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