@etherisc/gif-next 0.0.2-b1059a4-617 → 0.0.2-b13fcec-949

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) 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 -183
  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 +90 -164
  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 +109 -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 +159 -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 +12 -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 +172 -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 +139 -131
  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 +14 -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 +864 -67
  71. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  72. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +142 -14
  73. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  74. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +121 -27
  75. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  76. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +104 -96
  77. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
  78. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +11 -0
  79. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  80. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +540 -7
  81. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  82. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +32 -64
  83. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  84. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +92 -0
  85. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  86. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +11 -0
  87. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  88. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +69 -157
  89. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  90. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +19 -47
  91. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +125 -17
  93. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  94. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +17 -9
  95. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +18 -7
  97. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  98. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +4 -4
  99. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  100. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +15 -2
  101. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  102. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +19 -0
  103. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  104. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +11 -0
  105. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  106. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +18 -0
  107. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  108. package/artifacts/contracts/registry/Registry.sol/Registry.json +31 -12
  109. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  110. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
  111. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  112. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +16 -5
  113. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  114. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +3 -3
  115. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  116. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +7 -7
  117. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  118. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  119. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  120. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  121. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  122. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  123. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  124. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  125. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  126. package/artifacts/contracts/shared/IService.sol/IService.json +11 -0
  127. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  128. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  129. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  130. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  131. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
  132. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  133. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  134. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  135. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +3 -3
  136. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  137. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  138. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  139. package/artifacts/contracts/shared/Service.sol/Service.json +12 -1
  140. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  141. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
  142. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  143. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  144. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  145. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestFee.sol/TestFee.json +2 -2
  147. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  148. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +3 -3
  149. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  150. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +6 -6
  151. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  152. package/artifacts/contracts/test/TestService.sol/TestService.json +14 -3
  153. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  154. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  155. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  156. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  157. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
  158. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  159. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  160. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  161. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
  162. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
  166. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/Fee.sol/FeeLib.json +2 -2
  168. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  169. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  170. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +17 -4
  172. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  173. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  174. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  175. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  176. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  177. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  178. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  179. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +23 -4
  180. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  181. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  182. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  183. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  184. package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +4 -0
  185. package/artifacts/contracts/types/Seconds.sol/SecondsLib.json +124 -0
  186. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  187. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  188. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  189. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +25 -7
  190. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  191. package/artifacts/contracts/types/UFixed.sol/MathLib.json +2 -2
  192. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  193. package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +2 -2
  194. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  195. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  196. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  197. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
  198. package/contracts/components/Component.sol +95 -85
  199. package/contracts/components/Distribution.sol +16 -44
  200. package/contracts/components/IComponent.sol +37 -17
  201. package/contracts/components/IDistributionComponent.sol +1 -30
  202. package/contracts/components/IPoolComponent.sol +73 -47
  203. package/contracts/components/IProductComponent.sol +3 -2
  204. package/contracts/components/Pool.sol +171 -126
  205. package/contracts/components/Product.sol +26 -18
  206. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +13 -0
  207. package/contracts/instance/BundleManager.sol +7 -5
  208. package/contracts/instance/Cloneable.sol +7 -2
  209. package/contracts/instance/IInstance.sol +16 -10
  210. package/contracts/instance/IInstanceService.sol +18 -5
  211. package/contracts/instance/Instance.sol +45 -9
  212. package/contracts/instance/InstanceAccessManager.sol +382 -157
  213. package/contracts/instance/InstanceReader.sol +7 -10
  214. package/contracts/instance/InstanceService.sol +174 -155
  215. package/contracts/instance/ObjectManager.sol +6 -8
  216. package/contracts/instance/base/ComponentService.sol +5 -5
  217. package/contracts/instance/base/KeyValueStore.sol +5 -2
  218. package/contracts/instance/base/Lifecycle.sol +11 -2
  219. package/contracts/instance/module/IAccess.sol +20 -13
  220. package/contracts/instance/module/IBundle.sol +2 -1
  221. package/contracts/instance/module/IComponents.sol +35 -0
  222. package/contracts/instance/module/IDistribution.sol +2 -0
  223. package/contracts/instance/module/IPolicy.sol +26 -1
  224. package/contracts/instance/module/ISetup.sol +7 -21
  225. package/contracts/instance/service/ApplicationService.sol +123 -41
  226. package/contracts/instance/service/BundleService.sol +76 -38
  227. package/contracts/instance/service/DistributionService.sol +213 -23
  228. package/contracts/instance/service/IApplicationService.sol +7 -7
  229. package/contracts/instance/service/IBundleService.sol +19 -11
  230. package/contracts/instance/service/IDistributionService.sol +36 -3
  231. package/contracts/instance/service/IPolicyService.sol +3 -20
  232. package/contracts/instance/service/IPoolService.sol +17 -2
  233. package/contracts/instance/service/PolicyService.sol +59 -130
  234. package/contracts/instance/service/PoolService.sol +128 -17
  235. package/contracts/instance/service/ProductService.sol +10 -2
  236. package/contracts/registry/ChainNft.sol +8 -0
  237. package/contracts/registry/IRegistry.sol +2 -0
  238. package/contracts/registry/ITransferInterceptor.sol +1 -0
  239. package/contracts/registry/Registry.sol +23 -20
  240. package/contracts/registry/RegistryService.sol +5 -5
  241. package/contracts/shared/IService.sol +2 -0
  242. package/contracts/shared/Registerable.sol +2 -2
  243. package/contracts/shared/TokenHandler.sol +11 -5
  244. package/contracts/types/Blocknumber.sol +1 -0
  245. package/contracts/types/Fee.sol +1 -0
  246. package/contracts/types/NftId.sol +8 -0
  247. package/contracts/types/ObjectType.sol +1 -0
  248. package/contracts/types/Referral.sol +4 -0
  249. package/contracts/types/RoleId.sol +13 -6
  250. package/contracts/types/Seconds.sol +54 -0
  251. package/contracts/types/StateId.sol +1 -0
  252. package/contracts/types/Timestamp.sol +13 -13
  253. package/contracts/types/UFixed.sol +1 -0
  254. package/contracts/types/Version.sol +1 -0
  255. package/package.json +1 -1
