@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
@@ -104,32 +104,9 @@ contract InstanceService is
104
104
  // tx sender will become instance owner
105
105
  address instanceOwner = msg.sender;
106
106
 
107
- // start with setting up a new OZ access manager
108
- AccessManagerCloneable clonedAccessManager = AccessManagerCloneable(
109
- Clones.clone(_masterAccessManager));
110
-
111
- // set up the instance admin
112
- InstanceAdmin clonedInstanceAdmin = InstanceAdmin(Clones.clone(_masterInstanceAdmin));
113
- clonedAccessManager.initialize(
114
- address(clonedInstanceAdmin)); // grant ADMIN_ROLE to instance admin
115
-
116
- clonedInstanceAdmin.initialize(
117
- clonedAccessManager,
118
- InstanceAdmin(_masterInstanceAdmin).getInstanceAuthorization());
119
-
120
- InstanceStore clonedInstanceStore = InstanceStore(Clones.clone(address(_masterInstanceStore)));
121
- BundleSet clonedBundleSet = BundleSet(Clones.clone(_masterInstanceBundleSet));
122
- InstanceReader clonedInstanceReader = InstanceReader(Clones.clone(address(_masterInstanceReader)));
123
-
124
- // clone instance
125
- clonedInstance = Instance(Clones.clone(_masterInstance));
126
- clonedInstance.initialize(
127
- clonedInstanceAdmin,
128
- clonedInstanceStore,
129
- clonedBundleSet,
130
- clonedInstanceReader,
131
- getRegistry(),
132
- instanceOwner);
107
+ // create instance admin and instance
108
+ InstanceAdmin instanceAdmin = _createInstanceAdmin();
109
+ clonedInstance = _createInstance(instanceAdmin, instanceOwner);
133
110
 
134
111
  // register cloned instance with registry
135
112
  clonedInstanceNftId = _registryService.registerInstance(
@@ -142,7 +119,7 @@ contract InstanceService is
142
119
  TargetManagerLib.getDefaultRewardRate());
143
120
 
144
121
  // MUST be set after instance is set up and registered
145
- clonedInstanceAdmin.initializeInstanceAuthorization(address(clonedInstance));
122
+ instanceAdmin.initializeInstanceAuthorization(address(clonedInstance));
146
123
 
147
124
  emit LogInstanceCloned(
148
125
  clonedInstanceNftId,
@@ -362,6 +339,53 @@ contract InstanceService is
362
339
  );
363
340
  }
364
341
 
342
+ /// @dev create new cloned instance admin
343
+ /// function used to setup a new instance
344
+ function _createInstanceAdmin()
345
+ internal
346
+ virtual
347
+ returns (InstanceAdmin clonedInstanceAdmin)
348
+ {
349
+ // start with setting up a new OZ access manager
350
+ AccessManagerCloneable clonedAccessManager = AccessManagerCloneable(
351
+ Clones.clone(_masterAccessManager));
352
+
353
+ // set up the instance admin
354
+ clonedInstanceAdmin = InstanceAdmin(Clones.clone(_masterInstanceAdmin));
355
+ clonedAccessManager.initialize(
356
+ address(clonedInstanceAdmin)); // grant ADMIN_ROLE to instance admin
357
+
358
+ clonedInstanceAdmin.initialize(
359
+ clonedAccessManager,
360
+ InstanceAdmin(_masterInstanceAdmin).getInstanceAuthorization());
361
+ }
362
+
363
+
364
+ /// @dev create new cloned instance
365
+ /// function used to setup a new instance
366
+ function _createInstance(
367
+ InstanceAdmin instanceAdmin,
368
+ address instanceOwner
369
+ )
370
+ internal
371
+ virtual
372
+ returns (Instance clonedInstance)
373
+ {
374
+ InstanceStore clonedInstanceStore = InstanceStore(Clones.clone(address(_masterInstanceStore)));
375
+ BundleSet clonedBundleSet = BundleSet(Clones.clone(_masterInstanceBundleSet));
376
+ InstanceReader clonedInstanceReader = InstanceReader(Clones.clone(address(_masterInstanceReader)));
377
+
378
+ // clone instance
379
+ clonedInstance = Instance(Clones.clone(_masterInstance));
380
+ clonedInstance.initialize(
381
+ instanceAdmin,
382
+ clonedInstanceStore,
383
+ clonedBundleSet,
384
+ clonedInstanceReader,
385
+ getRegistry(),
386
+ instanceOwner);
387
+ }
388
+
365
389
 
