@etherisc/gif-next 0.0.2-b3a8633-027 → 0.0.2-b3a9c97-695

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 (332) hide show
  1. package/README.md +16 -2
  2. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.dbg.json +1 -1
  3. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.json +21 -21
  4. package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.dbg.json +1 -1
  5. package/artifacts/contracts/authorization/Authorization.sol/Authorization.dbg.json +1 -1
  6. package/artifacts/contracts/authorization/Authorization.sol/Authorization.json +2 -2
  7. package/artifacts/contracts/authorization/IAccess.sol/IAccess.dbg.json +1 -1
  8. package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.dbg.json +1 -1
  9. package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.dbg.json +1 -1
  10. package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.dbg.json +1 -1
  11. package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +1 -1
  12. package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.dbg.json +1 -1
  13. package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.json +2 -2
  14. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +1 -1
  15. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.json +2 -2
  16. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.dbg.json +1 -1
  17. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.json +77 -64
  18. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.dbg.json +1 -1
  19. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.json +16 -16
  20. package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
  21. package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +43 -38
  22. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
  23. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +237 -74
  24. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  25. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +66 -38
  26. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  27. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +43 -0
  28. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  29. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +71 -0
  30. package/artifacts/contracts/instance/BundleSet.sol/BundleSet.dbg.json +1 -1
  31. package/artifacts/contracts/instance/BundleSet.sol/BundleSet.json +2 -2
  32. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  33. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  34. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  35. package/artifacts/contracts/instance/Instance.sol/Instance.json +2 -2
  36. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
  37. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +44 -44
  38. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +1 -1
  39. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +14 -14
  40. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  41. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +80 -122
  42. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  43. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +16 -16
  44. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  45. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +9 -9
  46. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
  47. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +72 -194
  48. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +1 -1
  49. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.json +2 -2
  50. package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
  51. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.dbg.json +1 -1
  52. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.json +2 -2
  53. package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.dbg.json +1 -1
  54. package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.json +2 -2
  55. package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.dbg.json +1 -1
  56. package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.json +2 -2
  57. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  58. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  59. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
  60. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  61. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  62. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  63. package/artifacts/contracts/mock/Dip.sol/Dip.dbg.json +1 -1
  64. package/artifacts/contracts/mock/Dip.sol/Dip.json +2 -2
  65. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.dbg.json +1 -1
  66. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.json +51 -51
  67. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +1 -1
  68. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +2 -2
  69. package/artifacts/contracts/oracle/IOracle.sol/IOracle.dbg.json +1 -1
  70. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.dbg.json +1 -1
  71. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.json +30 -0
  72. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
  73. package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
  74. package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +27 -35
  75. package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
  76. package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +2 -2
  77. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
  78. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +2 -2
  79. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +1 -1
  80. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +54 -99
  81. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +1 -1
  82. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +16 -16
  83. package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
  84. package/artifacts/contracts/pool/BundleService.sol/BundleService.json +438 -51
  85. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  86. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +102 -26
  87. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
  88. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +205 -1
  89. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  90. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +44 -57
  91. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
  92. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +158 -54
  93. package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
  94. package/artifacts/contracts/pool/Pool.sol/Pool.json +44 -95
  95. package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
  96. package/artifacts/contracts/pool/PoolService.sol/PoolService.json +281 -90
  97. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  98. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +47 -19
  99. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  100. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +21 -32
  101. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  102. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +9 -17
  103. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +1 -1
  104. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +19 -38
  105. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +1 -1
  106. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +16 -16
  107. package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
  108. package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +129 -58
  109. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  110. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +42 -30
  111. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  112. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.json +5 -0
  113. package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
  114. package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +16 -0
  115. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  116. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +188 -108
  117. package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
  118. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  119. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +19 -0
  120. package/artifacts/contracts/product/IProductService.sol/IProductService.dbg.json +1 -1
  121. package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
  122. package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +339 -167
  123. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  124. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +66 -26
  125. package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
  126. package/artifacts/contracts/product/PricingService.sol/PricingService.json +7 -2
  127. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
  128. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +2 -2
  129. package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
  130. package/artifacts/contracts/product/Product.sol/Product.json +19 -38
  131. package/artifacts/contracts/product/ProductService.sol/ProductService.dbg.json +1 -1
  132. package/artifacts/contracts/product/ProductService.sol/ProductService.json +2 -2
  133. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  134. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +2 -2
  135. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  136. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +16 -40
  137. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  138. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +12 -1
  139. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  140. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  141. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  142. package/artifacts/contracts/registry/Registry.sol/Registry.json +50 -165
  143. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
  144. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +114 -239
  145. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  146. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +2 -2
  147. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  148. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +2 -2
  149. package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.dbg.json +1 -1
  150. package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.dbg.json +1 -1
  151. package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.json +35 -16
  152. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +1 -1
  153. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +2 -2
  154. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  155. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  156. package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
  157. package/artifacts/contracts/shared/Component.sol/Component.json +0 -38
  158. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
  159. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +326 -62
  160. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
  161. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +72 -32
  162. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +1 -1
  163. package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
  164. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
  165. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.json +153 -0
  166. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
  167. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +19 -0
  168. package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  169. package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  170. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  171. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  172. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  173. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  174. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  175. package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.dbg.json +1 -1
  176. package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.dbg.json +4 -0
  177. package/artifacts/contracts/shared/{ERC165.sol/ERC165.json → InitializableERC165.sol/InitializableERC165.json} +4 -4
  178. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
  179. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.json +19 -38
  180. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  181. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  182. package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.dbg.json +1 -1
  183. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  184. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  185. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  186. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
  187. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  188. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  189. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  190. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  191. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  192. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  193. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +53 -6
  194. package/artifacts/contracts/shared/TokenTransferLib.sol/TokenTransferLib.dbg.json +4 -0
  195. package/artifacts/contracts/shared/TokenTransferLib.sol/TokenTransferLib.json +42 -0
  196. package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
  197. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
  198. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +1 -1
  199. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +12 -2
  200. package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
  201. package/artifacts/contracts/staking/Staking.sol/Staking.json +60 -74
  202. package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +1 -1
  203. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
  204. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +31 -19
  205. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
  206. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +2 -2
  207. package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
  208. package/artifacts/contracts/staking/StakingService.sol/StakingService.json +22 -22
  209. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
  210. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +12 -12
  211. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
  212. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +17 -12
  213. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
  214. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +7 -2
  215. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  216. package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
  217. package/artifacts/contracts/type/Amount.sol/AmountLib.json +37 -8
  218. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  219. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.json +2 -2
  220. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  221. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  222. package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
  223. package/artifacts/contracts/type/Fee.sol/FeeLib.json +7 -2
  224. package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
  225. package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
  226. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  227. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  228. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  229. package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
  230. package/artifacts/contracts/type/Referral.sol/ReferralLib.json +2 -2
  231. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.dbg.json +1 -1
  232. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
  233. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
  234. package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
  235. package/artifacts/contracts/type/Seconds.sol/SecondsLib.json +26 -2
  236. package/artifacts/contracts/type/Selector.sol/SelectorLib.dbg.json +1 -1
  237. package/artifacts/contracts/type/Selector.sol/SelectorSetLib.dbg.json +1 -1
  238. package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
  239. package/artifacts/contracts/type/String.sol/StrLib.dbg.json +1 -1
  240. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
  241. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.json +23 -4
  242. package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +1 -1
  243. package/artifacts/contracts/type/UFixed.sol/MathLib.json +9 -3
  244. package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
  245. package/artifacts/contracts/type/UFixed.sol/UFixedLib.json +39 -2
  246. package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
  247. package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
  248. package/artifacts/contracts/upgradeability/IVersionable.sol/IVersionable.dbg.json +1 -1
  249. package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  250. package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.json +2 -2
  251. package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  252. package/artifacts/contracts/upgradeability/Versionable.sol/Versionable.dbg.json +1 -1
  253. package/contracts/authorization/AccessAdmin.sol +1 -0
  254. package/contracts/distribution/BasicDistribution.sol +4 -15
  255. package/contracts/distribution/BasicDistributionAuthorization.sol +5 -1
  256. package/contracts/distribution/Distribution.sol +22 -10
  257. package/contracts/distribution/DistributionService.sol +46 -11
  258. package/contracts/distribution/IDistributionComponent.sol +8 -4
  259. package/contracts/distribution/IDistributionService.sol +10 -0
  260. package/contracts/instance/InstanceAuthorizationV3.sol +2 -0
  261. package/contracts/instance/InstanceReader.sol +10 -7
  262. package/contracts/instance/InstanceService.sol +51 -27
  263. package/contracts/instance/InstanceStore.sol +2 -1
  264. package/contracts/instance/base/ObjectLifecycle.sol +2 -3
  265. package/contracts/instance/module/IBundle.sol +1 -1
  266. package/contracts/instance/module/IComponents.sol +1 -7
  267. package/contracts/instance/module/IDistribution.sol +0 -1
  268. package/contracts/instance/module/IPolicy.sol +1 -1
  269. package/contracts/mock/Dip.sol +1 -1
  270. package/contracts/oracle/IOracleComponent.sol +2 -1
  271. package/contracts/oracle/Oracle.sol +15 -6
  272. package/contracts/pool/BasicPool.sol +7 -5
  273. package/contracts/pool/BasicPoolAuthorization.sol +11 -2
  274. package/contracts/pool/BundleService.sol +169 -16
  275. package/contracts/pool/IBundleService.sol +32 -5
  276. package/contracts/pool/IPoolComponent.sol +6 -0
  277. package/contracts/pool/IPoolService.sol +14 -17
  278. package/contracts/pool/Pool.sol +32 -15
  279. package/contracts/pool/PoolService.sol +146 -58
  280. package/contracts/product/ApplicationService.sol +37 -17
  281. package/contracts/product/BasicProduct.sol +3 -33
  282. package/contracts/product/BasicProductAuthorization.sol +3 -0
  283. package/contracts/product/ClaimService.sol +9 -8
  284. package/contracts/product/IApplicationService.sol +1 -0
  285. package/contracts/product/IClaimService.sol +1 -0
  286. package/contracts/product/IPolicyService.sol +23 -17
  287. package/contracts/product/IProductComponent.sol +1 -0
  288. package/contracts/product/PolicyService.sol +251 -131
  289. package/contracts/product/PricingService.sol +5 -1
  290. package/contracts/product/Product.sol +27 -6
  291. package/contracts/registry/ChainNft.sol +27 -28
  292. package/contracts/registry/IRegistry.sol +3 -2
  293. package/contracts/registry/Registry.sol +69 -60
  294. package/contracts/registry/RegistryAdmin.sol +49 -131
  295. package/contracts/registry/ReleaseRegistry.sol +24 -72
  296. package/contracts/shared/Component.sol +21 -21
  297. package/contracts/shared/ComponentService.sol +73 -14
  298. package/contracts/shared/IComponent.sol +4 -3
  299. package/contracts/shared/IComponentService.sol +15 -9
  300. package/contracts/shared/IInstanceLinkedComponent.sol +9 -3
  301. package/contracts/shared/{ERC165.sol → InitializableERC165.sol} +1 -1
  302. package/contracts/shared/InstanceLinkedComponent.sol +21 -0
  303. package/contracts/shared/NftOwnable.sol +2 -2
  304. package/contracts/shared/PolicyHolder.sol +2 -5
  305. package/contracts/shared/TokenHandler.sol +4 -0
  306. package/contracts/shared/TokenTransferLib.sol +60 -0
  307. package/contracts/staking/Staking.sol +9 -3
  308. package/contracts/staking/StakingService.sol +8 -12
  309. package/contracts/type/Amount.sol +12 -5
  310. package/contracts/type/Blocknumber.sol +7 -1
  311. package/contracts/type/Referral.sol +1 -0
  312. package/contracts/type/Seconds.sol +13 -1
  313. package/contracts/type/Timestamp.sol +11 -1
  314. package/contracts/type/UFixed.sol +29 -10
  315. package/package.json +1 -1
  316. package/artifacts/contracts/registry/GlobalRegistry.sol/GlobalRegistry.dbg.json +0 -4
  317. package/artifacts/contracts/registry/GlobalRegistry.sol/GlobalRegistry.json +0 -1503
  318. package/artifacts/contracts/registry/GlobalRegistryAdmin.sol/GlobalRegistryAdmin.dbg.json +0 -4
  319. package/artifacts/contracts/registry/GlobalRegistryAdmin.sol/GlobalRegistryAdmin.json +0 -1881
  320. package/artifacts/contracts/registry/IGlobalRegistry.sol/IGlobalRegistry.dbg.json +0 -4
  321. package/artifacts/contracts/registry/IGlobalRegistry.sol/IGlobalRegistry.json +0 -974
  322. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +0 -4
  323. package/artifacts/contracts/shared/MainnetId.sol/MainnetContract.dbg.json +0 -4
  324. package/artifacts/contracts/shared/MainnetId.sol/MainnetContract.json +0 -34
  325. package/artifacts/contracts/shared/MainnetId.sol/MainnetId.dbg.json +0 -4
  326. package/artifacts/contracts/shared/MainnetId.sol/MainnetId.json +0 -24
  327. package/artifacts/contracts/shared/MainnetId.sol/SidenetContract.dbg.json +0 -4
  328. package/artifacts/contracts/shared/MainnetId.sol/SidenetContract.json +0 -34
  329. package/contracts/registry/GlobalRegistry.sol +0 -95
  330. package/contracts/registry/GlobalRegistryAdmin.sol +0 -38
  331. package/contracts/registry/IGlobalRegistry.sol +0 -17
  332. package/contracts/shared/MainnetId.sol +0 -29
