@etherisc/gif-next 0.0.2-e42b0ca-323 → 0.0.2-e46206a-486

Sign up to get free protection for your applications and to get access to all the features.
Files changed (314) hide show
  1. package/README.md +175 -1
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +166 -39
  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 +1 -1
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +119 -39
  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 +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +108 -156
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +67 -139
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +417 -88
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +360 -51
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +4 -0
  19. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +66 -0
  20. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +4 -0
  21. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +24 -0
  22. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +4 -0
  23. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +42 -0
  24. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
  36. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  37. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  38. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  39. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
  40. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  41. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
  42. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  43. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  44. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  45. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +768 -694
  46. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +1 -1
  47. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  48. package/artifacts/contracts/instance/Instance.sol/Instance.json +974 -816
  49. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  50. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +224 -43
  51. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  52. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +51 -1
  53. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  54. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +49 -0
  55. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  56. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +1 -1
  57. package/artifacts/contracts/instance/base/IService.sol/IService.json +174 -53
  58. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +1 -1
  59. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +263 -45
  60. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  61. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +49 -23
  62. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  63. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +4 -4
  64. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +1 -1
  65. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +1 -1
  66. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.json +220 -52
  67. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +55 -54
  69. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +56 -55
  72. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +22 -93
  74. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +1 -1
  75. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +1 -1
  76. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.json +22 -93
  77. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +4 -0
  78. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +10 -0
  79. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +4 -0
  80. package/artifacts/contracts/instance/module/{compensation/ICompensation.sol/ICompensation.json → distribution/IDistribution.sol/IDistribution.json} +2 -2
  81. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +4 -0
  82. package/artifacts/contracts/instance/module/{compensation/ICompensation.sol/ICompensationModule.json → distribution/IDistribution.sol/IDistributionModule.json} +2 -2
  83. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
  84. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
  85. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +61 -51
  86. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
  87. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +61 -51
  88. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +1 -1
  89. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
  90. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +29 -14
  91. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
  92. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +28 -13
  93. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +1 -1
  94. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +1 -1
  95. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +104 -1
  96. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +1 -1
  97. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +126 -5
  98. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +1 -1
  99. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +1 -1
  100. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +326 -221
  101. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  102. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +2 -2
  103. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +1 -1
  104. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +326 -221
  105. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  106. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +391 -71
  107. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
  108. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +646 -0
  109. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  110. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +177 -75
  111. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
  112. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +446 -0
  113. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  114. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +235 -50
  115. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  116. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +325 -51
  117. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  118. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +350 -52
  119. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  120. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +476 -73
  121. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  122. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +186 -12
  123. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  124. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +190 -51
  125. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
  126. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +872 -0
  127. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
  128. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +34 -0
  129. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  130. package/artifacts/contracts/registry/Registry.sol/Registry.json +380 -139
  131. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
  132. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +1261 -0
  133. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
  134. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +504 -0
  135. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +4 -0
  136. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.json +107 -0
  137. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  138. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  139. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
  140. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +127 -0
  141. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  142. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +117 -37
  143. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  144. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +55 -14
  145. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +4 -0
  146. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +158 -0
  147. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
  148. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +349 -0
  149. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  150. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +190 -37
  151. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
  152. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +129 -0
  153. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  154. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +78 -14
  155. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +4 -0
  156. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +557 -0
  157. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  158. package/artifacts/contracts/test/TestFee.sol/TestFee.json +4 -4
  159. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +1 -1
  160. package/artifacts/contracts/test/TestPool.sol/TestPool.json +417 -88
  161. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +1 -1
  162. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +407 -56
  163. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  164. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +204 -36
  165. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  166. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +14 -14
  167. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  168. package/artifacts/contracts/test/TestService.sol/TestService.json +283 -62
  169. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  170. package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +91 -53
  171. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  172. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  173. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  174. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +103 -23
  175. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  176. package/artifacts/contracts/test/Usdc.sol/USDC.json +91 -53
  177. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  178. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  179. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  180. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
  181. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +104 -0
  182. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  183. package/artifacts/contracts/types/Fee.sol/FeeLib.json +52 -13
  184. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  185. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +31 -17
  186. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  187. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  188. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  189. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  190. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +4 -0
  191. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.json +100 -0
  192. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  193. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  194. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +4 -0
  195. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +123 -0
  196. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
  197. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
  198. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  199. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +134 -8
  200. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  201. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  202. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  203. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +15 -2
  204. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
  205. package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
  206. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
  207. package/artifacts/contracts/types/UFixed.sol/{UFixedMathLib.json → UFixedLib.json} +3 -3
  208. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  209. package/artifacts/contracts/types/Version.sol/VersionLib.json +40 -2
  210. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  211. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
  212. package/contracts/components/BaseComponent.sol +11 -20
  213. package/contracts/components/Distribution.sol +155 -0
  214. package/contracts/components/IBaseComponent.sol +1 -1
  215. package/contracts/components/IDistributionComponent.sol +46 -0
  216. package/contracts/components/IPoolComponent.sol +15 -8
  217. package/contracts/components/IProductComponent.sol +26 -8
  218. package/contracts/components/Pool.sol +99 -27
  219. package/contracts/components/Product.sol +204 -22
  220. package/contracts/experiment/cloning/Cloner.sol +47 -0
  221. package/contracts/instance/IInstance.sol +11 -11
  222. package/contracts/instance/Instance.sol +28 -13
  223. package/contracts/instance/base/ComponentServiceBase.sol +13 -6
  224. package/contracts/instance/base/IInstanceBase.sol +11 -2
  225. package/contracts/instance/base/IKeyValueStore.sol +4 -3
  226. package/contracts/instance/base/InstanceBase.sol +19 -10
  227. package/contracts/instance/base/KeyValueStore.sol +15 -9
  228. package/contracts/instance/base/Lifecycle.sol +15 -10
  229. package/contracts/instance/base/ModuleBase.sol +23 -18
  230. package/contracts/instance/base/ServiceBase.sol +20 -13
  231. package/contracts/instance/module/bundle/BundleModule.sol +12 -14
  232. package/contracts/instance/module/bundle/IBundle.sol +6 -11
  233. package/contracts/instance/module/component/ComponentModule.sol +33 -57
  234. package/contracts/instance/module/component/IComponent.sol +6 -31
  235. package/contracts/instance/module/distribution/DistributionModule.sol +17 -0
  236. package/contracts/instance/module/distribution/IDistribution.sol +10 -0
  237. package/contracts/instance/module/policy/IPolicy.sol +13 -10
  238. package/contracts/instance/module/policy/PolicyModule.sol +36 -21
  239. package/contracts/instance/module/pool/IPoolModule.sol +4 -4
  240. package/contracts/instance/module/pool/PoolModule.sol +23 -15
  241. package/contracts/instance/module/risk/IRisk.sol +18 -2
  242. package/contracts/instance/module/risk/RiskModule.sol +56 -2
  243. package/contracts/instance/module/treasury/ITreasury.sol +31 -50
  244. package/contracts/instance/module/treasury/TokenHandler.sol +1 -1
  245. package/contracts/instance/module/treasury/TreasuryModule.sol +70 -91
  246. package/contracts/instance/service/ComponentOwnerService.sol +238 -93
  247. package/contracts/instance/service/DistributionService.sol +54 -0
  248. package/contracts/instance/service/IComponentOwnerService.sol +0 -2
  249. package/contracts/instance/service/IDistributionService.sol +12 -0
  250. package/contracts/instance/service/IPoolService.sol +7 -0
  251. package/contracts/instance/service/IProductService.sol +56 -7
  252. package/contracts/instance/service/PoolService.sol +49 -23
  253. package/contracts/instance/service/ProductService.sol +250 -94
  254. package/contracts/registry/ChainNft.sol +80 -37
  255. package/contracts/registry/IRegistry.sol +28 -28
  256. package/contracts/registry/IRegistryService.sol +35 -0
  257. package/contracts/registry/ITransferInterceptor.sol +6 -0
  258. package/contracts/registry/Registry.sol +314 -272
  259. package/contracts/registry/RegistryService.sol +441 -0
  260. package/contracts/registry/RegistryServiceManager.sol +64 -0
  261. package/contracts/shared/ContractDeployerLib.sol +72 -0
  262. package/contracts/shared/INftOwnable.sol +22 -0
  263. package/contracts/shared/IRegisterable.sol +8 -15
  264. package/contracts/shared/IVersionable.sol +55 -11
  265. package/contracts/shared/NftOwnable.sol +136 -0
  266. package/contracts/shared/ProxyManager.sol +94 -0
  267. package/contracts/shared/Registerable.sol +62 -59
  268. package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
  269. package/contracts/shared/Versionable.sol +113 -55
  270. package/contracts/test/TestDistribution.sol +22 -0
  271. package/contracts/test/TestFee.sol +2 -2
  272. package/contracts/test/TestPool.sol +7 -2
  273. package/contracts/test/TestProduct.sol +38 -8
  274. package/contracts/test/TestRegisterable.sol +5 -6
  275. package/contracts/test/TestRoleId.sol +1 -1
  276. package/contracts/test/TestService.sol +5 -11
  277. package/contracts/types/DistributorType.sol +55 -0
  278. package/contracts/types/Fee.sol +10 -5
  279. package/contracts/types/Key32.sol +8 -3
  280. package/contracts/types/NumberId.sol +52 -0
  281. package/contracts/types/ObjectType.sol +51 -14
  282. package/contracts/types/Referral.sol +85 -0
  283. package/contracts/types/RiskId.sol +43 -0
  284. package/contracts/types/RoleId.sol +54 -10
  285. package/contracts/types/StateId.sol +1 -1
  286. package/contracts/types/Timestamp.sol +7 -3
  287. package/contracts/types/UFixed.sol +128 -12
  288. package/contracts/types/Version.sol +9 -0
  289. package/package.json +4 -3
  290. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +0 -4
  291. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.json +0 -333
  292. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +0 -4
  293. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.json +0 -10
  294. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +0 -4
  295. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.json +0 -333
  296. package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.dbg.json +0 -4
  297. package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.json +0 -10
  298. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensation.dbg.json +0 -4
  299. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensationModule.dbg.json +0 -4
  300. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
  301. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +0 -452
  302. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +0 -4
  303. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.json +0 -24
  304. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +0 -4
  305. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.json +0 -24
  306. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
  307. package/contracts/experiment/statemachine/README.md +0 -112
  308. package/contracts/instance/module/access/Access.sol +0 -149
  309. package/contracts/instance/module/access/IAccess.sol +0 -53
  310. package/contracts/instance/module/compensation/CompensationModule.sol +0 -8
  311. package/contracts/instance/module/compensation/ICompensation.sol +0 -10
  312. package/contracts/registry/IChainNft.sol +0 -21
  313. package/contracts/registry/IRegistryLinked.sol +0 -8
  314. package/contracts/shared/IOwnable.sol +0 -6
