@etherisc/gif-next 0.0.2-35bac6a → 0.0.2-37c4e96-676

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (405) hide show
  1. package/README.md +297 -7
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +4 -0
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +301 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +557 -0
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +4 -0
  7. package/artifacts/contracts/{instance/component/IComponent.sol/IComponentModule.json → components/IBaseComponent.sol/IBaseComponent.json} +124 -115
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +177 -0
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +308 -0
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +4 -0
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +207 -0
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +543 -40
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +433 -50
  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/Require.sol/Require.json +2 -2
  26. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +2 -2
  28. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/inheritance/A.sol/A.json +2 -2
  30. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +2 -2
  32. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  36. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  37. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  38. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +4 -0
  39. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +59 -0
  40. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +4 -0
  41. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +124 -0
  42. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +4 -0
  43. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +74 -0
  44. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +4 -0
  45. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +124 -0
  46. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +4 -0
  47. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +207 -0
  48. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  49. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +2 -2
  50. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  51. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +2 -2
  52. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  53. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1373 -325
  54. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +4 -0
  55. package/artifacts/contracts/instance/{component/IComponent.sol → IInstanceLinked.sol}/IInstanceLinked.json +1 -1
  56. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  57. package/artifacts/contracts/instance/Instance.sol/Instance.json +1679 -392
  58. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
  59. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +481 -0
  60. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  61. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +113 -0
  62. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
  63. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +560 -0
  64. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +4 -0
  65. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.json +115 -0
  66. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +4 -0
  67. package/artifacts/contracts/instance/base/IService.sol/IService.json +421 -0
  68. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +4 -0
  69. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +544 -0
  70. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
  71. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +718 -0
  72. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +4 -0
  73. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +169 -0
  74. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +4 -0
  75. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.json +10 -0
  76. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +4 -0
  77. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.json +468 -0
  78. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +4 -0
  79. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +297 -0
  80. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +4 -0
  81. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.json +10 -0
  82. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +4 -0
  83. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +297 -0
  84. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +4 -0
  85. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +117 -0
  86. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +4 -0
  87. package/artifacts/contracts/instance/{component → module/component}/IComponent.sol/IComponent.json +1 -1
  88. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +4 -0
  89. package/artifacts/contracts/instance/{product/IProductService.sol/IProductService.json → module/component/IComponent.sol/IComponentModule.json} +56 -53
  90. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +4 -0
  91. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +10 -0
  92. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +4 -0
  93. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.json +10 -0
  94. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +4 -0
  95. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.json +10 -0
  96. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +4 -0
  97. package/artifacts/contracts/instance/{policy → module/policy}/IPolicy.sol/IPolicy.json +1 -1
  98. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +4 -0
  99. package/artifacts/contracts/instance/{policy → module/policy}/IPolicy.sol/IPolicyModule.json +148 -108
  100. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +4 -0
  101. package/artifacts/contracts/instance/{policy → module/policy}/PolicyModule.sol/PolicyModule.json +148 -108
  102. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +4 -0
  103. package/artifacts/contracts/instance/{pool → module/pool}/IPoolModule.sol/IPool.json +1 -1
  104. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +4 -0
  105. package/artifacts/contracts/instance/{pool → module/pool}/IPoolModule.sol/IPoolModule.json +74 -59
  106. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +4 -0
  107. package/artifacts/contracts/instance/{pool → module/pool}/PoolModule.sol/PoolModule.json +64 -62
  108. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +4 -0
  109. package/artifacts/contracts/instance/{access/IAccess.sol/IAccess.json → module/risk/IRisk.sol/IRisk.json} +2 -2
  110. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +4 -0
  111. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +113 -0
  112. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +4 -0
  113. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +131 -0
  114. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +4 -0
  115. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.json +10 -0
  116. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +4 -0
  117. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +638 -0
  118. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +4 -0
  119. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +76 -0
  120. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +4 -0
  121. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +638 -0
  122. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +4 -0
  123. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +843 -0
  124. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
  125. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +646 -0
  126. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +4 -0
  127. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +466 -0
  128. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
  129. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +446 -0
  130. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +4 -0
  131. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +561 -0
  132. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +4 -0
  133. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +751 -0
  134. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
  135. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +769 -0
  136. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
  137. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +1076 -0
  138. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  139. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +239 -2
  140. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  141. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +249 -84
  142. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
  143. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +872 -0
  144. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
  145. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +34 -0
  146. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  147. package/artifacts/contracts/registry/Registry.sol/Registry.json +451 -85
  148. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
  149. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +1261 -0
  150. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
  151. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +504 -0
  152. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +4 -0
  153. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.json +107 -0
  154. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +4 -0
  155. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +35 -0
  156. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
  157. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +127 -0
  158. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +4 -0
  159. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +201 -0
  160. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +4 -0
  161. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +205 -0
  162. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +4 -0
  163. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +158 -0
  164. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
  165. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +349 -0
  166. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +4 -0
  167. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +274 -0
  168. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
  169. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +129 -0
  170. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +4 -0
  171. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +228 -0
  172. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +4 -0
  173. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +557 -0
  174. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +4 -0
  175. package/artifacts/contracts/test/TestFee.sol/TestFee.json +119 -0
  176. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +4 -0
  177. package/artifacts/contracts/test/TestPool.sol/TestPool.json +716 -0
  178. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +4 -0
  179. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +744 -0
  180. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +4 -0
  181. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +305 -0
  182. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +4 -0
  183. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +116 -0
  184. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +4 -0
  185. package/artifacts/contracts/test/TestService.sol/TestService.json +600 -0
  186. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +4 -0
  187. package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +376 -0
  188. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +4 -0
  189. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +218 -0
  190. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +4 -0
  191. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +286 -0
  192. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +4 -0
  193. package/artifacts/contracts/test/Usdc.sol/USDC.json +376 -0
  194. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +4 -0
  195. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.json +10 -0
  196. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  197. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
  198. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  199. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +2 -2
  200. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
  201. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +104 -0
  202. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +4 -0
  203. package/artifacts/contracts/types/Fee.sol/FeeLib.json +257 -0
  204. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +4 -0
  205. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +125 -0
  206. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  207. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +65 -4
  208. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +4 -0
  209. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +10 -0
  210. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +4 -0
  211. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.json +100 -0
  212. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +4 -0
  213. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +92 -0
  214. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +4 -0
  215. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +123 -0
  216. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
  217. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
  218. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +4 -0
  219. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +156 -0
  220. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +4 -0
  221. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +92 -0
  222. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  223. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +77 -2
  224. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
  225. package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
  226. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
  227. package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +479 -0
  228. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +4 -0
  229. package/artifacts/contracts/types/Version.sol/VersionLib.json +177 -0
  230. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +4 -0
  231. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +30 -0
  232. package/contracts/components/BaseComponent.sol +79 -0
  233. package/contracts/components/Distribution.sol +155 -0
  234. package/contracts/components/IBaseComponent.sol +19 -0
  235. package/contracts/components/IDistributionComponent.sol +46 -0
  236. package/contracts/components/IPoolComponent.sol +64 -0
  237. package/contracts/components/IProductComponent.sol +37 -0
  238. package/contracts/components/Pool.sol +235 -18
  239. package/contracts/components/Product.sol +268 -35
  240. package/contracts/experiment/cloning/Cloner.sol +47 -0
  241. package/contracts/experiment/errors/Require.sol +10 -5
  242. package/contracts/experiment/errors/Revert.sol +13 -8
  243. package/contracts/experiment/inheritance/A.sol +8 -11
  244. package/contracts/experiment/inheritance/B.sol +10 -5
  245. package/contracts/experiment/inheritance/C.sol +11 -5
  246. package/contracts/experiment/inheritance/IA.sol +2 -7
  247. package/contracts/experiment/inheritance/IB.sol +3 -2
  248. package/contracts/experiment/inheritance/IC.sol +4 -3
  249. package/contracts/experiment/statemachine/Dummy.sol +27 -0
  250. package/contracts/experiment/statemachine/ISM.sol +25 -0
  251. package/contracts/experiment/statemachine/SM.sol +57 -0
  252. package/contracts/experiment/statemachine/SimpleStateMachine.sol +31 -0
  253. package/contracts/experiment/types/TypeA.sol +14 -9
  254. package/contracts/experiment/types/TypeB.sol +14 -9
  255. package/contracts/instance/IInstance.sol +41 -9
  256. package/contracts/instance/IInstanceLinked.sol +8 -0
  257. package/contracts/instance/Instance.sol +62 -43
  258. package/contracts/instance/base/ComponentServiceBase.sol +49 -0
  259. package/contracts/instance/base/IInstanceBase.sol +23 -0
  260. package/contracts/instance/base/IKeyValueStore.sol +50 -0
  261. package/contracts/instance/base/ILifecycle.sol +30 -0
  262. package/contracts/instance/base/IService.sol +15 -0
  263. package/contracts/instance/base/InstanceBase.sol +89 -0
  264. package/contracts/instance/base/KeyValueStore.sol +162 -0
  265. package/contracts/instance/base/Lifecycle.sol +100 -0
  266. package/contracts/instance/base/ModuleBase.sol +57 -0
  267. package/contracts/instance/base/ServiceBase.sol +44 -0
  268. package/contracts/instance/module/bundle/BundleModule.sol +134 -0
  269. package/contracts/instance/module/bundle/IBundle.sol +53 -0
  270. package/contracts/instance/module/component/ComponentModule.sol +71 -0
  271. package/contracts/instance/module/component/IComponent.sol +28 -0
  272. package/contracts/instance/module/distribution/DistributionModule.sol +17 -0
  273. package/contracts/instance/module/distribution/IDistribution.sol +10 -0
  274. package/contracts/instance/module/policy/IPolicy.sol +63 -0
  275. package/contracts/instance/module/policy/PolicyModule.sol +91 -0
  276. package/contracts/instance/module/pool/IPoolModule.sol +41 -0
  277. package/contracts/instance/module/pool/PoolModule.sol +95 -0
  278. package/contracts/instance/module/risk/IRisk.sol +26 -0
  279. package/contracts/instance/module/risk/RiskModule.sol +62 -0
  280. package/contracts/instance/module/treasury/ITreasury.sol +84 -0
  281. package/contracts/instance/module/treasury/TokenHandler.sol +48 -0
  282. package/contracts/instance/module/treasury/TreasuryModule.sol +131 -0
  283. package/contracts/instance/service/ComponentOwnerService.sol +315 -0
  284. package/contracts/instance/service/DistributionService.sol +54 -0
  285. package/contracts/instance/service/IComponentOwnerService.sol +20 -0
  286. package/contracts/instance/service/IDistributionService.sol +12 -0
  287. package/contracts/instance/service/IPoolService.sol +37 -0
  288. package/contracts/instance/service/IProductService.sol +107 -0
  289. package/contracts/instance/service/PoolService.sol +149 -0
  290. package/contracts/instance/service/ProductService.sol +510 -0
  291. package/contracts/registry/ChainNft.sol +138 -109
  292. package/contracts/registry/IRegistry.sol +43 -56
  293. package/contracts/registry/IRegistryService.sol +35 -0
  294. package/contracts/registry/ITransferInterceptor.sol +6 -0
  295. package/contracts/registry/Registry.sol +363 -122
  296. package/contracts/registry/RegistryService.sol +441 -0
  297. package/contracts/registry/RegistryServiceManager.sol +64 -0
  298. package/contracts/shared/ContractDeployerLib.sol +72 -0
  299. package/contracts/shared/ERC165.sol +21 -0
  300. package/contracts/shared/INftOwnable.sol +22 -0
  301. package/contracts/shared/IRegisterable.sol +17 -0
  302. package/contracts/shared/IVersionable.sol +96 -0
  303. package/contracts/shared/NftOwnable.sol +136 -0
  304. package/contracts/shared/ProxyManager.sol +94 -0
  305. package/contracts/shared/Registerable.sol +89 -0
  306. package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
  307. package/contracts/shared/Versionable.sol +147 -0
  308. package/contracts/test/TestDistribution.sol +22 -0
  309. package/contracts/test/TestFee.sol +25 -0
  310. package/contracts/test/TestPool.sol +27 -0
  311. package/contracts/test/TestProduct.sol +74 -0
  312. package/contracts/test/TestRegisterable.sol +18 -0
  313. package/contracts/test/TestRoleId.sol +14 -0
  314. package/contracts/test/TestService.sol +26 -0
  315. package/contracts/test/TestToken.sol +26 -0
  316. package/contracts/test/TestVersion.sol +44 -0
  317. package/contracts/test/TestVersionable.sol +17 -0
  318. package/contracts/test/Usdc.sol +26 -0
  319. package/contracts/types/AddressSet.sol +58 -0
  320. package/contracts/types/Blocknumber.sol +76 -18
  321. package/contracts/types/ChainId.sol +18 -10
  322. package/contracts/types/DistributorType.sol +55 -0
  323. package/contracts/types/Fee.sol +56 -0
  324. package/contracts/types/Key32.sol +50 -0
  325. package/contracts/types/NftId.sol +48 -11
  326. package/contracts/types/NftIdSet.sol +60 -0
  327. package/contracts/types/NumberId.sol +52 -0
  328. package/contracts/types/ObjectType.sol +152 -0
  329. package/contracts/types/Referral.sol +85 -0
  330. package/contracts/types/RiskId.sol +43 -0
  331. package/contracts/types/RoleId.sol +82 -0
  332. package/contracts/types/StateId.sol +101 -0
  333. package/contracts/types/Timestamp.sol +89 -17
  334. package/contracts/types/UFixed.sol +189 -75
  335. package/contracts/types/Version.sol +104 -0
  336. package/package.json +21 -6
  337. package/artifacts/contracts/components/Component.sol/Component.dbg.json +0 -4
  338. package/artifacts/contracts/components/Component.sol/Component.json +0 -179
  339. package/artifacts/contracts/components/Component.sol/InstanceLinked.dbg.json +0 -4
  340. package/artifacts/contracts/components/Component.sol/InstanceLinked.json +0 -35
  341. package/artifacts/contracts/components/IPool.sol/IPoolComponent.dbg.json +0 -4
  342. package/artifacts/contracts/components/IPool.sol/IPoolComponent.json +0 -179
  343. package/artifacts/contracts/components/IProduct.sol/IProductComponent.dbg.json +0 -4
  344. package/artifacts/contracts/components/IProduct.sol/IProductComponent.json +0 -192
  345. package/artifacts/contracts/instance/access/Access.sol/AccessModule.dbg.json +0 -4
  346. package/artifacts/contracts/instance/access/Access.sol/AccessModule.json +0 -400
  347. package/artifacts/contracts/instance/access/IAccess.sol/IAccess.dbg.json +0 -4
  348. package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.dbg.json +0 -4
  349. package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.json +0 -35
  350. package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.dbg.json +0 -4
  351. package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.json +0 -50
  352. package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.dbg.json +0 -4
  353. package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.json +0 -336
  354. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.dbg.json +0 -4
  355. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.json +0 -327
  356. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.dbg.json +0 -4
  357. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.json +0 -147
  358. package/artifacts/contracts/instance/component/IComponent.sol/IComponent.dbg.json +0 -4
  359. package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.dbg.json +0 -4
  360. package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.json +0 -179
  361. package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.dbg.json +0 -4
  362. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.dbg.json +0 -4
  363. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.json +0 -94
  364. package/artifacts/contracts/instance/component/IComponent.sol/IInstanceLinked.dbg.json +0 -4
  365. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicy.dbg.json +0 -4
  366. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.dbg.json +0 -4
  367. package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
  368. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPool.dbg.json +0 -4
  369. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.dbg.json +0 -4
  370. package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
  371. package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.dbg.json +0 -4
  372. package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.json +0 -75
  373. package/artifacts/contracts/instance/product/IProductService.sol/IProductService.dbg.json +0 -4
  374. package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.dbg.json +0 -4
  375. package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.json +0 -75
  376. package/artifacts/contracts/instance/product/ProductService.sol/ProductService.dbg.json +0 -4
  377. package/artifacts/contracts/instance/product/ProductService.sol/ProductService.json +0 -167
  378. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
  379. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +0 -452
  380. package/artifacts/contracts/registry/IRegistry.sol/IOwnable.dbg.json +0 -4
  381. package/artifacts/contracts/registry/IRegistry.sol/IOwnable.json +0 -24
  382. package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.dbg.json +0 -4
  383. package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.json +0 -166
  384. package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.dbg.json +0 -4
  385. package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.json +0 -49
  386. package/artifacts/contracts/registry/Registry.sol/Registerable.dbg.json +0 -4
  387. package/artifacts/contracts/registry/Registry.sol/Registerable.json +0 -166
  388. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.dbg.json +0 -4
  389. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.json +0 -60
  390. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
  391. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +0 -453
  392. package/contracts/components/Component.sol +0 -62
  393. package/contracts/components/IPool.sol +0 -9
  394. package/contracts/components/IProduct.sol +0 -12
  395. package/contracts/instance/access/Access.sol +0 -218
  396. package/contracts/instance/access/IAccess.sol +0 -83
  397. package/contracts/instance/component/ComponentModule.sol +0 -248
  398. package/contracts/instance/component/IComponent.sol +0 -95
  399. package/contracts/instance/policy/IPolicy.sol +0 -66
  400. package/contracts/instance/policy/PolicyModule.sol +0 -107
  401. package/contracts/instance/pool/IPoolModule.sol +0 -41
  402. package/contracts/instance/pool/PoolModule.sol +0 -86
  403. package/contracts/instance/product/IProductService.sol +0 -46
  404. package/contracts/instance/product/ProductService.sol +0 -108
  405. package/contracts/registry/IChainNft.sol +0 -18
