@etherisc/gif-next 0.0.2-8210648-816 → 0.0.2-836e6e4-400

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 (396) hide show
  1. package/README.md +171 -2
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +168 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +248 -33
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +130 -0
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +0 -25
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +24 -57
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +0 -50
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +319 -68
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +324 -55
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +4 -0
  19. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +66 -0
  20. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +4 -0
  21. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +24 -0
  22. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +4 -0
  23. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +42 -0
  24. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
  36. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  37. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  38. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  39. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
  40. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  41. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
  42. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  43. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  44. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  45. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
  46. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
  47. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +788 -0
  48. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
  49. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +185 -0
  50. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  51. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +877 -1389
  52. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  53. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +448 -0
  54. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
  55. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +541 -0
  56. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  57. package/artifacts/contracts/instance/Instance.sol/Instance.json +1742 -1390
  58. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +4 -0
  59. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +1057 -0
  60. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +4 -0
  61. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +763 -0
  62. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +4 -0
  63. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1422 -0
  64. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
  65. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +879 -0
  66. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
  67. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +444 -0
  68. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
  69. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +285 -0
  70. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  71. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +49 -9
  72. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  73. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  74. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +27 -158
  75. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  76. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  77. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +37 -245
  78. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  79. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
  80. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +4 -0
  81. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +243 -0
  82. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +4 -0
  83. package/artifacts/contracts/instance/module/{bundle/IBundle.sol → IBundle.sol}/IBundle.json +1 -1
  84. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +4 -0
  85. package/artifacts/contracts/instance/module/{distribution/IDistribution.sol → IDistribution.sol}/IDistribution.json +1 -1
  86. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +4 -0
  87. package/artifacts/contracts/instance/module/{policy/IPolicy.sol → IPolicy.sol}/IPolicy.json +1 -1
  88. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +4 -0
  89. package/artifacts/contracts/instance/module/{risk/IRisk.sol → IRisk.sol}/IRisk.json +1 -1
  90. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +4 -0
  91. package/artifacts/contracts/instance/{base/ModuleBase.sol/ModuleBase.json → module/ISetup.sol/ISetup.json} +2 -2
  92. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +4 -0
  93. package/artifacts/contracts/instance/module/{treasury/ITreasury.sol → ITreasury.sol}/ITreasury.json +1 -1
  94. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
  95. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +923 -0
  96. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
  97. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +432 -0
  98. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  99. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +95 -75
  100. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  101. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +98 -57
  102. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
  103. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +420 -0
  104. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
  105. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +669 -0
  106. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  107. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +14 -14
  108. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  109. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +13 -13
  110. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
  111. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +664 -0
  112. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  113. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +15 -77
  114. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  115. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +25 -240
  116. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
  117. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +971 -0
  118. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
  119. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +464 -0
  120. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  121. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +83 -131
  122. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
  123. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +420 -0
  124. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  125. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +80 -393
  126. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
  127. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +420 -0
  128. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  129. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +47 -2
  130. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  131. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +150 -70
  132. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  133. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +259 -28
  134. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  135. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  136. package/artifacts/contracts/registry/Registry.sol/Registry.json +125 -212
  137. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
  138. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
  139. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  140. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +285 -87
  141. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  142. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +59 -76
  143. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
  144. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +546 -0
  145. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
  146. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +397 -0
  147. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  148. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  149. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  150. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  151. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  152. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
  153. package/artifacts/contracts/{instance/base → shared}/IService.sol/IService.json +14 -14
  154. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  155. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  156. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  157. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  158. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  159. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  160. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +6 -6
  161. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +4 -0
  162. package/artifacts/contracts/{instance/base/InstanceBase.sol/InstanceBase.json → shared/RegisterableUpgradable.sol/RegisterableUpgradable.json} +2 -104
  163. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
  164. package/artifacts/contracts/{instance/base/ServiceBase.sol/ServiceBase.json → shared/Service.sol/Service.json} +15 -15
  165. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +4 -0
  166. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +96 -0
  167. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  168. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  169. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  170. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  171. package/artifacts/contracts/test/TestFee.sol/TestFee.json +4 -4
  172. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  173. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +6 -6
  174. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  175. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +14 -14
  176. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  177. package/artifacts/contracts/test/TestService.sol/TestService.json +45 -29
  178. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  179. package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +91 -53
  180. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  181. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  182. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  183. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +18 -2
  184. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  185. package/artifacts/contracts/test/Usdc.sol/USDC.json +91 -53
  186. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  187. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  188. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  189. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
  190. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +104 -0
  191. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  192. package/artifacts/contracts/types/Fee.sol/FeeLib.json +4 -4
  193. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  194. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +31 -17
  195. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  196. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  197. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  198. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +26 -3
  199. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +4 -0
  200. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.json +100 -0
  201. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  202. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  203. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +4 -0
  204. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +123 -0
  205. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  206. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  207. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  208. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +134 -8
  209. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  210. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  211. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  212. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +15 -2
  213. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
  214. package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
  215. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
  216. package/artifacts/contracts/types/UFixed.sol/{UFixedMathLib.json → UFixedLib.json} +3 -3
  217. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  218. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  219. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  220. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +22 -3
  221. package/contracts/components/BaseComponent.sol +82 -13
  222. package/contracts/components/Distribution.sol +23 -15
  223. package/contracts/components/IBaseComponent.sol +16 -3
  224. package/contracts/components/IDistributionComponent.sol +2 -4
  225. package/contracts/components/IPoolComponent.sol +5 -3
  226. package/contracts/components/IProductComponent.sol +2 -4
  227. package/contracts/components/Pool.sol +57 -32
  228. package/contracts/components/Product.sol +60 -67
  229. package/contracts/experiment/cloning/Cloner.sol +47 -0
  230. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +23 -0
  231. package/contracts/instance/BundleManager.sol +129 -0
  232. package/contracts/instance/Cloneable.sol +46 -0
  233. package/contracts/instance/IInstance.sol +55 -47
  234. package/contracts/instance/IInstanceBase.sol +26 -0
  235. package/contracts/instance/IInstanceService.sol +38 -0
  236. package/contracts/instance/Instance.sol +257 -68
  237. package/contracts/instance/InstanceAccessManager.sol +304 -0
  238. package/contracts/instance/InstanceBase.sol +41 -0
  239. package/contracts/instance/InstanceReader.sol +315 -0
  240. package/contracts/instance/InstanceService.sol +300 -0
  241. package/contracts/instance/InstanceServiceManager.sol +54 -0
  242. package/contracts/instance/ObjectManager.sol +101 -0
  243. package/contracts/instance/base/ComponentServiceBase.sol +44 -21
  244. package/contracts/instance/base/IKeyValueStore.sol +13 -14
  245. package/contracts/instance/base/ILifecycle.sol +3 -3
  246. package/contracts/instance/base/KeyValueStore.sol +49 -38
  247. package/contracts/instance/base/Lifecycle.sol +1 -1
  248. package/contracts/instance/module/IAccess.sol +48 -0
  249. package/contracts/instance/module/IBundle.sol +20 -0
  250. package/contracts/instance/module/IDistribution.sol +39 -0
  251. package/contracts/instance/module/IPolicy.sol +45 -0
  252. package/contracts/instance/module/IRisk.sol +11 -0
  253. package/contracts/instance/module/ISetup.sol +46 -0
  254. package/contracts/instance/module/ITreasury.sol +23 -0
  255. package/contracts/instance/service/BundleService.sol +260 -0
  256. package/contracts/instance/service/BundleServiceManager.sol +51 -0
  257. package/contracts/instance/service/ComponentOwnerService.sol +147 -107
  258. package/contracts/instance/service/DistributionService.sol +78 -18
  259. package/contracts/instance/service/DistributionServiceManager.sol +51 -0
  260. package/contracts/instance/service/IBundleService.sol +45 -0
  261. package/contracts/instance/service/IComponentOwnerService.sol +1 -1
  262. package/contracts/instance/service/IDistributionService.sol +1 -1
  263. package/contracts/instance/service/IPolicyService.sol +87 -0
  264. package/contracts/instance/service/IPoolService.sol +7 -24
  265. package/contracts/instance/service/IProductService.sol +9 -76
  266. package/contracts/instance/service/PolicyService.sol +503 -0
  267. package/contracts/instance/service/PolicyServiceManager.sol +54 -0
  268. package/contracts/instance/service/PoolService.sol +80 -107
  269. package/contracts/instance/service/PoolServiceManager.sol +51 -0
  270. package/contracts/instance/service/ProductService.sol +95 -437
  271. package/contracts/instance/service/ProductServiceManager.sol +54 -0
  272. package/contracts/registry/ChainNft.sol +41 -26
  273. package/contracts/registry/IRegistry.sol +43 -25
  274. package/contracts/registry/IRegistryService.sol +53 -24
  275. package/contracts/registry/Registry.sol +212 -307
  276. package/contracts/registry/RegistryAccessManager.sol +210 -0
  277. package/contracts/registry/RegistryService.sol +150 -195
  278. package/contracts/registry/RegistryServiceManager.sol +28 -9
  279. package/contracts/registry/ReleaseManager.sol +348 -0
  280. package/contracts/registry/TokenRegistry.sol +110 -0
  281. package/contracts/shared/ERC165.sol +7 -3
  282. package/contracts/shared/IRegisterable.sol +1 -1
  283. package/contracts/shared/IService.sol +16 -0
  284. package/contracts/shared/NftOwnable.sol +2 -4
  285. package/contracts/shared/ProxyManager.sol +4 -4
  286. package/contracts/shared/Registerable.sol +3 -2
  287. package/contracts/shared/RegisterableUpgradable.sol +16 -0
  288. package/contracts/shared/Service.sol +58 -0
  289. package/contracts/shared/TokenHandler.sol +27 -0
  290. package/contracts/shared/UpgradableProxyWithAdmin.sol +2 -2
  291. package/contracts/shared/Versionable.sol +3 -3
  292. package/contracts/test/TestFee.sol +2 -2
  293. package/contracts/test/TestRoleId.sol +1 -1
  294. package/contracts/test/TestService.sol +6 -7
  295. package/contracts/types/DistributorType.sol +55 -0
  296. package/contracts/types/Fee.sol +3 -3
  297. package/contracts/types/Key32.sol +8 -3
  298. package/contracts/types/NftIdSet.sol +26 -24
  299. package/contracts/types/NumberId.sol +52 -0
  300. package/contracts/types/ObjectType.sol +35 -14
  301. package/contracts/types/Referral.sol +85 -0
  302. package/contracts/types/RoleId.sol +61 -9
  303. package/contracts/types/StateId.sol +5 -1
  304. package/contracts/types/Timestamp.sol +7 -3
  305. package/contracts/types/UFixed.sol +128 -12
  306. package/contracts/types/Version.sol +4 -1
  307. package/package.json +4 -3
  308. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +0 -4
  309. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.json +0 -24
  310. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +0 -4
  311. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +0 -4
  312. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +0 -4
  313. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +0 -4
  314. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +0 -4
  315. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.json +0 -333
  316. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +0 -4
  317. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.json +0 -10
  318. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +0 -4
  319. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.json +0 -333
  320. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +0 -4
  321. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +0 -297
  322. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +0 -4
  323. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +0 -4
  324. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +0 -297
  325. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +0 -4
  326. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +0 -117
  327. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +0 -4
  328. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.json +0 -10
  329. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +0 -4
  330. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.json +0 -117
  331. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +0 -4
  332. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +0 -10
  333. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +0 -4
  334. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +0 -4
  335. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.json +0 -10
  336. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +0 -4
  337. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +0 -4
  338. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +0 -271
  339. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
  340. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +0 -271
  341. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +0 -4
  342. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.json +0 -10
  343. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +0 -4
  344. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +0 -164
  345. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
  346. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -164
  347. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +0 -4
  348. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +0 -4
  349. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +0 -113
  350. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +0 -4
  351. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +0 -131
  352. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +0 -4
  353. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +0 -4
  354. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +0 -638
  355. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +0 -4
  356. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +0 -76
  357. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +0 -4
  358. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +0 -638
  359. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
  360. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +0 -457
  361. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +0 -4
  362. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +0 -557
  363. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +0 -4
  364. package/artifacts/contracts/test/TestPool.sol/TestPool.json +0 -716
  365. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +0 -4
  366. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +0 -744
  367. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +0 -4
  368. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +0 -99
  369. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
  370. package/contracts/instance/IInstanceLinked.sol +0 -8
  371. package/contracts/instance/base/IService.sol +0 -15
  372. package/contracts/instance/base/InstanceBase.sol +0 -89
  373. package/contracts/instance/base/ModuleBase.sol +0 -57
  374. package/contracts/instance/base/ServiceBase.sol +0 -44
  375. package/contracts/instance/module/access/Access.sol +0 -149
  376. package/contracts/instance/module/access/IAccess.sol +0 -53
  377. package/contracts/instance/module/bundle/BundleModule.sol +0 -134
  378. package/contracts/instance/module/bundle/IBundle.sol +0 -53
  379. package/contracts/instance/module/component/ComponentModule.sol +0 -71
  380. package/contracts/instance/module/component/IComponent.sol +0 -28
  381. package/contracts/instance/module/distribution/DistributionModule.sol +0 -17
  382. package/contracts/instance/module/distribution/IDistribution.sol +0 -10
  383. package/contracts/instance/module/policy/IPolicy.sol +0 -63
  384. package/contracts/instance/module/policy/PolicyModule.sol +0 -91
  385. package/contracts/instance/module/pool/IPoolModule.sol +0 -41
  386. package/contracts/instance/module/pool/PoolModule.sol +0 -95
  387. package/contracts/instance/module/risk/IRisk.sol +0 -26
  388. package/contracts/instance/module/risk/RiskModule.sol +0 -62
  389. package/contracts/instance/module/treasury/ITreasury.sol +0 -84
  390. package/contracts/instance/module/treasury/TokenHandler.sol +0 -48
  391. package/contracts/instance/module/treasury/TreasuryModule.sol +0 -131
  392. package/contracts/registry/IChainNft.sol +0 -22
  393. package/contracts/test/TestDistribution.sol +0 -22
  394. package/contracts/test/TestPool.sol +0 -27
  395. package/contracts/test/TestProduct.sol +0 -74
  396. package/contracts/types/ReferralId.sol +0 -48
