@etherisc/gif-next 0.0.2-7f39e38-904 → 0.0.2-804cdbf-724

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 (441) hide show
  1. package/README.md +32 -3
  2. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.dbg.json +4 -0
  3. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.json +1253 -0
  4. package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.dbg.json +4 -0
  5. package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.json +1206 -0
  6. package/artifacts/contracts/authorization/Authorization.sol/Authorization.dbg.json +4 -0
  7. package/artifacts/contracts/authorization/Authorization.sol/Authorization.json +358 -0
  8. package/artifacts/contracts/authorization/IAccess.sol/IAccess.dbg.json +4 -0
  9. package/artifacts/contracts/authorization/IAccess.sol/IAccess.json +10 -0
  10. package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.dbg.json +4 -0
  11. package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.json +1032 -0
  12. package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.dbg.json +4 -0
  13. package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.json +258 -0
  14. package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.dbg.json +4 -0
  15. package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.json +290 -0
  16. package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +4 -0
  17. package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.json +148 -0
  18. package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.dbg.json +4 -0
  19. package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.json +390 -0
  20. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +4 -0
  21. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.json +190 -0
  22. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.dbg.json +4 -0
  23. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.json +1505 -0
  24. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.dbg.json +4 -0
  25. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.json +410 -0
  26. package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
  27. package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +36 -255
  28. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
  29. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +147 -96
  30. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  31. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +86 -59
  32. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  33. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +82 -151
  34. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  35. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +52 -17
  36. package/artifacts/contracts/instance/BundleSet.sol/BundleSet.dbg.json +4 -0
  37. package/artifacts/contracts/instance/BundleSet.sol/BundleSet.json +703 -0
  38. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  39. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +77 -78
  40. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  41. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +149 -52
  42. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  43. package/artifacts/contracts/instance/Instance.sol/Instance.json +91 -132
  44. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +4 -0
  45. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +1626 -0
  46. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +4 -0
  47. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +601 -0
  48. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  49. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +230 -65
  50. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  51. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +216 -119
  52. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  53. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +70 -51
  54. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
  55. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +260 -137
  56. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +1 -1
  57. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.json +2 -2
  58. package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
  59. package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.json +0 -53
  60. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.dbg.json +4 -0
  61. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.json +10 -0
  62. package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.dbg.json +4 -0
  63. package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.json +182 -0
  64. package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.dbg.json +4 -0
  65. package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.json +181 -0
  66. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +8 -116
  68. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  73. package/artifacts/contracts/mock/Dip.sol/Dip.dbg.json +1 -1
  74. package/artifacts/contracts/mock/Dip.sol/Dip.json +2 -2
  75. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.dbg.json +4 -0
  76. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.json +1155 -0
  77. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +4 -0
  78. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +418 -0
  79. package/artifacts/contracts/oracle/IOracle.sol/IOracle.dbg.json +4 -0
  80. package/artifacts/contracts/oracle/IOracle.sol/IOracle.json +52 -0
  81. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.dbg.json +4 -0
  82. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.json +772 -0
  83. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +4 -0
  84. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.json +675 -0
  85. package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +4 -0
  86. package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +1063 -0
  87. package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +4 -0
  88. package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +1034 -0
  89. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +4 -0
  90. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +730 -0
  91. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +4 -0
  92. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +1477 -0
  93. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +4 -0
  94. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +410 -0
  95. package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
  96. package/artifacts/contracts/pool/BundleService.sol/BundleService.json +102 -59
  97. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  98. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +74 -43
  99. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
  100. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +20 -1
  101. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  102. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +18 -207
  103. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
  104. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +35 -1
  105. package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
  106. package/artifacts/contracts/pool/Pool.sol/Pool.json +25 -315
  107. package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
  108. package/artifacts/contracts/pool/PoolService.sol/PoolService.json +84 -42
  109. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  110. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +63 -40
  111. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  112. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +79 -36
  113. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  114. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +68 -37
  115. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +4 -0
  116. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +1299 -0
  117. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +4 -0
  118. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +410 -0
  119. package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
  120. package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +119 -68
  121. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  122. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +88 -53
  123. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  124. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.json +20 -1
  125. package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
  126. package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +20 -1
  127. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  128. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +20 -1
  129. package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
  130. package/artifacts/contracts/product/IPricingService.sol/IPricingService.json +20 -1
  131. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  132. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +24 -47
  133. package/artifacts/contracts/product/IProductService.sol/IProductService.dbg.json +1 -1
  134. package/artifacts/contracts/product/IProductService.sol/IProductService.json +20 -1
  135. package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
  136. package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +97 -46
  137. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  138. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +77 -42
  139. package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
  140. package/artifacts/contracts/product/PricingService.sol/PricingService.json +105 -62
  141. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
  142. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +81 -50
  143. package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
  144. package/artifacts/contracts/product/Product.sol/Product.json +31 -165
  145. package/artifacts/contracts/product/ProductService.sol/ProductService.dbg.json +1 -1
  146. package/artifacts/contracts/product/ProductService.sol/ProductService.json +61 -26
  147. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  148. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +59 -32
  149. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  150. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  151. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  152. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +86 -74
  153. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  154. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +31 -184
  155. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  156. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  157. package/artifacts/contracts/registry/Registry.sol/Registry.json +255 -112
  158. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +4 -0
  159. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +1746 -0
  160. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  161. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +69 -15
  162. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  163. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +51 -35
  164. package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.dbg.json +4 -0
  165. package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.json +164 -0
  166. package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.dbg.json +4 -0
  167. package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.json +1159 -0
  168. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +4 -0
  169. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +214 -0
  170. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  171. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +19 -11
  172. package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
  173. package/artifacts/contracts/shared/Component.sol/Component.json +18 -12
  174. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
  175. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +96 -70
  176. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
  177. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +73 -54
  178. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +1 -1
  179. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.json +20 -1
  180. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  181. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  182. package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
  183. package/artifacts/contracts/shared/IComponent.sol/IComponent.json +11 -5
  184. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
  185. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.json +27 -1
  186. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
  187. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +24 -5
  188. package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  189. package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.json +11 -15
  190. package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  191. package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.json +0 -5
  192. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  193. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +7 -1
  194. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  195. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  196. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +7 -1
  197. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  198. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  199. package/artifacts/contracts/shared/IService.sol/IService.json +20 -1
  200. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  201. package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.dbg.json +4 -0
  202. package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.json +39 -0
  203. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
  204. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.json +31 -65
  205. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  206. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.json +15 -99
  207. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  208. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.json +4 -65
  209. package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.dbg.json +4 -0
  210. package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.json +306 -0
  211. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  212. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +13 -7
  213. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  214. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +6 -6
  215. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  216. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +35 -16
  217. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  218. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +14 -8
  219. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  220. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  221. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  222. package/artifacts/contracts/shared/Service.sol/Service.json +20 -1
  223. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  224. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +6 -6
  225. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  226. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  227. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  228. package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
  229. package/artifacts/contracts/staking/IStaking.sol/IStaking.json +121 -118
  230. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
  231. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.json +222 -71
  232. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +1 -1
  233. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +102 -44
  234. package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
  235. package/artifacts/contracts/staking/Staking.sol/Staking.json +186 -183
  236. package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +4 -0
  237. package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.json +164 -0
  238. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
  239. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +71 -58
  240. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
  241. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +263 -39
  242. package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
  243. package/artifacts/contracts/staking/StakingService.sol/StakingService.json +271 -135
  244. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
  245. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +67 -47
  246. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
  247. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +734 -187
  248. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
  249. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +95 -18
  250. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  251. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.json +2 -2
  252. package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
  253. package/artifacts/contracts/type/Amount.sol/AmountLib.json +68 -4
  254. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  255. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.json +2 -2
  256. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  257. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.json +4 -4
  258. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  259. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.json +4 -4
  260. package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
  261. package/artifacts/contracts/type/Fee.sol/FeeLib.json +12 -12
  262. package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
  263. package/artifacts/contracts/type/Key32.sol/Key32Lib.json +2 -2
  264. package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
  265. package/artifacts/contracts/type/NftId.sol/NftIdLib.json +28 -4
  266. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  267. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.json +2 -2
  268. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  269. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.json +149 -2
  270. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  271. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.json +4 -4
  272. package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
  273. package/artifacts/contracts/type/Referral.sol/ReferralLib.json +4 -4
  274. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.dbg.json +4 -0
  275. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.json +204 -0
  276. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
  277. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.json +4 -4
  278. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
  279. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +219 -6
  280. package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
  281. package/artifacts/contracts/type/Seconds.sol/SecondsLib.json +26 -2
  282. package/artifacts/contracts/type/Selector.sol/SelectorLib.dbg.json +4 -0
  283. package/artifacts/contracts/type/Selector.sol/SelectorLib.json +129 -0
  284. package/artifacts/contracts/type/Selector.sol/SelectorSetLib.dbg.json +4 -0
  285. package/artifacts/contracts/type/Selector.sol/SelectorSetLib.json +10 -0
  286. package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
  287. package/artifacts/contracts/type/StateId.sol/StateIdLib.json +2 -2
  288. package/artifacts/contracts/type/String.sol/StrLib.dbg.json +4 -0
  289. package/artifacts/contracts/type/String.sol/StrLib.json +132 -0
  290. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
  291. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.json +17 -4
  292. package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +1 -1
  293. package/artifacts/contracts/type/UFixed.sol/MathLib.json +2 -2
  294. package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
  295. package/artifacts/contracts/type/UFixed.sol/UFixedLib.json +21 -2
  296. package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
  297. package/artifacts/contracts/type/Version.sol/VersionLib.json +2 -2
  298. package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
  299. package/artifacts/contracts/type/Version.sol/VersionPartLib.json +21 -2
  300. package/contracts/authorization/AccessAdmin.sol +591 -0
  301. package/contracts/authorization/AccessManagerCloneable.sol +16 -0
  302. package/contracts/authorization/Authorization.sol +218 -0
  303. package/contracts/authorization/IAccess.sol +48 -0
  304. package/contracts/authorization/IAccessAdmin.sol +136 -0
  305. package/contracts/authorization/IAuthorization.sol +54 -0
  306. package/contracts/authorization/IModuleAuthorization.sol +21 -0
  307. package/contracts/authorization/IServiceAuthorization.sol +38 -0
  308. package/contracts/authorization/ModuleAuthorization.sol +78 -0
  309. package/contracts/authorization/ServiceAuthorization.sol +90 -0
  310. package/contracts/distribution/BasicDistribution.sol +149 -0
  311. package/contracts/distribution/BasicDistributionAuthorization.sol +43 -0
  312. package/contracts/distribution/Distribution.sol +126 -106
  313. package/contracts/distribution/DistributionService.sol +13 -9
  314. package/contracts/distribution/DistributionServiceManager.sol +0 -12
  315. package/contracts/distribution/IDistributionComponent.sol +17 -35
  316. package/contracts/distribution/IDistributionService.sol +5 -1
  317. package/contracts/instance/{BundleManager.sol → BundleSet.sol} +23 -23
  318. package/contracts/instance/IInstance.sol +25 -16
  319. package/contracts/instance/IInstanceService.sol +36 -27
  320. package/contracts/instance/Instance.sol +113 -87
  321. package/contracts/instance/InstanceAdmin.sol +266 -0
  322. package/contracts/instance/InstanceAuthorizationV3.sol +202 -0
  323. package/contracts/instance/InstanceReader.sol +52 -13
  324. package/contracts/instance/InstanceService.sol +175 -99
  325. package/contracts/instance/InstanceStore.sol +38 -22
  326. package/contracts/instance/base/BalanceStore.sol +11 -6
  327. package/contracts/instance/base/Cloneable.sol +2 -25
  328. package/contracts/instance/base/ObjectCounter.sol +21 -0
  329. package/contracts/instance/base/ObjectLifecycle.sol +106 -0
  330. package/contracts/instance/base/{ObjectManager.sol → ObjectSet.sol} +11 -14
  331. package/contracts/instance/module/IAccess.sol +2 -10
  332. package/contracts/oracle/BasicOracle.sol +48 -0
  333. package/contracts/oracle/BasicOracleAuthorization.sol +46 -0
  334. package/contracts/oracle/IOracle.sol +36 -0
  335. package/contracts/oracle/IOracleComponent.sol +32 -0
  336. package/contracts/oracle/IOracleService.sol +65 -0
  337. package/contracts/oracle/Oracle.sol +157 -0
  338. package/contracts/oracle/OracleService.sol +278 -0
  339. package/contracts/oracle/OracleServiceManager.sol +42 -0
  340. package/contracts/pool/BasicPool.sol +164 -0
  341. package/contracts/pool/BasicPoolAuthorization.sol +49 -0
  342. package/contracts/pool/BundleService.sol +26 -26
  343. package/contracts/pool/IPoolComponent.sol +0 -60
  344. package/contracts/pool/IPoolService.sol +3 -0
  345. package/contracts/pool/Pool.sol +143 -131
  346. package/contracts/pool/PoolService.sol +38 -11
  347. package/contracts/product/ApplicationService.sol +5 -5
  348. package/contracts/product/BasicProduct.sol +82 -0
  349. package/contracts/product/BasicProductAuthorization.sol +40 -0
  350. package/contracts/product/ClaimService.sol +11 -6
  351. package/contracts/product/IClaimService.sol +6 -0
  352. package/contracts/product/IProductComponent.sol +6 -9
  353. package/contracts/product/PolicyService.sol +8 -6
  354. package/contracts/product/PricingService.sol +7 -8
  355. package/contracts/product/Product.sol +103 -88
  356. package/contracts/product/ProductService.sol +5 -5
  357. package/contracts/registry/ChainNft.sol +1 -0
  358. package/contracts/registry/IRegistry.sol +33 -24
  359. package/contracts/registry/IRegistryService.sol +7 -6
  360. package/contracts/registry/Registry.sol +146 -148
  361. package/contracts/registry/RegistryAdmin.sol +365 -0
  362. package/contracts/registry/RegistryService.sol +8 -8
  363. package/contracts/registry/RegistryServiceManager.sol +0 -19
  364. package/contracts/registry/ReleaseLifecycle.sol +27 -0
  365. package/contracts/registry/ReleaseRegistry.sol +487 -0
  366. package/contracts/registry/ServiceAuthorizationV3.sol +200 -0
  367. package/contracts/registry/TokenRegistry.sol +22 -61
  368. package/contracts/shared/Component.sol +8 -13
  369. package/contracts/shared/ComponentService.sol +50 -64
  370. package/contracts/shared/ComponentVerifyingService.sol +13 -7
  371. package/contracts/shared/IComponent.sol +3 -7
  372. package/contracts/shared/IComponentService.sol +11 -0
  373. package/contracts/shared/IInstanceLinkedComponent.sol +4 -0
  374. package/contracts/shared/IKeyValueStore.sol +2 -1
  375. package/contracts/shared/ILifecycle.sol +1 -2
  376. package/contracts/shared/INftOwnable.sol +1 -1
  377. package/contracts/shared/IService.sol +7 -0
  378. package/contracts/shared/InitializableCustom.sol +177 -0
  379. package/contracts/shared/InstanceLinkedComponent.sol +26 -20
  380. package/contracts/shared/KeyValueStore.sol +7 -6
  381. package/contracts/shared/Lifecycle.sol +16 -60
  382. package/contracts/shared/{NftIdSetManager.sol → NftIdSet.sol} +1 -1
  383. package/contracts/shared/NftOwnable.sol +2 -13
  384. package/contracts/shared/PolicyHolder.sol +2 -1
  385. package/contracts/shared/ProxyManager.sol +6 -3
  386. package/contracts/shared/Service.sol +27 -21
  387. package/contracts/shared/UpgradableProxyWithAdmin.sol +1 -3
  388. package/contracts/staking/IStaking.sol +40 -25
  389. package/contracts/staking/IStakingService.sol +42 -44
  390. package/contracts/staking/StakeManagerLib.sol +101 -26
  391. package/contracts/staking/Staking.sol +136 -127
  392. package/contracts/staking/StakingLifecycle.sol +23 -0
  393. package/contracts/staking/StakingManager.sol +10 -22
  394. package/contracts/staking/StakingReader.sol +75 -36
  395. package/contracts/staking/StakingService.sol +124 -88
  396. package/contracts/staking/StakingServiceManager.sol +2 -2
  397. package/contracts/staking/StakingStore.sol +401 -115
  398. package/contracts/staking/TargetManagerLib.sol +28 -0
  399. package/contracts/type/Amount.sol +15 -1
  400. package/contracts/type/NftId.sol +8 -8
  401. package/contracts/type/ObjectType.sol +171 -69
  402. package/contracts/type/RequestId.sol +75 -0
  403. package/contracts/type/RoleId.sol +103 -72
  404. package/contracts/type/Seconds.sol +10 -0
  405. package/contracts/type/Selector.sol +102 -0
  406. package/contracts/type/StateId.sol +12 -0
  407. package/contracts/type/String.sol +53 -0
  408. package/contracts/type/Timestamp.sol +6 -2
  409. package/contracts/type/UFixed.sol +6 -0
  410. package/contracts/type/Version.sol +3 -1
  411. package/package.json +8 -5
  412. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +0 -4
  413. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +0 -778
  414. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +0 -4
  415. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +0 -1348
  416. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.dbg.json +0 -4
  417. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.json +0 -132
  418. package/artifacts/contracts/instance/base/ObjectManager.sol/ObjectManager.dbg.json +0 -4
  419. package/artifacts/contracts/instance/base/ObjectManager.sol/ObjectManager.json +0 -256
  420. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +0 -4
  421. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +0 -322
  422. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +0 -4
  423. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +0 -1151
  424. package/artifacts/contracts/registry/ServiceAuthorizationsLib.sol/ServiceAuthorizationsLib.dbg.json +0 -4
  425. package/artifacts/contracts/registry/ServiceAuthorizationsLib.sol/ServiceAuthorizationsLib.json +0 -137
  426. package/artifacts/contracts/shared/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +0 -4
  427. package/artifacts/contracts/shared/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +0 -1206
  428. package/artifacts/contracts/shared/NftIdSetManager.sol/NftIdSetManager.dbg.json +0 -4
  429. package/artifacts/contracts/shared/NftIdSetManager.sol/NftIdSetManager.json +0 -306
  430. package/artifacts/contracts/staking/IStakingManager.sol/IStakingManager.dbg.json +0 -4
  431. package/artifacts/contracts/staking/IStakingManager.sol/IStakingManager.json +0 -37
  432. package/artifacts/contracts/staking/IStakingStore.sol/IStakingStore.dbg.json +0 -4
  433. package/artifacts/contracts/staking/IStakingStore.sol/IStakingStore.json +0 -357
  434. package/contracts/instance/InstanceAccessManager.sol +0 -543
  435. package/contracts/instance/InstanceAuthorizationsLib.sol +0 -336
  436. package/contracts/registry/RegistryAccessManager.sol +0 -196
  437. package/contracts/registry/ReleaseManager.sol +0 -563
  438. package/contracts/registry/ServiceAuthorizationsLib.sol +0 -173
  439. package/contracts/shared/AccessManagerUpgradeableInitializeable.sol +0 -13
  440. package/contracts/staking/IStakingManager.sol +0 -15
  441. package/contracts/staking/IStakingStore.sol +0 -130