@@ -1,29 +1,246 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.19;
2
+ pragma solidity ^0.8.20;
3
3
 
4
- import {IPoolComponent} from "./IPool.sol";
5
- import {Component} from "./Component.sol";
4
+ import {ObjectType, POOL} from "../types/ObjectType.sol";
5
+ import {IProductService} from "../instance/service/IProductService.sol";
6
+ import {IPoolService} from "../instance/service/IPoolService.sol";
7
+ import {NftId} from "../types/NftId.sol";
8
+ import {Fee} from "../types/Fee.sol";
9
+ import {UFixed} from "../types/UFixed.sol";
10
+ import {IPoolComponent} from "./IPoolComponent.sol";
11
+ import {BaseComponent} from "./BaseComponent.sol";
6
12
 
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";
7
16
 
8
- contract Pool is
9
- Component,
10
- IPoolComponent
11
- {
17
+ import {IRegisterable} from "../shared/IRegisterable.sol";
18
+ import {Registerable} from "../shared/Registerable.sol";
19
+
20
+ contract Pool is BaseComponent, IPoolComponent {
21
+
22
+ bool internal _isVerifying;
23
+ UFixed internal _collateralizationLevel;
24
+
25
+ Fee internal _initialPoolFee;
26
+ Fee internal _initialStakingFee;
27
+ Fee internal _initialPerformanceFee;
28
+
29
+ // may be used to interact with instance by derived contracts
30
+ IPoolService internal _poolService;
31
+
32
+ // only relevant to protect callback functions for "active" pools
33
+ IProductService private _productService;
34
+
35
+ modifier onlyPoolService() {
36
+ require(
37
+ msg.sender == address(_poolService),
38
+ "ERROR:POL-001:NOT_POOL_SERVICE");
39
+ _;
40
+ }
41
+
42
+ modifier onlyProductService() {
43
+ require(
44
+ msg.sender == address(_productService),
45
+ "ERROR:POL-002:NOT_PRODUCT_SERVICE");
46
+ _;
47
+ }
12
48
 
13
49
  constructor(
14
- address registry,
15
- address instance
50
+ address registry,
51
+ NftId instanceNftId,
52
+ // TODO refactor into tokenNftId
53
+ address token,
54
+ bool isInterceptor,
55
+ bool verifying,
56
+ UFixed collateralizationLevel,
57
+ Fee memory poolFee,
58
+ Fee memory stakingFee,
59
+ Fee memory performanceFee,
60
+ address initialOwner
61
+ )
62
+ BaseComponent(registry, instanceNftId, token, POOL(), isInterceptor, initialOwner)
63
+ {
64
+ _isVerifying = verifying;
65
+ // TODO add validation
66
+ _collateralizationLevel = collateralizationLevel;
67
+ _initialPoolFee = poolFee;
68
+ _initialStakingFee = stakingFee;
69
+ _initialPerformanceFee = performanceFee;
70
+
71
+ _poolService = _instance.getPoolService();
72
+ _productService = _instance.getProductService();
73
+
74
+ _registerInterface(type(IPoolComponent).interfaceId);
75
+ }
76
+
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
+
99
+ /**
100
+ * @dev see {IPool.underwrite}.
101
+ * Default implementation that only writes a {LogUnderwrittenByPool} entry.
102
+ */
103
+ function underwrite(
104
+ NftId policyNftId,
105
+ bytes memory policyData,
106
+ bytes memory bundleFilter,
107
+ uint256 collateralizationAmount
108
+ )
109
+ external
110
+ onlyProductService
111
+ virtual override
112
+ {
113
+ _underwrite(policyNftId, policyData, bundleFilter, collateralizationAmount);
114
+ }
115
+
116
+ /**
117
+ * @dev see {IPoolComponent.policyMatchesBundle}.
118
+ * Default implementation always returns true
119
+ */
120
+ function policyMatchesBundle(
121
+ bytes memory, // policyData
122
+ bytes memory // bundleFilter
16
123
  )
17
- Component(registry, instance)
18
- { }
124
+ public
125
+ view
126
+ virtual override
127
+ returns (bool isMatching)
128
+ {
129
+ return true;
130
+ }
131
+
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
+ }
19
140
 
20
- // from registerable
21
- function getType() public view override returns(uint256) {
22
- return _registry.POOL();
141
+ function setFees(
142
+ Fee memory poolFee,
143
+ Fee memory stakingFee,
144
+ Fee memory performanceFee
145
+ )
146
+ external
147
+ onlyOwner
148
+ override
149
+ {
150
+ _poolService.setFees(poolFee, stakingFee, performanceFee);
151
+ }
152
+
153
+ function setBundleFee(
154
+ NftId bundleNftId,
155
+ Fee memory fee
156
+ )
157
+ external
158
+ override
159
+ // TODO add onlyBundleOwner
160
+ {
161
+ _poolService.setBundleFee(bundleNftId, fee);
162
+ }
163
+ // TODO delete, call instance instead
164
+ function getFees()
165
+ external
166
+ view
167
+ override
168
+ returns (Fee memory, Fee memory, Fee memory)
169
+ {
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
+ //}
23
177
  }
24
178
 
25
- // from registerable
26
- function getData() external view override returns(bytes memory data) {
27
- return bytes(abi.encode(getInstance().getNftId()));
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)
188
+ {
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
+ )
207
+ );
208
+ }
209
+
210
+ // Internals
211
+
212
+ function _underwrite(
213
+ NftId policyNftId,
214
+ bytes memory policyData,
215
+ bytes memory bundleFilter,
216
+ uint256 collateralizationAmount
217
+ )
218
+ internal
219
+ {
220
+ require(
221
+ policyMatchesBundle(policyData, bundleFilter),
222
+ "ERROR:POL-020:POLICY_BUNDLE_MISMATCH"
223
+ );
224
+
225
+ emit LogUnderwrittenByPool(policyNftId, collateralizationAmount, address(this));
226
+ }
227
+
228
+ function _createBundle(
229
+ address bundleOwner,
230
+ Fee memory fee,
231
+ uint256 amount,
232
+ uint256 lifetime,
233
+ bytes calldata filter
234
+ )
235
+ internal
236
+ returns(NftId bundleNftId)
237
+ {
238
+ bundleNftId = _poolService.createBundle(
239
+ bundleOwner,
240
+ fee,
241
+ amount,
242
+ lifetime,
243
+ filter
244
+ );
28
245
  }
