@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
@@ -0,0 +1,247 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
5
+ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
6
+
7
+ import {IComponent} from "./IComponent.sol";
8
+ import {IProductService} from "../instance/service/IProductService.sol";
9
+ import {IInstanceService} from "../instance/IInstanceService.sol";
10
+ import {IInstance} from "../instance/IInstance.sol";
11
+ import {InstanceAccessManager} from "../instance/InstanceAccessManager.sol";
12
+ import {IRegistry} from "../registry/IRegistry.sol";
13
+ import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
14
+ import {ObjectType, INSTANCE, PRODUCT} from "../types/ObjectType.sol";
15
+ import {VersionPart} from "../types/Version.sol";
16
+ import {Registerable} from "../shared/Registerable.sol";
17
+ import {RoleId, RoleIdLib} from "../types/RoleId.sol";
18
+ import {IAccess} from "../instance/module/IAccess.sol";
19
+
20
+ // TODO discuss to inherit from oz accessmanaged
21
+ // TODO make contract upgradeable
22
+ // then add (Distribution|Pool|Product)Upradeable that also intherit from Versionable
23
+ // same pattern as for Service which is also upgradeable
24
+ abstract contract Component is
25
+ Registerable,
26
+ IComponent
27
+ {
28
+ // keccak256(abi.encode(uint256(keccak256("gif-next.contracts.component.Component.sol")) - 1)) & ~bytes32(uint256(0xff));
29
+ bytes32 public constant CONTRACT_LOCATION_V1 = 0xffe8d4462baed26a47154f4b8f6db497d2f772496965791d25bd456e342b7f00;
30
+
31
+ struct ComponentStorage {
32
+ IInstance _instance; // instance for this component
33
+
34
+ string _name; // unique (per instance) component name
35
+ IERC20Metadata _token; // token for this component
36
+ address _wallet; // wallet for this component (default = component contract itself)
37
+ bool _isNftInterceptor; // declares if component is involved in nft transfers
38
+ IInstanceService _instanceService; // instance service for this component
39
+
40
+ NftId _productNftId; // only relevant for components that are linked to a aproduct
41
+ IProductService _productService; // product service for component, might not be relevant for some component types (eg oracles)
42
+ }
43
+
44
+
45
+ modifier onlyChainNft() {
46
+ if(msg.sender != address(getRegistry().getChainNft())) {
47
+ revert ErrorComponentNotChainNft(msg.sender);
48
+ }
49
+ _;
50
+ }
51
+
52
+
53
+ modifier onlyProductService() {
54
+ if(msg.sender != address(_getComponentStorage()._productService)) {
55
+ revert ErrorComponentNotProductService(msg.sender);
56
+ }
57
+ _;
58
+ }
59
+
60
+ // TODO discuss replacement with modifier restricted from accessmanaged
61
+ modifier onlyInstanceRole(uint64 roleIdNum) {
62
+ RoleId roleId = RoleIdLib.toRoleId(roleIdNum);
63
+ InstanceAccessManager accessManager = InstanceAccessManager(_getComponentStorage()._instance.authority());
64
+ if( !accessManager.hasRole(roleId, msg.sender)) {
65
+ revert ErrorComponentUnauthorized(msg.sender, roleIdNum);
66
+ }
67
+ _;
68
+ }
69
+
70
+ // TODO discuss replacement with modifier restricted from accessmanaged
71
+ modifier isNotLocked() {
72
+ InstanceAccessManager accessManager = InstanceAccessManager(_getComponentStorage()._instance.authority());
73
+ if (accessManager.isTargetLocked(address(this))) {
74
+ revert IAccess.ErrorIAccessTargetLocked(address(this));
75
+ }
76
+ _;
77
+ }
78
+
79
+ function _getComponentStorage() private pure returns (ComponentStorage storage $) {
80
+ assembly {
81
+ $.slot := CONTRACT_LOCATION_V1
82
+ }
83
+ }
84
+
85
+
86
+ function _initializeComponent(
87
+ address registry,
88
+ NftId instanceNftId,
89
+ string memory name,
90
+ address token,
91
+ ObjectType componentType,
92
+ bool isInterceptor,
93
+ address initialOwner,
94
+ bytes memory data
95
+ )
96
+ internal
97
+ //onlyInitializing//TODO uncomment when "fully" upgradeable
98
+ virtual
99
+ {
100
+ ComponentStorage storage $ = _getComponentStorage();
101
+ _initializeRegisterable(registry, instanceNftId, componentType, isInterceptor, initialOwner, data);
102
+
103
+ // set unique name of component
104
+ $._name = name;
105
+ $._isNftInterceptor = isInterceptor;
106
+
107
+ // set and check linked instance
108
+ IRegistry.ObjectInfo memory instanceInfo = getRegistry().getObjectInfo(instanceNftId);
109
+ $._instance = IInstance(instanceInfo.objectAddress);
110
+ if(!$._instance.supportsInterface(type(IInstance).interfaceId)) {
111
+ revert ErrorComponentNotInstance(instanceNftId, instanceInfo.objectAddress);
112
+ }
113
+
114
+ // set linked services
115
+ VersionPart gifVersion = $._instance.getMajorVersion();
116
+ $._instanceService = IInstanceService(getRegistry().getServiceAddress(INSTANCE(), gifVersion));
117
+ $._productService = IProductService(getRegistry().getServiceAddress(PRODUCT(), gifVersion));
118
+
119
+ // set wallet and token
120
+ $._wallet = address(this);
121
+ $._token = IERC20Metadata(token);
122
+
123
+ _registerInterface(type(IComponent).interfaceId);
124
+ }
125
+
126
+ /// @dev callback function for nft transfers. may only be called by chain nft contract.
127
+ /// default implementation is empty. overriding functions MUST add onlyChainNft modifier
128
+ function nftTransferFrom(address from, address to, uint256 tokenId)
129
+ external
130
+ virtual override
131
+ onlyChainNft()
132
+ { }
133
+
134
+ // TODO discuss replacement with modifier restricted from accessmanaged
135
+ function lock() external onlyOwner override {
136
+ _getComponentStorage()._instanceService.setTargetLocked(getName(), true);
137
+ }
138
+
139
+ // TODO discuss replacement with modifier restricted from accessmanaged
140
+ function unlock() external onlyOwner override {
141
+ _getComponentStorage()._instanceService.setTargetLocked(getName(), false);
142
+ }
143
+
144
+ // only product service may set product nft id during registration of product setup
145
+ function setProductNftId(NftId productNftId)
146
+ external
147
+ override
148
+ onlyProductService()
149
+ {
150
+ ComponentStorage storage $ = _getComponentStorage();
151
+
152
+ if($._productNftId.gtz()) {
153
+ revert ErrorComponentProductNftAlreadySet();
154
+ }
155
+
156
+ $._productNftId = productNftId;
157
+ }
158
+
159
+ /// @dev Sets the wallet address for the component.
160
+ /// if the current wallet has tokens, these will be transferred.
161
+ /// if the new wallet address is externally owned, an approval from the
162
+ /// owner of the external wallet for the component to move all tokens must exist.
163
+ function setWallet(address newWallet)
164
+ external
165
+ override
166
+ onlyOwner
167
+ {
168
+ ComponentStorage storage $ = _getComponentStorage();
169
+
170
+ address currentWallet = $._wallet;
171
+ uint256 currentBalance = $._token.balanceOf(currentWallet);
172
+
173
+ // checks
174
+ if (newWallet == address(0)) {
175
+ revert ErrorComponentWalletAddressZero();
176
+ }
177
+ if (newWallet == currentWallet) {
178
+ revert ErrorComponentWalletAddressIsSameAsCurrent(newWallet);
179
+ }
180
+
181
+ if (currentBalance > 0) {
182
+ if (currentWallet == address(this)) {
183
+ // move tokens from component smart contract to external wallet
184
+ } else {
185
+ // move tokens from external wallet to component smart contract or another external wallet
186
+ uint256 allowance = $._token.allowance(currentWallet, address(this));
187
+ if (allowance < currentBalance) {
188
+ revert ErrorComponentWalletAllowanceTooSmall(currentWallet, newWallet, allowance, currentBalance);
189
+ }
190
+ }
191
+ }
192
+
193
+ // effects
194
+ $._wallet = newWallet;
195
+ emit LogComponentWalletAddressChanged(newWallet);
196
+
197
+ // interactions
198
+ if (currentBalance > 0) {
199
+ // transfer tokens from current wallet to new wallet
200
+ if (currentWallet == address(this)) {
201
+ // transferFrom requires self allowance too
202
+ $._token.approve(address(this), currentBalance);
203
+ }
204
+
205
+ SafeERC20.safeTransferFrom($._token, currentWallet, newWallet, currentBalance);
206
+ emit LogComponentWalletTokensTransferred(currentWallet, newWallet, currentBalance);
207
+ }
208
+ }
209
+
210
+ function getWallet()
211
+ public
212
+ view
213
+ override
214
+ returns (address walletAddress)
215
+ {
216
+ return _getComponentStorage()._wallet;
217
+ }
218
+
219
+ function getToken() public view override returns (IERC20Metadata token) {
220
+ return _getComponentStorage()._token;
221
+ }
222
+
223
+ function isNftInterceptor() public view override returns(bool isInterceptor) {
224
+ return _getComponentStorage()._isNftInterceptor;
225
+ }
226
+
227
+ function getInstance() public view override returns (IInstance instance) {
228
+ return _getComponentStorage()._instance;
229
+ }
230
+
231
+ function getName() public view override returns(string memory name) {
232
+ return _getComponentStorage()._name;
233
+ }
234
+
235
+ function getProductNftId() public view override returns (NftId productNftId) {
236
+ return _getComponentStorage()._productNftId;
237
+ }
238
+
239
+ function getInstanceService() public view returns (IInstanceService) {
240
+ return _getComponentStorage()._instanceService;
241
+ }
242
+
243
+ function getProductService() public view returns (IProductService) {
244
+ return _getComponentStorage()._productService;
245
+ }
246
+
247
+ }
@@ -4,49 +4,48 @@ pragma solidity ^0.8.19;
4
4
  import {DISTRIBUTION} from "../types/ObjectType.sol";