@@ -4,23 +4,29 @@ pragma solidity ^0.8.19;
4
4
  import {DISTRIBUTION} from "../types/ObjectType.sol";
5
5
  import {IDistributionService} from "../instance/service/IDistributionService.sol";
6
6
  import {IProductService} from "../instance/service/IProductService.sol";
7
- import {NftId} from "../types/NftId.sol";
8
- import {ReferralId} from "../types/ReferralId.sol";
7
+ import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
8
+ import {ReferralId} from "../types/Referral.sol";
9
9
  import {Fee, FeeLib} from "../types/Fee.sol";
10
10
  import {BaseComponent} from "./BaseComponent.sol";
11
11
  import {IDistributionComponent} from "./IDistributionComponent.sol";
12
12
  import {IRegistry} from "../registry/IRegistry.sol";
13
13
  import {IRegisterable} from "../shared/IRegisterable.sol";
14
+ import {ISetup} from "../instance/module/ISetup.sol";
14
15
  import {Registerable} from "../shared/Registerable.sol";
16
+ import {TokenHandler} from "../shared/TokenHandler.sol";
17
+ import {InstanceReader} from "../instance/InstanceReader.sol";
15
18
 
16
19
  contract Distribution is
17
20
  BaseComponent,
18
21
  IDistributionComponent
