@etherisc/gif-next 0.0.2-f29e479-370 → 0.0.2-f30e0eb-805

Sign up to get free protection for your applications and to get access to all the features.
Files changed (250) hide show
  1. package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
  2. package/artifacts/contracts/components/Component.sol/Component.json +68 -89
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.json +113 -140
  5. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
  6. package/artifacts/contracts/components/IComponent.sol/IComponent.json +65 -73
  7. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +91 -122
  9. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +256 -189
  11. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +69 -145
  13. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  14. package/artifacts/contracts/components/Pool.sol/Pool.json +279 -245
  15. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  16. package/artifacts/contracts/components/Product.sol/Product.json +73 -162
  17. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  18. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
  19. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  20. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +64 -50
  21. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  22. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +5 -0
  23. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  24. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +171 -308
  25. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  26. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +98 -40
  27. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  28. package/artifacts/contracts/instance/Instance.sol/Instance.json +260 -379
  29. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  30. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +448 -121
  31. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  32. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +120 -227
  33. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  34. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +148 -161
  35. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  36. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +31 -23
  37. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  38. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -13
  39. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
  40. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +1 -1
  41. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  42. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  43. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  44. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +40 -10
  45. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  46. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +36 -11
  47. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  48. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +54 -71
  49. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  50. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +4 -0
  51. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.json +10 -0
  52. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  53. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  54. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  55. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  56. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  57. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  58. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +161 -62
  59. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  60. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +33 -25
  61. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  62. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +137 -140
  63. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  64. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +12 -12
  65. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
  66. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +3 -3
  67. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  68. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +2 -2
  69. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  70. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +505 -91
  71. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  72. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +78 -42
  73. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  74. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +110 -27
  75. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  76. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +93 -96
  77. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
  78. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +350 -8
  80. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +21 -64
  82. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +81 -0
  84. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  85. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  86. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +58 -157
  87. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  88. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +19 -47
  89. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  90. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +114 -17
  91. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +17 -9
  93. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  94. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +7 -7
  95. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +4 -4
  97. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  98. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +15 -2
  99. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  100. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +19 -0
  101. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  102. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  103. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +18 -0
  104. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  105. package/artifacts/contracts/registry/Registry.sol/Registry.json +31 -12
  106. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  107. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
  108. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  109. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +5 -5
  110. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  111. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +3 -3
  112. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  113. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +7 -7
  114. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  115. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  116. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  117. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  118. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  119. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  120. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  121. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  122. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  123. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  124. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  125. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  126. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  127. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
  128. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  129. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  130. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  131. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +3 -3
  132. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  133. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  134. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  135. package/artifacts/contracts/shared/Service.sol/Service.json +1 -1
  136. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  137. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
  138. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  139. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  140. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  141. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  142. package/artifacts/contracts/test/TestFee.sol/TestFee.json +2 -2
  143. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +3 -3
  145. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +6 -6
  147. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  148. package/artifacts/contracts/test/TestService.sol/TestService.json +3 -3
  149. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  150. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  151. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  152. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  153. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
  154. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  155. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  156. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  157. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
  158. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  159. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  160. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  161. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
  162. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/Fee.sol/FeeLib.json +2 -2
  164. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  165. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  166. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +17 -4
  168. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  169. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  170. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  172. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  173. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  175. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +23 -4
  176. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  177. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  178. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  179. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  180. package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +4 -0
  181. package/artifacts/contracts/types/Seconds.sol/SecondsLib.json +124 -0
  182. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  183. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  184. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  185. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +25 -7
  186. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  187. package/artifacts/contracts/types/UFixed.sol/MathLib.json +2 -2
  188. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  189. package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +2 -2
  190. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  191. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  192. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  193. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
  194. package/contracts/components/Component.sol +95 -85
  195. package/contracts/components/Distribution.sol +12 -19
  196. package/contracts/components/IComponent.sol +37 -17
  197. package/contracts/components/IDistributionComponent.sol +1 -22
  198. package/contracts/components/IPoolComponent.sol +73 -47
  199. package/contracts/components/IProductComponent.sol +3 -2
  200. package/contracts/components/Pool.sol +171 -126
  201. package/contracts/components/Product.sol +26 -18
  202. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +13 -0
  203. package/contracts/instance/BundleManager.sol +7 -5
  204. package/contracts/instance/Cloneable.sol +7 -2
  205. package/contracts/instance/IInstance.sol +16 -10
  206. package/contracts/instance/IInstanceService.sol +18 -5
  207. package/contracts/instance/Instance.sol +45 -9
  208. package/contracts/instance/InstanceAccessManager.sol +382 -157
  209. package/contracts/instance/InstanceReader.sol +7 -10
  210. package/contracts/instance/InstanceService.sol +174 -155
  211. package/contracts/instance/ObjectManager.sol +6 -8
  212. package/contracts/instance/base/ComponentService.sol +5 -5
  213. package/contracts/instance/base/KeyValueStore.sol +5 -2
  214. package/contracts/instance/base/Lifecycle.sol +11 -2
  215. package/contracts/instance/module/IAccess.sol +20 -13
  216. package/contracts/instance/module/IBundle.sol +2 -1
  217. package/contracts/instance/module/IComponents.sol +35 -0
  218. package/contracts/instance/module/IDistribution.sol +2 -1
  219. package/contracts/instance/module/IPolicy.sol +26 -1
  220. package/contracts/instance/module/ISetup.sol +7 -22
  221. package/contracts/instance/service/ApplicationService.sol +123 -41
  222. package/contracts/instance/service/BundleService.sol +76 -38
  223. package/contracts/instance/service/DistributionService.sol +139 -47
  224. package/contracts/instance/service/IApplicationService.sol +7 -7
  225. package/contracts/instance/service/IBundleService.sol +19 -11
  226. package/contracts/instance/service/IDistributionService.sol +19 -4
  227. package/contracts/instance/service/IPolicyService.sol +3 -20
  228. package/contracts/instance/service/IPoolService.sol +17 -2
  229. package/contracts/instance/service/PolicyService.sol +59 -132
  230. package/contracts/instance/service/PoolService.sol +128 -17
  231. package/contracts/instance/service/ProductService.sol +10 -2
  232. package/contracts/registry/ChainNft.sol +8 -0
  233. package/contracts/registry/IRegistry.sol +2 -0
  234. package/contracts/registry/ITransferInterceptor.sol +1 -0
  235. package/contracts/registry/Registry.sol +23 -20
  236. package/contracts/registry/RegistryService.sol +5 -5
  237. package/contracts/shared/Registerable.sol +2 -2
  238. package/contracts/shared/TokenHandler.sol +11 -5
  239. package/contracts/types/Blocknumber.sol +1 -0
  240. package/contracts/types/Fee.sol +1 -0
  241. package/contracts/types/NftId.sol +8 -0
  242. package/contracts/types/ObjectType.sol +1 -0
  243. package/contracts/types/Referral.sol +4 -0
  244. package/contracts/types/RoleId.sol +13 -6
  245. package/contracts/types/Seconds.sol +54 -0
  246. package/contracts/types/StateId.sol +1 -0
  247. package/contracts/types/Timestamp.sol +13 -13
  248. package/contracts/types/UFixed.sol +1 -0
  249. package/contracts/types/Version.sol +1 -0
  250. package/package.json +1 -1