@@ -14,9 +14,8 @@ import {IVersionable} from "../shared/IVersionable.sol";
14
14
  import {Key32} from "../type/Key32.sol";
15
15
  import {KeyValueStore} from "../shared/KeyValueStore.sol";
16
16
  import {KEEP_STATE} from "../type/StateId.sol";
17
- import {LibNftIdSet} from "../type/NftIdSet.sol";
18
17
  import {NftId, NftIdLib} from "../type/NftId.sol";
19
- import {NftIdSetManager} from "../shared/NftIdSetManager.sol";
18
+ import {NftIdSet} from "../shared/NftIdSet.sol";
20
19
  import {ObjectType, INSTANCE, PROTOCOL, STAKE, STAKING, TARGET} from "../type/ObjectType.sol";
21
20
  import {Seconds, SecondsLib} from "../type/Seconds.sol";
22
21
  import {StakingReader} from "./StakingReader.sol";
@@ -27,12 +26,22 @@ import {UFixed, UFixedLib} from "../type/UFixed.sol";
27
26
  import {Version, VersionLib} from "../type/Version.sol";
28
27
  import {Versionable} from "../shared/Versionable.sol";
29
28
 
29
+ import {RegistryAdmin} from "../registry/RegistryAdmin.sol";
30
+ import {StakingLifecycle} from "./StakingLifecycle.sol";
31
+
30
32
 
