@etherisc/gif-next 0.0.2-7bdd29a-841 → 0.0.2-7bddd7e-496

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/README.md +4 -1
  2. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.dbg.json +1 -1
  3. package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.dbg.json +1 -1
  4. package/artifacts/contracts/authorization/Authorization.sol/Authorization.dbg.json +1 -1
  5. package/artifacts/contracts/authorization/Authorization.sol/Authorization.json +2 -2
  6. package/artifacts/contracts/authorization/IAccess.sol/IAccess.dbg.json +1 -1
  7. package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.dbg.json +1 -1
  8. package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.dbg.json +1 -1
  9. package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.dbg.json +1 -1
  10. package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +1 -1
  11. package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.dbg.json +1 -1
  12. package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.json +2 -2
  13. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +1 -1
  14. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.dbg.json +1 -1
  15. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.json +24 -42
  16. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.dbg.json +1 -1
  17. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.json +2 -2
  18. package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
  19. package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +0 -26
  20. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
  21. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +76 -131
  22. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  23. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +39 -51
  24. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  25. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +0 -26
  26. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  27. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +0 -31
  28. package/artifacts/contracts/instance/BundleSet.sol/BundleSet.dbg.json +1 -1
  29. package/artifacts/contracts/instance/BundleSet.sol/BundleSet.json +2 -2
  30. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  31. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  32. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  33. package/artifacts/contracts/instance/Instance.sol/Instance.json +2 -2
  34. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
  35. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +54 -54
  36. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +1 -1
  37. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +2 -2
  38. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  39. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +2 -2
  40. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  41. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +2 -2
  42. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  43. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +2 -2
  44. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
  45. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +2 -2
  46. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +1 -1
  47. package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
  48. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.dbg.json +1 -1
  49. package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.dbg.json +1 -1
  50. package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.dbg.json +1 -1
  51. package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.json +2 -2
  52. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  53. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  54. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
  55. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  56. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  57. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  58. package/artifacts/contracts/mock/Dip.sol/Dip.dbg.json +1 -1
  59. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.dbg.json +1 -1
  60. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.json +18 -36
  61. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +1 -1
  62. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +2 -2
  63. package/artifacts/contracts/oracle/IOracle.sol/IOracle.dbg.json +1 -1
  64. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.dbg.json +1 -1
  65. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.json +0 -26
  66. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
  67. package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
  68. package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +0 -26
  69. package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
  70. package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +2 -2
  71. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
  72. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +2 -2
  73. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +1 -1
  74. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +0 -26
  75. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +1 -1
  76. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +2 -2
  77. package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
  78. package/artifacts/contracts/pool/BundleService.sol/BundleService.json +46 -101
  79. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  80. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +24 -36
  81. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
  82. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +0 -31
  83. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  84. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +0 -26
  85. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
  86. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +0 -31
  87. package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
  88. package/artifacts/contracts/pool/Pool.sol/Pool.json +0 -26
  89. package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
  90. package/artifacts/contracts/pool/PoolService.sol/PoolService.json +40 -151
  91. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  92. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +21 -61
  93. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  94. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +2 -2
  95. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  96. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +2 -2
  97. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +1 -1
  98. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +0 -26
  99. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +1 -1
  100. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +2 -2
  101. package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
  102. package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +58 -66
  103. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  104. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +30 -34
  105. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  106. package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
  107. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  108. package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
  109. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  110. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +0 -26
  111. package/artifacts/contracts/product/IProductService.sol/IProductService.dbg.json +1 -1
  112. package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
  113. package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +14 -14
  114. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  115. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +8 -8
  116. package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
  117. package/artifacts/contracts/product/PricingService.sol/PricingService.json +2 -2
  118. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
  119. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +2 -2
  120. package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
  121. package/artifacts/contracts/product/Product.sol/Product.json +0 -26
  122. package/artifacts/contracts/product/ProductService.sol/ProductService.dbg.json +1 -1
  123. package/artifacts/contracts/product/ProductService.sol/ProductService.json +2 -2
  124. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  125. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +2 -2
  126. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  127. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  128. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  129. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  130. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  131. package/artifacts/contracts/registry/Registry.sol/Registry.json +2 -2
  132. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
  133. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +28 -28
  134. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  135. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +2 -2
  136. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  137. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +2 -2
  138. package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.dbg.json +1 -1
  139. package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.dbg.json +1 -1
  140. package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.json +2 -2
  141. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +1 -1
  142. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +2 -2
  143. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  144. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  145. package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
  146. package/artifacts/contracts/shared/Component.sol/Component.json +0 -26
  147. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
  148. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +108 -68
  149. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
  150. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +55 -35
  151. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +1 -1
  152. package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
  153. package/artifacts/contracts/shared/IComponent.sol/IComponent.json +0 -26
  154. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
  155. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
  156. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +0 -26
  157. package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  158. package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  159. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  160. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  161. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  162. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  163. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  164. package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.dbg.json +1 -1
  165. package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.dbg.json +1 -1
  166. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
  167. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.json +0 -26
  168. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  169. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  170. package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.dbg.json +1 -1
  171. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  172. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  173. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  174. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  175. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  176. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  177. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +288 -16
  178. package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
  179. package/artifacts/contracts/staking/IStaking.sol/IStaking.json +0 -26
  180. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
  181. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +1 -1
  182. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +30 -113
  183. package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
  184. package/artifacts/contracts/staking/Staking.sol/Staking.json +92 -70
  185. package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +1 -1
  186. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
  187. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +47 -23
  188. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
  189. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +2 -2
  190. package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
  191. package/artifacts/contracts/staking/StakingService.sol/StakingService.json +2 -2
  192. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
  193. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +2 -2
  194. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
  195. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +2 -2
  196. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
  197. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +2 -2
  198. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  199. package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
  200. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  201. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  202. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  203. package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
  204. package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
  205. package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
  206. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  207. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  208. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  209. package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
  210. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.dbg.json +1 -1
  211. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
  212. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
  213. package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
  214. package/artifacts/contracts/type/Selector.sol/SelectorLib.dbg.json +1 -1
  215. package/artifacts/contracts/type/Selector.sol/SelectorSetLib.dbg.json +1 -1
  216. package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
  217. package/artifacts/contracts/type/String.sol/StrLib.dbg.json +1 -1
  218. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
  219. package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +1 -1
  220. package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
  221. package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
  222. package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
  223. package/artifacts/contracts/upgradeability/IVersionable.sol/IVersionable.dbg.json +1 -1
  224. package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  225. package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  226. package/artifacts/contracts/upgradeability/Versionable.sol/Versionable.dbg.json +1 -1
  227. package/contracts/authorization/Authorization.sol +0 -1
  228. package/contracts/distribution/DistributionService.sol +3 -17
  229. package/contracts/distribution/IDistributionService.sol +1 -3
  230. package/contracts/instance/InstanceAdmin.sol +23 -4
  231. package/contracts/instance/InstanceService.sol +1 -1
  232. package/contracts/pool/BundleService.sol +2 -16
  233. package/contracts/pool/IBundleService.sol +2 -3
  234. package/contracts/pool/IPoolService.sol +1 -3
  235. package/contracts/pool/PoolService.sol +12 -53
  236. package/contracts/product/ClaimService.sol +1 -9
  237. package/contracts/product/IProductService.sol +1 -0
  238. package/contracts/product/PolicyService.sol +14 -6
  239. package/contracts/registry/RegistryAdmin.sol +9 -0
  240. package/contracts/shared/Component.sol +6 -19
  241. package/contracts/shared/ComponentService.sol +10 -19
  242. package/contracts/shared/IComponent.sol +0 -1
  243. package/contracts/shared/TokenHandler.sol +96 -22
  244. package/contracts/staking/StakeManagerLib.sol +0 -25
  245. package/contracts/staking/Staking.sol +3 -23
  246. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/af588ef278664c2b6f7ba0f58512e1b2.json"