@@ -3,85 +3,111 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {Fee} from "../types/Fee.sol";
5
5
  import {IComponent} from "./IComponent.sol";
6
- import {ISetup} from "../instance/module/ISetup.sol";
6
+ import {IComponents} from "../instance/module/IComponents.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
- event LogUnderwrittenByPool(NftId policyNftId, uint256 collateralizationAmount, address pool);
16
+ error ErrorPoolNotBundleOwner(NftId bundleNftId, address caller);
17
+ error ErrorPoolNotPoolService(address caller);
15
18
 
16
- error ErrorPoolNotPoolService(address service);
19
+ error ErrorPoolApplicationBundleMismatch(NftId applicationNftId);
17
20
 
18
- function getSetupInfo() external view returns (ISetup.PoolSetupInfo memory setupInfo);
21
+ event LogPoolVerifiedByPool(address pool, NftId applicationNftId, uint256 collateralizationAmount);
19
22
 
20
- function setFees(
21
- Fee memory poolFee,
22
- Fee memory stakingFee,
23
- Fee memory performanceFee
24
- ) external;
23
+ /// @dev increases the staked tokens by the specified amount
24
+ /// only the bundle owner may stake tokens
25
+ /// bundle MUST be in active or locked state
26
+ function stake(NftId bundleNftId, uint256 amount) external;
27
+
28
+ /// @dev decreases the staked tokens by the specified amount
29
+ /// only the bundle owner may unstake tokens from the bundle
30
+ /// bundle MUST be in active, locked or closed state
31
+ function unstake(NftId bundleNftId, uint256 amount) external;
25
32
 