31
33
  contract StakingStore is
32
34
  AccessManaged,
33
- KeyValueStore
35
+ KeyValueStore,
36
+ StakingLifecycle
34
37
  {
35
38
 
39
+ event LogStakingStoreReserveBalanceIncreased(NftId targetNftId, Amount dipAmount, Amount reserveBalance, Blocknumber lastUpdatedIn);
40
+ event LogStakingStoreReserveBalanceDecreased(NftId targetNftId, Amount dipAmount, Amount reserveBalance, Blocknumber lastUpdatedIn);
41
+
42
+ event LogStakingStoreTotalValueLockedIncreased(NftId targetNftId, address token, Amount amount, Amount newBalance, Blocknumber lastUpdatedIn);
43
+ event LogStakingStoreTotalValueLockedDecreased(NftId targetNftId, address token, Amount amount, Amount newBalance, Blocknumber lastUpdatedIn);
44
+
36
45
  event LogStakingStoreStakesIncreased(NftId nftId, Amount addedAmount, Amount newBalance, Blocknumber lastUpdatedIn);
37
46
  event LogStakingStoreStakesDecreased(NftId nftId, Amount addedAmount, Amount newBalance, Blocknumber lastUpdatedIn);
38
47
 
@@ -41,50 +50,84 @@ contract StakingStore is
41
50
 
42
51
  event LogStakingStoreRewardsRestaked(NftId nftId, Amount amount, Amount rewardAmount, Amount rewardIncrementAmount, Amount newBalance, Blocknumber lastUpdatedIn);
43
52
 
53
+ // in/decreasing reward reserves
54
+ error ErrorStakingStoreNotTarget(NftId targetNftId);
55
+ error ErrorStakingStoreRewardReservesInsufficient(NftId targetNftId, Amount dipAmount, Amount reservesBalanceAmount);
56
+
44
57
  // creating and updating of balance
45
58
  error ErrorStakingStoreBalanceAlreadyInitialized(NftId nftId);
46
59
  error ErrorStakingStoreBalanceNotInitialized(NftId nftId);
47
60
 
48
61
  // update balance
62
+ error ErrorStakingStoreTvlBalanceNotInitialized(NftId nftId);
49
63
 
50
64
  IRegistry private _registry;
51
- NftIdSetManager private _targetManager;
65
+ NftIdSet private _targetNftIdSet;
52
66
  StakingReader private _reader;
53
67
 
68
+ // staking rate
69
+ mapping(uint256 chainId => mapping(address token => UFixed stakingRate)) private _stakingRate;
70
+
71
+ // total, stake and reward balances
54
72
  mapping(NftId nftId => Amount stakes) private _stakeBalance;
55
73
  mapping(NftId nftId => Amount rewards) private _rewardBalance;
74
+ mapping(NftId nftId => Amount reserves) private _reserveBalance;
56
75
 
57
- // TODO check if this is made redundant by *Info struct updates
58
76
  mapping(NftId nftId => Timestamp lastUpdatedAt) private _lastUpdatedAt;
59
77
  mapping(NftId nftId => Blocknumber lastUpdatedIn) private _lastUpdatedIn;
60
78
 
79
+ // total value locked balance
80
+ mapping(NftId nftId => mapping(address token => Amount tvl)) private _tvlBalance;
81
+ mapping(NftId nftId => mapping(address token => Amount tvlInDip)) private _tvlInDip;
82
+ mapping(NftId nftId => Amount tvlRequiredDip) private _tvlRequiredDip;
83
+ mapping(NftId nftId => Blocknumber lastUpdatedIn) private _tvlLastUpdatedIn;
61
84
 
62
- constructor(
63
- address initialAuthority,
64
- address registryAddress
65
- )
66
- AccessManaged(initialAuthority)
85
+
86
+ constructor(IRegistry registry, StakingReader reader)
87
+ AccessManaged(msg.sender)
67
88
  {
68
- _registry = IRegistry(registryAddress);
69
- _reader = new StakingReader();
70
- _targetManager = new NftIdSetManager();
89
+ // set final authority
90
+ setAuthority(registry.getAuthority());
91
+
92
+ // set internal variables
93
+ _registry = registry; //TODO if keeps registry -> RegistryLinked and checks registry address
94
+ _reader = reader;
95
+ _targetNftIdSet = new NftIdSet();
96
+
97
+ // register protocol target
98
+ _createTarget(
99
+ NftIdLib.toNftId(1101),
100
+ IStaking.TargetInfo({
101
+ objectType: PROTOCOL(),
102
+ chainId: 1,
103
+ lockingPeriod: TargetManagerLib.getDefaultLockingPeriod(),
104
+ rewardRate: TargetManagerLib.getDefaultRewardRate()}));
71
105
  }
72
106
 
73
107
 
74
- //--- target specific functions ------------------------------------//
108
+ //--- staking rate specific functions -----------------------------------//
109
+
110
+ function setStakingRate(
111
+ uint256 chainId,
112
+ address token,
113
+ UFixed stakingRate
114
+ )
115
+ external
116
+ restricted()
117
+ {
118
+ _stakingRate[chainId][token] = stakingRate;
119
+ }
120
+
121
+ //--- target specific functions -----------------------------------------//
75
122
 
76
123
  function createTarget(
77
124
  NftId targetNftId,
78
125
  IStaking.TargetInfo memory targetInfo
79
126
  )
80
127
  external
128
+ restricted()
81
129
  {
82
- _create(
83
- targetNftId.toKey32(TARGET()),
84
- abi.encode(targetInfo));
85
-
86
- _createBalance(targetNftId, AmountLib.zero());
87
- _targetManager.add(targetNftId);
130
+ _createTarget(targetNftId, targetInfo);
88
131
  }
89
132
 
90
133
 
@@ -93,26 +136,134 @@ contract StakingStore is
93
136
  IStaking.TargetInfo memory targetInfo
94
137
  )