366
390
  /// all gif targets MUST be children of instanceNftId
367
391
  function _createGifTarget(
@@ -7,7 +7,7 @@ import {Amount} from "../type/Amount.sol";
7
7
  import {Key32} from "../type/Key32.sol";
8
8
  import {NftId} from "../type/NftId.sol";
9
9
  import {ClaimId} from "../type/ClaimId.sol";
10
- import {ObjectType, BUNDLE, POLICY, POOL, PRODUCT, COMPONENT, DISTRIBUTOR, DISTRIBUTOR_TYPE} from "../type/ObjectType.sol";
10
+ import {ObjectType, BUNDLE, POLICY, POOL, PRODUCT, COMPONENT, DISTRIBUTOR} from "../type/ObjectType.sol";
11
11
  import {RequestId} from "../type/RequestId.sol";
12
12
  import {RiskId} from "../type/RiskId.sol";
13
13
  import {StateId} from "../type/StateId.sol";
@@ -116,6 +116,7 @@ contract InstanceStore is
116
116
 
117
117
  //--- Distributor -------------------------------------------------------//
118
118
  function createDistributor(NftId distributorNftId, IDistribution.DistributorInfo memory info) external restricted() {
119
+ _registerBalanceTarget(distributorNftId);
119
120
  _create(_toNftKey32(distributorNftId, DISTRIBUTOR()), abi.encode(info));
120
121
  }
121
122
 
@@ -54,9 +54,7 @@ contract ObjectLifecycle is
54
54
  setStateTransition(POLICY(), APPLIED(), REVOKED());
55
55
  setStateTransition(POLICY(), APPLIED(), DECLINED());
56
56
  setStateTransition(POLICY(), APPLIED(), COLLATERALIZED());
57
- setStateTransition(POLICY(), APPLIED(), ACTIVE());
58
- setStateTransition(POLICY(), COLLATERALIZED(), ACTIVE());
59
- setStateTransition(POLICY(), ACTIVE(), CLOSED());
57
+ setStateTransition(POLICY(), COLLATERALIZED(), CLOSED());
60
58
  }
61
59
 