5
5
  import {IDistributionService} from "../instance/service/IDistributionService.sol";
6
6
  import {IProductService} from "../instance/service/IProductService.sol";
7
- import {NftId} from "../types/NftId.sol";
8
- import {ReferralId} from "../types/ReferralId.sol";
7
+ import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
8
+ import {ReferralId} from "../types/Referral.sol";
9
9
  import {Fee, FeeLib} from "../types/Fee.sol";
10
- import {BaseComponent} from "./BaseComponent.sol";
10
+ import {Component} from "./Component.sol";
11
11
  import {IDistributionComponent} from "./IDistributionComponent.sol";
12
12
  import {IRegistry} from "../registry/IRegistry.sol";
13
13
  import {IRegisterable} from "../shared/IRegisterable.sol";
14
+ import {ISetup} from "../instance/module/ISetup.sol";
14
15
  import {Registerable} from "../shared/Registerable.sol";
16
+ import {TokenHandler} from "../shared/TokenHandler.sol";
17
+ import {InstanceReader} from "../instance/InstanceReader.sol";
15
18
 
16
- contract Distribution is
17
- BaseComponent,
19
+ abstract contract Distribution is
20
+ Component,
18
21
  IDistributionComponent
19
22
  {
20
-
21
- Fee internal _initialDistributionFee;
22
23
  bool internal _isVerifying;
24
+ Fee internal _initialDistributionFee;
23
25
 
24
- IDistributionService private _distributionService;
25
- IProductService private _productService;
26
+ TokenHandler internal _tokenHandler;
26
27
 
27
- modifier onlyProductService() {
28
- require(
29
- msg.sender == address(_productService),
30
- "ERROR:POL-002:NOT_PRODUCT_SERVICE");
31
- _;
32
- }
28
+ IDistributionService private _distributionService;
33
29
 
34
30
  constructor(
35
31
  address registry,
36
32
  NftId instanceNftId,
37
33
  // TODO refactor into tokenNftId
34
+ string memory name,
38
35
  address token,
39
36
  bool verifying,
40
37
  Fee memory distributionFee,
41
- address initialOwner
38
+ address initialOwner,
39
+ bytes memory data
42
40
  )
43
- BaseComponent(registry, instanceNftId, token, DISTRIBUTION(), true, initialOwner)
44
41
  {
42
+ _initializeComponent(registry, instanceNftId, name, token, DISTRIBUTION(), true, initialOwner, data);
43
+
45
44
  _isVerifying = verifying;
46
45
  _initialDistributionFee = distributionFee;
47
46
 
48
- _distributionService = _instance.getDistributionService();
49
- _productService = _instance.getProductService();
47
+ _tokenHandler = new TokenHandler(token);
48
+ _distributionService = getInstance().getDistributionService();
50
49
 
51
50
  _registerInterface(type(IDistributionComponent).interfaceId);
52
51
  }
@@ -70,7 +69,8 @@ contract Distribution is
70
69
  virtual override
71
70
  returns (uint256 feeAmount)
72
71
  {
73
- Fee memory fee = getDistributionFee();
72
+ ISetup.DistributionSetupInfo memory setupInfo = getSetupInfo();
73
+ Fee memory fee = setupInfo.distributionFee;
74
74
  (feeAmount,) = FeeLib.calculateFee(fee, netPremiumAmount);
75
75
  }
76
76
 
@@ -115,41 +115,29 @@ contract Distribution is
115
115
  return false;
116
116
  }
