@etherisc/gif-next 0.0.2-9ed3c41-176 → 0.0.2-9f1b659-471
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.
- package/README.md +103 -9
- package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.dbg.json +4 -0
- package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.json +1075 -0
- package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.dbg.json +4 -0
- package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.json +790 -0
- package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.dbg.json +4 -0
- package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.json +843 -0
- package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.dbg.json +1 -1
- package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.json +673 -262
- package/artifacts/contracts/authorization/AccessAdminLib.sol/AccessAdminLib.dbg.json +4 -0
- package/artifacts/contracts/authorization/AccessAdminLib.sol/AccessAdminLib.json +1289 -0
- package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.dbg.json +1 -1
- package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.json +202 -5
- package/artifacts/contracts/authorization/Authorization.sol/Authorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/Authorization.sol/Authorization.json +456 -24
- package/artifacts/contracts/authorization/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.dbg.json +1 -1
- package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.json +549 -209
- package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.json +215 -18
- package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.json +265 -16
- package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.json +473 -17
- package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.dbg.json +1 -1
- package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.json +212 -473
- package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.dbg.json +1 -1
- package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.json +431 -36
- package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +139 -381
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +814 -399
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +228 -124
- package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +135 -187
- package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +582 -141
- package/artifacts/contracts/examples/fire/DamageLevel.sol/DamageLevelLib.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/DamageLevel.sol/DamageLevelLib.json +22 -0
- package/artifacts/contracts/examples/fire/FirePool.sol/FirePool.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/FirePool.sol/FirePool.json +1484 -0
- package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.json +805 -0
- package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.json +2053 -0
- package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.json +805 -0
- package/artifacts/contracts/examples/fire/FireUSD.sol/FireUSD.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/FireUSD.sol/FireUSD.json +376 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.json +1439 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.json +805 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.json +1171 -0
- package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.json +1647 -0
- package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.json +805 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.json +2585 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleProductAuthorization.sol/SimpleProductAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleProductAuthorization.sol/SimpleProductAuthorization.json +805 -0
- package/artifacts/contracts/instance/BundleSet.sol/BundleSet.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleSet.sol/BundleSet.json +193 -45
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +567 -67
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +385 -60
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +573 -165
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +1034 -311
- package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +369 -68
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1685 -774
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +399 -231
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +143 -105
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +983 -782
- package/artifacts/contracts/instance/RiskSet.sol/RiskSet.dbg.json +4 -0
- package/artifacts/contracts/instance/RiskSet.sol/RiskSet.json +866 -0
- package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.json +8 -8
- package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.json +2 -2
- package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.json +46 -5
- package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.json +16 -5
- package/artifacts/contracts/instance/base/ObjectSetHelperLib.sol/ObjectSetHelperLib.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ObjectSetHelperLib.sol/ObjectSetHelperLib.json +168 -0
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/mock/Dip.sol/Dip.dbg.json +1 -1
- package/artifacts/contracts/mock/Dip.sol/Dip.json +2 -2
- package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.json +152 -350
- package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +1 -1
- package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +429 -37
- package/artifacts/contracts/oracle/IOracle.sol/IOracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.json +129 -129
- package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.json +98 -11
- package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +128 -318
- package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +198 -190
- package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +177 -97
- package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +1 -1
- package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +198 -433
- package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +1 -1
- package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +430 -35
- package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleService.sol/BundleService.json +574 -270
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +216 -104
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +383 -53
- package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +158 -212
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +711 -340
- package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/pool/Pool.sol/Pool.json +148 -392
- package/artifacts/contracts/pool/PoolLib.sol/PoolLib.dbg.json +4 -0
- package/artifacts/contracts/pool/PoolLib.sol/PoolLib.json +522 -0
- package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolService.sol/PoolService.json +925 -545
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +230 -106
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +353 -180
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +159 -99
- package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +1 -1
- package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +287 -427
- package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +1 -1
- package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +430 -35
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +466 -245
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +187 -123
- package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.json +301 -9
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +350 -18
- package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +417 -101
- package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
- package/artifacts/contracts/product/IPricingService.sol/IPricingService.json +183 -80
- package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +272 -222
- package/artifacts/contracts/product/IRiskService.sol/IRiskService.dbg.json +4 -0
- package/artifacts/contracts/{shared/ComponentVerifyingService.sol/ComponentVerifyingService.json → product/IRiskService.sol/IRiskService.json} +283 -157
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +532 -311
- package/artifacts/contracts/product/PolicyServiceLib.sol/PolicyServiceLib.dbg.json +4 -0
- package/artifacts/contracts/product/PolicyServiceLib.sol/PolicyServiceLib.json +783 -0
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +196 -108
- package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
- package/artifacts/contracts/product/PricingService.sol/PricingService.json +249 -329
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +165 -137
- package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/product/Product.sol/Product.json +279 -419
- package/artifacts/contracts/product/RiskService.sol/RiskService.dbg.json +4 -0
- package/artifacts/contracts/product/RiskService.sol/RiskService.json +873 -0
- package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.dbg.json +4 -0
- package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.json +774 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +59 -16
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +359 -48
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +169 -37
- package/artifacts/contracts/registry/IRelease.sol/IRelease.dbg.json +4 -0
- package/artifacts/contracts/registry/IRelease.sol/IRelease.json +24 -0
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +5 -18
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +565 -109
- package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +795 -394
- package/artifacts/contracts/registry/RegistryAuthorization.sol/RegistryAuthorization.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryAuthorization.sol/RegistryAuthorization.json +1061 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +136 -290
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +141 -89
- package/artifacts/contracts/registry/ReleaseAdmin.sol/ReleaseAdmin.dbg.json +4 -0
- package/artifacts/contracts/registry/ReleaseAdmin.sol/ReleaseAdmin.json +2152 -0
- package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.json +47 -6
- package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.json +483 -253
- package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +1 -1
- package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +489 -20
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +120 -60
- package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/shared/Component.sol/Component.json +86 -277
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +624 -560
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +198 -120
- package/artifacts/contracts/shared/ContractLib.sol/ContractLib.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractLib.sol/ContractLib.json +632 -0
- package/artifacts/contracts/shared/ContractLib.sol/IInstanceAdminHelper.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractLib.sol/IInstanceAdminHelper.json +24 -0
- package/artifacts/contracts/shared/ContractLib.sol/ITargetHelper.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractLib.sol/ITargetHelper.json +30 -0
- package/artifacts/contracts/shared/ContractLib.sol/ITokenRegistryHelper.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractLib.sol/ITokenRegistryHelper.json +40 -0
- package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponent.sol/IComponent.json +92 -93
- package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponentService.sol/IComponentService.json +535 -240
- package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +118 -129
- package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.json +42 -6
- package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.json +36 -0
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +35 -0
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +15 -47
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +167 -0
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +84 -2
- package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.dbg.json +4 -0
- package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.json +53 -0
- package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.json +117 -318
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.json +48 -7
- package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.json +42 -1
- package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.dbg.json +1 -1
- package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.json +2 -2
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +41 -57
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +19 -141
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +141 -97
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -15
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +86 -111
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +585 -12
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandlerBase.dbg.json +4 -0
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandlerBase.json +484 -0
- package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.dbg.json +4 -0
- package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.json +172 -0
- package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/IStaking.sol/IStaking.json +1305 -159
- package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
- package/artifacts/contracts/staking/IStakingService.sol/IStakingService.json +235 -123
- package/artifacts/contracts/staking/ITargetManager.sol/ITargetManager.dbg.json +4 -0
- package/artifacts/contracts/staking/ITargetManager.sol/ITargetManager.json +69 -0
- package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
- package/artifacts/contracts/staking/Staking.sol/Staking.json +1588 -478
- package/artifacts/contracts/staking/StakingLib.sol/StakingLib.dbg.json +4 -0
- package/artifacts/contracts/staking/StakingLib.sol/StakingLib.json +470 -0
- package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.json +46 -5
- package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +225 -104
- package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +185 -223
- package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingService.sol/StakingService.json +282 -281
- package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +144 -96
- package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +1311 -560
- package/artifacts/contracts/staking/TargetManager.sol/TargetManager.dbg.json +4 -0
- package/artifacts/contracts/staking/TargetManager.sol/TargetManager.json +134 -0
- package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
- package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +135 -49
- package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
- package/artifacts/contracts/type/Amount.sol/AmountLib.json +63 -10
- package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.json +45 -19
- package/artifacts/contracts/type/ChainId.sol/ChainIdLib.dbg.json +4 -0
- package/artifacts/contracts/type/ChainId.sol/ChainIdLib.json +193 -0
- package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.json +28 -4
- package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.json +2 -2
- package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/type/Fee.sol/FeeLib.json +98 -37
- package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/type/Key32.sol/Key32Lib.json +2 -2
- package/artifacts/contracts/type/Key32Set.sol/LibKey32Set.dbg.json +4 -0
- package/artifacts/contracts/type/Key32Set.sol/LibKey32Set.json +33 -0
- package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/NftId.sol/NftIdLib.json +23 -4
- package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.json +2 -2
- package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.json +33 -31
- package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.json +19 -19
- package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/type/Referral.sol/ReferralLib.json +2 -2
- package/artifacts/contracts/type/RequestId.sol/RequestIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RequestId.sol/RequestIdLib.json +2 -2
- package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RiskId.sol/RiskIdLib.json +125 -7
- package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +42 -157
- package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
- package/artifacts/contracts/type/Seconds.sol/SecondsLib.json +93 -2
- package/artifacts/contracts/type/Selector.sol/SelectorLib.dbg.json +1 -1
- package/artifacts/contracts/type/Selector.sol/SelectorLib.json +21 -2
- package/artifacts/contracts/type/Selector.sol/SelectorSetLib.dbg.json +1 -1
- package/artifacts/contracts/type/Selector.sol/SelectorSetLib.json +2 -2
- package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/StateId.sol/StateIdLib.json +15 -2
- package/artifacts/contracts/type/String.sol/StrLib.dbg.json +1 -1
- package/artifacts/contracts/type/String.sol/StrLib.json +50 -2
- package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/type/Timestamp.sol/TimestampLib.json +24 -5
- package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/type/UFixed.sol/UFixedLib.json +109 -35
- package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/type/Version.sol/VersionLib.json +2 -21
- package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/type/Version.sol/VersionPartLib.json +101 -2
- package/artifacts/contracts/upgradeability/IVersionable.sol/IVersionable.dbg.json +4 -0
- package/artifacts/contracts/{shared → upgradeability}/IVersionable.sol/IVersionable.json +11 -1
- package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.dbg.json +4 -0
- package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.json +656 -0
- package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
- package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +142 -0
- package/artifacts/contracts/upgradeability/Versionable.sol/Versionable.dbg.json +4 -0
- package/artifacts/contracts/{shared → upgradeability}/Versionable.sol/Versionable.json +11 -1
- package/contracts/accounting/AccountingService.sol +274 -0
- package/contracts/accounting/AccountingServiceManager.sol +38 -0
- package/contracts/accounting/IAccountingService.sol +47 -0
- package/contracts/authorization/AccessAdmin.sol +458 -269
- package/contracts/authorization/AccessAdminLib.sol +396 -0
- package/contracts/authorization/AccessManagerCloneable.sol +146 -4
- package/contracts/authorization/Authorization.sol +159 -208
- package/contracts/authorization/IAccess.sol +25 -6
- package/contracts/authorization/IAccessAdmin.sol +87 -79
- package/contracts/authorization/IAuthorization.sol +9 -37
- package/contracts/authorization/IServiceAuthorization.sol +57 -17
- package/contracts/authorization/ServiceAuthorization.sol +255 -25
- package/contracts/distribution/BasicDistribution.sol +22 -30
- package/contracts/distribution/BasicDistributionAuthorization.sol +34 -10
- package/contracts/distribution/Distribution.sol +48 -84
- package/contracts/distribution/DistributionService.sol +276 -130
- package/contracts/distribution/DistributionServiceManager.sol +8 -11
- package/contracts/distribution/IDistributionComponent.sol +11 -14
- package/contracts/distribution/IDistributionService.sol +56 -26
- package/contracts/examples/fire/DamageLevel.sol +59 -0
- package/contracts/examples/fire/FirePool.sol +86 -0
- package/contracts/examples/fire/FirePoolAuthorization.sol +35 -0
- package/contracts/examples/fire/FireProduct.sol +433 -0
- package/contracts/examples/fire/FireProductAuthorization.sol +45 -0
- package/contracts/examples/fire/FireUSD.sol +26 -0
- package/contracts/examples/unpermissioned/SimpleDistribution.sol +81 -0
- package/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol +28 -0
- package/contracts/examples/unpermissioned/SimpleOracle.sol +133 -0
- package/contracts/examples/unpermissioned/SimplePool.sol +102 -0
- package/contracts/examples/unpermissioned/SimplePoolAuthorization.sol +28 -0
- package/contracts/examples/unpermissioned/SimpleProduct.sol +437 -0
- package/contracts/examples/unpermissioned/SimpleProductAuthorization.sol +28 -0
- package/contracts/instance/BundleSet.sol +42 -38
- package/contracts/instance/IInstance.sol +102 -43
- package/contracts/instance/IInstanceService.sol +59 -34
- package/contracts/instance/Instance.sol +193 -100
- package/contracts/instance/InstanceAdmin.sol +275 -158
- package/contracts/instance/InstanceAuthorizationV3.sol +120 -56
- package/contracts/instance/InstanceReader.sol +478 -251
- package/contracts/instance/InstanceService.sol +293 -236
- package/contracts/instance/InstanceServiceManager.sol +8 -13
- package/contracts/instance/InstanceStore.sol +24 -2
- package/contracts/instance/RiskSet.sol +126 -0
- package/contracts/instance/base/BalanceStore.sol +4 -6
- package/contracts/instance/base/ObjectCounter.sol +1 -2
- package/contracts/instance/base/ObjectLifecycle.sol +13 -10
- package/contracts/instance/base/ObjectSet.sol +31 -33
- package/contracts/instance/base/ObjectSetHelperLib.sol +30 -0
- package/contracts/instance/module/IBundle.sol +6 -5
- package/contracts/instance/module/IComponents.sol +30 -20
- package/contracts/instance/module/IDistribution.sol +21 -9
- package/contracts/instance/module/IPolicy.sol +50 -29
- package/contracts/instance/module/IRisk.sol +5 -0
- package/contracts/mock/Dip.sol +1 -1
- package/contracts/oracle/BasicOracle.sol +2 -5
- package/contracts/oracle/BasicOracleAuthorization.sol +15 -8
- package/contracts/oracle/IOracle.sol +9 -4
- package/contracts/oracle/IOracleComponent.sol +2 -1
- package/contracts/oracle/IOracleService.sol +2 -1
- package/contracts/oracle/Oracle.sol +23 -26
- package/contracts/oracle/OracleService.sol +119 -87
- package/contracts/oracle/OracleServiceManager.sol +8 -11
- package/contracts/pool/BasicPool.sol +39 -41
- package/contracts/pool/BasicPoolAuthorization.sol +43 -11
- package/contracts/pool/BundleService.sol +218 -128
- package/contracts/pool/BundleServiceManager.sol +8 -11
- package/contracts/pool/IBundleService.sol +43 -33
- package/contracts/pool/IPoolComponent.sol +20 -10
- package/contracts/pool/IPoolService.sol +97 -77
- package/contracts/pool/Pool.sol +146 -124
- package/contracts/pool/PoolLib.sol +341 -0
- package/contracts/pool/PoolService.sol +419 -256
- package/contracts/pool/PoolServiceManager.sol +6 -9
- package/contracts/product/ApplicationService.sol +153 -80
- package/contracts/product/ApplicationServiceManager.sol +6 -6
- package/contracts/product/BasicProduct.sol +13 -46
- package/contracts/product/BasicProductAuthorization.sol +33 -10
- package/contracts/product/ClaimService.sol +382 -194
- package/contracts/product/ClaimServiceManager.sol +6 -6
- package/contracts/product/IApplicationService.sol +29 -3
- package/contracts/product/IClaimService.sol +48 -11
- package/contracts/product/IPolicyService.sol +61 -37
- package/contracts/product/IPricingService.sol +11 -10
- package/contracts/product/IProductComponent.sol +28 -5
- package/contracts/product/IRiskService.sol +48 -0
- package/contracts/product/PolicyService.sol +443 -273
- package/contracts/product/PolicyServiceLib.sol +139 -0
- package/contracts/product/PolicyServiceManager.sol +6 -9
- package/contracts/product/PricingService.sol +90 -84
- package/contracts/product/PricingServiceManager.sol +6 -9
- package/contracts/product/Product.sol +201 -100
- package/contracts/product/RiskService.sol +190 -0
- package/contracts/product/RiskServiceManager.sol +39 -0
- package/contracts/registry/ChainNft.sol +72 -40
- package/contracts/registry/IRegistry.sol +70 -32
- package/contracts/registry/IRegistryService.sol +5 -12
- package/contracts/registry/IRelease.sol +29 -0
- package/contracts/registry/ITransferInterceptor.sol +1 -2
- package/contracts/registry/Registry.sol +367 -207
- package/contracts/registry/RegistryAdmin.sol +110 -287
- package/contracts/registry/RegistryAuthorization.sol +312 -0
- package/contracts/registry/RegistryService.sol +42 -67
- package/contracts/registry/RegistryServiceManager.sol +5 -5
- package/contracts/registry/ReleaseAdmin.sol +195 -0
- package/contracts/registry/ReleaseLifecycle.sol +8 -3
- package/contracts/registry/ReleaseRegistry.sol +279 -241
- package/contracts/registry/ServiceAuthorizationV3.sol +205 -63
- package/contracts/registry/TokenRegistry.sol +61 -59
- package/contracts/shared/Component.sol +70 -137
- package/contracts/shared/ComponentService.sol +452 -346
- package/contracts/shared/ComponentServiceManager.sol +10 -7
- package/contracts/shared/ContractLib.sol +312 -0
- package/contracts/shared/IComponent.sol +6 -18
- package/contracts/shared/IComponentService.sol +50 -41
- package/contracts/shared/IInstanceLinkedComponent.sol +7 -27
- package/contracts/shared/IKeyValueStore.sol +1 -1
- package/contracts/shared/ILifecycle.sol +3 -1
- package/contracts/shared/INftOwnable.sol +4 -0
- package/contracts/shared/IPolicyHolder.sol +12 -22
- package/contracts/shared/IRegisterable.sol +22 -1
- package/contracts/shared/IService.sol +4 -6
- package/contracts/shared/{ERC165.sol → InitializableERC165.sol} +11 -3
- package/contracts/shared/InstanceLinkedComponent.sol +83 -40
- package/contracts/shared/KeyValueStore.sol +4 -4
- package/contracts/shared/Lifecycle.sol +15 -4
- package/contracts/shared/NftOwnable.sol +33 -11
- package/contracts/shared/PolicyHolder.sol +20 -59
- package/contracts/shared/Registerable.sol +52 -21
- package/contracts/shared/RegistryLinked.sol +9 -14
- package/contracts/shared/Service.sol +22 -38
- package/contracts/shared/TokenHandler.sol +310 -26
- package/contracts/shared/TokenHandlerDeployerLib.sol +20 -0
- package/contracts/staking/IStaking.sol +203 -69
- package/contracts/staking/IStakingService.sol +45 -78
- package/contracts/staking/ITargetManager.sol +28 -0
- package/contracts/staking/Staking.sol +525 -243
- package/contracts/staking/StakingLib.sol +195 -0
- package/contracts/staking/StakingManager.sol +11 -13
- package/contracts/staking/StakingReader.sol +55 -90
- package/contracts/staking/StakingService.sol +62 -152
- package/contracts/staking/StakingServiceManager.sol +9 -7
- package/contracts/staking/StakingStore.sol +867 -337
- package/contracts/staking/TargetManager.sol +103 -0
- package/contracts/staking/TargetManagerLib.sol +8 -4
- package/contracts/type/Amount.sol +31 -5
- package/contracts/type/Blocknumber.sol +22 -16
- package/contracts/type/ChainId.sol +101 -0
- package/contracts/type/ClaimId.sol +6 -1
- package/contracts/type/Fee.sol +8 -8
- package/contracts/type/Key32.sol +2 -2
- package/contracts/type/Key32Set.sol +62 -0
- package/contracts/type/NftId.sol +7 -0
- package/contracts/type/ObjectType.sol +73 -37
- package/contracts/type/PayoutId.sol +10 -10
- package/contracts/type/Referral.sol +1 -0
- package/contracts/type/RiskId.sol +38 -6
- package/contracts/type/RoleId.sol +61 -55
- package/contracts/type/Seconds.sol +35 -1
- package/contracts/type/Selector.sol +5 -0
- package/contracts/type/StateId.sol +15 -1
- package/contracts/type/String.sol +12 -0
- package/contracts/type/Timestamp.sol +14 -7
- package/contracts/type/UFixed.sol +57 -126
- package/contracts/type/Version.sol +54 -5
- package/contracts/{shared → upgradeability}/IVersionable.sol +3 -0
- package/contracts/{shared → upgradeability}/ProxyManager.sol +96 -49
- package/contracts/upgradeability/UpgradableProxyWithAdmin.sol +24 -0
- package/contracts/{shared → upgradeability}/Versionable.sol +8 -5
- package/package.json +5 -4
- package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.dbg.json +0 -4
- package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.json +0 -290
- package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.dbg.json +0 -4
- package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.json +0 -390
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +0 -4
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +0 -129
- package/artifacts/contracts/product/IProductService.sol/IProductService.dbg.json +0 -4
- package/artifacts/contracts/product/IProductService.sol/IProductService.json +0 -400
- package/artifacts/contracts/product/ProductService.sol/ProductService.dbg.json +0 -4
- package/artifacts/contracts/product/ProductService.sol/ProductService.json +0 -708
- package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +0 -4
- package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +0 -702
- package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +0 -4
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +0 -4
- package/artifacts/contracts/shared/ERC165.sol/ERC165.json +0 -73
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +0 -4
- package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.dbg.json +0 -4
- package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.json +0 -39
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +0 -4
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +0 -617
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +0 -4
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +0 -129
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +0 -4
- package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +0 -4
- package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +0 -460
- package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +0 -4
- package/artifacts/contracts/type/UFixed.sol/MathLib.json +0 -10
- package/contracts/authorization/IModuleAuthorization.sol +0 -21
- package/contracts/authorization/ModuleAuthorization.sol +0 -78
- package/contracts/instance/module/IAccess.sol +0 -46
- package/contracts/product/IProductService.sol +0 -33
- package/contracts/product/ProductService.sol +0 -124
- package/contracts/product/ProductServiceManager.sol +0 -42
- package/contracts/shared/ComponentVerifyingService.sol +0 -117
- package/contracts/shared/InitializableCustom.sol +0 -177
- package/contracts/shared/UpgradableProxyWithAdmin.sol +0 -16
- package/contracts/staking/StakeManagerLib.sol +0 -231
@@ -3,31 +3,25 @@ pragma solidity ^0.8.20;
|
|
3
3
|
|
4
4
|
import {AccessManaged} from "@openzeppelin/contracts/access/manager/AccessManaged.sol";
|
5
5
|
|
6
|
-
import {Amount, AmountLib} from "../type/Amount.sol";
|
7
|
-
import {Blocknumber, BlocknumberLib} from "../type/Blocknumber.sol";
|
8
|
-
import {ChainNft} from "../registry/ChainNft.sol";
|
9
|
-
import {Component} from "../shared/Component.sol";
|
10
6
|
import {IRegistry} from "../registry/IRegistry.sol";
|
11
|
-
import {IRegistryService} from "../registry/IRegistryService.sol";
|
12
7
|
import {IStaking} from "./IStaking.sol";
|
13
|
-
import {
|
14
|
-
|
8
|
+
import {ITargetManager} from "./ITargetManager.sol";
|
9
|
+
|
10
|
+
import {Amount, AmountLib} from "../type/Amount.sol";
|
11
|
+
import {ChainId, ChainIdLib} from "../type/ChainId.sol";
|
12
|
+
import {Blocknumber, BlocknumberLib} from "../type/Blocknumber.sol";
|
15
13
|
import {KeyValueStore} from "../shared/KeyValueStore.sol";
|
16
|
-
import {KEEP_STATE} from "../type/StateId.sol";
|
17
14
|
import {NftId, NftIdLib} from "../type/NftId.sol";
|
18
15
|
import {NftIdSet} from "../shared/NftIdSet.sol";
|
19
|
-
import {ObjectType
|
16
|
+
import {ObjectType} from "../type/ObjectType.sol";
|
17
|
+
import {PROTOCOL} from "../type/ObjectType.sol";
|
20
18
|
import {Seconds, SecondsLib} from "../type/Seconds.sol";
|
19
|
+
import {StakingLib} from "./StakingLib.sol";
|
20
|
+
import {StakingLifecycle} from "./StakingLifecycle.sol";
|
21
21
|
import {StakingReader} from "./StakingReader.sol";
|
22
22
|
import {TargetManagerLib} from "./TargetManagerLib.sol";
|
23
23
|
import {Timestamp, TimestampLib} from "../type/Timestamp.sol";
|
24
|
-
import {TokenRegistry} from "../registry/TokenRegistry.sol";
|
25
24
|
import {UFixed, UFixedLib} from "../type/UFixed.sol";
|
26
|
-
import {Version, VersionLib} from "../type/Version.sol";
|
27
|
-
import {Versionable} from "../shared/Versionable.sol";
|
28
|
-
|
29
|
-
import {RegistryAdmin} from "../registry/RegistryAdmin.sol";
|
30
|
-
import {StakingLifecycle} from "./StakingLifecycle.sol";
|
31
25
|
|
32
26
|
|
33
27
|
contract StakingStore is
|
@@ -36,115 +30,290 @@ contract StakingStore is
|
|
36
30
|
StakingLifecycle
|
37
31
|
{
|
38
32
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
event LogStakingStoreTotalValueLockedDecreased(NftId targetNftId, address token, Amount amount, Amount newBalance, Blocknumber lastUpdatedIn);
|
44
|
-
|
45
|
-
event LogStakingStoreStakesIncreased(NftId nftId, Amount addedAmount, Amount newBalance, Blocknumber lastUpdatedIn);
|
46
|
-
event LogStakingStoreStakesDecreased(NftId nftId, Amount addedAmount, Amount newBalance, Blocknumber lastUpdatedIn);
|
47
|
-
|
48
|
-
event LogStakingStoreRewardsIncreased(NftId nftId, Amount addedAmount, Amount newBalance, Blocknumber lastUpdatedIn);
|
49
|
-
event LogStakingStoreRewardsDecreased(NftId nftId, Amount addedAmount, Amount newBalance, Blocknumber lastUpdatedIn);
|
33
|
+
// token
|
34
|
+
error ErrorStakingStoreTokenNotRegistered(ChainId chainId, address token);
|
35
|
+
error ErrorStakingStoreTokenAlreadyAdded(ChainId chainId, address token);
|
36
|
+
error ErrorStakingStoreTokenUnknown(ChainId chainId, address token);
|
50
37
|
|
51
|
-
|
38
|
+
// target
|
39
|
+
error ErrorStakingStoreTargetNotInitialized(NftId targetNftId);
|
40
|
+
error ErrorStakingStoreLimitNotInitialized(NftId targetNftId);
|
52
41
|
|
53
42
|
// in/decreasing reward reserves
|
54
43
|
error ErrorStakingStoreNotTarget(NftId targetNftId);
|
55
|
-
error ErrorStakingStoreRewardReservesInsufficient(NftId targetNftId, Amount
|
44
|
+
error ErrorStakingStoreRewardReservesInsufficient(NftId targetNftId, Amount reserveAmount, Amount claimedAmount);
|
56
45
|
|
57
|
-
//
|
58
|
-
error
|
59
|
-
error
|
46
|
+
// stakes
|
47
|
+
error ErrorStakingStoreStakesExceedingTargetMaxAmount(NftId targetNftId, Amount stakeLimitAmount, Amount newIStaking);
|
48
|
+
error ErrorStakingStoreStakeNotInitialized(NftId nftId);
|
60
49
|
|
61
|
-
//
|
62
|
-
error
|
50
|
+
// creating and updating of staking balance
|
51
|
+
error ErrorStakingStoreStakeBalanceAlreadyInitialized(NftId nftId);
|
52
|
+
error ErrorStakingStoreStakeBalanceNotInitialized(NftId nftI);
|
53
|
+
|
54
|
+
// creating and updating of tvl balance
|
55
|
+
error ErrorStakingStoreTvlBalanceAlreadyInitialized(NftId nftId, address token);
|
56
|
+
error ErrorStakingStoreTvlBalanceNotInitialized(NftId nftId, address token);
|
63
57
|
|
64
58
|
IRegistry private _registry;
|
65
|
-
|
59
|
+
ITargetManager private _targetManager;
|
66
60
|
StakingReader private _reader;
|
61
|
+
NftIdSet private _targetNftIdSet;
|
67
62
|
|
68
|
-
// staking rate
|
69
|
-
mapping(uint256 chainId => mapping(address token => UFixed stakingRate)) private _stakingRate;
|
70
63
|
|
71
|
-
//
|
72
|
-
mapping(NftId
|
73
|
-
mapping(NftId nftId => Amount rewards) private _rewardBalance;
|
74
|
-
mapping(NftId nftId => Amount reserves) private _reserveBalance;
|
64
|
+
// stakes
|
65
|
+
mapping(NftId stakeNftId => IStaking.StakeInfo) private _stakeInfo;
|
75
66
|
|
76
|
-
|
77
|
-
mapping(NftId
|
67
|
+
// targets
|
68
|
+
mapping(NftId targetNftId => IStaking.TargetInfo) private _targetInfo;
|
69
|
+
mapping(NftId targetNftId => IStaking.LimitInfo) private _limitInfo;
|
70
|
+
mapping(NftId targetNftId => mapping(address token => IStaking.TvlInfo)) private _tvlInfo;
|
71
|
+
mapping(NftId targetNftId => address [] token) private _targetToken;
|
78
72
|
|
79
|
-
//
|
80
|
-
mapping(
|
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;
|
73
|
+
// staking rate
|
74
|
+
mapping(ChainId chainId => mapping(address token => IStaking.TokenInfo)) private _tokenInfo;
|
84
75
|
|
85
76
|
|
86
|
-
constructor(
|
77
|
+
constructor(
|
78
|
+
IRegistry registry,
|
79
|
+
StakingReader reader
|
80
|
+
)
|
87
81
|
AccessManaged(msg.sender)
|
88
82
|
{
|
89
83
|
// set final authority
|
90
84
|
setAuthority(registry.getAuthority());
|
91
85
|
|
92
86
|
// set internal variables
|
93
|
-
_registry = registry;
|
87
|
+
_registry = registry;
|
94
88
|
_reader = reader;
|
95
89
|
_targetNftIdSet = new NftIdSet();
|
96
90
|
|
97
91
|
// register protocol target
|
98
92
|
_createTarget(
|
99
93
|
NftIdLib.toNftId(1101),
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
rewardRate: TargetManagerLib.getDefaultRewardRate()}));
|
94
|
+
PROTOCOL(),
|
95
|
+
TargetManagerLib.getDefaultLockingPeriod(),
|
96
|
+
TargetManagerLib.getDefaultRewardRate(),
|
97
|
+
false); // no parameter check
|
105
98
|
}
|
106
99
|
|
100
|
+
//--- dependency management ---------------------------------------------//
|
101
|
+
|
102
|
+
function setStakingReader(address reader)
|
103
|
+
external
|
104
|
+
restricted()
|
105
|
+
{
|
106
|
+
address oldReader = address(_reader);
|
107
|
+
_reader = StakingReader(reader);
|
108
|
+
|
109
|
+
emit IStaking.LogStakingStakingReaderSet(reader, oldReader);
|
110
|
+
}
|
111
|
+
|
112
|
+
|
113
|
+
function setTargetManager(address targetManager)
|
114
|
+
external
|
115
|
+
restricted()
|
116
|
+
{
|
117
|
+
address oldTargetManager = address(_targetManager);
|
118
|
+
_targetManager = ITargetManager(targetManager);
|
119
|
+
|
120
|
+
emit IStaking.LogStakingTargetManagerSet(targetManager, oldTargetManager);
|
121
|
+
}
|
122
|
+
|
123
|
+
//--- token management --------------------------------------------------//
|
124
|
+
|
125
|
+
/// @dev Registers a token for tvl management.
|
126
|
+
function addToken(
|
127
|
+
ChainId chainId,
|
128
|
+
address token
|
129
|
+
)
|
130
|
+
external
|
131
|
+
restricted() // token registry via staking
|
132
|
+
{
|
133
|
+
// checks
|
134
|
+
IStaking.TokenInfo storage info = _tokenInfo[chainId][token];
|
135
|
+
|
136
|
+
// check token is not yet registered
|
137
|
+
if (info.lastUpdateIn.gtz()) {
|
138
|
+
revert ErrorStakingStoreTokenAlreadyAdded(chainId, token);
|
139
|
+
}
|
140
|
+
|
141
|
+
info.stakingRate = UFixedLib.zero();
|
142
|
+
info.lastUpdateIn = BlocknumberLib.current();
|
143
|
+
|
144
|
+
// logging
|
145
|
+
emit IStaking.LogStakingTokenAdded(chainId, token);
|
146
|
+
}
|
107
147
|
|
108
|
-
//--- staking rate specific functions -----------------------------------//
|
109
148
|
|
149
|
+
/// @dev Sets the staking rate for the token.
|
110
150
|
function setStakingRate(
|
111
|
-
|
151
|
+
ChainId chainId,
|
112
152
|
address token,
|
113
153
|
UFixed stakingRate
|
114
154
|
)
|
115
155
|
external
|
116
|
-
restricted()
|
156
|
+
restricted() // staking
|
157
|
+
returns (
|
158
|
+
UFixed oldStakingRate,
|
159
|
+
Blocknumber lastUpdatedIn
|
160
|
+
)
|
117
161
|
{
|
118
|
-
|
162
|
+
IStaking.TokenInfo storage info = _tokenInfo[chainId][token];
|
163
|
+
if (info.lastUpdateIn.eqz()) {
|
164
|
+
revert ErrorStakingStoreTokenUnknown(chainId, token);
|
165
|
+
}
|
166
|
+
|
167
|
+
// get previous values
|
168
|
+
oldStakingRate = info.stakingRate;
|
169
|
+
lastUpdatedIn = info.lastUpdateIn;
|
170
|
+
|
171
|
+
// update values
|
172
|
+
info.stakingRate = stakingRate;
|
173
|
+
info.lastUpdateIn = BlocknumberLib.current();
|
119
174
|
}
|
120
175
|
|
121
|
-
//--- target
|
176
|
+
//--- target management -------------------------------------------------//
|
122
177
|
|
123
178
|
function createTarget(
|
124
179
|
NftId targetNftId,
|
125
|
-
|
180
|
+
ObjectType objectType,
|
181
|
+
Seconds lockingPeriod,
|
182
|
+
UFixed rewardRate
|
126
183
|
)
|
127
184
|
external
|
128
|
-
restricted()
|
185
|
+
restricted() // staking
|
129
186
|
{
|
130
|
-
_createTarget(targetNftId,
|
187
|
+
_createTarget(targetNftId, objectType, lockingPeriod, rewardRate, true);
|
131
188
|
}
|
132
189
|
|
133
190
|
|
134
|
-
function
|
191
|
+
function setLockingPeriod(
|
192
|
+
NftId targetNftId,
|
193
|
+
Seconds lockingPeriod
|
194
|
+
)
|
195
|
+
external
|
196
|
+
restricted() // staking
|
197
|
+
returns (
|
198
|
+
Seconds oldLockingPeriod,
|
199
|
+
Blocknumber lastUpdatedIn
|
200
|
+
)
|
201
|
+
{
|
202
|
+
TargetManagerLib.checkLockingPeriod(targetNftId, lockingPeriod);
|
203
|
+
|
204
|
+
IStaking.TargetInfo storage targetInfo;
|
205
|
+
(targetInfo, lastUpdatedIn) = _verifyAndUpdateTarget(targetNftId);
|
206
|
+
|
207
|
+
oldLockingPeriod = targetInfo.lockingPeriod;
|
208
|
+
targetInfo.lockingPeriod = lockingPeriod;
|
209
|
+
}
|
210
|
+
|
211
|
+
|
212
|
+
function setRewardRate(
|
213
|
+
NftId targetNftId,
|
214
|
+
UFixed rewardRate
|
215
|
+
)
|
216
|
+
external
|
217
|
+
restricted() // staking
|
218
|
+
returns (
|
219
|
+
UFixed oldRewardRate,
|
220
|
+
Blocknumber lastUpdatedIn
|
221
|
+
)
|
222
|
+
{
|
223
|
+
TargetManagerLib.checkRewardRate(targetNftId, rewardRate);
|
224
|
+
|
225
|
+
IStaking.TargetInfo storage targetInfo;
|
226
|
+
(targetInfo, lastUpdatedIn) = _verifyAndUpdateTarget(targetNftId);
|
227
|
+
|
228
|
+
oldRewardRate = targetInfo.rewardRate;
|
229
|
+
targetInfo.rewardRate = rewardRate;
|
230
|
+
}
|
231
|
+
|
232
|
+
|
233
|
+
// TODO refactor to set limits functionality
|
234
|
+
function setMaxStakedAmount(
|
235
|
+
NftId targetNftId,
|
236
|
+
Amount stakeLimitAmount
|
237
|
+
)
|
238
|
+
external
|
239
|
+
restricted() // staking
|
240
|
+
returns (
|
241
|
+
Amount oldLimitAmount,
|
242
|
+
Blocknumber lastUpdatedIn
|
243
|
+
)
|
244
|
+
{
|
245
|
+
IStaking.TargetInfo storage targetInfo;
|
246
|
+
(targetInfo, lastUpdatedIn) = _verifyAndUpdateTarget(targetNftId);
|
247
|
+
|
248
|
+
oldLimitAmount = targetInfo.limitAmount;
|
249
|
+
targetInfo.limitAmount = stakeLimitAmount;
|
250
|
+
|
251
|
+
emit IStaking.LogStakingTargetMaxStakedAmountSet(targetNftId, stakeLimitAmount, lastUpdatedIn);
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
function setTargetLimits(
|
135
257
|
NftId targetNftId,
|
136
|
-
|
258
|
+
Amount marginAmount,
|
259
|
+
Amount hardLimitAmount
|
137
260
|
)
|
138
261
|
external
|
262
|
+
virtual
|
139
263
|
restricted()
|
140
264
|
{
|
141
|
-
|
142
|
-
|
143
|
-
|
265
|
+
// checks
|
266
|
+
IStaking.LimitInfo storage limitInfo = _getAndVerifyLimit(targetNftId);
|
267
|
+
Blocknumber lastUpdateIn = limitInfo.lastUpdateIn;
|
268
|
+
|
269
|
+
// effects
|
270
|
+
limitInfo.marginAmount = marginAmount;
|
271
|
+
limitInfo.hardLimitAmount = hardLimitAmount;
|
272
|
+
limitInfo.lastUpdateIn = BlocknumberLib.current();
|
273
|
+
|
274
|
+
// logging
|
275
|
+
emit IStaking.LogStakingTargetLimitsUpdated(
|
276
|
+
targetNftId,
|
277
|
+
marginAmount,
|
278
|
+
hardLimitAmount,
|
279
|
+
lastUpdateIn);
|
144
280
|
}
|
145
281
|
|
146
282
|
|
147
|
-
function
|
283
|
+
function addTargetToken(
|
284
|
+
NftId targetNftId,
|
285
|
+
address token
|
286
|
+
)
|
287
|
+
external
|
288
|
+
restricted()
|
289
|
+
{
|
290
|
+
// checks
|
291
|
+
|
292
|
+
// skip registering if tvl balance has already been initialized
|
293
|
+
IStaking.TvlInfo storage tvlInfo = _tvlInfo[targetNftId][token];
|
294
|
+
if (tvlInfo.lastUpdateIn.gtz()) {
|
295
|
+
return;
|
296
|
+
}
|
297
|
+
|
298
|
+
// check target exists
|
299
|
+
_getAndVerifyTarget(targetNftId);
|
300
|
+
|
301
|
+
// check token is known for chain id of target
|
302
|
+
ChainId chainId = ChainIdLib.fromNftId(targetNftId);
|
303
|
+
if (_tokenInfo[chainId][token].lastUpdateIn.eqz()) {
|
304
|
+
revert ErrorStakingStoreTokenUnknown(chainId, token);
|
305
|
+
}
|
306
|
+
|
307
|
+
// effects
|
308
|
+
tvlInfo.tvlAmount = AmountLib.zero();
|
309
|
+
tvlInfo.lastUpdateIn = BlocknumberLib.current();
|
310
|
+
|
311
|
+
// add token to list of know tokens for target
|
312
|
+
_targetToken[targetNftId].push(token);
|
313
|
+
}
|
314
|
+
|
315
|
+
|
316
|
+
function refillRewardReserves(
|
148
317
|
NftId targetNftId,
|
149
318
|
Amount dipAmount
|
150
319
|
)
|
@@ -152,14 +321,26 @@ contract StakingStore is
|
|
152
321
|
restricted()
|
153
322
|
returns (Amount newReserveBalance)
|
154
323
|
{
|
155
|
-
|
156
|
-
|
324
|
+
// checks
|
325
|
+
IStaking.TargetInfo storage targetInfo = _getAndVerifyTarget(targetNftId);
|
326
|
+
Blocknumber lastUpdateIn = targetInfo.lastUpdateIn;
|
327
|
+
|
328
|
+
// effects
|
329
|
+
targetInfo.reserveAmount = targetInfo.reserveAmount + dipAmount;
|
330
|
+
targetInfo.lastUpdateIn = BlocknumberLib.current();
|
157
331
|
|
158
|
-
|
332
|
+
// logging
|
333
|
+
newReserveBalance = targetInfo.reserveAmount;
|
334
|
+
emit IStaking.LogStakingRewardReservesRefilled(
|
335
|
+
targetNftId,
|
336
|
+
dipAmount,
|
337
|
+
_registry.ownerOf(targetNftId),
|
338
|
+
newReserveBalance,
|
339
|
+
lastUpdateIn);
|
159
340
|
}
|
160
341
|
|
161
342
|
|
162
|
-
function
|
343
|
+
function withdrawRewardReserves(
|
163
344
|
NftId targetNftId,
|
164
345
|
Amount dipAmount
|
165
346
|
)
|
@@ -167,18 +348,20 @@ contract StakingStore is
|
|
167
348
|
restricted()
|
168
349
|
returns (Amount newReserveBalance)
|
169
350
|
{
|
170
|
-
|
171
|
-
|
172
|
-
revert ErrorStakingStoreRewardReservesInsufficient(
|
173
|
-
targetNftId,
|
174
|
-
dipAmount,
|
175
|
-
reserveAmount);
|
176
|
-
}
|
351
|
+
// checks
|
352
|
+
IStaking.TargetInfo storage targetInfo = _getAndVerifyTarget(targetNftId);
|
177
353
|
|
178
|
-
|
179
|
-
Blocknumber
|
354
|
+
// effects
|
355
|
+
Blocknumber lastUpdateIn = _decreaseReserves(targetNftId, targetInfo, dipAmount);
|
180
356
|
|
181
|
-
|
357
|
+
// logging
|
358
|
+
newReserveBalance = targetInfo.reserveAmount;
|
359
|
+
emit IStaking.LogStakingRewardReservesWithdrawn(
|
360
|
+
targetNftId,
|
361
|
+
dipAmount,
|
362
|
+
_registry.ownerOf(targetNftId),
|
363
|
+
newReserveBalance,
|
364
|
+
lastUpdateIn);
|
182
365
|
}
|
183
366
|
|
184
367
|
|
@@ -186,7 +369,6 @@ contract StakingStore is
|
|
186
369
|
|
187
370
|
function increaseTotalValueLocked(
|
188
371
|
NftId targetNftId,
|
189
|
-
UFixed stakingRate,
|
190
372
|
address token,
|
191
373
|
Amount amount
|
192
374
|
)
|
@@ -194,32 +376,20 @@ contract StakingStore is
|
|
194
376
|
restricted()
|
195
377
|
returns (Amount newBalance)
|
196
378
|
{
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
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);
|
379
|
+
// checks
|
380
|
+
IStaking.TvlInfo storage tvlInfo = _getAndVerifyTvl(targetNftId, token);
|
381
|
+
|
382
|
+
// effects
|
383
|
+
// update tvl balance and adapts required stakes if necessary
|
384
|
+
tvlInfo.tvlAmount = tvlInfo.tvlAmount + amount;
|
385
|
+
_checkAndUpdateTargetLimit(targetNftId, token, tvlInfo);
|
386
|
+
tvlInfo.lastUpdateIn = BlocknumberLib.current();
|
387
|
+
newBalance = tvlInfo.tvlAmount;
|
217
388
|
}
|
218
389
|
|
219
390
|
|
220
391
|
function decreaseTotalValueLocked(
|
221
392
|
NftId targetNftId,
|
222
|
-
UFixed stakingRate,
|
223
393
|
address token,
|
224
394
|
Amount amount
|
225
395
|
)
|
@@ -227,389 +397,749 @@ contract StakingStore is
|
|
227
397
|
restricted()
|
228
398
|
returns (Amount newBalance)
|
229
399
|
{
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
400
|
+
// checks
|
401
|
+
IStaking.TvlInfo storage tvlInfo = _getAndVerifyTvl(targetNftId, token);
|
402
|
+
|
403
|
+
// effects
|
404
|
+
// update tvl balance and adapts required stakes if necessary
|
405
|
+
tvlInfo.tvlAmount = tvlInfo.tvlAmount - amount;
|
406
|
+
_checkAndUpdateTargetLimit(targetNftId, token, tvlInfo);
|
407
|
+
tvlInfo.lastUpdateIn = BlocknumberLib.current();
|
408
|
+
newBalance = tvlInfo.tvlAmount;
|
409
|
+
}
|
235
410
|
|
236
|
-
newBalance = oldBalance - amount;
|
237
|
-
Amount newDipBalance = AmountLib.toAmount((
|
238
|
-
stakingRate * newBalance.toUFixed()).toInt());
|
239
411
|
|
240
|
-
|
241
|
-
|
242
|
-
|
412
|
+
function updateTargetLimit(NftId targetNftId)
|
413
|
+
external
|
414
|
+
restricted()
|
415
|
+
returns (Amount stakeLimitAmount)
|
416
|
+
{
|
417
|
+
return _updateTargetLimit(targetNftId);
|
418
|
+
}
|
243
419
|
|
244
|
-
// update new amount of required dip
|
245
|
-
_tvlRequiredDip[targetNftId] = _tvlRequiredDip[targetNftId] - oldDipBalance + newDipBalance;
|
246
420
|
|
247
|
-
|
248
|
-
|
421
|
+
function _checkAndUpdateTargetLimit(
|
422
|
+
NftId targetNftId,
|
423
|
+
address token,
|
424
|
+
IStaking.TvlInfo storage tvlInfo
|
425
|
+
)
|
426
|
+
internal
|
427
|
+
{
|
428
|
+
// update counter
|
429
|
+
tvlInfo.updatesCounter++;
|
430
|
+
|
431
|
+
// check if upgrade is necessary
|
432
|
+
bool updateRequired = _targetManager.isLimitUpdateRequired(
|
433
|
+
targetNftId,
|
434
|
+
token,
|
435
|
+
tvlInfo.updatesCounter,
|
436
|
+
tvlInfo.tvlBaselineAmount,
|
437
|
+
tvlInfo.tvlAmount);
|
438
|
+
|
439
|
+
if (updateRequired) {
|
440
|
+
// reset baseline and counter
|
441
|
+
tvlInfo.tvlBaselineAmount = tvlInfo.tvlAmount;
|
442
|
+
tvlInfo.updatesCounter = 0;
|
443
|
+
|
444
|
+
// update limit
|
445
|
+
_updateTargetLimit(targetNftId);
|
446
|
+
}
|
447
|
+
}
|
448
|
+
|
249
449
|
|
250
|
-
|
450
|
+
function _updateTargetLimit(NftId targetNftId)
|
451
|
+
internal
|
452
|
+
returns (Amount limitAmount)
|
453
|
+
{
|
454
|
+
// checks
|
455
|
+
IStaking.TargetInfo storage targetInfo = _getAndVerifyTarget(targetNftId);
|
456
|
+
IStaking.LimitInfo storage limitInfo = _getAndVerifyLimit(targetNftId);
|
457
|
+
Blocknumber lastUpdateIn = limitInfo.lastUpdateIn;
|
458
|
+
|
459
|
+
// calculate max stake amount
|
460
|
+
Amount requiredStakeAmount = getRequiredStakeBalance(targetNftId);
|
461
|
+
limitAmount = AmountLib.min(
|
462
|
+
targetInfo.limitAmount,
|
463
|
+
requiredStakeAmount + limitInfo.marginAmount);
|
464
|
+
|
465
|
+
limitAmount = AmountLib.min(
|
466
|
+
limitAmount,
|
467
|
+
limitInfo.hardLimitAmount);
|
468
|
+
|
469
|
+
// effects
|
470
|
+
targetInfo.limitAmount = limitAmount;
|
471
|
+
targetInfo.lastUpdateIn = BlocknumberLib.current();
|
472
|
+
|
473
|
+
// logging
|
474
|
+
emit IStaking.LogStakingTargetLimitUpdated(
|
475
|
+
targetNftId,
|
476
|
+
targetInfo.limitAmount,
|
477
|
+
limitInfo.hardLimitAmount,
|
478
|
+
requiredStakeAmount,
|
479
|
+
targetInfo.stakedAmount,
|
480
|
+
lastUpdateIn);
|
251
481
|
}
|
252
482
|
|
253
483
|
//--- stake specific functions -------------------------------------//
|
254
484
|
|
255
|
-
function
|
485
|
+
function createStake(
|
256
486
|
NftId stakeNftId,
|
257
|
-
|
487
|
+
NftId targetNftId,
|
488
|
+
address stakeOwner,
|
489
|
+
Amount stakeAmount
|
258
490
|
)
|
259
491
|
external
|
260
492
|
restricted()
|
493
|
+
returns (Timestamp lockedUntil)
|
261
494
|
{
|
262
|
-
|
263
|
-
|
264
|
-
|
495
|
+
// checks
|
496
|
+
IStaking.StakeInfo storage stakeInfo = _stakeInfo[stakeNftId];
|
497
|
+
if (stakeInfo.lastUpdateIn.gtz()) {
|
498
|
+
revert ErrorStakingStoreStakeBalanceAlreadyInitialized(stakeNftId);
|
499
|
+
}
|
500
|
+
|
501
|
+
IStaking.TargetInfo storage targetInfo = _getAndVerifyTarget(targetNftId);
|
502
|
+
_checkMaxStakedAmount(targetNftId, targetInfo, stakeAmount);
|
265
503
|
|
266
|
-
|
504
|
+
// effects
|
505
|
+
stakeInfo.targetNftId = targetNftId;
|
506
|
+
stakeInfo.stakedAmount = AmountLib.zero();
|
507
|
+
stakeInfo.rewardAmount = AmountLib.zero();
|
508
|
+
stakeInfo.lockedUntil = TimestampLib.current();
|
509
|
+
_setStakeLastUpdatesToCurrent(stakeInfo);
|
510
|
+
|
511
|
+
// logging for creation of empty stake
|
512
|
+
emit IStaking.LogStakingStakeCreated(stakeNftId, stakeInfo.targetNftId, stakeInfo.stakedAmount, stakeInfo.lockedUntil, stakeOwner);
|
513
|
+
|
514
|
+
// process stake amount
|
515
|
+
_stake(stakeNftId, stakeInfo, targetInfo, targetInfo.lockingPeriod, stakeAmount);
|
267
516
|
}
|
268
517
|
|
269
|
-
|
270
|
-
|
271
|
-
|
518
|
+
|
519
|
+
function stake(
|
520
|
+
NftId stakeNftId,
|
521
|
+
bool updateRewards,
|
522
|
+
bool restakeRewards,
|
523
|
+
Seconds additionalLockingPeriod,
|
524
|
+
Amount stakeAmount
|
272
525
|
)
|
273
526
|
external
|
274
527
|
restricted()
|
275
528
|
{
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
KEEP_STATE());
|
280
|
-
}
|
529
|
+
// checks
|
530
|
+
IStaking.StakeInfo storage stakeInfo = _getAndVerifyStake(stakeNftId);
|
531
|
+
IStaking.TargetInfo storage targetInfo = _getAndVerifyTarget(stakeInfo.targetNftId);
|
281
532
|
|
282
|
-
|
533
|
+
if (updateRewards) {
|
534
|
+
_updateRewards(stakeNftId, stakeInfo, targetInfo);
|
535
|
+
}
|
283
536
|
|
537
|
+
if (restakeRewards) {
|
538
|
+
_restakeRewards(stakeNftId, stakeInfo, targetInfo);
|
539
|
+
}
|
284
540
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
541
|
+
_stake(stakeNftId, stakeInfo, targetInfo, additionalLockingPeriod, stakeAmount);
|
542
|
+
}
|
543
|
+
|
544
|
+
|
545
|
+
function unstake(
|
546
|
+
NftId stakeNftId,
|
547
|
+
bool updateRewards,
|
548
|
+
bool restakeRewards,
|
549
|
+
Amount maxUnstakeAmount
|
289
550
|
)
|
290
551
|
external
|
291
552
|
restricted()
|
553
|
+
returns (Amount unstakedAmount)
|
292
554
|
{
|
293
|
-
|
555
|
+
// checks
|
556
|
+
IStaking.StakeInfo storage stakeInfo = _getAndVerifyStake(stakeNftId);
|
557
|
+
IStaking.TargetInfo storage targetInfo = _getAndVerifyTarget(stakeInfo.targetNftId);
|
294
558
|
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
_rewardBalance[nftId]); // unchanged reward balance
|
559
|
+
if (updateRewards) {
|
560
|
+
_updateRewards(stakeNftId, stakeInfo, targetInfo);
|
561
|
+
}
|
299
562
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
_rewardBalance[targetNftId]);
|
563
|
+
if (restakeRewards) {
|
564
|
+
_restakeRewards(stakeNftId, stakeInfo, targetInfo);
|
565
|
+
}
|
304
566
|
|
305
|
-
|
567
|
+
return _unstake(stakeNftId, stakeInfo, targetInfo, maxUnstakeAmount);
|
306
568
|
}
|
307
569
|
|
308
570
|
|
309
|
-
function
|
310
|
-
NftId nftId,
|
311
|
-
NftId targetNftId,
|
312
|
-
Amount rewardIncrementAmount
|
313
|
-
)
|
571
|
+
function updateRewards(NftId stakeNftId)
|
314
572
|
external
|
315
573
|
restricted()
|
316
574
|
{
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
// move all rewards to stake balance
|
322
|
-
_updateStakeBalance(
|
323
|
-
nftId,
|
324
|
-
stakeAmount + rewardAmount + rewardIncrementAmount, // new stake balance
|
325
|
-
AmountLib.zero()); // new reward balance
|
326
|
-
|
327
|
-
_updateTargetBalance(
|
328
|
-
targetNftId,
|
329
|
-
_stakeBalance[targetNftId] + rewardAmount + rewardIncrementAmount,
|
330
|
-
_rewardBalance[targetNftId] - rewardAmount);
|
331
|
-
|
332
|
-
emit LogStakingStoreRewardsRestaked(nftId, stakeAmount, rewardAmount, rewardIncrementAmount, _stakeBalance[nftId], lastUpdatedIn);
|
575
|
+
// checks
|
576
|
+
IStaking.StakeInfo storage stakeInfo = _getAndVerifyStake(stakeNftId);
|
577
|
+
IStaking.TargetInfo storage targetInfo = _getAndVerifyTarget(stakeInfo.targetNftId);
|
578
|
+
_updateRewards(stakeNftId, stakeInfo, targetInfo);
|
333
579
|
}
|
334
580
|
|
335
581
|
|
336
|
-
function
|
337
|
-
NftId
|
338
|
-
|
339
|
-
Amount rewardIncrementAmount
|
582
|
+
function restakeRewards(
|
583
|
+
NftId stakeNftId,
|
584
|
+
bool updateRewards
|
340
585
|
)
|
341
586
|
external
|
342
587
|
restricted()
|
343
588
|
{
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
_updateStakeBalance(
|
348
|
-
nftId,
|
349
|
-
_stakeBalance[nftId], // unchanged stake balance
|
350
|
-
_rewardBalance[nftId] + rewardIncrementAmount); // new reward balance
|
589
|
+
// checks
|
590
|
+
IStaking.StakeInfo storage stakeInfo = _getAndVerifyStake(stakeNftId);
|
591
|
+
IStaking.TargetInfo storage targetInfo = _getAndVerifyTarget(stakeInfo.targetNftId);
|
351
592
|
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
_rewardBalance[targetNftId] + rewardIncrementAmount);
|
593
|
+
if (updateRewards) {
|
594
|
+
_updateRewards(stakeNftId, stakeInfo, targetInfo);
|
595
|
+
}
|
356
596
|
|
357
|
-
|
597
|
+
_restakeRewards(stakeNftId, stakeInfo, targetInfo);
|
358
598
|
}
|
359
599
|
|
360
600
|
|
361
|
-
function
|
362
|
-
NftId
|
363
|
-
|
601
|
+
function claimRewards(
|
602
|
+
NftId stakeNftId,
|
603
|
+
bool updateRewards,
|
364
604
|
Amount maxClaimAmount
|
365
605
|
)
|
366
606
|
external
|
367
607
|
restricted()
|
368
608
|
returns (Amount claimedAmount)
|
369
609
|
{
|
370
|
-
|
610
|
+
// checks
|
611
|
+
IStaking.StakeInfo storage stakeInfo = _getAndVerifyStake(stakeNftId);
|
612
|
+
IStaking.TargetInfo storage targetInfo = _getAndVerifyTarget(stakeInfo.targetNftId);
|
371
613
|
|
372
|
-
|
373
|
-
|
614
|
+
if (updateRewards) {
|
615
|
+
_updateRewards(stakeNftId, stakeInfo, targetInfo);
|
616
|
+
}
|
374
617
|
|
375
|
-
|
376
|
-
|
377
|
-
nftId,
|
378
|
-
_stakeBalance[nftId], // unchanged stake balance
|
379
|
-
_rewardBalance[nftId] - claimedAmount); // new reward balance
|
618
|
+
claimedAmount = _claimRewards(stakeNftId, stakeInfo, targetInfo, maxClaimAmount);
|
619
|
+
}
|
380
620
|
|
381
|
-
|
382
|
-
targetNftId,
|
383
|
-
_stakeBalance[targetNftId],
|
384
|
-
_rewardBalance[targetNftId] - claimedAmount);
|
621
|
+
//--- view functions -----------------------------------------------//
|
385
622
|
|
386
|
-
|
623
|
+
function getStakingReader() external view returns (StakingReader stakingReader){
|
624
|
+
return _reader;
|
387
625
|
}
|
388
626
|
|
627
|
+
function getTargetManager() external view returns (ITargetManager targetManager){
|
628
|
+
return _targetManager;
|
629
|
+
}
|
389
630
|
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
Amount claimedAmount
|
401
|
-
)
|
631
|
+
|
632
|
+
function exists(NftId stakeNftId) external view returns (bool) {
|
633
|
+
return _stakeInfo[stakeNftId].lastUpdateIn.gtz();
|
634
|
+
}
|
635
|
+
|
636
|
+
|
637
|
+
function getRequiredStakeBalance(NftId targetNftId)
|
638
|
+
public
|
639
|
+
view
|
640
|
+
returns (Amount requiredStakeAmount)
|
402
641
|
{
|
403
|
-
|
642
|
+
address [] memory tokens = _targetToken[targetNftId];
|
643
|
+
if (tokens.length == 0) {
|
644
|
+
return AmountLib.zero();
|
645
|
+
}
|
404
646
|
|
405
|
-
|
406
|
-
|
407
|
-
|
647
|
+
requiredStakeAmount = AmountLib.zero();
|
648
|
+
ChainId targetChainId = _targetInfo[targetNftId].chainId;
|
649
|
+
address token;
|
650
|
+
Amount tvlAmount;
|
651
|
+
UFixed stakingRate;
|
408
652
|
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
_rewardBalance[nftId] - claimedAmount); // new reward balance
|
653
|
+
for (uint256 i = 0; i < tokens.length; i++) {
|
654
|
+
token = tokens[i];
|
655
|
+
tvlAmount = _tvlInfo[targetNftId][token].tvlAmount;
|
656
|
+
if (tvlAmount.eqz()) { continue; }
|
414
657
|
|
415
|
-
|
416
|
-
|
417
|
-
_stakeBalance[targetNftId] - unstakedAmount,
|
418
|
-
_rewardBalance[targetNftId] - claimedAmount);
|
658
|
+
stakingRate = _tokenInfo[targetChainId][token].stakingRate;
|
659
|
+
if (stakingRate.eqz()) { continue; }
|
419
660
|
|
420
|
-
|
421
|
-
|
661
|
+
requiredStakeAmount = requiredStakeAmount + tvlAmount.multiplyWith(stakingRate);
|
662
|
+
}
|
422
663
|
}
|
423
664
|
|
424
|
-
//--- view functions -----------------------------------------------//
|
425
665
|
|
426
|
-
|
427
|
-
|
666
|
+
/// @dev Returns true iff current stake amount is still locked
|
667
|
+
function isStakeLocked(NftId stakeNftId) public view returns (bool) {
|
668
|
+
return _stakeInfo[stakeNftId].lockedUntil > TimestampLib.current();
|
428
669
|
}
|
429
670
|
|
430
|
-
|
431
|
-
|
432
|
-
|
671
|
+
|
672
|
+
/// @dev Returns the stake infos for the specified stake.
|
673
|
+
function getStakeInfo(NftId stakeNftId) external view returns (IStaking.StakeInfo memory stakeInfo) {
|
674
|
+
return _stakeInfo[stakeNftId];
|
433
675
|
}
|
434
676
|
|
435
|
-
function getStakingRate(uint256 chainId, address token) external view returns (UFixed stakingRate) { return _stakingRate[chainId][token]; }
|
436
677
|
|
437
|
-
|
678
|
+
/// @dev Returns the stake infos for the specified stake.
|
679
|
+
function getStakeTarget(NftId stakeNftId) external view returns (NftId targetNftId) {
|
680
|
+
return _stakeInfo[stakeNftId].targetNftId;
|
681
|
+
}
|
438
682
|
|
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]; }
|
441
683
|
|
442
|
-
|
443
|
-
function
|
444
|
-
|
445
|
-
|
446
|
-
function getBalanceUpdatedIn(NftId nftId) external view returns (Blocknumber blocknumber) { return _lastUpdatedIn[nftId]; }
|
684
|
+
/// @dev Returns the target infos for the specified target.
|
685
|
+
function getTargetInfo(NftId targetNftId) external view returns (IStaking.TargetInfo memory targetInfo) {
|
686
|
+
return _targetInfo[targetNftId];
|
687
|
+
}
|
447
688
|
|
448
689
|
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
returns (
|
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];
|
690
|
+
/// @dev Returns the target limit infos for the specified target.
|
691
|
+
function getLimitInfo(NftId targetNftId) external view returns (IStaking.LimitInfo memory limitInfo) {
|
692
|
+
return _limitInfo[targetNftId];
|
463
693
|
}
|
464
694
|
|
465
695
|
|
466
|
-
|
467
|
-
|
468
|
-
|
696
|
+
/// @dev Returns the tvl infos for the specified target.
|
697
|
+
function getTvlInfo(NftId targetNftId, address token) external view returns (IStaking.TvlInfo memory tvlInfo) {
|
698
|
+
return _tvlInfo[targetNftId][token];
|
699
|
+
}
|
700
|
+
|
701
|
+
|
702
|
+
/// @dev Returns the tvl infos for the specified target.
|
703
|
+
function getTokenInfo(ChainId chainId, address token) external view returns (IStaking.TokenInfo memory tokenInfo) {
|
704
|
+
return _tokenInfo[chainId][token];
|
705
|
+
}
|
706
|
+
|
707
|
+
|
708
|
+
function getTargetSet() external view returns (NftIdSet targetNftIdSet) {
|
709
|
+
return _targetNftIdSet;
|
710
|
+
}
|
711
|
+
|
712
|
+
//--- internal functions -----------------------------------------------//
|
713
|
+
|
714
|
+
function _verifyAndUpdateTarget(NftId targetNftId)
|
715
|
+
private
|
469
716
|
returns (
|
470
|
-
|
471
|
-
|
472
|
-
Timestamp lastUpdatedAt
|
717
|
+
IStaking.TargetInfo storage targetInfo,
|
718
|
+
Blocknumber lastUpdatedIn
|
473
719
|
)
|
474
720
|
{
|
475
|
-
|
476
|
-
|
477
|
-
|
721
|
+
// checks
|
722
|
+
targetInfo = _getAndVerifyTarget(targetNftId);
|
723
|
+
lastUpdatedIn = targetInfo.lastUpdateIn;
|
724
|
+
targetInfo.lastUpdateIn = BlocknumberLib.current();
|
478
725
|
}
|
479
726
|
|
480
|
-
//--- private functions -------------------------------------------//
|
481
727
|
|
482
728
|
function _createTarget(
|
483
729
|
NftId targetNftId,
|
484
|
-
|
730
|
+
ObjectType objectType,
|
731
|
+
Seconds lockingPeriod,
|
732
|
+
UFixed rewardRate,
|
733
|
+
bool checkParameters
|
485
734
|
)
|
486
735
|
private
|
487
736
|
{
|
488
|
-
|
489
|
-
|
490
|
-
|
737
|
+
// checks
|
738
|
+
if (checkParameters) {
|
739
|
+
TargetManagerLib.checkTargetParameters(
|
740
|
+
_registry,
|
741
|
+
_reader,
|
742
|
+
targetNftId,
|
743
|
+
objectType,
|
744
|
+
lockingPeriod,
|
745
|
+
rewardRate);
|
746
|
+
}
|
491
747
|
|
492
|
-
//
|
493
|
-
_tvlLastUpdatedIn[targetNftId]= BlocknumberLib.currentBlocknumber();
|
494
|
-
_createTargetBalance(targetNftId);
|
748
|
+
// effects
|
495
749
|
|
750
|
+
// target info
|
751
|
+
IStaking.TargetInfo storage targetInfo = _targetInfo[targetNftId];
|
752
|
+
targetInfo.stakedAmount = AmountLib.zero();
|
753
|
+
targetInfo.rewardAmount = AmountLib.zero();
|
754
|
+
targetInfo.reserveAmount = AmountLib.zero();
|
755
|
+
targetInfo.limitAmount = AmountLib.max();
|
756
|
+
|
757
|
+
targetInfo.objectType = objectType;
|
758
|
+
targetInfo.lockingPeriod = lockingPeriod;
|
759
|
+
targetInfo.rewardRate = rewardRate;
|
760
|
+
targetInfo.chainId = ChainIdLib.fromNftId(targetNftId);
|
761
|
+
targetInfo.lastUpdateIn = BlocknumberLib.current();
|
762
|
+
|
763
|
+
// limit info
|
764
|
+
IStaking.LimitInfo storage limitInfo = _limitInfo[targetNftId];
|
765
|
+
limitInfo.marginAmount = AmountLib.zero();
|
766
|
+
limitInfo.hardLimitAmount = AmountLib.max();
|
767
|
+
limitInfo.lastUpdateIn = BlocknumberLib.current();
|
768
|
+
|
769
|
+
// add new target to target set
|
496
770
|
_targetNftIdSet.add(targetNftId);
|
497
771
|
}
|
498
772
|
|
499
|
-
|
773
|
+
|
774
|
+
function _spendRewardReserves(
|
500
775
|
NftId targetNftId,
|
501
|
-
|
776
|
+
IStaking.TargetInfo storage targetInfo,
|
777
|
+
Amount dipAmount
|
502
778
|
)
|
503
779
|
private
|
504
|
-
returns (Blocknumber lastUpdatedIn)
|
505
780
|
{
|
506
|
-
|
507
|
-
revert ErrorStakingStoreNotTarget(targetNftId);
|
508
|
-
}
|
509
|
-
|
510
|
-
lastUpdatedIn = _lastUpdatedIn[targetNftId];
|
781
|
+
Blocknumber lastUpdateIn = _decreaseReserves(targetNftId, targetInfo, dipAmount);
|
511
782
|
|
512
|
-
|
513
|
-
|
783
|
+
// logging
|
784
|
+
emit IStaking.LogStakingRewardReservesSpent(
|
785
|
+
targetNftId,
|
786
|
+
dipAmount,
|
787
|
+
targetInfo.reserveAmount,
|
788
|
+
lastUpdateIn);
|
514
789
|
}
|
515
790
|
|
516
791
|
|
517
|
-
function
|
792
|
+
function _decreaseReserves(
|
793
|
+
NftId targetNftId,
|
794
|
+
IStaking.TargetInfo storage targetInfo,
|
795
|
+
Amount dipAmount
|
796
|
+
)
|
518
797
|
private
|
798
|
+
returns ( Blocknumber lastUpdateIn)
|
799
|
+
{
|
800
|
+
lastUpdateIn = targetInfo.lastUpdateIn;
|
801
|
+
|
802
|
+
// check if reserves are sufficient
|
803
|
+
if (dipAmount > targetInfo.reserveAmount) {
|
804
|
+
revert ErrorStakingStoreRewardReservesInsufficient(
|
805
|
+
targetNftId,
|
806
|
+
targetInfo.reserveAmount,
|
807
|
+
dipAmount);
|
808
|
+
}
|
809
|
+
|
810
|
+
// effects
|
811
|
+
targetInfo.reserveAmount = targetInfo.reserveAmount - dipAmount;
|
812
|
+
targetInfo.lastUpdateIn = BlocknumberLib.current();
|
813
|
+
}
|
814
|
+
|
815
|
+
|
816
|
+
function _updateRewards(
|
817
|
+
NftId stakeNftId,
|
818
|
+
IStaking.StakeInfo storage stakeInfo,
|
819
|
+
IStaking.TargetInfo storage targetInfo
|
820
|
+
)
|
821
|
+
internal
|
822
|
+
returns (Amount rewardIncreaseAmount)
|
519
823
|
{
|
520
|
-
if
|
521
|
-
|
824
|
+
// return if reward rate is zero
|
825
|
+
if (targetInfo.rewardRate.eqz()) {
|
826
|
+
return rewardIncreaseAmount;
|
522
827
|
}
|
523
828
|
|
524
|
-
//
|
525
|
-
|
526
|
-
|
527
|
-
_reserveBalance[nftId] = AmountLib.zero();
|
829
|
+
// get seconds since last update on stake
|
830
|
+
Seconds duration = SecondsLib.toSeconds(
|
831
|
+
block.timestamp - stakeInfo.lastUpdateAt.toInt());
|
528
832
|
|
529
|
-
//
|
530
|
-
|
531
|
-
|
833
|
+
// return if duration is zero
|
834
|
+
if (duration.eqz()) {
|
835
|
+
return AmountLib.zero();
|
836
|
+
}
|
837
|
+
|
838
|
+
// calculate reward increase since
|
839
|
+
rewardIncreaseAmount = StakingLib.calculateRewardAmount(
|
840
|
+
targetInfo.rewardRate,
|
841
|
+
duration,
|
842
|
+
stakeInfo.stakedAmount);
|
843
|
+
|
844
|
+
// update target + stake
|
845
|
+
targetInfo.rewardAmount = targetInfo.rewardAmount + rewardIncreaseAmount;
|
846
|
+
stakeInfo.rewardAmount = stakeInfo.rewardAmount + rewardIncreaseAmount;
|
847
|
+
_setLastUpdatesToCurrent(stakeInfo, targetInfo);
|
848
|
+
|
849
|
+
// logging
|
850
|
+
emit IStaking.LogStakingStakeRewardsUpdated(
|
851
|
+
stakeNftId,
|
852
|
+
rewardIncreaseAmount,
|
853
|
+
stakeInfo.stakedAmount,
|
854
|
+
stakeInfo.rewardAmount,
|
855
|
+
stakeInfo.lockedUntil);
|
532
856
|
}
|
533
857
|
|
534
858
|
|
535
|
-
function
|
536
|
-
|
859
|
+
function _restakeRewards(
|
860
|
+
NftId stakeNftId,
|
861
|
+
IStaking.StakeInfo storage stakeInfo,
|
862
|
+
IStaking.TargetInfo storage targetInfo
|
863
|
+
)
|
864
|
+
internal
|
865
|
+
returns (Amount restakeAmount)
|
537
866
|
{
|
538
|
-
|
539
|
-
|
867
|
+
restakeAmount = stakeInfo.rewardAmount;
|
868
|
+
|
869
|
+
// return if reward amount is zero
|
870
|
+
if (restakeAmount.eqz()) {
|
871
|
+
return restakeAmount;
|
540
872
|
}
|
541
873
|
|
542
|
-
//
|
543
|
-
|
544
|
-
|
874
|
+
// check restaking amount does not exceed target max staked amount
|
875
|
+
_checkMaxStakedAmount(stakeInfo.targetNftId, targetInfo, restakeAmount);
|
876
|
+
|
877
|
+
// use up reserves for newly staked dips
|
878
|
+
_spendRewardReserves(stakeInfo.targetNftId, targetInfo, restakeAmount);
|
879
|
+
|
880
|
+
// update target + stake
|
881
|
+
targetInfo.stakedAmount = targetInfo.stakedAmount + restakeAmount;
|
882
|
+
targetInfo.rewardAmount = targetInfo.rewardAmount - restakeAmount;
|
883
|
+
stakeInfo.stakedAmount = stakeInfo.stakedAmount + restakeAmount;
|
884
|
+
stakeInfo.rewardAmount = AmountLib.zero();
|
885
|
+
_setLastUpdatesToCurrent(stakeInfo, targetInfo);
|
886
|
+
|
887
|
+
// logging
|
888
|
+
emit IStaking.LogStakingRewardsRestaked(
|
889
|
+
stakeNftId,
|
890
|
+
restakeAmount,
|
891
|
+
stakeInfo.stakedAmount,
|
892
|
+
AmountLib.zero(),
|
893
|
+
stakeInfo.lockedUntil);
|
894
|
+
}
|
545
895
|
|
546
|
-
|
547
|
-
|
548
|
-
|
896
|
+
|
897
|
+
function _stake(
|
898
|
+
NftId stakeNftId,
|
899
|
+
IStaking.StakeInfo storage stakeInfo,
|
900
|
+
IStaking.TargetInfo storage targetInfo,
|
901
|
+
Seconds maxAdditionalLockingPeriod,
|
902
|
+
Amount stakeAmount
|
903
|
+
)
|
904
|
+
internal
|
905
|
+
{
|
906
|
+
// return if reward amount is zero
|
907
|
+
if (stakeAmount.eqz()) {
|
908
|
+
return;
|
909
|
+
}
|
910
|
+
|
911
|
+
// check restaking amount does not exceed target max staked amount
|
912
|
+
_checkMaxStakedAmount(stakeInfo.targetNftId, targetInfo, stakeAmount);
|
913
|
+
|
914
|
+
// update target + stake
|
915
|
+
targetInfo.stakedAmount = targetInfo.stakedAmount + stakeAmount;
|
916
|
+
stakeInfo.stakedAmount = stakeInfo.stakedAmount + stakeAmount;
|
917
|
+
|
918
|
+
// increase locked until if applicable
|
919
|
+
Seconds additionalLockingPeriod = SecondsLib.min(maxAdditionalLockingPeriod, targetInfo.lockingPeriod);
|
920
|
+
if (stakeAmount.gtz() && additionalLockingPeriod.gtz()) {
|
921
|
+
stakeInfo.lockedUntil = stakeInfo.lockedUntil.addSeconds(additionalLockingPeriod);
|
922
|
+
}
|
923
|
+
|
924
|
+
_setLastUpdatesToCurrent(stakeInfo, targetInfo);
|
925
|
+
|
926
|
+
// logging
|
927
|
+
emit IStaking.LogStakingStaked(
|
928
|
+
stakeNftId,
|
929
|
+
stakeAmount,
|
930
|
+
stakeInfo.stakedAmount,
|
931
|
+
stakeInfo.rewardAmount,
|
932
|
+
stakeInfo.lockedUntil);
|
549
933
|
}
|
550
934
|
|
551
935
|
|
552
|
-
function
|
936
|
+
function _claimRewards(
|
553
937
|
NftId stakeNftId,
|
554
|
-
|
555
|
-
|
938
|
+
IStaking.StakeInfo storage stakeInfo,
|
939
|
+
IStaking.TargetInfo storage targetInfo,
|
940
|
+
Amount maxClaimAmount
|
556
941
|
)
|
557
|
-
|
942
|
+
internal
|
943
|
+
returns (Amount claimAmount)
|
558
944
|
{
|
559
|
-
|
560
|
-
_rewardBalance[stakeNftId] = newRewardAmount;
|
945
|
+
claimAmount = AmountLib.min(maxClaimAmount, stakeInfo.rewardAmount);
|
561
946
|
|
562
|
-
|
563
|
-
|
947
|
+
// return if no rewards to claim
|
948
|
+
if (claimAmount.eqz()) {
|
949
|
+
return claimAmount;
|
950
|
+
}
|
951
|
+
|
952
|
+
// effects
|
953
|
+
// use up reserves for claimed rewards
|
954
|
+
_spendRewardReserves(stakeInfo.targetNftId, targetInfo, claimAmount);
|
955
|
+
|
956
|
+
// update target + stake
|
957
|
+
targetInfo.rewardAmount = targetInfo.rewardAmount - claimAmount;
|
958
|
+
stakeInfo.rewardAmount = stakeInfo.rewardAmount - claimAmount;
|
959
|
+
_setLastUpdatesToCurrent(stakeInfo, targetInfo);
|
960
|
+
|
961
|
+
// logging
|
962
|
+
emit IStaking.LogStakingRewardsClaimed(
|
963
|
+
stakeNftId,
|
964
|
+
claimAmount,
|
965
|
+
stakeInfo.stakedAmount,
|
966
|
+
stakeInfo.rewardAmount,
|
967
|
+
stakeInfo.lockedUntil);
|
564
968
|
}
|
565
969
|
|
566
970
|
|
567
|
-
function
|
568
|
-
NftId
|
569
|
-
|
570
|
-
|
971
|
+
function _unstake(
|
972
|
+
NftId stakeNftId,
|
973
|
+
IStaking.StakeInfo storage stakeInfo,
|
974
|
+
IStaking.TargetInfo storage targetInfo,
|
975
|
+
Amount maxUnstakeAmount
|
976
|
+
)
|
977
|
+
internal
|
978
|
+
returns (Amount unstakedAmount)
|
979
|
+
{
|
980
|
+
unstakedAmount = AmountLib.min(maxUnstakeAmount, stakeInfo.stakedAmount);
|
981
|
+
|
982
|
+
// return if no stakes to claim
|
983
|
+
if (unstakedAmount.eqz()) {
|
984
|
+
return unstakedAmount;
|
985
|
+
}
|
986
|
+
|
987
|
+
// check if stake is still locked
|
988
|
+
if (isStakeLocked(stakeNftId)) {
|
989
|
+
revert IStaking.ErrorStakingStakeLocked(stakeNftId, stakeInfo.lockedUntil);
|
990
|
+
}
|
991
|
+
|
992
|
+
// update target + stake
|
993
|
+
targetInfo.stakedAmount = targetInfo.stakedAmount - unstakedAmount;
|
994
|
+
stakeInfo.stakedAmount = stakeInfo.stakedAmount - unstakedAmount;
|
995
|
+
_setLastUpdatesToCurrent(stakeInfo, targetInfo);
|
996
|
+
|
997
|
+
// logging
|
998
|
+
emit IStaking.LogStakingUnstaked(
|
999
|
+
stakeNftId,
|
1000
|
+
unstakedAmount,
|
1001
|
+
stakeInfo.stakedAmount,
|
1002
|
+
stakeInfo.rewardAmount,
|
1003
|
+
stakeInfo.lockedUntil);
|
1004
|
+
}
|
1005
|
+
|
1006
|
+
|
1007
|
+
function _setLastUpdatesToCurrent(
|
1008
|
+
IStaking.StakeInfo storage stakeInfo,
|
1009
|
+
IStaking.TargetInfo storage targetInfo
|
1010
|
+
)
|
1011
|
+
internal
|
1012
|
+
{
|
1013
|
+
targetInfo.lastUpdateIn = BlocknumberLib.current();
|
1014
|
+
_setStakeLastUpdatesToCurrent(stakeInfo);
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
|
1018
|
+
function _setStakeLastUpdatesToCurrent(
|
1019
|
+
IStaking.StakeInfo storage stakeInfo
|
1020
|
+
)
|
1021
|
+
internal
|
1022
|
+
{
|
1023
|
+
stakeInfo.lastUpdateIn = BlocknumberLib.current();
|
1024
|
+
stakeInfo.lastUpdateAt = TimestampLib.current();
|
1025
|
+
}
|
1026
|
+
|
1027
|
+
//--- private stake and target functions --------------------------------//
|
1028
|
+
|
1029
|
+
|
1030
|
+
function _getAndVerifyStake(
|
1031
|
+
NftId stakeNftId
|
571
1032
|
)
|
572
1033
|
private
|
1034
|
+
view
|
1035
|
+
returns (
|
1036
|
+
IStaking.StakeInfo storage stakeInfo
|
1037
|
+
)
|
573
1038
|
{
|
574
|
-
|
575
|
-
|
1039
|
+
stakeInfo = _stakeInfo[stakeNftId];
|
1040
|
+
if (stakeInfo.lastUpdateIn.eqz()) {
|
1041
|
+
revert ErrorStakingStoreStakeNotInitialized(stakeNftId);
|
1042
|
+
}
|
1043
|
+
}
|
576
1044
|
|
577
|
-
|
578
|
-
|
1045
|
+
|
1046
|
+
function _checkMaxStakedAmount(
|
1047
|
+
NftId targetNftId,
|
1048
|
+
IStaking.TargetInfo storage targetInfo,
|
1049
|
+
Amount additionalstakedAmount
|
1050
|
+
)
|
1051
|
+
private
|
1052
|
+
{
|
1053
|
+
if (targetInfo.stakedAmount + additionalstakedAmount > targetInfo.limitAmount) {
|
1054
|
+
revert IStaking.ErrorStakingTargetMaxStakedAmountExceeded(
|
1055
|
+
targetNftId,
|
1056
|
+
targetInfo.limitAmount,
|
1057
|
+
targetInfo.stakedAmount + additionalstakedAmount);
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
// TODO add check for tvl dependent maximum, see #628
|
579
1061
|
}
|
580
1062
|
|
581
|
-
|
1063
|
+
|
1064
|
+
function _getAndVerifyTarget(
|
1065
|
+
NftId targetNftId
|
1066
|
+
)
|
582
1067
|
private
|
583
1068
|
view
|
584
|
-
returns (
|
1069
|
+
returns (
|
1070
|
+
IStaking.TargetInfo storage targetInfo
|
1071
|
+
)
|
585
1072
|
{
|
586
|
-
|
1073
|
+
targetInfo = _targetInfo[targetNftId];
|
587
1074
|
|
588
|
-
if (
|
589
|
-
revert
|
1075
|
+
if (targetInfo.lastUpdateIn.eqz()) {
|
1076
|
+
revert ErrorStakingStoreTargetNotInitialized(targetNftId);
|
590
1077
|
}
|
591
1078
|
}
|
592
1079
|
|
593
1080
|
|
594
|
-
function
|
595
|
-
NftId targetNftId
|
596
|
-
address token
|
1081
|
+
function _getAndVerifyLimit(
|
1082
|
+
NftId targetNftId
|
597
1083
|
)
|
598
1084
|
private
|
599
1085
|
view
|
600
1086
|
returns (
|
601
|
-
|
602
|
-
Amount oldBalance,
|
603
|
-
Amount oldDipBalance
|
1087
|
+
IStaking.LimitInfo storage limitInfo
|
604
1088
|
)
|
605
1089
|
{
|
606
|
-
|
1090
|
+
limitInfo = _limitInfo[targetNftId];
|
1091
|
+
|
1092
|
+
if (limitInfo.lastUpdateIn.eqz()) {
|
1093
|
+
revert ErrorStakingStoreLimitNotInitialized(targetNftId);
|
1094
|
+
}
|
1095
|
+
}
|
1096
|
+
|
1097
|
+
//--- private tvl functions ------------------------------------------------//
|
1098
|
+
|
1099
|
+
/// @dev Initializes token balance handling for the specified target.
|
1100
|
+
function _createTvlBalance(NftId targetNftId, address token)
|
1101
|
+
private
|
1102
|
+
{
|
1103
|
+
IStaking.TvlInfo storage info = _tvlInfo[targetNftId][token];
|
607
1104
|
|
608
|
-
if (
|
609
|
-
revert
|
1105
|
+
if (info.lastUpdateIn.gtz()) {
|
1106
|
+
revert ErrorStakingStoreTvlBalanceAlreadyInitialized(targetNftId, token);
|
610
1107
|
}
|
611
1108
|
|
612
|
-
|
613
|
-
|
1109
|
+
// set tvl balances to 0 and update last updated in
|
1110
|
+
info.tvlAmount = AmountLib.zero();
|
1111
|
+
info.lastUpdateIn = BlocknumberLib.current();
|
1112
|
+
}
|
1113
|
+
|
1114
|
+
|
1115
|
+
function _updateTvlBalance(
|
1116
|
+
NftId targetNftId,
|
1117
|
+
address token,
|
1118
|
+
Amount newTvlAmount
|
1119
|
+
)
|
1120
|
+
private
|
1121
|
+
returns (
|
1122
|
+
Amount oldTvlAmount,
|
1123
|
+
Blocknumber lastUpdatedIn
|
1124
|
+
)
|
1125
|
+
{
|
1126
|
+
IStaking.TvlInfo storage tvlInfo = _getAndVerifyTvl(targetNftId, token);
|
1127
|
+
oldTvlAmount = tvlInfo.tvlAmount;
|
1128
|
+
lastUpdatedIn = tvlInfo.lastUpdateIn;
|
1129
|
+
|
1130
|
+
tvlInfo.tvlAmount = newTvlAmount;
|
1131
|
+
tvlInfo.lastUpdateIn = BlocknumberLib.current();
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
|
1135
|
+
function _getAndVerifyTvl(NftId targetNftId, address token)
|
1136
|
+
private
|
1137
|
+
view
|
1138
|
+
returns (IStaking.TvlInfo storage tvlInfo)
|
1139
|
+
{
|
1140
|
+
tvlInfo = _tvlInfo[targetNftId][token];
|
1141
|
+
if (tvlInfo.lastUpdateIn.eqz()) {
|
1142
|
+
revert ErrorStakingStoreTvlBalanceNotInitialized(targetNftId, token);
|
1143
|
+
}
|
614
1144
|
}
|
615
1145
|
}
|