@etherisc/gif-next 0.0.2-bdcb44f-543 → 0.0.2-be8b3db-650

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
  2. package/artifacts/contracts/components/Component.sol/Component.json +40 -0
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.json +41 -19
  5. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
  6. package/artifacts/contracts/components/IComponent.sol/IComponent.json +40 -0
  7. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +41 -19
  9. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +57 -150
  11. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +40 -0
  13. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  14. package/artifacts/contracts/components/Pool.sol/Pool.json +76 -189
  15. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  16. package/artifacts/contracts/components/Product.sol/Product.json +40 -0
  17. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  18. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +30 -11
  19. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  20. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  21. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +32 -174
  22. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  23. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  24. package/artifacts/contracts/instance/Instance.sol/Instance.json +103 -238
  25. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  26. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +2 -2
  27. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  28. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +73 -144
  29. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  30. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +32 -32
  31. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  32. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +17 -17
  33. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  34. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
  35. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
  36. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  37. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  38. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  39. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +40 -10
  40. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  41. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +36 -11
  42. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  43. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  44. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +4 -0
  45. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.json +10 -0
  46. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  47. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  48. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  49. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  50. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  51. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  52. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +14 -14
  53. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  54. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +8 -8
  55. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  56. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +132 -135
  57. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  58. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +12 -12
  59. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
  60. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +2 -2
  61. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  62. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +2 -2
  63. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  64. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +234 -63
  65. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  66. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +40 -32
  67. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  68. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  69. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +89 -92
  70. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
  71. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  72. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +156 -1
  73. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  74. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +21 -0
  75. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  76. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +81 -0
  77. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  78. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +31 -10
  80. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +6 -6
  82. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +105 -16
  84. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  85. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +13 -9
  86. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  87. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +2 -2
  88. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  89. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +2 -2
  90. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  91. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +15 -2
  92. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  93. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  94. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  95. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  96. package/artifacts/contracts/registry/Registry.sol/Registry.json +4 -4
  97. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  98. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
  99. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  100. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +12 -12
  101. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  102. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +7 -7
  103. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  104. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +3 -3
  105. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  106. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  107. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  108. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  109. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  110. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  111. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  112. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  113. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  114. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  115. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  116. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  117. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  118. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
  119. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  120. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  121. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  122. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  123. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  124. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  125. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  126. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  127. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
  128. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  129. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  130. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  131. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  132. package/artifacts/contracts/test/TestFee.sol/TestFee.json +2 -2
  133. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  134. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  135. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  136. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  137. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  138. package/artifacts/contracts/test/TestService.sol/TestService.json +2 -2
  139. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  140. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  141. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  142. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  143. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
  144. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  145. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  146. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  147. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
  148. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  149. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  150. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  151. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
  152. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  153. package/artifacts/contracts/types/Fee.sol/FeeLib.json +2 -2
  154. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  155. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  156. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  157. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +17 -4
  158. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  159. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  160. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  161. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  163. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +23 -4
  166. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  168. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  169. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  170. package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  172. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  173. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +2 -2
  175. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  176. package/artifacts/contracts/types/UFixed.sol/MathLib.json +2 -2
  177. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  178. package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +2 -2
  179. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  180. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  181. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  182. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
  183. package/contracts/components/Component.sol +20 -0
  184. package/contracts/components/Distribution.sol +0 -13
  185. package/contracts/components/IComponent.sol +6 -0
  186. package/contracts/components/IDistributionComponent.sol +0 -8
  187. package/contracts/components/IPoolComponent.sol +5 -43
  188. package/contracts/components/Pool.sol +38 -117
  189. package/contracts/components/Product.sol +4 -0
  190. package/contracts/instance/BundleManager.sol +6 -4
  191. package/contracts/instance/IInstance.sol +3 -2
  192. package/contracts/instance/IInstanceService.sol +2 -1
  193. package/contracts/instance/Instance.sol +8 -4
  194. package/contracts/instance/InstanceReader.sol +4 -3
  195. package/contracts/instance/InstanceService.sol +5 -6
  196. package/contracts/instance/base/KeyValueStore.sol +5 -2
  197. package/contracts/instance/base/Lifecycle.sol +11 -2
  198. package/contracts/instance/module/IComponents.sol +35 -0
  199. package/contracts/instance/module/ISetup.sol +4 -17
  200. package/contracts/instance/service/ApplicationService.sol +6 -5
  201. package/contracts/instance/service/BundleService.sol +72 -35
  202. package/contracts/instance/service/DistributionService.sol +75 -19
  203. package/contracts/instance/service/IBundleService.sol +16 -9
  204. package/contracts/instance/service/IDistributionService.sol +13 -1
  205. package/contracts/instance/service/IPolicyService.sol +2 -0
  206. package/contracts/instance/service/IPoolService.sol +17 -2
  207. package/contracts/instance/service/PolicyService.sol +46 -45
  208. package/contracts/instance/service/PoolService.sol +72 -18
  209. package/contracts/registry/ChainNft.sol +4 -0
  210. package/contracts/registry/Registry.sol +10 -12
  211. package/contracts/shared/TokenHandler.sol +11 -5
  212. package/contracts/types/Blocknumber.sol +1 -0
  213. package/contracts/types/Fee.sol +1 -0
  214. package/contracts/types/NftId.sol +8 -0
  215. package/contracts/types/ObjectType.sol +1 -0
  216. package/contracts/types/Referral.sol +4 -0
  217. package/contracts/types/StateId.sol +1 -0
  218. package/contracts/types/Timestamp.sol +1 -0
  219. package/contracts/types/UFixed.sol +1 -0
  220. package/contracts/types/Version.sol +1 -0
  221. package/package.json +1 -1
