@etherisc/gif-next 0.0.2-e79d227-681 → 0.0.2-e7a5428-226
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +57 -1
- package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.dbg.json +4 -0
- package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.json +1075 -0
- package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.dbg.json +4 -0
- package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.json +790 -0
- package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.dbg.json +4 -0
- package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.json +843 -0
- package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.dbg.json +1 -1
- package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.json +640 -269
- package/artifacts/contracts/authorization/AccessAdminLib.sol/AccessAdminLib.dbg.json +4 -0
- package/artifacts/contracts/authorization/AccessAdminLib.sol/AccessAdminLib.json +1289 -0
- package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.dbg.json +1 -1
- package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.json +202 -5
- package/artifacts/contracts/authorization/Authorization.sol/Authorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/Authorization.sol/Authorization.json +409 -33
- package/artifacts/contracts/authorization/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.dbg.json +1 -1
- package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.json +525 -213
- package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.json +179 -19
- package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.json +246 -16
- package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +1 -1
- package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.json +420 -27
- package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.dbg.json +1 -1
- package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.json +105 -185
- package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.dbg.json +1 -1
- package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.json +381 -46
- package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +58 -127
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +533 -218
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +150 -82
- package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +37 -106
- package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +379 -79
- package/artifacts/contracts/examples/fire/DamageLevel.sol/DamageLevelLib.dbg.json +1 -1
- package/artifacts/contracts/examples/fire/FirePool.sol/FirePool.dbg.json +1 -1
- package/artifacts/contracts/examples/fire/FirePool.sol/FirePool.json +183 -128
- package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.dbg.json +1 -1
- package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.json +355 -52
- package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.dbg.json +1 -1
- package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.json +324 -250
- package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.dbg.json +1 -1
- package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.json +380 -45
- package/artifacts/contracts/examples/fire/FireUSD.sol/FireUSD.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.json +191 -182
- package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.json +805 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.json +94 -100
- package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.json +196 -155
- package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.json +805 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.dbg.json +1 -1
- package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.json +600 -296
- package/artifacts/contracts/examples/unpermissioned/SimpleProductAuthorization.sol/SimpleProductAuthorization.dbg.json +4 -0
- package/artifacts/contracts/examples/unpermissioned/SimpleProductAuthorization.sol/SimpleProductAuthorization.json +805 -0
- package/artifacts/contracts/instance/BundleSet.sol/BundleSet.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleSet.sol/BundleSet.json +88 -45
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +482 -50
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +373 -13
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +493 -85
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +1017 -334
- package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +380 -52
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +914 -554
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +377 -80
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +83 -57
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +690 -566
- package/artifacts/contracts/instance/RiskSet.sol/RiskSet.dbg.json +1 -1
- package/artifacts/contracts/instance/RiskSet.sol/RiskSet.json +141 -85
- package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.json +8 -8
- package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.json +2 -2
- package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.json +2 -2
- package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.json +16 -5
- package/artifacts/contracts/instance/base/ObjectSetHelperLib.sol/ObjectSetHelperLib.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ObjectSetHelperLib.sol/ObjectSetHelperLib.json +168 -0
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/mock/Dip.sol/Dip.dbg.json +1 -1
- package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.json +77 -81
- package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +1 -1
- package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +379 -47
- package/artifacts/contracts/oracle/IOracle.sol/IOracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.json +41 -45
- package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.json +56 -3
- package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +61 -65
- package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +120 -68
- package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +99 -55
- package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +1 -1
- package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +102 -114
- package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +1 -1
- package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +355 -52
- package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleService.sol/BundleService.json +304 -226
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +120 -76
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +200 -89
- package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +59 -63
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +333 -169
- package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/pool/Pool.sol/Pool.json +72 -76
- package/artifacts/contracts/pool/PoolLib.sol/PoolLib.dbg.json +4 -0
- package/artifacts/contracts/pool/PoolLib.sol/PoolLib.json +522 -0
- package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolService.sol/PoolService.json +574 -360
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +146 -74
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +293 -63
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +106 -46
- package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +1 -1
- package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +193 -182
- package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +1 -1
- package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +380 -45
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +292 -195
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +127 -99
- package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.json +235 -4
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +181 -19
- package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +160 -68
- package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
- package/artifacts/contracts/product/IPricingService.sol/IPricingService.json +77 -3
- package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +168 -157
- package/artifacts/contracts/product/IRiskService.sol/IRiskService.dbg.json +1 -1
- package/artifacts/contracts/product/IRiskService.sol/IRiskService.json +258 -22
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +278 -187
- package/artifacts/contracts/product/PolicyServiceLib.sol/PolicyServiceLib.dbg.json +4 -0
- package/artifacts/contracts/product/PolicyServiceLib.sol/PolicyServiceLib.json +783 -0
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +129 -85
- package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
- package/artifacts/contracts/product/PricingService.sol/PricingService.json +135 -126
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +103 -75
- package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/product/Product.sol/Product.json +187 -176
- package/artifacts/contracts/product/RiskService.sol/RiskService.dbg.json +1 -1
- package/artifacts/contracts/product/RiskService.sol/RiskService.json +326 -91
- package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.json +103 -47
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +54 -19
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +56 -3
- package/artifacts/contracts/registry/IRelease.sol/IRelease.dbg.json +4 -0
- package/artifacts/contracts/{authorization/AccessAdmin.sol/IAccessManagedChecker.json → registry/IRelease.sol/IRelease.json} +6 -6
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +92 -57
- package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +727 -479
- package/artifacts/contracts/registry/RegistryAuthorization.sol/RegistryAuthorization.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryAuthorization.sol/RegistryAuthorization.json +1061 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +75 -39
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +79 -43
- package/artifacts/contracts/registry/ReleaseAdmin.sol/ReleaseAdmin.dbg.json +4 -0
- package/artifacts/contracts/registry/ReleaseAdmin.sol/ReleaseAdmin.json +2152 -0
- package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.json +2 -2
- package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.json +386 -64
- package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +1 -1
- package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +437 -26
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +120 -60
- package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/shared/Component.sol/Component.json +60 -50
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +247 -531
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +111 -95
- package/artifacts/contracts/shared/ContractLib.sol/ContractLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ContractLib.sol/ContractLib.json +178 -34
- package/artifacts/contracts/shared/ContractLib.sol/IInstanceAdminHelper.dbg.json +1 -1
- package/artifacts/contracts/shared/ContractLib.sol/ITargetHelper.dbg.json +1 -1
- package/artifacts/contracts/shared/ContractLib.sol/ITokenRegistryHelper.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractLib.sol/ITokenRegistryHelper.json +40 -0
- package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponent.sol/IComponent.json +41 -31
- package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponentService.sol/IComponentService.json +155 -382
- package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +41 -45
- package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.json +6 -6
- package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +19 -0
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +139 -1
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +56 -3
- package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.json +2 -2
- package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.json +60 -64
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.json +6 -6
- package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.dbg.json +1 -1
- package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.json +2 -2
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +21 -2
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +137 -62
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +51 -11
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +63 -162
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandlerBase.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandlerBase.json +118 -29
- package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.json +32 -32
- package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/IStaking.sol/IStaking.json +1026 -101
- package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
- package/artifacts/contracts/staking/IStakingService.sol/IStakingService.json +214 -110
- package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
- package/artifacts/contracts/staking/Staking.sol/Staking.json +1218 -214
- package/artifacts/contracts/staking/StakingLib.sol/StakingLib.dbg.json +4 -0
- package/artifacts/contracts/staking/StakingLib.sol/StakingLib.json +470 -0
- package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.json +2 -2
- package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +139 -61
- package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +174 -217
- package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingService.sol/StakingService.json +253 -174
- package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +87 -55
- package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +957 -603
- package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
- package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +101 -51
- package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
- package/artifacts/contracts/type/Amount.sol/AmountLib.json +11 -11
- package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.json +45 -19
- package/artifacts/contracts/type/ChainId.sol/ChainIdLib.dbg.json +4 -0
- package/artifacts/contracts/type/ChainId.sol/ChainIdLib.json +193 -0
- package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.json +2 -2
- package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.json +2 -2
- package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/type/Fee.sol/FeeLib.json +94 -38
- package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/type/Key32.sol/Key32Lib.json +2 -2
- package/artifacts/contracts/type/Key32Set.sol/LibKey32Set.dbg.json +1 -1
- package/artifacts/contracts/type/Key32Set.sol/LibKey32Set.json +2 -2
- package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/NftId.sol/NftIdLib.json +2 -2
- package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.json +2 -2
- package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.json +33 -31
- package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.json +2 -2
- package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/type/Referral.sol/ReferralLib.json +2 -2
- package/artifacts/contracts/type/RequestId.sol/RequestIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RequestId.sol/RequestIdLib.json +2 -2
- package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RiskId.sol/RiskIdLib.json +30 -6
- package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +42 -157
- package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
- package/artifacts/contracts/type/Seconds.sol/SecondsLib.json +45 -2
- package/artifacts/contracts/type/Selector.sol/SelectorLib.dbg.json +1 -1
- package/artifacts/contracts/type/Selector.sol/SelectorLib.json +21 -2
- package/artifacts/contracts/type/Selector.sol/SelectorSetLib.dbg.json +1 -1
- package/artifacts/contracts/type/Selector.sol/SelectorSetLib.json +2 -2
- package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/String.sol/StrLib.dbg.json +1 -1
- package/artifacts/contracts/type/String.sol/StrLib.json +50 -2
- package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/type/Timestamp.sol/TimestampLib.json +3 -3
- package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/type/UFixed.sol/UFixedLib.json +61 -37
- package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/type/Version.sol/VersionLib.json +2 -21
- package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/type/Version.sol/VersionPartLib.json +101 -2
- package/artifacts/contracts/upgradeability/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/upgradeability/IVersionable.sol/IVersionable.json +10 -0
- package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.json +65 -27
- package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +15 -2
- package/artifacts/contracts/upgradeability/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/upgradeability/Versionable.sol/Versionable.json +10 -0
- package/contracts/accounting/AccountingService.sol +274 -0
- package/contracts/accounting/AccountingServiceManager.sol +38 -0
- package/contracts/accounting/IAccountingService.sol +47 -0
- package/contracts/authorization/AccessAdmin.sol +422 -258
- package/contracts/authorization/AccessAdminLib.sol +396 -0
- package/contracts/authorization/AccessManagerCloneable.sol +146 -4
- package/contracts/authorization/Authorization.sol +142 -262
- package/contracts/authorization/IAccess.sol +25 -7
- package/contracts/authorization/IAccessAdmin.sol +87 -80
- package/contracts/authorization/IAuthorization.sol +9 -43
- package/contracts/authorization/IServiceAuthorization.sol +55 -17
- package/contracts/authorization/ServiceAuthorization.sol +248 -34
- package/contracts/distribution/BasicDistribution.sol +16 -14
- package/contracts/distribution/BasicDistributionAuthorization.sol +29 -9
- package/contracts/distribution/Distribution.sol +38 -75
- package/contracts/distribution/DistributionService.sol +181 -87
- package/contracts/distribution/DistributionServiceManager.sol +1 -1
- package/contracts/distribution/IDistributionComponent.sol +3 -10
- package/contracts/distribution/IDistributionService.sol +34 -19
- package/contracts/examples/fire/FirePool.sol +6 -6
- package/contracts/examples/fire/FirePoolAuthorization.sol +2 -1
- package/contracts/examples/fire/FireProduct.sol +15 -13
- package/contracts/examples/fire/FireProductAuthorization.sol +2 -1
- package/contracts/examples/unpermissioned/SimpleDistribution.sol +34 -11
- package/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol +28 -0
- package/contracts/examples/unpermissioned/SimpleOracle.sol +4 -8
- package/contracts/examples/unpermissioned/SimplePool.sol +7 -13
- package/contracts/examples/unpermissioned/SimplePoolAuthorization.sol +28 -0
- package/contracts/examples/unpermissioned/SimpleProduct.sol +119 -27
- package/contracts/examples/unpermissioned/SimpleProductAuthorization.sol +28 -0
- package/contracts/instance/BundleSet.sol +4 -4
- package/contracts/instance/IInstance.sol +92 -19
- package/contracts/instance/IInstanceService.sol +52 -9
- package/contracts/instance/Instance.sol +163 -57
- package/contracts/instance/InstanceAdmin.sol +271 -166
- package/contracts/instance/InstanceAuthorizationV3.sol +89 -40
- package/contracts/instance/InstanceReader.sol +422 -369
- package/contracts/instance/InstanceService.sol +252 -176
- package/contracts/instance/InstanceServiceManager.sol +1 -1
- package/contracts/instance/InstanceStore.sol +13 -2
- package/contracts/instance/RiskSet.sol +21 -14
- package/contracts/instance/base/BalanceStore.sol +4 -6
- package/contracts/instance/base/ObjectCounter.sol +1 -2
- package/contracts/instance/base/ObjectLifecycle.sol +6 -8
- package/contracts/instance/base/ObjectSet.sol +7 -8
- package/contracts/instance/base/ObjectSetHelperLib.sol +30 -0
- package/contracts/instance/module/IBundle.sol +6 -5
- package/contracts/instance/module/IComponents.sol +19 -7
- package/contracts/instance/module/IDistribution.sol +21 -8
- package/contracts/instance/module/IPolicy.sol +28 -8
- package/contracts/instance/module/IRisk.sol +4 -0
- package/contracts/oracle/BasicOracle.sol +2 -4
- package/contracts/oracle/BasicOracleAuthorization.sol +15 -8
- package/contracts/oracle/IOracle.sol +9 -4
- package/contracts/oracle/Oracle.sol +3 -5
- package/contracts/oracle/OracleService.sol +24 -23
- package/contracts/oracle/OracleServiceManager.sol +1 -1
- package/contracts/pool/BasicPool.sol +3 -16
- package/contracts/pool/BasicPoolAuthorization.sol +29 -16
- package/contracts/pool/BundleService.sol +67 -104
- package/contracts/pool/BundleServiceManager.sol +1 -1
- package/contracts/pool/IBundleService.sol +27 -33
- package/contracts/pool/IPoolService.sol +57 -40
- package/contracts/pool/Pool.sol +13 -25
- package/contracts/pool/PoolLib.sol +341 -0
- package/contracts/pool/PoolService.sol +203 -201
- package/contracts/pool/PoolServiceManager.sol +1 -1
- package/contracts/product/ApplicationService.sol +86 -18
- package/contracts/product/ApplicationServiceManager.sol +1 -1
- package/contracts/product/BasicProduct.sol +3 -3
- package/contracts/product/BasicProductAuthorization.sol +32 -11
- package/contracts/product/ClaimService.sol +187 -171
- package/contracts/product/ClaimServiceManager.sol +1 -1
- package/contracts/product/IApplicationService.sol +24 -2
- package/contracts/product/IClaimService.sol +18 -5
- package/contracts/product/IPolicyService.sol +20 -8
- package/contracts/product/IPricingService.sol +1 -0
- package/contracts/product/IProductComponent.sol +4 -1
- package/contracts/product/IRiskService.sol +25 -10
- package/contracts/product/PolicyService.sol +110 -198
- package/contracts/product/PolicyServiceLib.sol +139 -0
- package/contracts/product/PolicyServiceManager.sol +1 -1
- package/contracts/product/PricingService.sol +52 -46
- package/contracts/product/PricingServiceManager.sol +3 -3
- package/contracts/product/Product.sol +93 -27
- package/contracts/product/RiskService.sol +119 -36
- package/contracts/product/RiskServiceManager.sol +1 -1
- package/contracts/registry/ChainNft.sol +4 -2
- package/contracts/registry/IRegistry.sol +23 -24
- package/contracts/registry/IRelease.sol +29 -0
- package/contracts/registry/Registry.sol +22 -11
- package/contracts/registry/RegistryAdmin.sol +100 -363
- package/contracts/registry/RegistryAuthorization.sol +309 -0
- package/contracts/registry/RegistryService.sol +4 -4
- package/contracts/registry/RegistryServiceManager.sol +1 -1
- package/contracts/registry/ReleaseAdmin.sol +195 -0
- package/contracts/registry/ReleaseLifecycle.sol +2 -0
- package/contracts/registry/ReleaseRegistry.sol +157 -117
- package/contracts/registry/ServiceAuthorizationV3.sol +194 -27
- package/contracts/registry/TokenRegistry.sol +61 -59
- package/contracts/shared/Component.sol +34 -37
- package/contracts/shared/ComponentService.sol +314 -433
- package/contracts/shared/ComponentServiceManager.sol +1 -1
- package/contracts/shared/ContractLib.sol +164 -76
- package/contracts/shared/IComponent.sol +1 -10
- package/contracts/shared/IComponentService.sol +22 -41
- package/contracts/shared/IInstanceLinkedComponent.sol +0 -11
- package/contracts/shared/IKeyValueStore.sol +1 -1
- package/contracts/shared/INftOwnable.sol +2 -0
- package/contracts/shared/IRegisterable.sol +15 -5
- package/contracts/shared/IService.sol +3 -5
- package/contracts/shared/InitializableERC165.sol +9 -1
- package/contracts/shared/InstanceLinkedComponent.sol +7 -18
- package/contracts/shared/KeyValueStore.sol +3 -3
- package/contracts/shared/NftOwnable.sol +8 -6
- package/contracts/shared/PolicyHolder.sol +4 -3
- package/contracts/shared/Registerable.sol +42 -19
- package/contracts/shared/RegistryLinked.sol +1 -1
- package/contracts/shared/Service.sol +13 -30
- package/contracts/shared/TokenHandler.sol +45 -92
- package/contracts/staking/IStaking.sol +155 -64
- package/contracts/staking/IStakingService.sol +45 -75
- package/contracts/staking/Staking.sol +444 -203
- package/contracts/staking/{StakeManagerLib.sol → StakingLib.sol} +55 -84
- package/contracts/staking/StakingManager.sol +1 -2
- package/contracts/staking/StakingReader.sol +41 -80
- package/contracts/staking/StakingService.sol +62 -181
- package/contracts/staking/StakingServiceManager.sol +6 -4
- package/contracts/staking/StakingStore.sol +697 -329
- package/contracts/staking/TargetManagerLib.sol +1 -1
- package/contracts/type/Amount.sol +4 -0
- package/contracts/type/Blocknumber.sol +15 -15
- package/contracts/type/ChainId.sol +101 -0
- package/contracts/type/Fee.sol +8 -8
- package/contracts/type/NftId.sol +3 -3
- package/contracts/type/ObjectType.sol +67 -38
- package/contracts/type/RiskId.sol +9 -3
- package/contracts/type/RoleId.sol +63 -45
- package/contracts/type/Seconds.sol +14 -0
- package/contracts/type/Selector.sol +5 -0
- package/contracts/type/String.sol +12 -0
- package/contracts/type/Timestamp.sol +4 -7
- package/contracts/type/UFixed.sol +35 -127
- package/contracts/type/Version.sol +54 -5
- package/contracts/upgradeability/IVersionable.sol +3 -0
- package/contracts/upgradeability/ProxyManager.sol +26 -12
- package/contracts/upgradeability/UpgradableProxyWithAdmin.sol +12 -2
- package/contracts/upgradeability/Versionable.sol +6 -3
- package/package.json +2 -2
- package/artifacts/contracts/authorization/AccessAdmin.sol/IAccessManagedChecker.dbg.json +0 -4
- package/artifacts/contracts/authorization/ReleaseAccessManager.sol/ReleaseAccessManager.dbg.json +0 -4
- package/artifacts/contracts/authorization/ReleaseAccessManager.sol/ReleaseAccessManager.json +0 -1196
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +0 -4
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +0 -129
- package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +0 -4
- package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.json +0 -474
- package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +0 -4
- package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +0 -440
- package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +0 -4
- package/artifacts/contracts/type/UFixed.sol/MathLib.json +0 -16
- package/contracts/authorization/ReleaseAccessManager.sol +0 -38
- package/contracts/instance/module/IAccess.sol +0 -46
- package/contracts/shared/ComponentVerifyingService.sol +0 -128
@@ -4,29 +4,31 @@ pragma solidity ^0.8.20;
|
|
4
4
|
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
5
|
|
6
6
|
import {IRegistry} from "../registry/IRegistry.sol";
|
7
|
-
import {
|
7
|
+
import {IRelease} from "../registry/IRelease.sol";
|
8
8
|
import {IStaking} from "./IStaking.sol";
|
9
|
+
import {IStakingService} from "./IStakingService.sol";
|
9
10
|
import {IVersionable} from "../upgradeability/IVersionable.sol";
|
10
11
|
|
11
12
|
import {Amount, AmountLib} from "../type/Amount.sol";
|
13
|
+
import {Blocknumber} from "../type/Blocknumber.sol";
|
14
|
+
import {ChainId, ChainIdLib} from "../type/ChainId.sol";
|
12
15
|
import {Component} from "../shared/Component.sol";
|
13
16
|
import {IComponent} from "../shared/IComponent.sol";
|
14
|
-
import {IComponentService} from "../shared/IComponentService.sol";
|
15
17
|
import {NftId} from "../type/NftId.sol";
|
16
|
-
import {ObjectType,
|
17
|
-
import {Seconds} from "../type/Seconds.sol";
|
18
|
-
import {
|
18
|
+
import {ObjectType, PROTOCOL, STAKE, STAKING, TARGET} from "../type/ObjectType.sol";
|
19
|
+
import {Seconds, SecondsLib} from "../type/Seconds.sol";
|
20
|
+
import {Registerable} from "../shared/Registerable.sol";
|
21
|
+
import {StakingLib} from "./StakingLib.sol";
|
19
22
|
import {StakingReader} from "./StakingReader.sol";
|
20
23
|
import {StakingStore} from "./StakingStore.sol";
|
21
|
-
import {TargetManagerLib} from "./TargetManagerLib.sol";
|
22
|
-
import {Timestamp} from "../type/Timestamp.sol";
|
23
24
|
import {TokenHandler} from "../shared/TokenHandler.sol";
|
24
25
|
import {TokenHandlerDeployerLib} from "../shared/TokenHandlerDeployerLib.sol";
|
25
26
|
import {TokenRegistry} from "../registry/TokenRegistry.sol";
|
26
27
|
import {UFixed} from "../type/UFixed.sol";
|
27
|
-
import {Version, VersionLib} from "../type/Version.sol";
|
28
|
+
import {Version, VersionLib, VersionPart, VersionPartLib} from "../type/Version.sol";
|
28
29
|
import {Versionable} from "../upgradeability/Versionable.sol";
|
29
30
|
|
31
|
+
|
30
32
|
contract Staking is
|
31
33
|
Component,
|
32
34
|
Versionable,
|
@@ -38,108 +40,277 @@ contract Staking is
|
|
38
40
|
bytes32 public constant STAKING_LOCATION_V1 = 0xafe8d4462b2ed26a47154f4b8f6d1497d2f772496965791d25bd456e342b7f00;
|
39
41
|
|
40
42
|
struct StakingStorage {
|
41
|
-
IRegistryService _registryService;
|
42
43
|
TokenRegistry _tokenRegistry;
|
43
44
|
TokenHandler _tokenHandler;
|
45
|
+
IStakingService _stakingService;
|
44
46
|
StakingStore _store;
|
45
47
|
StakingReader _reader;
|
46
48
|
NftId _protocolNftId;
|
47
49
|
}
|
48
50
|
|
49
51
|
|
50
|
-
modifier
|
51
|
-
|
52
|
-
revert ErrorStakingNotStake(stakeNftId);
|
53
|
-
}
|
52
|
+
modifier onlyStakeOwner(NftId stakeNftId) {
|
53
|
+
_checkTypeAndOwner(stakeNftId, STAKE(), true);
|
54
54
|
_;
|
55
55
|
}
|
56
56
|
|
57
57
|
|
58
58
|
modifier onlyTarget(NftId targetNftId) {
|
59
|
-
|
60
|
-
revert ErrorStakingNotTarget(targetNftId);
|
61
|
-
}
|
59
|
+
_checkTypeAndOwner(targetNftId, TARGET(), false);
|
62
60
|
_;
|
63
61
|
}
|
64
62
|
|
63
|
+
//--- contract intitialization -------------------------------------------
|
64
|
+
|
65
65
|
function initializeTokenHandler()
|
66
66
|
external
|
67
|
+
virtual
|
67
68
|
{
|
68
69
|
if (msg.sender != address(getRegistry())) {
|
69
70
|
revert ErrorStakingNotRegistry(msg.sender);
|
70
71
|
}
|
71
72
|
|
72
73
|
StakingStorage storage $ = _getStakingStorage();
|
74
|
+
address dipToken = _getStakingStorage()._tokenRegistry.getDipTokenAddress();
|
73
75
|
$._tokenHandler = TokenHandlerDeployerLib.deployTokenHandler(
|
74
76
|
address(getRegistry()),
|
75
77
|
address(this),
|
76
|
-
|
78
|
+
dipToken,
|
77
79
|
getRegistry().getAuthority());
|
78
80
|
}
|
79
81
|
|
80
|
-
|
82
|
+
//--- staking owner functions -------------------------------------------//
|
83
|
+
|
84
|
+
|
85
|
+
/// @inheritdoc IStaking
|
86
|
+
function setProtocolLockingPeriod(Seconds newLockingPeriod)
|
87
|
+
external
|
88
|
+
virtual
|
89
|
+
restricted()
|
90
|
+
onlyOwner()
|
91
|
+
{
|
92
|
+
StakingStorage storage $ = _getStakingStorage();
|
93
|
+
(
|
94
|
+
Seconds oldLockingPeriod,
|
95
|
+
Blocknumber lastUpdatedIn
|
96
|
+
) = $._store.setLockingPeriod($._protocolNftId, newLockingPeriod);
|
97
|
+
|
98
|
+
emit LogStakingProtocolLockingPeriodSet($._protocolNftId, newLockingPeriod, oldLockingPeriod, lastUpdatedIn);
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
/// @inheritdoc IStaking
|
103
|
+
function setProtocolRewardRate(UFixed newRewardRate)
|
104
|
+
external
|
105
|
+
virtual
|
106
|
+
restricted()
|
107
|
+
onlyOwner()
|
108
|
+
{
|
109
|
+
StakingStorage storage $ = _getStakingStorage();
|
110
|
+
(
|
111
|
+
UFixed oldRewardRate,
|
112
|
+
Blocknumber lastUpdatedIn
|
113
|
+
) = $._store.setRewardRate($._protocolNftId, newRewardRate);
|
114
|
+
|
115
|
+
emit LogStakingProtocolRewardRateSet($._protocolNftId, newRewardRate, oldRewardRate, lastUpdatedIn);
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
/// @inheritdoc IStaking
|
120
|
+
function setStakingRate(
|
121
|
+
ChainId chainId,
|
122
|
+
address token,
|
123
|
+
UFixed stakingRate
|
124
|
+
)
|
125
|
+
external
|
126
|
+
virtual
|
127
|
+
restricted()
|
128
|
+
onlyOwner()
|
129
|
+
{
|
130
|
+
(
|
131
|
+
UFixed oldStakingRate,
|
132
|
+
Blocknumber lastUpdateIn
|
133
|
+
) = _getStakingStorage()._store.setStakingRate(chainId, token, stakingRate);
|
134
|
+
|
135
|
+
emit LogStakingStakingRateSet(chainId, token, stakingRate, oldStakingRate, lastUpdateIn);
|
136
|
+
}
|
137
|
+
|
138
|
+
|
139
|
+
/// @inheritdoc IStaking
|
140
|
+
function setStakingService(VersionPart release)
|
141
|
+
external
|
142
|
+
virtual
|
143
|
+
restricted()
|
144
|
+
onlyOwner()
|
145
|
+
{
|
146
|
+
// effects
|
147
|
+
StakingStorage storage $ = _getStakingStorage();
|
148
|
+
address oldStakingService = address($._stakingService);
|
149
|
+
$._stakingService = StakingLib.checkAndGetStakingService(getRegistry(), release);
|
150
|
+
|
151
|
+
emit LogStakingStakingServiceSet(address($._stakingService), release, oldStakingService);
|
152
|
+
}
|
153
|
+
|
154
|
+
|
155
|
+
/// @inheritdoc IStaking
|
81
156
|
function setStakingReader(StakingReader stakingReader)
|
82
157
|
external
|
83
158
|
virtual
|
159
|
+
restricted()
|
84
160
|
onlyOwner()
|
85
161
|
{
|
86
162
|
if(stakingReader.getStaking() != IStaking(this)) {
|
87
163
|
revert ErrorStakingStakingReaderStakingMismatch(address(stakingReader.getStaking()));
|
88
164
|
}
|
89
165
|
|
166
|
+
address oldReader = address(_getStakingStorage()._reader);
|
90
167
|
_getStakingStorage()._reader = stakingReader;
|
168
|
+
|
169
|
+
emit LogStakingStakingReaderSet(address(stakingReader), oldReader);
|
91
170
|
}
|
92
171
|
|
93
172
|
|
94
|
-
|
95
|
-
function
|
173
|
+
/// @inheritdoc IStaking
|
174
|
+
function addToken(
|
175
|
+
ChainId chainId,
|
176
|
+
address token
|
177
|
+
)
|
96
178
|
external
|
97
179
|
virtual
|
180
|
+
restricted()
|
181
|
+
onlyOwner()
|
182
|
+
{
|
183
|
+
_addToken(
|
184
|
+
_getStakingStorage(), chainId, token);
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
/// @inheritdoc IStaking
|
189
|
+
function approveTokenHandler(IERC20Metadata token, Amount amount)
|
190
|
+
public
|
191
|
+
virtual
|
192
|
+
restricted()
|
98
193
|
onlyOwner()
|
99
194
|
{
|
100
195
|
StakingStorage storage $ = _getStakingStorage();
|
101
|
-
|
102
|
-
|
103
|
-
|
196
|
+
Amount oldAllowanceAmount = AmountLib.toAmount(
|
197
|
+
token.allowance(
|
198
|
+
address(this),
|
199
|
+
address($._tokenHandler)));
|
200
|
+
|
201
|
+
// staking token handler approval via its own implementation in staking service
|
202
|
+
$._stakingService.approveTokenHandler(
|
203
|
+
token,
|
204
|
+
amount);
|
205
|
+
|
206
|
+
emit LogStakingTokenHandlerApproved(address(token), amount, oldAllowanceAmount);
|
207
|
+
}
|
208
|
+
|
209
|
+
//--- target management -------------------------------------------------//
|
210
|
+
|
211
|
+
|
212
|
+
/// @inheritdoc IStaking
|
213
|
+
function refillRewardReserves(NftId targetNftId, Amount dipAmount)
|
214
|
+
external
|
215
|
+
virtual
|
216
|
+
restricted()
|
217
|
+
onlyTarget(targetNftId)
|
218
|
+
returns (Amount newBalance)
|
219
|
+
{
|
220
|
+
address transferFrom = msg.sender;
|
221
|
+
_refillRewardReserves(targetNftId, dipAmount, transferFrom);
|
222
|
+
}
|
223
|
+
|
224
|
+
|
225
|
+
/// @inheritdoc IStaking
|
226
|
+
function withdrawRewardReserves(NftId targetNftId, Amount dipAmount)
|
227
|
+
external
|
228
|
+
virtual
|
229
|
+
restricted()
|
230
|
+
onlyTarget(targetNftId)
|
231
|
+
returns (Amount newBalance)
|
232
|
+
{
|
233
|
+
address transferTo;
|
234
|
+
|
235
|
+
// case 1: protocol target: staking owner is recipient
|
236
|
+
if (targetNftId == getRegistry().getProtocolNftId()) {
|
237
|
+
// verify that the caller is the staking owner
|
238
|
+
transferTo = getOwner();
|
239
|
+
if (msg.sender != transferTo) {
|
240
|
+
revert ErrorStakingNotStakingOwner();
|
241
|
+
}
|
242
|
+
|
243
|
+
// case 2: same chain target: target owner is recipient
|
244
|
+
} else if (ChainIdLib.isCurrentChain(targetNftId)) {
|
245
|
+
// verify that the caller is the target owner
|
246
|
+
transferTo = getRegistry().ownerOf(targetNftId);
|
247
|
+
if (msg.sender != transferTo) {
|
248
|
+
revert ErrorStakingNotNftOwner(targetNftId);
|
249
|
+
}
|
250
|
+
|
251
|
+
// case 3: cross-chain target: TODO decide how to handle and implement
|
252
|
+
} else {
|
253
|
+
revert("Cross-chain target not supported");
|
104
254
|
}
|
105
255
|
|
106
|
-
|
107
|
-
|
256
|
+
newBalance = _withdrawRewardReserves(targetNftId, dipAmount, transferTo);
|
257
|
+
}
|
258
|
+
|
108
259
|
|
109
|
-
|
260
|
+
/// @inheritdoc IStaking
|
261
|
+
function refillRewardReservesByService(NftId targetNftId, Amount dipAmount, address transferFrom)
|
262
|
+
external
|
263
|
+
virtual
|
264
|
+
restricted()
|
265
|
+
onlyTarget(targetNftId)
|
266
|
+
returns (Amount newBalance)
|
267
|
+
{
|
268
|
+
_refillRewardReserves(targetNftId, dipAmount, transferFrom);
|
269
|
+
}
|
270
|
+
|
271
|
+
|
272
|
+
/// @inheritdoc IStaking
|
273
|
+
function withdrawRewardReservesByService(NftId targetNftId, Amount dipAmount, address transferTo)
|
274
|
+
external
|
275
|
+
virtual
|
276
|
+
restricted()
|
277
|
+
onlyTarget(targetNftId)
|
278
|
+
returns (Amount newBalance)
|
279
|
+
{
|
280
|
+
// check that service does not withdraw from protocol target
|
281
|
+
if (targetNftId == getRegistry().getProtocolNftId()) {
|
282
|
+
revert ErrorStakingTargetTypeNotSupported(targetNftId, PROTOCOL());
|
283
|
+
}
|
284
|
+
|
285
|
+
// default: on-chain target owner is recipient
|
286
|
+
address targetOwner = getRegistry().ownerOf(targetNftId);
|
287
|
+
return _withdrawRewardReserves(targetNftId, dipAmount, targetOwner);
|
110
288
|
}
|
111
289
|
|
112
|
-
// target management
|
113
290
|
|
291
|
+
/// @inheritdoc IStaking
|
114
292
|
function registerTarget(
|
115
293
|
NftId targetNftId,
|
116
294
|
ObjectType expectedObjectType,
|
117
|
-
uint256 chainId,
|
118
295
|
Seconds initialLockingPeriod,
|
119
296
|
UFixed initialRewardRate
|
120
297
|
)
|
121
298
|
external
|
122
299
|
virtual
|
123
|
-
restricted()
|
300
|
+
restricted() // staking service
|
124
301
|
{
|
125
|
-
|
126
|
-
getRegistry(),
|
127
|
-
_getStakingStorage()._reader,
|
128
|
-
targetNftId,
|
129
|
-
expectedObjectType,
|
130
|
-
initialLockingPeriod,
|
131
|
-
initialRewardRate);
|
132
|
-
|
302
|
+
// checks done by staking store
|
133
303
|
_getStakingStorage()._store.createTarget(
|
134
304
|
targetNftId,
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
305
|
+
expectedObjectType,
|
306
|
+
initialLockingPeriod,
|
307
|
+
initialRewardRate);
|
308
|
+
|
309
|
+
emit LogStakingTargetCreated(targetNftId, expectedObjectType, initialLockingPeriod, initialRewardRate, AmountLib.max());
|
140
310
|
}
|
141
311
|
|
142
312
|
|
313
|
+
/// @inheritdoc IStaking
|
143
314
|
function setLockingPeriod(
|
144
315
|
NftId targetNftId,
|
145
316
|
Seconds lockingPeriod
|
@@ -149,66 +320,56 @@ contract Staking is
|
|
149
320
|
restricted()
|
150
321
|
onlyTarget(targetNftId)
|
151
322
|
{
|
152
|
-
(
|
153
|
-
Seconds oldLockingPeriod,
|
154
|
-
TargetInfo memory targetInfo
|
155
|
-
) = TargetManagerLib.updateLockingPeriod(
|
156
|
-
this,
|
157
|
-
targetNftId,
|
158
|
-
lockingPeriod);
|
159
|
-
|
160
|
-
_getStakingStorage()._store.updateTarget(targetNftId, targetInfo);
|
323
|
+
(Seconds oldLockingPeriod, ) = _getStakingStorage()._store.setLockingPeriod(targetNftId, lockingPeriod);
|
161
324
|
|
162
|
-
emit
|
325
|
+
emit LogStakingTargetLockingPeriodSet(targetNftId, lockingPeriod, oldLockingPeriod);
|
163
326
|
}
|
164
327
|
|
165
|
-
// TODO add function to set protocol reward rate: onlyOwner
|
166
|
-
// get protocol nft id (from where)
|
167
328
|
|
329
|
+
/// @inheritdoc IStaking
|
168
330
|
function setRewardRate(NftId targetNftId, UFixed rewardRate)
|
169
331
|
external
|
170
332
|
virtual
|
171
333
|
restricted()
|
172
334
|
onlyTarget(targetNftId)
|
173
335
|
{
|
174
|
-
(
|
175
|
-
UFixed oldRewardRate,
|
176
|
-
TargetInfo memory targetInfo
|
177
|
-
) = TargetManagerLib.updateRewardRate(
|
178
|
-
this,
|
179
|
-
targetNftId,
|
180
|
-
rewardRate);
|
181
|
-
|
182
|
-
_getStakingStorage()._store.updateTarget(targetNftId, targetInfo);
|
336
|
+
(UFixed oldRewardRate,) = _getStakingStorage()._store.setRewardRate(targetNftId, rewardRate);
|
183
337
|
|
184
|
-
emit
|
338
|
+
emit LogStakingTargetRewardRateSet(targetNftId, rewardRate, oldRewardRate);
|
185
339
|
}
|
186
340
|
|
187
341
|
|
188
|
-
|
342
|
+
/// @inheritdoc IStaking
|
343
|
+
function setMaxStakedAmount(NftId targetNftId, Amount maxStakedAmount)
|
189
344
|
external
|
190
345
|
virtual
|
191
346
|
restricted()
|
192
|
-
|
347
|
+
onlyTarget(targetNftId)
|
193
348
|
{
|
194
|
-
|
195
|
-
|
196
|
-
|
349
|
+
_getStakingStorage()._store.setMaxStakedAmount(targetNftId, maxStakedAmount);
|
350
|
+
|
351
|
+
emit LogStakingTargetMaxStakedAmountSet(targetNftId, maxStakedAmount);
|
197
352
|
}
|
198
353
|
|
199
354
|
|
200
|
-
|
355
|
+
/// @inheritdoc IStaking
|
356
|
+
function addTargetToken(NftId targetNftId, address token)
|
201
357
|
external
|
202
358
|
virtual
|
203
359
|
restricted()
|
204
|
-
|
360
|
+
onlyTarget(targetNftId)
|
205
361
|
{
|
206
|
-
// update book keeping of reward reserves
|
207
362
|
StakingStorage storage $ = _getStakingStorage();
|
208
|
-
|
363
|
+
ChainId chainId = ChainIdLib.fromNftId(targetNftId);
|
364
|
+
_addToken($, chainId, token);
|
365
|
+
|
366
|
+
$._store.addTargetToken(targetNftId, token);
|
367
|
+
|
368
|
+
emit LogStakingTargetTokenAdded(targetNftId, chainId, token);
|
209
369
|
}
|
210
370
|
|
211
371
|
|
372
|
+
/// @inheritdoc IStaking
|
212
373
|
function increaseTotalValueLocked(NftId targetNftId, address token, Amount amount)
|
213
374
|
external
|
214
375
|
virtual
|
@@ -216,12 +377,13 @@ contract Staking is
|
|
216
377
|
returns (Amount newBalance)
|
217
378
|
{
|
218
379
|
StakingStorage storage $ = _getStakingStorage();
|
219
|
-
|
220
|
-
|
221
|
-
|
380
|
+
newBalance = $._store.increaseTotalValueLocked(targetNftId, token, amount);
|
381
|
+
|
382
|
+
emit LogStakingTotalValueLockedIncreased(targetNftId, token, amount, newBalance);
|
222
383
|
}
|
223
384
|
|
224
385
|
|
386
|
+
/// @inheritdoc IStaking
|
225
387
|
function decreaseTotalValueLocked(NftId targetNftId, address token, Amount amount)
|
226
388
|
external
|
227
389
|
virtual
|
@@ -229,12 +391,14 @@ contract Staking is
|
|
229
391
|
returns (Amount newBalance)
|
230
392
|
{
|
231
393
|
StakingStorage storage $ = _getStakingStorage();
|
232
|
-
|
233
|
-
|
234
|
-
|
394
|
+
newBalance = $._store.decreaseTotalValueLocked(targetNftId, token, amount);
|
395
|
+
|
396
|
+
emit LogStakingTotalValueLockedDecreased(targetNftId, token, amount, newBalance);
|
235
397
|
}
|
236
398
|
|
237
399
|
|
400
|
+
// TODO add to interface and implement
|
401
|
+
/// inheritdoc IStaking
|
238
402
|
function registerRemoteTarget(NftId targetNftId, TargetInfo memory targetInfo)
|
239
403
|
external
|
240
404
|
virtual
|
@@ -244,6 +408,8 @@ contract Staking is
|
|
244
408
|
|
245
409
|
}
|
246
410
|
|
411
|
+
// TODO add to interface and implement
|
412
|
+
/// @inheritdoc IStaking
|
247
413
|
function updateRemoteTvl(NftId targetNftId, address token, Amount amount)
|
248
414
|
external
|
249
415
|
virtual
|
@@ -255,55 +421,81 @@ contract Staking is
|
|
255
421
|
|
256
422
|
//--- staking functions -------------------------------------------------//
|
257
423
|
|
424
|
+
/// @inheritdoc IStaking
|
258
425
|
function createStake(
|
259
|
-
NftId stakeNftId,
|
260
426
|
NftId targetNftId,
|
261
|
-
Amount stakeAmount
|
427
|
+
Amount stakeAmount,
|
428
|
+
address stakeOwner
|
262
429
|
)
|
263
430
|
external
|
264
431
|
virtual
|
265
|
-
restricted()
|
432
|
+
restricted()
|
433
|
+
onlyTarget(targetNftId)
|
434
|
+
returns (NftId stakeNftId)
|
266
435
|
{
|
436
|
+
// effects (includes further checks in service)
|
267
437
|
StakingStorage storage $ = _getStakingStorage();
|
268
|
-
|
269
|
-
|
270
|
-
targetNftId,
|
271
|
-
stakeAmount);
|
438
|
+
stakeNftId = $._stakingService.createStakeObject(targetNftId, stakeOwner);
|
439
|
+
$._store.createStake(stakeNftId, targetNftId, stakeOwner, stakeAmount);
|
272
440
|
|
273
|
-
//
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
lockedUntil: lockedUntil}));
|
278
|
-
|
279
|
-
// update target stake balance
|
280
|
-
$._store.increaseStake(
|
281
|
-
stakeNftId,
|
282
|
-
targetNftId,
|
283
|
-
stakeAmount);
|
441
|
+
// interactions
|
442
|
+
if (stakeAmount.gtz()) {
|
443
|
+
$._stakingService.pullDipToken(stakeAmount, stakeOwner);
|
444
|
+
}
|
284
445
|
}
|
285
446
|
|
286
447
|
|
448
|
+
/// @inheritdoc IStaking
|
287
449
|
function stake(
|
288
450
|
NftId stakeNftId,
|
289
451
|
Amount stakeAmount
|
290
452
|
)
|
291
453
|
external
|
292
454
|
virtual
|
293
|
-
restricted()
|
294
|
-
|
295
|
-
returns (Amount
|
455
|
+
restricted()
|
456
|
+
onlyStakeOwner(stakeNftId)
|
457
|
+
returns (Amount newStakeBalance)
|
296
458
|
{
|
297
459
|
StakingStorage storage $ = _getStakingStorage();
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
460
|
+
$._store.stake(
|
461
|
+
stakeNftId,
|
462
|
+
true, // update rewards
|
463
|
+
true, // restake rewards
|
464
|
+
SecondsLib.max(), // max additional locking duration
|
303
465
|
stakeAmount);
|
466
|
+
|
467
|
+
// collect staked DIP token via staking service
|
468
|
+
if (stakeAmount.gtz()) {
|
469
|
+
address stakeOwner = getRegistry().ownerOf(stakeNftId);
|
470
|
+
$._stakingService.pullDipToken(stakeAmount, stakeOwner);
|
471
|
+
}
|
304
472
|
}
|
305
473
|
|
306
474
|
|
475
|
+
/// @inheritdoc IStaking
|
476
|
+
function unstake(NftId stakeNftId)
|
477
|
+
external
|
478
|
+
virtual
|
479
|
+
restricted()
|
480
|
+
onlyStakeOwner(stakeNftId)
|
481
|
+
returns (Amount unstakedAmount)
|
482
|
+
{
|
483
|
+
StakingStorage storage $ = _getStakingStorage();
|
484
|
+
unstakedAmount = $._store.unstake(
|
485
|
+
stakeNftId,
|
486
|
+
true, // update rewards
|
487
|
+
true, // restake rewards
|
488
|
+
AmountLib.max()); // unstake up to this amount
|
489
|
+
|
490
|
+
// transfer unstaked DIP token via staking service
|
491
|
+
if (unstakedAmount.gtz()) {
|
492
|
+
address stakeOwner = getRegistry().ownerOf(stakeNftId);
|
493
|
+
$._stakingService.pushDipToken(unstakedAmount, stakeOwner);
|
494
|
+
}
|
495
|
+
}
|
496
|
+
|
497
|
+
|
498
|
+
/// @inheritdoc IStaking
|
307
499
|
function restake(
|
308
500
|
NftId stakeNftId,
|
309
501
|
NftId newTargetNftId
|
@@ -311,95 +503,79 @@ contract Staking is
|
|
311
503
|
external
|
312
504
|
virtual
|
313
505
|
restricted() // only staking service
|
314
|
-
|
315
|
-
|
506
|
+
onlyStakeOwner(stakeNftId)
|
507
|
+
onlyTarget(newTargetNftId)
|
508
|
+
returns (
|
509
|
+
NftId newStakeNftId,
|
510
|
+
Amount newStakedAmount
|
511
|
+
)
|
316
512
|
{
|
317
|
-
// TODO add check that allows additional staking amount
|
318
513
|
StakingStorage storage $ = _getStakingStorage();
|
319
514
|
|
320
|
-
//
|
515
|
+
// step 1: unstake as much as possible
|
516
|
+
newStakedAmount = $._store.unstake(
|
517
|
+
stakeNftId,
|
518
|
+
true, // update rewards
|
519
|
+
true, // restake rewards
|
520
|
+
AmountLib.max()); // unstake up to this amount
|
521
|
+
|
522
|
+
// step 2: create new stake with full unstaked amount
|
523
|
+
address stakeOwner = getRegistry().ownerOf(stakeNftId);
|
524
|
+
newStakeNftId = $._stakingService.createStakeObject(newTargetNftId, stakeOwner);
|
525
|
+
$._store.createStake(newStakeNftId, newTargetNftId, stakeOwner, newStakedAmount);
|
526
|
+
|
527
|
+
// logging
|
528
|
+
emit LogStakingStakeRestaked(newStakeNftId, newTargetNftId, newStakedAmount, stakeOwner, stakeNftId);
|
321
529
|
}
|
322
530
|
|
323
531
|
|
324
532
|
function updateRewards(NftId stakeNftId)
|
325
533
|
external
|
326
534
|
virtual
|
327
|
-
restricted()
|
328
|
-
|
535
|
+
restricted()
|
536
|
+
onlyStakeOwner(stakeNftId)
|
537
|
+
returns (Amount newRewardAmount)
|
329
538
|
{
|
330
539
|
StakingStorage storage $ = _getStakingStorage();
|
331
|
-
|
540
|
+
$._store.updateRewards(stakeNftId);
|
332
541
|
}
|
333
542
|
|
334
543
|
|
335
544
|
function claimRewards(NftId stakeNftId)
|
336
545
|
external
|
337
546
|
virtual
|
338
|
-
restricted()
|
339
|
-
|
547
|
+
restricted()
|
548
|
+
onlyStakeOwner(stakeNftId)
|
340
549
|
returns (
|
341
|
-
Amount
|
550
|
+
Amount claimedAmount
|
342
551
|
)
|
343
552
|
{
|
344
553
|
StakingStorage storage $ = _getStakingStorage();
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
// unstake all available rewards
|
350
|
-
rewardsClaimedAmount = $._store.claimUpTo(
|
351
|
-
stakeNftId,
|
352
|
-
targetNftId,
|
554
|
+
claimedAmount = $._store.claimRewards(
|
555
|
+
stakeNftId,
|
556
|
+
true,
|
353
557
|
AmountLib.max());
|
354
558
|
|
355
|
-
//
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
external
|
362
|
-
virtual
|
363
|
-
restricted() // only staking service
|
364
|
-
onlyStake(stakeNftId)
|
365
|
-
returns (
|
366
|
-
Amount unstakedAmount,
|
367
|
-
Amount rewardsClaimedAmount
|
368
|
-
)
|
369
|
-
{
|
370
|
-
StakingStorage storage $ = _getStakingStorage();
|
371
|
-
|
372
|
-
StakeManagerLib.checkUnstakeParameters($._reader, stakeNftId);
|
373
|
-
|
374
|
-
// update rewards since last update
|
375
|
-
NftId targetNftId = _updateRewards($._reader, $._store, stakeNftId);
|
376
|
-
|
377
|
-
// unstake all available dips
|
378
|
-
(
|
379
|
-
unstakedAmount,
|
380
|
-
rewardsClaimedAmount
|
381
|
-
) = $._store.unstakeUpTo(
|
382
|
-
stakeNftId,
|
383
|
-
targetNftId,
|
384
|
-
AmountLib.max(), // unstake all stakes
|
385
|
-
AmountLib.max()); // claim all rewards
|
386
|
-
|
387
|
-
// update reward reserves
|
388
|
-
$._store.decreaseReserves(targetNftId, rewardsClaimedAmount);
|
559
|
+
// collect staked DIP token by staking service
|
560
|
+
if (claimedAmount.gtz()) {
|
561
|
+
// interactions
|
562
|
+
address stakeOwner = getRegistry().ownerOf(stakeNftId);
|
563
|
+
$._stakingService.pushDipToken(claimedAmount, stakeOwner);
|
564
|
+
}
|
389
565
|
}
|
390
566
|
|
391
567
|
|
392
568
|
//--- view functions ----------------------------------------------------//
|
393
569
|
|
394
|
-
function getStakingReader() public view returns (StakingReader reader) {
|
570
|
+
function getStakingReader() public virtual view returns (StakingReader reader) {
|
395
571
|
return _getStakingStorage()._reader;
|
396
572
|
}
|
397
573
|
|
398
|
-
function getStakingStore() external view returns (StakingStore stakingStore) {
|
574
|
+
function getStakingStore() external virtual view returns (StakingStore stakingStore) {
|
399
575
|
return _getStakingStorage()._store;
|
400
576
|
}
|
401
577
|
|
402
|
-
function getTokenRegistryAddress() external view returns (address tokenRegistry) {
|
578
|
+
function getTokenRegistryAddress() external virtual view returns (address tokenRegistry) {
|
403
579
|
return address(_getStakingStorage()._tokenRegistry);
|
404
580
|
}
|
405
581
|
|
@@ -407,96 +583,161 @@ contract Staking is
|
|
407
583
|
return _getStakingStorage()._tokenHandler;
|
408
584
|
}
|
409
585
|
|
410
|
-
// from
|
586
|
+
// from IRegisterable
|
587
|
+
function getRelease()
|
588
|
+
public
|
589
|
+
pure
|
590
|
+
virtual override (IRelease, Registerable)
|
591
|
+
returns(VersionPart)
|
592
|
+
{
|
593
|
+
return VersionPartLib.toVersionPart(3);
|
594
|
+
}
|
595
|
+
|
596
|
+
// from IVersionable
|
411
597
|
function getVersion()
|
412
598
|
public
|
413
599
|
pure
|
414
|
-
virtual override (IVersionable, Versionable)
|
600
|
+
virtual override (Component, IVersionable, Versionable)
|
415
601
|
returns(Version)
|
416
602
|
{
|
417
|
-
return VersionLib.toVersion(
|
603
|
+
return VersionLib.toVersion(3,0,0);
|
418
604
|
}
|
419
605
|
|
420
606
|
//--- internal functions ------------------------------------------------//
|
421
607
|
|
422
|
-
|
423
|
-
|
424
|
-
StakingStore store,
|
425
|
-
NftId stakeNftId
|
426
|
-
)
|
608
|
+
|
609
|
+
function _refillRewardReserves(NftId targetNftId, Amount dipAmount, address transferFrom)
|
427
610
|
internal
|
428
611
|
virtual
|
429
|
-
returns (
|
612
|
+
returns (Amount newBalance)
|
430
613
|
{
|
431
|
-
|
614
|
+
// checks + effects
|
615
|
+
StakingStorage storage $ = _getStakingStorage();
|
616
|
+
newBalance = $._store.refillRewardReserves(targetNftId, dipAmount);
|
432
617
|
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
618
|
+
// interactions
|
619
|
+
// collect DIP token from target owner
|
620
|
+
if (dipAmount.gtz()) {
|
621
|
+
$._stakingService.pullDipToken(dipAmount, transferFrom);
|
622
|
+
}
|
623
|
+
}
|
438
624
|
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
625
|
+
|
626
|
+
function _withdrawRewardReserves(NftId targetNftId, Amount dipAmount, address transferTo)
|
627
|
+
internal
|
628
|
+
virtual
|
629
|
+
returns (Amount newBalance)
|
630
|
+
{
|
631
|
+
// checks + effects
|
632
|
+
StakingStorage storage $ = _getStakingStorage();
|
633
|
+
newBalance = $._store.withdrawRewardReserves(targetNftId, dipAmount);
|
634
|
+
|
635
|
+
// interactions
|
636
|
+
// transfer DIP token to designated address
|
637
|
+
if (dipAmount.gtz()) {
|
638
|
+
$._stakingService.pushDipToken(dipAmount, transferTo);
|
639
|
+
}
|
443
640
|
}
|
444
641
|
|
445
642
|
|
446
|
-
function
|
643
|
+
function _addToken(
|
644
|
+
StakingStorage storage $,
|
645
|
+
ChainId chainId,
|
646
|
+
address token
|
647
|
+
)
|
447
648
|
internal
|
448
|
-
virtual
|
649
|
+
virtual
|
449
650
|
{
|
450
|
-
|
451
|
-
|
452
|
-
|
651
|
+
if ($._store.getTokenInfo(chainId, token).lastUpdateIn.eqz()) {
|
652
|
+
$._store.addToken(chainId, token);
|
653
|
+
}
|
453
654
|
}
|
454
655
|
|
455
656
|
|
657
|
+
/// @dev top level initializer (upgradable contract)
|
456
658
|
function _initialize(
|
457
659
|
address owner,
|
458
660
|
bytes memory data
|
459
661
|
)
|
460
662
|
internal
|
461
663
|
virtual override
|
462
|
-
|
664
|
+
onlyInitializing()
|
463
665
|
{
|
464
666
|
(
|
465
667
|
address registryAddress,
|
466
668
|
address tokenRegistryAddress,
|
467
|
-
address stakingStoreAddress
|
468
|
-
|
469
|
-
) = abi.decode(data, (address, address, address, address));
|
669
|
+
address stakingStoreAddress
|
670
|
+
) = abi.decode(data, (address, address, address));
|
470
671
|
|
471
|
-
//
|
672
|
+
// wiring to external contracts
|
472
673
|
IRegistry registry = IRegistry(registryAddress);
|
473
|
-
|
474
|
-
|
475
|
-
|
674
|
+
StakingStorage storage $ = _getStakingStorage();
|
675
|
+
$._protocolNftId = registry.getProtocolNftId();
|
676
|
+
$._store = StakingStore(stakingStoreAddress);
|
677
|
+
$._reader = StakingStore(stakingStoreAddress).getStakingReader();
|
678
|
+
$._tokenRegistry = TokenRegistry(tokenRegistryAddress);
|
679
|
+
// staking service has to be set via setStakingService after deploying the first GIF release
|
476
680
|
|
477
|
-
|
478
|
-
|
479
|
-
|
681
|
+
__Component_init(
|
682
|
+
registry.getAuthority(),
|
683
|
+
address(registry),
|
480
684
|
registry.getNftId(), // parent nft id
|
481
685
|
CONTRACT_NAME,
|
482
|
-
dipTokenAddress,
|
483
686
|
STAKING(),
|
484
687
|
false, // is interceptor
|
485
|
-
|
688
|
+
owner,
|
486
689
|
"", // registry data
|
487
690
|
""); // component data
|
488
691
|
|
489
|
-
//
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
$._reader = StakingStore(stakingStoreAddress).getStakingReader();
|
494
|
-
$._tokenRegistry = TokenRegistry(tokenRegistryAddress);
|
692
|
+
// Protocol target is created in the StakingStore constructor.
|
693
|
+
// This allows setting up the protocol target before the full
|
694
|
+
// staking authorization setup is in place.
|
695
|
+
_checkAndLogProtocolTargetCreation($);
|
495
696
|
|
496
697
|
_registerInterface(type(IStaking).interfaceId);
|
497
698
|
}
|
498
699
|
|
499
700
|
|
701
|
+
function _checkAndLogProtocolTargetCreation(StakingStorage storage $)
|
702
|
+
internal
|
703
|
+
virtual
|
704
|
+
{
|
705
|
+
TargetInfo memory protocolInfo = $._store.getTargetInfo($._protocolNftId);
|
706
|
+
|
707
|
+
if (protocolInfo.lastUpdateIn.eqz()) {
|
708
|
+
revert ErrorStakingTargetNotFound($._protocolNftId);
|
709
|
+
}
|
710
|
+
|
711
|
+
emit LogStakingTargetCreated($._protocolNftId, protocolInfo.objectType, protocolInfo.lockingPeriod, protocolInfo.rewardRate, protocolInfo.maxStakedAmount);
|
712
|
+
}
|
713
|
+
|
714
|
+
|
715
|
+
function _checkTypeAndOwner(NftId nftId, ObjectType expectedObjectType, bool checkOwner)
|
716
|
+
internal
|
717
|
+
view
|
718
|
+
{
|
719
|
+
StakingStorage storage $ = _getStakingStorage();
|
720
|
+
if (expectedObjectType == STAKE()) {
|
721
|
+
if (!$._store.exists(nftId)) {
|
722
|
+
revert ErrorStakingNotStake(nftId);
|
723
|
+
}
|
724
|
+
} else {
|
725
|
+
if (expectedObjectType == TARGET()) {
|
726
|
+
if (!$._store.getTargetSet().exists(nftId)) {
|
727
|
+
revert ErrorStakingNotTarget(nftId);
|
728
|
+
}
|
729
|
+
}
|
730
|
+
}
|
731
|
+
|
732
|
+
if (checkOwner) {
|
733
|
+
address nftOwner = getRegistry().ownerOf(nftId);
|
734
|
+
if (msg.sender != nftOwner) {
|
735
|
+
revert ErrorStakingNotOwner(nftId, nftOwner, msg.sender);
|
736
|
+
}
|
737
|
+
}
|
738
|
+
}
|
739
|
+
|
740
|
+
|
500
741
|
function _getStakingStorage() private pure returns (StakingStorage storage $) {
|
501
742
|
assembly {
|
502
743
|
$.slot := STAKING_LOCATION_V1
|