@etherisc/gif-next 0.0.2-804cdbf-724 → 0.0.2-8112a1f-745
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -9
- package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.dbg.json +4 -0
- package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.json +1075 -0
- package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.dbg.json +4 -0
- package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.json +790 -0
- package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.dbg.json +4 -0
- package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.json +843 -0
- package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.dbg.json +1 -1
- package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.json +673 -262
- package/artifacts/contracts/authorization/AccessAdminLib.sol/AccessAdminLib.dbg.json +4 -0
- package/artifacts/contracts/authorization/AccessAdminLib.sol/AccessAdminLib.json +1289 -0
- package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.dbg.json +1 -1
- package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.json +202 -5
- package/artifacts/contracts/authorization/Authorization.sol/Authorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/Authorization.sol/Authorization.json +456 -24
- package/artifacts/contracts/authorization/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.dbg.json +1 -1
- package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.json +549 -209
- package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.json +215 -18
- package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.json +265 -16
- package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.json +473 -17
- package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.dbg.json +1 -1
- package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.json +212 -473
- package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.dbg.json +1 -1
- package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.json +431 -36
- package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +139 -381
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +814 -399
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +228 -124
- package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +135 -187
- package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +582 -141
- package/artifacts/contracts/examples/fire/DamageLevel.sol/DamageLevelLib.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/DamageLevel.sol/DamageLevelLib.json +22 -0
- package/artifacts/contracts/examples/fire/FirePool.sol/FirePool.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/FirePool.sol/FirePool.json +1484 -0
- package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.json +805 -0
- package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.json +2053 -0
- package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.json +805 -0
- package/artifacts/contracts/examples/fire/FireUSD.sol/FireUSD.dbg.json +4 -0
- package/artifacts/contracts/examples/fire/FireUSD.sol/FireUSD.json +376 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.json +1439 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.json +805 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.json +1171 -0
- package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.json +1647 -0
- package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.json +805 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.json +2585 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleProductAuthorization.sol/SimpleProductAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleProductAuthorization.sol/SimpleProductAuthorization.json +805 -0
- package/artifacts/contracts/instance/BundleSet.sol/BundleSet.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleSet.sol/BundleSet.json +193 -45
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +567 -67
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +385 -60
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +573 -165
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +1034 -311
- package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +369 -68
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1685 -774
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +399 -231
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +143 -105
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +983 -782
- package/artifacts/contracts/instance/RiskSet.sol/RiskSet.dbg.json +4 -0
- package/artifacts/contracts/instance/RiskSet.sol/RiskSet.json +866 -0
- package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.json +8 -8
- package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.json +2 -2
- package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.json +46 -5
- package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.json +16 -5
- package/artifacts/contracts/instance/base/ObjectSetHelperLib.sol/ObjectSetHelperLib.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ObjectSetHelperLib.sol/ObjectSetHelperLib.json +168 -0
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/mock/Dip.sol/Dip.dbg.json +1 -1
- package/artifacts/contracts/mock/Dip.sol/Dip.json +2 -2
- package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.json +152 -350
- package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +1 -1
- package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +429 -37
- package/artifacts/contracts/oracle/IOracle.sol/IOracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.json +129 -129
- package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.json +98 -11
- package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +128 -318
- package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +198 -190
- package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +177 -97
- package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +1 -1
- package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +198 -433
- package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +1 -1
- package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +430 -35
- package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleService.sol/BundleService.json +574 -270
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +216 -104
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +383 -53
- package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +158 -212
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +711 -340
- package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/pool/Pool.sol/Pool.json +148 -392
- package/artifacts/contracts/pool/PoolLib.sol/PoolLib.dbg.json +4 -0
- package/artifacts/contracts/pool/PoolLib.sol/PoolLib.json +522 -0
- package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolService.sol/PoolService.json +925 -545
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +230 -106
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +353 -180
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +159 -99
- package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +1 -1
- package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +287 -427
- package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +1 -1
- package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +430 -35
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +466 -245
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +187 -123
- package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.json +301 -9
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +350 -18
- package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +417 -101
- package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
- package/artifacts/contracts/product/IPricingService.sol/IPricingService.json +183 -80
- package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +272 -222
- package/artifacts/contracts/product/IRiskService.sol/IRiskService.dbg.json +4 -0
- package/artifacts/contracts/{shared/ComponentVerifyingService.sol/ComponentVerifyingService.json → product/IRiskService.sol/IRiskService.json} +283 -157
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +532 -311
- package/artifacts/contracts/product/PolicyServiceLib.sol/PolicyServiceLib.dbg.json +4 -0
- package/artifacts/contracts/product/PolicyServiceLib.sol/PolicyServiceLib.json +783 -0
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +196 -108
- package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
- package/artifacts/contracts/product/PricingService.sol/PricingService.json +249 -329
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +165 -137
- package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/product/Product.sol/Product.json +279 -419
- package/artifacts/contracts/product/RiskService.sol/RiskService.dbg.json +4 -0
- package/artifacts/contracts/product/RiskService.sol/RiskService.json +873 -0
- package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.dbg.json +4 -0
- package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.json +774 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +59 -16
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +359 -48
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +169 -37
- package/artifacts/contracts/registry/IRelease.sol/IRelease.dbg.json +4 -0
- package/artifacts/contracts/registry/IRelease.sol/IRelease.json +24 -0
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +5 -18
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +565 -109
- package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +795 -394
- package/artifacts/contracts/registry/RegistryAuthorization.sol/RegistryAuthorization.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryAuthorization.sol/RegistryAuthorization.json +1061 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +136 -290
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +141 -89
- package/artifacts/contracts/registry/ReleaseAdmin.sol/ReleaseAdmin.dbg.json +4 -0
- package/artifacts/contracts/registry/ReleaseAdmin.sol/ReleaseAdmin.json +2152 -0
- package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.json +47 -6
- package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.json +483 -253
- package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +1 -1
- package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +489 -20
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +120 -60
- package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/shared/Component.sol/Component.json +86 -277
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +624 -560
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +198 -120
- package/artifacts/contracts/shared/ContractLib.sol/ContractLib.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractLib.sol/ContractLib.json +632 -0
- package/artifacts/contracts/shared/ContractLib.sol/IInstanceAdminHelper.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractLib.sol/IInstanceAdminHelper.json +24 -0
- package/artifacts/contracts/shared/ContractLib.sol/ITargetHelper.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractLib.sol/ITargetHelper.json +30 -0
- package/artifacts/contracts/shared/ContractLib.sol/ITokenRegistryHelper.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractLib.sol/ITokenRegistryHelper.json +40 -0
- package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponent.sol/IComponent.json +92 -93
- package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponentService.sol/IComponentService.json +535 -240
- package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +118 -129
- package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.json +42 -6
- package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.json +36 -0
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +35 -0
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +15 -47
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +167 -0
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +84 -2
- package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.dbg.json +4 -0
- package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.json +53 -0
- package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.json +117 -318
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.json +48 -7
- package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.json +42 -1
- package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.dbg.json +1 -1
- package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.json +2 -2
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +41 -57
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +19 -141
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +141 -97
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -15
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +86 -111
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +585 -12
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandlerBase.dbg.json +4 -0
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandlerBase.json +484 -0
- package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.dbg.json +4 -0
- package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.json +172 -0
- package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/IStaking.sol/IStaking.json +1086 -164
- 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 +1230 -415
- package/artifacts/contracts/staking/StakingLib.sol/StakingLib.dbg.json +4 -0
- package/artifacts/contracts/staking/StakingLib.sol/StakingLib.json +470 -0
- package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.json +46 -5
- package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +201 -104
- 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 +999 -599
- package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
- package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +135 -49
- package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
- package/artifacts/contracts/type/Amount.sol/AmountLib.json +63 -10
- package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.json +45 -19
- package/artifacts/contracts/type/ChainId.sol/ChainIdLib.dbg.json +4 -0
- package/artifacts/contracts/type/ChainId.sol/ChainIdLib.json +193 -0
- package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.json +28 -4
- package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.json +2 -2
- package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/type/Fee.sol/FeeLib.json +98 -37
- package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/type/Key32.sol/Key32Lib.json +2 -2
- package/artifacts/contracts/type/Key32Set.sol/LibKey32Set.dbg.json +4 -0
- package/artifacts/contracts/type/Key32Set.sol/LibKey32Set.json +33 -0
- package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/NftId.sol/NftIdLib.json +23 -4
- package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.json +2 -2
- package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.json +33 -31
- package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.json +19 -19
- package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/type/Referral.sol/ReferralLib.json +2 -2
- package/artifacts/contracts/type/RequestId.sol/RequestIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RequestId.sol/RequestIdLib.json +2 -2
- package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RiskId.sol/RiskIdLib.json +125 -7
- package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +42 -157
- package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
- package/artifacts/contracts/type/Seconds.sol/SecondsLib.json +93 -2
- package/artifacts/contracts/type/Selector.sol/SelectorLib.dbg.json +1 -1
- package/artifacts/contracts/type/Selector.sol/SelectorLib.json +21 -2
- package/artifacts/contracts/type/Selector.sol/SelectorSetLib.dbg.json +1 -1
- package/artifacts/contracts/type/Selector.sol/SelectorSetLib.json +2 -2
- package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/StateId.sol/StateIdLib.json +15 -2
- package/artifacts/contracts/type/String.sol/StrLib.dbg.json +1 -1
- package/artifacts/contracts/type/String.sol/StrLib.json +50 -2
- package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/type/Timestamp.sol/TimestampLib.json +24 -5
- package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/type/UFixed.sol/UFixedLib.json +109 -35
- package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/type/Version.sol/VersionLib.json +2 -21
- package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/type/Version.sol/VersionPartLib.json +101 -2
- package/artifacts/contracts/upgradeability/IVersionable.sol/IVersionable.dbg.json +4 -0
- package/artifacts/contracts/{shared → upgradeability}/IVersionable.sol/IVersionable.json +11 -1
- package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.dbg.json +4 -0
- package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.json +656 -0
- package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
- package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +142 -0
- package/artifacts/contracts/upgradeability/Versionable.sol/Versionable.dbg.json +4 -0
- package/artifacts/contracts/{shared → upgradeability}/Versionable.sol/Versionable.json +11 -1
- package/contracts/accounting/AccountingService.sol +274 -0
- package/contracts/accounting/AccountingServiceManager.sol +38 -0
- package/contracts/accounting/IAccountingService.sol +47 -0
- package/contracts/authorization/AccessAdmin.sol +458 -269
- package/contracts/authorization/AccessAdminLib.sol +396 -0
- package/contracts/authorization/AccessManagerCloneable.sol +146 -4
- package/contracts/authorization/Authorization.sol +159 -208
- package/contracts/authorization/IAccess.sol +25 -6
- package/contracts/authorization/IAccessAdmin.sol +87 -79
- package/contracts/authorization/IAuthorization.sol +9 -37
- package/contracts/authorization/IServiceAuthorization.sol +57 -17
- package/contracts/authorization/ServiceAuthorization.sol +255 -25
- package/contracts/distribution/BasicDistribution.sol +22 -30
- package/contracts/distribution/BasicDistributionAuthorization.sol +34 -10
- package/contracts/distribution/Distribution.sol +48 -84
- package/contracts/distribution/DistributionService.sol +276 -130
- package/contracts/distribution/DistributionServiceManager.sol +8 -11
- package/contracts/distribution/IDistributionComponent.sol +11 -14
- package/contracts/distribution/IDistributionService.sol +56 -26
- package/contracts/examples/fire/DamageLevel.sol +59 -0
- package/contracts/examples/fire/FirePool.sol +86 -0
- package/contracts/examples/fire/FirePoolAuthorization.sol +35 -0
- package/contracts/examples/fire/FireProduct.sol +433 -0
- package/contracts/examples/fire/FireProductAuthorization.sol +45 -0
- package/contracts/examples/fire/FireUSD.sol +26 -0
- package/contracts/examples/unpermissioned/SimpleDistribution.sol +81 -0
- package/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol +28 -0
- package/contracts/examples/unpermissioned/SimpleOracle.sol +133 -0
- package/contracts/examples/unpermissioned/SimplePool.sol +102 -0
- package/contracts/examples/unpermissioned/SimplePoolAuthorization.sol +28 -0
- package/contracts/examples/unpermissioned/SimpleProduct.sol +437 -0
- package/contracts/examples/unpermissioned/SimpleProductAuthorization.sol +28 -0
- package/contracts/instance/BundleSet.sol +42 -38
- package/contracts/instance/IInstance.sol +102 -43
- package/contracts/instance/IInstanceService.sol +59 -34
- package/contracts/instance/Instance.sol +193 -100
- package/contracts/instance/InstanceAdmin.sol +275 -158
- package/contracts/instance/InstanceAuthorizationV3.sol +120 -56
- package/contracts/instance/InstanceReader.sol +478 -251
- package/contracts/instance/InstanceService.sol +293 -236
- package/contracts/instance/InstanceServiceManager.sol +8 -13
- package/contracts/instance/InstanceStore.sol +24 -2
- package/contracts/instance/RiskSet.sol +126 -0
- package/contracts/instance/base/BalanceStore.sol +4 -6
- package/contracts/instance/base/ObjectCounter.sol +1 -2
- package/contracts/instance/base/ObjectLifecycle.sol +13 -10
- package/contracts/instance/base/ObjectSet.sol +31 -33
- package/contracts/instance/base/ObjectSetHelperLib.sol +30 -0
- package/contracts/instance/module/IBundle.sol +6 -5
- package/contracts/instance/module/IComponents.sol +30 -20
- package/contracts/instance/module/IDistribution.sol +21 -9
- package/contracts/instance/module/IPolicy.sol +50 -29
- package/contracts/instance/module/IRisk.sol +5 -0
- package/contracts/mock/Dip.sol +1 -1
- package/contracts/oracle/BasicOracle.sol +2 -5
- package/contracts/oracle/BasicOracleAuthorization.sol +15 -8
- package/contracts/oracle/IOracle.sol +9 -4
- package/contracts/oracle/IOracleComponent.sol +2 -1
- package/contracts/oracle/IOracleService.sol +2 -1
- package/contracts/oracle/Oracle.sol +23 -26
- package/contracts/oracle/OracleService.sol +119 -87
- package/contracts/oracle/OracleServiceManager.sol +8 -11
- package/contracts/pool/BasicPool.sol +39 -41
- package/contracts/pool/BasicPoolAuthorization.sol +43 -11
- package/contracts/pool/BundleService.sol +218 -128
- package/contracts/pool/BundleServiceManager.sol +8 -11
- package/contracts/pool/IBundleService.sol +43 -33
- package/contracts/pool/IPoolComponent.sol +20 -10
- package/contracts/pool/IPoolService.sol +97 -77
- package/contracts/pool/Pool.sol +146 -124
- package/contracts/pool/PoolLib.sol +341 -0
- package/contracts/pool/PoolService.sol +419 -256
- package/contracts/pool/PoolServiceManager.sol +6 -9
- package/contracts/product/ApplicationService.sol +153 -80
- package/contracts/product/ApplicationServiceManager.sol +6 -6
- package/contracts/product/BasicProduct.sol +13 -46
- package/contracts/product/BasicProductAuthorization.sol +33 -10
- package/contracts/product/ClaimService.sol +382 -194
- package/contracts/product/ClaimServiceManager.sol +6 -6
- package/contracts/product/IApplicationService.sol +29 -3
- package/contracts/product/IClaimService.sol +48 -11
- package/contracts/product/IPolicyService.sol +61 -37
- package/contracts/product/IPricingService.sol +11 -10
- package/contracts/product/IProductComponent.sol +28 -5
- package/contracts/product/IRiskService.sol +48 -0
- package/contracts/product/PolicyService.sol +443 -273
- package/contracts/product/PolicyServiceLib.sol +139 -0
- package/contracts/product/PolicyServiceManager.sol +6 -9
- package/contracts/product/PricingService.sol +90 -84
- package/contracts/product/PricingServiceManager.sol +6 -9
- package/contracts/product/Product.sol +201 -100
- package/contracts/product/RiskService.sol +190 -0
- package/contracts/product/RiskServiceManager.sol +39 -0
- package/contracts/registry/ChainNft.sol +72 -40
- package/contracts/registry/IRegistry.sol +70 -32
- package/contracts/registry/IRegistryService.sol +5 -12
- package/contracts/registry/IRelease.sol +29 -0
- package/contracts/registry/ITransferInterceptor.sol +1 -2
- package/contracts/registry/Registry.sol +367 -207
- package/contracts/registry/RegistryAdmin.sol +110 -287
- package/contracts/registry/RegistryAuthorization.sol +309 -0
- package/contracts/registry/RegistryService.sol +42 -67
- package/contracts/registry/RegistryServiceManager.sol +5 -5
- package/contracts/registry/ReleaseAdmin.sol +195 -0
- package/contracts/registry/ReleaseLifecycle.sol +8 -3
- package/contracts/registry/ReleaseRegistry.sol +279 -241
- package/contracts/registry/ServiceAuthorizationV3.sol +205 -63
- package/contracts/registry/TokenRegistry.sol +61 -59
- package/contracts/shared/Component.sol +70 -137
- package/contracts/shared/ComponentService.sol +452 -346
- package/contracts/shared/ComponentServiceManager.sol +10 -7
- package/contracts/shared/ContractLib.sol +312 -0
- package/contracts/shared/IComponent.sol +6 -18
- package/contracts/shared/IComponentService.sol +50 -41
- package/contracts/shared/IInstanceLinkedComponent.sol +7 -27
- package/contracts/shared/IKeyValueStore.sol +1 -1
- package/contracts/shared/ILifecycle.sol +3 -1
- package/contracts/shared/INftOwnable.sol +4 -0
- package/contracts/shared/IPolicyHolder.sol +12 -22
- package/contracts/shared/IRegisterable.sol +22 -1
- package/contracts/shared/IService.sol +4 -6
- package/contracts/shared/{ERC165.sol → InitializableERC165.sol} +11 -3
- package/contracts/shared/InstanceLinkedComponent.sol +83 -40
- package/contracts/shared/KeyValueStore.sol +4 -4
- package/contracts/shared/Lifecycle.sol +15 -4
- package/contracts/shared/NftOwnable.sol +33 -11
- package/contracts/shared/PolicyHolder.sol +20 -59
- package/contracts/shared/Registerable.sol +52 -21
- package/contracts/shared/RegistryLinked.sol +9 -14
- package/contracts/shared/Service.sol +22 -38
- package/contracts/shared/TokenHandler.sol +310 -26
- package/contracts/shared/TokenHandlerDeployerLib.sol +20 -0
- package/contracts/staking/IStaking.sol +163 -66
- package/contracts/staking/IStakingService.sol +45 -78
- package/contracts/staking/Staking.sol +478 -243
- package/contracts/staking/StakingLib.sol +195 -0
- package/contracts/staking/StakingManager.sol +11 -13
- package/contracts/staking/StakingReader.sol +55 -90
- package/contracts/staking/StakingService.sol +62 -152
- package/contracts/staking/StakingServiceManager.sol +9 -7
- package/contracts/staking/StakingStore.sol +698 -340
- package/contracts/staking/TargetManagerLib.sol +8 -4
- package/contracts/type/Amount.sol +31 -5
- package/contracts/type/Blocknumber.sol +22 -16
- package/contracts/type/ChainId.sol +101 -0
- package/contracts/type/ClaimId.sol +6 -1
- package/contracts/type/Fee.sol +8 -8
- package/contracts/type/Key32.sol +2 -2
- package/contracts/type/Key32Set.sol +62 -0
- package/contracts/type/NftId.sol +7 -0
- package/contracts/type/ObjectType.sol +73 -37
- package/contracts/type/PayoutId.sol +10 -10
- package/contracts/type/Referral.sol +1 -0
- package/contracts/type/RiskId.sol +38 -6
- package/contracts/type/RoleId.sol +61 -55
- package/contracts/type/Seconds.sol +35 -1
- package/contracts/type/Selector.sol +5 -0
- package/contracts/type/StateId.sol +15 -1
- package/contracts/type/String.sol +12 -0
- package/contracts/type/Timestamp.sol +14 -7
- package/contracts/type/UFixed.sol +57 -126
- package/contracts/type/Version.sol +54 -5
- package/contracts/{shared → upgradeability}/IVersionable.sol +3 -0
- package/contracts/{shared → upgradeability}/ProxyManager.sol +96 -48
- package/contracts/{shared → upgradeability}/UpgradableProxyWithAdmin.sol +12 -2
- package/contracts/{shared → upgradeability}/Versionable.sol +8 -5
- package/package.json +5 -4
- package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.dbg.json +0 -4
- package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.json +0 -290
- package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.dbg.json +0 -4
- package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.json +0 -390
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +0 -4
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +0 -129
- package/artifacts/contracts/product/IProductService.sol/IProductService.dbg.json +0 -4
- package/artifacts/contracts/product/IProductService.sol/IProductService.json +0 -400
- package/artifacts/contracts/product/ProductService.sol/ProductService.dbg.json +0 -4
- package/artifacts/contracts/product/ProductService.sol/ProductService.json +0 -708
- package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +0 -4
- package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +0 -702
- package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +0 -4
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +0 -4
- package/artifacts/contracts/shared/ERC165.sol/ERC165.json +0 -73
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +0 -4
- package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.dbg.json +0 -4
- package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.json +0 -39
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +0 -4
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +0 -617
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +0 -4
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +0 -129
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +0 -4
- package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +0 -4
- package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +0 -460
- package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +0 -4
- package/artifacts/contracts/type/UFixed.sol/MathLib.json +0 -10
- package/contracts/authorization/IModuleAuthorization.sol +0 -21
- package/contracts/authorization/ModuleAuthorization.sol +0 -78
- package/contracts/instance/module/IAccess.sol +0 -46
- package/contracts/product/IProductService.sol +0 -33
- package/contracts/product/ProductService.sol +0 -124
- package/contracts/product/ProductServiceManager.sol +0 -42
- package/contracts/shared/ComponentVerifyingService.sol +0 -117
- package/contracts/shared/InitializableCustom.sol +0 -177
- package/contracts/staking/StakeManagerLib.sol +0 -231
@@ -3,31 +3,24 @@ pragma solidity ^0.8.20;
|
|
3
3
|
|
4
4
|
import {AccessManaged} from "@openzeppelin/contracts/access/manager/AccessManaged.sol";
|
5
5
|
|
6
|
-
import {Amount, AmountLib} from "../type/Amount.sol";
|
7
|
-
import {Blocknumber, BlocknumberLib} from "../type/Blocknumber.sol";
|
8
|
-
import {ChainNft} from "../registry/ChainNft.sol";
|
9
|
-
import {Component} from "../shared/Component.sol";
|
10
6
|
import {IRegistry} from "../registry/IRegistry.sol";
|
11
|
-
import {IRegistryService} from "../registry/IRegistryService.sol";
|
12
7
|
import {IStaking} from "./IStaking.sol";
|
13
|
-
|
14
|
-
import {
|
8
|
+
|
9
|
+
import {Amount, AmountLib} from "../type/Amount.sol";
|
10
|
+
import {ChainId, ChainIdLib} from "../type/ChainId.sol";
|
11
|
+
import {Blocknumber, BlocknumberLib} from "../type/Blocknumber.sol";
|
15
12
|
import {KeyValueStore} from "../shared/KeyValueStore.sol";
|
16
|
-
import {KEEP_STATE} from "../type/StateId.sol";
|
17
13
|
import {NftId, NftIdLib} from "../type/NftId.sol";
|
18
14
|
import {NftIdSet} from "../shared/NftIdSet.sol";
|
19
|
-
import {ObjectType
|
15
|
+
import {ObjectType} from "../type/ObjectType.sol";
|
16
|
+
import {PROTOCOL} from "../type/ObjectType.sol";
|
20
17
|
import {Seconds, SecondsLib} from "../type/Seconds.sol";
|
18
|
+
import {StakingLib} from "./StakingLib.sol";
|
19
|
+
import {StakingLifecycle} from "./StakingLifecycle.sol";
|
21
20
|
import {StakingReader} from "./StakingReader.sol";
|
22
21
|
import {TargetManagerLib} from "./TargetManagerLib.sol";
|
23
22
|
import {Timestamp, TimestampLib} from "../type/Timestamp.sol";
|
24
|
-
import {TokenRegistry} from "../registry/TokenRegistry.sol";
|
25
23
|
import {UFixed, UFixedLib} from "../type/UFixed.sol";
|
26
|
-
import {Version, VersionLib} from "../type/Version.sol";
|
27
|
-
import {Versionable} from "../shared/Versionable.sol";
|
28
|
-
|
29
|
-
import {RegistryAdmin} from "../registry/RegistryAdmin.sol";
|
30
|
-
import {StakingLifecycle} from "./StakingLifecycle.sol";
|
31
24
|
|
32
25
|
|
33
26
|
contract StakingStore is
|
@@ -36,51 +29,44 @@ contract StakingStore is
|
|
36
29
|
StakingLifecycle
|
37
30
|
{
|
38
31
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
event LogStakingStoreTotalValueLockedDecreased(NftId targetNftId, address token, Amount amount, 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);
|
44
36
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
event LogStakingStoreRewardsIncreased(NftId nftId, Amount addedAmount, Amount newBalance, Blocknumber lastUpdatedIn);
|
49
|
-
event LogStakingStoreRewardsDecreased(NftId nftId, Amount addedAmount, Amount newBalance, Blocknumber lastUpdatedIn);
|
50
|
-
|
51
|
-
event LogStakingStoreRewardsRestaked(NftId nftId, Amount amount, Amount rewardAmount, Amount rewardIncrementAmount, Amount newBalance, Blocknumber lastUpdatedIn);
|
37
|
+
// target
|
38
|
+
error ErrorStakingStoreTargetNotInitialized(NftId targetNftId);
|
52
39
|
|
53
40
|
// in/decreasing reward reserves
|
54
41
|
error ErrorStakingStoreNotTarget(NftId targetNftId);
|
55
|
-
error ErrorStakingStoreRewardReservesInsufficient(NftId targetNftId, Amount
|
42
|
+
error ErrorStakingStoreRewardReservesInsufficient(NftId targetNftId, Amount reserveAmount, Amount claimedAmount);
|
56
43
|
|
57
|
-
//
|
58
|
-
error
|
59
|
-
error
|
44
|
+
// stakes
|
45
|
+
error ErrorStakingStoreStakesExceedingTargetMaxAmount(NftId targetNftId, Amount maxStakedAmount, Amount newIStaking);
|
46
|
+
error ErrorStakingStoreStakeNotInitialized(NftId nftId);
|
60
47
|
|
61
|
-
//
|
62
|
-
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);
|
63
55
|
|
64
56
|
IRegistry private _registry;
|
65
57
|
NftIdSet private _targetNftIdSet;
|
66
58
|
StakingReader private _reader;
|
67
59
|
|
68
|
-
//
|
69
|
-
mapping(
|
70
|
-
|
71
|
-
// total, stake and reward balances
|
72
|
-
mapping(NftId nftId => Amount stakes) private _stakeBalance;
|
73
|
-
mapping(NftId nftId => Amount rewards) private _rewardBalance;
|
74
|
-
mapping(NftId nftId => Amount reserves) private _reserveBalance;
|
60
|
+
// stakes
|
61
|
+
mapping(NftId stakeNftId => IStaking.StakeInfo) private _stakeInfo;
|
75
62
|
|
76
|
-
|
77
|
-
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;
|
78
67
|
|
79
|
-
//
|
80
|
-
mapping(
|
81
|
-
mapping(NftId nftId => mapping(address token => Amount tvlInDip)) private _tvlInDip;
|
82
|
-
mapping(NftId nftId => Amount tvlRequiredDip) private _tvlRequiredDip;
|
83
|
-
mapping(NftId nftId => Blocknumber lastUpdatedIn) private _tvlLastUpdatedIn;
|
68
|
+
// staking rate
|
69
|
+
mapping(ChainId chainId => mapping(address token => IStaking.TokenInfo)) private _tokenInfo;
|
84
70
|
|
85
71
|
|
86
72
|
constructor(IRegistry registry, StakingReader reader)
|
@@ -90,61 +76,183 @@ contract StakingStore is
|
|
90
76
|
setAuthority(registry.getAuthority());
|
91
77
|
|
92
78
|
// set internal variables
|
93
|
-
_registry = registry;
|
79
|
+
_registry = registry;
|
94
80
|
_reader = reader;
|
95
81
|
_targetNftIdSet = new NftIdSet();
|
96
82
|
|
97
83
|
// register protocol target
|
98
84
|
_createTarget(
|
99
85
|
NftIdLib.toNftId(1101),
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
rewardRate: TargetManagerLib.getDefaultRewardRate()}));
|
86
|
+
PROTOCOL(),
|
87
|
+
TargetManagerLib.getDefaultLockingPeriod(),
|
88
|
+
TargetManagerLib.getDefaultRewardRate(),
|
89
|
+
false); // no parameter check
|
105
90
|
}
|
106
91
|
|
107
92
|
|
108
|
-
//---
|
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
|
+
|
109
118
|
|
119
|
+
/// @dev Sets the staking rate for the token.
|
110
120
|
function setStakingRate(
|
111
|
-
|
121
|
+
ChainId chainId,
|
112
122
|
address token,
|
113
123
|
UFixed stakingRate
|
114
124
|
)
|
115
125
|
external
|
116
|
-
restricted()
|
126
|
+
restricted() // staking
|
127
|
+
returns (
|
128
|
+
UFixed oldStakingRate,
|
129
|
+
Blocknumber lastUpdatedIn
|
130
|
+
)
|
117
131
|
{
|
118
|
-
|
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();
|
119
144
|
}
|
120
145
|
|
121
|
-
//--- target
|
146
|
+
//--- target management -------------------------------------------------//
|
122
147
|
|
123
148
|
function createTarget(
|
124
149
|
NftId targetNftId,
|
125
|
-
|
150
|
+
ObjectType objectType,
|
151
|
+
Seconds lockingPeriod,
|
152
|
+
UFixed rewardRate
|
126
153
|
)
|
127
154
|
external
|
128
|
-
restricted()
|
155
|
+
restricted() // staking
|
129
156
|
{
|
130
|
-
_createTarget(targetNftId,
|
157
|
+
_createTarget(targetNftId, objectType, lockingPeriod, rewardRate, true);
|
131
158
|
}
|
132
159
|
|
133
160
|
|
134
|
-
function
|
135
|
-
NftId targetNftId,
|
136
|
-
|
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
|
137
225
|
)
|
138
226
|
external
|
139
227
|
restricted()
|
140
228
|
{
|
141
|
-
|
142
|
-
|
143
|
-
|
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);
|
144
252
|
}
|
145
253
|
|
146
254
|
|
147
|
-
function
|
255
|
+
function refillRewardReserves(
|
148
256
|
NftId targetNftId,
|
149
257
|
Amount dipAmount
|
150
258
|
)
|
@@ -152,14 +260,26 @@ contract StakingStore is
|
|
152
260
|
restricted()
|
153
261
|
returns (Amount newReserveBalance)
|
154
262
|
{
|
155
|
-
|
156
|
-
|
263
|
+
// checks
|
264
|
+
IStaking.TargetInfo storage targetInfo = _getAndVerifyTarget(targetNftId);
|
265
|
+
Blocknumber lastUpdateIn = targetInfo.lastUpdateIn;
|
157
266
|
|
158
|
-
|
267
|
+
// effects
|
268
|
+
targetInfo.reserveAmount = targetInfo.reserveAmount + dipAmount;
|
269
|
+
targetInfo.lastUpdateIn = BlocknumberLib.current();
|
270
|
+
|
271
|
+
// logging
|
272
|
+
newReserveBalance = targetInfo.reserveAmount;
|
273
|
+
emit IStaking.LogStakingRewardReservesRefilled(
|
274
|
+
targetNftId,
|
275
|
+
dipAmount,
|
276
|
+
_registry.ownerOf(targetNftId),
|
277
|
+
newReserveBalance,
|
278
|
+
lastUpdateIn);
|
159
279
|
}
|
160
280
|
|
161
281
|
|
162
|
-
function
|
282
|
+
function withdrawRewardReserves(
|
163
283
|
NftId targetNftId,
|
164
284
|
Amount dipAmount
|
165
285
|
)
|
@@ -167,18 +287,20 @@ contract StakingStore is
|
|
167
287
|
restricted()
|
168
288
|
returns (Amount newReserveBalance)
|
169
289
|
{
|
170
|
-
|
171
|
-
|
172
|
-
revert ErrorStakingStoreRewardReservesInsufficient(
|
173
|
-
targetNftId,
|
174
|
-
dipAmount,
|
175
|
-
reserveAmount);
|
176
|
-
}
|
290
|
+
// checks
|
291
|
+
IStaking.TargetInfo storage targetInfo = _getAndVerifyTarget(targetNftId);
|
177
292
|
|
178
|
-
|
179
|
-
Blocknumber
|
293
|
+
// effects
|
294
|
+
Blocknumber lastUpdateIn = _decreaseReserves(targetNftId, targetInfo, dipAmount);
|
180
295
|
|
181
|
-
|
296
|
+
// logging
|
297
|
+
newReserveBalance = targetInfo.reserveAmount;
|
298
|
+
emit IStaking.LogStakingRewardReservesWithdrawn(
|
299
|
+
targetNftId,
|
300
|
+
dipAmount,
|
301
|
+
_registry.ownerOf(targetNftId),
|
302
|
+
newReserveBalance,
|
303
|
+
lastUpdateIn);
|
182
304
|
}
|
183
305
|
|
184
306
|
|
@@ -186,7 +308,6 @@ contract StakingStore is
|
|
186
308
|
|
187
309
|
function increaseTotalValueLocked(
|
188
310
|
NftId targetNftId,
|
189
|
-
UFixed stakingRate,
|
190
311
|
address token,
|
191
312
|
Amount amount
|
192
313
|
)
|
@@ -194,32 +315,18 @@ contract StakingStore is
|
|
194
315
|
restricted()
|
195
316
|
returns (Amount newBalance)
|
196
317
|
{
|
197
|
-
|
198
|
-
|
199
|
-
Amount oldBalance,
|
200
|
-
Amount oldDipBalance
|
201
|
-
) = _getAndVerifyTvl(targetNftId, token);
|
318
|
+
// checks
|
319
|
+
IStaking.TvlInfo storage tvlInfo = _getAndVerifyTvl(targetNftId, token);
|
202
320
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
_tvlBalance[targetNftId][token] = newBalance;
|
208
|
-
_tvlInDip[targetNftId][token] = newDipBalance;
|
209
|
-
|
210
|
-
// update new amount of required dip
|
211
|
-
_tvlRequiredDip[targetNftId] = _tvlRequiredDip[targetNftId] - oldDipBalance + newDipBalance;
|
212
|
-
|
213
|
-
// update last updated in
|
214
|
-
_tvlLastUpdatedIn[targetNftId] = BlocknumberLib.currentBlocknumber();
|
215
|
-
|
216
|
-
emit LogStakingStoreTotalValueLockedIncreased(targetNftId, token, amount, newBalance, tvlLastUpdatedIn);
|
321
|
+
// effects
|
322
|
+
tvlInfo.tvlAmount = tvlInfo.tvlAmount + amount;
|
323
|
+
tvlInfo.lastUpdateIn = BlocknumberLib.current();
|
324
|
+
newBalance = tvlInfo.tvlAmount;
|
217
325
|
}
|
218
326
|
|
219
327
|
|
220
328
|
function decreaseTotalValueLocked(
|
221
329
|
NftId targetNftId,
|
222
|
-
UFixed stakingRate,
|
223
330
|
address token,
|
224
331
|
Amount amount
|
225
332
|
)
|
@@ -227,389 +334,640 @@ contract StakingStore is
|
|
227
334
|
restricted()
|
228
335
|
returns (Amount newBalance)
|
229
336
|
{
|
230
|
-
|
231
|
-
|
232
|
-
Amount oldBalance,
|
233
|
-
Amount oldDipBalance
|
234
|
-
) = _getAndVerifyTvl(targetNftId, token);
|
235
|
-
|
236
|
-
newBalance = oldBalance - amount;
|
237
|
-
Amount newDipBalance = AmountLib.toAmount((
|
238
|
-
stakingRate * newBalance.toUFixed()).toInt());
|
337
|
+
// checks
|
338
|
+
IStaking.TvlInfo storage tvlInfo = _getAndVerifyTvl(targetNftId, token);
|
239
339
|
|
240
|
-
//
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
// update new amount of required dip
|
245
|
-
_tvlRequiredDip[targetNftId] = _tvlRequiredDip[targetNftId] - oldDipBalance + newDipBalance;
|
246
|
-
|
247
|
-
// update last updated in
|
248
|
-
_tvlLastUpdatedIn[targetNftId] = BlocknumberLib.currentBlocknumber();
|
249
|
-
|
250
|
-
emit LogStakingStoreTotalValueLockedDecreased(targetNftId, token, amount, newBalance, tvlLastUpdatedIn);
|
340
|
+
// effects
|
341
|
+
tvlInfo.tvlAmount = tvlInfo.tvlAmount - amount;
|
342
|
+
tvlInfo.lastUpdateIn = BlocknumberLib.current();
|
343
|
+
newBalance = tvlInfo.tvlAmount;
|
251
344
|
}
|
252
345
|
|
253
346
|
//--- stake specific functions -------------------------------------//
|
254
347
|
|
255
|
-
function
|
348
|
+
function createStake(
|
256
349
|
NftId stakeNftId,
|
257
|
-
|
350
|
+
NftId targetNftId,
|
351
|
+
address stakeOwner,
|
352
|
+
Amount stakeAmount
|
258
353
|
)
|
259
354
|
external
|
260
355
|
restricted()
|
356
|
+
returns (Timestamp lockedUntil)
|
261
357
|
{
|
262
|
-
|
263
|
-
|
264
|
-
|
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);
|
265
376
|
|
266
|
-
|
377
|
+
// process stake amount
|
378
|
+
_stake(stakeNftId, stakeInfo, targetInfo, targetInfo.lockingPeriod, stakeAmount);
|
267
379
|
}
|
268
380
|
|
269
|
-
|
270
|
-
|
271
|
-
|
381
|
+
|
382
|
+
function stake(
|
383
|
+
NftId stakeNftId,
|
384
|
+
bool updateRewards,
|
385
|
+
bool restakeRewards,
|
386
|
+
Seconds additionalLockingPeriod,
|
387
|
+
Amount stakeAmount
|
272
388
|
)
|
273
389
|
external
|
274
390
|
restricted()
|
275
391
|
{
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
KEEP_STATE());
|
280
|
-
}
|
392
|
+
// checks
|
393
|
+
IStaking.StakeInfo storage stakeInfo = _getAndVerifyStake(stakeNftId);
|
394
|
+
IStaking.TargetInfo storage targetInfo = _getAndVerifyTarget(stakeInfo.targetNftId);
|
281
395
|
|
282
|
-
|
396
|
+
if (updateRewards) {
|
397
|
+
_updateRewards(stakeNftId, stakeInfo, targetInfo);
|
398
|
+
}
|
283
399
|
|
400
|
+
if (restakeRewards) {
|
401
|
+
_restakeRewards(stakeNftId, stakeInfo, targetInfo);
|
402
|
+
}
|
284
403
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
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
|
289
413
|
)
|
290
414
|
external
|
291
415
|
restricted()
|
416
|
+
returns (Amount unstakedAmount)
|
292
417
|
{
|
293
|
-
|
418
|
+
// checks
|
419
|
+
IStaking.StakeInfo storage stakeInfo = _getAndVerifyStake(stakeNftId);
|
420
|
+
IStaking.TargetInfo storage targetInfo = _getAndVerifyTarget(stakeInfo.targetNftId);
|
294
421
|
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
_rewardBalance[nftId]); // unchanged reward balance
|
422
|
+
if (updateRewards) {
|
423
|
+
_updateRewards(stakeNftId, stakeInfo, targetInfo);
|
424
|
+
}
|
299
425
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
_rewardBalance[targetNftId]);
|
426
|
+
if (restakeRewards) {
|
427
|
+
_restakeRewards(stakeNftId, stakeInfo, targetInfo);
|
428
|
+
}
|
304
429
|
|
305
|
-
|
430
|
+
return _unstake(stakeNftId, stakeInfo, targetInfo, maxUnstakeAmount);
|
306
431
|
}
|
307
432
|
|
308
433
|
|
309
|
-
function
|
310
|
-
NftId nftId,
|
311
|
-
NftId targetNftId,
|
312
|
-
Amount rewardIncrementAmount
|
313
|
-
)
|
434
|
+
function updateRewards(NftId stakeNftId)
|
314
435
|
external
|
315
436
|
restricted()
|
316
437
|
{
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
// move all rewards to stake balance
|
322
|
-
_updateStakeBalance(
|
323
|
-
nftId,
|
324
|
-
stakeAmount + rewardAmount + rewardIncrementAmount, // new stake balance
|
325
|
-
AmountLib.zero()); // new reward balance
|
326
|
-
|
327
|
-
_updateTargetBalance(
|
328
|
-
targetNftId,
|
329
|
-
_stakeBalance[targetNftId] + rewardAmount + rewardIncrementAmount,
|
330
|
-
_rewardBalance[targetNftId] - rewardAmount);
|
331
|
-
|
332
|
-
emit LogStakingStoreRewardsRestaked(nftId, stakeAmount, rewardAmount, rewardIncrementAmount, _stakeBalance[nftId], lastUpdatedIn);
|
438
|
+
// checks
|
439
|
+
IStaking.StakeInfo storage stakeInfo = _getAndVerifyStake(stakeNftId);
|
440
|
+
IStaking.TargetInfo storage targetInfo = _getAndVerifyTarget(stakeInfo.targetNftId);
|
441
|
+
_updateRewards(stakeNftId, stakeInfo, targetInfo);
|
333
442
|
}
|
334
443
|
|
335
444
|
|
336
|
-
function
|
337
|
-
NftId
|
338
|
-
|
339
|
-
Amount rewardIncrementAmount
|
445
|
+
function restakeRewards(
|
446
|
+
NftId stakeNftId,
|
447
|
+
bool updateRewards
|
340
448
|
)
|
341
449
|
external
|
342
450
|
restricted()
|
343
451
|
{
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
_updateStakeBalance(
|
348
|
-
nftId,
|
349
|
-
_stakeBalance[nftId], // unchanged stake balance
|
350
|
-
_rewardBalance[nftId] + rewardIncrementAmount); // new reward balance
|
452
|
+
// checks
|
453
|
+
IStaking.StakeInfo storage stakeInfo = _getAndVerifyStake(stakeNftId);
|
454
|
+
IStaking.TargetInfo storage targetInfo = _getAndVerifyTarget(stakeInfo.targetNftId);
|
351
455
|
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
_rewardBalance[targetNftId] + rewardIncrementAmount);
|
456
|
+
if (updateRewards) {
|
457
|
+
_updateRewards(stakeNftId, stakeInfo, targetInfo);
|
458
|
+
}
|
356
459
|
|
357
|
-
|
460
|
+
_restakeRewards(stakeNftId, stakeInfo, targetInfo);
|
358
461
|
}
|
359
462
|
|
360
463
|
|
361
|
-
function
|
362
|
-
NftId
|
363
|
-
|
464
|
+
function claimRewards(
|
465
|
+
NftId stakeNftId,
|
466
|
+
bool updateRewards,
|
364
467
|
Amount maxClaimAmount
|
365
468
|
)
|
366
469
|
external
|
367
470
|
restricted()
|
368
471
|
returns (Amount claimedAmount)
|
369
472
|
{
|
370
|
-
|
473
|
+
// checks
|
474
|
+
IStaking.StakeInfo storage stakeInfo = _getAndVerifyStake(stakeNftId);
|
475
|
+
IStaking.TargetInfo storage targetInfo = _getAndVerifyTarget(stakeInfo.targetNftId);
|
371
476
|
|
372
|
-
|
373
|
-
|
477
|
+
if (updateRewards) {
|
478
|
+
_updateRewards(stakeNftId, stakeInfo, targetInfo);
|
479
|
+
}
|
374
480
|
|
375
|
-
|
376
|
-
|
377
|
-
nftId,
|
378
|
-
_stakeBalance[nftId], // unchanged stake balance
|
379
|
-
_rewardBalance[nftId] - claimedAmount); // new reward balance
|
481
|
+
claimedAmount = _claimRewards(stakeNftId, stakeInfo, targetInfo, maxClaimAmount);
|
482
|
+
}
|
380
483
|
|
381
|
-
|
382
|
-
targetNftId,
|
383
|
-
_stakeBalance[targetNftId],
|
384
|
-
_rewardBalance[targetNftId] - claimedAmount);
|
484
|
+
//--- view functions -----------------------------------------------//
|
385
485
|
|
386
|
-
|
486
|
+
function getStakingReader() external view returns (StakingReader stakingReader){
|
487
|
+
return _reader;
|
387
488
|
}
|
388
489
|
|
389
490
|
|
390
|
-
function
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
)
|
491
|
+
function exists(NftId stakeNftId) external view returns (bool) {
|
492
|
+
return _stakeInfo[stakeNftId].lastUpdateIn.gtz();
|
493
|
+
}
|
494
|
+
|
495
|
+
|
496
|
+
function getRequiredStakeBalance(NftId targetNftId)
|
396
497
|
external
|
397
|
-
|
398
|
-
returns (
|
399
|
-
Amount unstakedAmount,
|
400
|
-
Amount claimedAmount
|
401
|
-
)
|
498
|
+
view
|
499
|
+
returns (Amount requiredStakedAmount)
|
402
500
|
{
|
403
|
-
|
501
|
+
address [] memory tokens = _targetToken[targetNftId];
|
502
|
+
if (tokens.length == 0) {
|
503
|
+
return AmountLib.zero();
|
504
|
+
}
|
404
505
|
|
405
|
-
|
406
|
-
|
407
|
-
|
506
|
+
requiredStakedAmount = AmountLib.zero();
|
507
|
+
ChainId targetChainId = _targetInfo[targetNftId].chainId;
|
508
|
+
address token;
|
509
|
+
Amount tvlAmount;
|
510
|
+
UFixed stakingRate;
|
408
511
|
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
_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; }
|
414
516
|
|
415
|
-
|
416
|
-
|
417
|
-
_stakeBalance[targetNftId] - unstakedAmount,
|
418
|
-
_rewardBalance[targetNftId] - claimedAmount);
|
517
|
+
stakingRate = _tokenInfo[targetChainId][token].stakingRate;
|
518
|
+
if (stakingRate.eqz()) { continue; }
|
419
519
|
|
420
|
-
|
421
|
-
|
520
|
+
requiredStakedAmount = requiredStakedAmount + tvlAmount.multiplyWith(stakingRate);
|
521
|
+
}
|
422
522
|
}
|
423
523
|
|
424
|
-
//--- view functions -----------------------------------------------//
|
425
524
|
|
426
|
-
|
427
|
-
|
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();
|
428
528
|
}
|
429
529
|
|
430
|
-
|
431
|
-
|
432
|
-
|
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];
|
534
|
+
}
|
535
|
+
|
536
|
+
|
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;
|
433
540
|
}
|
434
541
|
|
435
|
-
function getStakingRate(uint256 chainId, address token) external view returns (UFixed stakingRate) { return _stakingRate[chainId][token]; }
|
436
542
|
|
437
|
-
|
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
|
+
}
|
438
547
|
|
439
|
-
function getTotalValueLocked(NftId nftId, address token) external view returns (Amount tvlBalanceAmount) { return _tvlBalance[nftId][token]; }
|
440
|
-
function getRequiredStakeBalance(NftId nftId) external view returns (Amount requiredAmount) { return _tvlRequiredDip[nftId]; }
|
441
548
|
|
442
|
-
|
443
|
-
function
|
444
|
-
|
445
|
-
|
446
|
-
function getBalanceUpdatedIn(NftId nftId) external view returns (Blocknumber blocknumber) { return _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];
|
552
|
+
}
|
447
553
|
|
448
554
|
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
returns (
|
453
|
-
Amount stakeBalance,
|
454
|
-
Amount rewardBalance,
|
455
|
-
Amount reserveBalance,
|
456
|
-
Blocknumber lastUpdatedIn
|
457
|
-
)
|
458
|
-
{
|
459
|
-
stakeBalance = _stakeBalance[nftId];
|
460
|
-
rewardBalance = _rewardBalance[nftId];
|
461
|
-
reserveBalance = _reserveBalance[nftId];
|
462
|
-
lastUpdatedIn = _lastUpdatedIn[nftId];
|
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];
|
463
558
|
}
|
464
559
|
|
465
560
|
|
466
|
-
function
|
467
|
-
|
468
|
-
|
561
|
+
function getTargetSet() external view returns (NftIdSet targetNftIdSet) {
|
562
|
+
return _targetNftIdSet;
|
563
|
+
}
|
564
|
+
|
565
|
+
//--- internal functions -----------------------------------------------//
|
566
|
+
|
567
|
+
function _verifyAndUpdateTarget(NftId targetNftId)
|
568
|
+
private
|
469
569
|
returns (
|
470
|
-
|
471
|
-
|
472
|
-
Timestamp lastUpdatedAt
|
570
|
+
IStaking.TargetInfo storage targetInfo,
|
571
|
+
Blocknumber lastUpdatedIn
|
473
572
|
)
|
474
573
|
{
|
475
|
-
|
476
|
-
|
477
|
-
|
574
|
+
// checks
|
575
|
+
targetInfo = _getAndVerifyTarget(targetNftId);
|
576
|
+
lastUpdatedIn = targetInfo.lastUpdateIn;
|
577
|
+
targetInfo.lastUpdateIn = BlocknumberLib.current();
|
478
578
|
}
|
479
579
|
|
480
|
-
//--- private functions -------------------------------------------//
|
481
580
|
|
482
581
|
function _createTarget(
|
483
582
|
NftId targetNftId,
|
484
|
-
|
583
|
+
ObjectType objectType,
|
584
|
+
Seconds lockingPeriod,
|
585
|
+
UFixed rewardRate,
|
586
|
+
bool checkParameters
|
485
587
|
)
|
486
588
|
private
|
487
589
|
{
|
488
|
-
|
489
|
-
|
490
|
-
|
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();
|
491
607
|
|
492
|
-
|
493
|
-
|
494
|
-
|
608
|
+
targetInfo.objectType = objectType;
|
609
|
+
targetInfo.lockingPeriod = lockingPeriod;
|
610
|
+
targetInfo.rewardRate = rewardRate;
|
611
|
+
targetInfo.chainId = ChainIdLib.fromNftId(targetNftId);
|
612
|
+
targetInfo.lastUpdateIn = BlocknumberLib.current();
|
495
613
|
|
614
|
+
// add new target to target set
|
496
615
|
_targetNftIdSet.add(targetNftId);
|
497
616
|
}
|
498
617
|
|
499
|
-
|
618
|
+
|
619
|
+
function _spendRewardReserves(
|
500
620
|
NftId targetNftId,
|
501
|
-
|
621
|
+
IStaking.TargetInfo storage targetInfo,
|
622
|
+
Amount dipAmount
|
502
623
|
)
|
503
624
|
private
|
504
|
-
returns (Blocknumber lastUpdatedIn)
|
505
625
|
{
|
506
|
-
|
507
|
-
revert ErrorStakingStoreNotTarget(targetNftId);
|
508
|
-
}
|
509
|
-
|
510
|
-
lastUpdatedIn = _lastUpdatedIn[targetNftId];
|
626
|
+
Blocknumber lastUpdateIn = _decreaseReserves(targetNftId, targetInfo, dipAmount);
|
511
627
|
|
512
|
-
|
513
|
-
|
628
|
+
// logging
|
629
|
+
emit IStaking.LogStakingRewardReservesSpent(
|
630
|
+
targetNftId,
|
631
|
+
dipAmount,
|
632
|
+
targetInfo.reserveAmount,
|
633
|
+
lastUpdateIn);
|
514
634
|
}
|
515
635
|
|
516
636
|
|
517
|
-
function
|
637
|
+
function _decreaseReserves(
|
638
|
+
NftId targetNftId,
|
639
|
+
IStaking.TargetInfo storage targetInfo,
|
640
|
+
Amount dipAmount
|
641
|
+
)
|
518
642
|
private
|
643
|
+
returns ( Blocknumber lastUpdateIn)
|
644
|
+
{
|
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);
|
653
|
+
}
|
654
|
+
|
655
|
+
// effects
|
656
|
+
targetInfo.reserveAmount = targetInfo.reserveAmount - dipAmount;
|
657
|
+
targetInfo.lastUpdateIn = BlocknumberLib.current();
|
658
|
+
}
|
659
|
+
|
660
|
+
|
661
|
+
function _updateRewards(
|
662
|
+
NftId stakeNftId,
|
663
|
+
IStaking.StakeInfo storage stakeInfo,
|
664
|
+
IStaking.TargetInfo storage targetInfo
|
665
|
+
)
|
666
|
+
internal
|
667
|
+
returns (Amount rewardIncreaseAmount)
|
519
668
|
{
|
520
|
-
if
|
521
|
-
|
669
|
+
// return if reward rate is zero
|
670
|
+
if (targetInfo.rewardRate.eqz()) {
|
671
|
+
return rewardIncreaseAmount;
|
522
672
|
}
|
523
673
|
|
524
|
-
//
|
525
|
-
|
526
|
-
|
527
|
-
_reserveBalance[nftId] = AmountLib.zero();
|
674
|
+
// get seconds since last update on stake
|
675
|
+
Seconds duration = SecondsLib.toSeconds(
|
676
|
+
block.timestamp - stakeInfo.lastUpdateAt.toInt());
|
528
677
|
|
529
|
-
//
|
530
|
-
|
531
|
-
|
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);
|
532
701
|
}
|
533
702
|
|
534
703
|
|
535
|
-
function
|
536
|
-
|
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
|
537
750
|
{
|
538
|
-
if
|
539
|
-
|
751
|
+
// return if reward amount is zero
|
752
|
+
if (stakeAmount.eqz()) {
|
753
|
+
return;
|
754
|
+
}
|
755
|
+
|
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;
|
762
|
+
|
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);
|
540
767
|
}
|
541
768
|
|
542
|
-
|
543
|
-
_stakeBalance[nftId] = AmountLib.zero();
|
544
|
-
_rewardBalance[nftId] = AmountLib.zero();
|
769
|
+
_setLastUpdatesToCurrent(stakeInfo, targetInfo);
|
545
770
|
|
546
|
-
//
|
547
|
-
|
548
|
-
|
771
|
+
// logging
|
772
|
+
emit IStaking.LogStakingStaked(
|
773
|
+
stakeNftId,
|
774
|
+
stakeAmount,
|
775
|
+
stakeInfo.stakedAmount,
|
776
|
+
stakeInfo.rewardAmount,
|
777
|
+
stakeInfo.lockedUntil);
|
549
778
|
}
|
550
779
|
|
551
780
|
|
552
|
-
function
|
781
|
+
function _claimRewards(
|
553
782
|
NftId stakeNftId,
|
554
|
-
|
555
|
-
|
783
|
+
IStaking.StakeInfo storage stakeInfo,
|
784
|
+
IStaking.TargetInfo storage targetInfo,
|
785
|
+
Amount maxClaimAmount
|
556
786
|
)
|
557
|
-
|
787
|
+
internal
|
788
|
+
returns (Amount claimAmount)
|
558
789
|
{
|
559
|
-
|
560
|
-
|
790
|
+
claimAmount = AmountLib.min(maxClaimAmount, stakeInfo.rewardAmount);
|
791
|
+
|
792
|
+
// return if no rewards to claim
|
793
|
+
if (claimAmount.eqz()) {
|
794
|
+
return claimAmount;
|
795
|
+
}
|
561
796
|
|
562
|
-
|
563
|
-
|
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);
|
564
813
|
}
|
565
814
|
|
566
815
|
|
567
|
-
function
|
568
|
-
NftId
|
569
|
-
|
570
|
-
|
816
|
+
function _unstake(
|
817
|
+
NftId stakeNftId,
|
818
|
+
IStaking.StakeInfo storage stakeInfo,
|
819
|
+
IStaking.TargetInfo storage targetInfo,
|
820
|
+
Amount maxUnstakeAmount
|
571
821
|
)
|
572
|
-
|
822
|
+
internal
|
823
|
+
returns (Amount unstakedAmount)
|
824
|
+
{
|
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
|
+
}
|
836
|
+
|
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);
|
849
|
+
}
|
850
|
+
|
851
|
+
|
852
|
+
function _setLastUpdatesToCurrent(
|
853
|
+
IStaking.StakeInfo storage stakeInfo,
|
854
|
+
IStaking.TargetInfo storage targetInfo
|
855
|
+
)
|
856
|
+
internal
|
573
857
|
{
|
574
|
-
|
575
|
-
|
858
|
+
targetInfo.lastUpdateIn = BlocknumberLib.current();
|
859
|
+
_setStakeLastUpdatesToCurrent(stakeInfo);
|
860
|
+
}
|
861
|
+
|
576
862
|
|
577
|
-
|
578
|
-
|
863
|
+
function _setStakeLastUpdatesToCurrent(
|
864
|
+
IStaking.StakeInfo storage stakeInfo
|
865
|
+
)
|
866
|
+
internal
|
867
|
+
{
|
868
|
+
stakeInfo.lastUpdateIn = BlocknumberLib.current();
|
869
|
+
stakeInfo.lastUpdateAt = TimestampLib.current();
|
579
870
|
}
|
580
871
|
|
581
|
-
|
872
|
+
//--- private stake and target functions --------------------------------//
|
873
|
+
|
874
|
+
|
875
|
+
function _getAndVerifyStake(
|
876
|
+
NftId stakeNftId
|
877
|
+
)
|
582
878
|
private
|
583
879
|
view
|
584
|
-
returns (
|
880
|
+
returns (
|
881
|
+
IStaking.StakeInfo storage stakeInfo
|
882
|
+
)
|
585
883
|
{
|
586
|
-
|
884
|
+
stakeInfo = _stakeInfo[stakeNftId];
|
885
|
+
if (stakeInfo.lastUpdateIn.eqz()) {
|
886
|
+
revert ErrorStakingStoreStakeNotInitialized(stakeNftId);
|
887
|
+
}
|
888
|
+
}
|
889
|
+
|
587
890
|
|
588
|
-
|
589
|
-
|
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);
|
590
903
|
}
|
904
|
+
|
905
|
+
// TODO add check for tvl dependent maximum, see #628
|
591
906
|
}
|
592
907
|
|
593
908
|
|
594
|
-
function
|
595
|
-
NftId targetNftId
|
596
|
-
address token
|
909
|
+
function _getAndVerifyTarget(
|
910
|
+
NftId targetNftId
|
597
911
|
)
|
598
912
|
private
|
599
913
|
view
|
600
914
|
returns (
|
601
|
-
|
602
|
-
Amount oldBalance,
|
603
|
-
Amount oldDipBalance
|
915
|
+
IStaking.TargetInfo storage targetInfo
|
604
916
|
)
|
605
917
|
{
|
606
|
-
|
918
|
+
targetInfo = _targetInfo[targetNftId];
|
607
919
|
|
608
|
-
if (
|
609
|
-
revert
|
920
|
+
if (targetInfo.lastUpdateIn.eqz()) {
|
921
|
+
revert ErrorStakingStoreTargetNotInitialized(targetNftId);
|
610
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
|
+
}
|
611
941
|
|
612
|
-
|
613
|
-
|
942
|
+
|
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
|
+
}
|
614
972
|
}
|
615
973
|
}
|