@@ -7,13 +7,13 @@ import {IBundleService} from "../instance/service/IBundleService.sol";
7
7
  import {InstanceReader} from "../instance/InstanceReader.sol";
8
8
  import {IPoolComponent} from "./IPoolComponent.sol";
9
9
  import {IPoolService} from "../instance/service/IPoolService.sol";
10
- import {ISetup} from "../instance/module/ISetup.sol";
10
+ import {IComponents} from "../instance/module/IComponents.sol";
11
11
  import {NftId, NftIdLib} from "../types/NftId.sol";
12
12
  import {POOL} from "../types/ObjectType.sol";
13
13
  import {RoleId, PUBLIC_ROLE} from "../types/RoleId.sol";
14
14
  import {Seconds} from "../types/Seconds.sol";
15
15
  import {TokenHandler} from "../shared/TokenHandler.sol";
16
- import {UFixed} from "../types/UFixed.sol";
16
+ import {UFixed, UFixedLib} from "../types/UFixed.sol";
17
17
 
18
18
 
19
19
  abstract contract Pool is
@@ -24,23 +24,6 @@ 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
- uint256 _maxCapitalAmount;
30
-
31
- bool _isExternallyManaged;
32
- bool _isVerifyingApplications;
33
-
34
- RoleId _bundleOwnerRole;
35
- bool _isInterceptingBundleTransfers;
36
-
37
- Fee _initialPoolFee;
38
- Fee _initialStakingFee;
39
- Fee _initialPerformanceFee;
40
-
41
- TokenHandler _tokenHandler;
42
-
43
- // may be used to interact with instance by derived contracts
44
27
  IPoolService _poolService;
45
28
  IBundleService _bundleService;
46
29
  }
@@ -68,10 +51,6 @@ abstract contract Pool is
68
51
  string memory name,
69
52
  address token,
70
53
  bool isInterceptingNftTransfers,
71
- bool isExternallyManaging,
72
- bool isVerifying,
73
- UFixed collateralizationLevel,
74
- UFixed retentionLevel,
75
54
  address initialOwner,
76
55
  bytes memory registryData // writeonly data that will saved in the object info record of the registry
77
56
  )
@@ -82,17 +61,6 @@ abstract contract Pool is
82
61
  initializeComponent(registry, instanceNftId, name, token, POOL(), isInterceptingNftTransfers, initialOwner, registryData);
83
62
 
84
63
  PoolStorage storage $ = _getPoolStorage();
85
- // TODO add validation
86
- $._tokenHandler = new TokenHandler(token);
87
- $._maxCapitalAmount = type(uint256).max;
88
- $._isExternallyManaged = isExternallyManaging;
89
- $._isVerifyingApplications = isVerifying;
90
- $._bundleOwnerRole = PUBLIC_ROLE();
91
- $._collateralizationLevel = collateralizationLevel;
92
- $._retentionLevel = retentionLevel;
93
- $._initialPoolFee = FeeLib.zeroFee();
94
- $._initialStakingFee = FeeLib.zeroFee();
95
- $._initialPerformanceFee = FeeLib.zeroFee();
96
64
  $._poolService = getInstance().getPoolService();
