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