@etherisc/gif-next 0.0.2-b16cd64-952 → 0.0.2-b20ce14-335
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +16 -0
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +346 -102
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +276 -289
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +2 -2
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +154 -40
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +62 -101
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +32 -32
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +8 -8
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +6 -6
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +71 -50
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +18 -10
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +108 -50
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +30 -26
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +284 -61
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +52 -8
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +42 -66
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +22 -34
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +37 -32
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +50 -0
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +173 -46
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +385 -22
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +120 -4
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +513 -62
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +65 -21
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +238 -26
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +60 -12
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +2 -2
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +2 -2
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +2 -2
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +2 -2
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +2 -2
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +2 -2
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +2 -2
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Amount.sol/AmountLib.dbg.json +1 -1
- package/artifacts/contracts/types/Amount.sol/AmountLib.json +52 -4
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.json +83 -4
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
- package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.json +116 -7
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.json +2 -2
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
- package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +1 -1
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +17 -4
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/contracts/components/Distribution.sol +6 -2
- package/contracts/components/IPoolComponent.sol +1 -1
- package/contracts/components/Pool.sol +3 -4
- package/contracts/components/Product.sol +137 -59
- package/contracts/instance/BundleManager.sol +3 -4
- package/contracts/instance/IInstance.sol +25 -21
- package/contracts/instance/IInstanceService.sol +0 -4
- package/contracts/instance/Instance.sol +85 -102
- package/contracts/instance/InstanceReader.sol +30 -4
- package/contracts/instance/InstanceService.sol +11 -28
- package/contracts/instance/base/Lifecycle.sol +12 -4
- package/contracts/instance/module/IPolicy.sol +11 -6
- package/contracts/instance/service/ApplicationService.sol +10 -5
- package/contracts/instance/service/BundleService.sol +21 -9
- package/contracts/instance/service/ClaimService.sol +111 -23
- package/contracts/instance/service/DistributionService.sol +14 -18
- package/contracts/instance/service/IApplicationService.sol +3 -7
- package/contracts/instance/service/IBundleService.sol +9 -0
- package/contracts/instance/service/IClaimService.sol +46 -15
- package/contracts/instance/service/IPolicyService.sol +72 -5
- package/contracts/instance/service/IPoolService.sol +3 -0
- package/contracts/instance/service/PolicyService.sol +282 -73
- package/contracts/instance/service/PoolService.sol +34 -1
- package/contracts/instance/service/ProductService.sol +1 -1
- package/contracts/types/Amount.sol +10 -0
- package/contracts/types/ClaimId.sol +25 -2
- package/contracts/types/ObjectType.sol +5 -5
- package/contracts/types/PayoutId.sol +33 -5
- package/contracts/types/StateId.sol +6 -2
- package/contracts/types/Timestamp.sol +5 -0
- package/package.json +1 -1
@@ -14,17 +14,21 @@ import {ISetup} from "../module/ISetup.sol";
|
|
14
14
|
|
15
15
|
import {TokenHandler} from "../../shared/TokenHandler.sol";
|
16
16
|
|
17
|
+
import {Amount, AmountLib} from "../../types/Amount.sol";
|
18
|
+
import {ClaimId, ClaimIdLib} from "../../types/ClaimId.sol";
|
17
19
|
import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
|
18
20
|
import {UFixed, UFixedLib} from "../../types/UFixed.sol";
|
19
|
-
import {ObjectType, APPLICATION, DISTRIBUTION, PRODUCT, POOL, POLICY, BUNDLE} from "../../types/ObjectType.sol";
|
20
|
-
import {APPLIED,
|
21
|
+
import {ObjectType, APPLICATION, DISTRIBUTION, PRODUCT, POOL, POLICY, BUNDLE, CLAIM} from "../../types/ObjectType.sol";
|
22
|
+
import {APPLIED, COLLATERALIZED, ACTIVE, KEEP_STATE, CLOSED, DECLINED, CONFIRMED} from "../../types/StateId.sol";
|
21
23
|
import {NftId, NftIdLib} from "../../types/NftId.sol";
|
24
|
+
import {PayoutId, PayoutIdLib} from "../../types/PayoutId.sol";
|
22
25
|
import {StateId} from "../../types/StateId.sol";
|
23
26
|
import {VersionPart} from "../../types/Version.sol";
|
24
27
|
|
25
28
|
import {ComponentService} from "../base/ComponentService.sol";
|
26
29
|
import {IApplicationService} from "./IApplicationService.sol";
|
27
30
|
import {IBundleService} from "./IBundleService.sol";
|
31
|
+
import {IClaimService} from "./IClaimService.sol";
|
28
32
|
import {IDistributionService} from "./IDistributionService.sol";
|
29
33
|
import {InstanceReader} from "../InstanceReader.sol";
|
30
34
|
import {IPolicyService} from "./IPolicyService.sol";
|
@@ -40,10 +44,11 @@ contract PolicyService is
|
|
40
44
|
using NftIdLib for NftId;
|
41
45
|
using TimestampLib for Timestamp;
|
42
46
|
|
43
|
-
IPoolService internal _poolService;
|
44
|
-
IBundleService internal _bundleService;
|
45
47
|
IApplicationService internal _applicationService;
|
48
|
+
IBundleService internal _bundleService;
|
49
|
+
IClaimService internal _claimService;
|
46
50
|
IDistributionService internal _distributionService;
|
51
|
+
IPoolService internal _poolService;
|
47
52
|
|
48
53
|
event LogProductServiceSender(address sender);
|
49
54
|
|
@@ -64,6 +69,7 @@ contract PolicyService is
|
|
64
69
|
VersionPart majorVersion = getVersion().toMajorPart();
|
65
70
|
_poolService = IPoolService(getRegistry().getServiceAddress(POOL(), majorVersion));
|
66
71
|
_bundleService = IBundleService(getRegistry().getServiceAddress(BUNDLE(), majorVersion));
|
72
|
+
_claimService = IClaimService(getRegistry().getServiceAddress(CLAIM(), majorVersion));
|
67
73
|
_applicationService = IApplicationService(getRegistry().getServiceAddress(APPLICATION(), majorVersion));
|
68
74
|
_distributionService = IDistributionService(getRegistry().getServiceAddress(DISTRIBUTION(), majorVersion));
|
69
75
|
|
@@ -82,32 +88,6 @@ contract PolicyService is
|
|
82
88
|
product = Product(productInfo.objectAddress);
|
83
89
|
}
|
84
90
|
|
85
|
-
// function _getAndVerifyUnderwritingSetup(
|
86
|
-
// IInstance instance,
|
87
|
-
// InstanceReader instanceReader,
|
88
|
-
// IPolicy.PolicyInfo memory policyInfo,
|
89
|
-
// ISetup.ProductSetupInfo memory productSetupInfo
|
90
|
-
// )
|
91
|
-
// internal
|
92
|
-
// view
|
93
|
-
// returns (
|
94
|
-
// NftId poolNftId,
|
95
|
-
// IComponents.PoolInfo memory poolInfo,
|
96
|
-
// NftId bundleNftId,
|
97
|
-
// IBundle.BundleInfo memory bundleInfo
|
98
|
-
// )
|
99
|
-
// {
|
100
|
-
// // check match between policy and bundle (via pool)
|
101
|
-
// poolNftId = productSetupInfo.poolNftId;
|
102
|
-
// bundleNftId = policyInfo.bundleNftId;
|
103
|
-
// bundleInfo = instanceReader.getBundleInfo(bundleNftId);
|
104
|
-
// require(bundleInfo.poolNftId == poolNftId, "BUNDLE_POOL_MISMATCH");
|
105
|
-
|
106
|
-
// // calculate required collateral
|
107
|
-
// IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
|
108
|
-
// poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
|
109
|
-
// }
|
110
|
-
|
111
91
|
|
112
92
|
function decline(
|
113
93
|
NftId policyNftId
|
@@ -120,7 +100,7 @@ contract PolicyService is
|
|
120
100
|
|
121
101
|
|
122
102
|
/// @dev underwites application which includes the locking of the required collateral from the pool.
|
123
|
-
function
|
103
|
+
function collateralize(
|
124
104
|
NftId applicationNftId, // = policyNftId
|
125
105
|
bool requirePremiumPayment,
|
126
106
|
Timestamp activateAt
|
@@ -134,12 +114,18 @@ contract PolicyService is
|
|
134
114
|
|
135
115
|
// check policy matches with calling product
|
136
116
|
IPolicy.PolicyInfo memory applicationInfo = instanceReader.getPolicyInfo(applicationNftId);
|
137
|
-
|
117
|
+
|
118
|
+
if (applicationInfo.productNftId != productNftId) {
|
119
|
+
revert ErrorPolicyServiceProductMismatch(applicationNftId, applicationInfo.productNftId, productNftId);
|
120
|
+
}
|
138
121
|
|
139
122
|
// check policy is in state applied
|
140
|
-
require(instanceReader.getPolicyState(applicationNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
|
123
|
+
// require(instanceReader.getPolicyState(applicationNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
|
124
|
+
if (instanceReader.getPolicyState(applicationNftId) != APPLIED()) {
|
125
|
+
revert ErrorPolicyServicePolicyStateNotApplied(applicationNftId);
|
126
|
+
}
|
141
127
|
|
142
|
-
StateId newPolicyState =
|
128
|
+
StateId newPolicyState = COLLATERALIZED();
|
143
129
|
|
144
130
|
// optional activation of policy
|
145
131
|
if(activateAt > zeroTimestamp()) {
|
@@ -269,6 +255,7 @@ contract PolicyService is
|
|
269
255
|
revert ErrorIPolicyServicePolicyAlreadyClosed(policyNftId);
|
270
256
|
}
|
271
257
|
|
258
|
+
// TODO consider to allow for underpaid premiums (with the effects of reducing max payouts accordingly)
|
272
259
|
if (policyInfo.premiumAmount != policyInfo.premiumPaidAmount) {
|
273
260
|
revert ErrorIPolicyServicePremiumNotFullyPaid(policyNftId, policyInfo.premiumAmount, policyInfo.premiumPaidAmount);
|
274
261
|
}
|
@@ -277,10 +264,6 @@ contract PolicyService is
|
|
277
264
|
revert ErrorIPolicyServiceOpenClaims(policyNftId, policyInfo.openClaimsCount);
|
278
265
|
}
|
279
266
|
|
280
|
-
if (TimestampLib.blockTimestamp().lte(policyInfo.expiredAt) && (policyInfo.payoutAmount < policyInfo.sumInsuredAmount)) {
|
281
|
-
revert ErrorIPolicyServicePolicyHasNotExpired(policyNftId, policyInfo.expiredAt);
|
282
|
-
}
|
283
|
-
|
284
267
|
policyInfo.closedAt = TimestampLib.blockTimestamp();
|
285
268
|
|
286
269
|
_poolService.releaseCollateral(
|
@@ -291,6 +274,205 @@ contract PolicyService is
|
|
291
274
|
instance.updatePolicy(policyNftId, policyInfo, CLOSED());
|
292
275
|
}
|
293
276
|
|
277
|
+
function submitClaim(
|
278
|
+
NftId policyNftId,
|
279
|
+
Amount claimAmount,
|
280
|
+
bytes memory claimData
|
281
|
+
)
|
282
|
+
external
|
283
|
+
virtual
|
284
|
+
returns (ClaimId claimId)
|
285
|
+
{
|
286
|
+
(
|
287
|
+
IInstance instance,
|
288
|
+
InstanceReader instanceReader,
|
289
|
+
IPolicy.PolicyInfo memory policyInfo
|
290
|
+
) = _verifyCallerWithPolicy(policyNftId);
|
291
|
+
|
292
|
+
// check policy is in its active period
|
293
|
+
if(policyInfo.activatedAt.eqz() || TimestampLib.blockTimestamp() >= policyInfo.expiredAt) {
|
294
|
+
revert ErrorPolicyServicePolicyNotOpen(policyNftId);
|
295
|
+
}
|
296
|
+
|
297
|
+
// check policy including this claim is still within sum insured
|
298
|
+
if(policyInfo.payoutAmount.toInt() + claimAmount.toInt() > policyInfo.sumInsuredAmount) {
|
299
|
+
revert ErrorPolicyServiceClaimExceedsSumInsured(
|
300
|
+
policyNftId,
|
301
|
+
AmountLib.toAmount(policyInfo.sumInsuredAmount),
|
302
|
+
AmountLib.toAmount(policyInfo.payoutAmount.toInt() + claimAmount.toInt()));
|
303
|
+
}
|
304
|
+
|
305
|
+
// create new claim
|
306
|
+
claimId = ClaimIdLib.toClaimId(policyInfo.claimsCount + 1);
|
307
|
+
_claimService.submit(instance, policyNftId, claimId, claimAmount, claimData);
|
308
|
+
|
309
|
+
// update and save policy info with instance
|
310
|
+
policyInfo.claimsCount += 1;
|
311
|
+
policyInfo.openClaimsCount += 1;
|
312
|
+
instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
313
|
+
|
314
|
+
emit LogPolicyServiceClaimSubmitted(policyNftId, claimId, claimAmount);
|
315
|
+
}
|
316
|
+
|
317
|
+
function confirmClaim(
|
318
|
+
NftId policyNftId,
|
319
|
+
ClaimId claimId,
|
320
|
+
Amount confirmedAmount
|
321
|
+
)
|
322
|
+
external
|
323
|
+
{
|
324
|
+
(
|
325
|
+
IInstance instance,
|
326
|
+
InstanceReader instanceReader,
|
327
|
+
IPolicy.PolicyInfo memory policyInfo
|
328
|
+
) = _verifyCallerWithPolicy(policyNftId);
|
329
|
+
|
330
|
+
// check/update claim info
|
331
|
+
_claimService.confirm(instance, instanceReader, policyNftId, claimId, confirmedAmount);
|
332
|
+
|
333
|
+
// update and save policy info with instance
|
334
|
+
instance.updatePolicy(policyNftId, policyInfo, CONFIRMED());
|
335
|
+
|
336
|
+
emit LogPolicyServiceClaimConfirmed(policyNftId, claimId, confirmedAmount);
|
337
|
+
}
|
338
|
+
|
339
|
+
function declineClaim(
|
340
|
+
NftId policyNftId,
|
341
|
+
ClaimId claimId
|
342
|
+
)
|
343
|
+
external
|
344
|
+
{
|
345
|
+
(
|
346
|
+
IInstance instance,
|
347
|
+
InstanceReader instanceReader,
|
348
|
+
IPolicy.PolicyInfo memory policyInfo
|
349
|
+
) = _verifyCallerWithPolicy(policyNftId);
|
350
|
+
|
351
|
+
// check/update claim info
|
352
|
+
_claimService.decline(instance, instanceReader, policyNftId, claimId);
|
353
|
+
|
354
|
+
// update and save policy info with instance
|
355
|
+
policyInfo.openClaimsCount -= 1;
|
356
|
+
instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
357
|
+
|
358
|
+
emit LogPolicyServiceClaimDeclined(policyNftId, claimId);
|
359
|
+
}
|
360
|
+
|
361
|
+
function closeClaim(
|
362
|
+
NftId policyNftId,
|
363
|
+
ClaimId claimId
|
364
|
+
)
|
365
|
+
external
|
366
|
+
{
|
367
|
+
(
|
368
|
+
IInstance instance,
|
369
|
+
InstanceReader instanceReader,
|
370
|
+
IPolicy.PolicyInfo memory policyInfo
|
371
|
+
) = _verifyCallerWithPolicy(policyNftId);
|
372
|
+
|
373
|
+
// check/update claim info
|
374
|
+
_claimService.close(instance, instanceReader, policyNftId, claimId);
|
375
|
+
|
376
|
+
// update and save policy info with instance
|
377
|
+
policyInfo.openClaimsCount -= 1;
|
378
|
+
instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
379
|
+
|
380
|
+
emit LogPolicyServiceClaimClosed(policyNftId, claimId);
|
381
|
+
}
|
382
|
+
|
383
|
+
function createPayout(
|
384
|
+
NftId policyNftId,
|
385
|
+
ClaimId claimId,
|
386
|
+
Amount amount,
|
387
|
+
bytes memory data
|
388
|
+
)
|
389
|
+
external
|
390
|
+
returns (PayoutId payoutId)
|
391
|
+
{
|
392
|
+
(
|
393
|
+
IInstance instance,
|
394
|
+
InstanceReader instanceReader,
|
395
|
+
IPolicy.PolicyInfo memory policyInfo
|
396
|
+
) = _verifyCallerWithPolicy(policyNftId);
|
397
|
+
|
398
|
+
IPolicy.ClaimInfo memory claimInfo = instanceReader.getClaimInfo(policyNftId, claimId);
|
399
|
+
StateId claimState = instanceReader.getClaimState(policyNftId, claimId);
|
400
|
+
|
401
|
+
// TODO add checks
|
402
|
+
// claim needs to be open
|
403
|
+
// claim.paidAmount + amount <= claim.claimAmount
|
404
|
+
|
405
|
+
// check/update claim info
|
406
|
+
uint8 claimNo = claimInfo.payoutsCount + 1;
|
407
|
+
payoutId = PayoutIdLib.toPayoutId(claimId, claimNo);
|
408
|
+
_claimService.createPayout(
|
409
|
+
instance,
|
410
|
+
policyNftId,
|
411
|
+
payoutId,
|
412
|
+
amount,
|
413
|
+
data);
|
414
|
+
|
415
|
+
// update and save policy info with instance
|
416
|
+
policyInfo.payoutAmount.add(amount);
|
417
|
+
instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
418
|
+
|
419
|
+
emit LogPolicyServicePayoutCreated(policyNftId, payoutId, amount);
|
420
|
+
}
|
421
|
+
|
422
|
+
function processPayout(
|
423
|
+
NftId policyNftId,
|
424
|
+
PayoutId payoutId
|
425
|
+
)
|
426
|
+
external
|
427
|
+
{
|
428
|
+
(
|
429
|
+
IInstance instance,
|
430
|
+
InstanceReader instanceReader,
|
431
|
+
IPolicy.PolicyInfo memory policyInfo
|
432
|
+
) = _verifyCallerWithPolicy(policyNftId);
|
433
|
+
|
434
|
+
// check/update claim info
|
435
|
+
(
|
436
|
+
Amount amount,
|
437
|
+
bool payoutIsClosingClaim
|
438
|
+
) = _claimService.processPayout(
|
439
|
+
instance,
|
440
|
+
instanceReader,
|
441
|
+
policyNftId,
|
442
|
+
payoutId);
|
443
|
+
|
444
|
+
// update policy info if affected by processed payout
|
445
|
+
if(payoutIsClosingClaim) {
|
446
|
+
policyInfo.openClaimsCount -= 1;
|
447
|
+
instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
|
448
|
+
}
|
449
|
+
|
450
|
+
emit LogPolicyServicePayoutProcessed(policyNftId, payoutId, amount);
|
451
|
+
}
|
452
|
+
|
453
|
+
function _verifyCallerWithPolicy(
|
454
|
+
NftId policyNftId
|
455
|
+
)
|
456
|
+
internal
|
457
|
+
returns (
|
458
|
+
IInstance instance,
|
459
|
+
InstanceReader instanceReader,
|
460
|
+
IPolicy.PolicyInfo memory policyInfo
|
461
|
+
)
|
462
|
+
{
|
463
|
+
NftId productNftId;
|
464
|
+
(productNftId,, instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
465
|
+
instanceReader = instance.getInstanceReader();
|
466
|
+
|
467
|
+
// check caller(product) policy match
|
468
|
+
policyInfo = instanceReader.getPolicyInfo(policyNftId);
|
469
|
+
if(policyInfo.productNftId != productNftId) {
|
470
|
+
revert ErrorPolicyServiceProductMismatch(policyNftId,
|
471
|
+
policyInfo.productNftId,
|
472
|
+
productNftId);
|
473
|
+
}
|
474
|
+
}
|
475
|
+
|
294
476
|
function _getPoolNftId(
|
295
477
|
IInstance instance,
|
296
478
|
NftId productNftId
|
@@ -308,53 +490,80 @@ contract PolicyService is
|
|
308
490
|
function _processPremiumByTreasury(
|
309
491
|
IInstance instance,
|
310
492
|
NftId policyNftId,
|
311
|
-
uint256
|
493
|
+
uint256 premiumExpectedAmount
|
312
494
|
)
|
313
495
|
internal
|
314
496
|
returns (uint256 netPremiumAmount)
|
315
497
|
{
|
316
498
|
// process token transfer(s)
|
317
|
-
if(
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
499
|
+
if(premiumExpectedAmount == 0) {
|
500
|
+
return 0;
|
501
|
+
}
|
502
|
+
|
503
|
+
NftId productNftId = getRegistry().getObjectInfo(policyNftId).parentNftId;
|
504
|
+
IPolicy.PolicyInfo memory policyInfo = instance.getInstanceReader().getPolicyInfo(policyNftId);
|
505
|
+
IPolicy.Premium memory premium = _applicationService.calculatePremium(
|
506
|
+
productNftId,
|
507
|
+
policyInfo.riskId,
|
508
|
+
policyInfo.sumInsuredAmount,
|
509
|
+
policyInfo.lifetime,
|
510
|
+
policyInfo.applicationData,
|
511
|
+
policyInfo.bundleNftId,
|
512
|
+
policyInfo.referralId
|
513
|
+
);
|
514
|
+
|
515
|
+
if (premium.premiumAmount != premiumExpectedAmount) {
|
516
|
+
revert ErrorIPolicyServicePremiumMismatch(
|
517
|
+
policyNftId,
|
518
|
+
premiumExpectedAmount,
|
519
|
+
premium.premiumAmount);
|
520
|
+
}
|
337
521
|
|
338
|
-
|
522
|
+
address policyOwner = getRegistry().ownerOf(policyNftId);
|
523
|
+
ISetup.ProductSetupInfo memory productSetupInfo = instance.getInstanceReader().getProductSetupInfo(productNftId);
|
524
|
+
TokenHandler tokenHandler = productSetupInfo.tokenHandler;
|
525
|
+
if (tokenHandler.getToken().allowance(policyOwner, address(tokenHandler)) < premium.premiumAmount) {
|
526
|
+
revert ErrorIPolicyServiceInsufficientAllowance(policyOwner, address(tokenHandler), premium.premiumAmount);
|
527
|
+
}
|
528
|
+
|
529
|
+
uint256 productFeeAmountToTransfer = premium.productFeeFixAmount + premium.productFeeVarAmount;
|
530
|
+
uint256 distributionFeeAmountToTransfer = premium.distributionFeeFixAmount + premium.distributionFeeVarAmount - premium.discountAmount;
|
531
|
+
uint256 poolFeeAmountToTransfer = premium.poolFeeFixAmount + premium.poolFeeVarAmount;
|
532
|
+
uint256 bundleFeeAmountToTransfer = premium.bundleFeeFixAmount + premium.bundleFeeVarAmount;
|
533
|
+
uint256 poolAmountToTransfer = premium.netPremiumAmount + poolFeeAmountToTransfer + bundleFeeAmountToTransfer;
|
534
|
+
netPremiumAmount = premium.netPremiumAmount;
|
535
|
+
|
536
|
+
// move product fee to product wallet
|
537
|
+
{
|
339
538
|
address productWallet = productSetupInfo.wallet;
|
340
|
-
|
341
|
-
|
342
|
-
}
|
343
|
-
tokenHandler.transfer(policyOwner, productWallet, premium.productFeeFixAmount + premium.productFeeVarAmount);
|
539
|
+
tokenHandler.transfer(policyOwner, productWallet, productFeeAmountToTransfer);
|
540
|
+
}
|
344
541
|
|
345
|
-
|
542
|
+
// move distribution fee to distribution wallet
|
543
|
+
{
|
346
544
|
ISetup.DistributionSetupInfo memory distributionSetupInfo = instance.getInstanceReader().getDistributionSetupInfo(productSetupInfo.distributionNftId);
|
347
545
|
address distributionWallet = distributionSetupInfo.wallet;
|
348
|
-
uint256 distributionFeeAmountToTransfer = premium.distributionFeeFixAmount + premium.distributionFeeVarAmount - premium.discountAmount;
|
349
546
|
tokenHandler.transfer(policyOwner, distributionWallet, distributionFeeAmountToTransfer);
|
350
547
|
_distributionService.processSale(productSetupInfo.distributionNftId, policyInfo.referralId, premium, distributionFeeAmountToTransfer);
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
548
|
+
}
|
549
|
+
|
550
|
+
// move netpremium, bundleFee and poolFee to pool wallet
|
551
|
+
{
|
552
|
+
address poolWallet = instance.getInstanceReader().getComponentInfo(productSetupInfo.poolNftId).wallet;
|
553
|
+
tokenHandler.transfer(policyOwner, poolWallet, poolAmountToTransfer);
|
554
|
+
_poolService.processSale(policyInfo.bundleNftId, premium, poolAmountToTransfer);
|
555
|
+
}
|
556
|
+
|
557
|
+
// validate total amount transferred
|
558
|
+
{
|
559
|
+
uint256 totalTransferred = distributionFeeAmountToTransfer + poolAmountToTransfer + productFeeAmountToTransfer;
|
560
|
+
|
561
|
+
if (premium.premiumAmount != totalTransferred) {
|
562
|
+
revert ErrorPolicyServiceTransferredPremiumMismatch(
|
563
|
+
policyNftId,
|
564
|
+
premium.premiumAmount,
|
565
|
+
totalTransferred);
|
566
|
+
}
|
358
567
|
}
|
359
568
|
|
360
569
|
// TODO: add logging
|
@@ -13,7 +13,7 @@ import {IVersionable} from "../../shared/IVersionable.sol";
|
|
13
13
|
import {Versionable} from "../../shared/Versionable.sol";
|
14
14
|
import {INftOwnable} from "../../shared/INftOwnable.sol";
|
15
15
|
|
16
|
-
import {Amount} from "../../types/Amount.sol";
|
16
|
+
import {Amount, AmountLib} from "../../types/Amount.sol";
|
17
17
|
import {Fee, FeeLib} from "../../types/Fee.sol";
|
18
18
|
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
19
19
|
import {ObjectType, POOL, BUNDLE} from "../../types/ObjectType.sol";
|
@@ -44,6 +44,7 @@ contract PoolService is
|
|
44
44
|
IPoolService
|
45
45
|
{
|
46
46
|
using NftIdLib for NftId;
|
47
|
+
using AmountLib for Amount;
|
47
48
|
|
48
49
|
IBundleService internal _bundleService;
|
49
50
|
|
@@ -228,6 +229,38 @@ contract PoolService is
|
|
228
229
|
emit LogPoolServiceBundleClosed(instance.getNftId(), poolNftId, bundleNftId);
|
229
230
|
}
|
230
231
|
|
232
|
+
function processSale(
|
233
|
+
NftId bundleNftId,
|
234
|
+
IPolicy.Premium memory premium,
|
235
|
+
uint256 actualAmountTransferred
|
236
|
+
)
|
237
|
+
external
|
238
|
+
virtual
|
239
|
+
{
|
240
|
+
IRegistry registry = getRegistry();
|
241
|
+
IRegistry.ObjectInfo memory bundleObjectInfo = registry.getObjectInfo(bundleNftId);
|
242
|
+
IRegistry.ObjectInfo memory poolObjectInfo = registry.getObjectInfo(bundleObjectInfo.parentNftId);
|
243
|
+
IRegistry.ObjectInfo memory instanceObjectInfo = registry.getObjectInfo(poolObjectInfo.parentNftId);
|
244
|
+
IInstance instance = IInstance(instanceObjectInfo.objectAddress);
|
245
|
+
|
246
|
+
Amount poolFeeAmount = AmountLib.toAmount(premium.poolFeeFixAmount + premium.poolFeeVarAmount);
|
247
|
+
Amount bundleFeeAmount = AmountLib.toAmount(premium.bundleFeeFixAmount + premium.bundleFeeVarAmount);
|
248
|
+
Amount expectedTransferAmount = AmountLib.toAmount(premium.netPremiumAmount).add(poolFeeAmount).add(bundleFeeAmount);
|
249
|
+
if (! AmountLib.toAmount(actualAmountTransferred).eq(expectedTransferAmount)) {
|
250
|
+
revert ErrorPoolServiceInvalidTransferAmount(expectedTransferAmount, AmountLib.toAmount(actualAmountTransferred));
|
251
|
+
}
|
252
|
+
|
253
|
+
// update pool fee balance
|
254
|
+
if (poolFeeAmount.gtz()) {
|
255
|
+
IComponents.ComponentInfo memory poolComponentInfo = instance.getInstanceReader().getComponentInfo(poolObjectInfo.nftId);
|
256
|
+
poolComponentInfo.feeAmount = poolComponentInfo.feeAmount.add(poolFeeAmount);
|
257
|
+
instance.updatePoolSetup(poolObjectInfo.nftId, poolComponentInfo, KEEP_STATE());
|
258
|
+
}
|
259
|
+
|
260
|
+
if (bundleFeeAmount.gtz()) {
|
261
|
+
_bundleService.updateBundleFees(instance, bundleNftId, bundleFeeAmount);
|
262
|
+
}
|
263
|
+
}
|
231
264
|
|
232
265
|
function lockCollateral(
|
233
266
|
IInstance instance,
|
@@ -24,7 +24,7 @@ import {Timestamp, zeroTimestamp} from "../../types/Timestamp.sol";
|
|
24
24
|
import {UFixed, UFixedLib} from "../../types/UFixed.sol";
|
25
25
|
import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
|
26
26
|
import {ObjectType, PRODUCT, POOL, POLICY} from "../../types/ObjectType.sol";
|
27
|
-
import {APPLIED,
|
27
|
+
import {APPLIED, ACTIVE, KEEP_STATE} from "../../types/StateId.sol";
|
28
28
|
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
29
29
|
import {Fee, FeeLib} from "../../types/Fee.sol";
|
30
30
|
import {ReferralId} from "../../types/Referral.sol";
|
@@ -9,6 +9,7 @@ using {
|
|
9
9
|
AmountLib.eqz,
|
10
10
|
AmountLib.gtz,
|
11
11
|
AmountLib.toInt,
|
12
|
+
AmountLib.add,
|
12
13
|
AmountLib.toUFixed
|
13
14
|
} for Amount global;
|
14
15
|
|
@@ -40,11 +41,20 @@ library AmountLib {
|
|
40
41
|
return Amount.unwrap(amount) == 0;
|
41
42
|
}
|
42
43
|
|
44
|
+
/// @dev return true if amount1 equals amount2
|
45
|
+
function eq(Amount amount1, Amount amount2) public pure returns (bool) {
|
46
|
+
return Amount.unwrap(amount1) == Amount.unwrap(amount2);
|
47
|
+
}
|
48
|
+
|
43
49
|
/// @dev return true if amount is larger than 0
|
44
50
|
function gtz(Amount amount) public pure returns (bool) {
|
45
51
|
return Amount.unwrap(amount) > 0;
|
46
52
|
}
|
47
53
|
|
54
|
+
function add(Amount a1, Amount a2) public pure returns (Amount) {
|
55
|
+
return Amount.wrap(Amount.unwrap(a1) + Amount.unwrap(a2));
|
56
|
+
}
|
57
|
+
|
48
58
|
function toInt(Amount amount) public pure returns (uint256) {
|
49
59
|
return uint256(uint96(Amount.unwrap(amount)));
|
50
60
|
}
|
@@ -4,13 +4,18 @@ pragma solidity ^0.8.20;
|
|
4
4
|
// uint16 allows for 65'535 claims per policy
|
5
5
|
type ClaimId is uint16;
|
6
6
|
|
7
|
+
import {CLAIM} from "./ObjectType.sol";
|
8
|
+
import {Key32, KeyId, Key32Lib} from "./Key32.sol";
|
9
|
+
import {NftId} from "./NftId.sol";
|
10
|
+
|
7
11
|
// type bindings
|
8
12
|
using {
|
9
13
|
eqClaimId as ==,
|
10
14
|
neClaimId as !=,
|
11
15
|
ClaimIdLib.eqz,
|
12
16
|
ClaimIdLib.gtz,
|
13
|
-
ClaimIdLib.toInt
|
17
|
+
ClaimIdLib.toInt,
|
18
|
+
ClaimIdLib.toKey32
|
14
19
|
} for ClaimId global;
|
15
20
|
|
16
21
|
|
@@ -25,10 +30,14 @@ function neClaimId(ClaimId a, ClaimId b) pure returns (bool isDifferent) {
|
|
25
30
|
|
26
31
|
// library functions that operate on user defined type
|
27
32
|
library ClaimIdLib {
|
28
|
-
/// @dev
|
33
|
+
/// @dev claim id min value (0), use only for non-initialized values
|
29
34
|
function zero() public pure returns (ClaimId) {
|
30
35
|
return ClaimId.wrap(0);
|
31
36
|
}
|
37
|
+
/// @dev claim id max value (2**16-1), use only for non-initialized values
|
38
|
+
function max() public pure returns (ClaimId) {
|
39
|
+
return ClaimId.wrap(type(uint16).max);
|
40
|
+
}
|
32
41
|
|
33
42
|
/// @dev Converts an uint into a ClaimId.
|
34
43
|
function toClaimId(uint256 a) public pure returns (ClaimId) {
|
@@ -40,6 +49,20 @@ library ClaimIdLib {
|
|
40
49
|
return uint16(ClaimId.unwrap(a));
|
41
50
|
}
|
42
51
|
|
52
|
+
/// @dev Converts the ClaimId and NftId to a Key32.
|
53
|
+
function toKey32(ClaimId claimId, NftId policyNftId) public pure returns (Key32) {
|
54
|
+
return Key32Lib.toKey32(CLAIM(), toKeyId(claimId, policyNftId));
|
55
|
+
}
|
56
|
+
|
57
|
+
/// @dev Converts the ClaimId and NftId to a Key32.
|
58
|
+
function toKeyId(ClaimId claimId, NftId policyNftId) public pure returns (KeyId) {
|
59
|
+
return KeyId.wrap(
|
60
|
+
bytes31(
|
61
|
+
bytes14(
|
62
|
+
uint112(
|
63
|
+
NftId.unwrap(policyNftId) << 16 + ClaimId.unwrap(claimId)))));
|
64
|
+
}
|
65
|
+
|
43
66
|
/// @dev Returns true if the value is non-zero (> 0).
|
44
67
|
function gtz(ClaimId a) public pure returns (bool) {
|
45
68
|
return ClaimId.unwrap(a) > 0;
|
@@ -86,6 +86,10 @@ function POOL() pure returns (ObjectType) {
|
|
86
86
|
return toObjectType(140);
|
87
87
|
}
|
88
88
|
|
89
|
+
function BUNDLE() pure returns (ObjectType) {
|
90
|
+
return toObjectType(220);
|
91
|
+
}
|
92
|
+
|
89
93
|
function RISK() pure returns (ObjectType) {
|
90
94
|
return toObjectType(200);
|
91
95
|
}
|
@@ -102,12 +106,8 @@ function CLAIM() pure returns (ObjectType) {
|
|
102
106
|
return toObjectType(212);
|
103
107
|
}
|
104
108
|
|
105
|
-
function BUNDLE() pure returns (ObjectType) {
|
106
|
-
return toObjectType(220);
|
107
|
-
}
|
108
|
-
|
109
109
|
function PAYOUT() pure returns (ObjectType) {
|
110
|
-
return toObjectType(
|
110
|
+
return toObjectType(213);
|
111
111
|
}
|
112
112
|
|
113
113
|
/// @dev Converts the uint8 to a ObjectType.
|