@etherisc/gif-next 0.0.2-7b53731-014 → 0.0.2-7b86057-523

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 (422) hide show
  1. package/README.md +211 -27
  2. package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
  3. package/artifacts/contracts/components/Component.sol/Component.json +656 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +530 -86
  6. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
  7. package/artifacts/contracts/{registry/IChainNft.sol/IChainNft.json → components/IComponent.sol/IComponent.json} +244 -241
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +357 -49
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +400 -118
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +452 -74
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +564 -172
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +622 -117
  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/BundleManager.sol/BundleManager.dbg.json +4 -0
  45. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +764 -0
  46. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
  47. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +185 -0
  48. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  49. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +995 -1022
  50. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
  51. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +586 -0
  52. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  53. package/artifacts/contracts/instance/Instance.sol/Instance.json +1835 -1161
  54. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +4 -0
  55. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +1034 -0
  56. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +4 -0
  57. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1381 -0
  58. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
  59. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +1039 -0
  60. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
  61. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +473 -0
  62. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
  63. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +261 -0
  64. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
  65. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +603 -0
  66. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  67. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +27 -158
  68. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  69. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  70. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +37 -245
  71. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  72. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
  73. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +4 -0
  74. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +254 -0
  75. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +4 -0
  76. package/artifacts/contracts/instance/module/{bundle/IBundle.sol → IBundle.sol}/IBundle.json +1 -1
  77. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +4 -0
  78. package/artifacts/contracts/instance/module/{distribution/IDistribution.sol → IDistribution.sol}/IDistribution.json +1 -1
  79. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +4 -0
  80. package/artifacts/contracts/instance/module/{policy/IPolicy.sol → IPolicy.sol}/IPolicy.json +1 -1
  81. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +4 -0
  82. package/artifacts/contracts/instance/module/{risk/IRisk.sol → IRisk.sol}/IRisk.json +1 -1
  83. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +4 -0
  84. package/artifacts/contracts/instance/{base/ModuleBase.sol/ModuleBase.json → module/ISetup.sol/ISetup.json} +2 -2
  85. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +4 -0
  86. package/artifacts/contracts/instance/module/{treasury/ITreasury.sol → ITreasury.sol}/ITreasury.json +1 -1
  87. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
  88. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1102 -0
  89. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
  90. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +449 -0
  91. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +415 -63
  93. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
  94. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +437 -0
  95. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
  96. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +715 -0
  97. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  98. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +178 -62
  99. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
  100. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +766 -0
  101. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  102. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +178 -124
  103. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  104. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +175 -274
  105. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
  106. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +1227 -0
  107. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
  108. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +505 -0
  109. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  110. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +395 -132
  111. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
  112. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +437 -0
  113. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  114. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +348 -350
  115. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
  116. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +437 -0
  117. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  118. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +186 -12
  119. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  120. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +455 -36
  121. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
  122. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +981 -0
  123. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
  124. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +34 -0
  125. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  126. package/artifacts/contracts/registry/Registry.sol/Registry.json +465 -111
  127. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
  128. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
  129. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
  130. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +1200 -0
  131. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
  132. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +464 -0
  133. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
  134. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +547 -0
  135. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
  136. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +394 -0
  137. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +4 -0
  138. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.json +107 -0
  139. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  140. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  141. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
  142. package/artifacts/contracts/{instance/module/component/IComponent.sol/IComponentModule.json → shared/INftOwnable.sol/INftOwnable.json} +67 -57
  143. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  144. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +112 -37
  145. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
  146. package/artifacts/contracts/{instance/service/IComponentOwnerService.sol/IComponentOwnerService.json → shared/IService.sol/IService.json} +169 -117
  147. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  148. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +55 -14
  149. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +4 -0
  150. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +171 -0
  151. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
  152. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +362 -0
  153. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  154. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +193 -32
  155. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
  156. package/artifacts/contracts/{instance/base/InstanceBase.sol/InstanceBase.json → shared/Service.sol/Service.json} +202 -102
  157. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +4 -0
  158. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +96 -0
  159. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
  160. package/artifacts/contracts/shared/{Proxy.sol/ProxyWithProxyAdminGetter.json → UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json} +4 -4
  161. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  162. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +78 -14
  163. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  164. package/artifacts/contracts/test/TestFee.sol/TestFee.json +4 -4
  165. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  166. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +207 -31
  167. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  168. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +14 -14
  169. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  170. package/artifacts/contracts/test/TestService.sol/TestService.json +292 -63
  171. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  172. package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +91 -53
  173. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  174. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  175. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  176. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +103 -23
  177. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  178. package/artifacts/contracts/test/Usdc.sol/USDC.json +91 -53
  179. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  180. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  181. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  182. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
  183. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +104 -0
  184. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  185. package/artifacts/contracts/types/Fee.sol/FeeLib.json +4 -4
  186. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  187. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +31 -17
  188. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  189. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  190. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  191. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +26 -3
  192. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +4 -0
  193. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.json +100 -0
  194. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  195. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  196. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +4 -0
  197. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +123 -0
  198. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  199. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  200. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  201. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +134 -8
  202. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  203. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  204. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  205. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +15 -2
  206. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
  207. package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
  208. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
  209. package/artifacts/contracts/types/UFixed.sol/{UFixedMathLib.json → UFixedLib.json} +3 -3
  210. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  211. package/artifacts/contracts/types/Version.sol/VersionLib.json +40 -2
  212. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  213. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +22 -3
  214. package/contracts/components/Component.sol +216 -0
  215. package/contracts/components/Distribution.sol +57 -38
  216. package/contracts/components/IComponent.sol +43 -0
  217. package/contracts/components/IDistributionComponent.sol +6 -6
  218. package/contracts/components/IPoolComponent.sol +12 -23
  219. package/contracts/components/IProductComponent.sol +10 -9
  220. package/contracts/components/Pool.sol +112 -120
  221. package/contracts/components/Product.sol +99 -61
  222. package/contracts/experiment/cloning/Cloner.sol +47 -0
  223. package/contracts/instance/BundleManager.sol +125 -0
  224. package/contracts/instance/Cloneable.sol +46 -0
  225. package/contracts/instance/IInstance.sol +64 -45
  226. package/contracts/instance/IInstanceService.sol +41 -0
  227. package/contracts/instance/Instance.sol +254 -59
  228. package/contracts/instance/InstanceAccessManager.sol +298 -0
  229. package/contracts/instance/InstanceReader.sol +293 -0
  230. package/contracts/instance/InstanceService.sol +435 -0
  231. package/contracts/instance/InstanceServiceManager.sol +54 -0
  232. package/contracts/instance/ObjectManager.sol +84 -0
  233. package/contracts/instance/base/ComponentService.sol +134 -0
  234. package/contracts/instance/base/IKeyValueStore.sol +13 -14
  235. package/contracts/instance/base/ILifecycle.sol +3 -3
  236. package/contracts/instance/base/KeyValueStore.sol +49 -38
  237. package/contracts/instance/base/Lifecycle.sol +1 -1
  238. package/contracts/instance/module/IAccess.sol +48 -0
  239. package/contracts/instance/module/IBundle.sol +20 -0
  240. package/contracts/instance/module/IDistribution.sol +39 -0
  241. package/contracts/instance/module/IPolicy.sol +45 -0
  242. package/contracts/instance/module/IRisk.sol +11 -0
  243. package/contracts/instance/module/ISetup.sol +46 -0
  244. package/contracts/instance/module/ITreasury.sol +23 -0
  245. package/contracts/instance/service/BundleService.sol +293 -0
  246. package/contracts/instance/service/BundleServiceManager.sol +51 -0
  247. package/contracts/instance/service/DistributionService.sol +70 -23
  248. package/contracts/instance/service/DistributionServiceManager.sol +51 -0
  249. package/contracts/instance/service/IBundleService.sol +44 -0
  250. package/contracts/instance/service/IDistributionService.sol +1 -1
  251. package/contracts/instance/service/IPolicyService.sol +94 -0
  252. package/contracts/instance/service/IPoolService.sol +7 -24
  253. package/contracts/instance/service/IProductService.sol +9 -76
  254. package/contracts/instance/service/PolicyService.sol +538 -0
  255. package/contracts/instance/service/PolicyServiceManager.sol +54 -0
  256. package/contracts/instance/service/PoolService.sol +76 -115
  257. package/contracts/instance/service/PoolServiceManager.sol +51 -0
  258. package/contracts/instance/service/ProductService.sol +158 -434
  259. package/contracts/instance/service/ProductServiceManager.sol +54 -0
  260. package/contracts/registry/ChainNft.sol +79 -36
  261. package/contracts/registry/IRegistry.sol +65 -24
  262. package/contracts/registry/IRegistryService.sol +65 -0
  263. package/contracts/registry/ITransferInterceptor.sol +6 -0
  264. package/contracts/registry/Registry.sol +358 -287
  265. package/contracts/registry/RegistryAccessManager.sol +216 -0
  266. package/contracts/registry/RegistryService.sol +262 -0
  267. package/contracts/registry/RegistryServiceManager.sol +62 -0
  268. package/contracts/registry/ReleaseManager.sol +332 -0
  269. package/contracts/registry/TokenRegistry.sol +112 -0
  270. package/contracts/shared/ContractDeployerLib.sol +72 -0
  271. package/contracts/shared/ERC165.sol +6 -2
  272. package/contracts/shared/INftOwnable.sol +22 -0
  273. package/contracts/shared/IRegisterable.sol +8 -17
  274. package/contracts/shared/IService.sol +16 -0
  275. package/contracts/shared/IVersionable.sol +55 -11
  276. package/contracts/shared/NftOwnable.sol +139 -0
  277. package/contracts/shared/ProxyManager.sol +94 -0
  278. package/contracts/shared/Registerable.sol +59 -59
  279. package/contracts/shared/Service.sol +60 -0
  280. package/contracts/shared/TokenHandler.sol +27 -0
  281. package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
  282. package/contracts/shared/Versionable.sol +113 -55
  283. package/contracts/test/TestFee.sol +2 -2
  284. package/contracts/test/TestRegisterable.sol +5 -6
  285. package/contracts/test/TestRoleId.sol +1 -1
  286. package/contracts/test/TestService.sol +7 -14
  287. package/contracts/types/DistributorType.sol +55 -0
  288. package/contracts/types/Fee.sol +3 -3
  289. package/contracts/types/Key32.sol +8 -3
  290. package/contracts/types/NftIdSet.sol +26 -24
  291. package/contracts/types/NumberId.sol +52 -0
  292. package/contracts/types/ObjectType.sol +35 -14
  293. package/contracts/types/Referral.sol +85 -0
  294. package/contracts/types/RoleId.sol +61 -9
  295. package/contracts/types/StateId.sol +5 -1
  296. package/contracts/types/Timestamp.sol +7 -3
  297. package/contracts/types/UFixed.sol +128 -12
  298. package/contracts/types/Version.sol +13 -1
  299. package/package.json +4 -3
  300. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
  301. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +0 -174
  302. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
  303. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +0 -174
  304. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +0 -4
  305. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.json +0 -24
  306. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
  307. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +0 -300
  308. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
  309. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -113
  310. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +0 -4
  311. package/artifacts/contracts/instance/base/IService.sol/IService.json +0 -300
  312. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +0 -4
  313. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +0 -4
  314. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +0 -4
  315. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.json +0 -300
  316. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +0 -4
  317. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.json +0 -333
  318. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +0 -4
  319. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.json +0 -10
  320. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +0 -4
  321. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.json +0 -333
  322. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +0 -4
  323. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +0 -297
  324. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +0 -4
  325. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +0 -4
  326. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +0 -297
  327. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +0 -4
  328. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +0 -117
  329. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +0 -4
  330. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.json +0 -10
  331. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +0 -4
  332. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +0 -4
  333. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +0 -10
  334. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +0 -4
  335. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +0 -4
  336. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.json +0 -10
  337. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +0 -4
  338. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +0 -4
  339. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +0 -284
  340. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
  341. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +0 -284
  342. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +0 -4
  343. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.json +0 -10
  344. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +0 -4
  345. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +0 -144
  346. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
  347. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -144
  348. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +0 -4
  349. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +0 -4
  350. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +0 -113
  351. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +0 -4
  352. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +0 -131
  353. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +0 -4
  354. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +0 -4
  355. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +0 -511
  356. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +0 -4
  357. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +0 -76
  358. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +0 -4
  359. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +0 -511
  360. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
  361. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -531
  362. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
  363. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
  364. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +0 -4
  365. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.json +0 -24
  366. package/artifacts/contracts/registry/RegistryUpgradeable.sol/RegistryUpgradeable.dbg.json +0 -4
  367. package/artifacts/contracts/registry/RegistryUpgradeable.sol/RegistryUpgradeable.json +0 -495
  368. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +0 -4
  369. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.json +0 -24
  370. package/artifacts/contracts/shared/Proxy.sol/Proxy.dbg.json +0 -4
  371. package/artifacts/contracts/shared/Proxy.sol/Proxy.json +0 -178
  372. package/artifacts/contracts/shared/Proxy.sol/ProxyWithProxyAdminGetter.dbg.json +0 -4
  373. package/artifacts/contracts/shared/VersionableUpgradeable.sol/VersionableUpgradeable.dbg.json +0 -4
  374. package/artifacts/contracts/shared/VersionableUpgradeable.sol/VersionableUpgradeable.json +0 -187
  375. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +0 -4
  376. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +0 -405
  377. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +0 -4
  378. package/artifacts/contracts/test/TestPool.sol/TestPool.json +0 -578
  379. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +0 -4
  380. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +0 -575
  381. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +0 -4
  382. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +0 -99
  383. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
  384. package/contracts/components/BaseComponent.sol +0 -94
  385. package/contracts/components/IBaseComponent.sol +0 -19
  386. package/contracts/experiment/statemachine/README.md +0 -112
  387. package/contracts/instance/IInstanceLinked.sol +0 -8
  388. package/contracts/instance/base/ComponentServiceBase.sol +0 -42
  389. package/contracts/instance/base/IInstanceBase.sol +0 -22
  390. package/contracts/instance/base/IService.sol +0 -15
  391. package/contracts/instance/base/InstanceBase.sol +0 -91
  392. package/contracts/instance/base/ModuleBase.sol +0 -57
  393. package/contracts/instance/base/ServiceBase.sol +0 -37
  394. package/contracts/instance/module/access/Access.sol +0 -149
  395. package/contracts/instance/module/access/IAccess.sol +0 -53
  396. package/contracts/instance/module/bundle/BundleModule.sol +0 -134
  397. package/contracts/instance/module/bundle/IBundle.sol +0 -53
  398. package/contracts/instance/module/component/ComponentModule.sol +0 -70
  399. package/contracts/instance/module/component/IComponent.sol +0 -28
  400. package/contracts/instance/module/distribution/DistributionModule.sol +0 -17
  401. package/contracts/instance/module/distribution/IDistribution.sol +0 -10
  402. package/contracts/instance/module/policy/IPolicy.sol +0 -63
  403. package/contracts/instance/module/policy/PolicyModule.sol +0 -91
  404. package/contracts/instance/module/pool/IPoolModule.sol +0 -40
  405. package/contracts/instance/module/pool/PoolModule.sol +0 -90
  406. package/contracts/instance/module/risk/IRisk.sol +0 -26
  407. package/contracts/instance/module/risk/RiskModule.sol +0 -62
  408. package/contracts/instance/module/treasury/ITreasury.sol +0 -82
  409. package/contracts/instance/module/treasury/TokenHandler.sol +0 -48
  410. package/contracts/instance/module/treasury/TreasuryModule.sol +0 -138
  411. package/contracts/instance/service/ComponentOwnerService.sol +0 -157
  412. package/contracts/instance/service/IComponentOwnerService.sol +0 -22
  413. package/contracts/registry/IChainNft.sol +0 -21
  414. package/contracts/registry/IRegistryLinked.sol +0 -8
  415. package/contracts/registry/RegistryUpgradeable.sol +0 -416
  416. package/contracts/shared/IOwnable.sol +0 -6
  417. package/contracts/shared/Proxy.sol +0 -83
  418. package/contracts/shared/VersionableUpgradeable.sol +0 -108
  419. package/contracts/test/TestDistribution.sol +0 -21
  420. package/contracts/test/TestPool.sol +0 -25
  421. package/contracts/test/TestProduct.sol +0 -72
  422. package/contracts/types/ReferralId.sol +0 -48