26
- /// @dev sets an additional bundle fee, this fee is added on top of the poolFee and deducted from the premium amounts.
33
+ /// @dev extends the bundle lifetime of the bundle by the specified time
34
+ /// only the bundle owner may extend the bundle's lifetime
35
+ /// bundle MUST be in active or locked state
36
+ function extend(NftId bundleNftId, Seconds lifetimeExtension) external;
37
+
38
+ /// @dev locks the specified bundle
39
+ /// a bundle to be locked MUST be in active state
40
+ /// locked bundles may not be used to underwrite any new policy
41
+ function lockBundle(NftId bundleNftId) external;
42
+
43
+ /// @dev unlocks the specified bundle
44
+ /// a bundle to be unlocked MUST be in locked state
45
+ function unlockBundle(NftId bundleNftId) external;
46
+
47
+ /// @dev close the specified bundle
48
+ /// a bundle to be closed MUST be in active or locked state
49
+ /// to close a bundle all all linked policies MUST be in closed state as well
50
+ /// closing a bundle finalizes the bundle bookkeeping including overall profit calculation
51
+ /// once a bundle is closed this action cannot be reversed
52
+ function close(NftId bundleNftId) external;
53
+
54
+ /// @dev sets the fee for the specified bundle
55
+ /// the fee is added on top of the poolFee and deducted from the premium amounts
27
56
  /// via these fees individual bundler owner may earn income per policy in the context of peer to peer pools
28
57
  function setBundleFee(
29
58
  NftId bundleNftId,
30
59
  Fee memory fee
31
60
  ) external;
32
61
 
62
+ /// @dev sets the maximum overall capital amound held by this pool
63
+ /// function may only be called by pool owner
64
+ function setMaxCapitalAmount(uint256 maxCapitalAmount) external;
65
+
66
+ /// @dev sets the required role to create/own bundles
67
+ /// may only be called once after setting up a pool
68
+ /// may only be called by pool owner
69
+ function setBundleOwnerRole(RoleId bundleOwnerRole) external;
70
+
71
+ /// @dev update pool fees to the specified values
72
+ /// pool fees: are deducted from the premium amount and goes to the pool owner
73
+ /// staking fees: are deducted from the staked tokens by a bundle owner and goes to the pool owner
74
+ /// performance fees: when a bundle is closed a bundle specific profit is calculated
75
+ /// the performance fee is deducted from this profit and goes to the pool owner
76
+ function setFees(
77
+ Fee memory poolFee,
78
+ Fee memory stakingFee,
79
+ Fee memory performanceFee
80
+ ) external;
81
+
33
82
  /// @dev this is a callback function that is called by the product service when underwriting a policy.
34
83
  /// the pool has the option to check the details and object to underwriting by reverting.
35
84
  /// the function is only called for "active" pools that ask to be involved/notified
36
85
  /// by product related state changes.
37
86
  function verifyApplication(
38
87
  NftId applicationNftId,
39
- bytes memory policyData,
88
+ bytes memory applicationData,
89
+ NftId bundleNftId,
40
90
  bytes memory bundleFilter,
41
91
  uint256 collateralizationAmount
42
92
  ) external;
43
93
 