3
+ "buildInfo": "../../../build-info/06c30a14ab8f451d4ea027bea3c27095.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/af588ef278664c2b6f7ba0f58512e1b2.json"
3
+ "buildInfo": "../../../build-info/06c30a14ab8f451d4ea027bea3c27095.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/af588ef278664c2b6f7ba0f58512e1b2.json"
3
+ "buildInfo": "../../../build-info/06c30a14ab8f451d4ea027bea3c27095.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/af588ef278664c2b6f7ba0f58512e1b2.json"
3
+ "buildInfo": "../../../build-info/06c30a14ab8f451d4ea027bea3c27095.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/af588ef278664c2b6f7ba0f58512e1b2.json"
3
+ "buildInfo": "../../../build-info/06c30a14ab8f451d4ea027bea3c27095.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/af588ef278664c2b6f7ba0f58512e1b2.json"
3
+ "buildInfo": "../../../build-info/06c30a14ab8f451d4ea027bea3c27095.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/af588ef278664c2b6f7ba0f58512e1b2.json"
3
+ "buildInfo": "../../../build-info/06c30a14ab8f451d4ea027bea3c27095.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/af588ef278664c2b6f7ba0f58512e1b2.json"
3
+ "buildInfo": "../../../build-info/06c30a14ab8f451d4ea027bea3c27095.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/af588ef278664c2b6f7ba0f58512e1b2.json"
3
+ "buildInfo": "../../../build-info/06c30a14ab8f451d4ea027bea3c27095.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/af588ef278664c2b6f7ba0f58512e1b2.json"
3
+ "buildInfo": "../../../build-info/06c30a14ab8f451d4ea027bea3c27095.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/af588ef278664c2b6f7ba0f58512e1b2.json"
3
+ "buildInfo": "../../../build-info/06c30a14ab8f451d4ea027bea3c27095.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/af588ef278664c2b6f7ba0f58512e1b2.json"
3
+ "buildInfo": "../../../build-info/06c30a14ab8f451d4ea027bea3c27095.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/af588ef278664c2b6f7ba0f58512e1b2.json"
3
+ "buildInfo": "../../../build-info/06c30a14ab8f451d4ea027bea3c27095.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/af588ef278664c2b6f7ba0f58512e1b2.json"
3
+ "buildInfo": "../../../build-info/06c30a14ab8f451d4ea027bea3c27095.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/af588ef278664c2b6f7ba0f58512e1b2.json"
3
+ "buildInfo": "../../../build-info/06c30a14ab8f451d4ea027bea3c27095.json"
4
4
  }