@@ -4,30 +4,28 @@ pragma solidity ^0.8.20;
4
4
  import {Amount, AmountLib} from "../type/Amount.sol";
5
5
  import {ComponentVerifyingService} from "../shared/ComponentVerifyingService.sol";
6
6
  import {Fee, FeeLib} from "../type/Fee.sol";
7
+ import {IComponents} from "../instance/module/IComponents.sol";
8
+ import {IComponentService} from "./IComponentService.sol";
9
+ import {IInstance} from "../instance/IInstance.sol";
7
10
  import {IInstanceLinkedComponent} from "./IInstanceLinkedComponent.sol";
11
+ import {InstanceReader} from "../instance/InstanceReader.sol";
12
+ import {InstanceStore} from "../instance/InstanceStore.sol";
13
+ import {IInstanceService} from "../instance/IInstanceService.sol";
14
+ import {IPoolComponent} from "../pool/IPoolComponent.sol";
15
+ import {IProductComponent} from "../product/IProductComponent.sol";
8
16
  import {IRegistry} from "../registry/IRegistry.sol";
9
17
  import {IRegistryService} from "../registry/IRegistryService.sol";
10
- import {IInstance} from "../instance/IInstance.sol";
11
- import {IAccess} from "../instance/module/IAccess.sol";
18
+ import {KEEP_STATE} from "../type/StateId.sol";
12
19
  import {NftId} from "../type/NftId.sol";