@@ -3,6 +3,7 @@ pragma solidity ^0.8.19;
3
3
 
4
4
  import {NftId} from "../../types/NftId.sol";
5
5
  import {Fee} from "../../types/Fee.sol";
6
+ import {IPolicy} from "../module/IPolicy.sol";
6
7
  import {IService} from "../../shared/IService.sol";
7
8
  import {UFixed} from "../../types/UFixed.sol";
8
9
  import {DistributorType} from "../../types/DistributorType.sol";
@@ -11,7 +12,31 @@ import {Timestamp} from "../../types/Timestamp.sol";
11
12
 
12
13
 
13
14
  interface IDistributionService is IService {
15
+ error ErrorIDistributionServiceParentNftIdNotInstance(NftId nftId, NftId parentNftId);
16
+ error ErrorIDistributionServiceCallerNotDistributor(address caller);
17
+ error ErrorIDistributionServiceInvalidReferralId(ReferralId referralId);
18
+ error ErrorIDistributionServiceMaxReferralsExceeded(uint256 maxReferrals);
19
+ error ErrorIDistributionServiceDiscountTooLow(uint256 minDiscountPercentage, uint256 discountPercentage);
20
+ error ErrorIDistributionServiceDiscountTooHigh(uint256 maxDiscountPercentage, uint256 discountPercentage);
21
+ error ErrorIDistributionServiceExpiryTooLong(uint256 maxReferralLifetime, uint256 expiryAt);
22
+ error ErrorIDistributionServiceInvalidReferral(string code);
23
+ error ErrorIDistributionServiceExpirationInvalid(Timestamp expiryAt);
24
+ error ErrorIDistributionServiceCommissionTooHigh(uint256 commissionPercentage, uint256 maxCommissionPercentage);
25
+ error ErrorIDistributionServiceMinFeeTooHigh(uint256 minFee, uint256 limit);
26
+ error ErrorIDistributionServiceMaxDiscountTooHigh(uint256 maxDiscountPercentage, uint256 limit);
27
+ error ErrorIDistributionServiceFeeCalculationMismatch(
28
+ uint256 distributionFeeFixAmount,
29
+ uint256 distributionFeeVarAmount,
30
+ uint256 distributionOwnerFeeFixAmount,
31
+ uint256 distributionOwnerFeeVarAmount,
32
+ uint256 commissionAmount,
33
+ uint256 discountAmount
34
+ );
35
+ error ErrorIDistributionServiceReferralInvalid(NftId distributionNftId, ReferralId referralId);
36
+ error ErrorIDistributionServiceInvalidFeeTransferred(uint256 transferredDistributionFeeAmount, uint256 expectedDistributionFeeAmount);
37
+
14
38
  function setFees(
39
+ Fee memory minDistributionOwnerFee,
15
40
  Fee memory distributionFee
16
41
  ) external;
17
42
 
@@ -54,12 +79,20 @@ interface IDistributionService is IService {
54
79
 
55
80
  /// @dev callback from product service when selling a policy for a specific referralId
56
81
  function processSale(
82
+ NftId distributionNftId,
57
83
  ReferralId referralId,
58
- uint256 premiumAmount
84
+ IPolicy.Premium memory premium,
85
+ uint256 transferredDistributionFeeAmount
59
86
  ) external;
60
87
 
61
88
  function calculateFeeAmount(
89
+ NftId distributionNftId,
62
90
  ReferralId referralId,
63
- uint256 premiumAmount
64
- ) external view returns (uint256 feeAmount);
91
+ IPolicy.Premium memory premium
92
+ ) external view returns (IPolicy.Premium memory finalPremium);
93
+
94
+ function referralIsValid(
95
+ NftId distributorNftId,
96
+ ReferralId referralId
97
+ ) external view returns (bool isValid);
65
98
  }