44
- function lockBundle(NftId bundleNftId) external;
45
-
46
- function unlockBundle(NftId bundleNftId) external;
47
-
48
- /// @dev defines the multiplier to calculate the required collateral to cover a given sum insured amount
49
- /// default implementation returns 100%
50
- function getCollateralizationLevel() external view returns (UFixed collateralizationLevel);
51
-
52
- /// @dev defines the amount of collateral held in the pool.
53
- /// if the value is < 100% the pool is required to hold a policy that covers the locally missing collateral
54
- /// default implementation returns 100%
55
- function getRetentionLevel() external view returns (UFixed retentionLevel);
56
-
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
- /// @dev declares if pool relies on external management of collateral (yes/no):
64
- /// - 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
- /// - no: the pool smart contract ensures that the necessary capacity of the pool prior to underwriting.
66
- /// default implementation returns false (no)
67
- function isExternallyManaged() external view returns (bool);
68
-
69
- /// @dev declares if pool component is actively involved in underwriting (yes/no):
70
- /// - yes: verifying pools components actively confirm underwriting applications, ie the pool component logic explicitly needs to confirm the locking of collateral to cover the sum insured of the policy
71
- /// - no: underwriting a policy does not require any interaction with the pool component if the covering bundle can provide the necessary captial
72
- /// default implementation returnsfalse (no)
73
- function isVerifyingApplications() external view returns (bool);
74
-
75
- /// @dev returns true iff the policy application data in policyData matches
76
- /// with the bundle filter criteria encoded in bundleFilter
94
+ /// @dev returns true iff the application matches with the bundle
77
95
  /// this is a callback function that is only called if a pool declares itself as a verifying pool
78
96
  /// default implementation returns true
79
- function policyMatchesBundle(
80
- bytes memory policyData,
81
- bytes memory bundleFilter
97
+ function applicationMatchesBundle(
98
+ NftId applicationNftId,
99
+ bytes memory applicationData,
100
+ NftId bundleNftId,
101
+ bytes memory bundleFilter,
102
+ uint256 collateralizationAmount
82
103
  )
83
104
  external
84
105
  view
85
106
  returns (bool isMatching);
86
107
 
108
+ /// @dev returns pool specific infos for this pool
109
+ /// when registered with an instance the info is obtained from the data stored in the instance
110
+ /// when not registered the function returns the info from the component contract
111
+ function getPoolInfo() external view returns (IComponents.PoolInfo memory info);
112
+
87
113
  }
@@ -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
- uint256 lifetime,
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
- uint256 lifetime,
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 {POOL} from "../types/ObjectType.sol";
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 {UFixed} from "../types/UFixed.sol";
6
+ import {IBundleService} from "../instance/service/IBundleService.sol";
7
+ import {InstanceReader} from "../instance/InstanceReader.sol";
10
8
  import {IPoolComponent} from "./IPoolComponent.sol";
11
- import {Component} from "./Component.sol";
9
+ import {IPoolService} from "../instance/service/IPoolService.sol";
10
+ import {IComponents} from "../instance/module/IComponents.sol";
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";
12
15
  import {TokenHandler} from "../shared/TokenHandler.sol";
13
- import {ISetup} from "../instance/module/ISetup.sol";
14
-
15
- import {ISetup} from "../instance/module/ISetup.sol";
16
- import {InstanceReader} from "../instance/InstanceReader.sol";
16
+ import {UFixed, UFixedLib} from "../types/UFixed.sol";
17
17
 
18
18
 
19
19
  abstract contract Pool is
@@ -24,24 +24,19 @@ abstract contract Pool is
24
24
  bytes32 public constant POOL_STORAGE_LOCATION_V1 = 0x25e3e51823fbfffb988e0a2744bb93722d9f3e906c07cc0a9e77884c46c58300;
25
25
 
26
26
  struct PoolStorage {
27
- UFixed _collateralizationLevel;
28
- UFixed _retentionLevel;
29
-
30
- bool _isExternallyManaged;
31
- bool _isInterceptingBundleTransfers;
32
- bool _isVerifyingApplications;
33
-
34
- Fee _initialPoolFee;
35
- Fee _initialStakingFee;
36
- Fee _initialPerformanceFee;
37
-
38
- TokenHandler _tokenHandler;
39
-
40
- // may be used to interact with instance by derived contracts
41
27
  IPoolService _poolService;
42
28
  IBundleService _bundleService;
43
29
  }
44
30
 
