Skip to content

Commit b1d545f

Browse files
refine payout handling
1 parent 0593091 commit b1d545f

File tree

4 files changed

+41
-11
lines changed

4 files changed

+41
-11
lines changed

contracts/components/Product.sol

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,33 @@ abstract contract Product is
194194
data);
195195
}
196196

197-
function _processPayout(
197+
function _newPayout(
198198
bytes32 processId,
199-
uint256 payoutId,
200-
bool isComplete,
199+
uint256 amount,
201200
bytes memory data
202201
)
203202
internal
203+
returns(uint256 payoutId)
204+
{
205+
payoutId = _productService.newPayout(processId, amount, data);
206+
}
207+
208+
function _processPayout(
209+
bytes32 processId,
210+
uint256 payoutId
211+
)
212+
internal
213+
returns(
214+
bool success,
215+
uint256 feeAmount,
216+
uint256 netPayoutAmount
217+
)
204218
{
205-
_productService.processPayout(processId, payoutId, isComplete, data);
219+
(
220+
success,
221+
feeAmount,
222+
netPayoutAmount
223+
) = _productService.processPayout(processId, payoutId);
206224
}
207225

208226
function _request(

contracts/modules/IPolicy.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ interface IPolicy {
5656
enum PolicyFlowState {Started, Paused, Finished}
5757
enum ApplicationState {Applied, Revoked, Underwritten, Declined}
5858
enum PolicyState {Active, Expired, Closed}
59-
enum ClaimState {Applied, Confirmed, Declined}
59+
enum ClaimState {Applied, Confirmed, Declined, Closed}
6060
enum PayoutState {Expected, PaidOut}
6161

6262
// Objects
@@ -84,15 +84,14 @@ interface IPolicy {
8484
uint256 premiumPaidAmount;
8585
uint256 claimsCount;
8686
uint256 openClaimsCount;
87-
uint256 payoutsCount;
88-
uint256 openPayoutsCount;
8987
uint256 createdAt;
9088
uint256 updatedAt;
9189
}
9290

9391
struct Claim {
9492
ClaimState state;
9593
uint256 claimAmount;
94+
uint256 paidAmount;
9695
bytes data;
9796
uint256 createdAt;
9897
uint256 updatedAt;

contracts/modules/ITreasury.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ interface ITreasury {
6161
uint256 netPremiumAmount
6262
);
6363

64+
function processPayout(bytes32 processId, uint256 payoutId) external
65+
returns(
66+
bool success,
67+
uint256 feeAmount,
68+
uint256 netPayoutAmount
69+
);
70+
6471
function processCapital(uint256 bundleId, uint256 capitalAmount) external
6572
returns(
6673
bool success,

contracts/services/IProductService.sol

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,18 @@ interface IProductService {
4040
bytes calldata data
4141
) external returns(uint256 payoutId);
4242

43-
function processPayout(
43+
function newPayout(
4444
bytes32 processId,
45-
uint256 payoutId,
46-
bool isComplete,
45+
uint256 amount,
4746
bytes calldata data
48-
) external;
47+
) external returns(uint256 payoutId);
48+
49+
function processPayout(bytes32 processId, uint256 payoutId) external
50+
returns(
51+
bool success,
52+
uint256 feeAmount,
53+
uint256 netPayoutAmount
54+
);
4955

5056
function request(
5157
bytes32 processId,

0 commit comments

Comments
 (0)