97
65
  $._bundleService = getInstance().getBundleService();
98
66
 
@@ -145,7 +113,7 @@ abstract contract Pool is
145
113
  restricted()
146
114
  onlyBundleOwner(bundleNftId)
147
115
  {
148
- _getPoolStorage()._bundleService.lockBundle(bundleNftId);
116
+ _getPoolStorage()._bundleService.lock(bundleNftId);
149
117
  }
150
118
 
151
119
 
@@ -155,7 +123,7 @@ abstract contract Pool is
155
123
  restricted()
156
124
  onlyBundleOwner(bundleNftId)
157
125
  {
158
- _getPoolStorage()._bundleService.unlockBundle(bundleNftId);
126
+ _getPoolStorage()._bundleService.unlock(bundleNftId);
159
127
  }
160
128
 
161
129
 
@@ -165,7 +133,7 @@ abstract contract Pool is
165
133
  restricted()
166
134
  onlyBundleOwner(bundleNftId)
167
135
  {
168
- // TODO add implementation
136
+ _getPoolStorage()._bundleService.close(bundleNftId);
169
137
  }
170
138
 
171
139
 
@@ -178,7 +146,7 @@ abstract contract Pool is
178
146
  restricted()
179
147
  onlyBundleOwner(bundleNftId)
180
148
  {
181
- _getPoolStorage()._bundleService.setBundleFee(bundleNftId, fee);
149
+ _getPoolStorage()._bundleService.setFee(bundleNftId, fee);
182
150
  }
183
151
 
184
152
 
@@ -188,13 +156,7 @@ abstract contract Pool is
188
156
  restricted()
189
157
  onlyOwner()
190
158
  {
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);
159
+ _getPoolStorage()._poolService.setMaxCapitalAmount(maxCapitalAmount);
198
160
  }
199
161
 
200
162
 
@@ -204,16 +166,7 @@ abstract contract Pool is
204
166
  restricted()
205
167
  onlyOwner()
206
168
  {
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);
169
+ _getPoolStorage()._poolService.setBundleOwnerRole(bundleOwnerRole);
217
170
  }
218
171
 
219
172
 
@@ -243,7 +196,6 @@ abstract contract Pool is
243
196
  virtual
244
197
  restricted()
245
198
  {
246
- // validate application data against bundle filter
247
199
  if(!applicationMatchesBundle(
248
200
  applicationNftId,
249
201
  applicationData,
@@ -259,41 +211,6 @@ abstract contract Pool is
259
211
  }
260
212
 
261
213
 
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;
294
- }
295
-
296
-
297
214
  /// @dev see {IPoolComponent.applicationMatchesBundle}
298
215
  /// Override this function to implement any custom application verification
299
216
  /// Default implementation always returns true
@@ -313,14 +230,8 @@ abstract contract Pool is
313
230
  }
314
231
 
315
232
 
316
- function getSetupInfo() public view returns (ISetup.PoolSetupInfo memory setupInfo) {
317
- InstanceReader reader = getInstance().getInstanceReader();
318
- setupInfo = reader.getPoolSetupInfo(getNftId());
319
-
320
- // fallback to initial setup info (wallet is always != address(0))
321
- if(setupInfo.wallet == address(0)) {
322
- setupInfo = _getInitialSetupInfo();
323
- }
233
+ function getPoolInfo() external view returns (IComponents.PoolInfo memory poolInfo) {
234
+ poolInfo = abi.decode(getComponentInfo().data, (IComponents.PoolInfo));
324
235
  }
325
236
 
326
237
  // Internals
@@ -335,7 +246,7 @@ abstract contract Pool is
335
246
  internal
336
247
  returns(NftId bundleNftId)
337
248
  {
338
- bundleNftId = _getPoolStorage()._bundleService.createBundle(
249
+ bundleNftId = _getPoolStorage()._bundleService.create(
339
250
  bundleOwner,
340
251
  fee,
341
252
  amount,
@@ -350,23 +261,33 @@ abstract contract Pool is
350
261
  return keccak256(abi.encode(uint256(keccak256(name)) - 1)) & ~bytes32(uint256(0xff));
351
262
  }
352
263
 
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
- );
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
+ )));
370
291
  }
371
292
 