117
117
 
118
- /// @dev default distribution fee, ie when not using any valid referralId
119
- function getDistributionFee() public view returns (Fee memory distributionFee) {
120
- NftId productNftId = _instance.getProductNftId(getNftId());
121
- if (_instance.hasTreasuryInfo(productNftId)) {
122
- return _instance.getTreasuryInfo(productNftId).distributionFee;
123
- } else {
124
- return _initialDistributionFee;
118
+ function getSetupInfo() public view returns (ISetup.DistributionSetupInfo memory setupInfo) {
119
+ InstanceReader reader = getInstance().getInstanceReader();
120
+ setupInfo = reader.getDistributionSetupInfo(getNftId());
121
+
122
+ // fallback to initial setup info (wallet is always != address(0))
123
+ if(setupInfo.wallet == address(0)) {
124
+ setupInfo = _getInitialSetupInfo();
125
125
  }
126
126
  }
127
127
 
128
+ function _getInitialSetupInfo() internal view returns (ISetup.DistributionSetupInfo memory setupInfo) {
129
+ return ISetup.DistributionSetupInfo(
130
+ zeroNftId(),
131
+ _tokenHandler,
132
+ _initialDistributionFee,
133
+ _isVerifying,
134
+ address(this)
135
+ );
136
+ }
137
+
128
138
 
129
139
  /// @dev returns true iff the component needs to be called when selling/renewing policis
130
140
  function isVerifying() external view returns (bool verifying) {
131
141
  return _isVerifying;
132
142
  }
133
-
134
- // from IRegisterable
135
-
136
- function getInitialInfo()
137
- public
138
- view
139
- override (IRegisterable, Registerable)
140
- returns(IRegistry.ObjectInfo memory, bytes memory)
141
- {
142
- (
143
- IRegistry.ObjectInfo memory info,
144
- bytes memory data
145
- ) = super.getInitialInfo();
146
-
147
- return (
148
- info,
149
- abi.encode(
150
- _initialDistributionFee,
151
- _isVerifying
152
- )
153
- );
154
- }
155
143
  }
@@ -0,0 +1,50 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
+
6
+ import {IRegisterable} from "../shared/IRegisterable.sol";
7
+ import {IInstance} from "../instance/IInstance.sol";
8
+ import {IInstanceService} from "../instance/IInstanceService.sol";
9
+ import {IProductService} from "../instance/service/IProductService.sol";
10
+ import {ITransferInterceptor} from "../registry/ITransferInterceptor.sol";
11
+ import {NftId} from "../types/NftId.sol";
12
+
13
+ interface IComponent is
14
+ IRegisterable,
15
+ ITransferInterceptor
16
+ {
17
+
18
+ error ErrorComponentNotChainNft(address caller);
19
+ error ErrorComponentNotProductService(address caller);
20
+ error ErrorComponentNotInstance(NftId instanceNftId, address instance);
21
+ error ErrorComponentProductNftAlreadySet();
22
+ error ErrorComponentWalletAddressZero();
23
+ error ErrorComponentWalletAddressIsSameAsCurrent(address newWallet);
24
+ error ErrorComponentWalletAllowanceTooSmall(address oldWallet, address newWallet, uint256 allowance, uint256 balance);
25
+ error ErrorComponentUnauthorized(address caller, uint64 requiredRoleIdNum);
26
+
27
+ event LogComponentWalletAddressChanged(address newWallet);
28
+ event LogComponentWalletTokensTransferred(address from, address to, uint256 amount);
29
+
30
+ function getName() external view returns (string memory name);
31
+
32
+ // TODO remove and replace with accessmanaged target locking mechanism
33
+ function lock() external;
34
+ function unlock() external;
35
+
36
+ function getToken() external view returns (IERC20Metadata token);
37
+
38
+ function setWallet(address walletAddress) external;
39
+ function getWallet() external view returns (address walletAddress);
40
+
41
+ function isNftInterceptor() external view returns(bool isInterceptor);
42
+
43
+ function getInstance() external view returns (IInstance instance);
44
+
45
+ function setProductNftId(NftId productNftId) external;
46
+ function getProductNftId() external view returns (NftId productNftId);
47
+
48
+ function getInstanceService() external view returns (IInstanceService);
49
+ function getProductService() external view returns (IProductService);
50
+ }
@@ -2,10 +2,14 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  import {Fee} from "../types/Fee.sol";
5
- import {ReferralId} from "../types/ReferralId.sol";
5
+ import {IComponent} from "./IComponent.sol";
6
+ import {ISetup} from "../instance/module/ISetup.sol";
7
+ import {ReferralId} from "../types/Referral.sol";
6
8
  import {NftId} from "../types/NftId.sol";
7
9
 
8
- interface IDistributionComponent {
10
+ interface IDistributionComponent is IComponent {
11
+
12
+ function getSetupInfo() external view returns (ISetup.DistributionSetupInfo memory setupInfo);
9
13
 
10
14
  function setFees(
11
15
  Fee memory distributionFee
@@ -38,9 +42,6 @@ interface IDistributionComponent {
38
42
  /// @dev returns true iff the referral id is valid
39
43
  function referralIsValid(ReferralId referralId) external view returns (bool isValid);
40
44
 
41
- /// @dev default distribution fee, ie when not using any valid referralId
42
- function getDistributionFee() external view returns (Fee memory distributionFee);
43
-
44
45
  /// @dev returns true iff the component needs to be called when selling/renewing policis
45
46
  function isVerifying() external view returns (bool verifying);
46
47
  }
@@ -1,41 +1,39 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {NftId} from "../types/NftId.sol";
5
4
  import {Fee} from "../types/Fee.sol";
5
+ import {IComponent} from "./IComponent.sol";
6
+ import {ISetup} from "../instance/module/ISetup.sol";
7
+ import {NftId} from "../types/NftId.sol";
6
8
  import {UFixed} from "../types/UFixed.sol";
7
9
 
8
- interface IPoolComponent {
10
+ /// @dev pool components hold and manage the collateral to cover active policies
11
+ /// pools come in different flavors
12
+ interface IPoolComponent is IComponent {
9
13
 
10
14
  event LogUnderwrittenByPool(NftId policyNftId, uint256 collateralizationAmount, address pool);
11
15
 
16
+ error ErrorPoolNotPoolService(address service);
17
+
18
+ function getSetupInfo() external view returns (ISetup.PoolSetupInfo memory setupInfo);
19
+
12
20
  function setFees(
13
21
  Fee memory poolFee,
14
22
  Fee memory stakingFee,
15
23
  Fee memory performanceFee
16
24
  ) external;
17
25
 
18
- /**
19
- * @dev creates a new bundle for this pool.
20
- */
21
- function createBundle(
22
- Fee memory fee,
23
- uint256 initialAmount,
24
- uint256 lifetime,
25
- bytes memory filter
26
- ) external returns(NftId bundleNftId);
27
-
26
+ /// @dev sets an additional bundle fee, this fee is added on top of the poolFee and deducted from the premium amounts.
27
+ /// via these fees individual bundler owner may earn income per policy in the context of peer to peer pools
28
28
  function setBundleFee(
29
- NftId policyNftId,
29
+ NftId bundleNftId,
30
30
  Fee memory fee
31
31
  ) external;
32
32
 
33
- /**
34
- * @dev this is a callback function that is called by the product service when underwriting a policy.
35
- * the pool has the option to check the details and object to underwriting by reverting.
36
- * the function is only called for "active" pools that ask to be involved/notified
37
- * by product related state changes.
38
- */
33
+ /// @dev this is a callback function that is called by the product service when underwriting a policy.
34
+ /// the pool has the option to check the details and object to underwriting by reverting.
35
+ /// the function is only called for "active" pools that ask to be involved/notified
36
+ /// by product related state changes.
39
37
  function underwrite(
40
38
  NftId policyNftId,
41
39
  bytes memory policyData,
@@ -43,10 +41,31 @@ interface IPoolComponent {
43
41
  uint256 collateralizationAmount
44
42
  ) external;
45
43
 
46
- /**
47
- * @dev returns true iff the policy application data in policyData matches
48
- * with the bundle filter criteria encoded in bundleFilter.
49
- */
44
+ function lockBundle(NftId bundleNftId) external;
45
+
46
+ function unlockBundle(NftId bundleNftId) external;
47
+
48
+ /// @dev defines the multiplier to calculate the required collateral to cover a given sum insured amount
49
+ function getCollateralizationLevel() external view returns (UFixed collateralizationLevel);
50
+
51
+ /// @dev declares if pool intercept transfers of bundle nft ids
52
+ /// - yes: pool may block transfer of bundle ownership or simply updates some bookkeeping related to bundle ownership
53
+ /// - no: pool is not involved in transfer of bundle ownership
54
+ function isInterceptingBundleTransfers() external view returns (bool);
55
+
56
+ /// @dev declares if pool relies on external management of collateral (yes/no):
57
+ /// - yes: underwriting of new policies does not require an actual token balance, instead it is assumed that the pool owner will manage funds externally and inject enough tokens to allow process confirmed payouts
58
+ /// - no: the pool smart contract ensures that the necessary capacity of the pool prior to underwriting.
59
+ function isExternallyManaged() external view returns (bool);
60
+
61
+ /// @dev declares if pool component is actively involved in underwriting (yes/no):
62
+ /// - yes: verifying pools components actively confirm underwriting applications, ie the pool component logic explicitly needs to confirm the locking of collateral to cover the sum insured of the policy
63
+ /// - no: underwriting a policy does not require any interaction with the pool component if the covering bundle can provide the necessary captial
64
+ function isVerifyingApplications() external view returns (bool);
65
+
66
+ /// @dev returns true iff the policy application data in policyData matches
67
+ /// with the bundle filter criteria encoded in bundleFilter
68
+ /// this is a callback function that is only called if a pool declares itself as a verifying pool
50
69
  function policyMatchesBundle(
51
70
  bytes memory policyData,
52
71
  bytes memory bundleFilter
@@ -55,10 +74,4 @@ interface IPoolComponent {
55
74
  view
56
75
  returns (bool isMatching);
57
76
 
58
- function isVerifying() external view returns (bool verifying);
59
-
60
- function getCollateralizationLevel() external view returns (UFixed collateralizationLevel);
61
-
62
- function getFees() external view returns (Fee memory poolFee, Fee memory stakingFee, Fee memory performanceFee);
63
-
64
77
  }
@@ -2,11 +2,15 @@
2
2
  pragma solidity ^0.8.20;
3
3
 
4
4
  import {Fee} from "../types/Fee.sol";
5
+ import {IComponent} from "./IComponent.sol";
6
+ import {ISetup} from "../instance/module/ISetup.sol";
5
7
  import {NftId} from "../types/NftId.sol";
6
- import {ReferralId} from "../types/ReferralId.sol";
8
+ import {ReferralId} from "../types/Referral.sol";
7
9
  import {RiskId} from "../types/RiskId.sol";
8
10
 
9
- interface IProductComponent {
11
+ interface IProductComponent is IComponent {
12
+
13
+ function getSetupInfo() external view returns (ISetup.ProductSetupInfo memory setupInfo);
10
14
 
11
15
  function setFees(
12
16
  Fee memory productFee,
@@ -18,8 +22,8 @@ interface IProductComponent {
18
22
  RiskId riskId,
19
23
  uint256 lifetime,
20
24
  bytes memory applicationData,
21
- ReferralId referralId,
22
- NftId bundleNftId
25
+ NftId bundleNftId,
26
+ ReferralId referralId
23
27
  ) external view returns (uint256 premiumAmount);
24
28
 
25
29
  function calculateNetPremium(
@@ -29,9 +33,7 @@ interface IProductComponent {
29
33
  bytes memory applicationData
30
34
  ) external view returns (uint256 netPremiumAmount);
31
35
 
32
- function getProductFee() external view returns (Fee memory productFee);
33
- function getProcessingFee() external view returns (Fee memory processingFee);
34
-
36
+
35
37
  function getPoolNftId() external view returns (NftId poolNftId);
36
38
  function getDistributionNftId() external view returns (NftId distributionNftId);
37
39
  }