@etherisc/gif-next 0.0.2-f7b8c9f-518 → 0.0.2-f7eda15-119

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