372
293
 
@@ -24,6 +24,7 @@ import {TokenHandler} from "../shared/TokenHandler.sol";
24
24
  import {InstanceReader} from "../instance/InstanceReader.sol";
25
25
  import {IPolicy} from "../instance/module/IPolicy.sol";
26
26
  import {ISetup} from "../instance/module/ISetup.sol";
27
+ import {IComponents} from "../instance/module/IComponents.sol";
27
28
  import {Pool} from "../components/Pool.sol";
28
29
  import {Distribution} from "../components/Distribution.sol";
29
30
 
@@ -265,6 +266,9 @@ abstract contract Product is
265
266
  function _getInitialSetupInfo() internal view returns (ISetup.ProductSetupInfo memory setupInfo) {
266
267
  ProductStorage storage $ = _getProductStorage();
267
268
 
269
+ ISetup.DistributionSetupInfo memory distributionSetupInfo = $._distribution.getSetupInfo();
270
+ IComponents.PoolInfo memory poolInfo = $._pool.getPoolInfo();
271
+
268
272
  return ISetup.ProductSetupInfo(
269
273
  getToken(),
270
274
  $._tokenHandler,
@@ -22,9 +22,10 @@ contract BundleManager is
22
22
  event LogBundleManagerBundleAdded(NftId poolNftId, NftId bundleNftId);
23
23
  event LogBundleManagerBundleUnlocked(NftId poolNftId, NftId bundleNftId);
24
24
  event LogBundleManagerBundleLocked(NftId poolNftId, NftId bundleNftId);
25
+ event LogBundleManagerBundleClosed(NftId poolNftId, NftId bundleNftId);
25
26
 
26
- error ErrorBundleManagerErrorPolicyAlreadyActivated(NftId policyNftId);
27
- error ErrorBundleManagerErrorBundleLocked(NftId bundleNftId, NftId policyNftId);
27
+ error ErrorBundleManagerPolicyAlreadyActivated(NftId policyNftId);
28
+ error ErrorBundleManagerBundleLocked(NftId bundleNftId, NftId policyNftId);
28
29
  error ErrorBundleManagerPolicyWithOpenClaims(NftId policyNftId, uint256 openClaimsCount);
29
30
  error ErrorBundleManagerPolicyNotCloseable(NftId policyNftId);
30
31
  error ErrorBundleManagerBundleUnknown(NftId bundleNftId);
@@ -32,7 +33,7 @@ contract BundleManager is
32
33
 
33
34
  mapping(NftId bundleNftId => LibNftIdSet.Set policies) internal _activePolicies;
34
35
 
35
- /// @dev links a policy with its bundle
36
+ /// @dev links a policy to its bundle
36
37
  // to link a policy it MUST NOT yet have been activated
37
38
  // the bundle MUST be unlocked (active) for linking (underwriting) and registered with this instance
38
39
  function linkPolicy(NftId policyNftId) external restricted() {
@@ -42,7 +43,7 @@ contract BundleManager is
42
43
 
43
44
  // ensure bundle is unlocked (in active set) and registered with this instance
44
45
  if (!_isActive(poolNftId, bundleNftId)) {
45
- revert ErrorBundleManagerErrorBundleLocked(bundleNftId, policyNftId);
46
+ revert ErrorBundleManagerBundleLocked(bundleNftId, policyNftId);
46
47
  }
47
48
 
48
49
  LibNftIdSet.add(_activePolicies[bundleNftId], policyNftId);
@@ -85,6 +86,7 @@ contract BundleManager is
85
86
  emit LogBundleManagerBundleAdded(poolNftId, bundleNftId);
86
87
  }
87
88
 
89
+
88
90
  /// @dev unlocked (active) bundles are available to underwrite new policies
89
91
  function unlock(NftId bundleNftId) external restricted() {
90
92
  NftId poolNftId = _instance.getInstanceReader().getBundleInfo(bundleNftId).poolNftId;
@@ -15,6 +15,7 @@ import {InstanceReader} from "./InstanceReader.sol";
15
15
 
16
16
  import {IBundle} from "./module/IBundle.sol";
17
17
  import {IBundleService} from "./service/IBundleService.sol";
18
+ import {IComponents} from "./module/IComponents.sol";
18
19
  import {IDistributionService} from "./service/IDistributionService.sol";
19
20
  import {InstanceAccessManager} from "./InstanceAccessManager.sol";
20
21
  import {IKeyValueStore} from "./base/IKeyValueStore.sol";
@@ -48,8 +49,8 @@ interface IInstance is IRegisterable, IKeyValueStore, IAccessManaged {
48
49
  function updateDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup, StateId newState) external;
49
50
  function updateDistributionSetupState(NftId distributionNftId, StateId newState) external;
50
51
 
51
- function createPoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup) external;
52
- function updatePoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup, StateId newState) external;
52
+ function createPoolSetup(NftId poolNftId, IComponents.ComponentInfo memory info) external;
53
+ function updatePoolSetup(NftId poolNftId, IComponents.ComponentInfo memory info, StateId newState) external;
53
54
  function updatePoolSetupState(NftId poolNftId, StateId newState) external;
54
55
 
55
56
  function createBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle) external;