13
20
  import {ObjectType, REGISTRY, COMPONENT, DISTRIBUTION, INSTANCE, ORACLE, POOL, PRODUCT} from "../type/ObjectType.sol";
14
21
  import {RoleId, DISTRIBUTION_OWNER_ROLE, ORACLE_OWNER_ROLE, POOL_OWNER_ROLE, PRODUCT_OWNER_ROLE} from "../type/RoleId.sol";
15
- import {KEEP_STATE} from "../type/StateId.sol";
16
- import {IComponents} from "../instance/module/IComponents.sol";
17
- import {IComponentService} from "./IComponentService.sol";
18
- import {IDistributionComponent} from "../distribution/IDistributionComponent.sol";
19
- import {IInstanceService} from "../instance/IInstanceService.sol";
20
- import {IPoolComponent} from "../pool/IPoolComponent.sol";
21
- import {IProductComponent} from "../product/IProductComponent.sol";
22
- import {InstanceReader} from "../instance/InstanceReader.sol";
23
- import {InstanceStore} from "../instance/InstanceStore.sol";
24
22
  import {TokenHandler} from "./TokenHandler.sol";
23
+ import {TokenTransferLib} from "../shared/TokenTransferLib.sol";
25
24
 
26
25
  contract ComponentService is
27
26
  ComponentVerifyingService,
28
27
  IComponentService
