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