62
60
  function _setupClaimLifecycle() private {
@@ -68,6 +66,7 @@ contract ObjectLifecycle is
68
66
 
69
67
  function _setupPayoutLifecycle() private {
70
68
  setInitialState(PAYOUT(), EXPECTED());
69
+ // TODO: add state cancelled
71
70
  setStateTransition(PAYOUT(), EXPECTED(), PAID());
72
71
  }
73
72
 
@@ -13,7 +13,7 @@ interface IBundle {
13
13
  NftId poolNftId;
14
14
  Fee fee; // bundle fee on net premium amounts
15
15
  bytes filter; // required conditions for applications to be considered for collateralization by this bundle
16
- Seconds lifetime; // lifetime of bundle after creation
16
+ Timestamp activatedAt;
17
17
  Timestamp expiredAt; // no new policies starting with this timestamp
18
18
  Timestamp closedAt; // no open policies, locked amount = 0
19
19
  }
@@ -21,7 +21,6 @@ interface IComponents {
21
21
  bytes data; // will hold component type specific additional info (eg encoded pool info)
22
22
  }
23
23
 
24
-
25
24
  struct ProductInfo {
26
25
  NftId distributionNftId;
27
26
  NftId poolNftId;
@@ -36,17 +35,12 @@ interface IComponents {
36
35
 
37
36
 
38
37
  struct PoolInfo {
39
- NftId productNftId; // the nft of the product this pool is linked to
40
38
  RoleId bundleOwnerRole; // the required role for bundle owners
41
- // TODO maxCapitalAmount -> maxBalanceAmount
42
- Amount maxCapitalAmount; // max capital amount allowed for pool
39
+ Amount maxBalanceAmount; // max balance amount allowed for pool
43
40
  bool isInterceptingBundleTransfers; // intercepts nft transfers for bundles
44
41
  bool isExternallyManaged; // funding bundles is restricted to book keeping, actual funds may be provided as needed to support payouts
45
42
  bool isVerifyingApplications; // underwriting requires the pool component checks/confirms the applications
46
43
  UFixed collateralizationLevel; // factor to calculate collateral for sum insurance (default 100%)
47
44
  UFixed retentionLevel; // amount of collateral held in pool (default 100%)
48
- Fee poolFee; // pool fee on net premium
49
- Fee stakingFee; // pool fee on staked capital from investor
50
- Fee performanceFee; // pool fee on profits from capital investors
51
45
  }
52
46
  }
@@ -25,7 +25,6 @@ interface IDistribution {
25
25
  DistributorType distributorType;
26
26
  bool active;
27
27
  bytes data;
28
- Amount commissionAmount;
29
28
  uint32 numPoliciesSold;
30
29
  }
31
30
 
@@ -22,7 +22,7 @@ interface IPolicy {
22
22
  uint256 netPremiumAmount;
23
23
  // fullPremium = netPremium + all fixed amounts + all variable amounts (excl commission and minDistribtuionOwnerFee variable part)
24
24
  uint256 fullPremiumAmount;
25
- // premium = fullPremium - discount
25
+ // effective premium = fullPremium - discount
26
26
  uint256 premiumAmount;
27
27
  uint256 productFeeFixAmount;
28
28
  uint256 poolFeeFixAmount;
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
4
+ import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5
5
 
6
6
  contract Dip is ERC20 {
7
7
 
@@ -11,7 +11,8 @@ import {UFixed} from "../type/UFixed.sol";
11
11
  import {Timestamp} from "../type/Timestamp.sol";
12
12
 
13
13
  interface IOracleComponent is IInstanceLinkedComponent {
14
-
14
+ error ErrorOracleNotImplemented(string methodName);
15
+
15
16
  /// @dev callback method for requesting some data from the oracle
16
17
  function request(
17
18
  RequestId requestId,
@@ -1,19 +1,17 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
+ import {Amount} from "../type/Amount.sol";
4
5
  import {COMPONENT, ORACLE} from "../type/ObjectType.sol";
5
6
  import {IAuthorization} from "../authorization/IAuthorization.sol";
6
7
  import {IComponentService} from "../shared/IComponentService.sol";
8
+ import {IInstanceLinkedComponent} from "../shared/IInstanceLinkedComponent.sol";
7
9
  import {IOracleComponent} from "./IOracleComponent.sol";
8
10
  import {IOracleService} from "./IOracleService.sol";
9
- import {IRegistry} from "../registry/IRegistry.sol";
10
- import {ITransferInterceptor} from "../registry/ITransferInterceptor.sol";
11
- import {NftId, NftIdLib} from "../type/NftId.sol";
11
+ import {NftId} from "../type/NftId.sol";
12
12
  import {InstanceLinkedComponent} from "../shared/InstanceLinkedComponent.sol";
13
- import {InstanceReader} from "../instance/InstanceReader.sol";
14
13
  import {RequestId} from "../type/RequestId.sol";
15
- import {Timestamp, TimestampLib} from "../type/Timestamp.sol";
16
- import {UFixed} from "../type/UFixed.sol";
14
+ import {Timestamp} from "../type/Timestamp.sol";
17
15
 
18
16
 
19
17
  abstract contract Oracle is
@@ -73,6 +71,17 @@ abstract contract Oracle is
73
71
  return false;
74
72
  }
75
73
 
74
+ function withdrawFees(Amount amount)
75
+ external
76
+ virtual
77
+ override(IInstanceLinkedComponent, InstanceLinkedComponent)
78
+ onlyOwner()
79
+ restricted()
80
+ returns (Amount withdrawnAmount)
81
+ {
82
+ revert ErrorOracleNotImplemented("withdrawFees");
83
+ }
84
+
76
85
 
77
86
  function _initializeOracle(
78
87
  address registry,
@@ -14,6 +14,7 @@ import {NftId, NftIdLib} from "../type/NftId.sol";
14
14
  import {BUNDLE, COMPONENT, POOL} from "../type/ObjectType.sol";
15
15
  import {RoleId, PUBLIC_ROLE} from "../type/RoleId.sol";
16
16
  import {Seconds} from "../type/Seconds.sol";
17
+ import {Timestamp} from "../type/Timestamp.sol";
17
18
  import {TokenHandler} from "../shared/TokenHandler.sol";
18
19
  import {UFixed, UFixedLib} from "../type/UFixed.sol";
19
20
 
@@ -81,8 +82,9 @@ abstract contract BasicPool is
81
82
  virtual
82
83
  restricted()
83
84
  onlyBundleOwner(bundleNftId)
85
+ returns(Timestamp newExpiredAt)
84
86
  {
85
- _extend(bundleNftId, lifetimeExtension);
87
+ return _extend(bundleNftId, lifetimeExtension);
86
88
  }
87
89
 
88
90
 
@@ -106,13 +108,13 @@ abstract contract BasicPool is
106
108
  }
107
109
 
108
110
 
109
- function close(NftId bundleNftId)
111
+ function closeBundle(NftId bundleNftId)
110
112
  public
111
113
  virtual
112
114
  restricted()
113
115
  onlyBundleOwner(bundleNftId)
114
116
  {
115
- _close(bundleNftId);
117
+ _closeBundle(bundleNftId);
116
118
  }
117
119
 
118
120
 
@@ -129,13 +131,13 @@ abstract contract BasicPool is
129
131
  }
130
132
 
131
133
 
132
- function setMaxCapitalAmount(Amount maxCapitalAmount)
134
+ function setMaxBalanceAmount(Amount maxBalanceAmount)
133
135
  public
134
136
  virtual
135
137
  restricted()
136
138
  onlyOwner()
137
139
  {
138
- _setMaxCapitalAmount(maxCapitalAmount);
140
+ _setMaxBalanceAmount(maxBalanceAmount);
139
141
  }
140
142
 
141
143
 
@@ -4,6 +4,8 @@ pragma solidity ^0.8.20;
4
4
  import {Authorization} from "../authorization/Authorization.sol";
5
5
  import {BasicPool} from "./BasicPool.sol";
6
6
  import {IAccess} from "../authorization/IAccess.sol";
7
+ import {IInstanceLinkedComponent} from "../shared/IInstanceLinkedComponent.sol";
8
+ import {IPoolComponent} from "./IPoolComponent.sol";
7
9
  import {POOL} from "../type/ObjectType.sol";
8
10
  import {PUBLIC_ROLE} from "../../contracts/type/RoleId.sol";
9
11
  import {RoleId} from "../type/RoleId.sol";
@@ -38,12 +40,19 @@ contract BasicPoolAuthorization
38
40
  _authorize(functions, BasicPool.extend.selector, "extend");
39
41
  _authorize(functions, BasicPool.lockBundle.selector, "lockBundle");
40
42
  _authorize(functions, BasicPool.unlockBundle.selector, "unlockBundle");
41
- _authorize(functions, BasicPool.close.selector, "close");
43
+ _authorize(functions, BasicPool.closeBundle.selector, "closeBundle");
42
44
  _authorize(functions, BasicPool.setBundleFee.selector, "setBundleFee");
43
45
 
44
- _authorize(functions, BasicPool.setMaxCapitalAmount.selector, "setMaxCapitalAmount");
46
+ _authorize(functions, BasicPool.setMaxBalanceAmount.selector, "setMaxBalanceAmount");
45
47
  _authorize(functions, BasicPool.setBundleOwnerRole.selector, "setBundleOwnerRole");
46
48
  _authorize(functions, BasicPool.setFees.selector, "setFees");
49
+ _authorize(functions, BasicPool.stake.selector, "stake");
50
+ _authorize(functions, BasicPool.unstake.selector, "unstake");
51
+ _authorize(functions, BasicPool.extend.selector, "extend");
52
+
53
+ _authorize(functions, IInstanceLinkedComponent.withdrawFees.selector, "withdrawFees");
54
+
55
+ _authorize(functions, IPoolComponent.withdrawBundleFees.selector, "withdrawBundleFees");
47
56
  }
48
57
  }
49
58
 
@@ -3,6 +3,7 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {IBundle} from "../instance/module/IBundle.sol";
5
5
  import {IBundleService} from "./IBundleService.sol";
6
+ import {IComponents} from "../instance/module/IComponents.sol";
6
7
  import {IComponentService} from "../shared/IComponentService.sol";
7
8
  import {IRegistry} from "../registry/IRegistry.sol";
8
9
  import {IRegistryService} from "../registry/IRegistryService.sol";
@@ -19,7 +20,8 @@ import {NftId, NftIdLib} from "../type/NftId.sol";
19
20
  import {ObjectType, COMPONENT, POOL, BUNDLE, REGISTRY} from "../type/ObjectType.sol";
20
21
  import {StateId, ACTIVE, PAUSED, CLOSED, KEEP_STATE} from "../type/StateId.sol";
21
22
  import {Seconds} from "../type/Seconds.sol";
22
- import {TimestampLib, zeroTimestamp} from "../type/Timestamp.sol";
23
+ import {Timestamp, TimestampLib, zeroTimestamp} from "../type/Timestamp.sol";
24
+ import {TokenTransferLib} from "../shared/TokenTransferLib.sol";
23
25
 
24
26
  string constant BUNDLE_SERVICE_NAME = "BundleService";
25
27
 
@@ -27,8 +29,7 @@ contract BundleService is
27
29
  ComponentVerifyingService,
28
30
  IBundleService
29
31
  {
30
- using NftIdLib for NftId;
31
-
32
+
32
33
  string public constant NAME = "BundleService";
33
34
 
34
35
  address private _registryAddress;
@@ -111,13 +112,15 @@ contract BundleService is
111
112
  InstanceStore instanceStore = instance.getInstanceStore();
112
113
  instanceStore.createBundle(
113
114
  bundleNftId,
114
- IBundle.BundleInfo(
115
- poolNftId,
116
- bundleFee,
117
- filter,
118
- lifetime,
119
- TimestampLib.blockTimestamp().addSeconds(lifetime),
120
- zeroTimestamp()));
115
+ IBundle.BundleInfo({
116
+ poolNftId: poolNftId,
117
+ fee: bundleFee,
118
+ filter: filter,
119
+ activatedAt: TimestampLib.blockTimestamp(),
120
+ expiredAt: TimestampLib.blockTimestamp().addSeconds(lifetime),
121
+ closedAt: zeroTimestamp()
122
+ })
123
+ );
121
124
 
122
125
  // bundle book keeping
123
126
  _componentService.increaseBundleBalance(
@@ -129,7 +132,6 @@ contract BundleService is
129
132
  // put bundle under bundle managemet
130
133
  BundleSet bundleManager = instance.getBundleSet();
131
134
  bundleManager.add(bundleNftId);
132
-
133
135
  // TODO add logging
134
136
  }
135
137
 
@@ -146,7 +148,7 @@ contract BundleService is
146
148
  restricted()
147
149
  {
148
150
  InstanceReader instanceReader = instance.getInstanceReader();
149
- StateId bundleState = instanceReader.getMetadata(bundleNftId.toKey32(BUNDLE())).state;
151
+ StateId bundleState = instance.getInstanceReader().getBundleState(bundleNftId);
150
152
  IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
151
153
 
152
154
  // ensure bundle is active and not yet expired
@@ -216,9 +218,9 @@ contract BundleService is
216
218
  external
217
219
  virtual
218
220
  restricted
221
+ returns (Amount unstakedAmount, Amount feeAmount)
219
222
  {
220
- // udpate bundle state
221
- instance.getInstanceStore().updateBundleState(bundleNftId, CLOSED());
223
+ InstanceReader instanceReader = instance.getInstanceReader();
222
224
 
223
225
  // ensure no open policies attached to bundle
224
226
  BundleSet bundleManager = instance.getBundleSet();
@@ -227,8 +229,117 @@ contract BundleService is
227
229
  revert ErrorBundleServiceBundleWithOpenPolicies(bundleNftId, openPolicies);
228
230
  }
229
231
 
230
- // update set of active bundles
231
- bundleManager.lock(bundleNftId);
232
+ {
233
+ // update bundle state
234
+ InstanceStore instanceStore = instance.getInstanceStore();
235
+ instanceStore.updateBundleState(bundleNftId, CLOSED());
236
+ bundleManager.lock(bundleNftId);
237
+
238
+ // decrease bundle counters
239
+ Amount balanceAmountWithFees = instanceReader.getBalanceAmount(bundleNftId);
240
+ feeAmount = instanceReader.getFeeAmount(bundleNftId);
241
+ unstakedAmount = balanceAmountWithFees - feeAmount;
242
+ _componentService.decreaseBundleBalance(instanceStore, bundleNftId, unstakedAmount, feeAmount);
243
+ }
244
+ }
245
+
246
+ /// @inheritdoc IBundleService
247
+ function stake(
248
+ IInstance instance,
249
+ NftId bundleNftId,
250
+ Amount amount
251
+ )
252
+ external
253
+ virtual
254
+ // TODO: restricted() (once #462 is done)
255
+ {
256
+ IBundle.BundleInfo memory bundleInfo = instance.getInstanceReader().getBundleInfo(bundleNftId);
257
+ StateId bundleState = instance.getInstanceReader().getBundleState(bundleNftId);
258
+
259
+ if( (bundleState != ACTIVE() && bundleState != PAUSED()) // locked bundles can be staked
260
+ || bundleInfo.expiredAt < TimestampLib.blockTimestamp()
261
+ || bundleInfo.closedAt.gtz()) {
262
+ revert ErrorBundleServiceBundleNotOpen(bundleNftId, bundleState, bundleInfo.expiredAt);
263
+ }
264
+
265
+ _componentService.increaseBundleBalance(
266
+ instance.getInstanceStore(),
267
+ bundleNftId,
268
+ amount,
269
+ AmountLib.zero());
270
+ }
271
+
272
+ /// @inheritdoc IBundleService
273
+ function unstake(
274
+ IInstance instance,
275
+ NftId bundleNftId,
276
+ Amount amount
277
+ )
278
+ external
279
+ virtual
280
+ // TODO: restricted() (once #462 is done)
281
+ returns (Amount unstakedAmount)
282
+ {
283
+ InstanceStore instanceStore = instance.getInstanceStore();
284
+ (
285
+ Amount balanceAmount,
286
+ Amount lockedAmount,
287
+ Amount feeAmount
288
+ ) = instanceStore.getAmounts(bundleNftId);
289
+
290
+ Amount unstakedAmount = amount;
291
+ Amount availableAmount = balanceAmount - (lockedAmount + feeAmount);
292
+
293
+ // if amount is max, then unstake all available
294
+ if (amount.gte(AmountLib.max())) {
295
+ unstakedAmount = availableAmount;
296
+ }
297
+
298
+ // ensure unstaked amount does not exceed available amount
299
+ if (unstakedAmount > availableAmount) {
300
+ revert ErrorBundleServiceUnstakeAmountExceedsLimit(amount, availableAmount);
301
+ }
302
+
303
+ _componentService.decreaseBundleBalance(
304
+ instanceStore,
305
+ bundleNftId,
306
+ unstakedAmount,
307
+ AmountLib.zero());
308
+
309
+ return unstakedAmount;
310
+ }
311
+
312
+ /// @inheritdoc IBundleService
313
+ function extend(NftId bundleNftId, Seconds lifetimeExtension)
314
+ external
315
+ virtual
316
+ // TODO: restricted() (once #462 is done)
317
+ returns (Timestamp extendedExpiredAt)
318
+ {
319
+ (NftId poolNftId,, IInstance instance) = _getAndVerifyActiveComponent(POOL());
320
+ IBundle.BundleInfo memory bundleInfo = instance.getInstanceReader().getBundleInfo(bundleNftId);
321
+ StateId bundleState = instance.getInstanceReader().getBundleState(bundleNftId);
322
+
323
+ // ensure bundle belongs to the pool
324
+ if (bundleInfo.poolNftId != poolNftId) {
325
+ revert ErrorBundleServiceBundlePoolMismatch(bundleNftId, bundleInfo.poolNftId, poolNftId);
326
+ }
327
+
328
+ // ensure bundle is active and not yet expired
329
+ if(bundleState != ACTIVE() || bundleInfo.expiredAt < TimestampLib.blockTimestamp()) {
330
+ revert ErrorBundleServiceBundleNotOpen(bundleNftId, bundleState, bundleInfo.expiredAt);
331
+ }
332
+
333
+ if (lifetimeExtension.eqz()) {
334
+ revert ErrorBundleServiceExtensionLifetimeIsZero();
335
+ }
336
+
337
+ bundleInfo.expiredAt = bundleInfo.expiredAt.addSeconds(lifetimeExtension);
338
+ instance.getInstanceStore().updateBundle(bundleNftId, bundleInfo, KEEP_STATE());
339
+
340
+ emit LogBundleServiceBundleExtended(bundleNftId, lifetimeExtension, bundleInfo.expiredAt);
341
+
342
+ return bundleInfo.expiredAt;
232
343
  }
233
344
 
234
345
 
@@ -262,6 +373,48 @@ contract BundleService is
262
373
  instance.getBundleSet().unlinkPolicy(policyNftId);
263
374
  }
264
375
 
376
+ /// @inheritdoc IBundleService
377
+ function withdrawBundleFees(NftId bundleNftId, Amount amount)
378
+ public
379
+ virtual
380
+ // TODO: restricted() (once #462 is done)
381
+ returns (Amount withdrawnAmount)
382
+ {
383
+ (NftId poolNftId,, IInstance instance) = _getAndVerifyActiveComponent(POOL());
384
+ InstanceReader reader = instance.getInstanceReader();
385
+
386
+ IComponents.ComponentInfo memory poolInfo = reader.getComponentInfo(poolNftId);
387
+ address poolWallet = poolInfo.wallet;
388
+
389
+ IBundle.BundleInfo memory bundleInfo = reader.getBundleInfo(bundleNftId);
390
+
391
+ // determine withdrawn amount
392
+ withdrawnAmount = amount;
393
+ if (withdrawnAmount.gte(AmountLib.max())) {
394
+ withdrawnAmount = reader.getFeeAmount(bundleNftId);
395
+ } else {
396
+ if (withdrawnAmount.gt(reader.getFeeAmount(bundleNftId))) {
397
+ revert ErrorBundleServiceFeesWithdrawAmountExceedsLimit(withdrawnAmount, reader.getFeeAmount(bundleNftId));
398
+ }
399
+ }
400
+
401
+ // decrease fee counters by withdrawnAmount
402
+ {
403
+ InstanceStore store = instance.getInstanceStore();
404
+ // decrease fee amount of the bundle
405
+ _componentService.decreaseBundleBalance(store, bundleNftId, AmountLib.zero(), withdrawnAmount);
406
+ // decrease pool balance
407
+ _componentService.decreasePoolBalance(store, poolNftId, withdrawnAmount, AmountLib.zero());
408
+ }
409
+
410
+ // transfer amount to bundle owner
411
+ {
412
+ address owner = getRegistry().ownerOf(bundleNftId);
413
+ emit LogBundleServiceFeesWithdrawn(bundleNftId, owner, address(poolInfo.token), withdrawnAmount);
414
+ TokenTransferLib.distributeTokens(poolWallet, owner, withdrawnAmount, poolInfo.tokenHandler);
415
+ }
416
+ }
417
+
265
418
  /// @dev links policy to bundle
266
419
  function _linkPolicy(IInstance instance, NftId policyNftId)
267
420
  internal
@@ -26,6 +26,15 @@ interface IBundleService is IService {
26
26
 
27
27
  error ErrorBundleServicePolicyNotCloseable(NftId policyNftId);
28
28
 
29
+ error ErrorBundleServiceFeesWithdrawAmountExceedsLimit(Amount amount, Amount limit);
30
+
31
+ error ErrorBundleServiceUnstakeAmountExceedsLimit(Amount amount, Amount limit);
32
+
33
+ error ErrorBundleServiceExtensionLifetimeIsZero();
34
+
35
+ event LogBundleServiceFeesWithdrawn(NftId bundleNftId, address recipient, address tokenAddress, Amount amount);
36
+ event LogBundleServiceBundleExtended(NftId bundleNftId, Seconds lifetimeExtension, Timestamp extendedExpiredAt);
37
+
29
38
  /// @dev create a new bundle for the specified attributes
30
39
  /// may only be called by pool service
31
40
  function create(
@@ -41,11 +50,20 @@ interface IBundleService is IService {
41
50
  returns(NftId bundleNftId); // the nft id of the newly created bundle
42
51
 
43
52
 
44
- /// @dev increase bundle stakes by the specified amount
45
- /// may only be called by the bundle owner
46
- // function stake(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
53
+ /// @dev increase bundle stakes by the specified amount. bundle must not be expired or closed
54
+ /// may only be called by the pool service
55
+ function stake(IInstance instance, NftId bundleNftId, Amount amount) external;
56
+
57
+ /// @dev decrease bundle stakes by the specified amount
58
+ /// may only be called by the pool service
59
+ /// @param instance the instance relevant for the bundle
60
+ /// @param bundleNftId the bundle nft id
61
+ /// @param amount the amount to unstake (set to AmountLib.max() to unstake all available stakes)
62
+ /// @return unstakedAmount the effective unstaked amount
63
+ function unstake(IInstance instance, NftId bundleNftId, Amount amount) external returns (Amount unstakedAmount);
47
64
 
48
- // function unstake(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
65
+ /// @dev extend the lifetime of the bundle by the specified time in seconds
66
+ function extend(NftId bundleNftId, Seconds lifetimeExtension) external returns (Timestamp extendedExpiredAt);
49
67
 
50
68
  /// @dev locks the specified bundle, locked bundles are not available to collateralize new policies
51
69
  /// only active bundles may be locked
@@ -61,10 +79,12 @@ interface IBundleService is IService {
61
79
  /// only open bundles (active or locked) may be closed
62
80
  /// to close a bundle it may not have any non-closed polices attached to it
63
81
  /// may only be called by registered and unlocked pool components
82
+ /// @return balanceAmount the unstaked amount that was remaining in the bundle
83
+ /// @return feeAmount the fee amount that was remaining for the bundle
64
84
  function close(
65
85
  IInstance instance,
66
86
  NftId bundleNftId
67
- ) external;
87
+ ) external returns (Amount balanceAmount, Amount feeAmount);
68
88
 
69
89
  /// @dev set bundle fee to provided value
70
90
  /// may only be called by registered and unlocked pool components
@@ -103,4 +123,11 @@ interface IBundleService is IService {
103
123
  IInstance instance,
104
124
  NftId policyNftId
105
125
  ) external;
126
+
127
+ /// @dev Withdraw bundle feeds for the given bundle
128
+ /// @param bundleNftId the bundle Nft Id
129
+ /// @param amount the amount to withdraw. If set to AMOUNT_MAX, the full commission available is withdrawn
130
+ /// @return withdrawnAmount the effective withdrawn amount
131
+ function withdrawBundleFees(NftId bundleNftId, Amount amount) external returns (Amount withdrawnAmount);
132
+
106
133
  }
@@ -46,6 +46,12 @@ interface IPoolComponent is IInstanceLinkedComponent {
46
46
  view
47
47
  returns (bool isMatching);
48
48
 
49
+ /// @dev Withdraw bundle feeds for the given bundle
50
+ /// @param bundleNftId the bundle Nft Id
51
+ /// @param amount the amount to withdraw. If set to AMOUNT_MAX, the full commission available is withdrawn
52
+ /// @return withdrawnAmount the effective withdrawn amount
53
+ function withdrawBundleFees(NftId bundleNftId, Amount amount) external returns (Amount withdrawnAmount);
54
+
49
55
  /// @dev returns initial pool specific infos for this pool
50
56
  function getInitialPoolInfo() external view returns (IComponents.PoolInfo memory info);
51
57