29
28
  {
30
-
31
29
  error ErrorComponentServiceAlreadyRegistered(address component);
32
30
  error ErrorComponentServiceNotComponent(address component);
33
31
  error ErrorComponentServiceInvalidType(address component, ObjectType requiredType, ObjectType componentType);
@@ -94,6 +92,37 @@ contract ComponentService is
94
92
  // TODO implement
95
93
  function unlock() external virtual {}
96
94
 
95
+ function withdrawFees(Amount amount)
96
+ external
97
+ virtual
98
+ returns (Amount withdrawnAmount)
99
+ {
100
+ (NftId componentNftId,, IInstance instance) = _getAndVerifyActiveComponent(COMPONENT());
101
+ IComponents.ComponentInfo memory info = instance.getInstanceReader().getComponentInfo(componentNftId);
102
+ address componentWallet = info.wallet;
103
+
104
+ // determine withdrawn amount
105
+ withdrawnAmount = amount;
106
+ if (withdrawnAmount.gte(AmountLib.max())) {
107
+ withdrawnAmount = instance.getInstanceReader().getFeeAmount(componentNftId);
108
+ } else if (withdrawnAmount.eqz()) {
109
+ revert ErrorComponentServiceWithdrawAmountIsZero();
110
+ } else {
111
+ Amount withdrawLimit = instance.getInstanceReader().getFeeAmount(componentNftId);
112
+ if (withdrawnAmount.gt(withdrawLimit)) {
113
+ revert ErrorComponentServiceWithdrawAmountExceedsLimit(withdrawnAmount, withdrawLimit);
114
+ }
115
+ }
116
+
117
+ // decrease fee counters by withdrawnAmount
118
+ _changeTargetBalance(DECREASE, instance.getInstanceStore(), componentNftId, AmountLib.zero(), withdrawnAmount);
119
+
120
+ // transfer amount to component owner
121
+ address componentOwner = getRegistry().ownerOf(componentNftId);
122
+ emit LogComponentServiceComponentFeesWithdrawn(componentNftId, componentOwner, address(info.token), withdrawnAmount);
123
+ TokenTransferLib.distributeTokens(componentWallet, componentOwner, withdrawnAmount, info.tokenHandler);
124
+ }
125
+
97
126
 
98
127
  //-------- product ------------------------------------------------------//
99
128
 
@@ -112,7 +141,7 @@ contract ComponentService is
112
141
  contractAddress,
113
142
  PRODUCT(),
114
143
  PRODUCT_OWNER_ROLE());
115
-
144
+
116
145
  // create product info
117
146
  IComponents.ProductInfo memory productInfo = IProductComponent(contractAddress).getInitialProductInfo();
118
147
  instanceStore.createProduct(productNftId, productInfo);
@@ -255,6 +284,36 @@ contract ComponentService is
255
284
  _changeTargetBalance(DECREASE, instanceStore, distributionNftId, amount, feeAmount);
256
285
  }
257
286
 
287
+ //-------- distributor -------------------------------------------------------//
288
+
289
+ function increaseDistributorBalance(
290
+ InstanceStore instanceStore,
291
+ NftId distributorNftId,
292
+ Amount amount,
293
+ Amount feeAmount
294
+ )
295
+ external
296
+ virtual
297
+ // TODO re-enable once role granting is stable and fixed
298
+ // restricted()
299
+ {
300
+ _changeTargetBalance(INCREASE, instanceStore, distributorNftId, amount, feeAmount);
301
+ }
302
+
303
+ function decreaseDistributorBalance(
304
+ InstanceStore instanceStore,
305
+ NftId distributorNftId,
306
+ Amount amount,
307
+ Amount feeAmount
308
+ )
309
+ external
310
+ virtual
311
+ // TODO re-enable once role granting is stable and fixed
312
+ // restricted()
313
+ {
314
+ _changeTargetBalance(DECREASE, instanceStore, distributorNftId, amount, feeAmount);
315
+ }
316
+
258
317
  //-------- oracle -------------------------------------------------------//
259
318
 
260
319
  function registerOracle()
@@ -462,7 +521,7 @@ contract ComponentService is
462
521
  instanceReader = instance.getInstanceReader();
463
522
  instanceStore = instance.getInstanceStore();
464
523
 
465
- IComponents.ComponentInfo memory componentInfo = component.getComponentInfo();
524
+ IComponents.ComponentInfo memory componentInfo = component.getInitialComponentInfo();
466
525
  componentInfo.tokenHandler = new TokenHandler(address(componentInfo.token));
467
526
 