@@ -52,8 +52,9 @@ interface IInstanceService is IService {
52
52
  BundleManager clonedBundleManager
53
53
  );
54
54
 
55
- function hasRole(address account, RoleId role, address instanceAddress) external returns (bool);
56
55
  function setTargetLocked(string memory targetName, bool locked) external;
57
56
 
57
+ function hasRole(address account, RoleId role, address instanceAddress) external returns (bool);
58
+
58
59
  }
59
60
 
@@ -26,6 +26,7 @@ import {KeyValueStore} from "./base/KeyValueStore.sol";
26
26
 
27
27
  import {IAccess} from "./module/IAccess.sol";
28
28
  import {IBundle} from "./module/IBundle.sol";
29
+ import {IComponents} from "./module/IComponents.sol";
29
30
  import {IDistribution} from "./module/IDistribution.sol";
30
31
  import {IPolicy} from "./module/IPolicy.sol";
31
32
  import {IRisk} from "./module/IRisk.sol";
@@ -36,6 +37,7 @@ import {IPoolService} from "./service/IPoolService.sol";
36
37
  import {IProductService} from "./service/IProductService.sol";
37
38
  import {IPolicyService} from "./service/IPolicyService.sol";
38
39
  import {IBundleService} from "./service/IBundleService.sol";
40
+ import {TokenHandler} from "../shared/TokenHandler.sol";
39
41
  import {VersionPart, VersionPartLib} from "../types/Version.sol";
40
42
 
41
43
  contract Instance is
@@ -66,6 +68,8 @@ contract Instance is
66
68
  __AccessManaged_init(accessManagerAddress);
67
69
 
68
70
  initializeRegisterable(registryAddress, registryNftId, INSTANCE(), false, initialOwner, "");
71
+ initializeLifecycle();
72
+
69
73
  registerInterface(type(IInstance).interfaceId);
70
74
  }
71
75
 
@@ -96,12 +100,12 @@ contract Instance is
96
100
  }
97
101
 
98
102
  //--- PoolSetup ------------------------------------------------------//