@@ -7,6 +7,7 @@ import {IService} from "../../shared/IService.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
  import {StateId} from "../../types/StateId.sol";
11
12
  import {Timestamp} from "../../types/Timestamp.sol";
12
13
  import {UFixed} from "../../types/UFixed.sol";
@@ -23,6 +24,8 @@ interface IPolicyService is IService {
23
24
  error ErrorIPolicyServiceOpenClaims(NftId policyNftId, uint16 openClaimsCount);
24
25
  error ErrorIPolicyServicePolicyHasNotExpired(NftId policyNftId, Timestamp expiredAt);
25
26
 
27
+ error ErrorIPolicyServicePremiumMismatch(NftId policyNftId, uint256 premiumAmount, uint256 recalculatedPremiumAmount);
28
+
26
29
  /// @dev declines an application represented by {policyNftId}
27
30
  /// an application can only be declined in applied state
28
31
  /// only the related product may decline an application
@@ -60,26 +63,6 @@ interface IPolicyService is IService {
60
63
  /// this function can only be called by a product. the policy needs to match with the calling product
61
64
  function close(NftId policyNftId) external;
62
65
 
63
- /// @dev calculates the total premium amount for the specified attributes
64
- /// also returns the various fees included in the total premium amount
65
- function calculatePremium(
66
- RiskId riskId,
67
- uint256 sumInsuredAmount,
68
- uint256 lifetime,
69
- bytes memory applicationData,
70
- NftId bundleNftId,
71
- ReferralId referralId
72
- )
73
- external
74
- view
75
- returns (
76
- uint256 premiumAmount,
77
- uint256 productFeeAmount,
78
- uint256 poolFeeAmount,
79
- uint256 bundleFeeAmount,
80
- uint256 distributionFeeAmount
81
- );
82
-
83
66
  // TODO move function to pool service
84
67
  function calculateRequiredCollateral(
85
68
  UFixed collateralizationLevel,
@@ -1,17 +1,32 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import {NftId} from "../../types/NftId.sol";
5
4
  import {Fee} from "../../types/Fee.sol";
6
- import {StateId} from "../../types/StateId.sol";
5
+ import {NftId} from "../../types/NftId.sol";
7
6
  import {IService} from "../../shared/IService.sol";
8
7
  import {IBundle} from "../module/IBundle.sol";
9
8
  import {IInstance} from "../../instance/IInstance.sol";
9
+ import {RoleId} from "../../types/RoleId.sol";
10
+ import {StateId} from "../../types/StateId.sol";
10
11
 
11
12
  interface IPoolService is IService {
12
13
 
14
+ event LogPoolServiceMaxCapitalAmountUpdated(NftId poolNftId, uint256 previousMaxCapitalAmount, uint256 currentMaxCapitalAmount);
15
+ event LogPoolServiceBundleOwnerRoleSet(NftId poolNftId, RoleId bundleOwnerRole);
16
+
17
+ error ErrorPoolServiceBundleOwnerRoleAlreadySet(NftId poolNftId);
18
+
19
+ /// @dev registers a new pool with the registry service
13
20
  function register(address poolAddress) external returns(NftId);
14
21
 
22
+ /// @dev defines the required role for bundle owners for the calling pool
23
+ /// default implementation returns PUBLIC ROLE
24
+ function setBundleOwnerRole(RoleId bundleOwnerRole) external;
25
+
26
+ /// @dev sets the max capital amount for the calling pool
27
+ function setMaxCapitalAmount(uint256 maxCapitalAmount) external;
28
+
29
+ /// @dev set pool sepecific fees
15
30
  function setFees(
16
31
  Fee memory poolFee,
17
32
  Fee memory stakingFee,
@@ -2,43 +2,34 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  import {IRegistry} from "../../registry/IRegistry.sol";
5
- import {IProductComponent} from "../../components/IProductComponent.sol";
6
5
  import {Product} from "../../components/Product.sol";
7
- import {IPoolComponent} from "../../components/IPoolComponent.sol";
6
+ import {IComponents} from "../module/IComponents.sol";
8
7
  import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
9
8
  import {IInstance} from "../IInstance.sol";
10
9
  import {IPolicy} from "../module/IPolicy.sol";
10
+ import {IPoolComponent} from "../../components/IPoolComponent.sol";
11
11
  import {IRisk} from "../module/IRisk.sol";
12
12
  import {IBundle} from "../module/IBundle.sol";
13
- import {IProductService} from "./IProductService.sol";
14
- import {ITreasury} from "../module/ITreasury.sol";
15
13
  import {ISetup} from "../module/ISetup.sol";
16
14
 
17
15
  import {TokenHandler} from "../../shared/TokenHandler.sol";
18
16
 
19
- import {IVersionable} from "../../shared/IVersionable.sol";
20
- import {Versionable} from "../../shared/Versionable.sol";
21
-
22
17
  import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
23
18
  import {UFixed, UFixedLib} from "../../types/UFixed.sol";
24
- import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
25
- import {ObjectType, INSTANCE, PRODUCT, POOL, POLICY, BUNDLE} from "../../types/ObjectType.sol";
19
+ import {ObjectType, APPLICATION, DISTRIBUTION, PRODUCT, POOL, POLICY, BUNDLE} from "../../types/ObjectType.sol";
26
20
  import {APPLIED, UNDERWRITTEN, ACTIVE, KEEP_STATE, CLOSED} from "../../types/StateId.sol";
27
- import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
28
- import {Fee, FeeLib} from "../../types/Fee.sol";
29
- import {ReferralId} from "../../types/Referral.sol";
30
- import {RiskId} from "../../types/RiskId.sol";
21
+ import {NftId, NftIdLib} from "../../types/NftId.sol";
31
22
  import {StateId} from "../../types/StateId.sol";
32
- import {Version, VersionLib} from "../../types/Version.sol";
33
- //import {RoleId, PRODUCT_OWNER_ROLE} from "../../types/RoleId.sol";
34
23
 
35
- import {IService} from "../../shared/IService.sol";
36
- import {Service} from "../../shared/Service.sol";
37
24
  import {ComponentService} from "../base/ComponentService.sol";
38
- import {IPolicyService} from "./IPolicyService.sol";
25
+ import {IApplicationService} from "./IApplicationService.sol";
26
+ import {IBundleService} from "./IBundleService.sol";
27
+ import {IDistributionService} from "./IDistributionService.sol";
39
28
  import {InstanceReader} from "../InstanceReader.sol";
29
+ import {IPolicyService} from "./IPolicyService.sol";
40
30
  import {IPoolService} from "./IPoolService.sol";
41
- import {IBundleService} from "./IBundleService.sol";
31
+ import {IService} from "../../shared/IService.sol";
32
+ import {Service} from "../../shared/Service.sol";
42
33
 
43
34
 
44
35
  contract PolicyService is
@@ -50,6 +41,8 @@ contract PolicyService is
50
41
 
51
42
  IPoolService internal _poolService;
52
43
  IBundleService internal _bundleService;
44
+ IApplicationService internal _applicationService;
45
+ IDistributionService internal _distributionService;
53
46
 
54
47
  event LogProductServiceSender(address sender);
55
48
 
@@ -69,6 +62,8 @@ contract PolicyService is
69
62
 
70
63
  _poolService = IPoolService(getRegistry().getServiceAddress(POOL(), getMajorVersion()));
71
64
  _bundleService = IBundleService(getRegistry().getServiceAddress(BUNDLE(), getMajorVersion()));
65
+ _applicationService = IApplicationService(getRegistry().getServiceAddress(APPLICATION(), getMajorVersion()));
66
+ _distributionService = IDistributionService(getRegistry().getServiceAddress(DISTRIBUTION(), getMajorVersion()));
72
67
 
73
68
  registerInterface(type(IPolicyService).interfaceId);
74
69
  }
@@ -85,93 +80,6 @@ contract PolicyService is
85
80
  product = Product(productInfo.objectAddress);
86
81
  }
87
82
 
88
- // TODO: no access restrictions
89
- function calculatePremium(
90
- RiskId riskId,
91
- uint256 sumInsuredAmount,
92
- uint256 lifetime,
93
- bytes memory applicationData,
94
- NftId bundleNftId,
95
- ReferralId referralId
96
- )
97
- public
98
- view
99
- virtual override
100
- returns (
101
- uint256 premiumAmount,
102
- uint256 productFeeAmount,
103
- uint256 poolFeeAmount,
104
- uint256 bundleFeeAmount,
105
- uint256 distributionFeeAmount
106
- )
107
- {
108
- Product product = _getAndVerifyInstanceAndProduct();
109
- uint256 netPremiumAmount = product.calculateNetPremium(
110
- sumInsuredAmount,
111
- riskId,
112
- lifetime,
113
- applicationData
114
- );
115
-
116
- (
117
- productFeeAmount,
118
- poolFeeAmount,
119
- bundleFeeAmount,
120
- distributionFeeAmount
121
- ) = _calculateFeeAmounts(
122
- netPremiumAmount,
123
- product,
124
- bundleNftId,
125
- referralId
126
- );
127
-
128
- premiumAmount = netPremiumAmount + productFeeAmount;
129
- premiumAmount += poolFeeAmount + bundleFeeAmount;
130
- premiumAmount += distributionFeeAmount;
131
- }
132
-
133
- function _calculateFeeAmounts(
134
- uint256 netPremiumAmount,
135
- Product product,
136
- NftId bundleNftId,
137
- ReferralId referralId
138
- )
139
- internal
140
- view
141
- returns (
142
- uint256 productFeeAmount,
143
- uint256 poolFeeAmount,
144
- uint256 bundleFeeAmount,
145
- uint256 distributionFeeAmount
146
- )
147
- {
148
- InstanceReader instanceReader;
149
- {
150
- IInstance instance = product.getInstance();
151
- instanceReader = instance.getInstanceReader();
152
- }
153
-
154
- NftId poolNftId = product.getPoolNftId();
155
- IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
156
- require(bundleInfo.poolNftId == poolNftId,"ERROR:PRS-035:BUNDLE_POOL_MISMATCH");
157
-
158
- {
159
- ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(product.getProductNftId());
160
- (productFeeAmount,) = FeeLib.calculateFee(productSetupInfo.productFee, netPremiumAmount);
161
- }
162
- {
163
- ISetup.PoolSetupInfo memory poolSetupInfo = instanceReader.getPoolSetupInfo(poolNftId);
164
- (poolFeeAmount,) = FeeLib.calculateFee(poolSetupInfo.poolFee, netPremiumAmount);
165
- }
166
- {
167
- NftId distributionNftId = product.getDistributionNftId();
168
- ISetup.DistributionSetupInfo memory distributionSetupInfo = instanceReader.getDistributionSetupInfo(distributionNftId);
169
- (distributionFeeAmount,) = FeeLib.calculateFee(distributionSetupInfo.distributionFee, netPremiumAmount);
170
- }
171
-
172
- (bundleFeeAmount,) = FeeLib.calculateFee(bundleInfo.fee, netPremiumAmount);
173
- }
174
-
175
83
  function _getAndVerifyUnderwritingSetup(
176
84
  IInstance instance,
177
85
  InstanceReader instanceReader,
@@ -194,7 +102,9 @@ contract PolicyService is
194
102
  require(bundleInfo.poolNftId == poolNftId, "POLICY_BUNDLE_MISMATCH");
195
103
 
196
104
  // calculate required collateral
197
- ISetup.PoolSetupInfo memory poolInfo = instanceReader.getPoolSetupInfo(poolNftId);
105
+ IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
106
+ IComponents.PoolInfo memory poolInfo = abi.decode(
107
+ componentInfo.data, (IComponents.PoolInfo));
198
108
 
199
109
  // obtain remaining return values
200
110
  // TODO required collateral amount should be calculated by pool service, not policy service
@@ -267,7 +177,6 @@ contract PolicyService is
267
177
  if(requirePremiumPayment) {
268
178
  netPremiumAmount = _processPremiumByTreasury(
269
179
  instance,
270
- productNftId,
271
180
  applicationNftId,
272
181
  policyInfo.premiumAmount);
273
182
 
@@ -295,13 +204,19 @@ contract PolicyService is
295
204
  instance.updatePolicy(applicationNftId, policyInfo, newPolicyState);
296
205
 
297
206
  // also verify/confirm application by pool if necessary
298
- if(instanceReader.getPoolSetupInfo(poolNftId).isVerifyingApplications) {
207
+ if(abi.decode(
208
+ instanceReader.getComponentInfo(poolNftId).data,
209
+ (IComponents.PoolInfo)
210
+ ).isVerifyingApplications
211
+ )
212
+ {
299
213
  IPoolComponent pool = IPoolComponent(
300
214
  getRegistry().getObjectInfo(poolNftId).objectAddress);
301
215
 
302
216
  pool.verifyApplication(
303
217
  applicationNftId,
304
218
  policyInfo.applicationData,
219
+ bundleNftId,
305
220
  bundleInfo.filter,
306
221
  collateralAmount);
307
222
  }
@@ -330,7 +245,6 @@ contract PolicyService is
330
245
 
331
246
  uint256 netPremiumAmount = _processPremiumByTreasury(
332
247
  instance,
333
- productInfo.nftId,
334
248
  policyNftId,
335
249
  unpaidPremiumAmount);
336
250
 
@@ -434,7 +348,6 @@ contract PolicyService is
434
348
 
435
349
  function _processPremiumByTreasury(
436
350
  IInstance instance,
437
- NftId productNftId,
438
351
  NftId policyNftId,
439
352
  uint256 premiumAmount
440
353
  )
@@ -443,30 +356,46 @@ contract PolicyService is
443
356
  {
444
357
  // process token transfer(s)
445
358
  if(premiumAmount > 0) {
359
+ NftId productNftId = getRegistry().getObjectInfo(policyNftId).parentNftId;
446
360
  ISetup.ProductSetupInfo memory productSetupInfo = instance.getInstanceReader().getProductSetupInfo(productNftId);
361
+ IPolicy.PolicyInfo memory policyInfo = instance.getInstanceReader().getPolicyInfo(policyNftId);
447
362
  TokenHandler tokenHandler = productSetupInfo.tokenHandler;
448
363
  address policyOwner = getRegistry().ownerOf(policyNftId);
449
- ISetup.PoolSetupInfo memory poolSetupInfo = instance.getInstanceReader().getPoolSetupInfo(productSetupInfo.poolNftId);
450
- address poolWallet = poolSetupInfo.wallet;
451
- netPremiumAmount = premiumAmount;
452
- Fee memory productFee = productSetupInfo.productFee;
453
-
454
- if (FeeLib.feeIsZero(productFee)) {
455
- tokenHandler.transfer(
456
- policyOwner,
457
- poolWallet,
458
- premiumAmount
364
+ address poolWallet = instance.getInstanceReader().getComponentInfo(productSetupInfo.poolNftId).wallet;
365
+ IPolicy.Premium memory premium = _applicationService.calculatePremium(
366
+ productNftId,
367
+ policyInfo.riskId,
368
+ policyInfo.sumInsuredAmount,
369
+ policyInfo.lifetime,
370
+ policyInfo.applicationData,
371
+ policyInfo.bundleNftId,
372
+ policyInfo.referralId
459
373
  );
460
- } else {
461
- (uint256 productFeeAmount, uint256 netAmount) = FeeLib.calculateFee(productSetupInfo.productFee, netPremiumAmount);
462
- address productWallet = productSetupInfo.wallet;
463
- if (tokenHandler.getToken().allowance(policyOwner, address(tokenHandler)) < premiumAmount) {
464
- revert ErrorIPolicyServiceInsufficientAllowance(policyOwner, address(tokenHandler), premiumAmount);
465
- }
466
- tokenHandler.transfer(policyOwner, productWallet, productFeeAmount);
467
- tokenHandler.transfer(policyOwner, poolWallet, netAmount);
468
- netPremiumAmount = netAmount;
374
+
375
+ if (premium.premiumAmount != premiumAmount) {
376
+ revert ErrorIPolicyServicePremiumMismatch(policyNftId, premiumAmount, premium.premiumAmount);
377
+ }
378
+
379
+ // move product fee to product wallet
380
+ address productWallet = productSetupInfo.wallet;
381
+ if (tokenHandler.getToken().allowance(policyOwner, address(tokenHandler)) < premium.premiumAmount) {
382
+ revert ErrorIPolicyServiceInsufficientAllowance(policyOwner, address(tokenHandler), premium.premiumAmount);
469
383
  }
384
+ tokenHandler.transfer(policyOwner, productWallet, premium.productFeeFixAmount + premium.productFeeVarAmount);
385
+
386
+ // move distribution fee to distribution wallet
387
+ ISetup.DistributionSetupInfo memory distributionSetupInfo = instance.getInstanceReader().getDistributionSetupInfo(productSetupInfo.distributionNftId);
388
+ address distributionWallet = distributionSetupInfo.wallet;
389
+ uint256 distributionFeeAmountToTransfer = premium.distributionFeeFixAmount + premium.distributionFeeVarAmount - premium.discountAmount;
390
+ tokenHandler.transfer(policyOwner, distributionWallet, distributionFeeAmountToTransfer);
391
+ _distributionService.processSale(productSetupInfo.distributionNftId, policyInfo.referralId, premium, distributionFeeAmountToTransfer);
392
+
393
+ // move netpremium to pool wallet
394
+ tokenHandler.transfer(policyOwner, poolWallet, premium.netPremiumAmount);
395
+
396
+ // TODO: move pool related tokens too
397
+ // TODO: move bundle related tokens too
398
+ netPremiumAmount = premium.netPremiumAmount;
470
399
  }
471
400
 
472
401
  // TODO: add logging
@@ -6,20 +6,22 @@ import {IRegistry} from "../../registry/IRegistry.sol";
6
6
  import {IInstance} from "../../instance/IInstance.sol";
7
7
  import {IBundle} from "../../instance/module/IBundle.sol";
8
8
  import {TokenHandler} from "../../instance/module/ITreasury.sol";
9
- import {ISetup} from "../module/ISetup.sol";
9
+ import {IComponents} from "../module/IComponents.sol";
10
10
  import {IPolicy} from "../module/IPolicy.sol";
11
11
 
12
12
  import {IVersionable} from "../../shared/IVersionable.sol";
13
13
  import {Versionable} from "../../shared/Versionable.sol";
14
14
  import {INftOwnable} from "../../shared/INftOwnable.sol";
15
15
 
16
+ import {Fee, FeeLib} from "../../types/Fee.sol";
16
17
  import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
17
18
  import {ObjectType, POOL, BUNDLE} from "../../types/ObjectType.sol";
18
- import {POOL_OWNER_ROLE, RoleId} from "../../types/RoleId.sol";
19
+ import {PUBLIC_ROLE, POOL_OWNER_ROLE, POLICY_SERVICE_ROLE, RoleId} from "../../types/RoleId.sol";
19
20
  import {Fee, FeeLib} from "../../types/Fee.sol";
20
21
  import {Version, VersionLib} from "../../types/Version.sol";
21
22
  import {KEEP_STATE, StateId} from "../../types/StateId.sol";
22
23
  import {TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
24
+ import {Version, VersionLib} from "../../types/Version.sol";
23
25
 
24
26
  import {IService} from "../../shared/IService.sol";
25
27
  import {Service} from "../../shared/Service.sol";
@@ -63,7 +65,7 @@ contract PoolService is
63
65
  return POOL();
64
66
  }
65
67
 
66
- function register(address poolAddress)
68
+ /*function register(address poolAddress)
67
69
  external
68
70
  returns(NftId poolNftId)
69
71
  {
@@ -78,32 +80,141 @@ contract PoolService is
78
80
  POOL_OWNER_ROLE());
79
81
 
80
82
  IPoolComponent pool = IPoolComponent(poolAddress);
81
- IRegistry.ObjectInfo memory poolInfo = getRegistryService().registerPool(pool, owner);
83
+ IRegistry.ObjectInfo memory registryInfo = getRegistryService().registerPool(pool, owner);
82
84
  pool.linkToRegisteredNftId();
83
- poolNftId = poolInfo.nftId;
85
+ poolNftId = registryInfo.nftId;
84
86
 
85
87
  instance.createPoolSetup(poolNftId, pool.getSetupInfo());
86
- getInstanceService().createGifTarget(instanceNftId, poolAddress, pool.getName());
87
- getInstanceService().grantPoolDefaultPermissions(instanceNftId, poolAddress, pool.getName());
88
+
89
+ bytes4[][] memory selectors = new bytes4[][](2);
90
+ selectors[0] = new bytes4[](1);
91
+ selectors[1] = new bytes4[](1);
92
+
93
+ selectors[0][0] = IPoolComponent.setFees.selector;
94
+ selectors[1][0] = IPoolComponent.verifyApplication.selector;
95
+
96
+ RoleId[] memory roles = new RoleId[](2);
97
+ roles[0] = POOL_OWNER_ROLE();
98
+ roles[1] = POLICY_SERVICE_ROLE();
99
+
100
+ getInstanceService().createGifTarget(
101
+ instanceNftId,
102
+ poolAddress,
103
+ pool.getName(),
104
+ selectors,
105
+ roles);
106
+ }*/
107
+
108
+ function register(address poolAddress)
109
+ external
110
+ returns(NftId poolNftId)
111
+ {
112
+ (
113
+ IComponent component,
114
+ address owner,
115
+ IInstance instance,
116
+ NftId instanceNftId
117
+ ) = _checkComponentForRegistration(
118
+ poolAddress,
119
+ POOL(),
120
+ POOL_OWNER_ROLE());
121
+
122
+ IPoolComponent pool = IPoolComponent(poolAddress);
123
+ IRegistry.ObjectInfo memory registryInfo = getRegistryService().registerPool(pool, owner);
124
+ pool.linkToRegisteredNftId();
125
+ poolNftId = registryInfo.nftId;
126
+
127
+ // amend component info with pool specific token handler
128
+ IComponents.ComponentInfo memory componentInfo = pool.getComponentInfo();
129
+ componentInfo.tokenHandler = new TokenHandler(address(componentInfo.token));
130
+
131
+ // save amended component info with instance
132
+ instance.createPoolSetup(poolNftId, componentInfo);
133
+
134
+ bytes4[][] memory selectors = new bytes4[][](2);
135
+ selectors[0] = new bytes4[](1);
136
+ selectors[1] = new bytes4[](1);
137
+
138
+ selectors[0][0] = IPoolComponent.setFees.selector;
139
+ selectors[1][0] = IPoolComponent.verifyApplication.selector;
140
+
141
+ RoleId[] memory roles = new RoleId[](2);
142
+ roles[0] = POOL_OWNER_ROLE();
143
+ roles[1] = POLICY_SERVICE_ROLE();
144
+
145
+ getInstanceService().createGifTarget(
146
+ instanceNftId,
147
+ poolAddress,
148
+ pool.getName(),
149
+ selectors,
150
+ roles);
151
+ }
152
+
153
+
154
+ function setMaxCapitalAmount(uint256 maxCapitalAmount)
155
+ external
156
+ virtual
157
+ {
158
+ (IRegistry.ObjectInfo memory registryInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
159
+ InstanceReader instanceReader = instance.getInstanceReader();
160
+ NftId poolNftId = registryInfo.nftId;
161
+
162
+ IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
163
+ IComponents.PoolInfo memory poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
164
+ uint256 previousMaxCapitalAmount = poolInfo.maxCapitalAmount;
165
+
166
+ poolInfo.maxCapitalAmount = maxCapitalAmount;
167
+ componentInfo.data = abi.encode(poolInfo);
168
+ instance.updatePoolSetup(poolNftId, componentInfo, KEEP_STATE());
169
+
170
+ emit LogPoolServiceMaxCapitalAmountUpdated(poolNftId, previousMaxCapitalAmount, maxCapitalAmount);
88
171
  }
89
172
 
173
+ function setBundleOwnerRole(RoleId bundleOwnerRole)
174
+ external
175
+ virtual
176
+ {
177
+ (IRegistry.ObjectInfo memory registryInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
178
+ InstanceReader instanceReader = instance.getInstanceReader();
179
+ NftId poolNftId = registryInfo.nftId;
180
+
181
+ IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
182
+ IComponents.PoolInfo memory poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
183
+
184
+ // bundle owner role may only be set once per pool
185
+ if(poolInfo.bundleOwnerRole != PUBLIC_ROLE()) {
186
+ revert ErrorPoolServiceBundleOwnerRoleAlreadySet(poolNftId);
187
+ }
188
+
189
+ poolInfo.bundleOwnerRole = bundleOwnerRole;
190
+ componentInfo.data = abi.encode(poolInfo);
191
+ instance.updatePoolSetup(poolNftId, componentInfo, KEEP_STATE());
192
+
193
+ emit LogPoolServiceBundleOwnerRoleSet(poolNftId, bundleOwnerRole);
194
+ }
195
+
196
+
90
197
  function setFees(
91
198
  Fee memory poolFee,
92
199
  Fee memory stakingFee,
93
200
  Fee memory performanceFee
94
201
  )
95
202
  external
96
- override
203
+ virtual
97
204
  {
98
- (IRegistry.ObjectInfo memory poolInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
205
+ (IRegistry.ObjectInfo memory registryInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
99
206
  InstanceReader instanceReader = instance.getInstanceReader();
100
- NftId poolNftId = poolInfo.nftId;
101
-
102
- ISetup.PoolSetupInfo memory poolSetupInfo = instanceReader.getPoolSetupInfo(poolNftId);
103
- poolSetupInfo.poolFee = poolFee;
104
- poolSetupInfo.stakingFee = stakingFee;
105
- poolSetupInfo.performanceFee = performanceFee;
106
-
107
- instance.updatePoolSetup(poolNftId, poolSetupInfo, KEEP_STATE());
207
+ NftId poolNftId = registryInfo.nftId;
208
+
209
+ IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
210
+ IComponents.PoolInfo memory poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
211
+
212
+ poolInfo.poolFee = poolFee;
213
+ poolInfo.stakingFee = stakingFee;
214
+ poolInfo.performanceFee = performanceFee;
215
+ componentInfo.data = abi.encode(poolInfo);
216
+ instance.updatePoolSetup(poolNftId, componentInfo, KEEP_STATE());
217
+
218
+ // TODO add logging
108
219
  }
109
220
  }
@@ -113,12 +113,20 @@ contract ProductService is ComponentService, IProductService {
113
113
  // create product setup in instance
114
114
  instance.createProductSetup(productNftId, product.getSetupInfo());
115
115
 
116
+ bytes4[][] memory selectors = new bytes4[][](1);
117
+ selectors[0] = new bytes4[](1);
118
+ selectors[0][0] = IProductComponent.setFees.selector;
119
+
120
+ RoleId[] memory roles = new RoleId[](1);
121
+ roles[0] = PRODUCT_OWNER_ROLE();
122
+
116
123
  // create target for instane access manager
117
124
  getInstanceService().createGifTarget(
118
125
  getRegistry().getNftId(address(instance)),
119
126
  address(product),
120
- product.getName());
121
- getInstanceService().grantProductDefaultPermissions(instance.getNftId(), address(product), product.getName());
127
+ product.getName(),
128
+ selectors,
129
+ roles);
122
130
  }
123
131
 
124
132
  function getDomain() public pure override(IService, Service) returns(ObjectType) {
@@ -95,6 +95,10 @@ contract ChainNft is ERC721Enumerable {
95
95
 
96
96
  _totalMinted++;
97
97
  _safeMint(to, tokenId);
98
+
99
+ if(interceptor != address(0)) {
100
+ ITransferInterceptor(interceptor).nftMint(to, tokenId);
101
+ }
98
102
  }
99
103
 
100
104
 
@@ -195,6 +199,10 @@ contract ChainNft is ERC721Enumerable {
195
199
  _chainIdDigits;
196
200
  }
197
201
 
202
+ function getNextTokenId() external view returns (uint256) {
203
+ return calculateTokenId(_idNext);
204
+ }
205
+
198
206
  function _getNextTokenId() private returns (uint256 id) {
199
207
  id = calculateTokenId(_idNext);
200
208
  _idNext++;
@@ -84,6 +84,8 @@ interface IRegistry is IERC165 {
84
84
 
85
85
  function isRegisteredService(address contractAddress) external view returns (bool);
86
86
 
87
+ function isRegisteredComponent(address object) external view returns (bool);
88
+
87
89
  function isValidRelease(VersionPart version) external view returns (bool);
88
90
 
89
91
  function getServiceAddress(