468
527
  instanceStore.createComponent(
@@ -35,10 +35,11 @@ interface IComponent is
35
35
  /// only component owner (nft holder) is authorizes to call this function
36
36
  function approveTokenHandler(Amount spendingLimitAmount) external;
37
37
 
38
- /// @dev sets the wallet address for the component
39
- /// if the current wallet has tokens, these will be transferred
38
+ /// @dev sets the wallet address for the component.
39
+ /// if the current wallet has tokens, these will be transferred.
40
40
  /// if the new wallet address is externally owned, an approval from the
41
- /// owner of the external wallet for the component to move all tokens must exist
41
+ /// owner of the external wallet to the tokenhandler of the component that
42
+ /// covers the current component balance must exist
42
43
  function setWallet(address walletAddress) external;
43
44
 
44
45
  /// @dev returns the name of this component
@@ -1,21 +1,12 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
5
- import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
6
4
 
7
5
  import {Amount} from "../type/Amount.sol";
8
6
  import {Fee} from "../type/Fee.sol";
9
- import {IComponents} from "../instance/module/IComponents.sol";
10
- import {IInstance} from "../instance/IInstance.sol";
11
- import {IInstanceService} from "../instance/IInstanceService.sol";
12
7
  import {InstanceStore} from "../instance/InstanceStore.sol";
13
- import {IProductService} from "../product/IProductService.sol";
14
- import {IRegisterable} from "../shared/IRegisterable.sol";
15
8
  import {IService} from "../shared/IService.sol";
16
9
  import {NftId} from "../type/NftId.sol";
17
- import {ObjectType} from "../type/ObjectType.sol";
18
- import {TokenHandler} from "../shared/TokenHandler.sol";
19
10
  import {UFixed} from "../type/UFixed.sol";
20
11
 
21
12
  /// @dev component base class
@@ -27,7 +18,12 @@ interface IComponentService is
27
18
  error ErrorComponentServiceWalletAddressZero();
28
19
  error ErrorComponentServiceWalletAddressIsSameAsCurrent();
29
20
 
21
+ error ErrorComponentServiceWithdrawAmountIsZero();
22
+ error ErrorComponentServiceWithdrawAmountExceedsLimit(Amount withdrawnAmount, Amount withdrawLimit);
23
+ error ErrorComponentServiceWalletAllowanceTooSmall(address wallet, address spender, uint256 allowance, uint256 amount);
24
+
30
25
  event LogComponentServiceWalletAddressChanged(NftId componentNftId, address currentWallet, address newWallet);
26
+ event LogComponentServiceComponentFeesWithdrawn(NftId componentNftId, address recipient, address token, Amount withdrawnAmount);
31
27
  event LogComponentServiceProductFeesUpdated(NftId productNftId);
32
28
  event LogComponentServiceDistributionFeesUpdated(NftId distributionNftId);
33
29
  event LogComponentServicePoolFeesUpdated(NftId poolNftId);
@@ -51,6 +47,11 @@ interface IComponentService is
51
47
  /// @dev unlocks the component associated with the caller
52
48
  function unlock() external;
53
49
 
50
+ /// @dev Withdraw fees from the distribution component. Only component owner is allowed to withdraw fees.
51
+ /// @param withdrawAmount the amount to withdraw
52
+ /// @return withdrawnAmount the amount that was actually withdrawn
53
+ function withdrawFees(Amount withdrawAmount) external returns (Amount withdrawnAmount);
54
+
54
55
  //-------- product ------------------------------------------------------//
55
56
 
56
57
  /// @dev registers the sending component as a product component
@@ -77,6 +78,10 @@ interface IComponentService is
77
78
  function increaseDistributionBalance(InstanceStore instanceStore, NftId distributionNftId, Amount amount, Amount feeAmount) external;
78
79
  function decreaseDistributionBalance(InstanceStore instanceStore, NftId distributionNftId, Amount amount, Amount feeAmount) external;
79
80
 
81
+ //-------- distributor --------------------------------------------------//
82
+ function increaseDistributorBalance(InstanceStore instanceStore, NftId distributorNftId, Amount amount, Amount feeAmount) external;
83
+ function decreaseDistributorBalance(InstanceStore instanceStore, NftId distributorNftId, Amount amount, Amount feeAmount) external;
84
+
80
85
  //-------- oracle -------------------------------------------------------//
81
86
 
82
87
  /// @dev registers the sending component as an oracle component
@@ -99,4 +104,5 @@ interface IComponentService is
99
104
  //-------- bundle -------------------------------------------------------//
100
105
  function increaseBundleBalance(InstanceStore instanceStore, NftId bundleNftId, Amount amount, Amount feeAmount) external;
101
106
  function decreaseBundleBalance(InstanceStore instanceStore, NftId bundleNftId, Amount amount, Amount feeAmount) external;
107
+
102
108
  }
@@ -4,6 +4,7 @@ pragma solidity ^0.8.20;
4
4
  import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
5
5
  import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
6
6
 
7
+ import {Amount} from "../type/Amount.sol";
7
8
  import {IComponent} from "../shared/IComponent.sol";
8
9
  import {IAuthorization} from "../authorization/IAuthorization.sol";
9
10
  import {IComponents} from "../instance/module/IComponents.sol";
@@ -37,14 +38,19 @@ interface IInstanceLinkedComponent is
37
38
  /// only component owner (nft holder) is authorizes to call this function
38
39
  function unlock() external;
39
40
 
41
+ /// @dev Withdraw fees from the distribution component. Only component owner is allowed to withdraw fees.
42
+ /// @param amount the amount to withdraw
43
+ /// @return withdrawnAmount the amount that was actually withdrawn
44
+ function withdrawFees(Amount amount) external returns (Amount withdrawnAmount);
45
+
40
46
  /// @dev defines the instance to which this component is linked to
41
47
  function getInstance() external view returns (IInstance instance);
42
48
 
49
+ /// @dev returns the initial component authorization specification.
50
+ function getAuthorization() external view returns (IAuthorization authorization);
51
+
43
52
  /// @dev defines the product to which this component is linked to
44
53
  /// this is only relevant for pool and distribution components
45
54
  function getProductNftId() external view returns (NftId productNftId);
46
55
 
47
- /// @dev returns the initial component authorization specification.
48
- function getAuthorization() external view returns (IAuthorization authorization);
49
-
50
56
  }
@@ -4,7 +4,7 @@ pragma solidity ^0.8.20;
4
4
  import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
5
5
  import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
6
6
 
7
- contract ERC165 is
7
+ contract InitializableERC165 is
8
8
  Initializable,
9
9
  IERC165