@@ -1,14 +1,17 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.19;
2
+ pragma solidity ^0.8.20;
3
3
 
4
4
  import {Fee} from "../types/Fee.sol";
5
+ import {IComponent} from "./IComponent.sol";
6
+ import {ISetup} from "../instance/module/ISetup.sol";
5
7
  import {NftId} from "../types/NftId.sol";
6
- import {ReferralId} from "../types/ReferralId.sol";
8
+ import {ReferralId} from "../types/Referral.sol";
7
9
  import {RiskId} from "../types/RiskId.sol";
8
10
 
9
- import {IBaseComponent} from "./IBaseComponent.sol";
11
+ interface IProductComponent is IComponent {
12
+
13
+ function getSetupInfo() external view returns (ISetup.ProductSetupInfo memory setupInfo);
10
14
 
11
- interface IProductComponent is IBaseComponent {
12
15
  function setFees(
13
16
  Fee memory productFee,
14
17
  Fee memory processingFee
@@ -19,8 +22,8 @@ interface IProductComponent is IBaseComponent {
19
22
  RiskId riskId,
20
23
  uint256 lifetime,
21
24
  bytes memory applicationData,
22
- ReferralId referralId,
23
- NftId bundleNftId
25
+ NftId bundleNftId,
26
+ ReferralId referralId
24
27
  ) external view returns (uint256 premiumAmount);
25
28
 
26
29
  function calculateNetPremium(
@@ -30,9 +33,7 @@ interface IProductComponent is IBaseComponent {
30
33
  bytes memory applicationData
31
34
  ) external view returns (uint256 netPremiumAmount);
32
35
 
33
- function getProductFee() external view returns (Fee memory productFee);
34
- function getProcessingFee() external view returns (Fee memory processingFee);
35
-
36
+
36
37
  function getPoolNftId() external view returns (NftId poolNftId);
37
38
  function getDistributionNftId() external view returns (NftId distributionNftId);
38
39
  }
@@ -1,29 +1,36 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.19;
2
+ pragma solidity ^0.8.20;
3
3
 
4
- import {ObjectType, POOL} from "../types/ObjectType.sol";
5
- import {IProductService} from "../instance/service/IProductService.sol";
4
+ import {POOL} from "../types/ObjectType.sol";
6
5
  import {IPoolService} from "../instance/service/IPoolService.sol";
7
- import {NftId} from "../types/NftId.sol";
6
+ import {IBundleService} from "../instance/service/IBundleService.sol";
7
+ import {NftId, NftIdLib} from "../types/NftId.sol";
8
8
  import {Fee} from "../types/Fee.sol";
9
9
  import {UFixed} from "../types/UFixed.sol";
10
10
  import {IPoolComponent} from "./IPoolComponent.sol";
11
- import {BaseComponent} from "./BaseComponent.sol";
11
+ import {Component} from "./Component.sol";
12
+ import {TokenHandler} from "../shared/TokenHandler.sol";
13
+ import {ISetup} from "../instance/module/ISetup.sol";
12
14
 
13
- contract Pool is BaseComponent, IPoolComponent {
15
+ import {ISetup} from "../instance/module/ISetup.sol";
16
+ import {InstanceReader} from "../instance/InstanceReader.sol";
14
17
 
15
- bool internal _isVerifying;
18
+
19
+ abstract contract Pool is Component, IPoolComponent {
20
+ using NftIdLib for NftId;
21
+
22
+ bool internal _isConfirmingApplication;
16
23
  UFixed internal _collateralizationLevel;
17
24
 
18
25
  Fee internal _initialPoolFee;
19
26
  Fee internal _initialStakingFee;
20
27
  Fee internal _initialPerformanceFee;
21
28
 
29
+ TokenHandler internal _tokenHandler;
30
+
22
31
  // may be used to interact with instance by derived contracts
23
32
  IPoolService internal _poolService;
24
-
25
- // only relevant to protect callback functions for "active" pools
26
- IProductService private _productService;
33
+ IBundleService private _bundleService;
27
34
 
28
35
  modifier onlyPoolService() {
29
36
  require(
@@ -32,86 +39,50 @@ contract Pool is BaseComponent, IPoolComponent {
32
39
  _;
33
40
  }
34
41
 
35
- modifier onlyProductService() {
36
- require(
37
- msg.sender == address(_productService),
38
- "ERROR:POL-002:NOT_PRODUCT_SERVICE");
39
- _;
40
- }
41
-
42
42
  constructor(
43
43
  address registry,
44
44
  NftId instanceNftId,
45
+ string memory name,
45
46
  // TODO refactor into tokenNftId
46
47
  address token,
47
- bool verifying,
48
+ bool isInterceptor,
49
+ bool isConfirmingApplication,
48
50
  UFixed collateralizationLevel,
49
51
  Fee memory poolFee,
50
52
  Fee memory stakingFee,
51
- Fee memory performanceFee
52
- )
53
- BaseComponent(registry, instanceNftId, token)
54
- {
55
- _isVerifying = verifying;
53
+ Fee memory performanceFee,
54
+ address initialOwner,
55
+ bytes memory data
56
+ ) Component(
57
+ registry,
58
+ instanceNftId,
59
+ name,
60
+ token,
61
+ POOL(),
62
+ isInterceptor,
63
+ initialOwner,
64
+ data
65
+ ) {
66
+ _isConfirmingApplication = isConfirmingApplication;
56
67
  // TODO add validation
57
68
  _collateralizationLevel = collateralizationLevel;
58
69
  _initialPoolFee = poolFee;
59
70
  _initialStakingFee = stakingFee;
60
71
  _initialPerformanceFee = performanceFee;
61
72
 
62
- _poolService = _instance.getPoolService();
63
- _productService = _instance.getProductService();
64
- }
73
+ _tokenHandler = new TokenHandler(token);
65
74
 
66
- function setFees(
67
- Fee memory poolFee,
68
- Fee memory stakingFee,
69
- Fee memory performanceFee
70
- )
71
- external
72
- onlyOwner
73
- override
74
- {
75
- _poolService.setFees(poolFee, stakingFee, performanceFee);
76
- }
75
+ _poolService = getInstance().getPoolService();
76
+ _bundleService = getInstance().getBundleService();
77
77
 
78
- function createBundle(
79
- Fee memory fee,
80
- uint256 initialAmount,
81
- uint256 lifetime,
82
- bytes memory filter
83
- )
84
- external
85
- virtual override
86
- returns(NftId bundleNftId)
87
- {
88
- address owner = msg.sender;
89
- bundleNftId = _poolService.createBundle(
90
- owner,
91
- fee,
92
- initialAmount,
93
- lifetime,
94
- filter
95
- );
96
-
97
- // TODO add logging
98
- }
99
-
100
- function setBundleFee(
101
- NftId bundleNftId,
102
- Fee memory fee
103
- )
104
- external
105
- override
106
- // TODO add onlyBundleOwner
107
- {
108
- _poolService.setBundleFee(bundleNftId, fee);
78
+ _registerInterface(type(IPoolComponent).interfaceId);
109
79
  }
110
80
 
111
81
  /**
112
82
  * @dev see {IPool.underwrite}.
113
83
  * Default implementation that only writes a {LogUnderwrittenByPool} entry.
114
84
  */
85
+ // FIXME: remove this function .. only _internal
115
86
  function underwrite(
116
87
  NftId policyNftId,
117
88
  bytes memory policyData,
@@ -119,7 +90,7 @@ contract Pool is BaseComponent, IPoolComponent {
119
90
  uint256 collateralizationAmount
120
91
  )
121
92
  external
122
- onlyProductService
93
+ restricted()
123
94
  virtual override
124
95
  {
125
96
  _underwrite(policyNftId, policyData, bundleFilter, collateralizationAmount);
@@ -142,14 +113,83 @@ contract Pool is BaseComponent, IPoolComponent {
142
113
  }
143
114
 
144
115
 
145
- function isVerifying() external view override returns (bool verifying) {
146
- return _isVerifying;
116
+ function isConfirmingApplication() external view override returns (bool isConfirmingApplication) {
117
+ return _isConfirmingApplication;
147
118
  }
148
119
 
149
120
  function getCollateralizationLevel() external view override returns (UFixed collateralizationLevel) {
150
121
  return _collateralizationLevel;
151
122
  }
152
123
 
124
+ function setFees(
125
+ Fee memory poolFee,
126
+ Fee memory stakingFee,
127
+ Fee memory performanceFee
128
+ )
129
+ external
130
+ restricted()
131
+ override
132
+ {
133
+ _poolService.setFees(poolFee, stakingFee, performanceFee);
134
+ }
135
+
136
+ function setBundleFee(
137
+ NftId bundleNftId,
138
+ Fee memory fee
139
+ )
140
+ external
141
+ override
142
+ // TODO: add onlyBundleOwner
143
+ {
144
+ _bundleService.setBundleFee(bundleNftId, fee);
145
+ }
146
+
147
+ function lockBundle(
148
+ NftId bundleNftId
149
+ )
150
+ external
151
+ override
152
+ // TODO: add onlyBundleOwner
153
+ {
154
+ _bundleService.lockBundle(bundleNftId);
155
+ }
156
+
157
+ function unlockBundle(
158
+ NftId bundleNftId
159
+ )
160
+ external
161
+ override
162
+ // TODO: add onlyBundleOwner
163
+ {
164
+ _bundleService.unlockBundle(bundleNftId);
165
+ }
166
+
167
+ function getSetupInfo() public view returns (ISetup.PoolSetupInfo memory setupInfo) {
168
+ InstanceReader reader = getInstance().getInstanceReader();
169
+ setupInfo = reader.getPoolSetupInfo(getNftId());
170
+
171
+ // fallback to initial setup info (wallet is always != address(0))
172
+ if(setupInfo.wallet == address(0)) {
173
+ setupInfo = _getInitialSetupInfo();
174
+ }
175
+ }
176
+
177
+ function _getInitialSetupInfo() internal view returns (ISetup.PoolSetupInfo memory) {
178
+ return ISetup.PoolSetupInfo(
179
+ getProductNftId(),
180
+ _tokenHandler,
181
+ _collateralizationLevel,
182
+ _initialPoolFee,
183
+ _initialStakingFee,
184
+ _initialPerformanceFee,
185
+ false,
186
+ _isConfirmingApplication,
187
+ getWallet()
188
+ );
189
+ }
190
+
191
+ // Internals
192
+
153
193
  function _underwrite(
154
194
  NftId policyNftId,
155
195
  bytes memory policyData,
@@ -176,7 +216,7 @@ contract Pool is BaseComponent, IPoolComponent {
176
216
  internal
177
217
  returns(NftId bundleNftId)
178
218
  {
179
- bundleNftId = _poolService.createBundle(
219
+ bundleNftId = _bundleService.createBundle(
180
220
  bundleOwner,
181
221
  fee,
182
222
  amount,
@@ -184,52 +224,4 @@ contract Pool is BaseComponent, IPoolComponent {
184
224
  filter
185
225
  );
186
226
  }
187
-
188
- // from pool component
189
- function getPoolFee()
190
- external
191
- view
192
- override
193
- returns (Fee memory poolFee)
194
- {
195
- NftId productNftId = _instance.getProductNftId(getNftId());
196
- if (_instance.hasTreasuryInfo(productNftId)) {
197
- return _instance.getTreasuryInfo(productNftId).poolFee;
198
- } else {
199
- return _initialPoolFee;
200
- }
201
- }
202
-
203
- function getStakingFee()
204
- external
205
- view
206
- override
207
- returns (Fee memory stakingFee)
208
- {
209
- NftId productNftId = _instance.getProductNftId(getNftId());
210
- if (_instance.hasTreasuryInfo(productNftId)) {
211
- return _instance.getTreasuryInfo(productNftId).stakingFee;
212
- } else {
213
- return _initialStakingFee;
214
- }
215
- }
216
-
217
- function getPerformanceFee()
218
- external
219
- view
220
- override
221
- returns (Fee memory performanceFee)
222
- {
223
- NftId productNftId = _instance.getProductNftId(getNftId());
224
- if (_instance.hasTreasuryInfo(productNftId)) {
225
- return _instance.getTreasuryInfo(productNftId).performanceFee;
226
- } else {
227
- return _initialPerformanceFee;
228
- }
229
- }
230
-
231
- // from registerable
232
- function getType() public pure override returns (ObjectType) {
233
- return POOL();
234
- }
235
227
  }
@@ -1,41 +1,75 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import {IRisk} from "../instance/module/risk/IRisk.sol";
5
- import {ITreasury} from "../instance/module/treasury/ITreasury.sol";
6
- import {IProductService} from "../instance/service/IProductService.sol";
4
+ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
+
6
+ import {IRisk} from "../instance/module/IRisk.sol";
7
+ import {IPolicyService} from "../instance/service/IPolicyService.sol";
7
8
  import {IProductComponent} from "./IProductComponent.sol";
8
- import {NftId} from "../types/NftId.sol";
9
- import {ObjectType, PRODUCT} from "../types/ObjectType.sol";
10
- import {ReferralId} from "../types/ReferralId.sol";
9
+ import {NftId, NftIdLib} from "../types/NftId.sol";
10
+ import {PRODUCT} from "../types/ObjectType.sol";
11
+ import {ReferralId} from "../types/Referral.sol";
11
12
  import {RiskId, RiskIdLib} from "../types/RiskId.sol";
12
13
  import {StateId} from "../types/StateId.sol";
13
14
  import {Timestamp} from "../types/Timestamp.sol";
14
15
  import {Fee} from "../types/Fee.sol";
15
- import {BaseComponent} from "./BaseComponent.sol";
16
+ import {Component} from "./Component.sol";
17
+
18
+ import {TokenHandler} from "../shared/TokenHandler.sol";
19
+
20
+ import {InstanceReader} from "../instance/InstanceReader.sol";
21
+ import {ISetup} from "../instance/module/ISetup.sol";
22
+ import {Pool} from "../components/Pool.sol";
23
+ import {Distribution} from "../components/Distribution.sol";
24
+
25
+ abstract contract Product is Component, IProductComponent {
26
+ using NftIdLib for NftId;
16
27
 
17
- contract Product is BaseComponent, IProductComponent {
18
- IProductService internal _productService;
19
- address internal _pool;
20
- address internal _distribution;
28
+ IPolicyService internal _policyService;
29
+ Pool internal _pool;
30
+ Distribution internal _distribution;
21
31
  Fee internal _initialProductFee;
22
32
  Fee internal _initialProcessingFee;
33
+ TokenHandler internal _tokenHandler;
34
+
35
+ NftId internal _poolNftId;
36
+ NftId internal _distributionNftId;
23
37
 
24
38
  constructor(
25
39
  address registry,
26
40
  NftId instanceNftid,
41
+ string memory name,
27
42
  address token,
43
+ bool isInterceptor,
28
44
  address pool,
29
45
  address distribution,
30
46
  Fee memory productFee,
31
- Fee memory processingFee
32
- ) BaseComponent(registry, instanceNftid, token) {
47
+ Fee memory processingFee,
48
+ address initialOwner,
49
+ bytes memory data
50
+ ) Component (
51
+ registry,
52
+ instanceNftid,
53
+ name,
54
+ token,
55
+ PRODUCT(),
56
+ isInterceptor,
57
+ initialOwner,
58
+ data
59
+ ) {
33
60
  // TODO add validation
34
- _productService = _instance.getProductService();
35
- _pool = pool;
36
- _distribution = distribution;
61
+ _policyService = getInstance().getPolicyService();
62
+ _pool = Pool(pool);
63
+ _distribution = Distribution(distribution);
37
64
  _initialProductFee = productFee;
38
- _initialProcessingFee = processingFee;
65
+ _initialProcessingFee = processingFee;
66
+
67
+ _tokenHandler = new TokenHandler(token);
68
+
69
+ _poolNftId = getRegistry().getNftId(address(_pool));
70
+ _distributionNftId = getRegistry().getNftId(address(_distribution));
71
+
72
+ _registerInterface(type(IProductComponent).interfaceId);
39
73
  }
40
74
 
41
75
 
@@ -44,15 +78,15 @@ contract Product is BaseComponent, IProductComponent {
44
78
  RiskId riskId,
45
79
  uint256 lifetime,
46
80
  bytes memory applicationData,
47
- ReferralId referralId,
48
- NftId bundleNftId
81
+ NftId bundleNftId,
82
+ ReferralId referralId
49
83
  )
50
84
  external
51
85
  view
52
86
  override
53
87
  returns (uint256 premiumAmount)
54
88
  {
55
- (premiumAmount,,,,) = _productService.calculatePremium(
89
+ (premiumAmount,,,,) = _policyService.calculatePremium(
56
90
  riskId,
57
91
  sumInsuredAmount,
58
92
  lifetime,
@@ -86,19 +120,19 @@ contract Product is BaseComponent, IProductComponent {
86
120
  RiskId id,
87
121
  bytes memory data
88
122
  ) internal {
89
- _productService.createRisk(
123
+ getProductService().createRisk(
90
124
  id,
91
125
  data
92
126
  );
93
127
  }
94
128
 
95
- function _setRiskInfo(
129
+ function _updateRisk(
96
130
  RiskId id,
97
- IRisk.RiskInfo memory info
131
+ bytes memory data
98
132
  ) internal {
99
- _productService.setRiskInfo(
133
+ getProductService().updateRisk(
100
134
  id,
101
- info
135
+ data
102
136
  );
103
137
  }
104
138
 
@@ -106,14 +140,14 @@ contract Product is BaseComponent, IProductComponent {
106
140
  RiskId id,
107
141
  StateId state
108
142
  ) internal {
109
- _productService.updateRiskState(
143
+ getProductService().updateRiskState(
110
144
  id,
111
145
  state
112
146
  );
113
147
  }
114
148
 
115
149
  function _getRiskInfo(RiskId id) internal view returns (IRisk.RiskInfo memory info) {
116
- return _instance.getRiskInfo(id);
150
+ return getInstance().getInstanceReader().getRiskInfo(id);
117
151
  }
118
152
 
119
153
  function _createApplication(
@@ -125,7 +159,7 @@ contract Product is BaseComponent, IProductComponent {
125
159
  NftId bundleNftId,
126
160
  ReferralId referralId
127
161
  ) internal returns (NftId nftId) {
128
- nftId = _productService.createApplication(
162
+ nftId = _policyService.createApplication(
129
163
  applicationOwner,
130
164
  riskId,
131
165
  sumInsuredAmount,
@@ -143,7 +177,7 @@ contract Product is BaseComponent, IProductComponent {
143
177
  )
144
178
  internal
145
179
  {
146
- _productService.underwrite(
180
+ _policyService.underwrite(
147
181
  policyNftId,
148
182
  requirePremiumPayment,
149
183
  activateAt);
@@ -155,7 +189,7 @@ contract Product is BaseComponent, IProductComponent {
155
189
  )
156
190
  internal
157
191
  {
158
- _productService.collectPremium(
192
+ _policyService.collectPremium(
159
193
  policyNftId,
160
194
  activateAt);
161
195
  }
@@ -166,17 +200,25 @@ contract Product is BaseComponent, IProductComponent {
166
200
  )
167
201
  internal
168
202
  {
169
- _productService.activate(
203
+ _policyService.activate(
170
204
  policyNftId,
171
205
  activateAt);
172
206
  }
173
207
 
208
+ function _close(
209
+ NftId policyNftId
210
+ )
211
+ internal
212
+ {
213
+ _policyService.close(policyNftId);
214
+ }
215
+
174
216
  function getPoolNftId() external view override returns (NftId poolNftId) {
175
- return _registry.getNftId(_pool);
217
+ return getRegistry().getNftId(address(_pool));
176
218
  }
177
219
 
178
220
  function getDistributionNftId() external view override returns (NftId distributionNftId) {
179
- return _registry.getNftId(_distribution);
221
+ return getRegistry().getNftId(address(_distribution));
180
222
  }
181
223
 
182
224
  // from product component
@@ -188,40 +230,36 @@ contract Product is BaseComponent, IProductComponent {
188
230
  onlyOwner
189
231
  override
190
232
  {
191
- _productService.setFees(productFee, processingFee);
233
+ getProductService().setFees(productFee, processingFee);
192
234
  }
193
235
 
236
+ function getSetupInfo() public view returns (ISetup.ProductSetupInfo memory setupInfo) {
237
+ InstanceReader reader = getInstance().getInstanceReader();
238
+ setupInfo = reader.getProductSetupInfo(getNftId());
194
239
 
195
- function getProductFee()
196
- external
197
- view
198
- override
199
- returns (Fee memory productFee)
200
- {
201
- NftId productNftId = getNftId();
202
- if (_instance.hasTreasuryInfo(productNftId)) {
203
- return _instance.getTreasuryInfo(productNftId).productFee;
204
- } else {
205
- return _initialProductFee;
240
+ // fallback to initial setup info (wallet is always != address(0))
241
+ if(setupInfo.wallet == address(0)) {
242
+ setupInfo = _getInitialSetupInfo();
206
243
  }
207
244
  }
208
245
 
209
- function getProcessingFee()
210
- external
211
- view
212
- override
213
- returns (Fee memory processingFee)
214
- {
215
- NftId productNftId = getNftId();
216
- if (_instance.hasTreasuryInfo(productNftId)) {
217
- return _instance.getTreasuryInfo(productNftId).processingFee;
218
- } else {
219
- return _initialProcessingFee;
220
- }
221
- }
246
+ function _getInitialSetupInfo() internal view returns (ISetup.ProductSetupInfo memory setupInfo) {
247
+ ISetup.DistributionSetupInfo memory distributionSetupInfo = _distribution.getSetupInfo();
248
+ ISetup.PoolSetupInfo memory poolSetupInfo = _pool.getSetupInfo();
222
249
 
223
- // from registerable
224
- function getType() public pure override returns (ObjectType) {
225
- return PRODUCT();
250
+ return ISetup.ProductSetupInfo(
251
+ getToken(),
252
+ _tokenHandler,
253
+ _distributionNftId,
254
+ _poolNftId,
255
+ distributionSetupInfo.distributionFee,
256
+ _initialProductFee,
257
+ _initialProcessingFee,
258
+ poolSetupInfo.poolFee,
259
+ poolSetupInfo.stakingFee,
260
+ poolSetupInfo.performanceFee,
261
+ false,
262
+ getWallet()
263
+ );
226
264
  }
227
265
  }
@@ -0,0 +1,47 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
5
+
6
+
7
+ contract Cloner {
8
+
9
+ Mock1 public mock1;
10
+ Mock2 public mock2;
11
+
12
+ constructor() {
13
+ mock1 = new Mock1();
14
+ mock2 = new Mock2();
15
+ }
16
+
17
+ function createClone(address master)
18
+ external
19
+ returns (address cloned)
20
+ {
21
+ cloned = Clones.clone(master);
22
+ }
23
+ }
24
+
25
+
26
+ contract Mock1 {
27
+ function getValue() external virtual view returns (uint256) {
28
+ return 42;
29
+ }
30
+ }
31
+
32
+ contract Mock2 is Mock1 {
33
+ uint256 internal _value;
34
+
35
+ constructor() {
36
+ _value = 42;
37
+ }
38
+
39
+ function setValue(uint256 value) external virtual {
40
+ _value = value;
41
+ }
42
+
43
+ function getValue() external virtual override view returns (uint256) {
44
+ return _value;
45
+ }
46
+ }
47
+