99
- function createPoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup) external restricted() {
100
- create(_toNftKey32(poolNftId, POOL()), abi.encode(setup));
103
+ function createPoolSetup(NftId poolNftId, IComponents.ComponentInfo memory info) external restricted() {
104
+ create(_toNftKey32(poolNftId, POOL()), abi.encode(info));
101
105
  }
102
106
 
103
- function updatePoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup, StateId newState) external restricted() {
104
- update(_toNftKey32(poolNftId, POOL()), abi.encode(setup), newState);
107
+ function updatePoolSetup(NftId poolNftId, IComponents.ComponentInfo memory info, StateId newState) external restricted() {
108
+ update(_toNftKey32(poolNftId, POOL()), abi.encode(info), newState);
105
109
  }
106
110
 
107
111
  function updatePoolSetupState(NftId poolNftId, StateId newState) external restricted() {
@@ -17,6 +17,7 @@ import {StateId} from "../types/StateId.sol";
17
17
 
18
18
  import {IRegistry} from "../registry/IRegistry.sol";
19
19
  import {IBundle} from "../instance/module/IBundle.sol";
20
+ import {IComponents} from "../instance/module/IComponents.sol";
20
21
  import {IDistribution} from "../instance/module/IDistribution.sol";
21
22
  import {IInstance} from "./IInstance.sol";
22
23
  import {IKeyValueStore} from "../instance/base/IKeyValueStore.sol";
@@ -151,14 +152,14 @@ contract InstanceReader {
151
152
  }
152
153
  }
153
154
 
154
- function getPoolSetupInfo(NftId poolNftId)
155
+ function getComponentInfo(NftId poolNftId)
155
156
  public
156
157
  view
157
- returns (ISetup.PoolSetupInfo memory info)
158
+ returns (IComponents.ComponentInfo memory info)
158
159
  {
159
160
  bytes memory data = _store.getData(toPoolKey(poolNftId));
160
161
  if (data.length > 0) {
161
- return abi.decode(data, (ISetup.PoolSetupInfo));
162
+ return abi.decode(data, (IComponents.ComponentInfo));
162
163
  }
163
164
  }
164
165
 
@@ -234,9 +234,10 @@ contract InstanceService is
234
234
  // configure authorization for bundle service on instance
235
235
  address bundleServiceAddress = getRegistry().getServiceAddress(BUNDLE(), getMajorVersion());
236
236
  clonedAccessManager.grantRole(BUNDLE_SERVICE_ROLE(), address(bundleServiceAddress));
237
- bytes4[] memory instanceBundleServiceSelectors = new bytes4[](2);
237
+ bytes4[] memory instanceBundleServiceSelectors = new bytes4[](3);
238
238
  instanceBundleServiceSelectors[0] = clonedInstance.createBundle.selector;
239
239
  instanceBundleServiceSelectors[1] = clonedInstance.updateBundle.selector;
240
+ instanceBundleServiceSelectors[2] = clonedInstance.updateBundleState.selector;
240
241
  clonedAccessManager.setTargetFunctionRole(
241
242
  "Instance",
242
243
  instanceBundleServiceSelectors,
@@ -410,9 +411,8 @@ contract InstanceService is
410
411
  fctSelectors[0] = IDistributionComponent.setFees.selector;
411
412
  instanceAccessManager.setTargetFunctionRole(distributionName, fctSelectors, DISTRIBUTION_OWNER_ROLE());
412
413
 
413
- bytes4[] memory fctSelectors2 = new bytes4[](2);
414
- fctSelectors2[0] = IDistributionComponent.processSale.selector;
415
- fctSelectors2[1] = IDistributionComponent.processRenewal.selector;
414
+ bytes4[] memory fctSelectors2 = new bytes4[](1);
415
+ fctSelectors2[0] = IDistributionComponent.processRenewal.selector;
416
416
  instanceAccessManager.setTargetFunctionRole(distributionName, fctSelectors2, PRODUCT_SERVICE_ROLE());
417
417
  }
418
418
 
@@ -448,7 +448,7 @@ contract InstanceService is
448
448
  instanceAccessManager.setTargetFunctionRole(
449
449
  poolName,
450
450
  fctSelectors3,
451
- IPoolComponent(poolAddress).getBundleOwnerRole());
451
+ IPoolComponent(poolAddress).getPoolInfo().bundleOwnerRole);
452
452
  }
453
453
 
454
454
  function grantProductDefaultPermissions(NftId instanceNftId, address productAddress, string memory productName) external onlyRegisteredService {
@@ -485,6 +485,5 @@ contract InstanceService is
485
485
  InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
486
486
  accessManager.setTargetClosed(targetName, locked);
487
487
  }
488
-
489
488
  }
490
489
 
@@ -88,7 +88,7 @@ contract KeyValueStore is Lifecycle, IKeyValueStore {
88
88
 
89
89
  // create log entries
90
90
  // solhint-disable avoid-tx-origin
91
- emit LogStateUpdated(key32.toObjectType(), key32.toKeyId(), state, stateOld, updatedBy, tx.origin, lastUpdatedIn);
91
+ emit LogStateUpdated(key32.toObjectType(), key32.toKeyId(), stateOld, state, updatedBy, tx.origin, lastUpdatedIn);
92
92
  emit LogInfoUpdated(key32.toObjectType(), key32.toKeyId(), state, updatedBy, tx.origin, lastUpdatedIn);
93
93
  // solhing-enable
94
94
  }