95
138
  external
139
+ restricted()
96
140
  {
97
141
  _update(
98
142
  targetNftId.toKey32(TARGET()),
99
143
  abi.encode(targetInfo), KEEP_STATE());
100
144
  }
101
145
 
146
+
147
+ function increaseReserves(
148
+ NftId targetNftId,
149
+ Amount dipAmount
150
+ )
151
+ external
152
+ restricted()
153
+ returns (Amount newReserveBalance)
154
+ {
155
+ newReserveBalance = _reserveBalance[targetNftId] + dipAmount;
156
+ Blocknumber lastUpdatedIn = _updateReserves(targetNftId, newReserveBalance);
157
+
158
+ emit LogStakingStoreReserveBalanceIncreased(targetNftId, dipAmount, newReserveBalance, lastUpdatedIn);
159
+ }
160
+
161
+
162
+ function decreaseReserves(
163
+ NftId targetNftId,
164
+ Amount dipAmount
165
+ )
166
+ external
167
+ restricted()
168
+ returns (Amount newReserveBalance)
169
+ {
170
+ Amount reserveAmount = _reserveBalance[targetNftId];
171
+ if (dipAmount > reserveAmount) {
172
+ revert ErrorStakingStoreRewardReservesInsufficient(
173
+ targetNftId,
174
+ dipAmount,
175
+ reserveAmount);
176
+ }
177
+
178
+ newReserveBalance = _reserveBalance[targetNftId] - dipAmount;
179
+ Blocknumber lastUpdatedIn = _updateReserves(targetNftId, newReserveBalance);
180
+
181
+ emit LogStakingStoreReserveBalanceDecreased(targetNftId, dipAmount, newReserveBalance, lastUpdatedIn);
182
+ }
183
+
184
+
185
+ //--- tvl specific functions -------------------------------------//
186
+
187
+ function increaseTotalValueLocked(
188
+ NftId targetNftId,
189
+ UFixed stakingRate,
190
+ address token,
191
+ Amount amount
192
+ )
193
+ external
194
+ restricted()
195
+ returns (Amount newBalance)
196
+ {
197
+ (
198
+ Blocknumber tvlLastUpdatedIn,
199
+ Amount oldBalance,
200
+ Amount oldDipBalance
201
+ ) = _getAndVerifyTvl(targetNftId, token);
202
+
203
+ newBalance = oldBalance + amount;
204
+ Amount newDipBalance = newBalance.multiplyWith(stakingRate);
205
+
206
+ // update new tvl balances
207
+ _tvlBalance[targetNftId][token] = newBalance;
208
+ _tvlInDip[targetNftId][token] = newDipBalance;
209
+
210
+ // update new amount of required dip
211
+ _tvlRequiredDip[targetNftId] = _tvlRequiredDip[targetNftId] - oldDipBalance + newDipBalance;
212
+
213
+ // update last updated in
214
+ _tvlLastUpdatedIn[targetNftId] = BlocknumberLib.currentBlocknumber();
215
+
216
+ emit LogStakingStoreTotalValueLockedIncreased(targetNftId, token, amount, newBalance, tvlLastUpdatedIn);
217
+ }
218
+
219
+
220
+ function decreaseTotalValueLocked(
221
+ NftId targetNftId,
222
+ UFixed stakingRate,
223
+ address token,
224
+ Amount amount
225
+ )
226
+ external
227
+ restricted()
228
+ returns (Amount newBalance)
229
+ {
230
+ (
231
+ Blocknumber tvlLastUpdatedIn,
232
+ Amount oldBalance,
233
+ Amount oldDipBalance
234
+ ) = _getAndVerifyTvl(targetNftId, token);
235
+
236
+ newBalance = oldBalance - amount;
237
+ Amount newDipBalance = AmountLib.toAmount((
238
+ stakingRate * newBalance.toUFixed()).toInt());
239
+
240
+ // update new tvl balances
241
+ _tvlBalance[targetNftId][token] = newBalance;
242
+ _tvlInDip[targetNftId][token] = newDipBalance;
243
+
244
+ // update new amount of required dip
245
+ _tvlRequiredDip[targetNftId] = _tvlRequiredDip[targetNftId] - oldDipBalance + newDipBalance;
246
+
247
+ // update last updated in
248
+ _tvlLastUpdatedIn[targetNftId] = BlocknumberLib.currentBlocknumber();
249
+
250
+ emit LogStakingStoreTotalValueLockedDecreased(targetNftId, token, amount, newBalance, tvlLastUpdatedIn);
251
+ }
252
+
102
253
  //--- stake specific functions -------------------------------------//
