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