@@ -134,7 +134,6 @@ contract Authorization
134
134
  RoleIdLib.toComponentRoleId(componentType, 0),
135
135
  _toTargetRoleName(
136
136
  getTargetName()));
137
-
138
137
  }
139
138
 
140
139
  /// @dev Add a contract role for the provided role id and name.
@@ -1,8 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
-
6
4
  import {IRegistry} from "../registry/IRegistry.sol";
7
5
  import {IInstance} from "../instance/IInstance.sol";
8
6
  import {IComponentService} from "../shared/IComponentService.sol";
@@ -19,7 +17,7 @@ import {KEEP_STATE} from "../type/StateId.sol";
19
17
  import {ObjectType, COMPONENT, DISTRIBUTION, INSTANCE, DISTRIBUTION, DISTRIBUTOR, REGISTRY} from "../type/ObjectType.sol";
20
18
  import {ComponentVerifyingService} from "../shared/ComponentVerifyingService.sol";
21
19
  import {IDistributionService} from "./IDistributionService.sol";
22
- import {UFixed, UFixedLib} from "../type/UFixed.sol";
20
+ import {UFixed} from "../type/UFixed.sol";
23
21
  import {DistributorType, DistributorTypeLib} from "../type/DistributorType.sol";
24
22
  import {ReferralId, ReferralLib} from "../type/Referral.sol";
25
23
  import {Timestamp, TimestampLib} from "../type/Timestamp.sol";
@@ -275,17 +273,6 @@ contract DistributionService is
275
273
  }
276
274
  }
277
275
 
278
- if (withdrawnAmount.eqz()) {
279
- revert ErrorDistributionServiceCommissionWithdrawAmountIsZero();
280
- }
281
-
282
- // check allowance
283
- IERC20Metadata token = IERC20Metadata(distributionInfo.token);
284
- uint256 tokenAllowance = token.allowance(distributionWallet, address(distributionInfo.tokenHandler));
285
- if (tokenAllowance < withdrawnAmount.toInt()) {
286
- revert ErrorDistributionServiceWalletAllowanceTooSmall(distributionWallet, address(distributionInfo.tokenHandler), tokenAllowance, withdrawnAmount.toInt());
287
- }
288
-
289
276
  // decrease fee counters by withdrawnAmount and update distributor info
290
277
  {
291
278
  InstanceStore store = instance.getInstanceStore();
@@ -298,9 +285,8 @@ contract DistributionService is
298
285
  // transfer amount to distributor
299
286
  {
300
287
  address distributor = getRegistry().ownerOf(distributorNftId);
301
- emit LogDistributionServiceCommissionWithdrawn(distributorNftId, distributor, address(token), withdrawnAmount);
302
- // TODO: centralize token handling (issue #471)
303
- distributionInfo.tokenHandler.transfer(distributionWallet, distributor, withdrawnAmount);
288
+ emit LogDistributionServiceCommissionWithdrawn(distributorNftId, distributor, address(distributionInfo.token), withdrawnAmount);
289
+ distributionInfo.tokenHandler.distributeTokens(distributionWallet, distributor, withdrawnAmount);
304
290
  }
305
291
  }
306
292
 
