@etherisc/gif-next 0.0.2-eb98db7-932 → 0.0.2-ebf1a6b-485
Sign up to get free protection for your applications and to get access to all the features.
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/Component.json +10 -89
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +67 -134
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IComponent.sol/IComponent.json +7 -73
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +46 -117
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +238 -96
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +11 -145
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +241 -112
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +15 -162
- 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 +84 -146
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +11 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +149 -211
- 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 +79 -110
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +44 -33
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +17 -17
- 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/ComponentService.sol/ComponentService.json +12 -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 +2 -2
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- 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/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 +172 -62
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +33 -25
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +34 -23
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +9 -9
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +14 -3
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +2 -2
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +535 -69
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +96 -32
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +121 -27
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +17 -6
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +11 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +344 -6
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +11 -64
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +11 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +11 -0
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +48 -157
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +19 -47
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +22 -11
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +6 -6
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +14 -3
- 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/IRegistryService.sol/IRegistryService.json +11 -0
- 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 +24 -13
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +7 -7
- 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/IService.sol/IService.json +11 -0
- 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 +3 -3
- 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/Service.sol/Service.json +12 -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 +3 -3
- 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 +14 -3
- 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/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/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- 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/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- 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/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- 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 +4 -0
- package/artifacts/contracts/types/Seconds.sol/SecondsLib.json +124 -0
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +25 -7
- 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/Component.sol +68 -88
- package/contracts/components/Distribution.sol +12 -6
- package/contracts/components/IComponent.sol +31 -17
- package/contracts/components/IDistributionComponent.sol +1 -14
- package/contracts/components/IPoolComponent.sol +89 -25
- package/contracts/components/IProductComponent.sol +3 -2
- package/contracts/components/Pool.sol +216 -92
- package/contracts/components/Product.sol +24 -20
- package/contracts/instance/BundleManager.sol +1 -1
- package/contracts/instance/InstanceService.sol +15 -1
- package/contracts/instance/module/IBundle.sol +2 -1
- package/contracts/instance/module/IDistribution.sol +2 -1
- package/contracts/instance/module/IPolicy.sol +26 -1
- package/contracts/instance/module/ISetup.sol +5 -7
- package/contracts/instance/service/ApplicationService.sol +121 -40
- package/contracts/instance/service/BundleService.sol +4 -3
- package/contracts/instance/service/DistributionService.sol +91 -43
- package/contracts/instance/service/IApplicationService.sol +7 -7
- package/contracts/instance/service/IBundleService.sol +3 -2
- package/contracts/instance/service/IDistributionService.sol +15 -2
- package/contracts/instance/service/IPolicyService.sol +1 -20
- package/contracts/instance/service/PolicyService.sol +31 -105
- package/contracts/registry/RegistryService.sol +5 -5
- package/contracts/shared/IService.sol +2 -0
- package/contracts/shared/Registerable.sol +2 -2
- package/contracts/types/RoleId.sol +7 -2
- package/contracts/types/Seconds.sol +54 -0
- package/contracts/types/Timestamp.sol +12 -13
- package/package.json +1 -1
@@ -5,46 +5,95 @@ import {Fee} from "../types/Fee.sol";
|
|
5
5
|
import {IComponent} from "./IComponent.sol";
|
6
6
|
import {ISetup} from "../instance/module/ISetup.sol";
|
7
7
|
import {NftId} from "../types/NftId.sol";
|
8
|
+
import {RoleId} from "../types/RoleId.sol";
|
9
|
+
import {Seconds} from "../types/Seconds.sol";
|
8
10
|
import {UFixed} from "../types/UFixed.sol";
|
9
11
|
|
10
12
|
/// @dev pool components hold and manage the collateral to cover active policies
|
11
13
|
/// pools come in different flavors
|
12
14
|
interface IPoolComponent is IComponent {
|
13
15
|
|
14
|
-
|
16
|
+
error ErrorPoolNotBundleOwner(NftId bundleNftId, address caller);
|
17
|
+
error ErrorPoolNotPoolService(address caller);
|
15
18
|
|
16
|
-
error
|
19
|
+
error ErrorPoolApplicationBundleMismatch(NftId applicationNftId);
|
20
|
+
error ErrorPoolBundleOwnerRoleAlreadySet();
|
17
21
|
|
18
|
-
|
22
|
+
event LogPoolVerifiedByPool(address pool, NftId applicationNftId, uint256 collateralizationAmount);
|
23
|
+
event LogPoolBundleMaxCapitalAmountUpdated(uint256 previousMaxCapitalAmount, uint256 currentMaxCapitalAmount);
|
24
|
+
event LogPoolBundleOwnerRoleSet(RoleId bundleOwnerRole);
|
19
25
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
26
|
+
/// @dev increases the staked tokens by the specified amount
|
27
|
+
/// only the bundle owner may stake tokens
|
28
|
+
/// bundle MUST be in active or locked state
|
29
|
+
function stake(NftId bundleNftId, uint256 amount) external;
|
30
|
+
|
31
|
+
/// @dev decreases the staked tokens by the specified amount
|
32
|
+
/// only the bundle owner may unstake tokens from the bundle
|
33
|
+
/// bundle MUST be in active, locked or closed state
|
34
|
+
function unstake(NftId bundleNftId, uint256 amount) external;
|
35
|
+
|
36
|
+
/// @dev extends the bundle lifetime of the bundle by the specified time
|
37
|
+
/// only the bundle owner may extend the bundle's lifetime
|
38
|
+
/// bundle MUST be in active or locked state
|
39
|
+
function extend(NftId bundleNftId, Seconds lifetimeExtension) external;
|
40
|
+
|
41
|
+
/// @dev locks the specified bundle
|
42
|
+
/// a bundle to be locked MUST be in active state
|
43
|
+
/// locked bundles may not be used to underwrite any new policy
|
44
|
+
function lockBundle(NftId bundleNftId) external;
|
45
|
+
|
46
|
+
/// @dev unlocks the specified bundle
|
47
|
+
/// a bundle to be unlocked MUST be in locked state
|
48
|
+
function unlockBundle(NftId bundleNftId) external;
|
25
49
|
|
26
|
-
/// @dev
|
50
|
+
/// @dev close the specified bundle
|
51
|
+
/// a bundle to be closed MUST be in active or locked state
|
52
|
+
/// to close a bundle all all linked policies MUST be in closed state as well
|
53
|
+
/// closing a bundle finalizes the bundle bookkeeping including overall profit calculation
|
54
|
+
/// once a bundle is closed this action cannot be reversed
|
55
|
+
function close(NftId bundleNftId) external;
|
56
|
+
|
57
|
+
/// @dev sets the fee for the specified bundle
|
58
|
+
/// the fee is added on top of the poolFee and deducted from the premium amounts
|
27
59
|
/// via these fees individual bundler owner may earn income per policy in the context of peer to peer pools
|
28
60
|
function setBundleFee(
|
29
61
|
NftId bundleNftId,
|
30
62
|
Fee memory fee
|
31
63
|
) external;
|
32
64
|
|
65
|
+
/// @dev sets the maximum overall capital amound held by this pool
|
66
|
+
/// function may only be called by pool owner
|
67
|
+
function setMaxCapitalAmount(uint256 maxCapitalAmount) external;
|
68
|
+
|
69
|
+
/// @dev sets the required role to create/own bundles
|
70
|
+
/// may only be called once after setting up a pool
|
71
|
+
/// may only be called by pool owner
|
72
|
+
function setBundleOwnerRole(RoleId bundleOwnerRole) external;
|
73
|
+
|
74
|
+
/// @dev update pool fees to the specified values
|
75
|
+
/// pool fees: are deducted from the premium amount and goes to the pool owner
|
76
|
+
/// staking fees: are deducted from the staked tokens by a bundle owner and goes to the pool owner
|
77
|
+
/// performance fees: when a bundle is closed a bundle specific profit is calculated
|
78
|
+
/// the performance fee is deducted from this profit and goes to the pool owner
|
79
|
+
function setFees(
|
80
|
+
Fee memory poolFee,
|
81
|
+
Fee memory stakingFee,
|
82
|
+
Fee memory performanceFee
|
83
|
+
) external;
|
84
|
+
|
33
85
|
/// @dev this is a callback function that is called by the product service when underwriting a policy.
|
34
86
|
/// the pool has the option to check the details and object to underwriting by reverting.
|
35
87
|
/// the function is only called for "active" pools that ask to be involved/notified
|
36
88
|
/// by product related state changes.
|
37
89
|
function verifyApplication(
|
38
90
|
NftId applicationNftId,
|
39
|
-
bytes memory
|
91
|
+
bytes memory applicationData,
|
92
|
+
NftId bundleNftId,
|
40
93
|
bytes memory bundleFilter,
|
41
94
|
uint256 collateralizationAmount
|
42
95
|
) external;
|
43
96
|
|
44
|
-
function lockBundle(NftId bundleNftId) external;
|
45
|
-
|
46
|
-
function unlockBundle(NftId bundleNftId) external;
|
47
|
-
|
48
97
|
/// @dev defines the multiplier to calculate the required collateral to cover a given sum insured amount
|
49
98
|
/// default implementation returns 100%
|
50
99
|
function getCollateralizationLevel() external view returns (UFixed collateralizationLevel);
|
@@ -54,12 +103,6 @@ interface IPoolComponent is IComponent {
|
|
54
103
|
/// default implementation returns 100%
|
55
104
|
function getRetentionLevel() external view returns (UFixed retentionLevel);
|
56
105
|
|
57
|
-
/// @dev declares if pool intercept transfers of bundle nft ids
|
58
|
-
/// - yes: pool may block transfer of bundle ownership or simply updates some bookkeeping related to bundle ownership. callback function is nftTransferFrom
|
59
|
-
/// - no: pool is not involved in transfer of bundle ownership
|
60
|
-
/// default implementation returns false (no)
|
61
|
-
function isInterceptingBundleTransfers() external view returns (bool);
|
62
|
-
|
63
106
|
/// @dev declares if pool relies on external management of collateral (yes/no):
|
64
107
|
/// - yes: underwriting of new policies does not require an actual token balance, instead it is assumed that the pool owner will manage funds externally and inject enough tokens to allow process confirmed payouts
|
65
108
|
/// - no: the pool smart contract ensures that the necessary capacity of the pool prior to underwriting.
|
@@ -72,16 +115,37 @@ interface IPoolComponent is IComponent {
|
|
72
115
|
/// default implementation returnsfalse (no)
|
73
116
|
function isVerifyingApplications() external view returns (bool);
|
74
117
|
|
75
|
-
/// @dev returns
|
76
|
-
|
118
|
+
/// @dev returns the maximum overall capital amound held by this pool
|
119
|
+
function getMaxCapitalAmount() external view returns (uint256 maxCapitalAmount);
|
120
|
+
|
121
|
+
/// @dev declares if pool intercept transfers of bundle nft ids
|
122
|
+
/// - yes: pool may block transfer of bundle ownership or simply updates some bookkeeping related to bundle ownership. callback function is nftTransferFrom
|
123
|
+
/// - no: pool is not involved in transfer of bundle ownership
|
124
|
+
/// default implementation returns false (no)
|
125
|
+
function isInterceptingBundleTransfers() external view returns (bool);
|
126
|
+
|
127
|
+
/// @dev returns the required role for bundle owners
|
128
|
+
/// default emplementation returns PUBLIC_ROLE
|
129
|
+
/// the PUBLIC_ROLE role implies that no specific roole is required for bundle owners
|
130
|
+
function getBundleOwnerRole() external view returns (RoleId bundleOwnerRole);
|
131
|
+
|
132
|
+
/// @dev returns true iff the application matches with the bundle
|
77
133
|
/// this is a callback function that is only called if a pool declares itself as a verifying pool
|
78
134
|
/// default implementation returns true
|
79
|
-
function
|
80
|
-
|
81
|
-
bytes memory
|
135
|
+
function applicationMatchesBundle(
|
136
|
+
NftId applicationNftId,
|
137
|
+
bytes memory applicationData,
|
138
|
+
NftId bundleNftId,
|
139
|
+
bytes memory bundleFilter,
|
140
|
+
uint256 collateralizationAmount
|
82
141
|
)
|
83
142
|
external
|
84
143
|
view
|
85
144
|
returns (bool isMatching);
|
86
145
|
|
146
|
+
/// @dev returns setup infos for this pool
|
147
|
+
/// when registered with an instance the setup info is obtained from the data stored in the instance
|
148
|
+
/// when not registered the function returns the initial setup info
|
149
|
+
function getSetupInfo() external view returns (ISetup.PoolSetupInfo memory setupInfo);
|
150
|
+
|
87
151
|
}
|
@@ -7,6 +7,7 @@ import {ISetup} from "../instance/module/ISetup.sol";
|
|
7
7
|
import {NftId} from "../types/NftId.sol";
|
8
8
|
import {ReferralId} from "../types/Referral.sol";
|
9
9
|
import {RiskId} from "../types/RiskId.sol";
|
10
|
+
import {Seconds} from "../types/Seconds.sol";
|
10
11
|
|
11
12
|
interface IProductComponent is IComponent {
|
12
13
|
|
@@ -20,7 +21,7 @@ interface IProductComponent is IComponent {
|
|
20
21
|
function calculatePremium(
|
21
22
|
uint256 sumInsuredAmount,
|
22
23
|
RiskId riskId,
|
23
|
-
|
24
|
+
Seconds lifetime,
|
24
25
|
bytes memory applicationData,
|
25
26
|
NftId bundleNftId,
|
26
27
|
ReferralId referralId
|
@@ -29,7 +30,7 @@ interface IProductComponent is IComponent {
|
|
29
30
|
function calculateNetPremium(
|
30
31
|
uint256 sumInsuredAmount,
|
31
32
|
RiskId riskId,
|
32
|
-
|
33
|
+
Seconds lifetime,
|
33
34
|
bytes memory applicationData
|
34
35
|
) external view returns (uint256 netPremiumAmount);
|
35
36
|
|
@@ -1,19 +1,19 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {
|
5
|
-
import {IPoolService} from "../instance/service/IPoolService.sol";
|
6
|
-
import {IBundleService} from "../instance/service/IBundleService.sol";
|
7
|
-
import {NftId, NftIdLib} from "../types/NftId.sol";
|
4
|
+
import {Component} from "./Component.sol";
|
8
5
|
import {Fee, FeeLib} from "../types/Fee.sol";
|
9
|
-
import {
|
6
|
+
import {IBundleService} from "../instance/service/IBundleService.sol";
|
7
|
+
import {InstanceReader} from "../instance/InstanceReader.sol";
|
10
8
|
import {IPoolComponent} from "./IPoolComponent.sol";
|
11
|
-
import {
|
12
|
-
import {TokenHandler} from "../shared/TokenHandler.sol";
|
13
|
-
import {ISetup} from "../instance/module/ISetup.sol";
|
14
|
-
|
9
|
+
import {IPoolService} from "../instance/service/IPoolService.sol";
|
15
10
|
import {ISetup} from "../instance/module/ISetup.sol";
|
16
|
-
import {
|
11
|
+
import {NftId, NftIdLib} from "../types/NftId.sol";
|
12
|
+
import {POOL} from "../types/ObjectType.sol";
|
13
|
+
import {RoleId, PUBLIC_ROLE} from "../types/RoleId.sol";
|
14
|
+
import {Seconds} from "../types/Seconds.sol";
|
15
|
+
import {TokenHandler} from "../shared/TokenHandler.sol";
|
16
|
+
import {UFixed} from "../types/UFixed.sol";
|
17
17
|
|
18
18
|
|
19
19
|
abstract contract Pool is
|
@@ -26,11 +26,14 @@ abstract contract Pool is
|
|
26
26
|
struct PoolStorage {
|
27
27
|
UFixed _collateralizationLevel;
|
28
28
|
UFixed _retentionLevel;
|
29
|
-
|
29
|
+
uint256 _maxCapitalAmount;
|
30
|
+
|
30
31
|
bool _isExternallyManaged;
|
31
|
-
bool _isInterceptingBundleTransfers;
|
32
32
|
bool _isVerifyingApplications;
|
33
33
|
|
34
|
+
RoleId _bundleOwnerRole;
|
35
|
+
bool _isInterceptingBundleTransfers;
|
36
|
+
|
34
37
|
Fee _initialPoolFee;
|
35
38
|
Fee _initialStakingFee;
|
36
39
|
Fee _initialPerformanceFee;
|
@@ -42,6 +45,15 @@ abstract contract Pool is
|
|
42
45
|
IBundleService _bundleService;
|
43
46
|
}
|
44
47
|
|
48
|
+
|
49
|
+
modifier onlyBundleOwner(NftId bundleNftId) {
|
50
|
+
if(msg.sender != getRegistry().ownerOf(bundleNftId)) {
|
51
|
+
revert ErrorPoolNotBundleOwner(bundleNftId, msg.sender);
|
52
|
+
}
|
53
|
+
_;
|
54
|
+
}
|
55
|
+
|
56
|
+
|
45
57
|
modifier onlyPoolService() {
|
46
58
|
if(msg.sender != address(_getPoolStorage()._poolService)) {
|
47
59
|
revert ErrorPoolNotPoolService(msg.sender);
|
@@ -54,7 +66,6 @@ abstract contract Pool is
|
|
54
66
|
address registry,
|
55
67
|
NftId instanceNftId,
|
56
68
|
string memory name,
|
57
|
-
// TODO refactor into tokenNftId
|
58
69
|
address token,
|
59
70
|
bool isInterceptingNftTransfers,
|
60
71
|
bool isExternallyManaging,
|
@@ -62,19 +73,21 @@ abstract contract Pool is
|
|
62
73
|
UFixed collateralizationLevel,
|
63
74
|
UFixed retentionLevel,
|
64
75
|
address initialOwner,
|
65
|
-
bytes memory data
|
76
|
+
bytes memory registryData // writeonly data that will saved in the object info record of the registry
|
66
77
|
)
|
67
78
|
public
|
68
79
|
virtual
|
69
80
|
onlyInitializing()
|
70
81
|
{
|
71
|
-
initializeComponent(registry, instanceNftId, name, token, POOL(), isInterceptingNftTransfers, initialOwner,
|
82
|
+
initializeComponent(registry, instanceNftId, name, token, POOL(), isInterceptingNftTransfers, initialOwner, registryData);
|
72
83
|
|
73
84
|
PoolStorage storage $ = _getPoolStorage();
|
74
85
|
// TODO add validation
|
75
86
|
$._tokenHandler = new TokenHandler(token);
|
87
|
+
$._maxCapitalAmount = type(uint256).max;
|
76
88
|
$._isExternallyManaged = isExternallyManaging;
|
77
89
|
$._isVerifyingApplications = isVerifying;
|
90
|
+
$._bundleOwnerRole = PUBLIC_ROLE();
|
78
91
|
$._collateralizationLevel = collateralizationLevel;
|
79
92
|
$._retentionLevel = retentionLevel;
|
80
93
|
$._initialPoolFee = FeeLib.zeroFee();
|
@@ -86,66 +99,121 @@ abstract contract Pool is
|
|
86
99
|
registerInterface(type(IPoolComponent).interfaceId);
|
87
100
|
}
|
88
101
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
function verifyApplication(
|
94
|
-
NftId applicationNftId,
|
95
|
-
bytes memory applicationData,
|
96
|
-
bytes memory bundleFilter,
|
97
|
-
uint256 collateralizationAmount
|
102
|
+
|
103
|
+
function stake(
|
104
|
+
NftId bundleNftId,
|
105
|
+
uint256 amount
|
98
106
|
)
|
99
|
-
|
107
|
+
public
|
108
|
+
virtual
|
100
109
|
restricted()
|
101
|
-
|
110
|
+
onlyBundleOwner(bundleNftId)
|
102
111
|
{
|
103
|
-
|
104
|
-
policyMatchesBundle(applicationData, bundleFilter),
|
105
|
-
"ERROR:POL-020:POLICY_BUNDLE_MISMATCH"
|
106
|
-
);
|
107
|
-
|
108
|
-
emit LogUnderwrittenByPool(applicationNftId, collateralizationAmount, address(this));
|
112
|
+
// TODO add implementation
|
109
113
|
}
|
110
114
|
|
111
115
|
|
112
|
-
function
|
113
|
-
|
116
|
+
function unstake(
|
117
|
+
NftId bundleNftId,
|
118
|
+
uint256 amount
|
119
|
+
)
|
120
|
+
public
|
121
|
+
virtual
|
122
|
+
restricted()
|
123
|
+
onlyBundleOwner(bundleNftId)
|
124
|
+
{
|
125
|
+
// TODO add implementation
|
114
126
|
}
|
115
127
|
|
116
128
|
|
117
|
-
function
|
118
|
-
|
129
|
+
function extend(
|
130
|
+
NftId bundleNftId,
|
131
|
+
Seconds lifetimeExtension
|
132
|
+
)
|
133
|
+
public
|
134
|
+
virtual
|
135
|
+
restricted()
|
136
|
+
onlyBundleOwner(bundleNftId)
|
137
|
+
{
|
138
|
+
// TODO add implementation
|
119
139
|
}
|
120
140
|
|
121
141
|
|
122
|
-
function
|
123
|
-
|
142
|
+
function lockBundle(NftId bundleNftId)
|
143
|
+
public
|
144
|
+
virtual
|
145
|
+
restricted()
|
146
|
+
onlyBundleOwner(bundleNftId)
|
147
|
+
{
|
148
|
+
_getPoolStorage()._bundleService.lockBundle(bundleNftId);
|
124
149
|
}
|
125
150
|
|
126
151
|
|
127
|
-
function
|
128
|
-
|
152
|
+
function unlockBundle(NftId bundleNftId)
|
153
|
+
public
|
154
|
+
virtual
|
155
|
+
restricted()
|
156
|
+
onlyBundleOwner(bundleNftId)
|
157
|
+
{
|
158
|
+
_getPoolStorage()._bundleService.unlockBundle(bundleNftId);
|
129
159
|
}
|
130
160
|
|
131
161
|
|
132
|
-
function
|
133
|
-
|
162
|
+
function close(NftId bundleNftId)
|
163
|
+
public
|
164
|
+
virtual
|
165
|
+
restricted()
|
166
|
+
onlyBundleOwner(bundleNftId)
|
167
|
+
{
|
168
|
+
// TODO add implementation
|
134
169
|
}
|
135
170
|
|
136
171
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
bytes memory, // policyData
|
141
|
-
bytes memory // bundleFilter
|
172
|
+
function setBundleFee(
|
173
|
+
NftId bundleNftId,
|
174
|
+
Fee memory fee
|
142
175
|
)
|
143
176
|
public
|
144
|
-
|
145
|
-
|
146
|
-
|
177
|
+
virtual
|
178
|
+
restricted()
|
179
|
+
onlyBundleOwner(bundleNftId)
|
147
180
|
{
|
148
|
-
|
181
|
+
_getPoolStorage()._bundleService.setBundleFee(bundleNftId, fee);
|
182
|
+
}
|
183
|
+
|
184
|
+
|
185
|
+
function setMaxCapitalAmount(uint256 maxCapitalAmount)
|
186
|
+
public
|
187
|
+
virtual
|
188
|
+
restricted()
|
189
|
+
onlyOwner()
|
190
|
+
{
|
191
|
+
// TODO refactor to use pool service
|
192
|
+
// _getPoolStorage()._poolService.setMaxCapitalAmount(...);
|
193
|
+
|
194
|
+
uint256 previousMaxCapitalAmount = _getPoolStorage()._maxCapitalAmount;
|
195
|
+
_getPoolStorage()._maxCapitalAmount = maxCapitalAmount;
|
196
|
+
|
197
|
+
emit LogPoolBundleMaxCapitalAmountUpdated(previousMaxCapitalAmount, maxCapitalAmount);
|
198
|
+
}
|
199
|
+
|
200
|
+
|
201
|
+
function setBundleOwnerRole(RoleId bundleOwnerRole)
|
202
|
+
public
|
203
|
+
virtual
|
204
|
+
restricted()
|
205
|
+
onlyOwner()
|
206
|
+
{
|
207
|
+
// TODO refactor to use pool service
|
208
|
+
// _getPoolStorage()._poolService.setBundleOwnerRole(...);
|
209
|
+
|
210
|
+
if(_getPoolStorage()._bundleOwnerRole != PUBLIC_ROLE()) {
|
211
|
+
revert ErrorPoolBundleOwnerRoleAlreadySet();
|
212
|
+
}
|
213
|
+
|
214
|
+
_getPoolStorage()._bundleOwnerRole = bundleOwnerRole;
|
215
|
+
|
216
|
+
emit LogPoolBundleOwnerRoleSet(bundleOwnerRole);
|
149
217
|
}
|
150
218
|
|
151
219
|
|
@@ -154,45 +222,97 @@ abstract contract Pool is
|
|
154
222
|
Fee memory stakingFee,
|
155
223
|
Fee memory performanceFee
|
156
224
|
)
|
157
|
-
|
158
|
-
|
225
|
+
public
|
226
|
+
virtual
|
159
227
|
restricted()
|
160
|
-
|
228
|
+
onlyOwner()
|
161
229
|
{
|
162
230
|
_getPoolStorage()._poolService.setFees(poolFee, stakingFee, performanceFee);
|
163
231
|
}
|
164
232
|
|
165
|
-
|
233
|
+
|
234
|
+
/// @dev see {IPool.verifyApplication}
|
235
|
+
function verifyApplication(
|
236
|
+
NftId applicationNftId,
|
237
|
+
bytes memory applicationData,
|
166
238
|
NftId bundleNftId,
|
167
|
-
|
239
|
+
bytes memory bundleFilter,
|
240
|
+
uint256 collateralizationAmount
|
168
241
|
)
|
169
|
-
|
170
|
-
|
171
|
-
|
242
|
+
public
|
243
|
+
virtual
|
244
|
+
restricted()
|
172
245
|
{
|
173
|
-
|
246
|
+
// validate application data against bundle filter
|
247
|
+
if(!applicationMatchesBundle(
|
248
|
+
applicationNftId,
|
249
|
+
applicationData,
|
250
|
+
bundleNftId,
|
251
|
+
bundleFilter,
|
252
|
+
collateralizationAmount)
|
253
|
+
)
|
254
|
+
{
|
255
|
+
revert ErrorPoolApplicationBundleMismatch(applicationNftId);
|
256
|
+
}
|
257
|
+
|
258
|
+
emit LogPoolVerifiedByPool(address(this), applicationNftId, collateralizationAmount);
|
174
259
|
}
|
175
260
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
{
|
183
|
-
_getPoolStorage().
|
261
|
+
|
262
|
+
function getCollateralizationLevel() public view virtual returns (UFixed collateralizationLevel) {
|
263
|
+
return _getPoolStorage()._collateralizationLevel;
|
264
|
+
}
|
265
|
+
|
266
|
+
|
267
|
+
function getRetentionLevel() public view virtual returns (UFixed retentionLevel) {
|
268
|
+
return _getPoolStorage()._retentionLevel;
|
269
|
+
}
|
270
|
+
|
271
|
+
|
272
|
+
function isExternallyManaged() public view virtual returns (bool) {
|
273
|
+
return _getPoolStorage()._isExternallyManaged;
|
274
|
+
}
|
275
|
+
|
276
|
+
|
277
|
+
function isVerifyingApplications() public view virtual returns (bool isConfirmingApplication) {
|
278
|
+
return _getPoolStorage()._isVerifyingApplications;
|
279
|
+
}
|
280
|
+
|
281
|
+
|
282
|
+
function getMaxCapitalAmount() public view virtual returns (uint256 maxCapitalAmount) {
|
283
|
+
return _getPoolStorage()._maxCapitalAmount;
|
284
|
+
}
|
285
|
+
|
286
|
+
|
287
|
+
function isInterceptingBundleTransfers() public view virtual returns (bool) {
|
288
|
+
return isNftInterceptor();
|
289
|
+
}
|
290
|
+
|
291
|
+
|
292
|
+
function getBundleOwnerRole() public view returns (RoleId bundleOwnerRole) {
|
293
|
+
return _getPoolStorage()._bundleOwnerRole;
|
184
294
|
}
|
185
295
|
|
186
|
-
|
187
|
-
|
296
|
+
|
297
|
+
/// @dev see {IPoolComponent.applicationMatchesBundle}
|
298
|
+
/// Override this function to implement any custom application verification
|
299
|
+
/// Default implementation always returns true
|
300
|
+
function applicationMatchesBundle(
|
301
|
+
NftId applicationNftId,
|
302
|
+
bytes memory applicationData,
|
303
|
+
NftId bundleNftId,
|
304
|
+
bytes memory bundleFilter,
|
305
|
+
uint256 collateralizationAmount
|
188
306
|
)
|
189
|
-
|
190
|
-
|
191
|
-
|
307
|
+
public
|
308
|
+
view
|
309
|
+
virtual override
|
310
|
+
returns (bool isMatching)
|
192
311
|
{
|
193
|
-
|
312
|
+
return true;
|
194
313
|
}
|
195
314
|
|
315
|
+
|
196
316
|
function getSetupInfo() public view returns (ISetup.PoolSetupInfo memory setupInfo) {
|
197
317
|
InstanceReader reader = getInstance().getInstanceReader();
|
198
318
|
setupInfo = reader.getPoolSetupInfo(getNftId());
|
@@ -203,30 +323,13 @@ abstract contract Pool is
|
|
203
323
|
}
|
204
324
|
}
|
205
325
|
|
206
|
-
function _getInitialSetupInfo() internal view returns (ISetup.PoolSetupInfo memory) {
|
207
|
-
PoolStorage storage $ = _getPoolStorage();
|
208
|
-
return ISetup.PoolSetupInfo(
|
209
|
-
getProductNftId(),
|
210
|
-
$._tokenHandler,
|
211
|
-
isNftInterceptor(),
|
212
|
-
$._isExternallyManaged,
|
213
|
-
$._isVerifyingApplications,
|
214
|
-
$._collateralizationLevel,
|
215
|
-
$._retentionLevel,
|
216
|
-
$._initialPoolFee,
|
217
|
-
$._initialStakingFee,
|
218
|
-
$._initialPerformanceFee,
|
219
|
-
getWallet()
|
220
|
-
);
|
221
|
-
}
|
222
|
-
|
223
326
|
// Internals
|
224
327
|
|
225
328
|
function _createBundle(
|
226
329
|
address bundleOwner,
|
227
330
|
Fee memory fee,
|
228
331
|
uint256 amount,
|
229
|
-
|
332
|
+
Seconds lifetime,
|
230
333
|
bytes memory filter
|
231
334
|
)
|
232
335
|
internal
|
@@ -242,10 +345,31 @@ abstract contract Pool is
|
|
242
345
|
// TODO add logging
|
243
346
|
}
|
244
347
|
|
348
|
+
// TODO remove function once this is no longer used to produce contract locations on the fly ...
|
245
349
|
function getContractLocation(bytes memory name) external pure returns (bytes32 hash) {
|
246
350
|
return keccak256(abi.encode(uint256(keccak256(name)) - 1)) & ~bytes32(uint256(0xff));
|
247
351
|
}
|
248
352
|
|
353
|
+
|
354
|
+
function _getInitialSetupInfo() internal view returns (ISetup.PoolSetupInfo memory) {
|
355
|
+
PoolStorage storage $ = _getPoolStorage();
|
356
|
+
return ISetup.PoolSetupInfo(
|
357
|
+
getProductNftId(),
|
358
|
+
$._tokenHandler,
|
359
|
+
$._maxCapitalAmount,
|
360
|
+
isNftInterceptor(),
|
361
|
+
$._isExternallyManaged,
|
362
|
+
$._isVerifyingApplications,
|
363
|
+
$._collateralizationLevel,
|
364
|
+
$._retentionLevel,
|
365
|
+
$._initialPoolFee,
|
366
|
+
$._initialStakingFee,
|
367
|
+
$._initialPerformanceFee,
|
368
|
+
getWallet()
|
369
|
+
);
|
370
|
+
}
|
371
|
+
|
372
|
+
|
249
373
|
function _getPoolStorage() private pure returns (PoolStorage storage $) {
|
250
374
|
assembly {
|
251
375
|
$.slot := POOL_STORAGE_LOCATION_V1
|