103
254
 
104
255
  function create(
105
256
  NftId stakeNftId,
106
- IStaking.StakeInfo memory stakeInfo,
107
- Amount stakeAmount
257
+ IStaking.StakeInfo memory stakeInfo
108
258
  )
109
259
  external
260
+ restricted()
110
261
  {
111
262
  _create(
112
263
  stakeNftId.toKey32(STAKE()),
113
264
  abi.encode(stakeInfo));
114
265
 
115
- _createBalance(stakeNftId, stakeAmount);
266
+ _createStakeBalance(stakeNftId);
116
267
  }
117
268
 
118
269
  function update(
@@ -120,6 +271,7 @@ contract StakingStore is
120
271
  IStaking.StakeInfo memory stakeInfo
121
272
  )
122
273
  external
274
+ restricted()
123
275
  {
124
276
  _update(
125
277
  stakeNftId.toKey32(STAKE()),
@@ -130,57 +282,52 @@ contract StakingStore is
130
282
  //--- general functions --------------------------------------------//
131
283
 
132
284
 
133
- function increaseBalance(NftId nftId, Amount amount, Amount rewardIncrementAmount)
285
+ function increaseStake(
286
+ NftId nftId,
287
+ NftId targetNftId,
288
+ Amount amount
289
+ )
134
290
  external
291
+ restricted()
135
292
  {
136
- Blocknumber lastUpdatedIn = _lastUpdatedIn[nftId];
137
- bool updated = false;
138
-
139
- if (lastUpdatedIn.eqz()) {
140
- revert ErrorStakingStoreBalanceNotInitialized(nftId);
141
- }
293
+ Blocknumber lastUpdatedIn = _checkBalanceExists(nftId);
142
294
 
143
- // update stake balance with amount
144
- if(amount.gtz()) {
145
- updated = true;
146
- _stakeBalance[nftId] = _stakeBalance[nftId] + amount;
147
- emit LogStakingStoreStakesIncreased(nftId, amount, _stakeBalance[nftId], lastUpdatedIn);
148
- }
295
+ _updateStakeBalance(
296
+ nftId,
297
+ _stakeBalance[nftId] + amount, // new stake balance
298
+ _rewardBalance[nftId]); // unchanged reward balance
149
299
 
150
- // update reward balance with amount
151
- if(rewardIncrementAmount.gtz()) {
152
- updated = true;
153
- _rewardBalance[nftId] = _rewardBalance[nftId] + rewardIncrementAmount;
154
- emit LogStakingStoreRewardsIncreased(nftId, rewardIncrementAmount, _rewardBalance[nftId], lastUpdatedIn);
155
- }
300
+ _updateTargetBalance(
301
+ targetNftId,
302
+ _stakeBalance[targetNftId] + amount,
303
+ _rewardBalance[targetNftId]);
156
304
 
157
- if (updated) {
158
- _lastUpdatedAt[nftId] = TimestampLib.blockTimestamp();
159
- _lastUpdatedIn[nftId] = BlocknumberLib.currentBlocknumber();
160
- }
305
+ emit LogStakingStoreStakesIncreased(nftId, amount, _stakeBalance[nftId], lastUpdatedIn);
161
306
  }
162
307
 
163
308
 
164
309
  function restakeRewards(
165
310
  NftId nftId,
311
+ NftId targetNftId,
166
312
  Amount rewardIncrementAmount
167
313
  )
168
314
  external
315
+ restricted()
169
316
  {
170
- Blocknumber lastUpdatedIn = _lastUpdatedIn[nftId];
317
+ Blocknumber lastUpdatedIn = _checkBalanceExists(nftId);
171
318
  Amount stakeAmount = _stakeBalance[nftId];
172
319
  Amount rewardAmount = _rewardBalance[nftId];
173
320
 
174
- if (lastUpdatedIn.eqz()) {
175
- revert ErrorStakingStoreBalanceNotInitialized(nftId);
176
- }
177
-
178
321
  // move all rewards to stake balance
179
- _stakeBalance[nftId] = stakeAmount + rewardAmount + rewardIncrementAmount;
180
- _rewardBalance[nftId] = AmountLib.zero();
322
+ _updateStakeBalance(
323
+ nftId,
324
+ stakeAmount + rewardAmount + rewardIncrementAmount, // new stake balance
325
+ AmountLib.zero()); // new reward balance
181
326
 
182
- _lastUpdatedAt[nftId] = TimestampLib.blockTimestamp();
183
- _lastUpdatedIn[nftId] = BlocknumberLib.currentBlocknumber();
327
+ _updateTargetBalance(
328
+ targetNftId,
329
+ _stakeBalance[targetNftId] + rewardAmount + rewardIncrementAmount,
330
+ _rewardBalance[targetNftId] - rewardAmount);
184
331
 
185
332
  emit LogStakingStoreRewardsRestaked(nftId, stakeAmount, rewardAmount, rewardIncrementAmount, _stakeBalance[nftId], lastUpdatedIn);
186
333
  }
@@ -188,22 +335,24 @@ contract StakingStore is
188
335
 
189
336
  function updateRewards(
190
337
  NftId nftId,
338
+ NftId targetNftId,
191
339
  Amount rewardIncrementAmount
192
340
  )
193
341
  external
342
+ restricted()
194
343
  {
195
- Blocknumber lastUpdatedIn = _lastUpdatedIn[nftId];
196
- Amount rewardAmount = _rewardBalance[nftId];
344
+ Blocknumber lastUpdatedIn = _checkBalanceExists(nftId);
197
345
 
198
- if (lastUpdatedIn.eqz()) {
199
- revert ErrorStakingStoreBalanceNotInitialized(nftId);
200
- }
201
-
202
- // move all rewards to stake balance
203
- _rewardBalance[nftId] = rewardAmount + rewardIncrementAmount;
346
+ // increse rewards by increment
347
+ _updateStakeBalance(
348
+ nftId,
349
+ _stakeBalance[nftId], // unchanged stake balance
350
+ _rewardBalance[nftId] + rewardIncrementAmount); // new reward balance
204
351
 
205
- _lastUpdatedAt[nftId] = TimestampLib.blockTimestamp();
206
- _lastUpdatedIn[nftId] = BlocknumberLib.currentBlocknumber();
352
+ _updateTargetBalance(
353
+ targetNftId,
354
+ _stakeBalance[targetNftId],
355
+ _rewardBalance[targetNftId] + rewardIncrementAmount);
207
356
 
208
357
  emit LogStakingStoreRewardsIncreased(nftId, rewardIncrementAmount, _rewardBalance[nftId], lastUpdatedIn);
209
358
  }
@@ -211,73 +360,62 @@ contract StakingStore is
211
360
 
212
361
  function claimUpTo(
213
362
  NftId nftId,
214
- Amount maxRewardAmount
363
+ NftId targetNftId,
364
+ Amount maxClaimAmount
215
365
  )
216
366
  external
217
- returns (Amount rewardsClaimedAmount)
367
+ restricted()
368
+ returns (Amount claimedAmount)
218
369
  {
219
- Blocknumber lastUpdatedIn = _lastUpdatedIn[nftId];
220
- bool updated = false;
221
-
222
- if (lastUpdatedIn.eqz()) {
223
- revert ErrorStakingStoreBalanceNotInitialized(nftId);
224
- }
370
+ Blocknumber lastUpdatedIn = _checkBalanceExists(nftId);
225
371
 
226
372
  // determine the claimable rewards amount
227
- if (maxRewardAmount > _rewardBalance[nftId]) {
228
- rewardsClaimedAmount = _rewardBalance[nftId];
229
- } else {
230
- rewardsClaimedAmount = maxRewardAmount;
231
- }
373
+ claimedAmount = AmountLib.min(maxClaimAmount, _rewardBalance[nftId]);
232
374
 
233
- // decrease reward amount
234
- _rewardBalance[nftId] = _rewardBalance[nftId] - rewardsClaimedAmount;
375
+ // decrease rewards by claimed amount
376
+ _updateStakeBalance(
377
+ nftId,
378
+ _stakeBalance[nftId], // unchanged stake balance
379
+ _rewardBalance[nftId] - claimedAmount); // new reward balance
235
380
 
236
- _lastUpdatedAt[nftId] = TimestampLib.blockTimestamp();
237
- _lastUpdatedIn[nftId] = BlocknumberLib.currentBlocknumber();
381
+ _updateTargetBalance(
382
+ targetNftId,
383
+ _stakeBalance[targetNftId],
384
+ _rewardBalance[targetNftId] - claimedAmount);
238
385
 
239
- emit LogStakingStoreRewardsDecreased(nftId, rewardsClaimedAmount, _rewardBalance[nftId], lastUpdatedIn);
386
+ emit LogStakingStoreRewardsDecreased(nftId, claimedAmount, _rewardBalance[nftId], lastUpdatedIn);
240
387
  }
241
388
 
242
389
 
243
390
  function unstakeUpTo(
244
391
  NftId nftId,
392
+ NftId targetNftId,
245
393
  Amount maxUnstakeAmount,
246
394
  Amount maxClaimAmount
247
395
  )
248
396
  external
397
+ restricted()
249
398
  returns (
250
399
  Amount unstakedAmount,
251
400
  Amount claimedAmount
252
401
  )
253
402
  {
254
- Blocknumber lastUpdatedIn = _lastUpdatedIn[nftId];
255
- bool updated = false;
256
-
257
- if (lastUpdatedIn.eqz()) {
258
- revert ErrorStakingStoreBalanceNotInitialized(nftId);
259
- }
403
+ Blocknumber lastUpdatedIn = _checkBalanceExists(nftId);
260
404
 
261
- // determine the unstakeable amount
262
- if (maxUnstakeAmount > _rewardBalance[nftId]) {
263
- unstakedAmount = _rewardBalance[nftId];
264
- } else {
265
- unstakedAmount = maxUnstakeAmount;
266
- }
267
-
268
- // determine the claimable rewards amount
269
- if (maxClaimAmount > _rewardBalance[nftId]) {
270
- claimedAmount = _rewardBalance[nftId];
271
- } else {
272
- claimedAmount = maxClaimAmount;
273
- }
405
+ // determine amounts
406
+ unstakedAmount = AmountLib.min(maxUnstakeAmount, _stakeBalance[nftId]);
407
+ claimedAmount = AmountLib.min(maxClaimAmount, _rewardBalance[nftId]);
274
408
 
275
- // decrease amounts
276
- _stakeBalance[nftId] = _stakeBalance[nftId] - unstakedAmount;
277
- _rewardBalance[nftId] = _rewardBalance[nftId] - claimedAmount;
409
+ // decrease stakes and rewards as determined
410
+ _updateStakeBalance(
411
+ nftId,
412
+ _stakeBalance[nftId] - unstakedAmount, // unchanged stake balance
413
+ _rewardBalance[nftId] - claimedAmount); // new reward balance
278
414
 
279
- _lastUpdatedAt[nftId] = TimestampLib.blockTimestamp();
280
- _lastUpdatedIn[nftId] = BlocknumberLib.currentBlocknumber();
415
+ _updateTargetBalance(
416
+ targetNftId,
417
+ _stakeBalance[targetNftId] - unstakedAmount,
418
+ _rewardBalance[targetNftId] - claimedAmount);
281
419
 
282
420
  emit LogStakingStoreStakesDecreased(nftId, unstakedAmount, _stakeBalance[nftId], lastUpdatedIn);
283
421
  emit LogStakingStoreRewardsDecreased(nftId, claimedAmount, _rewardBalance[nftId], lastUpdatedIn);
@@ -289,41 +427,189 @@ contract StakingStore is
289
427
  return _reader;
290
428
  }
291
429
 
292
- function getTargetManager() external view returns (NftIdSetManager targetManager){
293
- return _targetManager;
430
+ // TODO rename
431
+ function getTargetNftIdSet() external view returns (NftIdSet targetNftIdSet){
432
+ return _targetNftIdSet;
294
433
  }
295
434
 
296
- function exists(NftId stakeNftId) external view returns (bool) {
297
- return exists(stakeNftId.toKey32(STAKE()));
298
- }
435
+ function getStakingRate(uint256 chainId, address token) external view returns (UFixed stakingRate) { return _stakingRate[chainId][token]; }
436
+
437
+ function exists(NftId stakeNftId) external view returns (bool) { return exists(stakeNftId.toKey32(STAKE())); }
438
+
439
+ function getTotalValueLocked(NftId nftId, address token) external view returns (Amount tvlBalanceAmount) { return _tvlBalance[nftId][token]; }
440
+ function getRequiredStakeBalance(NftId nftId) external view returns (Amount requiredAmount) { return _tvlRequiredDip[nftId]; }
299
441
 
442
+ function getReserveBalance(NftId nftId) external view returns (Amount balanceAmount) { return _reserveBalance[nftId]; }
300
443
  function getStakeBalance(NftId nftId) external view returns (Amount balanceAmount) { return _stakeBalance[nftId]; }
301
444
  function getRewardBalance(NftId nftId) external view returns (Amount rewardAmount) { return _rewardBalance[nftId]; }
302
445
  function getBalanceUpdatedAt(NftId nftId) external view returns (Timestamp updatedAt) { return _lastUpdatedAt[nftId]; }
446
+ function getBalanceUpdatedIn(NftId nftId) external view returns (Blocknumber blocknumber) { return _lastUpdatedIn[nftId]; }
303
447
 
304
- function getBalanceAndLastUpdatedAt(NftId nftId)
448
+
449
+ function getTargetBalances(NftId nftId)
305
450
  external
306
451
  view
307
452
  returns (
308
453
  Amount stakeBalance,
454
+ Amount rewardBalance,
455
+ Amount reserveBalance,
456
+ Blocknumber lastUpdatedIn
457
+ )
458
+ {
459
+ stakeBalance = _stakeBalance[nftId];
460
+ rewardBalance = _rewardBalance[nftId];
461
+ reserveBalance = _reserveBalance[nftId];
462
+ lastUpdatedIn = _lastUpdatedIn[nftId];
463
+ }
464
+
465
+
466
+ function getStakeBalances(NftId nftId)
467
+ external
468
+ view
469
+ returns (
470
+ Amount stakeBalance,
471
+ Amount rewardBalance,
309
472
  Timestamp lastUpdatedAt
310
473
  )
311
474
  {
312
475
  stakeBalance = _stakeBalance[nftId];
476
+ rewardBalance = _rewardBalance[nftId];
313
477
  lastUpdatedAt = _lastUpdatedAt[nftId];
314
478
  }
315
479
 
316
480
  //--- private functions -------------------------------------------//
317
481
 
318
- function _createBalance(NftId nftId, Amount amount) private {
482
+ function _createTarget(
483
+ NftId targetNftId,
484
+ IStaking.TargetInfo memory targetInfo
485
+ )
486
+ private
487
+ {
488
+ _create(
489
+ targetNftId.toKey32(TARGET()),
490
+ abi.encode(targetInfo));
491
+
492
+ // initialize tvl and stake balance
493
+ _tvlLastUpdatedIn[targetNftId]= BlocknumberLib.currentBlocknumber();
494
+ _createTargetBalance(targetNftId);
495
+
496
+ _targetNftIdSet.add(targetNftId);
497
+ }
498
+
499
+ function _updateReserves(
500
+ NftId targetNftId,
501
+ Amount newRewardBalance
502
+ )
503
+ private
504
+ returns (Blocknumber lastUpdatedIn)
505
+ {
506
+ if (_lastUpdatedIn[targetNftId].eqz()) {
507
+ revert ErrorStakingStoreNotTarget(targetNftId);
508
+ }
509
+
510
+ lastUpdatedIn = _lastUpdatedIn[targetNftId];
511
+
512
+ _reserveBalance[targetNftId] = newRewardBalance;
513
+ _lastUpdatedIn[targetNftId] = BlocknumberLib.currentBlocknumber();
514
+ }
515
+
516
+
517
+ function _createTargetBalance(NftId nftId)
518
+ private
519
+ {
520
+ if (_lastUpdatedIn[nftId].gtz()) {
521
+ revert ErrorStakingStoreBalanceAlreadyInitialized(nftId);
522
+ }
523
+
524
+ // set target balances to 0
525
+ _stakeBalance[nftId] = AmountLib.zero();
526
+ _rewardBalance[nftId] = AmountLib.zero();
527
+ _reserveBalance[nftId] = AmountLib.zero();
528
+
529
+ // set last updated in to current block number
530
+ // we don't need last updated at timestamp for targets
531
+ _lastUpdatedIn[nftId] = BlocknumberLib.currentBlocknumber();
532
+ }
533
+
534
+
535
+ function _createStakeBalance(NftId nftId)
536
+ private
537
+ {
319
538
  if (_lastUpdatedIn[nftId].gtz()) {
320
539
  revert ErrorStakingStoreBalanceAlreadyInitialized(nftId);
321
540
  }
322
541
 
323
- _stakeBalance[nftId] = amount;
542
+ // set stake balances to 0
543
+ _stakeBalance[nftId] = AmountLib.zero();
324
544
  _rewardBalance[nftId] = AmountLib.zero();
325
545
 
546
+ // set last updated at/in to current timestamp/block number
326
547
  _lastUpdatedAt[nftId] = TimestampLib.blockTimestamp();
327
548
  _lastUpdatedIn[nftId] = BlocknumberLib.currentBlocknumber();
328
549
  }
550
+
551
+
552
+ function _updateStakeBalance(
553
+ NftId stakeNftId,
554
+ Amount newStakeAmount,
555
+ Amount newRewardAmount
556
+ )
557
+ private
558
+ {
559
+ _stakeBalance[stakeNftId] = newStakeAmount;
560
+ _rewardBalance[stakeNftId] = newRewardAmount;
561
+
562
+ _lastUpdatedAt[stakeNftId] = TimestampLib.blockTimestamp();
563
+ _lastUpdatedIn[stakeNftId] = BlocknumberLib.currentBlocknumber();
564
+ }
565
+
566
+
567
+ function _updateTargetBalance(
568
+ NftId targetNftId,
569
+ Amount newStakeAmount,
570
+ Amount newRewardAmount
571
+ )
572
+ private
573
+ {
574
+ _stakeBalance[targetNftId] = newStakeAmount;
575
+ _rewardBalance[targetNftId] = newRewardAmount;
576
+
577
+ // for targets we don't need the timestamp, just the blocknumber
578
+ _lastUpdatedIn[targetNftId] = BlocknumberLib.currentBlocknumber();
579
+ }
580
+
581
+ function _checkBalanceExists(NftId nftId)
582
+ private
583
+ view
584
+ returns (Blocknumber lastUpdatedIn)
585
+ {
586
+ lastUpdatedIn = _lastUpdatedIn[nftId];
587
+
588
+ if (lastUpdatedIn.eqz()) {
589
+ revert ErrorStakingStoreBalanceNotInitialized(nftId);
590
+ }
591
+ }
592
+
593
+
594
+ function _getAndVerifyTvl(
595
+ NftId targetNftId,
596
+ address token
597
+ )
598
+ private
599
+ view
600
+ returns (
601
+ Blocknumber tvlLastUpdatedIn,
602
+ Amount oldBalance,
603
+ Amount oldDipBalance
604
+ )
605
+ {
606
+ tvlLastUpdatedIn = _tvlLastUpdatedIn[targetNftId];
607
+
608
+ if (tvlLastUpdatedIn.eqz()) {
609
+ revert ErrorStakingStoreTvlBalanceNotInitialized(targetNftId);
610
+ }
611
+
612
+ oldBalance = _tvlBalance[targetNftId][token];
613
+ oldDipBalance = _tvlInDip[targetNftId][token];
614
+ }
329
615
  }