@@ -28,9 +28,7 @@ interface IDistributionService is IService {
28
28
  error ErrorIDistributionServiceMinFeeTooHigh(uint256 minFee, uint256 limit);
29
29
 
30
30
  error ErrorDistributionServiceCommissionWithdrawAmountExceedsLimit(Amount amount, Amount limit);
31
- error ErrorDistributionServiceCommissionWithdrawAmountIsZero();
32
- error ErrorDistributionServiceWalletAllowanceTooSmall(address wallet, address tokenHandler, uint256 allowance, uint256 amount);
33
-
31
+
34
32
  error ErrorDistributionServiceVariableFeesTooHight(uint256 maxDiscountPercentage, uint256 limit);
35
33
  error ErrorDistributionServiceMaxDiscountTooHigh(uint256 maxDiscountPercentage, uint256 limit);
36
34
 
@@ -7,6 +7,7 @@ import {AccessAdmin} from "../authorization/AccessAdmin.sol";
7
7
  import {AccessManagerCloneable} from "../authorization/AccessManagerCloneable.sol";
8
8
  import {IAccessAdmin} from "../authorization/IAccessAdmin.sol";
9
9
  import {IAuthorization} from "../authorization/IAuthorization.sol";
10
+ import {IComponent} from "../shared/IComponent.sol";
10
11
  import {IModuleAuthorization} from "../authorization/IModuleAuthorization.sol";
11
12
  import {IRegistry} from "../registry/IRegistry.sol";
12
13
  import {IInstance} from "./IInstance.sol";
@@ -14,6 +15,7 @@ import {IService} from "../shared/IService.sol";
14
15
  import {ObjectType, ObjectTypeLib, ALL, POOL, RELEASE} from "../type/ObjectType.sol";
15
16
  import {RoleId, RoleIdLib, ADMIN_ROLE, PUBLIC_ROLE, DISTRIBUTION_OWNER_ROLE, ORACLE_OWNER_ROLE, POOL_OWNER_ROLE, PRODUCT_OWNER_ROLE} from "../type/RoleId.sol";
16
17
  import {Str, StrLib} from "../type/String.sol";
18
+ import {TokenHandler} from "../shared/TokenHandler.sol";
17
19
  import {VersionPart} from "../type/Version.sol";
18
20
 
19
21
 
@@ -111,26 +113,43 @@ contract InstanceAdmin is
111
113
  /// @dev Initializes the authorization for the specified component.
112
114
  /// Important: The component MUST be registered.
113
115
  function initializeComponentAuthorization(
114
- address componentAddress,
116
+ IComponent component,
115
117
  IAuthorization authorization
116
118
  )
117
119
  external
118
120
  {
119
- _checkTargetIsReadyForAuthorization(componentAddress);
121
+ _checkTargetIsReadyForAuthorization(address(component));
120
122
 
121
123
  _createRoles(authorization);
122
124
 
123
125
  // create component target
124
126
  _createTarget(
125
- componentAddress,
127
+ address(component),
126
128
  authorization.getTargetName(),
127
129
  true, // checkAuthority
128
130
  false); // custom
129
131
 
132
+ _createTarget(
133
+ address(component.getTokenHandler()),
134
+ string(abi.encodePacked(authorization.getTargetName(), "TH")),
135
+ true,
136
+ false);
137
+
138
+ // FIXME: make this a bit nicer and work with IAuthorization. Use a specific role, not public - access to TokenHandler must be restricted
139
+ FunctionInfo[] memory functions = new FunctionInfo[](3);
140
+ functions[0] = toFunction(TokenHandler.collectTokens.selector, "collectTokens");
141
+ functions[1] = toFunction(TokenHandler.collectTokensThreeRecipients.selector, "collectTokensThreeRecipients");
142
+ functions[2] = toFunction(TokenHandler.distributeTokens.selector, "distributeTokens");
143
+
144
+ _authorizeTargetFunctions(
145
+ address(component.getTokenHandler()),
146
+ getPublicRole(),
147
+ functions);
148
+
130
149
  _grantRoleToAccount(
131
150
  authorization.getTargetRole(
132
151
  authorization.getTarget()),
133
- componentAddress);
152
+ address(component));
134
153
 
135
154
  _createTargetAuthorizations(authorization);
136
155
  }
@@ -314,7 +314,7 @@ contract InstanceService is
314
314
 
315
315
  InstanceAdmin instanceAdmin = instance.getInstanceAdmin();
316
316
  instanceAdmin.initializeComponentAuthorization(
317
- address(component),
317
+ component,
318
318
  component.getAuthorization());
319
319
  }
320
320
 
@@ -1,8 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
-
6
4
  import {IBundle} from "../instance/module/IBundle.sol";
7
5
  import {IBundleService} from "./IBundleService.sol";
8
6
  import {IComponents} from "../instance/module/IComponents.sol";
@@ -399,17 +397,6 @@ contract BundleService is
399
397
  }
400
398
  }
401
399
 
