@etherisc/gif-next 0.0.2-f79a517-071 → 0.0.2-f7a5beb-202

Sign up to get free protection for your applications and to get access to all the features.
Files changed (368) hide show
  1. package/README.md +67 -1
  2. package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
  3. package/artifacts/contracts/components/Component.sol/Component.json +613 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +353 -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} +185 -151
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +527 -9
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +611 -66
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +618 -30
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +492 -212
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +429 -137
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
  33. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  36. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
  37. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  38. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
  39. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  40. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  41. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
  42. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +764 -0
  43. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
  44. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +185 -0
  45. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  46. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1035 -995
  47. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
  48. package/artifacts/contracts/instance/{service/IComponentOwnerService.sol/IComponentOwnerService.json → IInstanceService.sol/IInstanceService.json} +155 -56
  49. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  50. package/artifacts/contracts/instance/Instance.sol/Instance.json +1821 -1096
  51. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +4 -0
  52. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +1034 -0
  53. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +4 -0
  54. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1381 -0
  55. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
  56. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +964 -0
  57. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
  58. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +473 -0
  59. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
  60. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +261 -0
  61. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
  62. package/artifacts/contracts/instance/base/{InstanceBase.sol/InstanceBase.json → ComponentService.sol/ComponentService.json} +134 -75
  63. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  64. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +27 -158
  65. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  66. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  67. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +37 -245
  68. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  69. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
  70. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +4 -0
  71. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +254 -0
  72. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +4 -0
  73. package/artifacts/contracts/instance/module/{bundle/IBundle.sol → IBundle.sol}/IBundle.json +1 -1
  74. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +4 -0
  75. package/artifacts/contracts/instance/module/{distribution/IDistribution.sol → IDistribution.sol}/IDistribution.json +1 -1
  76. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +4 -0
  77. package/artifacts/contracts/instance/module/{policy/IPolicy.sol → IPolicy.sol}/IPolicy.json +1 -1
  78. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +4 -0
  79. package/artifacts/contracts/instance/module/{risk/IRisk.sol → IRisk.sol}/IRisk.json +1 -1
  80. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +4 -0
  81. package/artifacts/contracts/instance/{base/ModuleBase.sol/ModuleBase.json → module/ISetup.sol/ISetup.json} +2 -2
  82. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +4 -0
  83. package/artifacts/contracts/instance/module/{treasury/ITreasury.sol → ITreasury.sol}/ITreasury.json +1 -1
  84. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
  85. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1102 -0
  86. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
  87. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +449 -0
  88. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  89. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +194 -52
  90. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
  91. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +437 -0
  92. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
  93. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +715 -0
  94. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  95. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +13 -18
  96. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
  97. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +766 -0
  98. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  99. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +15 -82
  100. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  101. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +25 -245
  102. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
  103. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +1227 -0
  104. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
  105. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +505 -0
  106. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  107. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +181 -128
  108. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
  109. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +437 -0
  110. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  111. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +174 -386
  112. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
  113. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +437 -0
  114. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  115. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  116. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  117. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +339 -59
  118. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  119. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +220 -111
  120. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  121. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  122. package/artifacts/contracts/registry/Registry.sol/Registry.json +301 -188
  123. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
  124. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
  125. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  126. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +83 -128
  127. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  128. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +53 -85
  129. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
  130. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +547 -0
  131. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
  132. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +394 -0
  133. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  134. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  135. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  136. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  137. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  138. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +0 -5
  139. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
  140. package/artifacts/contracts/{instance/base → shared}/IService.sol/IService.json +14 -19
  141. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  142. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  143. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +19 -6
  144. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  145. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +19 -6
  146. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  147. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +19 -11
  148. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
  149. package/artifacts/contracts/{instance/base/ComponentServiceBase.sol/ComponentServiceBase.json → shared/Service.sol/Service.json} +28 -33
  150. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +4 -0
  151. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +96 -0
  152. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  153. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  154. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  155. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  156. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  157. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +19 -11
  158. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  159. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +14 -14
  160. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  161. package/artifacts/contracts/test/TestService.sol/TestService.json +58 -34
  162. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  163. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  164. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  165. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  166. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +18 -2
  167. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  168. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  169. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
  172. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +104 -0
  173. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  175. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +31 -17
  176. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  177. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  178. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  179. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +26 -3
  180. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +4 -0
  181. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.json +100 -0
  182. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  183. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  184. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +4 -0
  185. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +123 -0
  186. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  187. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  188. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  189. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +134 -8
  190. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  191. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  192. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  193. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +15 -2
  194. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  195. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  196. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  197. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  198. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  199. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +22 -3
  200. package/contracts/components/Component.sol +247 -0
  201. package/contracts/components/Distribution.sol +37 -49
  202. package/contracts/components/IComponent.sol +50 -0
  203. package/contracts/components/IDistributionComponent.sol +6 -5
  204. package/contracts/components/IPoolComponent.sol +42 -29
  205. package/contracts/components/IProductComponent.sol +9 -7
  206. package/contracts/components/Pool.sol +137 -116
  207. package/contracts/components/Product.sol +78 -114
  208. package/contracts/instance/BundleManager.sol +125 -0
  209. package/contracts/instance/Cloneable.sol +46 -0
  210. package/contracts/instance/IInstance.sol +64 -44
  211. package/contracts/instance/IInstanceService.sol +40 -0
  212. package/contracts/instance/Instance.sol +251 -65
  213. package/contracts/instance/InstanceAccessManager.sol +298 -0
  214. package/contracts/instance/InstanceReader.sol +293 -0
  215. package/contracts/instance/InstanceService.sol +362 -0
  216. package/contracts/instance/InstanceServiceManager.sol +54 -0
  217. package/contracts/instance/ObjectManager.sol +84 -0
  218. package/contracts/instance/base/ComponentService.sol +134 -0
  219. package/contracts/instance/base/IKeyValueStore.sol +13 -14
  220. package/contracts/instance/base/ILifecycle.sol +3 -3
  221. package/contracts/instance/base/KeyValueStore.sol +49 -38
  222. package/contracts/instance/base/Lifecycle.sol +1 -1
  223. package/contracts/instance/module/IAccess.sol +48 -0
  224. package/contracts/instance/module/IBundle.sol +20 -0
  225. package/contracts/instance/module/IDistribution.sol +39 -0
  226. package/contracts/instance/module/IPolicy.sol +45 -0
  227. package/contracts/instance/module/IRisk.sol +11 -0
  228. package/contracts/instance/module/ISetup.sol +46 -0
  229. package/contracts/instance/module/ITreasury.sol +23 -0
  230. package/contracts/instance/service/BundleService.sol +293 -0
  231. package/contracts/instance/service/BundleServiceManager.sol +51 -0
  232. package/contracts/instance/service/DistributionService.sol +72 -20
  233. package/contracts/instance/service/DistributionServiceManager.sol +51 -0
  234. package/contracts/instance/service/IBundleService.sol +44 -0
  235. package/contracts/instance/service/IDistributionService.sol +1 -1
  236. package/contracts/instance/service/IPolicyService.sol +94 -0
  237. package/contracts/instance/service/IPoolService.sol +7 -24
  238. package/contracts/instance/service/IProductService.sol +9 -76
  239. package/contracts/instance/service/PolicyService.sol +538 -0
  240. package/contracts/instance/service/PolicyServiceManager.sol +54 -0
  241. package/contracts/instance/service/PoolService.sol +76 -116
  242. package/contracts/instance/service/PoolServiceManager.sol +51 -0
  243. package/contracts/instance/service/ProductService.sol +154 -432
  244. package/contracts/instance/service/ProductServiceManager.sol +54 -0
  245. package/contracts/registry/ChainNft.sol +1 -1
  246. package/contracts/registry/IRegistry.sol +47 -6
  247. package/contracts/registry/IRegistryService.sol +50 -20
  248. package/contracts/registry/Registry.sol +243 -214
  249. package/contracts/registry/RegistryAccessManager.sol +216 -0
  250. package/contracts/registry/RegistryService.sol +84 -263
  251. package/contracts/registry/RegistryServiceManager.sol +20 -22
  252. package/contracts/registry/ReleaseManager.sol +332 -0
  253. package/contracts/registry/TokenRegistry.sol +112 -0
  254. package/contracts/shared/ERC165.sol +6 -2
  255. package/contracts/shared/IRegisterable.sol +1 -3
  256. package/contracts/shared/IService.sol +16 -0
  257. package/contracts/shared/NftOwnable.sol +7 -4
  258. package/contracts/shared/ProxyManager.sol +1 -1
  259. package/contracts/shared/Registerable.sol +11 -14
  260. package/contracts/shared/Service.sol +60 -0
  261. package/contracts/shared/TokenHandler.sol +27 -0
  262. package/contracts/shared/Versionable.sol +2 -2
  263. package/contracts/test/TestRoleId.sol +1 -1
  264. package/contracts/test/TestService.sol +6 -7
  265. package/contracts/types/DistributorType.sol +55 -0
  266. package/contracts/types/Key32.sol +8 -3
  267. package/contracts/types/NftIdSet.sol +26 -24
  268. package/contracts/types/NumberId.sol +52 -0
  269. package/contracts/types/ObjectType.sol +35 -14
  270. package/contracts/types/Referral.sol +85 -0
  271. package/contracts/types/RoleId.sol +60 -15
  272. package/contracts/types/StateId.sol +5 -1
  273. package/contracts/types/Timestamp.sol +7 -3
  274. package/contracts/types/Version.sol +4 -1
  275. package/package.json +1 -1
  276. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
  277. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +0 -301
  278. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
  279. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +0 -254
  280. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +0 -4
  281. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.json +0 -24
  282. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
  283. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
  284. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -113
  285. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +0 -4
  286. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +0 -4
  287. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +0 -4
  288. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +0 -4
  289. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +0 -4
  290. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +0 -297
  291. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +0 -4
  292. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +0 -4
  293. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +0 -297
  294. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +0 -4
  295. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +0 -117
  296. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +0 -4
  297. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.json +0 -10
  298. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +0 -4
  299. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.json +0 -117
  300. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +0 -4
  301. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +0 -10
  302. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +0 -4
  303. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +0 -4
  304. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.json +0 -10
  305. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +0 -4
  306. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +0 -4
  307. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +0 -271
  308. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
  309. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +0 -271
  310. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +0 -4
  311. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.json +0 -10
  312. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +0 -4
  313. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +0 -164
  314. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
  315. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -164
  316. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +0 -4
  317. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +0 -4
  318. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +0 -113
  319. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +0 -4
  320. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +0 -131
  321. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +0 -4
  322. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +0 -4
  323. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +0 -638
  324. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +0 -4
  325. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +0 -76
  326. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +0 -4
  327. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +0 -638
  328. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
  329. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -827
  330. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
  331. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +0 -4
  332. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +0 -557
  333. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +0 -4
  334. package/artifacts/contracts/test/TestPool.sol/TestPool.json +0 -716
  335. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +0 -4
  336. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +0 -744
  337. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +0 -4
  338. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +0 -99
  339. package/contracts/components/BaseComponent.sol +0 -79
  340. package/contracts/components/IBaseComponent.sol +0 -19
  341. package/contracts/instance/IInstanceLinked.sol +0 -8
  342. package/contracts/instance/base/ComponentServiceBase.sol +0 -49
  343. package/contracts/instance/base/IInstanceBase.sol +0 -23
  344. package/contracts/instance/base/IService.sol +0 -15
  345. package/contracts/instance/base/InstanceBase.sol +0 -89
  346. package/contracts/instance/base/ModuleBase.sol +0 -57
  347. package/contracts/instance/base/ServiceBase.sol +0 -44
  348. package/contracts/instance/module/bundle/BundleModule.sol +0 -134
  349. package/contracts/instance/module/bundle/IBundle.sol +0 -53
  350. package/contracts/instance/module/component/ComponentModule.sol +0 -71
  351. package/contracts/instance/module/component/IComponent.sol +0 -28
  352. package/contracts/instance/module/distribution/DistributionModule.sol +0 -17
  353. package/contracts/instance/module/distribution/IDistribution.sol +0 -10
  354. package/contracts/instance/module/policy/IPolicy.sol +0 -63
  355. package/contracts/instance/module/policy/PolicyModule.sol +0 -91
  356. package/contracts/instance/module/pool/IPoolModule.sol +0 -41
  357. package/contracts/instance/module/pool/PoolModule.sol +0 -95
  358. package/contracts/instance/module/risk/IRisk.sol +0 -26
  359. package/contracts/instance/module/risk/RiskModule.sol +0 -62
  360. package/contracts/instance/module/treasury/ITreasury.sol +0 -84
  361. package/contracts/instance/module/treasury/TokenHandler.sol +0 -48
  362. package/contracts/instance/module/treasury/TreasuryModule.sol +0 -131
  363. package/contracts/instance/service/ComponentOwnerService.sol +0 -315
  364. package/contracts/instance/service/IComponentOwnerService.sol +0 -20
  365. package/contracts/test/TestDistribution.sol +0 -22
  366. package/contracts/test/TestPool.sol +0 -27
  367. package/contracts/test/TestProduct.sol +0 -74
  368. package/contracts/types/ReferralId.sol +0 -48
