@etherisc/gif-next 0.0.2-e802d97-251 → 0.0.2-e83e4a5-207

Sign up to get free protection for your applications and to get access to all the features.
Files changed (398) hide show
  1. package/README.md +18 -2
  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 +17 -242
  28. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
  29. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +138 -93
  30. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  31. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +65 -57
  32. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  33. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +71 -146
  34. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  35. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +45 -16
  36. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  37. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +33 -108
  38. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  39. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +58 -78
  40. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  41. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +147 -40
  42. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  43. package/artifacts/contracts/instance/Instance.sol/Instance.json +72 -140
  44. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
  45. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +1208 -290
  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 +110 -76
  50. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  51. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +210 -103
  52. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  53. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +49 -49
  54. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
  55. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +84 -135
  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 +1 -1
  61. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.json +2 -2
  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/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  65. package/artifacts/contracts/instance/base/ObjectManager.sol/ObjectManager.json +3 -78
  66. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  72. package/artifacts/contracts/mock/Dip.sol/Dip.dbg.json +1 -1
  73. package/artifacts/contracts/mock/Dip.sol/Dip.json +2 -2
  74. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.dbg.json +4 -0
  75. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.json +1155 -0
  76. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +4 -0
  77. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +418 -0
  78. package/artifacts/contracts/oracle/IOracle.sol/IOracle.dbg.json +1 -1
  79. package/artifacts/contracts/oracle/IOracle.sol/IOracle.json +43 -1
  80. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.dbg.json +1 -1
  81. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.json +13 -0
  82. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
  83. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.json +13 -0
  84. package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
  85. package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +13 -96
  86. package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
  87. package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +66 -29
  88. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
  89. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +44 -32
  90. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +4 -0
  91. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +1477 -0
  92. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +4 -0
  93. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +410 -0
  94. package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
  95. package/artifacts/contracts/pool/BundleService.sol/BundleService.json +78 -49
  96. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  97. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +50 -42
  98. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
  99. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +13 -0
  100. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  101. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +7 -202
  102. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
  103. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +13 -0
  104. package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
  105. package/artifacts/contracts/pool/Pool.sol/Pool.json +7 -303
  106. package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
  107. package/artifacts/contracts/pool/PoolService.sol/PoolService.json +62 -41
  108. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  109. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +42 -38
  110. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  111. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +66 -37
  112. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  113. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +44 -36
  114. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +4 -0
  115. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +1299 -0
  116. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +4 -0
  117. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +410 -0
  118. package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
  119. package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +106 -69
  120. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  121. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +64 -52
  122. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  123. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.json +13 -0
  124. package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
  125. package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +13 -0
  126. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  127. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +13 -0
  128. package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
  129. package/artifacts/contracts/product/IPricingService.sol/IPricingService.json +13 -0
  130. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  131. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +13 -42
  132. package/artifacts/contracts/product/IProductService.sol/IProductService.dbg.json +1 -1
  133. package/artifacts/contracts/product/IProductService.sol/IProductService.json +13 -0
  134. package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
  135. package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +84 -47
  136. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  137. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +53 -41
  138. package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
  139. package/artifacts/contracts/product/PricingService.sol/PricingService.json +92 -63
  140. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
  141. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +57 -49
  142. package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
  143. package/artifacts/contracts/product/Product.sol/Product.json +13 -153
  144. package/artifacts/contracts/product/ProductService.sol/ProductService.dbg.json +1 -1
  145. package/artifacts/contracts/product/ProductService.sol/ProductService.json +54 -25
  146. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  147. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +38 -30
  148. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  149. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  150. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  151. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +0 -44
  152. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  153. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +13 -0
  154. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  155. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  156. package/artifacts/contracts/registry/Registry.sol/Registry.json +24 -68
  157. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
  158. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +1505 -166
  159. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  160. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +50 -13
  161. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  162. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +37 -25
  163. package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.dbg.json +4 -0
  164. package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.json +164 -0
  165. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  166. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +185 -318
  167. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +4 -0
  168. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +214 -0
  169. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  170. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +4 -4
  171. package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
  172. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
  173. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +82 -85
  174. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
  175. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +52 -60
  176. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +1 -1
  177. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.json +13 -0
  178. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  179. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  180. package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
  181. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
  182. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.json +13 -0
  183. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
  184. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +13 -0
  185. package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  186. package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.json +11 -5
  187. package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  188. package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.json +0 -5
  189. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  190. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  191. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  192. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  193. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  194. package/artifacts/contracts/shared/IService.sol/IService.json +13 -0
  195. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  196. package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.dbg.json +1 -1
  197. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
  198. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.json +13 -53
  199. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  200. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.json +15 -89
  201. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  202. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.json +4 -65
  203. package/artifacts/contracts/shared/NftIdSetManager.sol/NftIdSetManager.dbg.json +1 -1
  204. package/artifacts/contracts/shared/NftIdSetManager.sol/NftIdSetManager.json +22 -22
  205. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  206. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +6 -6
  207. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  208. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +6 -6
  209. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  210. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +14 -14
  211. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  212. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +8 -8
  213. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  214. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  215. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  216. package/artifacts/contracts/shared/Service.sol/Service.json +13 -0
  217. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  218. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +6 -6
  219. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  220. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  221. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  222. package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
  223. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
  224. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.json +49 -7
  225. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +1 -1
  226. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +44 -28
  227. package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
  228. package/artifacts/contracts/staking/Staking.sol/Staking.json +44 -84
  229. package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +4 -0
  230. package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.json +164 -0
  231. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
  232. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +40 -56
  233. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
  234. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +6 -6
  235. package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
  236. package/artifacts/contracts/staking/StakingService.sol/StakingService.json +92 -73
  237. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
  238. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +39 -47
  239. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
  240. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +197 -149
  241. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
  242. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +22 -22
  243. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  244. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.json +2 -2
  245. package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
  246. package/artifacts/contracts/type/Amount.sol/AmountLib.json +8 -8
  247. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  248. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.json +2 -2
  249. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  250. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.json +4 -4
  251. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  252. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.json +4 -4
  253. package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
  254. package/artifacts/contracts/type/Fee.sol/FeeLib.json +12 -12
  255. package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
  256. package/artifacts/contracts/type/Key32.sol/Key32Lib.json +2 -2
  257. package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
  258. package/artifacts/contracts/type/NftId.sol/NftIdLib.json +4 -4
  259. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  260. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.json +2 -2
  261. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  262. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.json +136 -2
  263. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  264. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.json +4 -4
  265. package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
  266. package/artifacts/contracts/type/Referral.sol/ReferralLib.json +4 -4
  267. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.dbg.json +1 -1
  268. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.json +4 -4
  269. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
  270. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.json +4 -4
  271. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
  272. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +219 -6
  273. package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
  274. package/artifacts/contracts/type/Seconds.sol/SecondsLib.json +2 -2
  275. package/artifacts/contracts/type/Selector.sol/SelectorLib.dbg.json +4 -0
  276. package/artifacts/contracts/type/Selector.sol/SelectorLib.json +129 -0
  277. package/artifacts/contracts/type/Selector.sol/SelectorSetLib.dbg.json +4 -0
  278. package/artifacts/contracts/type/Selector.sol/SelectorSetLib.json +10 -0
  279. package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
  280. package/artifacts/contracts/type/StateId.sol/StateIdLib.json +2 -2
  281. package/artifacts/contracts/type/String.sol/StrLib.dbg.json +4 -0
  282. package/artifacts/contracts/type/String.sol/StrLib.json +132 -0
  283. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
  284. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.json +4 -4
  285. package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +1 -1
  286. package/artifacts/contracts/type/UFixed.sol/MathLib.json +2 -2
  287. package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
  288. package/artifacts/contracts/type/UFixed.sol/UFixedLib.json +21 -2
  289. package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
  290. package/artifacts/contracts/type/Version.sol/VersionLib.json +2 -2
  291. package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
  292. package/artifacts/contracts/type/Version.sol/VersionPartLib.json +2 -2
  293. package/contracts/authorization/AccessAdmin.sol +591 -0
  294. package/contracts/authorization/AccessManagerCloneable.sol +16 -0
  295. package/contracts/authorization/Authorization.sol +218 -0
  296. package/contracts/authorization/IAccess.sol +48 -0
  297. package/contracts/authorization/IAccessAdmin.sol +136 -0
  298. package/contracts/authorization/IAuthorization.sol +54 -0
  299. package/contracts/authorization/IModuleAuthorization.sol +21 -0
  300. package/contracts/authorization/IServiceAuthorization.sol +38 -0
  301. package/contracts/authorization/ModuleAuthorization.sol +78 -0
  302. package/contracts/authorization/ServiceAuthorization.sol +90 -0
  303. package/contracts/distribution/BasicDistribution.sol +149 -0
  304. package/contracts/distribution/BasicDistributionAuthorization.sol +43 -0
  305. package/contracts/distribution/Distribution.sol +126 -104
  306. package/contracts/distribution/DistributionService.sol +13 -9
  307. package/contracts/distribution/IDistributionComponent.sol +17 -35
  308. package/contracts/distribution/IDistributionService.sol +5 -1
  309. package/contracts/instance/IInstance.sol +11 -7
  310. package/contracts/instance/IInstanceService.sol +29 -18
  311. package/contracts/instance/Instance.sol +103 -85
  312. package/contracts/instance/InstanceAdmin.sol +202 -267
  313. package/contracts/instance/InstanceAuthorizationV3.sol +202 -0
  314. package/contracts/instance/InstanceReader.sol +24 -9
  315. package/contracts/instance/InstanceService.sol +151 -70
  316. package/contracts/instance/InstanceStore.sol +15 -20
  317. package/contracts/instance/base/BalanceStore.sol +11 -6
  318. package/contracts/instance/base/Cloneable.sol +2 -25
  319. package/contracts/instance/base/ObjectLifecycle.sol +106 -0
  320. package/contracts/instance/base/ObjectManager.sol +7 -10
  321. package/contracts/oracle/BasicOracle.sol +48 -0
  322. package/contracts/oracle/BasicOracleAuthorization.sol +46 -0
  323. package/contracts/oracle/IOracle.sol +16 -0
  324. package/contracts/oracle/Oracle.sol +61 -49
  325. package/contracts/oracle/OracleService.sol +5 -4
  326. package/contracts/pool/BasicPool.sol +164 -0
  327. package/contracts/pool/BasicPoolAuthorization.sol +49 -0
  328. package/contracts/pool/BundleService.sol +19 -19
  329. package/contracts/pool/IPoolComponent.sol +0 -60
  330. package/contracts/pool/Pool.sol +143 -131
  331. package/contracts/pool/PoolService.sol +7 -8
  332. package/contracts/product/ApplicationService.sol +5 -5
  333. package/contracts/product/BasicProduct.sol +82 -0
  334. package/contracts/product/BasicProductAuthorization.sol +40 -0
  335. package/contracts/product/ClaimService.sol +5 -5
  336. package/contracts/product/IProductComponent.sol +6 -9
  337. package/contracts/product/PolicyService.sol +5 -5
  338. package/contracts/product/PricingService.sol +4 -5
  339. package/contracts/product/Product.sol +103 -88
  340. package/contracts/product/ProductService.sol +5 -5
  341. package/contracts/registry/IRegistry.sol +5 -8
  342. package/contracts/registry/Registry.sol +6 -4
  343. package/contracts/registry/RegistryAdmin.sol +276 -148
  344. package/contracts/registry/RegistryService.sol +5 -5
  345. package/contracts/registry/RegistryServiceManager.sol +0 -5
  346. package/contracts/registry/ReleaseLifecycle.sol +27 -0
  347. package/contracts/registry/ReleaseManager.sol +161 -274
  348. package/contracts/registry/ServiceAuthorizationV3.sol +200 -0
  349. package/contracts/shared/ComponentService.sol +24 -61
  350. package/contracts/shared/ComponentVerifyingService.sol +1 -1
  351. package/contracts/shared/IInstanceLinkedComponent.sol +4 -0
  352. package/contracts/shared/IKeyValueStore.sol +1 -0
  353. package/contracts/shared/ILifecycle.sol +1 -2
  354. package/contracts/shared/IService.sol +7 -0
  355. package/contracts/shared/InstanceLinkedComponent.sol +26 -19
  356. package/contracts/shared/KeyValueStore.sol +6 -2
  357. package/contracts/shared/Lifecycle.sol +16 -69
  358. package/contracts/shared/Service.sol +27 -21
  359. package/contracts/staking/IStakingService.sol +11 -7
  360. package/contracts/staking/StakeManagerLib.sol +52 -0
  361. package/contracts/staking/Staking.sol +58 -96
  362. package/contracts/staking/StakingLifecycle.sol +23 -0
  363. package/contracts/staking/StakingService.sol +61 -56
  364. package/contracts/staking/StakingServiceManager.sol +0 -1
  365. package/contracts/staking/StakingStore.sol +82 -39
  366. package/contracts/type/ObjectType.sol +169 -62
  367. package/contracts/type/RoleId.sol +103 -75
  368. package/contracts/type/Selector.sol +102 -0
  369. package/contracts/type/String.sol +53 -0
  370. package/contracts/type/UFixed.sol +6 -0
  371. package/package.json +4 -1
  372. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.dbg.json +0 -4
  373. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.json +0 -228
  374. package/artifacts/contracts/registry/ServiceAuthorizationsLib.sol/ServiceAuthorizationsLib.dbg.json +0 -4
  375. package/artifacts/contracts/registry/ServiceAuthorizationsLib.sol/ServiceAuthorizationsLib.json +0 -137
  376. package/artifacts/contracts/shared/AccessManagerCustom.sol/AccessManagerCustom.dbg.json +0 -4
  377. package/artifacts/contracts/shared/AccessManagerCustom.sol/AccessManagerCustom.json +0 -1193
  378. package/artifacts/contracts/shared/AccessManagerExtended.sol/AccessManagerExtended.dbg.json +0 -4
  379. package/artifacts/contracts/shared/AccessManagerExtended.sol/AccessManagerExtended.json +0 -1715
  380. package/artifacts/contracts/shared/AccessManagerExtendedInitializeable.sol/AccessManagerExtendedInitializeable.dbg.json +0 -4
  381. package/artifacts/contracts/shared/AccessManagerExtendedInitializeable.sol/AccessManagerExtendedInitializeable.json +0 -1728
  382. package/artifacts/contracts/shared/AccessManagerExtendedWithDisable.sol/AccessManagerExtendedWithDisable.dbg.json +0 -4
  383. package/artifacts/contracts/shared/AccessManagerExtendedWithDisable.sol/AccessManagerExtendedWithDisable.json +0 -1806
  384. package/artifacts/contracts/shared/AccessManagerExtendedWithDisableInitializeable.sol/AccessManagerExtendedWithDisableInitializeable.dbg.json +0 -4
  385. package/artifacts/contracts/shared/AccessManagerExtendedWithDisableInitializeable.sol/AccessManagerExtendedWithDisableInitializeable.json +0 -1824
  386. package/artifacts/contracts/shared/IAccessManagerExtended.sol/IAccessManagerExtended.dbg.json +0 -4
  387. package/artifacts/contracts/shared/IAccessManagerExtended.sol/IAccessManagerExtended.json +0 -1562
  388. package/artifacts/contracts/shared/IAccessManagerExtendedWithDisable.sol/IAccessManagerExtendedWithDisable.dbg.json +0 -4
  389. package/artifacts/contracts/shared/IAccessManagerExtendedWithDisable.sol/IAccessManagerExtendedWithDisable.json +0 -1600
  390. package/contracts/instance/InstanceAuthorizationsLib.sol +0 -377
  391. package/contracts/registry/ServiceAuthorizationsLib.sol +0 -173
  392. package/contracts/shared/AccessManagerCustom.sol +0 -736
  393. package/contracts/shared/AccessManagerExtended.sol +0 -470
  394. package/contracts/shared/AccessManagerExtendedInitializeable.sol +0 -13
  395. package/contracts/shared/AccessManagerExtendedWithDisable.sol +0 -137
  396. package/contracts/shared/AccessManagerExtendedWithDisableInitializeable.sol +0 -14
  397. package/contracts/shared/IAccessManagerExtended.sol +0 -74
  398. package/contracts/shared/IAccessManagerExtendedWithDisable.sol +0 -18