19
22
  {
23
+ using NftIdLib for NftId;
20
24
 
21
25
  Fee internal _initialDistributionFee;
22
26
  bool internal _isVerifying;
23
27
 
28
+ TokenHandler internal _tokenHandler;
29
+
24
30
  IDistributionService private _distributionService;
25
31
  IProductService private _productService;
26
32
 
@@ -45,6 +51,8 @@ contract Distribution is
45
51
  _isVerifying = verifying;
46
52
  _initialDistributionFee = distributionFee;
47
53
 
54
+ _tokenHandler = TokenHandler(token);
55
+
48
56
  _distributionService = _instance.getDistributionService();
49
57
  _productService = _instance.getProductService();
50
58
 
@@ -70,7 +78,8 @@ contract Distribution is
70
78
  virtual override
71
79
  returns (uint256 feeAmount)
72
80
  {
73
- Fee memory fee = getDistributionFee();
81
+ ISetup.DistributionSetupInfo memory setupInfo = getSetupInfo();
82
+ Fee memory fee = setupInfo.distributionFee;
74
83
  (feeAmount,) = FeeLib.calculateFee(fee, netPremiumAmount);
75
84
  }
76
85
 
@@ -115,16 +124,11 @@ contract Distribution is
115
124
  return false;
116
125
  }