@@ -1,7 +1,11 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.19;
2
+ pragma solidity ^0.8.20;
3
3
 
4
4
  import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
+ import {IDistributionComponent} from "../../../components/IDistributionComponent.sol";
6
+ import {IPoolComponent} from "../../../components/IPoolComponent.sol";
7
+ import {IProductComponent} from "../../../components/IProductComponent.sol";
8
+ import {IComponentOwnerService} from "../../service/IComponentOwnerService.sol";
5
9
 
6
10
  import {NftId} from "../../../types/NftId.sol";
7
11
  import {UFixed} from "../../../types/UFixed.sol";
@@ -13,73 +17,48 @@ interface ITreasury {
13
17
  // TODO add events
14
18
  // TODO add errors
15
19
 
16
- struct ProductSetup {
17
- NftId productNftId;
18
- NftId distributorNftId;
20
+ // treasury info is linked to product nft id
21
+ struct TreasuryInfo {
19
22
  NftId poolNftId;
23
+ NftId distributionNftId;
20
24
  IERC20Metadata token;
21
- address wallet;
22
- Fee policyFee;
23
- Fee processingFee;
24
- }
25
-
26
- struct DistributorSetup {
27
- NftId distributorNftId;
28
- address wallet;
29
- Fee commissionFee;
30
- }
31
-
32
- struct PoolSetup {
33
- NftId poolNftId;
34
- address wallet;
35
- Fee stakingFee;
36
- Fee performanceFee;
25
+ Fee productFee; // product fee on net premium
26
+ Fee processingFee; // product fee on payout amounts
27
+ Fee poolFee; // pool fee on net premium
28
+ Fee stakingFee; // pool fee on staked capital from investor
29
+ Fee performanceFee; // pool fee on profits from capital investors
30
+ Fee distributionFee; // default distribution fee (no referral id)
37
31
  }
38
32
  }
39
33
 
40
34
  interface ITreasuryModule is ITreasury {
41
35
 
42
- function registerProduct(
36
+ function registerProductSetup(
43
37
  NftId productNftId,
44
- NftId distributorNftId,
45
- NftId poolNftId,
46
- IERC20Metadata token,
47
- address wallet,
48
- Fee memory policyFee,
49
- Fee memory processingFee
38
+ TreasuryInfo memory info
50
39
  ) external;
51
40
 
52
- function setProductFees(
41
+ function setTreasuryInfo(
53
42
  NftId productNftId,
54
- Fee memory policyFee,
55
- Fee memory processingFee
43
+ TreasuryInfo memory info
56
44
  ) external;
57
45
 
58
- function registerPool(
59
- NftId poolNftId,
60
- address wallet,
61
- Fee memory stakingFee,
62
- Fee memory performanceFee
63
- ) external;
46
+ function hasTreasuryInfo(
47
+ NftId productNftId
48
+ ) external view returns (bool hasInfo);
64
49
 
65
- function setPoolFees(
66
- NftId poolNftId,
67
- Fee memory stakingFee,
68
- Fee memory performanceFee
69
- ) external;
50
+ function getTreasuryInfo(
51
+ NftId productNftId
52
+ ) external view returns (TreasuryInfo memory info);
53
+
54
+ function getProductNftId(
55
+ NftId componentNftId
56
+ ) external view returns (NftId productNftId);
70
57
 
71
58
  function getTokenHandler(
72
59
  NftId componentNftId
73
60
  ) external view returns (TokenHandler tokenHandler);
74
61
 
75
- function getProductSetup(
76
- NftId productNftId
77
- ) external view returns (ProductSetup memory setup);
78
-
79
- function getPoolSetup(
80
- NftId poolNftId
81
- ) external view returns (PoolSetup memory setup);
82
-
83
62
  function calculateFeeAmount(
84
63
  uint256 amount,
85
64
  Fee memory fee
@@ -90,7 +69,7 @@ interface ITreasuryModule is ITreasury {
90
69
  uint256 fixedFee
91
70
  ) external pure returns (Fee memory fee);
92
71
 
93
- function getZeroFee() external pure returns (Fee memory fee);
72
+ function getZeroFee() external view returns (Fee memory fee);
94
73
 
95
74
  function getUFixed(
96
75
  uint256 a
@@ -100,4 +79,6 @@ interface ITreasuryModule is ITreasury {
100
79
  uint256 a,
101
80
  int8 exp
102
81
  ) external pure returns (UFixed);
82
+
83
+ function getComponentOwnerService() external view returns(IComponentOwnerService);
103
84
  }
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.19;
2
+ pragma solidity ^0.8.20;
3
3
 
4
4
  import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
5
 
@@ -1,103 +1,82 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.19;
2
+ pragma solidity ^0.8.20;
3
3
 
4
4
  import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
+ import {IDistributionComponent} from "../../../components/IDistributionComponent.sol";
6
+ import {IPoolComponent} from "../../../components/IPoolComponent.sol";
7
+ import {IProductComponent} from "../../../components/IProductComponent.sol";
5
8
 
6
9
  import {NftId} from "../../../types/NftId.sol";
10
+ import {TREASURY} from "../../../types/ObjectType.sol";
7
11
  import {Fee, FeeLib} from "../../../types/Fee.sol";
8
- import {UFixed, UFixedMathLib} from "../../../types/UFixed.sol";
12
+ import {UFixed, UFixedLib} from "../../../types/UFixed.sol";
9
13
  import {TokenHandler} from "./TokenHandler.sol";
14
+ import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
10
15
  import {ITreasuryModule} from "./ITreasury.sol";
11
-
12
- abstract contract TreasuryModule is ITreasuryModule {
13
- mapping(NftId productNftId => ProductSetup setup) private _productSetup;
14
- mapping(NftId distributorNftId => DistributorSetup setup)
15
- private _distributorSetup;
16
- mapping(NftId poolNftId => PoolSetup setup) private _poolSetup;
17
- mapping(NftId componentNftId => TokenHandler tokenHanlder) _tokenHandler;
18
-
19
- function registerProduct(
20
- NftId productNftId,
21
- NftId distributorNftId,
22
- NftId poolNftId,
23
- IERC20Metadata token,
24
- address wallet,
25
- Fee memory policyFee,
26
- Fee memory processingFee
27
- ) external override // TODO add authz (only component module)
28
- {
29
- require(address(_tokenHandler[productNftId]) == address(0), "ERROR:TRS-010:TOKEN_HANDLER_ALREADY_REGISTERED");
30
- require(address(_tokenHandler[poolNftId]) == address(0), "ERROR:TRS-011:TOKEN_HANDLER_ALREADY_REGISTERED");
31
- require(address(_tokenHandler[distributorNftId]) == address(0), "ERROR:TRS-012:TOKEN_HANDLER_ALREADY_REGISTERED");
32
- // TODO add additional validations
33
-
34
- // deploy product specific handler contract
35
- TokenHandler tokenHandler = new TokenHandler(productNftId, address(token));
36
- _tokenHandler[productNftId] = tokenHandler;
37
- _tokenHandler[poolNftId] = tokenHandler;
38
- _tokenHandler[distributorNftId] = tokenHandler;
39
-
40
- // create product setup
41
- _productSetup[productNftId] = ProductSetup(
42
- productNftId,
43
- distributorNftId,
44
- poolNftId,
45
- token,
46
- wallet,
47
- policyFee,
48
- processingFee
16
+ import {ModuleBase} from "../../base/ModuleBase.sol";
17
+
18
+ abstract contract TreasuryModule is
19
+ ModuleBase,
20
+ ITreasuryModule
21
+ {
22
+ // relation of distributor and pool nft map to product nft
23
+ mapping(NftId componentNftId => NftId productNftId) internal _productNft;
24
+ // relation of component nft to token hanlder
25
+ mapping(NftId componentNftId => TokenHandler tokenHandler) internal _tokenHandler;
26
+ Fee internal _zeroFee;
27
+
28
+ modifier onlyComponentOwnerService() virtual {
29
+ require(
30
+ msg.sender == address(this.getComponentOwnerService()),
31
+ "ERROR:CMP-001:NOT_COPONENT_OWNER_SERVICE"
49
32
  );
33
+ _;
34
+ }
50
35
 
51
- // TODO add logging
36
+ function _initializeTreasuryModule(IKeyValueStore keyValueStore) internal {
37
+ //_initializeModuleBase(keyValueStore);
38
+ _initialize(keyValueStore);
39
+ _zeroFee = FeeLib.zeroFee();
52
40
  }
53
41
 
54
- function setProductFees(
42
+ function registerProductSetup(
55
43
  NftId productNftId,
56
- Fee memory policyFee,
57
- Fee memory processingFee
58
- ) external override // TODO add authz (only component owner service)
44
+ TreasuryInfo memory setup
45
+ )
46
+ external
47
+ onlyComponentOwnerService
59
48
  {
60
- // TODO add validation
61
-
62
- ProductSetup storage setup = _productSetup[productNftId];
63
- setup.policyFee = policyFee;
64
- setup.processingFee = processingFee;
65
-
66
- // TODO add logging
67
- }
49
+ NftId poolNftId = setup.poolNftId;
50
+ NftId distributionNftId = setup.distributionNftId;
68
51
 
69
- function registerPool(
70
- NftId poolNftId,
71
- address wallet,
72
- Fee memory stakingFee,
73
- Fee memory performanceFee
74
- ) external override // TODO add authz (only component module)
75
- {
76
- // TODO add validation
52
+ require(address(_tokenHandler[productNftId]) == address(0), "ERROR:TRS-012:TOKEN_HANDLER_ALREADY_REGISTERED");
53
+ require(_productNft[poolNftId].eqz(), "ERROR:TRS-013:POOL_ALREADY_LINKED");
54
+ require(_productNft[distributionNftId].eqz(), "ERROR:TRS-014:COMPENSATION_ALREADY_LINKED");
77
55
 
78
- _poolSetup[poolNftId] = PoolSetup(
79
- poolNftId,
80
- wallet,
81
- stakingFee,
82
- performanceFee
83
- );
56
+ // TODO deploy TokenHandler with separate contract to save space
57
+ // deploy product specific handler contract
58
+ _tokenHandler[productNftId] = new TokenHandler(productNftId, address(setup.token));
59
+ _productNft[distributionNftId] = productNftId;
60
+ _productNft[poolNftId] = productNftId;
84
61
 
85
- // TODO add logging
62
+ _create(TREASURY(), productNftId, abi.encode(setup));
86
63
  }
87
64
 
88
- function setPoolFees(
89
- NftId poolNftId,
90
- Fee memory stakingFee,
91
- Fee memory performanceFee
92
- ) external override // TODO add authz (only component owner service)
65
+ function setTreasuryInfo(
66
+ NftId productNftId,
67
+ TreasuryInfo memory info
68
+ )
69
+ external
70
+ // TODO add authz (only component module)
71
+ override
93
72
  {
94
- // TODO add validation
95
-
96
- PoolSetup storage setup = _poolSetup[poolNftId];
97
- setup.stakingFee = stakingFee;
98
- setup.performanceFee = performanceFee;
73
+ _updateData(TREASURY(), productNftId, abi.encode(info));
74
+ }
99
75
 
100
- // TODO add logging
76
+ function getProductNftId(
77
+ NftId componentNftId
78
+ ) external view returns (NftId productNftId) {
79
+ return _productNft[componentNftId];
101
80
  }
102
81
 
103
82
  function getTokenHandler(
@@ -106,23 +85,23 @@ abstract contract TreasuryModule is ITreasuryModule {
106
85
  return _tokenHandler[componentNftId];
107
86
  }
108
87
 
109
- function getProductSetup(
88
+ function hasTreasuryInfo(
110
89
  NftId productNftId
111
- ) external view override returns (ProductSetup memory setup) {
112
- return _productSetup[productNftId];
90
+ ) public view override returns (bool hasInfo) {
91
+ return _exists(TREASURY(), productNftId);
113
92
  }
114
93
 
115
- function getPoolSetup(
116
- NftId poolNftId
117
- ) external view override returns (PoolSetup memory setup) {
118
- return _poolSetup[poolNftId];
94
+ function getTreasuryInfo(
95
+ NftId productNftId
96
+ ) public view override returns (TreasuryInfo memory info) {
97
+ return abi.decode(_getData(TREASURY(), productNftId), (TreasuryInfo));
119
98
  }
120
99
 
121
100
  function calculateFeeAmount(
122
101
  uint256 amount,
123
102
  Fee memory fee
124
103
  ) public pure override returns (uint256 feeAmount, uint256 netAmount) {
125
- return FeeLib.calculateFee(amount, fee);
104
+ return FeeLib.calculateFee(fee, amount);
126
105
  }
127
106
 
128
107
  function getFee(
@@ -132,14 +111,14 @@ abstract contract TreasuryModule is ITreasuryModule {
132
111
  return FeeLib.toFee(fractionalFee, fixedFee);
133
112
  }
134
113
 
135
- function getZeroFee() external pure override returns (Fee memory fee) {
136
- return FeeLib.zeroFee();
114
+ function getZeroFee() external view override returns (Fee memory fee) {
115
+ return _zeroFee;
137
116
  }
138
117
 
139
118
  function getUFixed(
140
119
  uint256 a
141
120
  ) external pure override returns (UFixed) {
142
- return UFixedMathLib.toUFixed(a);
121
+ return UFixedLib.toUFixed(a);
143
122
  }
144
123
 
145
124
  function getUFixed(
@@ -147,6 +126,6 @@ abstract contract TreasuryModule is ITreasuryModule {
147
126
  int8 exp
148
127
  ) external pure returns (UFixed)
149
128
  {
150
- return UFixedMathLib.toUFixed(a, exp);
129
+ return UFixedLib.toUFixed(a, exp);
151
130
  }
152
131
  }