402
- if (withdrawnAmount.eqz()) {
403
- revert ErrorBundleServiceFeesWithdrawAmountIsZero();
404
- }
405
-
406
- // check allowance
407
- IERC20Metadata token = IERC20Metadata(poolInfo.token);
408
- uint256 tokenAllowance = token.allowance(poolWallet, address(poolInfo.tokenHandler));
409
- if (tokenAllowance < withdrawnAmount.toInt()) {
410
- revert ErrorBundleServiceWalletAllowanceTooSmall(poolWallet, address(poolInfo.tokenHandler), tokenAllowance, withdrawnAmount.toInt());
411
- }
412
-
413
400
  // decrease fee counters by withdrawnAmount
414
401
  {
415
402
  InstanceStore store = instance.getInstanceStore();
@@ -422,9 +409,8 @@ contract BundleService is
422
409
  // transfer amount to bundle owner
423
410
  {
424
411
  address owner = getRegistry().ownerOf(bundleNftId);
425
- emit LogBundleServiceFeesWithdrawn(bundleNftId, owner, address(token), withdrawnAmount);
426
- // TODO: centralize token handling (issue #471)
427
- poolInfo.tokenHandler.transfer(poolWallet, owner, withdrawnAmount);
412
+ emit LogBundleServiceFeesWithdrawn(bundleNftId, owner, address(poolInfo.token), withdrawnAmount);
413
+ poolInfo.tokenHandler.distributeTokens(poolWallet, owner, withdrawnAmount);
428
414
  }
429
415
  }
430
416
 
@@ -27,9 +27,7 @@ interface IBundleService is IService {
27
27
  error ErrorBundleServicePolicyNotCloseable(NftId policyNftId);
28
28
 
29
29
  error ErrorBundleServiceFeesWithdrawAmountExceedsLimit(Amount amount, Amount limit);
30
- error ErrorBundleServiceFeesWithdrawAmountIsZero();
31
- error ErrorBundleServiceWalletAllowanceTooSmall(address wallet, address tokenHandler, uint256 allowance, uint256 amount);
32
-
30
+
33
31
  error ErrorBundleServiceUnstakeAmountExceedsLimit(Amount amount, Amount limit);
34
32
 
35
33
  error ErrorBundleServiceExtensionLifetimeIsZero();
@@ -126,6 +124,7 @@ interface IBundleService is IService {
126
124
  NftId policyNftId
127
125
  ) external;
128
126
 
127
+ // FIXME: move to pool service
129
128
  /// @dev Withdraw bundle feeds for the given bundle
130
129
  /// @param bundleNftId the bundle Nft Id
131
130
  /// @param amount the amount to withdraw. If set to AMOUNT_MAX, the full commission available is withdrawn
@@ -30,9 +30,7 @@ interface IPoolService is IService {
30
30
  error ErrorPoolServiceInvalidTransferAmount(Amount expectedAmount, Amount actualAmount);
31
31
  error ErrorPoolServiceBundlePoolMismatch(NftId bundleNftId, NftId poolNftId);
32
32
  error ErrorPoolServiceMaxBalanceAmountExceeded(NftId poolNftId, Amount maxBalanceAmount, Amount currentBalanceAmount, Amount transferAmount);
33
- error ErrorPoolServiceWalletAllowanceTooSmall(address wallet, address spender, uint256 allowance, uint256 amount);
34
- error ErrorPoolServiceAmountIsZero();
35
-
33
+
36
34
  /// @dev defines the required role for bundle owners for the calling pool
37
35
  /// default implementation returns PUBLIC ROLE
38
36
  function setBundleOwnerRole(RoleId bundleOwnerRole) external;
@@ -1,8 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
-
6
4
  import {IBundle} from "../instance/module/IBundle.sol";
7
5
  import {IBundleService} from "./IBundleService.sol";
8
6
  import {IComponents} from "../instance/module/IComponents.sol";
@@ -192,24 +190,10 @@ contract PoolService is
192
190
 
193
191
  if ((unstakedAmount + feeAmount).gtz()){
194
192
  IComponents.ComponentInfo memory poolComponentInfo = instance.getInstanceReader().getComponentInfo(poolNftId);
195
- TokenHandler tokenHandler = poolComponentInfo.tokenHandler;
196
- IERC20Metadata token = IERC20Metadata(poolComponentInfo.token);
197
-
198
- // TODO: centralize token handling (issue #471)
199
-
200
- // check allowance
201
- uint256 tokenAllowance = token.allowance(poolComponentInfo.wallet, address(tokenHandler));
202
- if (tokenAllowance < (unstakedAmount.toInt() + feeAmount.toInt())) {
203
- revert ErrorPoolServiceWalletAllowanceTooSmall(
204
- poolComponentInfo.wallet,
205
- address(tokenHandler),
206
- tokenAllowance,
207
- unstakedAmount.toInt() + feeAmount.toInt());
208
- }
209
-
210
- // transfer amount to bundle owner
211
- address bundleOwner = getRegistry().ownerOf(bundleNftId);
212
- tokenHandler.transfer(poolComponentInfo.wallet, bundleOwner, unstakedAmount + feeAmount);
193
+ poolComponentInfo.tokenHandler.distributeTokens(
194
+ poolComponentInfo.wallet,
195
+ getRegistry().ownerOf(bundleNftId),
196
+ unstakedAmount + feeAmount);
213
197
  }
214
198
  }
215
199
 
@@ -280,10 +264,6 @@ contract PoolService is
280
264
  revert ErrorPoolServiceBundlePoolMismatch(bundleNftId, poolNftId);
281
265
  }