117
126
 
118
- /// @dev default distribution fee, ie when not using any valid referralId
119
- function getDistributionFee() public view returns (Fee memory distributionFee) {
120
- NftId productNftId = _instance.getProductNftId(getNftId());
121
- if (_instance.hasTreasuryInfo(productNftId)) {
122
- return _instance.getTreasuryInfo(productNftId).distributionFee;
123
- } else {
124
- return _initialDistributionFee;
125
- }
127
+ function getSetupInfo() public view returns (ISetup.DistributionSetupInfo memory setupInfo) {
128
+ InstanceReader reader = _instance.getInstanceReader();
129
+ return reader.getDistributionSetupInfo(getNftId());
126
130
  }
127
-
131
+
128
132
 
129
133
  /// @dev returns true iff the component needs to be called when selling/renewing policis
130
134
  function isVerifying() external view returns (bool verifying) {
@@ -141,14 +145,18 @@ contract Distribution is
141
145
  {
142
146
  (
143
147
  IRegistry.ObjectInfo memory info,
144
- bytes memory data
145
148
  ) = super.getInitialInfo();
146
149
 
147
150
  return (
148
151
  info,
149
152
  abi.encode(
150
- _initialDistributionFee,
151
- _isVerifying
153
+ ISetup.DistributionSetupInfo(
154
+ _productNftId,
155
+ _tokenHandler,
156
+ _initialDistributionFee,
157
+ _isVerifying,
158
+ address(this)
159
+ )
152
160
  )
153
161
  );
154
162
  }
@@ -1,12 +1,19 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {IERC20Metadata} from "@openzeppelin5/contracts/token/ERC20/extensions/IERC20Metadata.sol";
4
+ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
5
 
6
6
  import {IRegisterable} from "../shared/IRegisterable.sol";
7
- import {IInstanceLinked} from "../instance/IInstanceLinked.sol";
7
+ import {IInstance} from "../instance/IInstance.sol";
8
+ import {NftId} from "../types/NftId.sol";
8
9
 
9
- interface IBaseComponent is IRegisterable, IInstanceLinked {
10
+ interface IBaseComponent is IRegisterable {
11
+ error ErrorBaseComponentWalletAddressIsSameAsCurrent(address newWallet);
12
+ error ErrorBaseComponentWalletAllowanceTooSmall(address oldWallet, address newWallet, uint256 allowance, uint256 balance);
13
+ error ErrorBaseComponentUnauthorized(address caller, uint64 requiredRoleIdNum);
14
+
15
+ event LogBaseComponentWalletAddressChanged(address newWallet);
16
+ event LogBaseComponentWalletTokensTransferred(address from, address to, uint256 amount);
10
17
 
11
18
  function lock() external;
12
19
 
@@ -14,6 +21,12 @@ interface IBaseComponent is IRegisterable, IInstanceLinked {
14
21
 
15
22
  function getToken() external view returns (IERC20Metadata token);
16
23
 
24
+ function setWallet(address walletAddress) external;
17
25
  function getWallet() external view returns (address walletAddress);
18
26
 
27
+ function getInstance() external view returns (IInstance instance);
28
+
29
+ function setProductNftId(NftId productNftId) external;
30
+ function getProductNftId() external view returns (NftId productNftId);
31
+
19
32
  }
@@ -2,8 +2,9 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  import {Fee} from "../types/Fee.sol";
5
- import {ReferralId} from "../types/ReferralId.sol";
5
+ import {ReferralId} from "../types/Referral.sol";
6
6
  import {NftId} from "../types/NftId.sol";
7
+ import {ISetup} from "../instance/module/ISetup.sol";
7
8
 
8
9
  interface IDistributionComponent {
9
10
 
@@ -38,9 +39,6 @@ interface IDistributionComponent {
38
39
  /// @dev returns true iff the referral id is valid
39
40
  function referralIsValid(ReferralId referralId) external view returns (bool isValid);
40
41
 
41
- /// @dev default distribution fee, ie when not using any valid referralId
42
- function getDistributionFee() external view returns (Fee memory distributionFee);
43
-
44
42
  /// @dev returns true iff the component needs to be called when selling/renewing policis
45
43
  function isVerifying() external view returns (bool verifying);
46
44
  }
@@ -43,6 +43,10 @@ interface IPoolComponent {
43
43
  uint256 collateralizationAmount
44
44
  ) external;
45
45
 
46
+ function lockBundle(NftId bundleNftId) external;
47
+
48
+ function unlockBundle(NftId bundleNftId) external;
49
+
46
50
  /**
47
51
  * @dev returns true iff the policy application data in policyData matches
48
52
  * with the bundle filter criteria encoded in bundleFilter.
@@ -55,10 +59,8 @@ interface IPoolComponent {
55
59
  view
56
60
  returns (bool isMatching);
57
61
 
58
- function isVerifying() external view returns (bool verifying);
62
+ function isConfirmingApplication() external view returns (bool isConfirmingApplication);
59
63
 
60
64
  function getCollateralizationLevel() external view returns (UFixed collateralizationLevel);
61
65
 
62
- function getFees() external view returns (Fee memory poolFee, Fee memory stakingFee, Fee memory performanceFee);
63
-
64
66
  }
@@ -3,7 +3,7 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {Fee} from "../types/Fee.sol";
5
5
  import {NftId} from "../types/NftId.sol";
6
- import {ReferralId} from "../types/ReferralId.sol";
6
+ import {ReferralId} from "../types/Referral.sol";
7
7
  import {RiskId} from "../types/RiskId.sol";
8
8
 
9
9
  interface IProductComponent {
@@ -29,9 +29,7 @@ interface IProductComponent {
29
29
  bytes memory applicationData
30
30
  ) external view returns (uint256 netPremiumAmount);
31
31
 
32
- function getProductFee() external view returns (Fee memory productFee);
33
- function getProcessingFee() external view returns (Fee memory processingFee);
34
-
32
+
35
33
  function getPoolNftId() external view returns (NftId poolNftId);
36
34
  function getDistributionNftId() external view returns (NftId distributionNftId);
37
35
  }
@@ -4,34 +4,45 @@ pragma solidity ^0.8.20;
4
4
  import {ObjectType, POOL} from "../types/ObjectType.sol";
5
5
  import {IProductService} from "../instance/service/IProductService.sol";
6
6
  import {IPoolService} from "../instance/service/IPoolService.sol";
7
- import {NftId} from "../types/NftId.sol";
7
+ import {IBundleService} from "../instance/service/IBundleService.sol";
8
+ import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
8
9
  import {Fee} from "../types/Fee.sol";
9
10
  import {UFixed} from "../types/UFixed.sol";
10
11
  import {IPoolComponent} from "./IPoolComponent.sol";
11
12
  import {BaseComponent} from "./BaseComponent.sol";
13
+ import {TokenHandler} from "../shared/TokenHandler.sol";
14
+ import {ISetup} from "../instance/module/ISetup.sol";
12
15
 
13
16
  import {IRegistry} from "../registry/IRegistry.sol";
14
- import {IPool} from "../instance/module/pool/IPoolModule.sol";
15
- import {ITreasury} from "../instance/module/treasury/ITreasury.sol";
17
+
18
+ // import {IPool} from "../instance/module/pool/IPoolModule.sol";
19
+ import {ITreasury} from "../instance/module/ITreasury.sol";
20
+ import {ISetup} from "../instance/module/ISetup.sol";
21
+ import {InstanceReader} from "../instance/InstanceReader.sol";
16
22
 
17
23
  import {IRegisterable} from "../shared/IRegisterable.sol";
18
24
  import {Registerable} from "../shared/Registerable.sol";
19
25
 
20
26
  contract Pool is BaseComponent, IPoolComponent {
27
+ using NftIdLib for NftId;
21
28
 
22
- bool internal _isVerifying;
29
+ bool internal _isConfirmingApplication;
23
30
  UFixed internal _collateralizationLevel;
24
31
 
25
32
  Fee internal _initialPoolFee;
26
33
  Fee internal _initialStakingFee;
27
34
  Fee internal _initialPerformanceFee;
28
35
 
36
+ TokenHandler internal _tokenHandler;
37
+
29
38
  // may be used to interact with instance by derived contracts
30
39
  IPoolService internal _poolService;
31
40
 
32
41
  // only relevant to protect callback functions for "active" pools
33
42
  IProductService private _productService;
34
43
 
44
+ IBundleService private _bundleService;
45
+
35
46
  modifier onlyPoolService() {
36
47
  require(
37
48
  msg.sender == address(_poolService),
@@ -52,7 +63,7 @@ contract Pool is BaseComponent, IPoolComponent {
52
63
  // TODO refactor into tokenNftId
53
64
  address token,
54
65
  bool isInterceptor,
55
- bool verifying,
66
+ bool isConfirmingApplication,
56
67
  UFixed collateralizationLevel,
57
68
  Fee memory poolFee,
58
69
  Fee memory stakingFee,
@@ -61,15 +72,18 @@ contract Pool is BaseComponent, IPoolComponent {
61
72
  )
62
73
  BaseComponent(registry, instanceNftId, token, POOL(), isInterceptor, initialOwner)
63
74
  {
64
- _isVerifying = verifying;
75
+ _isConfirmingApplication = isConfirmingApplication;
65
76
  // TODO add validation
66
77
  _collateralizationLevel = collateralizationLevel;
67
78
  _initialPoolFee = poolFee;
68
79
  _initialStakingFee = stakingFee;
69
80
  _initialPerformanceFee = performanceFee;
70
81
 
82
+ _tokenHandler = new TokenHandler(token);
83
+
71
84
  _poolService = _instance.getPoolService();
72
85
  _productService = _instance.getProductService();
86
+ _bundleService = _instance.getBundleService();
73
87
 
74
88
  _registerInterface(type(IPoolComponent).interfaceId);
75
89
  }
@@ -85,7 +99,7 @@ contract Pool is BaseComponent, IPoolComponent {
85
99
  returns(NftId bundleNftId)
86
100
  {
87
101
  address owner = msg.sender;
88
- bundleNftId = _poolService.createBundle(
102
+ bundleNftId = _bundleService.createBundle(
89
103
  owner,
90
104
  fee,
91
105
  initialAmount,
@@ -130,8 +144,8 @@ contract Pool is BaseComponent, IPoolComponent {
130
144
  }
131
145
 
132
146
 
133
- function isVerifying() external view override returns (bool verifying) {
134
- return _isVerifying;
147
+ function isConfirmingApplication() external view override returns (bool isConfirmingApplication) {
148
+ return _isConfirmingApplication;
135
149
  }
136
150
 
137
151
  function getCollateralizationLevel() external view override returns (UFixed collateralizationLevel) {
@@ -158,22 +172,32 @@ contract Pool is BaseComponent, IPoolComponent {
158
172
  override
159
173
  // TODO add onlyBundleOwner
160
174
  {
161
- _poolService.setBundleFee(bundleNftId, fee);
175
+ _bundleService.setBundleFee(bundleNftId, fee);
162
176
  }
163
- // TODO delete, call instance instead
164
- function getFees()
177
+
178
+ function lockBundle(
179
+ NftId bundleNftId
180
+ )
165
181
  external
166
- view
167
182
  override
168
- returns (Fee memory, Fee memory, Fee memory)
183
+ // TODO add onlyBundleOwner
169
184
  {
170
- NftId productNftId = _instance.getProductNftId(getNftId());
171
- //if (_instance.hasTreasuryInfo(productNftId)) {
172
- ITreasury.TreasuryInfo memory info = _instance.getTreasuryInfo(productNftId);
173
- return (info.poolFee, info.stakingFee, info.performanceFee);
174
- //} else {
175
- // return (_initialPoolFee, _initialStakingFee, _initialPerformanceFee);
176
- //}
185
+ _bundleService.lockBundle(bundleNftId);
186
+ }
187
+
188
+ function unlockBundle(
189
+ NftId bundleNftId
190
+ )
191
+ external
192
+ override
193
+ // TODO add onlyBundleOwner
194
+ {
195
+ _bundleService.unlockBundle(bundleNftId);
196
+ }
197
+
198
+ function getSetupInfo() public view returns (ISetup.PoolSetupInfo memory setupInfo) {
199
+ InstanceReader reader = _instance.getInstanceReader();
200
+ return reader.getPoolSetupInfo(getNftId());
177
201
  }
178
202
 
179
203
  // from IRegisterable
@@ -188,21 +212,22 @@ contract Pool is BaseComponent, IPoolComponent {
188
212
  {
189
213
  (
190
214
  IRegistry.ObjectInfo memory info,
191
- bytes memory data
192
215
  ) = super.getInitialInfo();
193
216
 
194
217
  return (
195
218
  info,
196
219
  abi.encode(
197
- IPool.PoolInfo(
198
- _isVerifying,
199
- _collateralizationLevel
200
- ),
201
- _wallet,
202
- _token,
203
- _initialPoolFee,
204
- _initialStakingFee,
205
- _initialPerformanceFee
220
+ ISetup.PoolSetupInfo(
221
+ _productNftId,
222
+ _tokenHandler,
223
+ _collateralizationLevel,
224
+ _initialPoolFee,
225
+ _initialStakingFee,
226
+ _initialPerformanceFee,
227
+ false,
228
+ _isConfirmingApplication,
229
+ _wallet
230
+ )
206
231
  )
207
232
  );
208
233
  }
@@ -235,7 +260,7 @@ contract Pool is BaseComponent, IPoolComponent {
235
260
  internal
236
261
  returns(NftId bundleNftId)
237
262
  {
238
- bundleNftId = _poolService.createBundle(
263
+ bundleNftId = _bundleService.createBundle(
239
264
  bundleOwner,
240
265
  fee,
241
266
  amount,
@@ -1,15 +1,16 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import {IERC20Metadata} from "@openzeppelin5/contracts/token/ERC20/extensions/IERC20Metadata.sol";
4
+ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
5
 
6
- import {IRisk} from "../instance/module/risk/IRisk.sol";
7
- import {ITreasury} from "../instance/module/treasury/ITreasury.sol";
6
+ import {IRisk} from "../instance/module/IRisk.sol";
7
+ import {ITreasury} from "../instance/module/ITreasury.sol";
8
8
  import {IProductService} from "../instance/service/IProductService.sol";
9
+ import {IPolicyService} from "../instance/service/IPolicyService.sol";
9
10
  import {IProductComponent} from "./IProductComponent.sol";
10
- import {NftId, zeroNftId} from "../types/NftId.sol";
11
+ import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
11
12
  import {ObjectType, PRODUCT} from "../types/ObjectType.sol";
12
- import {ReferralId} from "../types/ReferralId.sol";
13
+ import {ReferralId} from "../types/Referral.sol";
13
14
  import {RiskId, RiskIdLib} from "../types/RiskId.sol";
14
15
  import {StateId} from "../types/StateId.sol";
15
16
  import {Timestamp} from "../types/Timestamp.sol";
@@ -19,16 +20,25 @@ import {BaseComponent} from "./BaseComponent.sol";
19
20
  import {IRegistry} from "../registry/IRegistry.sol";
20
21
  import {IRegisterable} from "../shared/IRegisterable.sol";
21
22
  import {Registerable} from "../shared/Registerable.sol";
23
+ import {TokenHandler} from "../shared/TokenHandler.sol";
22
24
 
23
- import {IPool} from "../instance/module/pool/IPoolModule.sol";
25
+ import {InstanceReader} from "../instance/InstanceReader.sol";
26
+ import {ISetup} from "../instance/module/ISetup.sol";
24
27
  import {Pool} from "../components/Pool.sol";
28
+ import {Distribution} from "../components/Distribution.sol";
29
+
30
+ import {zeroNftId} from "../types/NftId.sol";
25
31
 
26
32
  contract Product is BaseComponent, IProductComponent {
33
+ using NftIdLib for NftId;
34
+
27
35
  IProductService internal _productService;
36
+ IPolicyService internal _policyService;
28
37
  Pool internal _pool;
29
- address internal _distribution;
38
+ Distribution internal _distribution;
30
39
  Fee internal _initialProductFee;
31
40
  Fee internal _initialProcessingFee;
41
+ TokenHandler internal _tokenHandler;
32
42
 
33
43
  NftId internal _poolNftId;
34
44
  NftId internal _distributionNftId;
@@ -46,13 +56,16 @@ contract Product is BaseComponent, IProductComponent {
46
56
  ) BaseComponent(registry, instanceNftid, token, PRODUCT(), isInterceptor, initialOwner) {
47
57
  // TODO add validation
48
58
  _productService = _instance.getProductService();
59
+ _policyService = _instance.getPolicyService();
49
60
  _pool = Pool(pool);
50
- _distribution = distribution;
61
+ _distribution = Distribution(distribution);
51
62
  _initialProductFee = productFee;
52
63
  _initialProcessingFee = processingFee;
53
64
 
65
+ _tokenHandler = new TokenHandler(token);
66
+
54
67
  _poolNftId = getRegistry().getNftId(address(_pool));
55
- _distributionNftId = getRegistry().getNftId(_distribution);
68
+ _distributionNftId = getRegistry().getNftId(address(_distribution));
56
69
 
57
70
  _registerInterface(type(IProductComponent).interfaceId);
58
71
  }
@@ -71,7 +84,7 @@ contract Product is BaseComponent, IProductComponent {
71
84
  override
72
85
  returns (uint256 premiumAmount)
73
86
  {
74
- (premiumAmount,,,,) = _productService.calculatePremium(
87
+ (premiumAmount,,,,) = _policyService.calculatePremium(
75
88
  riskId,
76
89
  sumInsuredAmount,
77
90
  lifetime,
@@ -111,13 +124,13 @@ contract Product is BaseComponent, IProductComponent {
111
124
  );
112
125
  }
113
126
 
114
- function _setRiskInfo(
127
+ function _updateRisk(
115
128
  RiskId id,
116
- IRisk.RiskInfo memory info
129
+ bytes memory data
117
130
  ) internal {
118
- _productService.setRiskInfo(
131
+ _productService.updateRisk(
119
132
  id,
120
- info
133
+ data
121
134
  );
122
135
  }
123
136
 
@@ -132,7 +145,7 @@ contract Product is BaseComponent, IProductComponent {
132
145
  }
133
146
 
134
147
  function _getRiskInfo(RiskId id) internal view returns (IRisk.RiskInfo memory info) {
135
- return _instance.getRiskInfo(id);
148
+ return _instance.getInstanceReader().getRiskInfo(id);
136
149
  }
137
150
 
138
151
  function _createApplication(
@@ -144,7 +157,7 @@ contract Product is BaseComponent, IProductComponent {
144
157
  NftId bundleNftId,
145
158
  ReferralId referralId
146
159
  ) internal returns (NftId nftId) {
147
- nftId = _productService.createApplication(
160
+ nftId = _policyService.createApplication(
148
161
  applicationOwner,
149
162
  riskId,
150
163
  sumInsuredAmount,
@@ -162,7 +175,7 @@ contract Product is BaseComponent, IProductComponent {
162
175
  )
163
176
  internal
164
177
  {
165
- _productService.underwrite(
178
+ _policyService.underwrite(
166
179
  policyNftId,
167
180
  requirePremiumPayment,
168
181
  activateAt);
@@ -174,7 +187,7 @@ contract Product is BaseComponent, IProductComponent {
174
187
  )
175
188
  internal
176
189
  {
177
- _productService.collectPremium(
190
+ _policyService.collectPremium(
178
191
  policyNftId,
179
192
  activateAt);
180
193
  }
@@ -185,7 +198,7 @@ contract Product is BaseComponent, IProductComponent {
185
198
  )
186
199
  internal
187
200
  {
188
- _productService.activate(
201
+ _policyService.activate(
189
202
  policyNftId,
190
203
  activateAt);
191
204
  }
@@ -195,7 +208,7 @@ contract Product is BaseComponent, IProductComponent {
195
208
  }
196
209
 
197
210
  function getDistributionNftId() external view override returns (NftId distributionNftId) {
198
- return getRegistry().getNftId(_distribution);
211
+ return getRegistry().getNftId(address(_distribution));
199
212
  }
200
213
 
201
214
  // from product component
@@ -210,38 +223,13 @@ contract Product is BaseComponent, IProductComponent {
210
223
  _productService.setFees(productFee, processingFee);
211
224
  }
212
225
 
213
- // TODO delete, call instance intead
214
- function getProductFee()
215
- external
216
- view
217
- override
218
- returns (Fee memory productFee)
219
- {
220
- NftId productNftId = getNftId();
221
- if (_instance.hasTreasuryInfo(productNftId)) {
222
- return _instance.getTreasuryInfo(productNftId).productFee;
223
- } else {
224
- return _initialProductFee;
225
- }
226
- }
227
-
228
- function getProcessingFee()
229
- external
230
- view
231
- override
232
- returns (Fee memory processingFee)
233
- {
234
- NftId productNftId = getNftId();
235
- if (_instance.hasTreasuryInfo(productNftId)) {
236
- return _instance.getTreasuryInfo(productNftId).processingFee;
237
- } else {
238
- return _initialProcessingFee;
239
- }
226
+ function getSetupInfo() public view returns (ISetup.ProductSetupInfo memory setupInfo) {
227
+ InstanceReader reader = _instance.getInstanceReader();
228
+ return reader.getProductSetupInfo(getNftId());
240
229
  }
241
230
 
242
231
  // from IRegisterable
243
232
 
244
- // TODO used only once, occupies space
245
233
  function getInitialInfo()
246
234
  public
247
235
  view
@@ -253,7 +241,7 @@ contract Product is BaseComponent, IProductComponent {
253
241
  IRegistry.ObjectInfo memory productInfo,
254
242
  bytes memory data
255
243
  ) = super.getInitialInfo();
256
-
244
+
257
245
  // TODO read pool & distribution fees
258
246
  // 1) from pool -> the only option -> pool must be registered first?
259
247
  // 2) from instance -> all fees are set into instance at product registration which is ongoing here
@@ -263,36 +251,41 @@ contract Product is BaseComponent, IProductComponent {
263
251
 
264
252
  // from PoolComponent
265
253
  (
266
- IRegistry.ObjectInfo memory poolInfo,
254
+ ,
267
255
  bytes memory poolData
268
256
  ) = _pool.getInitialInfo();
257
+
258
+ (
259
+ ISetup.PoolSetupInfo memory poolSetupInfo
260
+ ) = abi.decode(poolData, (ISetup.PoolSetupInfo));
269
261
 
262
+ // from DistributionComponent
270
263
  (
271
- /*IPool.PoolInfo memory info*/,
272
- /*address wallet*/,
273
- /*IERC20Metadata token*/,
274
- Fee memory initialPoolFee,
275
- Fee memory initialStakingFee,
276
- Fee memory initialPerformanceFee
277
- ) = abi.decode(poolData, (IPool.PoolInfo, address, IERC20Metadata, Fee, Fee, Fee));
264
+ ,
265
+ bytes memory distributionData
266
+ ) = _distribution.getInitialInfo();
278
267
 
279
- // TODO from DistributionComponent
268
+ (
269
+ ISetup.DistributionSetupInfo memory distributionSetupInfo
270
+ ) = abi.decode(distributionData, (ISetup.DistributionSetupInfo));
280
271
 
281
272
  return (
282
273
  productInfo,
283
274
  abi.encode(
284
- ITreasury.TreasuryInfo(
285
- _poolNftId,
286
- _distributionNftId,
275
+ ISetup.ProductSetupInfo(
287
276
  _token,
277
+ _tokenHandler,
278
+ _distributionNftId,
279
+ _poolNftId,
280
+ distributionSetupInfo.distributionFee,
288
281
  _initialProductFee,
289
282
  _initialProcessingFee,
290
- initialPoolFee,
291
- initialStakingFee,
292
- initialPerformanceFee,
293
- FeeLib.zeroFee()//_instance.getDistributionFee(_distributionNftId)
294
- ),
295
- _wallet
283
+ poolSetupInfo.poolFee,
284
+ poolSetupInfo.stakingFee,
285
+ poolSetupInfo.performanceFee,
286
+ false,
287
+ _wallet
288
+ )
296
289
  )
297
290
  );
298
291
  }