10
10
  {
@@ -6,6 +6,7 @@ import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessMana
6
6
  import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
7
7
  import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
8
8
 
9
+ import {Amount} from "../type/Amount.sol";
9
10
  import {Component} from "./Component.sol";
10
11
  import {IComponentService} from "./IComponentService.sol";
11
12
  import {IInstanceLinkedComponent} from "./IInstanceLinkedComponent.sol";
@@ -36,6 +37,7 @@ abstract contract InstanceLinkedComponent is
36
37
  IInstance _instance; // instance for this component
37
38
  InstanceReader _instanceReader; // instance reader for this component
38
39
  IAuthorization _initialAuthorization;
40
+ IComponentService _componentService;
39
41
  }
40
42
 
41
43
  function lock() external onlyOwner {
@@ -58,6 +60,17 @@ abstract contract InstanceLinkedComponent is
58
60
  return _getInstanceLinkedComponentStorage()._initialAuthorization;
59
61
  }
60
62
 
63
+ /// @inheritdoc IInstanceLinkedComponent
64
+ function withdrawFees(Amount amount)
65
+ external
66
+ virtual
67
+ onlyOwner()
68
+ restricted()
69
+ returns (Amount withdrawnAmount)
70
+ {
71
+ return _withdrawFees(amount);
72
+ }
73
+
61
74
  function _getInstanceLinkedComponentStorage() private pure returns (InstanceLinkedComponentStorage storage $) {
62
75
  assembly {
63
76
  $.slot := INSTANCE_LINKED_COMPONENT_LOCATION_V1
@@ -105,6 +118,7 @@ abstract contract InstanceLinkedComponent is
105
118
  // set component state
106
119
  $._instanceReader = $._instance.getInstanceReader();
107
120
  $._initialAuthorization = authorization;
121
+ $._componentService = IComponentService(_getServiceAddress(COMPONENT()));
108
122
 
109
123
  registerInterface(type(IAccessManaged).interfaceId);
110
124
  registerInterface(type(IInstanceLinkedComponent).interfaceId);
@@ -141,6 +155,13 @@ abstract contract InstanceLinkedComponent is
141
155
  return _getInstanceLinkedComponentStorage()._instanceReader;
142
156
  }
143
157
 
158
+ function _withdrawFees(Amount amount)
159
+ internal
160
+ returns (Amount withdrawnAmount)
161
+ {
162
+ return _getInstanceLinkedComponentStorage()._componentService.withdrawFees(amount);
163
+ }
164
+
144
165
 
145
166
  /// @dev returns the service address for the specified domain
146
167
  /// gets address via lookup from registry using the major version form the linked instance
@@ -1,13 +1,13 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {ERC165} from "./ERC165.sol";
4
+ import {InitializableERC165} from "./InitializableERC165.sol";
5
5
  import {INftOwnable} from "./INftOwnable.sol";
6
6
  import {NftId} from "../type/NftId.sol";
7
7
  import {RegistryLinked} from "./RegistryLinked.sol";
8
8
 
9
9
  contract NftOwnable is
10
- ERC165,
10
+ InitializableERC165,
11
11
  RegistryLinked,
12
12
  INftOwnable
13
13
  {
@@ -1,22 +1,19 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
5
4
  import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
6
- import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
7
5
 
8
6
  import {Amount} from "../type/Amount.sol";
9
7
  import {ClaimId} from "../type/ClaimId.sol";
10
- import {ERC165} from "./ERC165.sol";
8
+ import {InitializableERC165} from "./InitializableERC165.sol";
11
9
  import {IPolicyHolder} from "./IPolicyHolder.sol";
12
10
  import {NftId} from "../type/NftId.sol";
13
11
  import {PayoutId, PayoutIdLib} from "../type/PayoutId.sol";
14
12
  import {RegistryLinked} from "./RegistryLinked.sol";
15
- import {IRegistry} from "../registry/IRegistry.sol";
16
13
 
17
14
  /// @dev template implementation for IPolicyHolder
18
15
  contract PolicyHolder is
19
- ERC165,
16
+ InitializableERC165,
20
17
  RegistryLinked, // TODO need upgradeable version
21
18
  IPolicyHolder
22
19
  {
@@ -10,6 +10,8 @@ import {Amount} from "../type/Amount.sol";
10
10
  /// a default token contract is provided via contract constructor
11
11
  /// relies internally on oz SafeERC20.safeTransferFrom
12
12
  contract TokenHandler {
13
+ event LogTokenHandlerTokenTransfer(address token, address from, address to, uint256 amount);
14
+
13
15
  IERC20Metadata private _token;
14
16
 
15
17
  constructor(address token) {
@@ -24,6 +26,7 @@ contract TokenHandler {
24
26
  )
25
27
  external
26
28
  {
29
+ emit LogTokenHandlerTokenTransfer(address(_token), from, to, amount.toInt());
27
30
  SafeERC20.safeTransferFrom(
28
31
  _token,
29
32
  from,
@@ -40,6 +43,7 @@ contract TokenHandler {
40
43
  )
41
44
  external
42
45
  {
46
+ emit LogTokenHandlerTokenTransfer(token, from, to, amount.toInt());
43
47
  SafeERC20.safeTransferFrom(
44
48
  IERC20Metadata(token),
45
49
  from,
@@ -0,0 +1,60 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {Amount} from "../type/Amount.sol";
5
+ import {TokenHandler} from "../shared/TokenHandler.sol";
6
+
7
+ // library
8
+ library TokenTransferLib {
9
+
10
+ error ErrorTokenTransferLibAmountIsZero();
11
+ error ErrorTokenTransferLibAllowanceTooSmall(address from, address spender, uint256 allowance, uint256 amount);
12
+
13
+ /// @dev collect tokens from outside of the gif and transfer them to a wallet within the scope of gif
14
+ function collectTokens(
15
+ address from,
16
+ address to,
17
+ Amount amount,
18
+ TokenHandler tokenHandler
19
+ )
20
+ internal
21
+ {
22
+ _transfer(from, to, amount, tokenHandler);
23
+ }
24
+
25
+ /// @dev distribute tokens from a wallet within the scope of gif to an external address
26
+ function distributeTokens(
27
+ address from,
28
+ address to,
29
+ Amount amount,
30
+ TokenHandler tokenHandler
31
+ )
32
+ internal
33
+ {
34
+ _transfer(from, to, amount, tokenHandler);
35
+ }
36
+
37
+ function _transfer(
38
+ address from,
39
+ address to,
40
+ Amount amount,
41
+ TokenHandler tokenHandler
42
+ )
43
+ internal
44
+ {
45
+ if (amount.eqz()) {
46
+ revert ErrorTokenTransferLibAmountIsZero();
47
+ }
48
+
49
+ uint256 allowance = tokenHandler.getToken().allowance(from, address(tokenHandler));
50
+ if (allowance < amount.toInt()) {
51
+ revert ErrorTokenTransferLibAllowanceTooSmall(from, address(tokenHandler), allowance, amount.toInt());
52
+ }
53
+
54
+ tokenHandler.transfer(
55
+ from,
56
+ to,
57
+ amount);
58
+ }
59
+
60
+ }
@@ -8,6 +8,7 @@ import {IVersionable} from "../upgradeability/IVersionable.sol";
8
8
 
9
9
  import {Amount, AmountLib} from "../type/Amount.sol";
10
10
  import {Component} from "../shared/Component.sol";
11
+ import {IComponent} from "../shared/IComponent.sol";
11
12
  import {NftId} from "../type/NftId.sol";
12
13
  import {ObjectType, STAKING} from "../type/ObjectType.sol";
13
14
  import {Seconds} from "../type/Seconds.sol";
@@ -36,6 +37,7 @@ contract Staking is
36
37
  struct StakingStorage {
37
38
  IRegistryService _registryService;
38
39
  TokenRegistry _tokenRegistry;
40
+ TokenHandler _tokenHandler;
39
41
  StakingStore _store;
40
42
  StakingReader _reader;
41
43
  NftId _protocolNftId;
@@ -384,6 +386,7 @@ contract Staking is
384
386
  address(tokenHandler),
385
387
  dipAmount);
386
388
 
389
+ // TODO: centralize token handling (issue #471)
387
390
  tokenHandler.transfer(from, stakingWallet, dipAmount);
388
391
  }
389
392
 
@@ -400,7 +403,8 @@ contract Staking is
400
403
  stakingWallet,
401
404
  address(tokenHandler),
402
405
  dipAmount);
403
-
406
+
407
+ // TODO: centralize token handling (issue #471)
404
408
  tokenHandler.transfer(stakingWallet, to, dipAmount);
405
409
  }
406
410
 
@@ -419,6 +423,9 @@ contract Staking is
419
423
  return address(_getStakingStorage()._tokenRegistry);
420
424
  }
421
425
 
426
+ function getTokenHandler() public virtual override(Component, IComponent) view returns (TokenHandler tokenHandler) {
427
+ return _getStakingStorage()._tokenHandler;
428
+ }
422
429
 
423
430
  // from Versionable
424
431
  function getVersion()
@@ -489,14 +496,13 @@ contract Staking is
489
496
  "", // registry data
490
497
  ""); // component data
491
498
 
492
- _createAndSetTokenHandler();
493
-
494
499
  // wiring to external contracts
495
500
  StakingStorage storage $ = _getStakingStorage();
496
501
  $._protocolNftId = getRegistry().getProtocolNftId();
497
502
  $._store = StakingStore(stakingStoreAddress);
498
503
  $._reader = StakingStore(stakingStoreAddress).getStakingReader();
499
504
  $._tokenRegistry = TokenRegistry(tokenRegistryAddress);
505
+ $._tokenHandler = new TokenHandler(address(getToken()));
500
506
 
501
507
  registerInterface(type(IStaking).interfaceId);
502
508
  }
@@ -122,11 +122,10 @@ contract StakingService is
122
122
 
123
123
  // transfer withdrawal amount to target owner
124
124
  address instanceOwner = getRegistry().ownerOf(instanceNftId);
125
+ emit LogStakingServiceRewardReservesDecreased(instanceNftId, instanceOwner, dipAmount, newBalance);
125
126
  $._staking.transferDipAmount(
126
127
  instanceOwner,
127
128
  dipAmount);
128
-
129
- emit LogStakingServiceRewardReservesDecreased(instanceNftId, instanceOwner, dipAmount, newBalance);
130
129
  }
131
130
 
132
131
 
@@ -169,12 +168,12 @@ contract StakingService is
169
168
  targetNftId,
170
169
  dipAmount);
171
170
 
171
+ emit LogStakingServiceStakeCreated(stakeNftId, targetNftId, stakeOwner, dipAmount);
172
+
172
173
  // collect staked dip by staking
173
174
  $._staking.collectDipAmount(
174
175
  stakeOwner,
175
176
  dipAmount);
176
-
177
- emit LogStakingServiceStakeCreated(stakeNftId, targetNftId, stakeOwner, dipAmount);
178
177
  }