282
266
 
283
- if (amount.eqz()) {
284
- revert ErrorPoolServiceAmountIsZero();
285
- }
286
-
287
267
  // call bundle service for bookkeeping and additional checks
288
268
  Amount unstakedAmount = _bundleService.unstake(instance, bundleNftId, amount);
289
269
 
@@ -301,21 +281,13 @@ contract PoolService is
301
281
 
302
282
  IComponents.ComponentInfo memory poolComponentInfo = instanceReader.getComponentInfo(poolNftId);
303
283
  address poolWallet = poolComponentInfo.wallet;
304
-
305
- // check allowance
306
- {
307
- IERC20Metadata token = IERC20Metadata(poolComponentInfo.token);
308
- uint256 tokenAllowance = token.allowance(poolWallet, address(poolComponentInfo.tokenHandler));
309
- if (tokenAllowance < unstakedAmount.toInt()) {
310
- revert ErrorPoolServiceWalletAllowanceTooSmall(poolWallet, address(poolComponentInfo.tokenHandler), tokenAllowance, amount.toInt());
311
- }
312
- }
313
-
314
284
  // transfer amount to bundle owner
315
285
  address owner = getRegistry().ownerOf(bundleNftId);
316
286
  emit LogPoolServiceBundleUnstaked(instance.getNftId(), poolNftId, bundleNftId, unstakedAmount);
317
- // TODO: centralize token handling (issue #471)
318
- poolComponentInfo.tokenHandler.transfer(poolWallet, owner, unstakedAmount);
287
+ poolComponentInfo.tokenHandler.distributeTokens(
288
+ poolWallet,
289
+ owner,
290
+ unstakedAmount);
319
291
  return unstakedAmount;
320
292
  }
321
293
 
@@ -521,7 +493,6 @@ contract PoolService is
521
493
  }
522
494
 
523
495
 
524
- // TODO create (I)TreasuryService that deals with all gif related token transfers
525
496
  /// @dev transfers the specified amount from the bundle owner to the pool's wallet
526
497
  function _collectStakingAmount(
527
498
  InstanceReader instanceReader,
@@ -534,23 +505,11 @@ contract PoolService is
534
505
 
535
506
  // collecting investor token
536
507
  IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
537
- TokenHandler tokenHandler = componentInfo.tokenHandler;
538
508
  address poolWallet = componentInfo.wallet;
539
-
540
- if(amount.gtz()) {
541
- uint256 allowance = IERC20Metadata(componentInfo.token).allowance(bundleOwner, address(tokenHandler));
542
- if (allowance < amount.toInt()) {
543
- revert ErrorPoolServiceWalletAllowanceTooSmall(bundleOwner, address(tokenHandler), allowance, amount.toInt());
544
- }
545
-
546
- // TODO: centralize token handling (issue #471)
547
- tokenHandler.transfer(
548
- bundleOwner,
549
- poolWallet,
550
- amount);
551
- } else {
552
- revert ErrorPoolServiceAmountIsZero();
553
- }
509
+ componentInfo.tokenHandler.collectTokens(
510
+ bundleOwner,
511
+ poolWallet,
512
+ amount);
554
513
  }
555
514
 
556
515
  function _getDomain() internal pure override returns(ObjectType) {
@@ -302,20 +302,12 @@ contract ClaimService is
302
302
 
303
303
  // TODO callback IPolicyHolder
304
304
 
305
- if (netPayoutAmount.eqz()) {
306
- revert ErrorClaimsServicePayoutAmountIsZero(policyNftId, payoutId);
307
- }
308
-
309
305
  emit LogClaimServicePayoutProcessed(policyNftId, payoutId, payoutAmount, beneficiary, netPayoutAmount);
310
306
 
311
307
  {
312
308
  NftId poolNftId = getRegistry().getObjectInfo(policyInfo.bundleNftId).parentNftId;
313
309
  IComponents.ComponentInfo memory poolInfo = instanceReader.getComponentInfo(poolNftId);
314
- // TODO: centralize token handling (issue #471)
315
- poolInfo.tokenHandler.transfer(
316
- poolInfo.wallet,
317
- beneficiary,
318
- netPayoutAmount);
310
+ poolInfo.tokenHandler.distributeTokens(poolInfo.wallet, beneficiary, netPayoutAmount);
319
311
  }
320
312
  }