31
+
32
+ modifier onlyBundleOwner(NftId bundleNftId) {
33
+ if(msg.sender != getRegistry().ownerOf(bundleNftId)) {
34
+ revert ErrorPoolNotBundleOwner(bundleNftId, msg.sender);
35
+ }
36
+ _;
37
+ }
38
+
39
+
45
40
  modifier onlyPoolService() {
46
41
  if(msg.sender != address(_getPoolStorage()._poolService)) {
47
42
  revert ErrorPoolNotPoolService(msg.sender);
@@ -54,98 +49,124 @@ abstract contract Pool is
54
49
  address registry,
55
50
  NftId instanceNftId,
56
51
  string memory name,
57
- // TODO refactor into tokenNftId
58
52
  address token,
59
53
  bool isInterceptingNftTransfers,
60
- bool isExternallyManaging,
61
- bool isVerifying,
62
- UFixed collateralizationLevel,
63
- UFixed retentionLevel,
64
54
  address initialOwner,
65
- bytes memory data
55
+ bytes memory registryData // writeonly data that will saved in the object info record of the registry
66
56
  )
67
57
  public
68
58
  virtual
69
59
  onlyInitializing()
70
60
  {
71
- initializeComponent(registry, instanceNftId, name, token, POOL(), isInterceptingNftTransfers, initialOwner, data);
61
+ initializeComponent(registry, instanceNftId, name, token, POOL(), isInterceptingNftTransfers, initialOwner, registryData);
72
62
 
73
63
  PoolStorage storage $ = _getPoolStorage();
74
- // TODO add validation
75
- $._tokenHandler = new TokenHandler(token);
76
- $._isExternallyManaged = isExternallyManaging;
77
- $._isVerifyingApplications = isVerifying;
78
- $._collateralizationLevel = collateralizationLevel;
79
- $._retentionLevel = retentionLevel;
80
- $._initialPoolFee = FeeLib.zeroFee();
81
- $._initialStakingFee = FeeLib.zeroFee();
82
- $._initialPerformanceFee = FeeLib.zeroFee();
83
64
  $._poolService = getInstance().getPoolService();
84
65
  $._bundleService = getInstance().getBundleService();
85
66
 
86
67
  registerInterface(type(IPoolComponent).interfaceId);
87
68
  }
88
69
 
89
- /**
90
- * @dev see {IPool.verifyApplication}.
91
- * Default implementation that only writes a {LogUnderwrittenByPool} entry.
92
- */
93
- function verifyApplication(
94
- NftId applicationNftId,
95
- bytes memory applicationData,
96
- bytes memory bundleFilter,
97
- uint256 collateralizationAmount
70
+
71
+ function stake(
72
+ NftId bundleNftId,
73
+ uint256 amount
98
74
  )
99
- external
75
+ public
76
+ virtual
100
77
  restricted()
101
- virtual override
78
+ onlyBundleOwner(bundleNftId)
102
79
  {
103
- require(
104
- policyMatchesBundle(applicationData, bundleFilter),
105
- "ERROR:POL-020:POLICY_BUNDLE_MISMATCH"
106
- );
107
-
108
- emit LogUnderwrittenByPool(applicationNftId, collateralizationAmount, address(this));
80
+ // TODO add implementation
109
81
  }
110
82
 
111
83
 
112
- function isInterceptingBundleTransfers() external view override returns (bool) {
113
- return isNftInterceptor();
84
+ function unstake(
85
+ NftId bundleNftId,
86
+ uint256 amount
87
+ )
88
+ public
89
+ virtual
90
+ restricted()
91
+ onlyBundleOwner(bundleNftId)
92
+ {
93
+ // TODO add implementation
114
94
  }
115
95
 
116
96
 
117
- function isExternallyManaged() external view override returns (bool) {
118
- return _getPoolStorage()._isExternallyManaged;
97
+ function extend(
98
+ NftId bundleNftId,
99
+ Seconds lifetimeExtension
100
+ )
101
+ public
102
+ virtual
103
+ restricted()
104
+ onlyBundleOwner(bundleNftId)
105
+ {
106
+ // TODO add implementation
119
107
  }
120
108
 
121
109
 
122
- function getRetentionLevel() external view override returns (UFixed retentionLevel) {
123
- return _getPoolStorage()._retentionLevel;
110
+ function lockBundle(NftId bundleNftId)
111
+ public
112
+ virtual
113
+ //restricted() // TODO consider adding this back
114
+ onlyBundleOwner(bundleNftId)
115
+ {
116
+ _getPoolStorage()._bundleService.lock(bundleNftId);
124
117
  }
125
118
 
126
119
 
127
- function getCollateralizationLevel() external view override returns (UFixed collateralizationLevel) {
128
- return _getPoolStorage()._collateralizationLevel;
120
+ function unlockBundle(NftId bundleNftId)
121
+ public
122
+ virtual
123
+ //restricted()
124
+ onlyBundleOwner(bundleNftId)
125
+ {
126
+ _getPoolStorage()._bundleService.unlock(bundleNftId);
129
127
  }
130
128
 
131
129
 
132
- function isVerifyingApplications() external view override returns (bool isConfirmingApplication) {
133
- return _getPoolStorage()._isVerifyingApplications;
130
+ function close(NftId bundleNftId)
131
+ public
132
+ virtual
133
+ //restricted()
134
+ onlyBundleOwner(bundleNftId)
135
+ {
136
+ _getPoolStorage()._bundleService.close(bundleNftId);
134
137
  }
135
138
 
136
139
 
137
- /// @dev see {IPoolComponent.policyMatchesBundle}.
138
- /// Default implementation always returns true
139
- function policyMatchesBundle(
140
- bytes memory, // policyData
141
- bytes memory // bundleFilter
140
+ function setBundleFee(
141
+ NftId bundleNftId,
142
+ Fee memory fee
142
143
  )
143
144
  public
144
- pure
145
- virtual override
146
- returns (bool isMatching)
145
+ virtual
146
+ restricted()
147
+ onlyBundleOwner(bundleNftId)
147
148
  {
148
- return true;
149
+ _getPoolStorage()._bundleService.setFee(bundleNftId, fee);
150
+ }
151
+
152
+
153
+ function setMaxCapitalAmount(uint256 maxCapitalAmount)
154
+ public
155
+ virtual
156
+ restricted()
157
+ onlyOwner()
158
+ {
159
+ _getPoolStorage()._poolService.setMaxCapitalAmount(maxCapitalAmount);
160
+ }
161
+
162
+
163
+ function setBundleOwnerRole(RoleId bundleOwnerRole)
164
+ public
165
+ virtual
166
+ restricted()
167
+ onlyOwner()
168
+ {
169
+ _getPoolStorage()._poolService.setBundleOwnerRole(bundleOwnerRole);
149
170
  }
150
171
 
151
172
 
@@ -154,70 +175,63 @@ abstract contract Pool is
154
175
  Fee memory stakingFee,
155
176
  Fee memory performanceFee
156
177
  )
157
- external
158
- onlyOwner
178
+ public
179
+ virtual
159
180
  restricted()
160
- override
181
+ onlyOwner()
161
182
  {
162
183
  _getPoolStorage()._poolService.setFees(poolFee, stakingFee, performanceFee);
163
184
  }
164
185
 
165
- function setBundleFee(
186
+
187
+ /// @dev see {IPool.verifyApplication}
188
+ function verifyApplication(
189
+ NftId applicationNftId,
190
+ bytes memory applicationData,
166
191
  NftId bundleNftId,
167
- Fee memory fee
192
+ bytes memory bundleFilter,
193
+ uint256 collateralizationAmount
168
194
  )
169
- external
170
- override
171
- // TODO add onlyBundleOwner
195
+ public
196
+ virtual
197
+ restricted()
172
198
  {
173
- _getPoolStorage()._bundleService.setBundleFee(bundleNftId, fee);
174
- }
199
+ if(!applicationMatchesBundle(
200
+ applicationNftId,
201
+ applicationData,
202
+ bundleNftId,
203
+ bundleFilter,
204
+ collateralizationAmount)
205
+ )
206
+ {
207
+ revert ErrorPoolApplicationBundleMismatch(applicationNftId);
208
+ }
175
209
 
176
- function lockBundle(
177
- NftId bundleNftId
178
- )
179
- external
180
- override
181
- // TODO add onlyBundleOwner
182
- {
183
- _getPoolStorage()._bundleService.lockBundle(bundleNftId);
210
+ emit LogPoolVerifiedByPool(address(this), applicationNftId, collateralizationAmount);
184
211
  }
185
212
 
186
- function unlockBundle(
187
- NftId bundleNftId
213
+
214
+ /// @dev see {IPoolComponent.applicationMatchesBundle}
215
+ /// Override this function to implement any custom application verification
216
+ /// Default implementation always returns true
217
+ function applicationMatchesBundle(
218
+ NftId applicationNftId,
219
+ bytes memory applicationData,
220
+ NftId bundleNftId,
221
+ bytes memory bundleFilter,
222
+ uint256 collateralizationAmount
188
223
  )
189
- external
190
- override
191
- // TODO add onlyBundleOwner
224
+ public
225
+ view
226
+ virtual override
227
+ returns (bool isMatching)
192
228
  {
193
- _getPoolStorage()._bundleService.unlockBundle(bundleNftId);
229
+ return true;
194
230
  }
195
231
 
196
- function getSetupInfo() public view returns (ISetup.PoolSetupInfo memory setupInfo) {
197
- InstanceReader reader = getInstance().getInstanceReader();
198
- setupInfo = reader.getPoolSetupInfo(getNftId());
199
-
200
- // fallback to initial setup info (wallet is always != address(0))
201
- if(setupInfo.wallet == address(0)) {
202
- setupInfo = _getInitialSetupInfo();
203
- }
204
- }
205
232
 
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
- );
233
+ function getPoolInfo() external view returns (IComponents.PoolInfo memory poolInfo) {
234
+ poolInfo = abi.decode(getComponentInfo().data, (IComponents.PoolInfo));
221
235
  }
222
236
 
223
237
  // Internals
@@ -226,13 +240,13 @@ abstract contract Pool is
226
240
  address bundleOwner,
227
241
  Fee memory fee,
228
242
  uint256 amount,
229
- uint256 lifetime,
243
+ Seconds lifetime,
230
244
  bytes memory filter
231
245
  )
232
246
  internal
233
247
  returns(NftId bundleNftId)
234
248
  {
235
- bundleNftId = _getPoolStorage()._bundleService.createBundle(
249
+ bundleNftId = _getPoolStorage()._bundleService.create(
236
250
  bundleOwner,
237
251
  fee,
238
252
  amount,
@@ -242,10 +256,41 @@ abstract contract Pool is
242
256
  // TODO add logging
243
257
  }
244
258
 
259
+ // TODO remove function once this is no longer used to produce contract locations on the fly ...
245
260
  function getContractLocation(bytes memory name) external pure returns (bytes32 hash) {
246
261
  return keccak256(abi.encode(uint256(keccak256(name)) - 1)) & ~bytes32(uint256(0xff));
247
262
  }
248
263
 
264
+ /// @dev defines initial pool specification
265
+ /// overwrite this function according to your use case
266
+ function _getInitialInfo()
267
+ internal
268
+ view
269
+ virtual override
270
+ returns (IComponents.ComponentInfo memory info)
271
+ {
272
+ return IComponents.ComponentInfo(
273
+ getName(),
274
+ getToken(),
275
+ TokenHandler(address(0)), // will be created by GIF service during registration
276
+ address(this), // contract is its own wallet
277
+ abi.encode(
278
+ IComponents.PoolInfo(
279
+ NftIdLib.zero(), // will be set when GIF registers the related product
280
+ PUBLIC_ROLE(), // bundleOwnerRole
281
+ type(uint256).max, // maxCapitalAmount,
282
+ isNftInterceptor(), // isInterceptingBundleTransfers
283
+ false, // isExternallyManaged,
284
+ false, // isVerifyingApplications,
285
+ UFixedLib.toUFixed(1), // collateralizationLevel,
286
+ UFixedLib.toUFixed(1), // retentionLevel,
287
+ FeeLib.zeroFee(), // initialPoolFee,
288
+ FeeLib.zeroFee(), // initialStakingFee,
289
+ FeeLib.zeroFee() // initialPerformanceFee,
290
+ )));
291
+ }
292
+
293
+
249
294
  function _getPoolStorage() private pure returns (PoolStorage storage $) {
250
295
  assembly {
251
296
  $.slot := POOL_STORAGE_LOCATION_V1