179
178
 
180
179
 
@@ -197,12 +196,11 @@ contract StakingService is
197
196
 
198
197
  // collect staked dip by staking
199
198
  if (dipAmount.gtz()) {
199
+ emit LogStakingServiceStakeIncreased(stakeNftId, stakeOwner, dipAmount, stakeBalance);
200
200
  $._staking.collectDipAmount(
201
201
  stakeOwner,
202
202
  dipAmount);
203
203
  }
204
-
205
- emit LogStakingServiceStakeIncreased(stakeNftId, stakeOwner, dipAmount, stakeBalance);
206
204
  }
207
205
 
208
206
 
@@ -247,11 +245,10 @@ contract StakingService is
247
245
  address stakeOwner = msg.sender;
248
246
 
249
247
  Amount rewardsClaimedAmount = $._staking.claimRewards(stakeNftId);
248
+ emit LogStakingServiceRewardsClaimed(stakeNftId, stakeOwner, rewardsClaimedAmount);
250
249
  $._staking.transferDipAmount(
251
250
  stakeOwner,
252
251
  rewardsClaimedAmount);
253
-
254
- emit LogStakingServiceRewardsClaimed(stakeNftId, stakeOwner, rewardsClaimedAmount);
255
252
  }
256
253
 
257
254
 