321
313
 
@@ -12,6 +12,7 @@ import {Timestamp} from "../type/Timestamp.sol";
12
12
  import {UFixed} from "../type/UFixed.sol";
13
13
  import {Fee} from "../type/Fee.sol";
14
14
 
15
+ // TODO consider renaming to IRiskService
15
16
  interface IProductService is IService {
16
17
 
17
18
  function createRisk(
@@ -334,6 +334,7 @@ contract PolicyService is
334
334
  }
335
335
 
336
336
  // TODO consider to allow for underpaid premiums (with the effects of reducing max payouts accordingly)
337
+ // TODO consider to remove requirement for fully paid premiums altogether
337
338
  if (!(policyInfo.premiumAmount == policyInfo.premiumPaidAmount)) {
338
339
  revert ErrorPolicyServicePremiumNotFullyPaid(policyNftId, policyInfo.premiumAmount, policyInfo.premiumPaidAmount);
339
340
  }
@@ -345,9 +346,13 @@ contract PolicyService is
345
346
  policyNftId,
346
347
  policyInfo);
347
348
 
349
+ // TODO consider to also set expiredAt to current block timestamp if that timestamp is still in the futue
350
+
348
351
  // update policy state to closed
349
352
  policyInfo.closedAt = TimestampLib.blockTimestamp();
350
353
  instance.getInstanceStore().updatePolicy(policyNftId, policyInfo, CLOSED());
354
+
355
+ // TODO add logging
351
356
  }
352
357
 
353
358
 
@@ -473,7 +478,7 @@ contract PolicyService is
473
478
  address policyHolder = getRegistry().ownerOf(policyNftId);
474
479
 
475
480
  (
476
- NftId distributionNftId,
481
+ ,
477
482
  address distributionWallet,
478
483
  address poolWallet,
479
484
  address productWallet
@@ -481,11 +486,14 @@ contract PolicyService is
481
486
  instanceReader,
482
487
  productNftId);
483
488
 
484
- // TODO: centralize token handling (issue #471)
485
- // transfer premium amounts to target wallets
486
- tokenHandler.transfer(policyHolder, productWallet, premium.productFeeAmount);
487
- tokenHandler.transfer(policyHolder, distributionWallet, premium.distributionFeeAndCommissionAmount);
488
- tokenHandler.transfer(policyHolder, poolWallet, premium.poolPremiumAndFeeAmount);
489
+ tokenHandler.collectTokensThreeRecipients(
490
+ policyHolder,
491
+ productWallet,
492
+ premium.productFeeAmount,
493
+ distributionWallet,
494
+ premium.distributionFeeAndCommissionAmount,
495
+ poolWallet,
496
+ premium.poolPremiumAndFeeAmount);
489
497
  }
490
498
 
491
499
 
@@ -12,6 +12,7 @@ import {ReleaseRegistry} from "./ReleaseRegistry.sol";
12
12
  import {RoleId, RoleIdLib, ADMIN_ROLE, GIF_MANAGER_ROLE, GIF_ADMIN_ROLE, PUBLIC_ROLE} from "../type/RoleId.sol";
13
13
  import {StakingStore} from "../staking/StakingStore.sol";
14
14
  import {STAKING} from "../type/ObjectType.sol";
15
+ import {TokenHandler} from "../shared/TokenHandler.sol";
15
16
  import {TokenRegistry} from "./TokenRegistry.sol";
16
17
  import {VersionPart} from "../type/Version.sol";
17
18
 
@@ -360,6 +361,14 @@ contract RegistryAdmin is
360
361
  functions[13] = toFunction(StakingStore.unstakeUpTo.selector, "unstakeUpTo");
361
362
  _authorizeTargetFunctions(_stakingStore, stakingRoleId, functions);
362
363
 
364
+ // grant token handler authorizations
365
+ IStaking staking = IStaking(_staking);
366
+ functions = new FunctionInfo[](2);
367
+ functions[0] = toFunction(TokenHandler.collectTokens.selector, "collectTokens");
368
+ functions[1] = toFunction(TokenHandler.distributeTokens.selector, "distributeTokens");
369
+ // FIXME: replace this with a more specific role instead if public role - access to token handler must be restricted
370
+ _authorizeTargetFunctions(address(staking.getTokenHandler()), PUBLIC_ROLE(), functions);
371
+
363
372
  _grantRoleToAccount(stakingRoleId, _staking);
364
373
  }
365
374
  }
