@etherisc/gif-next 0.0.2-b9e43cf-870 → 0.0.2-bb1081a-994

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
  2. package/artifacts/contracts/components/{IBaseComponent.sol/IBaseComponent.json → Component.sol/Component.json} +230 -14
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.json +141 -10
  5. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
  6. package/artifacts/contracts/components/{BaseComponent.sol/BaseComponent.json → IComponent.sol/IComponent.json} +107 -87
  7. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +543 -0
  9. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +623 -45
  11. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +643 -5
  13. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  14. package/artifacts/contracts/components/Pool.sol/Pool.json +227 -73
  15. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  16. package/artifacts/contracts/components/Product.sol/Product.json +146 -15
  17. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  36. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  37. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  38. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +38 -62
  39. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  40. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  41. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +181 -15
  42. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  43. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +0 -5
  44. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  45. package/artifacts/contracts/instance/Instance.sol/Instance.json +113 -76
  46. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  47. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +47 -60
  48. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  49. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +42 -83
  50. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  51. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +59 -58
  52. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  53. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +37 -24
  54. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  55. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -32
  56. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
  57. package/artifacts/contracts/instance/base/{ComponentServiceBase.sol/ComponentServiceBase.json → ComponentService.sol/ComponentService.json} +102 -31
  58. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  59. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  60. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  61. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  62. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  63. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  64. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  66. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  69. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  70. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +229 -93
  71. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  72. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +31 -18
  73. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  74. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +126 -47
  75. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  76. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +31 -14
  77. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  78. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +98 -38
  79. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  80. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +0 -5
  81. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  82. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +0 -5
  83. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  84. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +0 -5
  85. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  86. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +0 -5
  87. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  88. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +153 -82
  89. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  90. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +44 -31
  91. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +126 -47
  93. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  94. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +31 -14
  95. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +126 -47
  97. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  98. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +31 -14
  99. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  100. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  101. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +83 -3
  102. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  103. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +33 -28
  104. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  105. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  106. package/artifacts/contracts/registry/Registry.sol/Registry.json +96 -24
  107. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  108. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +18 -18
  109. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  110. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +61 -56
  111. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  112. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +28 -15
  113. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  114. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +70 -53
  115. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  116. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +23 -26
  117. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  118. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  119. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  120. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  121. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +0 -5
  122. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  123. package/artifacts/contracts/shared/IService.sol/IService.json +0 -5
  124. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  125. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  126. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +19 -6
  127. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  128. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +19 -6
  129. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  130. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +19 -11
  131. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  132. package/artifacts/contracts/shared/Service.sol/Service.json +13 -5
  133. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  134. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  135. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  136. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  137. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  138. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +19 -11
  139. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  140. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  141. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  142. package/artifacts/contracts/test/TestService.sol/TestService.json +29 -21
  143. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  145. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  146. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  147. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  148. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  149. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  150. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  151. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  152. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  153. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  154. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  155. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  156. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  157. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  158. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  159. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  160. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  161. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  167. package/contracts/components/Component.sol +247 -0
  168. package/contracts/components/Distribution.sol +27 -48
  169. package/contracts/components/IComponent.sol +50 -0
  170. package/contracts/components/IDistributionComponent.sol +5 -2
  171. package/contracts/components/IPoolComponent.sol +40 -29
  172. package/contracts/components/IProductComponent.sol +7 -3
  173. package/contracts/components/Pool.sol +123 -138
  174. package/contracts/components/Product.sol +48 -86
  175. package/contracts/instance/BundleManager.sol +7 -11
  176. package/contracts/instance/IInstance.sol +20 -10
  177. package/contracts/instance/IInstanceService.sol +1 -1
  178. package/contracts/instance/Instance.sol +28 -31
  179. package/contracts/instance/InstanceAccessManager.sol +6 -11
  180. package/contracts/instance/InstanceReader.sol +3 -25
  181. package/contracts/instance/InstanceService.sol +31 -14
  182. package/contracts/instance/ObjectManager.sol +7 -24
  183. package/contracts/instance/base/ComponentService.sol +134 -0
  184. package/contracts/instance/module/ISetup.sol +2 -2
  185. package/contracts/instance/service/BundleService.sol +11 -6
  186. package/contracts/instance/service/DistributionService.sol +22 -36
  187. package/contracts/instance/service/IBundleService.sol +11 -1
  188. package/contracts/instance/service/PolicyService.sol +56 -76
  189. package/contracts/instance/service/PoolService.sol +19 -55
  190. package/contracts/instance/service/ProductService.sol +49 -30
  191. package/contracts/registry/IRegistry.sol +13 -6
  192. package/contracts/registry/IRegistryService.sol +16 -9
  193. package/contracts/registry/Registry.sol +100 -44
  194. package/contracts/registry/RegistryAccessManager.sol +31 -25
  195. package/contracts/registry/RegistryService.sol +27 -85
  196. package/contracts/registry/ReleaseManager.sol +72 -82
  197. package/contracts/registry/TokenRegistry.sol +5 -3
  198. package/contracts/shared/IRegisterable.sol +1 -3
  199. package/contracts/shared/NftOwnable.sol +5 -0
  200. package/contracts/shared/Registerable.sol +10 -14
  201. package/contracts/shared/Service.sol +4 -2
  202. package/contracts/types/RoleId.sol +2 -2
  203. package/package.json +1 -1
  204. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
  205. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
  206. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +0 -4
  207. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +0 -1206
  208. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
  209. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +0 -448
  210. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +0 -4
  211. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +0 -763
  212. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
  213. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
  214. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -113
  215. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
  216. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -814
  217. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
  218. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +0 -466
  219. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +0 -4
  220. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +0 -442
  221. package/contracts/components/BaseComponent.sol +0 -159
  222. package/contracts/components/IBaseComponent.sol +0 -34
  223. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +0 -23
  224. package/contracts/instance/IInstanceBase.sol +0 -26
  225. package/contracts/instance/InstanceBase.sol +0 -41
  226. package/contracts/instance/base/ComponentServiceBase.sol +0 -76
  227. package/contracts/instance/base/IInstanceBase.sol +0 -23
  228. package/contracts/instance/service/ComponentOwnerService.sol +0 -315
  229. package/contracts/instance/service/IComponentOwnerService.sol +0 -20
  230. package/contracts/shared/RegisterableUpgradable.sol +0 -16