@@ -134,6 +134,9 @@ contract KeyValueStore is Lifecycle, IKeyValueStore {
134
134
  StateId stateOld = metadata.state;
135
135
  require(stateOld.gtz(), "ERROR:KVS-041:NOT_EXISTING");
136
136
 
137
+ // ensure state transistion is valid
138
+ checkTransition(metadata.objectType, stateOld, state);
139
+
137
140
  // update metadata (and state)
138
141
  address updatedBy = msg.sender;
139
142
  Blocknumber lastUpdatedIn = metadata.updatedIn;
@@ -143,7 +146,7 @@ contract KeyValueStore is Lifecycle, IKeyValueStore {
143
146
 
144
147
  // create log entry
145
148
  // solhint-disable-next-line avoid-tx-origin
146
- emit LogStateUpdated(key32.toObjectType(), key32.toKeyId(), state, stateOld, updatedBy, tx.origin, lastUpdatedIn);
149
+ emit LogStateUpdated(key32.toObjectType(), key32.toKeyId(), stateOld, state, updatedBy, tx.origin, lastUpdatedIn);
147
150
  }
148
151
 
149
152
  function exists(Key32 key32) public view returns (bool) {
@@ -1,19 +1,27 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
+ import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
5
+
4
6
  import {NftId} from "../../types/NftId.sol";
5
7
  import {ObjectType, COMPONENT, BUNDLE, POLICY, RISK} from "../../types/ObjectType.sol";
6
8
  import {StateId, ACTIVE, PAUSED, ARCHIVED, CLOSED, APPLIED, UNDERWRITTEN, REVOKED, DECLINED} from "../../types/StateId.sol";
7
9
  import {ILifecycle} from "./ILifecycle.sol";
8
10
 
9
- contract Lifecycle is ILifecycle {
11
+ contract Lifecycle is
12
+ Initializable,
13
+ ILifecycle
14
+ {
10
15
  mapping(ObjectType objectType => StateId initialState)
11
16
  private _initialState;
12
17
 
13
18
  mapping(ObjectType objectType => mapping(StateId stateFrom => mapping(StateId stateTo => bool isValid)))
14
19
  private _isValidTransition;
15
20
 
16
- constructor() {
21
+ function initializeLifecycle()
22
+ public
23
+ onlyInitializing
24
+ {
17
25
  _setupBundleLifecycle();
18
26
  _setupComponentLifecycle();
19
27
  _setupPolicyLifecycle();
@@ -78,6 +86,7 @@ contract Lifecycle is ILifecycle {
78
86
  function _setupBundleLifecycle() internal {
79
87
  _initialState[BUNDLE()] = ACTIVE();
80
88
  _isValidTransition[BUNDLE()][ACTIVE()][PAUSED()] = true;
89
+ _isValidTransition[BUNDLE()][ACTIVE()][CLOSED()] = true;
81
90
  _isValidTransition[BUNDLE()][PAUSED()][ACTIVE()] = true;
82
91
  _isValidTransition[BUNDLE()][PAUSED()][CLOSED()] = true;
83
92
  }
@@ -0,0 +1,35 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
+
6
+ import {Fee} from "../../types/Fee.sol";
7
+ import {NftId} from "../../types/NftId.sol";
8
+ import {RoleId} from "../../types/RoleId.sol";
9
+ import {TokenHandler} from "../../shared/TokenHandler.sol";
10
+ import {UFixed} from "../../types/UFixed.sol";
11
+
12
+ interface IComponents {
13
+
14
+ struct ComponentInfo {
15
+ string name; // component name (needs to be unique per instance)
16
+ IERC20Metadata token;
17
+ TokenHandler tokenHandler;
18
+ address wallet;
19
+ bytes data; // will hold component type specific additional info (eg encoded pool info)
20
+ }
21
+
22
+ struct PoolInfo {
23
+ NftId productNftId; // the nft of the product this pool is linked to
24
+ RoleId bundleOwnerRole; // the required role for bundle owners
25
+ uint256 maxCapitalAmount; // max capital amount allowed for pool
26
+ bool isInterceptingBundleTransfers; // intercepts nft transfers for bundles
27
+ bool isExternallyManaged; // funding bundles is restricted to book keeping, actual funds may be provided as needed to support payouts
28
+ bool isVerifyingApplications; // underwriting requires the pool component checks/confirms the applications
29
+ UFixed collateralizationLevel; // factor to calculate collateral for sum insurance (default 100%)
30
+ UFixed retentionLevel; // amount of collateral held in pool (default 100%)
31
+ Fee poolFee; // pool fee on net premium
32
+ Fee stakingFee; // pool fee on staked capital from investor
33
+ Fee performanceFee; // pool fee on profits from capital investors
34
+ }
35
+ }
@@ -5,10 +5,12 @@ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IER
5
5
 
6
6
  import {Fee} from "../../types/Fee.sol";
7
7
  import {NftId} from "../../types/NftId.sol";
8
- import {UFixed} from "../../types/UFixed.sol";
8
+ import {RoleId} from "../../types/RoleId.sol";
9
9
  import {TokenHandler} from "../../shared/TokenHandler.sol";
10
+ import {UFixed} from "../../types/UFixed.sol";
10
11
 
11
12
  interface ISetup {
13
+
12
14
  struct ProductSetupInfo {
13
15
  IERC20Metadata token;
14
16
  TokenHandler tokenHandler;
@@ -26,21 +28,6 @@ interface ISetup {
26
28
  Fee minDistributionOwnerFee;
27
29
  Fee distributionFee; // recalculated whenever any fee on the product/pool/dist/disttype is changed
28
30
  address wallet;
29
- uint256 sumDistributionFees;
30
- }
31
-
32
- struct PoolSetupInfo {
33
- NftId productNftId;
34
- TokenHandler tokenHandler;
35
- uint256 maxCapitalAmount; // max capital amount allowed for pool
36
- bool isInterceptingBundleTransfers; // intercepts nft transfers for bundles
37
- bool isExternallyManaged; // funding bundles is restricted to book keeping, actual funds may be provided as needed to support payouts
38
- bool isVerifyingApplications; // underwriting requires the pool component checks/confirms the applications
39
- UFixed collateralizationLevel; // factor to calculate collateral for sum insurance (default 100%)
40
- UFixed retentionLevel; // amount of collateral held in pool (default 100%)
41
- Fee poolFee; // pool fee on net premium
42
- Fee stakingFee; // pool fee on staked capital from investor
43
- Fee performanceFee; // pool fee on profits from capital investors
44
- address wallet;
31
+ uint256 sumDistributionOwnerFees;
45
32
  }
46
33
  }
@@ -10,6 +10,7 @@ import {Product} from "../../components/Product.sol";
10
10
  import {IPoolComponent} from "../../components/IPoolComponent.sol";
11
11
  import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
12
12
  import {IInstance} from "../IInstance.sol";
13
+ import {IComponents} from "../module/IComponents.sol";
13
14
  import {IPolicy} from "../module/IPolicy.sol";
14
15
  import {IRisk} from "../module/IRisk.sol";
15
16
  import {IBundle} from "../module/IBundle.sol";
@@ -135,7 +136,6 @@ contract ApplicationService is
135
136
  );
136
137
 
137
138
  instance.createApplication(applicationNftId, policyInfo);
138
- instance.updateApplicationState(applicationNftId, APPLIED());
139
139
 
140
140
  // TODO: add logging
141
141
  }
@@ -254,8 +254,8 @@ contract ApplicationService is
254
254
  premium.fullPremiumAmount += t;
255
255
  }
256
256
  {
257
- ISetup.PoolSetupInfo memory poolSetupInfo = instanceReader.getPoolSetupInfo(poolNftId);
258
- uint256 t = poolSetupInfo.poolFee.fixedFee;
257
+ bytes memory componentData = instanceReader.getComponentInfo(poolNftId).data;
258
+ uint256 t = abi.decode(componentData, (IComponents.PoolInfo)).poolFee.fixedFee;
259
259
  premium.poolFeeFixAmount = t;
260
260
  premium.fullPremiumAmount += t;
261
261
  }
@@ -307,8 +307,9 @@ contract ApplicationService is
307
307
  premium.fullPremiumAmount += t;
308
308
  }
309
309
  {
310
- ISetup.PoolSetupInfo memory poolSetupInfo = instanceReader.getPoolSetupInfo(poolNftId);
311
- uint256 t = (UFixedLib.toUFixed(netPremiumAmount) * poolSetupInfo.poolFee.fractionalFee).toInt();
310
+ bytes memory componentData = instanceReader.getComponentInfo(poolNftId).data;
311
+ UFixed poolFractionalFee = abi.decode(componentData, (IComponents.PoolInfo)).poolFee.fractionalFee;
312
+ uint256 t = (UFixedLib.toUFixed(netPremiumAmount) * poolFractionalFee).toInt();
312
313
  premium.poolFeeVarAmount = t;
313
314
  premium.fullPremiumAmount += t;
314
315
  }