@@ -270,11 +267,10 @@ contract StakingService is
270
267
  ) = $._staking.unstake(stakeNftId);
271
268
 
272
269
  Amount totalAmount = unstakedAmount + rewardsClaimedAmount;
270
+ emit LogStakingServiceUnstaked(stakeNftId, stakeOwner, totalAmount);
273
271
  $._staking.transferDipAmount(
274
272
  stakeOwner,
275
273
  totalAmount);
276
-
277
- emit LogStakingServiceUnstaked(stakeNftId, stakeOwner, totalAmount);
278
274
  }
279
275
 
280
276
 
@@ -389,12 +385,12 @@ contract StakingService is
389
385
  StakingServiceStorage storage $ = _getStakingServiceStorage();
390
386
  newBalance = $._staking.refillRewardReserves(targetNftId, dipAmount);
391
387
 
388
+ emit LogStakingServiceRewardReservesIncreased(targetNftId, rewardProvider, dipAmount, newBalance);
389
+
392
390
  // collect reward dip from provider
393
391
  $._staking.collectDipAmount(
394
392
  rewardProvider,
395
393
  dipAmount);
396
-
397
- emit LogStakingServiceRewardReservesIncreased(targetNftId, rewardProvider, dipAmount, newBalance);
398
394
  }
399
395
 
400
396
 
@@ -12,13 +12,15 @@ using {
12
12
  nqAmount as !=,
13
13
  ltAmount as <,
14
14
  gtAmount as >,
15
+ AmountLib.add,
15
16
  AmountLib.eq,
16
17
  AmountLib.eqz,
17
18
  AmountLib.gtz,
19
+ AmountLib.gt,
20
+ AmountLib.gte,
21
+ AmountLib.multiplyWith,
18
22
  AmountLib.toInt,
19
- AmountLib.add,
20
- AmountLib.toUFixed,
21
- AmountLib.multiplyWith
23
+ AmountLib.toUFixed
22
24
  } for Amount global;
23
25
 
24
26
  function addAmount(Amount a, Amount b) pure returns (Amount) {
@@ -77,16 +79,21 @@ library AmountLib {
77
79
  return Amount.unwrap(amount1) == Amount.unwrap(amount2);
78
80
  }
79
81
 
80
- /// @dev return true if amount a1 is smaller than a2
82
+ /// @dev return true if amount a1 is less than a2
81
83
  function lt(Amount a1, Amount a2) public pure returns (bool) {
82
84
  return Amount.unwrap(a1) < Amount.unwrap(a2);
83
85
  }
84
86
 
85
- /// @dev return true if amount a1 is larger than a2
87
+ /// @dev return true if amount a1 is greater than a2
86
88
  function gt(Amount a1, Amount a2) public pure returns (bool) {
87
89
  return Amount.unwrap(a1) > Amount.unwrap(a2);
88
90
  }
89
91
 
92
+ /// @dev return true if amount a1 is greater or equal than a2
93
+ function gte(Amount a1, Amount a2) public pure returns (bool) {
94
+ return Amount.unwrap(a1) >= Amount.unwrap(a2);
95
+ }
96
+
90
97
  /// @dev return minimum of a1 and a2.
91
98
  function min(Amount a1, Amount a2) public pure returns (Amount) {
92
99
  if (Amount.unwrap(a1) < Amount.unwrap(a2)) {
@@ -11,8 +11,14 @@ using {
11
11
  eqBlocknumber as ==,
12
12
  neBlocknumber as !=,
13
13
  BlocknumberLib.toInt,
14
+ BlocknumberLib.eq,
15
+ BlocknumberLib.ne,
14
16
  BlocknumberLib.eqz,
15
- BlocknumberLib.gtz
17
+ BlocknumberLib.gtz,
18
+ BlocknumberLib.gt,
19
+ BlocknumberLib.gte,
20
+ BlocknumberLib.lt,
21
+ BlocknumberLib.lte
16
22
  } for Blocknumber global;
17
23
 
18
24
  /// @dev return true if Blocknumber a is greater than Blocknumber b
@@ -12,6 +12,7 @@ type ReferralStatus is uint8;
12
12
  using {
13
13
  eqReferralId as ==,
14
14
  neReferralId as !=,
15
+ ReferralLib.eqz,
15
16
  ReferralLib.toKey32
16
17
  } for ReferralId global;
17
18