@@ -1,15 +1,11 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
5
-
6
- import {NftId} from "../type/NftId.sol";
7
- import {ObjectType, COMPONENT, BUNDLE, POLICY, REQUEST, RISK, CLAIM, PAYOUT} from "../type/ObjectType.sol";
8
- import {StateId, ACTIVE, PAUSED, ARCHIVED, CLOSED, APPLIED, COLLATERALIZED, REVOKED, SUBMITTED, CONFIRMED, DECLINED, EXPECTED, PAID, FULFILLED, FAILED, CANCELLED} from "../type/StateId.sol";
4
+ import {ObjectType} from "../type/ObjectType.sol";
5
+ import {StateId, zeroStateId} from "../type/StateId.sol";
9
6
  import {ILifecycle} from "./ILifecycle.sol";
10
7
 
11
- contract Lifecycle is
12
- Initializable,
8
+ abstract contract Lifecycle is
13
9
  ILifecycle
14
10
  {
15
11
  mapping(ObjectType objectType => StateId initialState)
@@ -18,16 +14,17 @@ contract Lifecycle is
18
14
  mapping(ObjectType objectType => mapping(StateId stateFrom => mapping(StateId stateTo => bool isValid)))
19
15
  private _isValidTransition;
20
16
 
21
- function initializeLifecycle()
22
- public
23
- onlyInitializing
24
- {
25
- _setupBundleLifecycle();
26
- _setupComponentLifecycle();
27
- _setupPolicyLifecycle();
28
- _setupClaimAndPayoutLifecycle();
29
- _setupRiskLifecycle();
30
- _setupRequestLifecycle();
17
+ /// @dev child class must implement and CALL setup func at deployment/initializaton time
18
+ function _setupLifecycle() internal virtual;
19
+
20
+ function setInitialState(ObjectType ttype, StateId state) internal virtual {
21
+ assert(_initialState[ttype] == zeroStateId());
22
+ _initialState[ttype] = state;
23
+ }
24
+
25
+ function setStateTransition(ObjectType ttype, StateId oldState, StateId newState) internal virtual {
26
+ assert(_isValidTransition[ttype][oldState][newState] == false);
27
+ _isValidTransition[ttype][oldState][newState] = true;
31
28
  }
32
29
 
33
30
  function hasLifecycle(
@@ -59,9 +56,9 @@ contract Lifecycle is
59
56
  public
60
57
  view
61
58
  {
62
- // return if no life cycle support
59
+ // revert if no life cycle support
63
60
  if (_initialState[objectType].eqz()) {
64
- return;
61
+ revert ErrorNoLifecycle(objectType);
65
62
  }
66
63
 
67
64
  // enforce valid state transition
@@ -77,54 +74,4 @@ contract Lifecycle is
77
74
  ) public view returns (bool) {
78
75
  return _isValidTransition[objectType][fromId][toId];
79
76
  }
80
-
81
- function _setupComponentLifecycle() internal {
82
- _initialState[COMPONENT()] = ACTIVE();
83
- _isValidTransition[COMPONENT()][ACTIVE()][PAUSED()] = true;
84
- _isValidTransition[COMPONENT()][PAUSED()][ACTIVE()] = true;
85
- _isValidTransition[COMPONENT()][PAUSED()][ARCHIVED()] = true;
86
- }
87
-
88
- function _setupBundleLifecycle() internal {
89
- _initialState[BUNDLE()] = ACTIVE();
90
- _isValidTransition[BUNDLE()][ACTIVE()][PAUSED()] = true;
91
- _isValidTransition[BUNDLE()][ACTIVE()][CLOSED()] = true;
92
- _isValidTransition[BUNDLE()][PAUSED()][ACTIVE()] = true;
93
- _isValidTransition[BUNDLE()][PAUSED()][CLOSED()] = true;
94
- }
95
-
96
- function _setupPolicyLifecycle() internal {
97
- _initialState[POLICY()] = APPLIED();
98
- _isValidTransition[POLICY()][APPLIED()][REVOKED()] = true;
99
- _isValidTransition[POLICY()][APPLIED()][DECLINED()] = true;
100
- _isValidTransition[POLICY()][APPLIED()][COLLATERALIZED()] = true;
101
- _isValidTransition[POLICY()][APPLIED()][ACTIVE()] = true;
102
- _isValidTransition[POLICY()][COLLATERALIZED()][ACTIVE()] = true;
103
- _isValidTransition[POLICY()][ACTIVE()][CLOSED()] = true;
104
- }
105
-
106
- function _setupClaimAndPayoutLifecycle() internal {
107
- _initialState[CLAIM()] = SUBMITTED();
108
- _isValidTransition[CLAIM()][SUBMITTED()][CONFIRMED()] = true;
109
- _isValidTransition[CLAIM()][SUBMITTED()][DECLINED()] = true;
110
- _isValidTransition[CLAIM()][CONFIRMED()][CLOSED()] = true;
111
-
112
- _initialState[PAYOUT()] = EXPECTED();
113
- _isValidTransition[PAYOUT()][EXPECTED()][PAID()] = true;
114
- }
115
-
116
- function _setupRiskLifecycle() internal {
117
- _initialState[RISK()] = ACTIVE();
118
- _isValidTransition[RISK()][ACTIVE()][PAUSED()] = true;
119
- _isValidTransition[RISK()][PAUSED()][ACTIVE()] = true;
120
- _isValidTransition[RISK()][PAUSED()][ARCHIVED()] = true;
121
- }
122
-
123
- function _setupRequestLifecycle() internal {
124
- _initialState[REQUEST()] = ACTIVE();
125
- _isValidTransition[REQUEST()][ACTIVE()][FULFILLED()] = true;
126
- _isValidTransition[REQUEST()][ACTIVE()][FAILED()] = true;
127
- _isValidTransition[REQUEST()][FAILED()][FULFILLED()] = true;
128
- _isValidTransition[REQUEST()][ACTIVE()][CANCELLED()] = true;
129
- }
130
77
  }
@@ -4,17 +4,15 @@ pragma solidity ^0.8.20;
4
4
  import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
5
5
  import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
6
6
 
7
- import {ObjectType, REGISTRY, SERVICE} from "../type/ObjectType.sol";
8
- import {NftId} from "../type/NftId.sol";
9
- import {Version, VersionPart, VersionLib, VersionPartLib} from "../type/Version.sol";
10
-
11
- import {Versionable} from "./Versionable.sol";
7
+ import {IRegistry} from "../registry/IRegistry.sol";
12
8
  import {IService} from "./IService.sol";
13
9
  import {IVersionable} from "./IVersionable.sol";
14
- import {Versionable} from "./Versionable.sol";
10
+ import {NftId} from "../type/NftId.sol";
11
+ import {ObjectType, REGISTRY, SERVICE} from "../type/ObjectType.sol";
15
12
  import {Registerable} from "./Registerable.sol";
16
-
17
- import {IRegistry} from "../registry/IRegistry.sol";
13
+ import {RoleId, RoleIdLib} from "../type/RoleId.sol";
14
+ import {Version, VersionPart, VersionLib, VersionPartLib} from "../type/Version.sol";
15
+ import {Versionable} from "./Versionable.sol";
18
16
 
19
17
 
20
18
  /// @dev service base contract
@@ -27,15 +25,6 @@ abstract contract Service is
27
25
 
28
26
  uint8 private constant GIF_MAJOR_VERSION = 3;
29
27
 
30
- // from Versionable
31
- function getVersion()
32
- public
33
- pure
34
- virtual override (IVersionable, Versionable)
35
- returns(Version)
36
- {
37
- return VersionLib.toVersion(GIF_MAJOR_VERSION,0,0);
38
- }
39
28
 
40
29
  function initializeService(
41
30
  address registry,
@@ -58,9 +47,7 @@ abstract contract Service is
58
47
  if(authority != address(0)) {
59
48
  __AccessManaged_init(authority);
60
49
  } else {
61
- address registryServiceAddress = getRegistry().getServiceAddress(
62
- REGISTRY(),
63
- VersionPartLib.toVersionPart(GIF_MAJOR_VERSION));
50
+ address registryServiceAddress = _getServiceAddress(REGISTRY());
64
51
 
65
52
  // copy authority from already registered registry services
66
53
  __AccessManaged_init(IAccessManaged(registryServiceAddress).authority());
@@ -70,8 +57,27 @@ abstract contract Service is
70
57
  registerInterface(type(IService).interfaceId);
71
58
  }
72
59
 
60
+ function getDomain() external virtual pure returns(ObjectType serviceDomain) {
61
+ return _getDomain();
62
+ }
63
+
64
+ function getRoleId() external virtual pure returns(RoleId serviceRoleId) {
65
+ return RoleIdLib.roleForTypeAndVersion(_getDomain(), VersionPartLib.toVersionPart(GIF_MAJOR_VERSION));
66
+ }
67
+
68
+ // from Versionable
69
+ function getVersion()
70
+ public
71
+ pure
72
+ virtual override (IVersionable, Versionable)
73
+ returns(Version)
74
+ {
75
+ return VersionLib.toVersion(GIF_MAJOR_VERSION,0,0);
76
+ }
77
+
78
+ function _getDomain() internal virtual pure returns (ObjectType);
73
79
 
74
80
  function _getServiceAddress(ObjectType domain) internal view returns (address) {
75
- return getRegistry().getServiceAddress(domain, getVersion().toMajorPart());
81
+ return getRegistry().getServiceAddress(domain, VersionPartLib.toVersionPart(GIF_MAJOR_VERSION));
76
82
  }
77
83
  }
@@ -52,21 +52,25 @@ interface IStakingService is IService
52
52
  UFixed initialRewardRate
53
53
  ) external;
54
54
 
55
- /// @dev set the stake locking period to the specified duration.
55
+ /// @dev Set the instance stake locking period to the specified duration.
56
56
  /// permissioned: only the owner of the specified target may set the locking period
57
- function setLockingPeriod(NftId targetNftId, Seconds lockingPeriod) external;
57
+ function setInstanceLockingPeriod(NftId instanceNftId, Seconds lockingPeriod) external;
58
58
 
59
- /// @dev set the reward rate to the specified value
59
+ /// @dev Set the instance reward rate to the specified value
60
60
  /// permissioned: only the owner of the specified target may set the locking period
61
- function setRewardRate(NftId targetNftId, UFixed rewardRate) external;
61
+ function setInstanceRewardRate(NftId instanceNftId, UFixed rewardRate) external;
62
62
 
63
- /// @dev (re)fills the staking reward reserves for the specified target
63
+ /// @dev (Re)fills the staking reward reserves for the specified target using the dips provided by the reward provider.
64
64
  /// unpermissioned: anybody may fill up staking reward reserves
65
- function refillRewardReserves(NftId targetNftId, Amount dipAmount) external returns (Amount newBalance);
65
+ function refillInstanceRewardReserves(NftId instanceNftId, address rewardProvider, Amount dipAmount) external returns (Amount newBalance);
66
+
67
+ /// @dev (Re)fills the staking reward reserves for the specified target using the dips provided by the sender
68
+ /// unpermissioned: anybody may fill up staking reward reserves
69
+ function refillRewardReservesBySender(NftId targetNftId, Amount dipAmount) external returns (Amount newBalance);
66
70
 
67
71
  /// @dev defunds the staking reward reserves for the specified target
68
72
  /// permissioned: only the target owner may call this function
69
- function withdrawRewardReserves(NftId targetNftId, Amount dipAmount) external returns (Amount newBalance);
73
+ function withdrawInstanceRewardReserves(NftId instanceNftId, Amount dipAmount) external returns (Amount newBalance);
70
74
 
71
75
  /// @dev create a new stake with amount DIP to the specified target
72
76
  /// returns the id of the newly minted stake nft
@@ -13,12 +13,64 @@ import {NftId} from "../type/NftId.sol";
13
13
  import {ObjectType, INSTANCE, PROTOCOL, TARGET} from "../type/ObjectType.sol";
14
14
  import {Seconds, SecondsLib} from "../type/Seconds.sol";
15
15
  import {StakingReader} from "./StakingReader.sol";
16
+ import {StakingStore} from "./StakingStore.sol";
16
17
  import {Timestamp, TimestampLib} from "../type/Timestamp.sol";
17
18
  import {UFixed, UFixedLib} from "../type/UFixed.sol";
18
19
 
19
20
 
20
21
  library StakeManagerLib {
21
22
 
23
+ function stake(
24
+ IRegistry registry,
25
+ StakingReader stakingReader,
26
+ StakingStore stakingStore,
27
+ NftId stakeNftId,
28
+ Amount stakeAmount
29
+ )
30
+ external
31
+ returns (Amount stakeBalance)
32
+ {
33
+ // check that target is active for staking
34
+ (
35
+ UFixed rewardRate,
36
+ Seconds lockingPeriod
37
+ ) = checkStakeParameters(
38
+ stakingReader,
39
+ stakeNftId);
40
+
41
+ // calculate new rewards (if any)
42
+ (
43
+ Amount rewardIncrementAmount,
44
+ Amount currentTotalDipAmount
45
+ ) = calculateRewardIncrease(
46
+ stakingReader,
47
+ stakeNftId,
48
+ rewardRate);
49
+
50
+ stakeBalance = currentTotalDipAmount + stakeAmount;
51
+
52
+ // TODO check that additional dip, rewards and rewards increment
53
+ // are still ok with max target staking amount
54
+ NftId targetNftId = registry.getObjectInfo(stakeNftId).parentNftId;
55
+
56
+ stakingStore.restakeRewards(
57
+ stakeNftId,
58
+ targetNftId,
59
+ rewardIncrementAmount);
60
+
61
+ stakingStore.increaseStake(
62
+ stakeNftId,
63
+ targetNftId,
64
+ stakeAmount);
65
+
66
+ // update locked until with target locking period
67
+ stakingStore.update(
68
+ stakeNftId,
69
+ IStaking.StakeInfo({
70
+ lockedUntil: TimestampLib.blockTimestamp().addSeconds(
71
+ lockingPeriod)}));
72
+
73
+ }
22
74
 
23
75
  function checkCreateParameters(
24
76
  StakingReader stakingReader,
@@ -9,7 +9,6 @@ import {IRegistryService} from "../registry/IRegistryService.sol";
9
9
  import {IStaking} from "./IStaking.sol";
10
10
  import {IVersionable} from "../shared/IVersionable.sol";
11
11
  import {Key32} from "../type/Key32.sol";
12
- import {KEEP_STATE} from "../type/StateId.sol";
13
12
  import {LibNftIdSet} from "../type/NftIdSet.sol";
14
13
  import {NftId, NftIdLib} from "../type/NftId.sol";
15
14
  import {NftIdSetManager} from "../shared/NftIdSetManager.sol";
@@ -61,22 +60,11 @@ contract Staking is
61
60
  _;
62
61
  }
63
62
 
64
-
65
- // from Versionable
66
- function getVersion()
67
- public
68
- pure
69
- virtual override (IVersionable, Versionable)
70
- returns(Version)
71
- {
72
- return VersionLib.toVersion(GIF_MAJOR_VERSION,0,0);
73
- }
74
-
75
63
  // set/update staking reader
76
64
  function setStakingReader(StakingReader stakingReader)
77
65
  external
78
66
  virtual
79
- onlyOwner
67
+ onlyOwner()
80
68
  {
81
69
  if(stakingReader.getStaking() != IStaking(this)) {
82
70
  revert ErrorStakingStakingReaderStakingMismatch(address(stakingReader.getStaking()));
@@ -90,7 +78,7 @@ contract Staking is
90
78
  function setStakingRate(uint256 chainId, address token, UFixed stakingRate)
91
79
  external
92
80
  virtual
93
- onlyOwner
81
+ onlyOwner()
94
82
  {
95
83
  StakingStorage storage $ = _getStakingStorage();
96
84
 
@@ -104,8 +92,6 @@ contract Staking is
104
92
  emit LogStakingStakingRateSet(chainId, token, oldStakingRate, stakingRate);
105
93
  }
106
94
 
107
- // reward management
108
-
109
95
  // target management
110
96
 
111
97
  function registerTarget(
@@ -117,7 +103,7 @@ contract Staking is
117
103
  )
118
104
  external
119
105
  virtual
120
- // restricted // staking service access
106
+ restricted()
121
107
  {
122
108
  TargetManagerLib.checkTargetParameters(
123
109
  getRegistry(),
@@ -143,7 +129,7 @@ contract Staking is
143
129
  )
144
130
  external
145
131
  virtual
146
- // TODO add restricted // only staking service
132
+ restricted()
147
133
  onlyTarget(targetNftId)
148
134
  {
149
135
  (
@@ -165,7 +151,7 @@ contract Staking is
165
151
  function setRewardRate(NftId targetNftId, UFixed rewardRate)
166
152
  external
167
153
  virtual
168
- // TODO add restricted // only staking service
154
+ restricted()
169
155
  onlyTarget(targetNftId)
170
156
  {
171
157
  (
@@ -185,7 +171,7 @@ contract Staking is
185
171
  function refillRewardReserves(NftId targetNftId, Amount dipAmount)
186
172
  external
187
173
  virtual
188
- // TODO add restricted // only for target locking
174
+ restricted()
189
175
  returns (Amount newBalance)
190
176
  {
191
177
  // update book keeping of reward reserves
@@ -197,8 +183,7 @@ contract Staking is
197
183
  function withdrawRewardReserves(NftId targetNftId, Amount dipAmount)
198
184
  external
199
185
  virtual
200
- // TODO add restricted // only staking service
201
- // onlyNftOwner(targetNftId)
186
+ restricted()
202
187
  returns (Amount newBalance)
203
188
  {
204
189
  // update book keeping of reward reserves
@@ -210,7 +195,7 @@ contract Staking is
210
195
  function increaseTotalValueLocked(NftId targetNftId, address token, Amount amount)
211
196
  external
212
197
  virtual
213
- // restricted() // only pool service
198
+ restricted() // only pool service
214
199
  returns (Amount newBalance)
215
200
  {
216
201
  StakingStorage storage $ = _getStakingStorage();
@@ -223,7 +208,7 @@ contract Staking is
223
208
  function decreaseTotalValueLocked(NftId targetNftId, address token, Amount amount)
224
209
  external
225
210
  virtual
226
- // restricted() // only pool service
211
+ restricted() // only pool service
227
212
  returns (Amount newBalance)
228
213
  {
229
214
  StakingStorage storage $ = _getStakingStorage();
@@ -236,6 +221,7 @@ contract Staking is
236
221
  function registerRemoteTarget(NftId targetNftId, TargetInfo memory targetInfo)
237
222
  external
238
223
  virtual
224
+ restricted()
239
225
  onlyOwner // or CCIP
240
226
  {
241
227
 
@@ -244,6 +230,7 @@ contract Staking is
244
230
  function updateRemoteTvl(NftId targetNftId, address token, Amount amount)
245
231
  external
246
232
  virtual
233
+ restricted()
247
234
  onlyOwner // or CCIP
248
235
  {
249
236
 
@@ -258,7 +245,7 @@ contract Staking is
258
245
  )
259
246
  external
260
247
  virtual
261
- // TODO add restricted() // only staking service
248
+ restricted() // only staking service
262
249
  {
263
250
  StakingStorage storage $ = _getStakingStorage();
264
251
  Timestamp lockedUntil = StakeManagerLib.checkCreateParameters(
@@ -286,51 +273,17 @@ contract Staking is
286
273
  )
287
274
  external
288
275
  virtual
289
- // TODO add restricted() // only staking service
276
+ restricted() // only staking service
290
277
  onlyStake(stakeNftId)
291
278
  returns (Amount stakeBalance)
292
279
  {
293
280
  StakingStorage storage $ = _getStakingStorage();
294
-
295
- // check that target is active for staking
296
- (
297
- UFixed rewardRate,
298
- Seconds lockingPeriod
299
- ) = StakeManagerLib.checkStakeParameters(
300
- $._reader,
301
- stakeNftId);
302
-
303
- // calculate new rewards (if any)
304
- (
305
- Amount rewardIncrementAmount,
306
- Amount currentTotalDipAmount
307
- ) = StakeManagerLib.calculateRewardIncrease(
308
- $._reader,
281
+ stakeBalance = StakeManagerLib.stake(
282
+ getRegistry(),
283
+ $._reader,
284
+ $._store,
309
285
  stakeNftId,
310
- rewardRate);
311
-
312
- stakeBalance = currentTotalDipAmount + stakeAmount;
313
-
314
- // TODO check that additional dip, rewards and rewards increment
315
- // are still ok with max target staking amount
316
- NftId targetNftId = getRegistry().getObjectInfo(stakeNftId).parentNftId;
317
-
318
- $._store.restakeRewards(
319
- stakeNftId,
320
- targetNftId,
321
- rewardIncrementAmount);
322
-
323
- $._store.increaseStake(
324
- stakeNftId,
325
- targetNftId,
326
286
  stakeAmount);
327
-
328
- // update locked until with target locking period
329
- $._store.update(
330
- stakeNftId,
331
- StakeInfo({
332
- lockedUntil: TimestampLib.blockTimestamp().addSeconds(
333
- lockingPeriod)}));
334
287
  }
335
288
 
336
289
 
@@ -340,7 +293,7 @@ contract Staking is
340
293
  )
341
294
  external
342
295
  virtual
343
- // TODO add restricted() // only staking service
296
+ restricted() // only staking service
344
297
  onlyStake(stakeNftId)
345
298
  returns (NftId newStakeNftId)
346
299
  {
@@ -354,7 +307,7 @@ contract Staking is
354
307
  function updateRewards(NftId stakeNftId)
355
308
  external
356
309
  virtual
357
- // TODO add restricted() // only staking service
310
+ restricted() // only staking service
358
311
  onlyStake(stakeNftId)
359
312
  {
360
313
  StakingStorage storage $ = _getStakingStorage();
@@ -365,7 +318,7 @@ contract Staking is
365
318
  function claimRewards(NftId stakeNftId)
366
319
  external
367
320
  virtual
368
- // TODO add restricted() // only staking service
321
+ restricted() // only staking service
369
322
  onlyStake(stakeNftId)
370
323
  returns (
371
324
  Amount rewardsClaimedAmount
@@ -390,7 +343,7 @@ contract Staking is
390
343
  function unstake(NftId stakeNftId)
391
344
  external
392
345
  virtual
393
- // TODO add restricted() // only staking service
346
+ restricted() // only staking service
394
347
  onlyStake(stakeNftId)
395
348
  returns (
396
349
  Amount unstakedAmount,
@@ -419,35 +372,11 @@ contract Staking is
419
372
 
420
373
 
421
374
 
422
- function _updateRewards(
423
- StakingReader reader,
424
- StakingStore store,
425
- NftId stakeNftId
426
- )
427
- internal
428
- virtual
429
- returns (NftId targetNftId)
430
- {
431
- UFixed rewardRate;
432
-
433
- (targetNftId, rewardRate) = reader.getTargetRewardRate(stakeNftId);
434
- (Amount rewardIncrement, ) = StakeManagerLib.calculateRewardIncrease(
435
- reader,
436
- stakeNftId,
437
- rewardRate);
438
-
439
- store.updateRewards(
440
- stakeNftId,
441
- targetNftId,
442
- rewardIncrement);
443
- }
444
-
445
-
446
375
  //--- other functions ---------------------------------------------------//
447
376
 
448
377
  function collectDipAmount(address from, Amount dipAmount)
449
378
  external
450
- // TODO add restricted() // only staking service
379
+ restricted() // only staking service
451
380
  {
452
381
  TokenHandler tokenHandler = getTokenHandler();
453
382
  address stakingWallet = getWallet();
@@ -464,7 +393,7 @@ contract Staking is
464
393
 
465
394
  function transferDipAmount(address to, Amount dipAmount)
466
395
  external
467
- // TODO add restricted() // only staking service
396
+ restricted() // only staking service
468
397
  {
469
398
  TokenHandler tokenHandler = getTokenHandler();
470
399
  address stakingWallet = getWallet();
@@ -493,8 +422,43 @@ contract Staking is
493
422
  return address(_getStakingStorage()._tokenRegistry);
494
423
  }
495
424
 
425
+
426
+ // from Versionable
427
+ function getVersion()
428
+ public
429
+ pure
430
+ virtual override (IVersionable, Versionable)
431
+ returns(Version)
432
+ {
433
+ return VersionLib.toVersion(GIF_MAJOR_VERSION,0,0);
434
+ }
435
+
496
436
  //--- internal functions ------------------------------------------------//
497
437
 
438
+ function _updateRewards(
439
+ StakingReader reader,
440
+ StakingStore store,
441
+ NftId stakeNftId
442
+ )
443
+ internal
444
+ virtual
445
+ returns (NftId targetNftId)
446
+ {
447
+ UFixed rewardRate;
448
+
449
+ (targetNftId, rewardRate) = reader.getTargetRewardRate(stakeNftId);
450
+ (Amount rewardIncrement, ) = StakeManagerLib.calculateRewardIncrease(
451
+ reader,
452
+ stakeNftId,
453
+ rewardRate);
454
+
455
+ store.updateRewards(
456
+ stakeNftId,
457
+ targetNftId,
458
+ rewardIncrement);
459
+ }
460
+
461
+
498
462
  function _initialize(
499
463
  address owner,
500
464
  bytes memory data
@@ -530,7 +494,6 @@ contract Staking is
530
494
 
531
495
  _createAndSetTokenHandler();
532
496
 
533
-
534
497
  // wiring to external contracts
535
498
  StakingStorage storage $ = _getStakingStorage();
536
499
  $._protocolNftId = getRegistry().getProtocolNftId();
@@ -547,5 +510,4 @@ contract Staking is
547
510
  $.slot := STAKING_LOCATION_V1
548
511
  }
549
512
  }
550
-
551
513
  }
@@ -0,0 +1,23 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {TARGET, COMPONENT, STAKE} from "../type/ObjectType.sol";
5
+ import {INITIAL} from "../type/StateId.sol";
6
+ import {Lifecycle} from "../shared/Lifecycle.sol";
7
+
8
+ contract StakingLifecycle is
9
+ Lifecycle
10
+ {
11
+ constructor() {
12
+ _setupLifecycle();
13
+ }
14
+
15
+ function _setupLifecycle()
16
+ internal
17
+ override
18
+ {
19
+ setInitialState(TARGET(), INITIAL());
20
+ setInitialState(COMPONENT(), INITIAL());
21
+ setInitialState(STAKE(), INITIAL());
22
+ }
23
+ }