@@ -1,100 +1,99 @@
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
15
  import {IRegistry} from "../registry/IRegistry.sol";
14
- import {IPool} from "../instance/module/pool/IPoolModule.sol";
15
- import {ITreasury} from "../instance/module/treasury/ITreasury.sol";
16
+
17
+ import {ISetup} from "../instance/module/ISetup.sol";
18
+ import {InstanceReader} from "../instance/InstanceReader.sol";
16
19
 
17
20
  import {IRegisterable} from "../shared/IRegisterable.sol";
18
21
  import {Registerable} from "../shared/Registerable.sol";
19
22
 
20
- contract Pool is BaseComponent, IPoolComponent {
23
+ abstract contract Pool is
24
+ Component,
25
+ IPoolComponent
26
+ {
27
+ // keccak256(abi.encode(uint256(keccak256("gif-next.contracts.component.Pool.sol")) - 1)) & ~bytes32(uint256(0xff));
28
+ bytes32 public constant POOL_STORAGE_LOCATION_V1 = 0xecf35607b7e822969ee3625cd815bfc27031f3a93d0be2676e5bde943e2e2300;
21
29
 
22
- bool internal _isVerifying;
23
- UFixed internal _collateralizationLevel;
30
+ struct PoolStorage {
31
+ UFixed _collateralizationLevel;
24
32
 
25
- Fee internal _initialPoolFee;
26
- Fee internal _initialStakingFee;
27
- Fee internal _initialPerformanceFee;
33
+ bool _isExternallyManaged;
34
+ bool _isInterceptingBundleTransfers;
35
+ bool _isVerifyingApplications;
28
36
 
29
- // may be used to interact with instance by derived contracts
30
- IPoolService internal _poolService;
37
+ Fee _initialPoolFee;
38
+ Fee _initialStakingFee;
39
+ Fee _initialPerformanceFee;
31
40
 
32
- // only relevant to protect callback functions for "active" pools
33
- IProductService private _productService;
41
+ TokenHandler _tokenHandler;
34
42
 
35
- modifier onlyPoolService() {
36
- require(
37
- msg.sender == address(_poolService),
38
- "ERROR:POL-001:NOT_POOL_SERVICE");
39
- _;
43
+ // may be used to interact with instance by derived contracts
44
+ IPoolService _poolService;
45
+ IBundleService _bundleService;
40
46
  }
41
47
 
42
- modifier onlyProductService() {
43
- require(
44
- msg.sender == address(_productService),
45
- "ERROR:POL-002:NOT_PRODUCT_SERVICE");
48
+ modifier onlyPoolService() {
49
+ if(msg.sender != address(_getStorage()._poolService)) {
50
+ revert ErrorPoolNotPoolService(msg.sender);
51
+ }
46
52
  _;
47
53
  }
48
54
 
49
- constructor(
55
+
56
+ function _initializePool(
50
57
  address registry,
51
58
  NftId instanceNftId,
59
+ string memory name,
52
60
  // TODO refactor into tokenNftId
53
61
  address token,
54
- bool isInterceptor,
55
- bool verifying,
56
62
  UFixed collateralizationLevel,
63
+ bool isInterceptingNftTransfers,
64
+ bool isExternallyManaging,
65
+ bool isVerifying,
57
66
  Fee memory poolFee,
58
67
  Fee memory stakingFee,
59
68
  Fee memory performanceFee,
60
- address initialOwner
69
+ address initialOwner,
70
+ bytes memory data
61
71
  )
62
- BaseComponent(registry, instanceNftId, token, POOL(), isInterceptor, initialOwner)
72
+ internal
73
+ //onlyInitializing//TODO uncomment when "fully" upgradeable
74
+ virtual
63
75
  {
64
- _isVerifying = verifying;
76
+ _initializeComponent(registry, instanceNftId, name, token, POOL(), isInterceptingNftTransfers, initialOwner, data);
77
+
78
+ PoolStorage storage $ = _getStorage();
79
+
80
+ $._isExternallyManaged = isExternallyManaging;
81
+ $._isVerifyingApplications = isVerifying;
82
+
65
83
  // TODO add validation
66
- _collateralizationLevel = collateralizationLevel;
67
- _initialPoolFee = poolFee;
68
- _initialStakingFee = stakingFee;
69
- _initialPerformanceFee = performanceFee;
84
+ $._collateralizationLevel = collateralizationLevel;
85
+ $._initialPoolFee = poolFee;
86
+ $._initialStakingFee = stakingFee;
87
+ $._initialPerformanceFee = performanceFee;
88
+
89
+ $._tokenHandler = new TokenHandler(token);
70
90
 
71
- _poolService = _instance.getPoolService();
72
- _productService = _instance.getProductService();
91
+ $._poolService = getInstance().getPoolService();
92
+ $._bundleService = getInstance().getBundleService();
73
93
 
74
94
  _registerInterface(type(IPoolComponent).interfaceId);
75
95
  }
76
96
 
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
- );
95
-
96
- // TODO add logging
97
- }
98
97
 
99
98
  /**
100
99
  * @dev see {IPool.underwrite}.
@@ -113,31 +112,41 @@ contract Pool is BaseComponent, IPoolComponent {
113
112
  _underwrite(policyNftId, policyData, bundleFilter, collateralizationAmount);
114
113
  }
115
114
 
116
- /**
117
- * @dev see {IPoolComponent.policyMatchesBundle}.
118
- * Default implementation always returns true
119
- */
115
+
116
+ function isInterceptingBundleTransfers() external view override returns (bool) {
117
+ return isNftInterceptor();
118
+ }
119
+
120
+
121
+ function isExternallyManaged() external view override returns (bool) {
122
+ return _getStorage()._isExternallyManaged;
123
+ }
124
+
125
+
126
+ function getCollateralizationLevel() external view override returns (UFixed collateralizationLevel) {
127
+ return _getStorage()._collateralizationLevel;
128
+ }
129
+
130
+
131
+ function isVerifyingApplications() external view override returns (bool isConfirmingApplication) {
132
+ return _getStorage()._isVerifyingApplications;
133
+ }
134
+
135
+
136
+ /// @dev see {IPoolComponent.policyMatchesBundle}.
137
+ /// Default implementation always returns true
120
138
  function policyMatchesBundle(
121
139
  bytes memory, // policyData
122
140
  bytes memory // bundleFilter
123
141
  )
124
142
  public
125
- view
143
+ pure
126
144
  virtual override
127
145
  returns (bool isMatching)
128
146
  {
129
147
  return true;
130
148
  }
131
149
 
132
-
133
- function isVerifying() external view override returns (bool verifying) {
134
- return _isVerifying;
135
- }
136
-
137
- function getCollateralizationLevel() external view override returns (UFixed collateralizationLevel) {
138
- return _collateralizationLevel;
139
- }
140
-
141
150
  function setFees(
142
151
  Fee memory poolFee,
143
152
  Fee memory stakingFee,
@@ -147,7 +156,7 @@ contract Pool is BaseComponent, IPoolComponent {
147
156
  onlyOwner
148
157
  override
149
158
  {
150
- _poolService.setFees(poolFee, stakingFee, performanceFee);
159
+ _getStorage()._poolService.setFees(poolFee, stakingFee, performanceFee);
151
160
  }
152
161
 
153
162
  function setBundleFee(
@@ -158,52 +167,51 @@ contract Pool is BaseComponent, IPoolComponent {
158
167
  override
159
168
  // TODO add onlyBundleOwner
160
169
  {
161
- _poolService.setBundleFee(bundleNftId, fee);
170
+ _getStorage()._bundleService.setBundleFee(bundleNftId, fee);
162
171
  }
163
- // TODO delete, call instance instead
164
- function getFees()
172
+
173
+ function lockBundle(
174
+ NftId bundleNftId
175
+ )
165
176
  external
166
- view
167
177
  override
168
- returns (Fee memory, Fee memory, Fee memory)
178
+ // TODO add onlyBundleOwner
169
179
  {
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
- //}
180
+ _getStorage()._bundleService.lockBundle(bundleNftId);
177
181
  }
178
182
 
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)
183
+ function unlockBundle(
184
+ NftId bundleNftId
185
+ )
186
+ external
187
+ override
188
+ // TODO add onlyBundleOwner
188
189
  {
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
- )
190
+ _getStorage()._bundleService.unlockBundle(bundleNftId);
191
+ }
192
+
193
+ function getSetupInfo() public view returns (ISetup.PoolSetupInfo memory setupInfo) {
194
+ InstanceReader reader = getInstance().getInstanceReader();
195
+ setupInfo = reader.getPoolSetupInfo(getNftId());
196
+
197
+ // fallback to initial setup info (wallet is always != address(0))
198
+ if(setupInfo.wallet == address(0)) {
199
+ setupInfo = _getInitialSetupInfo();
200
+ }
201
+ }
202
+
203
+ function _getInitialSetupInfo() internal view returns (ISetup.PoolSetupInfo memory) {
204
+ PoolStorage storage $ = _getStorage();
205
+ return ISetup.PoolSetupInfo(
206
+ getProductNftId(),
207
+ $._tokenHandler,
208
+ $._collateralizationLevel,
209
+ $._initialPoolFee,
210
+ $._initialStakingFee,
211
+ $._initialPerformanceFee,
212
+ isNftInterceptor(),
213
+ $._isVerifyingApplications,
214
+ getWallet()
207
215
  );
208
216
  }
209
217
 
@@ -230,17 +238,30 @@ contract Pool is BaseComponent, IPoolComponent {
230
238
  Fee memory fee,
231
239
  uint256 amount,
232
240
  uint256 lifetime,
233
- bytes calldata filter
241
+ bytes memory filter
234
242
  )
235
243
  internal
236
244
  returns(NftId bundleNftId)
237
245
  {
238
- bundleNftId = _poolService.createBundle(
246
+ bundleNftId = _getStorage()._bundleService.createBundle(
239
247
  bundleOwner,
240
248
  fee,
241
249
  amount,
242
250
  lifetime,
243
- filter
244
- );
251
+ filter);
252
+
253
+ // TODO add logging
254
+ }
255
+
256
+ function getContractLocation(bytes memory name) external pure returns (bytes32 hash) {
257
+ return keccak256(abi.encode(uint256(keccak256(name)) - 1)) & ~bytes32(uint256(0xff));
245
258
  }
259
+
260
+
261
+ function _getStorage() private pure returns (PoolStorage storage $) {
262
+ assembly {
263
+ $.slot := POOL_STORAGE_LOCATION_V1
264
+ }
265
+ }
266
+
246
267
  }
@@ -3,56 +3,69 @@ pragma solidity ^0.8.19;
3
3
 
4
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
18
  import {IRegistry} from "../registry/IRegistry.sol";
20
19
  import {IRegisterable} from "../shared/IRegisterable.sol";
21
20
  import {Registerable} from "../shared/Registerable.sol";
21
+ import {TokenHandler} from "../shared/TokenHandler.sol";
22
22
 
23
- import {IPool} from "../instance/module/pool/IPoolModule.sol";
23
+ import {InstanceReader} from "../instance/InstanceReader.sol";
24
+ import {ISetup} from "../instance/module/ISetup.sol";
24
25
  import {Pool} from "../components/Pool.sol";
26
+ import {Distribution} from "../components/Distribution.sol";
25
27
 
26
- contract Product is BaseComponent, IProductComponent {
27
- IProductService internal _productService;
28
+ abstract contract Product is
29
+ Component,
30
+ IProductComponent
31
+ {
32
+ IPolicyService internal _policyService;
28
33
  Pool internal _pool;
29
- address internal _distribution;
34
+ Distribution internal _distribution;
30
35
  Fee internal _initialProductFee;
31
36
  Fee internal _initialProcessingFee;
37
+ TokenHandler internal _tokenHandler;
32
38
 
33
39
  NftId internal _poolNftId;
34
40
  NftId internal _distributionNftId;
35
41
 
36
42
  constructor(
37
43
  address registry,
38
- NftId instanceNftid,
44
+ NftId instanceNftId,
45
+ string memory name,
39
46
  address token,
40
47
  bool isInterceptor,
41
48
  address pool,
42
49
  address distribution,
43
50
  Fee memory productFee,
44
51
  Fee memory processingFee,
45
- address initialOwner
46
- ) BaseComponent(registry, instanceNftid, token, PRODUCT(), isInterceptor, initialOwner) {
52
+ address initialOwner,
53
+ bytes memory data
54
+ )
55
+ {
56
+ _initializeComponent(registry, instanceNftId, name, token, PRODUCT(), isInterceptor, initialOwner, data);
57
+
47
58
  // TODO add validation
48
- _productService = _instance.getProductService();
59
+ _policyService = getInstance().getPolicyService();
49
60
  _pool = Pool(pool);
50
- _distribution = distribution;
61
+ _distribution = Distribution(distribution);
51
62
  _initialProductFee = productFee;
52
63
  _initialProcessingFee = processingFee;
53
64
 
65
+ _tokenHandler = new TokenHandler(token);
66
+
54
67
  _poolNftId = getRegistry().getNftId(address(_pool));
55
- _distributionNftId = getRegistry().getNftId(_distribution);
68
+ _distributionNftId = getRegistry().getNftId(address(_distribution));
56
69
 
57
70
  _registerInterface(type(IProductComponent).interfaceId);
58
71
  }
@@ -63,15 +76,15 @@ contract Product is BaseComponent, IProductComponent {
63
76
  RiskId riskId,
64
77
  uint256 lifetime,
65
78
  bytes memory applicationData,
66
- ReferralId referralId,
67
- NftId bundleNftId
79
+ NftId bundleNftId,
80
+ ReferralId referralId
68
81
  )
69
82
  external
70
83
  view
71
84
  override
72
85
  returns (uint256 premiumAmount)
73
86
  {
74
- (premiumAmount,,,,) = _productService.calculatePremium(
87
+ (premiumAmount,,,,) = _policyService.calculatePremium(
75
88
  riskId,
76
89
  sumInsuredAmount,
77
90
  lifetime,
@@ -105,19 +118,19 @@ contract Product is BaseComponent, IProductComponent {
105
118
  RiskId id,
106
119
  bytes memory data
107
120
  ) internal {
108
- _productService.createRisk(
121
+ getProductService().createRisk(
109
122
  id,
110
123
  data
111
124
  );
112
125
  }
113
126
 
114
- function _setRiskInfo(
127
+ function _updateRisk(
115
128
  RiskId id,
116
- IRisk.RiskInfo memory info
129
+ bytes memory data
117
130
  ) internal {
118
- _productService.setRiskInfo(
131
+ getProductService().updateRisk(
119
132
  id,
120
- info
133
+ data
121
134
  );
122
135
  }
123
136
 
@@ -125,14 +138,14 @@ contract Product is BaseComponent, IProductComponent {
125
138
  RiskId id,
126
139
  StateId state
127
140
  ) internal {
128
- _productService.updateRiskState(
141
+ getProductService().updateRiskState(
129
142
  id,
130
143
  state
131
144
  );
132
145
  }
133
146
 
134
147
  function _getRiskInfo(RiskId id) internal view returns (IRisk.RiskInfo memory info) {
135
- return _instance.getRiskInfo(id);
148
+ return getInstance().getInstanceReader().getRiskInfo(id);
136
149
  }
137
150
 
138
151
  function _createApplication(
@@ -144,7 +157,7 @@ contract Product is BaseComponent, IProductComponent {
144
157
  NftId bundleNftId,
145
158
  ReferralId referralId
146
159
  ) internal returns (NftId nftId) {
147
- nftId = _productService.createApplication(
160
+ nftId = _policyService.createApplication(
148
161
  applicationOwner,
149
162
  riskId,
150
163
  sumInsuredAmount,
@@ -162,7 +175,7 @@ contract Product is BaseComponent, IProductComponent {
162
175
  )
163
176
  internal
164
177
  {
165
- _productService.underwrite(
178
+ _policyService.underwrite(
166
179
  policyNftId,
167
180
  requirePremiumPayment,
168
181
  activateAt);
@@ -174,7 +187,7 @@ contract Product is BaseComponent, IProductComponent {
174
187
  )
175
188
  internal
176
189
  {
177
- _productService.collectPremium(
190
+ _policyService.collectPremium(
178
191
  policyNftId,
179
192
  activateAt);
180
193
  }
@@ -185,17 +198,25 @@ contract Product is BaseComponent, IProductComponent {
185
198
  )
186
199
  internal
187
200
  {
188
- _productService.activate(
201
+ _policyService.activate(
189
202
  policyNftId,
190
203
  activateAt);
191
204
  }
192
205
 
206
+ function _close(
207
+ NftId policyNftId
208
+ )
209
+ internal
210
+ {
211
+ _policyService.close(policyNftId);
212
+ }
213
+
193
214
  function getPoolNftId() external view override returns (NftId poolNftId) {
194
215
  return getRegistry().getNftId(address(_pool));
195
216
  }
196
217
 
197
218
  function getDistributionNftId() external view override returns (NftId distributionNftId) {
198
- return getRegistry().getNftId(_distribution);
219
+ return getRegistry().getNftId(address(_distribution));
199
220
  }
200
221
 
201
222
  // from product component
@@ -207,93 +228,36 @@ contract Product is BaseComponent, IProductComponent {
207
228
  onlyOwner
208
229
  override
209
230
  {
210
- _productService.setFees(productFee, processingFee);
231
+ getProductService().setFees(productFee, processingFee);
211
232
  }
212
233
 
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
- }
234
+ function getSetupInfo() public view returns (ISetup.ProductSetupInfo memory setupInfo) {
235
+ InstanceReader reader = getInstance().getInstanceReader();
236
+ setupInfo = reader.getProductSetupInfo(getNftId());
227
237
 
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;
238
+ // fallback to initial setup info (wallet is always != address(0))
239
+ if(setupInfo.wallet == address(0)) {
240
+ setupInfo = _getInitialSetupInfo();
239
241
  }
240
242
  }
241
243
 
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
- )
244
+ function _getInitialSetupInfo() internal view returns (ISetup.ProductSetupInfo memory setupInfo) {
245
+ ISetup.DistributionSetupInfo memory distributionSetupInfo = _distribution.getSetupInfo();
246
+ ISetup.PoolSetupInfo memory poolSetupInfo = _pool.getSetupInfo();
247
+
248
+ return ISetup.ProductSetupInfo(
249
+ getToken(),
250
+ _tokenHandler,
251
+ _distributionNftId,
252
+ _poolNftId,
253
+ distributionSetupInfo.distributionFee,
254
+ _initialProductFee,
255
+ _initialProcessingFee,
256
+ poolSetupInfo.poolFee,
257
+ poolSetupInfo.stakingFee,
258
+ poolSetupInfo.performanceFee,
259
+ false,
260
+ getWallet()
297
261
  );
298
262
  }
299
263
  }