@@ -1,43 +1,41 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {NftId} from "../types/NftId.sol";
5
4
  import {Fee} from "../types/Fee.sol";
5
+ import {IComponent} from "./IComponent.sol";
6
+ import {ISetup} from "../instance/module/ISetup.sol";
7
+ import {NftId} from "../types/NftId.sol";
6
8
  import {UFixed} from "../types/UFixed.sol";
7
9
 
8
- interface IPoolComponent {
10
+ /// @dev pool components hold and manage the collateral to cover active policies
11
+ /// pools come in different flavors
12
+ interface IPoolComponent is IComponent {
9
13
 
10
14
  event LogUnderwrittenByPool(NftId policyNftId, uint256 collateralizationAmount, address pool);
11
15
 
16
+ error ErrorPoolNotPoolService(address service);
17
+
18
+ function getSetupInfo() external view returns (ISetup.PoolSetupInfo memory setupInfo);
19
+
12
20
  function setFees(
13
21
  Fee memory poolFee,
14
22
  Fee memory stakingFee,
15
23
  Fee memory performanceFee
16
24
  ) external;
17
25
 
18
- /**
19
- * @dev creates a new bundle for this pool.
20
- */
21
- function createBundle(
22
- Fee memory fee,
23
- uint256 initialAmount,
24
- uint256 lifetime,
25
- bytes memory filter
26
- ) external returns(NftId bundleNftId);
27
-
26
+ /// @dev sets an additional bundle fee, this fee is added on top of the poolFee and deducted from the premium amounts.
27
+ /// via these fees individual bundler owner may earn income per policy in the context of peer to peer pools
28
28
  function setBundleFee(
29
- NftId policyNftId,
29
+ NftId bundleNftId,
30
30
  Fee memory fee
31
31
  ) external;
32
32
 
33
- /**
34
- * @dev this is a callback function that is called by the product service when underwriting a policy.
35
- * the pool has the option to check the details and object to underwriting by reverting.
36
- * the function is only called for "active" pools that ask to be involved/notified
37
- * by product related state changes.
38
- */
39
- function underwrite(
40
- NftId policyNftId,
33
+ /// @dev this is a callback function that is called by the product service when underwriting a policy.
34
+ /// the pool has the option to check the details and object to underwriting by reverting.
35
+ /// the function is only called for "active" pools that ask to be involved/notified
36
+ /// by product related state changes.
37
+ function verifyApplication(
38
+ NftId applicationNftId,
41
39
  bytes memory policyData,
42
40
  bytes memory bundleFilter,
43
41
  uint256 collateralizationAmount
@@ -47,10 +45,27 @@ interface IPoolComponent {
47
45
 
48
46
  function unlockBundle(NftId bundleNftId) external;
49
47
 
50
- /**
51
- * @dev returns true iff the policy application data in policyData matches
52
- * with the bundle filter criteria encoded in bundleFilter.
53
- */
48
+ /// @dev defines the multiplier to calculate the required collateral to cover a given sum insured amount
49
+ function getCollateralizationLevel() external view returns (UFixed collateralizationLevel);
50
+
51
+ /// @dev declares if pool intercept transfers of bundle nft ids
52
+ /// - yes: pool may block transfer of bundle ownership or simply updates some bookkeeping related to bundle ownership. callback function is nftTransferFrom
53
+ /// - no: pool is not involved in transfer of bundle ownership
54
+ function isInterceptingBundleTransfers() external view returns (bool);
55
+
56
+ /// @dev declares if pool relies on external management of collateral (yes/no):
57
+ /// - 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
58
+ /// - no: the pool smart contract ensures that the necessary capacity of the pool prior to underwriting.
59
+ function isExternallyManaged() external view returns (bool);
60
+
61
+ /// @dev declares if pool component is actively involved in underwriting (yes/no):
62
+ /// - 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
63
+ /// - no: underwriting a policy does not require any interaction with the pool component if the covering bundle can provide the necessary captial
64
+ function isVerifyingApplications() external view returns (bool);
65
+
66
+ /// @dev returns true iff the policy application data in policyData matches
67
+ /// with the bundle filter criteria encoded in bundleFilter
68
+ /// this is a callback function that is only called if a pool declares itself as a verifying pool
54
69
  function policyMatchesBundle(
55
70
  bytes memory policyData,
56
71
  bytes memory bundleFilter
@@ -59,8 +74,4 @@ interface IPoolComponent {
59
74
  view
60
75
  returns (bool isMatching);
61
76
 
62
- function isConfirmingApplication() external view returns (bool isConfirmingApplication);
63
-
64
- function getCollateralizationLevel() external view returns (UFixed collateralizationLevel);
65
-
66
77
  }
@@ -2,11 +2,15 @@
2
2
  pragma solidity ^0.8.20;
3
3
 
4
4
  import {Fee} from "../types/Fee.sol";
5
+ import {IComponent} from "./IComponent.sol";
6
+ import {ISetup} from "../instance/module/ISetup.sol";
5
7
  import {NftId} from "../types/NftId.sol";
6
8
  import {ReferralId} from "../types/Referral.sol";
7
9
  import {RiskId} from "../types/RiskId.sol";
8
10
 
9
- interface IProductComponent {
11
+ interface IProductComponent is IComponent {
12
+
13
+ function getSetupInfo() external view returns (ISetup.ProductSetupInfo memory setupInfo);
10
14
 
11
15
  function setFees(
12
16
  Fee memory productFee,
@@ -18,8 +22,8 @@ interface IProductComponent {
18
22
  RiskId riskId,
19
23
  uint256 lifetime,
20
24
  bytes memory applicationData,
21
- ReferralId referralId,
22
- NftId bundleNftId
25
+ NftId bundleNftId,
26
+ ReferralId referralId
23
27
  ) external view returns (uint256 premiumAmount);
24
28
 
25
29
  function calculateNetPremium(
@@ -1,122 +1,107 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {ObjectType, POOL} from "../types/ObjectType.sol";
5
- import {IProductService} from "../instance/service/IProductService.sol";
4
+ import {POOL} from "../types/ObjectType.sol";
6
5
  import {IPoolService} from "../instance/service/IPoolService.sol";
7
6
  import {IBundleService} from "../instance/service/IBundleService.sol";
8
- import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
7
+ import {NftId, NftIdLib} from "../types/NftId.sol";
9
8
  import {Fee} from "../types/Fee.sol";
10
9
  import {UFixed} from "../types/UFixed.sol";
11
10
  import {IPoolComponent} from "./IPoolComponent.sol";
12
- import {BaseComponent} from "./BaseComponent.sol";
11
+ import {Component} from "./Component.sol";
13
12
  import {TokenHandler} from "../shared/TokenHandler.sol";
14
13
  import {ISetup} from "../instance/module/ISetup.sol";
15
14
 
16
15
  import {IRegistry} from "../registry/IRegistry.sol";
17
16
 
18
- // import {IPool} from "../instance/module/pool/IPoolModule.sol";
19
- import {ITreasury} from "../instance/module/ITreasury.sol";
20
17
  import {ISetup} from "../instance/module/ISetup.sol";
21
18
  import {InstanceReader} from "../instance/InstanceReader.sol";
22
19
 
23
20
  import {IRegisterable} from "../shared/IRegisterable.sol";
24
21
  import {Registerable} from "../shared/Registerable.sol";
25
22
 
26
- abstract contract Pool is BaseComponent, IPoolComponent {
27
- using NftIdLib for NftId;
23
+ abstract contract Pool is
24
+ Component,
25
+ IPoolComponent
26
+ {
27
+ // keccak256(abi.encode(uint256(keccak256("gif-next.contracts.component.Pool.sol")) - 1)) & ~bytes32(uint256(0xff));
28
+ bytes32 public constant POOL_STORAGE_LOCATION_V1 = 0xecf35607b7e822969ee3625cd815bfc27031f3a93d0be2676e5bde943e2e2300;
28
29
 
29
- bool internal _isConfirmingApplication;
30
- UFixed internal _collateralizationLevel;
30
+ struct PoolStorage {
31
+ UFixed _collateralizationLevel;
31
32
 
32
- Fee internal _initialPoolFee;
33
- Fee internal _initialStakingFee;
34
- Fee internal _initialPerformanceFee;
33
+ bool _isExternallyManaged;
34
+ bool _isInterceptingBundleTransfers;
35
+ bool _isVerifyingApplications;
35
36
 
36
- TokenHandler internal _tokenHandler;
37
+ Fee _initialPoolFee;
38
+ Fee _initialStakingFee;
39
+ Fee _initialPerformanceFee;
37
40
 
38
- // may be used to interact with instance by derived contracts
39
- IPoolService internal _poolService;
41
+ TokenHandler _tokenHandler;
40
42
 
41
- // only relevant to protect callback functions for "active" pools
42
- IProductService private _productService;
43
-
44
- IBundleService private _bundleService;
43
+ // may be used to interact with instance by derived contracts
44
+ IPoolService _poolService;
45
+ IBundleService _bundleService;
46
+ }
45
47
 
46
48
  modifier onlyPoolService() {
47
- require(
48
- msg.sender == address(_poolService),
49
- "ERROR:POL-001:NOT_POOL_SERVICE");
49
+ if(msg.sender != address(_getStorage()._poolService)) {
50
+ revert ErrorPoolNotPoolService(msg.sender);
51
+ }
50
52
  _;
51
53
  }
52
54
 
53
- modifier onlyProductService() {
54
- require(
55
- msg.sender == address(_productService),
56
- "ERROR:POL-002:NOT_PRODUCT_SERVICE");
57
- _;
58
- }
59
55
 
60
- constructor(
56
+ function _initializePool(
61
57
  address registry,
62
58
  NftId instanceNftId,
59
+ string memory name,
63
60
  // TODO refactor into tokenNftId
64
61
  address token,
65
- bool isInterceptor,
66
- bool isConfirmingApplication,
67
62
  UFixed collateralizationLevel,
63
+ bool isInterceptingNftTransfers,
64
+ bool isExternallyManaging,
65
+ bool isVerifying,
68
66
  Fee memory poolFee,
69
67
  Fee memory stakingFee,
70
68
  Fee memory performanceFee,
71
- address initialOwner
69
+ address initialOwner,
70
+ bytes memory data
72
71
  )
73
- BaseComponent(registry, instanceNftId, token, POOL(), isInterceptor, initialOwner)
72
+ internal
73
+ //onlyInitializing//TODO uncomment when "fully" upgradeable
74
+ virtual
74
75
  {
75
- _isConfirmingApplication = isConfirmingApplication;
76
+ _initializeComponent(registry, instanceNftId, name, token, POOL(), isInterceptingNftTransfers, initialOwner, data);
77
+
78
+ PoolStorage storage $ = _getStorage();
79
+
80
+ $._isExternallyManaged = isExternallyManaging;
81
+ $._isVerifyingApplications = isVerifying;
82
+
76
83
  // TODO add validation
77
- _collateralizationLevel = collateralizationLevel;
78
- _initialPoolFee = poolFee;
79
- _initialStakingFee = stakingFee;
80
- _initialPerformanceFee = performanceFee;
84
+ $._collateralizationLevel = collateralizationLevel;
85
+ $._initialPoolFee = poolFee;
86
+ $._initialStakingFee = stakingFee;
87
+ $._initialPerformanceFee = performanceFee;
81
88
 
82
- _tokenHandler = new TokenHandler(token);
89
+ $._tokenHandler = new TokenHandler(token);
83
90
 
84
- _poolService = _instance.getPoolService();
85
- _productService = _instance.getProductService();
86
- _bundleService = _instance.getBundleService();
91
+ $._poolService = getInstance().getPoolService();
92
+ $._bundleService = getInstance().getBundleService();
87
93
 
88
94
  _registerInterface(type(IPoolComponent).interfaceId);
89
95
  }
90
96
 
91
- function createBundle(
92
- Fee memory fee,
93
- uint256 initialAmount,
94
- uint256 lifetime,
95
- bytes memory filter
96
- )
97
- external
98
- virtual override
99
- returns(NftId bundleNftId)
100
- {
101
- address owner = msg.sender;
102
- bundleNftId = _bundleService.createBundle(
103
- owner,
104
- fee,
105
- initialAmount,
106
- lifetime,
107
- filter
108
- );
109
-
110
- // TODO add logging
111
- }
112
97
 
113
98
  /**
114
- * @dev see {IPool.underwrite}.
99
+ * @dev see {IPool.verifyApplication}.
115
100
  * Default implementation that only writes a {LogUnderwrittenByPool} entry.
116
101
  */
117
- function underwrite(
118
- NftId policyNftId,
119
- bytes memory policyData,
102
+ function verifyApplication(
103
+ NftId applicationNftId,
104
+ bytes memory applicationData,
120
105
  bytes memory bundleFilter,
121
106
  uint256 collateralizationAmount
122
107
  )
@@ -124,19 +109,43 @@ abstract contract Pool is BaseComponent, IPoolComponent {
124
109
  onlyProductService
125
110
  virtual override
126
111
  {
127
- _underwrite(policyNftId, policyData, bundleFilter, collateralizationAmount);
112
+ require(
113
+ policyMatchesBundle(applicationData, bundleFilter),
114
+ "ERROR:POL-020:POLICY_BUNDLE_MISMATCH"
115
+ );
116
+
117
+ emit LogUnderwrittenByPool(applicationNftId, collateralizationAmount, address(this));
128
118
  }
129
119
 
130
- /**
131
- * @dev see {IPoolComponent.policyMatchesBundle}.
132
- * Default implementation always returns true
133
- */
120
+
121
+ function isInterceptingBundleTransfers() external view override returns (bool) {
122
+ return isNftInterceptor();
123
+ }
124
+
125
+
126
+ function isExternallyManaged() external view override returns (bool) {
127
+ return _getStorage()._isExternallyManaged;
128
+ }
129
+
130
+
131
+ function getCollateralizationLevel() external view override returns (UFixed collateralizationLevel) {
132
+ return _getStorage()._collateralizationLevel;
133
+ }
134
+
135
+
136
+ function isVerifyingApplications() external view override returns (bool isConfirmingApplication) {
137
+ return _getStorage()._isVerifyingApplications;
138
+ }
139
+
140
+
141
+ /// @dev see {IPoolComponent.policyMatchesBundle}.
142
+ /// Default implementation always returns true
134
143
  function policyMatchesBundle(
135
144
  bytes memory, // policyData
136
145
  bytes memory // bundleFilter
137
146
  )
138
147
  public
139
- view
148
+ pure
140
149
  virtual override
141
150
  returns (bool isMatching)
142
151
  {
@@ -144,14 +153,6 @@ abstract contract Pool is BaseComponent, IPoolComponent {
144
153
  }
145
154
 
146
155
 
147
- function isConfirmingApplication() external view override returns (bool isConfirmingApplication) {
148
- return _isConfirmingApplication;
149
- }
150
-
151
- function getCollateralizationLevel() external view override returns (UFixed collateralizationLevel) {
152
- return _collateralizationLevel;
153
- }
154
-
155
156
  function setFees(
156
157
  Fee memory poolFee,
157
158
  Fee memory stakingFee,
@@ -161,7 +162,7 @@ abstract contract Pool is BaseComponent, IPoolComponent {
161
162
  onlyOwner
162
163
  override
163
164
  {
164
- _poolService.setFees(poolFee, stakingFee, performanceFee);
165
+ _getStorage()._poolService.setFees(poolFee, stakingFee, performanceFee);
165
166
  }
166
167
 
167
168
  function setBundleFee(
@@ -172,7 +173,7 @@ abstract contract Pool is BaseComponent, IPoolComponent {
172
173
  override
173
174
  // TODO add onlyBundleOwner
174
175
  {
175
- _bundleService.setBundleFee(bundleNftId, fee);
176
+ _getStorage()._bundleService.setBundleFee(bundleNftId, fee);
176
177
  }
177
178
 
178
179
  function lockBundle(
@@ -182,7 +183,7 @@ abstract contract Pool is BaseComponent, IPoolComponent {
182
183
  override
183
184
  // TODO add onlyBundleOwner
184
185
  {
185
- _bundleService.lockBundle(bundleNftId);
186
+ _getStorage()._bundleService.lockBundle(bundleNftId);
186
187
  }
187
188
 
188
189
  function unlockBundle(
@@ -192,81 +193,65 @@ abstract contract Pool is BaseComponent, IPoolComponent {
192
193
  override
193
194
  // TODO add onlyBundleOwner
194
195
  {
195
- _bundleService.unlockBundle(bundleNftId);
196
+ _getStorage()._bundleService.unlockBundle(bundleNftId);
196
197
  }
197
198
 
198
199
  function getSetupInfo() public view returns (ISetup.PoolSetupInfo memory setupInfo) {
199
- InstanceReader reader = _instance.getInstanceReader();
200
- return reader.getPoolSetupInfo(getNftId());
201
- }
200
+ InstanceReader reader = getInstance().getInstanceReader();
201
+ setupInfo = reader.getPoolSetupInfo(getNftId());
202
202
 
203
- // from IRegisterable
203
+ // fallback to initial setup info (wallet is always != address(0))
204
+ if(setupInfo.wallet == address(0)) {
205
+ setupInfo = _getInitialSetupInfo();
206
+ }
207
+ }
204
208
 
205
- // TODO used only once, occupies space
206
- // TODO do not use super
207
- function getInitialInfo()
208
- public
209
- view
210
- override (IRegisterable, Registerable)
211
- returns (IRegistry.ObjectInfo memory, bytes memory)
212
- {
213
- (
214
- IRegistry.ObjectInfo memory info,
215
- ) = super.getInitialInfo();
216
-
217
- return (
218
- info,
219
- abi.encode(
220
- getName(),
221
- ISetup.PoolSetupInfo(
222
- _productNftId,
223
- _tokenHandler,
224
- _collateralizationLevel,
225
- _initialPoolFee,
226
- _initialStakingFee,
227
- _initialPerformanceFee,
228
- false,
229
- _isConfirmingApplication,
230
- _wallet
231
- )
232
- )
209
+ function _getInitialSetupInfo() internal view returns (ISetup.PoolSetupInfo memory) {
210
+ PoolStorage storage $ = _getStorage();
211
+ return ISetup.PoolSetupInfo(
212
+ getProductNftId(),
213
+ $._tokenHandler,
214
+ $._collateralizationLevel,
215
+ $._initialPoolFee,
216
+ $._initialStakingFee,
217
+ $._initialPerformanceFee,
218
+ isNftInterceptor(),
219
+ $._isVerifyingApplications,
220
+ getWallet()
233
221
  );
234
222
  }
235
223
 
236
224
  // Internals
237
225
 
238
- function _underwrite(
239
- NftId policyNftId,
240
- bytes memory policyData,
241
- bytes memory bundleFilter,
242
- uint256 collateralizationAmount
243
- )
244
- internal
245
- {
246
- require(
247
- policyMatchesBundle(policyData, bundleFilter),
248
- "ERROR:POL-020:POLICY_BUNDLE_MISMATCH"
249
- );
250
-
251
- emit LogUnderwrittenByPool(policyNftId, collateralizationAmount, address(this));
252
- }
253
-
254
226
  function _createBundle(
255
227
  address bundleOwner,
256
228
  Fee memory fee,
257
229
  uint256 amount,
258
230
  uint256 lifetime,
259
- bytes calldata filter
231
+ bytes memory filter
260
232
  )
261
233
  internal
262
234
  returns(NftId bundleNftId)
263
235
  {
264
- bundleNftId = _bundleService.createBundle(
236
+ bundleNftId = _getStorage()._bundleService.createBundle(
265
237
  bundleOwner,
266
238
  fee,
267
239
  amount,
268
240
  lifetime,
269
- filter
270
- );
241
+ filter);
242
+
243
+ // TODO add logging
244
+ }
245
+
246
+ function getContractLocation(bytes memory name) external pure returns (bytes32 hash) {
247
+ return keccak256(abi.encode(uint256(keccak256(name)) - 1)) & ~bytes32(uint256(0xff));
271
248
  }
249
+
250
+
251
+ function _getStorage() private pure returns (PoolStorage storage $) {
252
+ assembly {
253
+ $.slot := POOL_STORAGE_LOCATION_V1
254
+ }
255
+ }
256
+
272
257
  }