29
- }
246
+ }
@@ -1,66 +1,299 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import {IProductService} from "../instance/product/IProductService.sol";
5
- import {Component} from "./Component.sol";
6
- import {IProductComponent} from "./IProduct.sol";
7
- import {NftId} from "../types/NftId.sol";
4
+ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
8
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";
9
+ 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/Referral.sol";
13
+ import {RiskId, RiskIdLib} from "../types/RiskId.sol";
14
+ import {StateId} from "../types/StateId.sol";
15
+ import {Timestamp} from "../types/Timestamp.sol";
16
+ import {Fee, FeeLib} from "../types/Fee.sol";
17
+ import {BaseComponent} from "./BaseComponent.sol";
9
18
 
10
- contract Product is
11
- Component,
12
- IProductComponent
13
- {
14
- IProductService private _productService;
15
- address private _pool;
19
+ import {IRegistry} from "../registry/IRegistry.sol";
20
+ import {IRegisterable} from "../shared/IRegisterable.sol";
21
+ import {Registerable} from "../shared/Registerable.sol";
22
+
23
+ import {IPool} from "../instance/module/pool/IPoolModule.sol";
24
+ import {Pool} from "../components/Pool.sol";
25
+
26
+ contract Product is BaseComponent, IProductComponent {
27
+ IProductService internal _productService;
28
+ Pool internal _pool;
29
+ address internal _distribution;
30
+ Fee internal _initialProductFee;
31
+ Fee internal _initialProcessingFee;
32
+
33
+ NftId internal _poolNftId;
34
+ NftId internal _distributionNftId;
16
35
 
17
36
  constructor(
18
- address registry,
19
- address instance,
20
- address pool
21
- )
22
- Component(registry, instance)
23
- {
37
+ address registry,
38
+ NftId instanceNftid,
39
+ address token,
40
+ bool isInterceptor,
41
+ address pool,
42
+ address distribution,
43
+ Fee memory productFee,
44
+ Fee memory processingFee,
45
+ address initialOwner
46
+ ) BaseComponent(registry, instanceNftid, token, PRODUCT(), isInterceptor, initialOwner) {
47
+ // TODO add validation
24
48
  _productService = _instance.getProductService();
25
- _pool = pool;
49
+ _pool = Pool(pool);
50
+ _distribution = distribution;
51
+ _initialProductFee = productFee;
52
+ _initialProcessingFee = processingFee;
53
+
54
+ _poolNftId = getRegistry().getNftId(address(_pool));
55
+ _distributionNftId = getRegistry().getNftId(_distribution);
56
+
57
+ _registerInterface(type(IProductComponent).interfaceId);
26
58
  }
27
59
 
28
- function _createApplication(
29
- address applicationOwner,
60
+
61
+ function calculatePremium(
30
62
  uint256 sumInsuredAmount,
31
- uint256 premiumAmount,
63
+ RiskId riskId,
32
64
  uint256 lifetime,
65
+ bytes memory applicationData,
66
+ ReferralId referralId,
33
67
  NftId bundleNftId
34
68
  )
35
- internal
36
- returns(NftId nftId)
69
+ external
70
+ view
71
+ override
72
+ returns (uint256 premiumAmount)
37
73
  {
74
+ (premiumAmount,,,,) = _productService.calculatePremium(
75
+ riskId,
76
+ sumInsuredAmount,
77
+ lifetime,
78
+ applicationData,
79
+ bundleNftId,
80
+ referralId
81
+ );
82
+ }
83
+
84
+
85
+ function calculateNetPremium(
86
+ uint256 sumInsuredAmount,
87
+ RiskId riskId,
88
+ uint256 lifetime,
89
+ bytes memory applicationData
90
+ )
91
+ external
92
+ view
93
+ virtual override
94
+ returns (uint256 netPremiumAmount)
95
+ {
96
+ // default 10% of sum insured
97
+ return sumInsuredAmount / 10;
98
+ }
99
+
100
+ function _toRiskId(string memory riskName) internal pure returns (RiskId riskId) {
101
+ return RiskIdLib.toRiskId(riskName);
102
+ }
103
+
104
+ function _createRisk(
105
+ RiskId id,
106
+ bytes memory data
107
+ ) internal {
108
+ _productService.createRisk(
109
+ id,
110
+ data
111
+ );
112
+ }
113
+
114
+ function _setRiskInfo(
115
+ RiskId id,
116
+ IRisk.RiskInfo memory info
117
+ ) internal {
118
+ _productService.setRiskInfo(
119
+ id,
120
+ info
121
+ );
122
+ }
123
+
124
+ function _updateRiskState(
125
+ RiskId id,
126
+ StateId state
127
+ ) internal {
128
+ _productService.updateRiskState(
129
+ id,
130
+ state
131
+ );
132
+ }
133
+
134
+ function _getRiskInfo(RiskId id) internal view returns (IRisk.RiskInfo memory info) {
135
+ return _instance.getRiskInfo(id);
136
+ }
137
+
138
+ function _createApplication(
139
+ address applicationOwner,
140
+ RiskId riskId,
141
+ uint256 sumInsuredAmount,
142
+ uint256 lifetime,
143
+ bytes memory applicationData,
144
+ NftId bundleNftId,
145
+ ReferralId referralId
146
+ ) internal returns (NftId nftId) {
38
147
  nftId = _productService.createApplication(
39
148
  applicationOwner,
149
+ riskId,
40
150
  sumInsuredAmount,
41
- premiumAmount,
42
151
  lifetime,
43
- bundleNftId
152
+ applicationData,
153
+ bundleNftId,
154
+ referralId
44
155
  );
45
156
  }
46
157
 
47
- function _underwrite(NftId nftId)
158
+ function _underwrite(
159
+ NftId policyNftId,
160
+ bool requirePremiumPayment,
161
+ Timestamp activateAt
162
+ )
163
+ internal
164
+ {
165
+ _productService.underwrite(
166
+ policyNftId,
167
+ requirePremiumPayment,
168
+ activateAt);
169
+ }
170
+
171
+ function _collectPremium(
172
+ NftId policyNftId,
173
+ Timestamp activateAt
174
+ )
175
+ internal
176
+ {
177
+ _productService.collectPremium(
178
+ policyNftId,
179
+ activateAt);
180
+ }
181
+
182
+ function _activate(
183
+ NftId policyNftId,
184
+ Timestamp activateAt
185
+ )
48
186
  internal
49
187
  {
50
- _productService.underwrite(nftId);
188
+ _productService.activate(
189
+ policyNftId,
190
+ activateAt);
51
191
  }
52
192
 
53
- function getPoolNftId() external view override returns(NftId poolNftId) {
54
- return _registry.getNftId(_pool);
193
+ function getPoolNftId() external view override returns (NftId poolNftId) {
194
+ return getRegistry().getNftId(address(_pool));
55
195
  }
56
196
 
57
- // from registerable
58
- function getType() public view override returns(uint256) {
59
- return _registry.PRODUCT();
197
+ function getDistributionNftId() external view override returns (NftId distributionNftId) {
198
+ return getRegistry().getNftId(_distribution);
60
199
  }
61
200
 
62
- // from registerable
63
- function getData() external view override returns(bytes memory data) {
64
- return bytes(abi.encode(getInstance().getNftId()));
201
+ // from product component
202
+ function setFees(
203
+ Fee memory productFee,
204
+ Fee memory processingFee
205
+ )
206
+ external
207
+ onlyOwner
208
+ override
209
+ {
210
+ _productService.setFees(productFee, processingFee);
211
+ }
212
+
213
+ // TODO delete, call instance intead
214
+ function getProductFee()
215
+ external
216
+ view
217
+ override
218
+ returns (Fee memory productFee)
219
+ {
220
+ NftId productNftId = getNftId();
221
+ if (_instance.hasTreasuryInfo(productNftId)) {
222
+ return _instance.getTreasuryInfo(productNftId).productFee;
223
+ } else {
224
+ return _initialProductFee;
225
+ }
226
+ }
227
+
228
+ function getProcessingFee()
229
+ external
230
+ view
231
+ override
232
+ returns (Fee memory processingFee)
233
+ {
234
+ NftId productNftId = getNftId();
235
+ if (_instance.hasTreasuryInfo(productNftId)) {
236
+ return _instance.getTreasuryInfo(productNftId).processingFee;
237
+ } else {
238
+ return _initialProcessingFee;
239
+ }
240
+ }
241
+
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
+ )
297
+ );
65
298
  }
66
- }
299
+ }
@@ -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
+
@@ -2,7 +2,6 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  contract Require {
5
-
6
5
  error AsmallerThanB_S();
7
6
  error AsmallerThanB_M(uint a);
8
7
  error AsmallerThanB_L(uint a, uint b);
@@ -13,21 +12,27 @@ contract Require {
13
12
  _b = 42;
14
13
  }
15
14
 
16
- function isAlargerThanBRequire_S(uint a) external view returns(bool isLarger) {
15
+ function isAlargerThanBRequire_S(
16
+ uint a
17
+ ) external view returns (bool isLarger) {
17
18
  require(a > _b, "ERROR:ABC-001");
18
19
 
19
20
  return true;
20
21
  }
21
22
 
22
- function isAlargerThanBRequire_M(uint a) external view returns(bool isLarger) {
23
+ function isAlargerThanBRequire_M(
24
+ uint a
25
+ ) external view returns (bool isLarger) {
23
26
  require(a > _b, "ERROR:ABC-002:A_IS_SMALLER");
24
27
 
25
28
  return true;
26
29
  }
27
30
 
28
- function isAlargerThanBRequire_L(uint a) external view returns(bool isLarger) {
31
+ function isAlargerThanBRequire_L(
32
+ uint a
33
+ ) external view returns (bool isLarger) {
29
34
  require(a > _b, "ERROR:ABC-003:A_IS_SMALLER_THAN_B");
30
35
 
31
36
  return true;
32
37
  }
33
- }
38
+ }