@@ -124,35 +124,22 @@ abstract contract Component is
124
124
  {
125
125
  // checks
126
126
  address currentWallet = getWallet();
127
- IERC20Metadata token = getToken();
128
- uint256 currentBalance = token.balanceOf(currentWallet);
129
-
130
- if (currentBalance > 0) {
131
- if (currentWallet == address(this)) {
132
- // move tokens from component smart contract to external wallet
133
- } else {
134
- // move tokens from external wallet to component smart contract or another external wallet
135
- uint256 allowance = token.allowance(currentWallet, address(getTokenHandler()));
136
- if (allowance < currentBalance) {
137
- revert ErrorComponentWalletAllowanceTooSmall(currentWallet, newWallet, allowance, currentBalance);
138
- }
139
- }
140
- }
127
+ uint256 currentBalance = getToken().balanceOf(currentWallet);
141
128
 
142
129
  // effects
143
130
  _setWallet(newWallet);
144
131
 
145
132
  // interactions
146
133
  if (currentBalance > 0) {
134
+ // move tokens from old to new wallet
147
135
  emit LogComponentWalletTokensTransferred(currentWallet, newWallet, currentBalance);
148
136
 
149
- // transfer tokens from current wallet to new wallet
150
137
  if (currentWallet == address(this)) {
151
- // transferFrom requires self allowance too
152
- token.approve(address(getTokenHandler()), currentBalance);
138
+ // transfer from the component requires an allowance
139
+ getTokenHandler().distributeTokens(currentWallet, newWallet, AmountLib.toAmount(currentBalance));
140
+ } else {
141
+ getTokenHandler().collectTokens(currentWallet, newWallet, AmountLib.toAmount(currentBalance));
153
142
  }
154
-
155
- getTokenHandler().transfer(currentWallet, newWallet, AmountLib.toAmount(currentBalance));
156
143
  }
157
144
  }
158
145
 
@@ -1,8 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
-
6
4
  import {Amount, AmountLib} from "../type/Amount.sol";
7
5
  import {ComponentVerifyingService} from "../shared/ComponentVerifyingService.sol";
8
6
  import {Fee, FeeLib} from "../type/Fee.sol";
@@ -115,22 +113,13 @@ contract ComponentService is
115
113
  }
116
114
  }
117
115
 
118
- // check allowance
119
- TokenHandler tokenHandler = info.tokenHandler;
120
- IERC20Metadata token = IERC20Metadata(info.token);
121
- uint256 tokenAllowance = token.allowance(componentWallet, address(tokenHandler));
122
- if (tokenAllowance < withdrawnAmount.toInt()) {
123
- revert ErrorComponentServiceWalletAllowanceTooSmall(componentWallet, address(tokenHandler), tokenAllowance, withdrawnAmount.toInt());
124
- }
125
-
126
116
  // decrease fee counters by withdrawnAmount
127
117
  _changeTargetBalance(DECREASE, instance.getInstanceStore(), componentNftId, AmountLib.zero(), withdrawnAmount);
128
118
 
129
119
  // transfer amount to component owner
130
120
  address componentOwner = getRegistry().ownerOf(componentNftId);
131
- emit LogComponentServiceComponentFeesWithdrawn(componentNftId, componentOwner, address(token), withdrawnAmount);
132
- // TODO: centralize token handling (issue #471)
133
- tokenHandler.transfer(componentWallet, componentOwner, withdrawnAmount);
121
+ emit LogComponentServiceComponentFeesWithdrawn(componentNftId, componentOwner, address(info.token), withdrawnAmount);
122
+ info.tokenHandler.distributeTokens(componentWallet, componentOwner, withdrawnAmount);
134
123
  }
135
124
 
136
125
 
@@ -522,22 +511,24 @@ contract ComponentService is
522
511
 
523
512
  component.linkToRegisteredNftId();
524
513
 
525
- // setup initial component authorization
526
- _instanceService.initializeAuthorization(
527
- instance.getNftId(),
528
- component);
529
-
530
514
  // save amended component info with instance
531
515
  instanceReader = instance.getInstanceReader();
532
516
  instanceStore = instance.getInstanceStore();
533
517
 
534
518
  IComponents.ComponentInfo memory componentInfo = component.getInitialComponentInfo();
535
- componentInfo.tokenHandler = new TokenHandler(address(componentInfo.token));
519
+ componentInfo.tokenHandler = new TokenHandler(
520
+ address(componentInfo.token),
521
+ address(instance.getInstanceAdmin().authority()));
536
522
 
537
523
  instanceStore.createComponent(
538
524
  component.getNftId(),
539
525
  componentInfo);
540
526
 
527
+ // setup initial component authorization
528
+ _instanceService.initializeAuthorization(
529
+ instance.getNftId(),
530
+ component);
531
+
541
532
  // TODO add logging
542
533
  }
543
534