From 484818d408b969dd7fcbf4e3dd645a7e67de1c4d Mon Sep 17 00:00:00 2001 From: Neo Sun Date: Wed, 15 May 2024 15:16:28 +1200 Subject: [PATCH 1/3] Add Parameter for all contract settable variable --- contracts/Airdropper.sol | 5 ++++- contracts/ConsumerHost.sol | 6 +++++- contracts/DisputeManager.sol | 5 ++++- contracts/IndexerRegistry.sol | 7 ++++++- contracts/PermissionedExchange.sol | 8 +++++++- contracts/PlanManager.sol | 5 ++++- contracts/PriceOracle.sol | 7 ++++++- contracts/PurchaseOfferMarket.sol | 13 ++++++++++++- contracts/RewardsBooster.sol | 21 +++++++++++++-------- contracts/RewardsDistributor.sol | 7 ++++++- contracts/RewardsPool.sol | 8 +++++++- contracts/SQTRedeem.sol | 5 ++++- contracts/Staking.sol | 12 +++++++++++- contracts/StateChannel.sol | 6 +++++- contracts/interfaces/IParameter.sol | 9 +++++++++ contracts/l2/EraManager.sol | 8 +++++++- publish/ABI/Airdropper.json | 19 +++++++++++++++++++ publish/ABI/ConsumerHost.json | 19 +++++++++++++++++++ publish/ABI/DisputeManager.json | 19 +++++++++++++++++++ publish/ABI/EraManager.json | 19 +++++++++++++++++++ publish/ABI/IndexerRegistry.json | 19 +++++++++++++++++++ publish/ABI/PermissionedExchange.json | 19 +++++++++++++++++++ publish/ABI/PlanManager.json | 19 +++++++++++++++++++ publish/ABI/PriceOracle.json | 19 +++++++++++++++++++ publish/ABI/PurchaseOfferMarket.json | 19 +++++++++++++++++++ publish/ABI/RewardsBooster.json | 19 +++++++++++++++++++ publish/ABI/RewardsDistributor.json | 19 +++++++++++++++++++ publish/ABI/RewardsPool.json | 19 +++++++++++++++++++ publish/ABI/SQTRedeem.json | 19 +++++++++++++++++++ publish/ABI/Staking.json | 19 +++++++++++++++++++ publish/ABI/StateChannel.json | 19 +++++++++++++++++++ 31 files changed, 395 insertions(+), 22 deletions(-) create mode 100644 contracts/interfaces/IParameter.sol diff --git a/contracts/Airdropper.sol b/contracts/Airdropper.sol index ba4709e1..3c45e377 100644 --- a/contracts/Airdropper.sol +++ b/contracts/Airdropper.sol @@ -8,7 +8,9 @@ import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; -contract Airdropper is Initializable, OwnableUpgradeable { +import './interfaces/IParameter.sol'; + +contract Airdropper is Initializable, OwnableUpgradeable, IParameter { using SafeERC20 for IERC20; // -- Data -- @@ -53,6 +55,7 @@ contract Airdropper is Initializable, OwnableUpgradeable { function setSettleDestination(address _settleDestination) external onlyOwner { settleDestination = _settleDestination; + emit Parameter('settleDestination', abi.encodePacked(settleDestination)); } function addController(address controller) external onlyOwner { diff --git a/contracts/ConsumerHost.sol b/contracts/ConsumerHost.sol index cca14f20..b0c137b8 100644 --- a/contracts/ConsumerHost.sol +++ b/contracts/ConsumerHost.sol @@ -15,6 +15,7 @@ import './interfaces/IConsumer.sol'; import './interfaces/IEraManager.sol'; import './interfaces/ISettings.sol'; import './interfaces/IConsumerRegistry.sol'; +import './interfaces/IParameter.sol'; /** * @title Consumer Host Contract @@ -25,7 +26,7 @@ import './interfaces/IConsumerRegistry.sol'; * Other contracts can verify the consumer and safeTransfer SQT. * */ -contract ConsumerHost is Initializable, OwnableUpgradeable, IConsumer, ERC165 { +contract ConsumerHost is Initializable, OwnableUpgradeable, IConsumer, ERC165, IParameter { using SafeERC20 for IERC20; // -- Structs -- @@ -109,6 +110,7 @@ contract ConsumerHost is Initializable, OwnableUpgradeable, IConsumer, ERC165 { __Ownable_init(); settings = _settings; feePerMill = _feePerMill; + emit Parameter('feePerMill', abi.encodePacked(feePerMill)); // Approve Token to State Channel. IERC20 sqt = IERC20(_sqt); @@ -130,6 +132,8 @@ contract ConsumerHost is Initializable, OwnableUpgradeable, IConsumer, ERC165 { function setFeeRate(uint256 _feePerMill) external onlyOwner { require(_feePerMill <= PER_MILL, 'C001'); feePerMill = _feePerMill; + + emit Parameter('feePerMill', abi.encodePacked(feePerMill)); } /** diff --git a/contracts/DisputeManager.sol b/contracts/DisputeManager.sol index cca232b4..5d7616ac 100644 --- a/contracts/DisputeManager.sol +++ b/contracts/DisputeManager.sol @@ -13,8 +13,9 @@ import './interfaces/ISettings.sol'; import './interfaces/IEraManager.sol'; import './interfaces/ISQToken.sol'; import './interfaces/IDisputeManager.sol'; +import './interfaces/IParameter.sol'; -contract DisputeManager is IDisputeManager, Initializable, OwnableUpgradeable { +contract DisputeManager is IDisputeManager, Initializable, OwnableUpgradeable, IParameter { using SafeERC20 for IERC20; enum DisputeType { @@ -65,6 +66,7 @@ contract DisputeManager is IDisputeManager, Initializable, OwnableUpgradeable { settings = _settings; nextDisputeId = 1; minimumDeposit = _minimumDeposit; + emit Parameter('minimumDeposit', abi.encodePacked(minimumDeposit)); } /** @@ -77,6 +79,7 @@ contract DisputeManager is IDisputeManager, Initializable, OwnableUpgradeable { function setMinimumDeposit(uint256 _minimumDeposit) external onlyOwner { minimumDeposit = _minimumDeposit; + emit Parameter('minimumDeposit', abi.encodePacked(minimumDeposit)); } function createDispute( diff --git a/contracts/IndexerRegistry.sol b/contracts/IndexerRegistry.sol index 348636dc..a393c179 100644 --- a/contracts/IndexerRegistry.sol +++ b/contracts/IndexerRegistry.sol @@ -15,6 +15,7 @@ import './Constants.sol'; import './interfaces/IRewardsStaking.sol'; import './interfaces/IStakingManager.sol'; import './utils/MathUtil.sol'; +import './interfaces/IParameter.sol'; /** * @title Indexer Registry Contract @@ -44,7 +45,7 @@ import './utils/MathUtil.sol'; * Indexer must set a appropriate commission rate and stake enough SQT Token when registering. * Indexer need to make sure all the query projects with NOT INDEXING status before unregister. */ -contract IndexerRegistry is Initializable, OwnableUpgradeable { +contract IndexerRegistry is Initializable, OwnableUpgradeable, IParameter { using SafeERC20 for IERC20; using MathUtil for uint256; @@ -113,6 +114,8 @@ contract IndexerRegistry is Initializable, OwnableUpgradeable { settings = _settings; minimumStakingAmount = _minimumStakingAmount; + emit Parameter('minimumStakingAmount', abi.encodePacked(minimumStakingAmount)); + emit Parameter('minimumCommissionRate', abi.encodePacked(uint256(0))); } /** @@ -129,6 +132,7 @@ contract IndexerRegistry is Initializable, OwnableUpgradeable { */ function setminimumStakingAmount(uint256 amount) external onlyOwner { minimumStakingAmount = amount; + emit Parameter('minimumStakingAmount', abi.encodePacked(minimumStakingAmount)); } /** @@ -139,6 +143,7 @@ contract IndexerRegistry is Initializable, OwnableUpgradeable { require(rate <= PER_MILL, 'IR006'); minimumCommissionRate = rate; emit MinimumCommissionRateUpdated(rate); + emit Parameter('minimumCommissionRate', abi.encodePacked(minimumCommissionRate)); } /** diff --git a/contracts/PermissionedExchange.sol b/contracts/PermissionedExchange.sol index ffdaae06..20abf8a4 100644 --- a/contracts/PermissionedExchange.sol +++ b/contracts/PermissionedExchange.sol @@ -10,13 +10,14 @@ import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; import './interfaces/ISettings.sol'; import './interfaces/IEraManager.sol'; +import './interfaces/IParameter.sol'; /** * @title PermissionedExchange Contract * @notice For now PermissionedExchange contract allows traders trade their SQTs on admin sent orders, later on we may allow others to send their orders. Controllers may set the trade quota for trader, and trader cannot trade over the their quota. * It provides a way for indexers to swap their rewards(SQT) to stable token with a fixed exchange rate. */ -contract PermissionedExchange is Initializable, OwnableUpgradeable { +contract PermissionedExchange is Initializable, OwnableUpgradeable, IParameter { using SafeERC20 for IERC20; struct ExchangeOrder { @@ -93,6 +94,9 @@ contract PermissionedExchange is Initializable, OwnableUpgradeable { for (uint256 i; i < _controllers.length; i++) { exchangeController[_controllers[i]] = true; } + + emit Parameter('tradeLimitation', abi.encodePacked(uint256(0))); + emit Parameter('tradeLimitationPerAccount', abi.encodePacked(uint256(0))); } /** @@ -118,6 +122,7 @@ contract PermissionedExchange is Initializable, OwnableUpgradeable { */ function setTradeLimitation(uint256 _limit) external onlyOwner { tradeLimitation = _limit; + emit Parameter('tradeLimitation', abi.encodePacked(tradeLimitation)); } /** @@ -126,6 +131,7 @@ contract PermissionedExchange is Initializable, OwnableUpgradeable { */ function setTradeLimitationPerAccount(uint256 _limit) external onlyOwner { tradeLimitationPerAccount = _limit; + emit Parameter('tradeLimitationPerAccount', abi.encodePacked(tradeLimitationPerAccount)); } /** diff --git a/contracts/PlanManager.sol b/contracts/PlanManager.sol index 123971c6..1e53eeea 100644 --- a/contracts/PlanManager.sol +++ b/contracts/PlanManager.sol @@ -13,6 +13,7 @@ import './interfaces/ISettings.sol'; import './interfaces/IPlanManager.sol'; import './interfaces/IEraManager.sol'; import './interfaces/IPriceOracle.sol'; +import './interfaces/IParameter.sol'; /** * @title Plan Manager Contract @@ -26,7 +27,7 @@ import './interfaces/IPriceOracle.sol'; * PlanTemplate: PlanTemplate is create and maintenance by owner, we provide a set of PlanTemplates * for Indexer to create the Plan. */ -contract PlanManager is Initializable, OwnableUpgradeable, IPlanManager { +contract PlanManager is Initializable, OwnableUpgradeable, IPlanManager, IParameter { /// @dev ### STATES /// @notice ISettings contract which stores SubQuery network contracts address ISettings public settings; @@ -81,6 +82,7 @@ contract PlanManager is Initializable, OwnableUpgradeable, IPlanManager { settings = _settings; limit = 5; nextPlanId = 1; + emit Parameter('limit', abi.encodePacked(limit)); } /** @@ -97,6 +99,7 @@ contract PlanManager is Initializable, OwnableUpgradeable, IPlanManager { */ function setPlanLimit(uint256 _limit) external onlyOwner { limit = _limit; + emit Parameter('limit', abi.encodePacked(limit)); } /** diff --git a/contracts/PriceOracle.sol b/contracts/PriceOracle.sol index 061c6809..0dedf6a4 100644 --- a/contracts/PriceOracle.sol +++ b/contracts/PriceOracle.sol @@ -7,8 +7,9 @@ import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; import './interfaces/IPriceOracle.sol'; +import './interfaces/IParameter.sol'; -contract PriceOracle is IPriceOracle, Initializable, OwnableUpgradeable { +contract PriceOracle is IPriceOracle, Initializable, OwnableUpgradeable, IParameter { ///@notice the price of assetTo in assetFrom mapping(address => mapping(address => uint256)) public prices; @@ -32,6 +33,8 @@ contract PriceOracle is IPriceOracle, Initializable, OwnableUpgradeable { sizeLimit = _sizeLimit; blockLimit = _blockLimit; enlargementFactor = 1e6; + emit Parameter('sizeLimit', abi.encodePacked(sizeLimit)); + emit Parameter('blockLimit', abi.encodePacked(blockLimit)); } event PricePosted(address assetFrom, address assetTo, uint256 previousPrice, uint256 newPrice); @@ -40,6 +43,8 @@ contract PriceOracle is IPriceOracle, Initializable, OwnableUpgradeable { function setLimit(uint256 _sizeLimit, uint256 _blockLimit) public onlyOwner { sizeLimit = _sizeLimit; blockLimit = _blockLimit; + emit Parameter('sizeLimit', abi.encodePacked(sizeLimit)); + emit Parameter('blockLimit', abi.encodePacked(blockLimit)); } ///@notice update the controller account diff --git a/contracts/PurchaseOfferMarket.sol b/contracts/PurchaseOfferMarket.sol index 9000e3cd..5ab95367 100644 --- a/contracts/PurchaseOfferMarket.sol +++ b/contracts/PurchaseOfferMarket.sol @@ -18,6 +18,7 @@ import './interfaces/IEraManager.sol'; import './interfaces/IStakingManager.sol'; import './Constants.sol'; import './utils/MathUtil.sol'; +import './interfaces/IParameter.sol'; /** * @title Purchase Offer Market Contract @@ -42,7 +43,12 @@ import './utils/MathUtil.sol'; * Consumers can cancel their purchase offer after expire date for free, but if cancel the unexpired Purchase Offer * we will charge the penalty fee. */ -contract PurchaseOfferMarket is Initializable, OwnableUpgradeable, IPurchaseOfferMarket { +contract PurchaseOfferMarket is + Initializable, + OwnableUpgradeable, + IPurchaseOfferMarket, + IParameter +{ using SafeERC20 for IERC20; /** @@ -139,6 +145,9 @@ contract PurchaseOfferMarket is Initializable, OwnableUpgradeable, IPurchaseOffe settings = _settings; penaltyRate = _penaltyRate; penaltyDestination = _penaltyDestination; + + emit Parameter('penaltyRate', abi.encodePacked(penaltyRate)); + emit Parameter('penaltyDestination', abi.encodePacked(penaltyDestination)); } /** @@ -156,6 +165,7 @@ contract PurchaseOfferMarket is Initializable, OwnableUpgradeable, IPurchaseOffe function setPenaltyRate(uint256 _penaltyRate) external onlyOwner { require(_penaltyRate < PER_MILL, 'PO001'); penaltyRate = _penaltyRate; + emit Parameter('penaltyRate', abi.encodePacked(penaltyRate)); } /** @@ -164,6 +174,7 @@ contract PurchaseOfferMarket is Initializable, OwnableUpgradeable, IPurchaseOffe */ function setPenaltyDestination(address _penaltyDestination) external onlyOwner { penaltyDestination = _penaltyDestination; + emit Parameter('penaltyDestination', abi.encodePacked(penaltyDestination)); } /** diff --git a/contracts/RewardsBooster.sol b/contracts/RewardsBooster.sol index 35b2b6b9..35a3f37b 100644 --- a/contracts/RewardsBooster.sol +++ b/contracts/RewardsBooster.sol @@ -24,13 +24,14 @@ import './interfaces/IProjectRegistry.sol'; import './utils/FixedMath.sol'; import './utils/MathUtil.sol'; import './utils/StakingUtil.sol'; +import './interfaces/IParameter.sol'; /** * @title Rewards for running * @notice ### Overview * The RewardsRunning using the Cobb-Douglas production function for staking & running */ -contract RewardsBooster is Initializable, OwnableUpgradeable, IRewardsBooster { +contract RewardsBooster is Initializable, OwnableUpgradeable, IRewardsBooster, IParameter { using ERC165CheckerUpgradeable for address; using SafeERC20 for IERC20; using MathUtil for uint256; @@ -120,6 +121,8 @@ contract RewardsBooster is Initializable, OwnableUpgradeable, IRewardsBooster { settings = _settings; issuancePerBlock = _issuancePerBlock; minimumDeploymentBooster = _minimumDeploymentBooster; + emit Parameter('issuancePerBlock', abi.encodePacked(issuancePerBlock)); + emit Parameter('minimumDeploymentBooster', abi.encodePacked(minimumDeploymentBooster)); } /** @@ -137,6 +140,7 @@ contract RewardsBooster is Initializable, OwnableUpgradeable, IRewardsBooster { function setMinimumDeploymentBooster(uint256 _minimumDeploymentBooster) external onlyOwner { minimumDeploymentBooster = _minimumDeploymentBooster; + emit Parameter('minimumDeploymentBooster', abi.encodePacked(minimumDeploymentBooster)); } /** @@ -151,6 +155,7 @@ contract RewardsBooster is Initializable, OwnableUpgradeable, IRewardsBooster { issuancePerBlock = _issuancePerBlock; emit ParameterUpdated('issuancePerBlock', issuancePerBlock); + emit Parameter('issuancePerBlock', abi.encodePacked(issuancePerBlock)); } /** @@ -197,10 +202,7 @@ contract RewardsBooster is Initializable, OwnableUpgradeable, IRewardsBooster { * @param deploymentId deploymentId * @param amount the added amount */ - function removeBoosterDeployment( - bytes32 deploymentId, - uint256 amount - ) external { + function removeBoosterDeployment(bytes32 deploymentId, uint256 amount) external { require(deploymentPools[deploymentId].accountBooster[msg.sender] >= amount, 'RB003'); _removeBoosterDeployment(deploymentId, msg.sender, amount); IERC20(settings.getContractAddress(SQContracts.SQToken)).safeTransfer(msg.sender, amount); @@ -278,21 +280,24 @@ contract RewardsBooster is Initializable, OwnableUpgradeable, IRewardsBooster { ); } - /** * @notice Add booster deployment staking * @param _deploymentId the deployment id * @param _account the booster account * @param _amount the added amount */ - function _addBoosterDeployment(bytes32 _deploymentId, address _account, uint256 _amount) internal { + function _addBoosterDeployment( + bytes32 _deploymentId, + address _account, + uint256 _amount + ) internal { DeploymentPool storage deploymentPool = deploymentPools[_deploymentId]; onDeploymentBoosterUpdate(_deploymentId, _account); deploymentPool.boosterPoint += _amount; deploymentPool.accountBooster[_account] += _amount; deploymentPool.accRewardsPerBooster = accRewardsPerBooster; totalBoosterPoint += _amount; - + emit DeploymentBoosterAdded(_deploymentId, _account, _amount); } diff --git a/contracts/RewardsDistributor.sol b/contracts/RewardsDistributor.sol index a4e4ecbe..d17210ac 100644 --- a/contracts/RewardsDistributor.sol +++ b/contracts/RewardsDistributor.sol @@ -20,6 +20,7 @@ import './interfaces/IStaking.sol'; import './interfaces/IStakingManager.sol'; import './Constants.sol'; import './utils/MathUtil.sol'; +import './interfaces/IParameter.sol'; /** * @title Rewards Distributer Contract @@ -55,7 +56,7 @@ import './utils/MathUtil.sol'; * * Runner's commission is treated as unbond request to Staking Contract, which applies a lock period on it. */ -contract RewardsDistributor is IRewardsDistributor, Initializable, OwnableUpgradeable { +contract RewardsDistributor is IRewardsDistributor, Initializable, OwnableUpgradeable, IParameter { using SafeERC20 for IERC20; using MathUtil for uint256; @@ -123,6 +124,8 @@ contract RewardsDistributor is IRewardsDistributor, Initializable, OwnableUpgrad //Settings settings = _settings; + emit Parameter('maxCommissionFactor', abi.encodePacked(uint256(0))); + emit Parameter('maxRewardFactor', abi.encodePacked(uint256(0))); } function setSettings(ISettings _settings) external onlyOwner { @@ -131,10 +134,12 @@ contract RewardsDistributor is IRewardsDistributor, Initializable, OwnableUpgrad function setMaxCommissionFactor(uint256 _maxCommissionFactor) external onlyOwner { maxCommissionFactor = _maxCommissionFactor; + emit Parameter('maxCommissionFactor', abi.encodePacked(maxCommissionFactor)); } function setMaxRewardFactor(uint256 _maxRewardFactor) external onlyOwner { maxRewardFactor = _maxRewardFactor; + emit Parameter('maxRewardFactor', abi.encodePacked(maxRewardFactor)); } /** diff --git a/contracts/RewardsPool.sol b/contracts/RewardsPool.sol index 925df2a7..8593eeaf 100644 --- a/contracts/RewardsPool.sol +++ b/contracts/RewardsPool.sol @@ -18,13 +18,14 @@ import './interfaces/ISQToken.sol'; import './utils/FixedMath.sol'; import './utils/MathUtil.sol'; import './utils/StakingUtil.sol'; +import './interfaces/IParameter.sol'; /** * @title Rewards Pool Contract * @notice ### Overview * The Rewards Pool using the Cobb-Douglas production function for PAYG and Open Agreement */ -contract RewardsPool is IRewardsPool, Initializable, OwnableUpgradeable { +contract RewardsPool is IRewardsPool, Initializable, OwnableUpgradeable, IParameter { using ERC165CheckerUpgradeable for address; using SafeERC20 for IERC20; using MathUtil for uint256; @@ -94,6 +95,9 @@ contract RewardsPool is IRewardsPool, Initializable, OwnableUpgradeable { alphaNumerator = 1; alphaDenominator = 3; settings = _settings; + + emit Parameter('alphaNumerator', abi.encodePacked(alphaNumerator)); + emit Parameter('alphaDenominator', abi.encodePacked(alphaDenominator)); } /** @@ -115,6 +119,8 @@ contract RewardsPool is IRewardsPool, Initializable, OwnableUpgradeable { alphaDenominator = _alphaDenominator; emit Alpha(alphaNumerator, alphaDenominator); + emit Parameter('alphaNumerator', abi.encodePacked(alphaNumerator)); + emit Parameter('alphaDenominator', abi.encodePacked(alphaDenominator)); } /** diff --git a/contracts/SQTRedeem.sol b/contracts/SQTRedeem.sol index a1cc4565..3e04b83d 100644 --- a/contracts/SQTRedeem.sol +++ b/contracts/SQTRedeem.sol @@ -10,8 +10,9 @@ import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import './interfaces/ISQTGift.sol'; +import './interfaces/IParameter.sol'; -contract SQTRedeem is Initializable, OwnableUpgradeable { +contract SQTRedeem is Initializable, OwnableUpgradeable, IParameter { address public sqtoken; /// @notice redeemable status of the contract @@ -32,6 +33,7 @@ contract SQTRedeem is Initializable, OwnableUpgradeable { __Ownable_init(); sqtoken = _sqtoken; + emit Parameter('redeemable', abi.encodePacked(false)); } function deposit(uint256 amount) public onlyOwner { @@ -44,6 +46,7 @@ contract SQTRedeem is Initializable, OwnableUpgradeable { function setRedeemable(bool _redeemable) external onlyOwner { redeemable = _redeemable; + emit Parameter('redeemable', abi.encodePacked(redeemable)); } function setRedeemableAmount(address nft, uint256 seriesId, uint256 amount) public onlyOwner { diff --git a/contracts/Staking.sol b/contracts/Staking.sol index 39023140..51691f26 100644 --- a/contracts/Staking.sol +++ b/contracts/Staking.sol @@ -16,6 +16,7 @@ import './interfaces/ISQToken.sol'; import './interfaces/IDisputeManager.sol'; import './Constants.sol'; import './utils/MathUtil.sol'; +import './interfaces/IParameter.sol'; /** * @title Staking Contract @@ -66,7 +67,7 @@ import './utils/MathUtil.sol'; * Tokens will transfer to user's account after the lockPeriod when users apply withdraw. * Every widthdraw will cost a fix rate fees(unbondFeeRate), and these fees will be transferred to treasury. */ -contract Staking is IStaking, Initializable, OwnableUpgradeable { +contract Staking is IStaking, Initializable, OwnableUpgradeable, IParameter { using SafeERC20 for IERC20; using MathUtil for uint256; @@ -188,6 +189,11 @@ contract Staking is IStaking, Initializable, OwnableUpgradeable { unbondFeeRate = _unbondFeeRate; lockPeriod = _lockPeriod; settings = _settings; + + emit Parameter('indexerLeverageLimit', abi.encodePacked(indexerLeverageLimit)); + emit Parameter('maxUnbondingRequest', abi.encodePacked(maxUnbondingRequest)); + emit Parameter('unbondFeeRate', abi.encodePacked(unbondFeeRate)); + emit Parameter('lockPeriod', abi.encodePacked(lockPeriod)); } function setSettings(ISettings _settings) external onlyOwner { @@ -196,19 +202,23 @@ contract Staking is IStaking, Initializable, OwnableUpgradeable { function setLockPeriod(uint256 _lockPeriod) external onlyOwner { lockPeriod = _lockPeriod; + emit Parameter('lockPeriod', abi.encodePacked(lockPeriod)); } function setIndexerLeverageLimit(uint256 _runnerLeverageLimit) external onlyOwner { indexerLeverageLimit = _runnerLeverageLimit; + emit Parameter('indexerLeverageLimit', abi.encodePacked(indexerLeverageLimit)); } function setUnbondFeeRateBP(uint256 _unbondFeeRate) external onlyOwner { require(_unbondFeeRate < PER_MILL, 'S001'); unbondFeeRate = _unbondFeeRate; + emit Parameter('unbondFeeRate', abi.encodePacked(unbondFeeRate)); } function setMaxUnbondingRequest(uint256 maxNum) external onlyOwner { maxUnbondingRequest = maxNum; + emit Parameter('maxUnbondingRequest', abi.encodePacked(maxUnbondingRequest)); } /** diff --git a/contracts/StateChannel.sol b/contracts/StateChannel.sol index 9c205e22..ff5a5974 100644 --- a/contracts/StateChannel.sol +++ b/contracts/StateChannel.sol @@ -17,6 +17,7 @@ import './interfaces/IRewardsPool.sol'; import './interfaces/IConsumerRegistry.sol'; import './interfaces/IRewardsBooster.sol'; import './utils/MathUtil.sol'; +import './interfaces/IParameter.sol'; /** * @title State Channel Contract @@ -24,7 +25,7 @@ import './utils/MathUtil.sol'; * The contact for Pay-as-you-go service for Indexer and Consumer. * The consumer is not only a account, but also a contract */ -contract StateChannel is Initializable, OwnableUpgradeable { +contract StateChannel is Initializable, OwnableUpgradeable, IParameter { using ERC165CheckerUpgradeable for address; using SafeERC20 for IERC20; @@ -113,6 +114,8 @@ contract StateChannel is Initializable, OwnableUpgradeable { terminateExpiration = 86400; settings = _settings; + + emit Parameter('terminateExpiration', abi.encodePacked(terminateExpiration)); } /** @@ -129,6 +132,7 @@ contract StateChannel is Initializable, OwnableUpgradeable { */ function setTerminateExpiration(uint256 expiration) external onlyOwner { terminateExpiration = expiration; + emit Parameter('terminateExpiration', abi.encodePacked(terminateExpiration)); } /** diff --git a/contracts/interfaces/IParameter.sol b/contracts/interfaces/IParameter.sol new file mode 100644 index 00000000..fbedbaff --- /dev/null +++ b/contracts/interfaces/IParameter.sol @@ -0,0 +1,9 @@ +// Copyright (C) 2020-2024 SubQuery Pte Ltd authors & contributors +// SPDX-License-Identifier: GPL-3.0-or-later + +pragma solidity ^0.8.15; + +abstract contract IParameter { + /// @notice Emitted when parameter change. + event Parameter(string name, bytes value); +} diff --git a/contracts/l2/EraManager.sol b/contracts/l2/EraManager.sol index 82064e5f..bf732e30 100644 --- a/contracts/l2/EraManager.sol +++ b/contracts/l2/EraManager.sol @@ -8,12 +8,13 @@ import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; import '../interfaces/IEraManager.sol'; import '../interfaces/ISettings.sol'; +import '../interfaces/IParameter.sol'; /** * @title EraManager contract * @notice Produce epochs based on a period to coordinate contracts. Staking and reward distributing are running based on Eras */ -contract EraManager is Initializable, OwnableUpgradeable, IEraManager { +contract EraManager is Initializable, OwnableUpgradeable, IEraManager, IParameter { /// @dev ### STATES /// @notice ISettings contract which stores SubQuery network contracts address ISettings public settings; @@ -51,6 +52,8 @@ contract EraManager is Initializable, OwnableUpgradeable, IEraManager { eraPeriod = _eraPeriod; eraNumber = 1; emit NewEraStart(eraNumber, msg.sender); + emit Parameter('eraPeriod', abi.encodePacked(eraPeriod)); + emit Parameter('maintenance', abi.encodePacked(false)); } /** @@ -63,10 +66,12 @@ contract EraManager is Initializable, OwnableUpgradeable, IEraManager { function enableMaintenance() external onlyOwner { maintenance = true; + emit Parameter('maintenance', abi.encodePacked(true)); } function disableMaintenance() external onlyOwner { maintenance = false; + emit Parameter('maintenance', abi.encodePacked(false)); } /** @@ -119,5 +124,6 @@ contract EraManager is Initializable, OwnableUpgradeable, IEraManager { eraPeriod = newEraPeriod; emit EraPeriodUpdate(eraNumber, eraPeriod); + emit Parameter('eraPeriod', abi.encodePacked(eraPeriod)); } } diff --git a/publish/ABI/Airdropper.json b/publish/ABI/Airdropper.json index c980bb19..bb1ceee5 100644 --- a/publish/ABI/Airdropper.json +++ b/publish/ABI/Airdropper.json @@ -81,6 +81,25 @@ "name": "OwnershipTransferred", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "Parameter", + "type": "event" + }, { "anonymous": false, "inputs": [ diff --git a/publish/ABI/ConsumerHost.json b/publish/ABI/ConsumerHost.json index dbe50471..a7a1dd65 100644 --- a/publish/ABI/ConsumerHost.json +++ b/publish/ABI/ConsumerHost.json @@ -162,6 +162,25 @@ "name": "Paid", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "Parameter", + "type": "event" + }, { "anonymous": false, "inputs": [ diff --git a/publish/ABI/DisputeManager.json b/publish/ABI/DisputeManager.json index c867c7f8..bd1f831a 100644 --- a/publish/ABI/DisputeManager.json +++ b/publish/ABI/DisputeManager.json @@ -93,6 +93,25 @@ "name": "OwnershipTransferred", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "Parameter", + "type": "event" + }, { "inputs": [ { diff --git a/publish/ABI/EraManager.json b/publish/ABI/EraManager.json index fc1ce4ae..5d3b27f1 100644 --- a/publish/ABI/EraManager.json +++ b/publish/ABI/EraManager.json @@ -69,6 +69,25 @@ "name": "OwnershipTransferred", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "Parameter", + "type": "event" + }, { "inputs": [], "name": "disableMaintenance", diff --git a/publish/ABI/IndexerRegistry.json b/publish/ABI/IndexerRegistry.json index 3a491163..b9f99051 100644 --- a/publish/ABI/IndexerRegistry.json +++ b/publish/ABI/IndexerRegistry.json @@ -44,6 +44,25 @@ "name": "OwnershipTransferred", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "Parameter", + "type": "event" + }, { "anonymous": false, "inputs": [ diff --git a/publish/ABI/PermissionedExchange.json b/publish/ABI/PermissionedExchange.json index a26114e4..47d59b7f 100644 --- a/publish/ABI/PermissionedExchange.json +++ b/publish/ABI/PermissionedExchange.json @@ -136,6 +136,25 @@ "name": "OwnershipTransferred", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "Parameter", + "type": "event" + }, { "anonymous": false, "inputs": [ diff --git a/publish/ABI/PlanManager.json b/publish/ABI/PlanManager.json index 1931b41e..c2a4fb1c 100644 --- a/publish/ABI/PlanManager.json +++ b/publish/ABI/PlanManager.json @@ -31,6 +31,25 @@ "name": "OwnershipTransferred", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "Parameter", + "type": "event" + }, { "anonymous": false, "inputs": [ diff --git a/publish/ABI/PriceOracle.json b/publish/ABI/PriceOracle.json index 492755de..44549ad9 100644 --- a/publish/ABI/PriceOracle.json +++ b/publish/ABI/PriceOracle.json @@ -31,6 +31,25 @@ "name": "OwnershipTransferred", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "Parameter", + "type": "event" + }, { "anonymous": false, "inputs": [ diff --git a/publish/ABI/PurchaseOfferMarket.json b/publish/ABI/PurchaseOfferMarket.json index 2e8e4597..44d9f10f 100644 --- a/publish/ABI/PurchaseOfferMarket.json +++ b/publish/ABI/PurchaseOfferMarket.json @@ -56,6 +56,25 @@ "name": "OwnershipTransferred", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "Parameter", + "type": "event" + }, { "anonymous": false, "inputs": [ diff --git a/publish/ABI/RewardsBooster.json b/publish/ABI/RewardsBooster.json index ac29fd78..289785ca 100644 --- a/publish/ABI/RewardsBooster.json +++ b/publish/ABI/RewardsBooster.json @@ -156,6 +156,25 @@ "name": "OwnershipTransferred", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "Parameter", + "type": "event" + }, { "anonymous": false, "inputs": [ diff --git a/publish/ABI/RewardsDistributor.json b/publish/ABI/RewardsDistributor.json index 0d5de298..a4e6472c 100644 --- a/publish/ABI/RewardsDistributor.json +++ b/publish/ABI/RewardsDistributor.json @@ -137,6 +137,25 @@ "name": "OwnershipTransferred", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "Parameter", + "type": "event" + }, { "anonymous": false, "inputs": [ diff --git a/publish/ABI/RewardsPool.json b/publish/ABI/RewardsPool.json index af678500..4509c7c0 100644 --- a/publish/ABI/RewardsPool.json +++ b/publish/ABI/RewardsPool.json @@ -112,6 +112,25 @@ "name": "OwnershipTransferred", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "Parameter", + "type": "event" + }, { "inputs": [], "name": "alphaDenominator", diff --git a/publish/ABI/SQTRedeem.json b/publish/ABI/SQTRedeem.json index 51bf4589..5690b292 100644 --- a/publish/ABI/SQTRedeem.json +++ b/publish/ABI/SQTRedeem.json @@ -31,6 +31,25 @@ "name": "OwnershipTransferred", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "Parameter", + "type": "event" + }, { "anonymous": false, "inputs": [ diff --git a/publish/ABI/Staking.json b/publish/ABI/Staking.json index c6f15b6d..cdd4cd40 100644 --- a/publish/ABI/Staking.json +++ b/publish/ABI/Staking.json @@ -81,6 +81,25 @@ "name": "OwnershipTransferred", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "Parameter", + "type": "event" + }, { "anonymous": false, "inputs": [ diff --git a/publish/ABI/StateChannel.json b/publish/ABI/StateChannel.json index 1a1e82e4..1281b363 100644 --- a/publish/ABI/StateChannel.json +++ b/publish/ABI/StateChannel.json @@ -236,6 +236,25 @@ "name": "OwnershipTransferred", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "value", + "type": "bytes" + } + ], + "name": "Parameter", + "type": "event" + }, { "inputs": [ { From 6dd32e2075c7b0142fec3067ba5bb7c69c8c73b7 Mon Sep 17 00:00:00 2001 From: Neo Sun Date: Thu, 16 May 2024 12:54:51 +1200 Subject: [PATCH 2/3] mv to utils --- contracts/Airdropper.sol | 5 +++-- contracts/ConsumerHost.sol | 4 ++-- contracts/DisputeManager.sol | 4 ++-- contracts/IndexerRegistry.sol | 4 ++-- contracts/PermissionedExchange.sol | 4 ++-- contracts/PlanManager.sol | 4 ++-- contracts/PriceOracle.sol | 4 ++-- contracts/PurchaseOfferMarket.sol | 4 ++-- contracts/RewardsBooster.sol | 4 ++-- contracts/RewardsDistributor.sol | 9 +++++++-- contracts/RewardsPool.sol | 4 ++-- contracts/SQTRedeem.sol | 4 ++-- contracts/Staking.sol | 4 ++-- contracts/StateChannel.sol | 4 ++-- contracts/l2/EraManager.sol | 4 ++-- .../IParameter.sol => utils/ParameterUtil.sol} | 2 +- 16 files changed, 37 insertions(+), 31 deletions(-) rename contracts/{interfaces/IParameter.sol => utils/ParameterUtil.sol} (87%) diff --git a/contracts/Airdropper.sol b/contracts/Airdropper.sol index 3c45e377..9ec92a2b 100644 --- a/contracts/Airdropper.sol +++ b/contracts/Airdropper.sol @@ -8,9 +8,9 @@ import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; -import './interfaces/IParameter.sol'; +import './utils/ParameterUtil.sol'; -contract Airdropper is Initializable, OwnableUpgradeable, IParameter { +contract Airdropper is Initializable, OwnableUpgradeable, ParameterUtil { using SafeERC20 for IERC20; // -- Data -- @@ -51,6 +51,7 @@ contract Airdropper is Initializable, OwnableUpgradeable, IParameter { __Ownable_init(); controllers[msg.sender] = true; settleDestination = _settleDestination; + emit Parameter('settleDestination', abi.encodePacked(settleDestination)); } function setSettleDestination(address _settleDestination) external onlyOwner { diff --git a/contracts/ConsumerHost.sol b/contracts/ConsumerHost.sol index b0c137b8..66b54433 100644 --- a/contracts/ConsumerHost.sol +++ b/contracts/ConsumerHost.sol @@ -15,7 +15,7 @@ import './interfaces/IConsumer.sol'; import './interfaces/IEraManager.sol'; import './interfaces/ISettings.sol'; import './interfaces/IConsumerRegistry.sol'; -import './interfaces/IParameter.sol'; +import './utils/ParameterUtil.sol'; /** * @title Consumer Host Contract @@ -26,7 +26,7 @@ import './interfaces/IParameter.sol'; * Other contracts can verify the consumer and safeTransfer SQT. * */ -contract ConsumerHost is Initializable, OwnableUpgradeable, IConsumer, ERC165, IParameter { +contract ConsumerHost is Initializable, OwnableUpgradeable, IConsumer, ERC165, ParameterUtil { using SafeERC20 for IERC20; // -- Structs -- diff --git a/contracts/DisputeManager.sol b/contracts/DisputeManager.sol index 5d7616ac..dcc7fb02 100644 --- a/contracts/DisputeManager.sol +++ b/contracts/DisputeManager.sol @@ -13,9 +13,9 @@ import './interfaces/ISettings.sol'; import './interfaces/IEraManager.sol'; import './interfaces/ISQToken.sol'; import './interfaces/IDisputeManager.sol'; -import './interfaces/IParameter.sol'; +import './utils/ParameterUtil.sol'; -contract DisputeManager is IDisputeManager, Initializable, OwnableUpgradeable, IParameter { +contract DisputeManager is IDisputeManager, Initializable, OwnableUpgradeable, ParameterUtil { using SafeERC20 for IERC20; enum DisputeType { diff --git a/contracts/IndexerRegistry.sol b/contracts/IndexerRegistry.sol index a393c179..1c54df81 100644 --- a/contracts/IndexerRegistry.sol +++ b/contracts/IndexerRegistry.sol @@ -15,7 +15,7 @@ import './Constants.sol'; import './interfaces/IRewardsStaking.sol'; import './interfaces/IStakingManager.sol'; import './utils/MathUtil.sol'; -import './interfaces/IParameter.sol'; +import './utils/ParameterUtil.sol'; /** * @title Indexer Registry Contract @@ -45,7 +45,7 @@ import './interfaces/IParameter.sol'; * Indexer must set a appropriate commission rate and stake enough SQT Token when registering. * Indexer need to make sure all the query projects with NOT INDEXING status before unregister. */ -contract IndexerRegistry is Initializable, OwnableUpgradeable, IParameter { +contract IndexerRegistry is Initializable, OwnableUpgradeable, ParameterUtil { using SafeERC20 for IERC20; using MathUtil for uint256; diff --git a/contracts/PermissionedExchange.sol b/contracts/PermissionedExchange.sol index 20abf8a4..90a0cd50 100644 --- a/contracts/PermissionedExchange.sol +++ b/contracts/PermissionedExchange.sol @@ -10,14 +10,14 @@ import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; import './interfaces/ISettings.sol'; import './interfaces/IEraManager.sol'; -import './interfaces/IParameter.sol'; +import './utils/ParameterUtil.sol'; /** * @title PermissionedExchange Contract * @notice For now PermissionedExchange contract allows traders trade their SQTs on admin sent orders, later on we may allow others to send their orders. Controllers may set the trade quota for trader, and trader cannot trade over the their quota. * It provides a way for indexers to swap their rewards(SQT) to stable token with a fixed exchange rate. */ -contract PermissionedExchange is Initializable, OwnableUpgradeable, IParameter { +contract PermissionedExchange is Initializable, OwnableUpgradeable, ParameterUtil { using SafeERC20 for IERC20; struct ExchangeOrder { diff --git a/contracts/PlanManager.sol b/contracts/PlanManager.sol index 1e53eeea..b2cb8de4 100644 --- a/contracts/PlanManager.sol +++ b/contracts/PlanManager.sol @@ -13,7 +13,7 @@ import './interfaces/ISettings.sol'; import './interfaces/IPlanManager.sol'; import './interfaces/IEraManager.sol'; import './interfaces/IPriceOracle.sol'; -import './interfaces/IParameter.sol'; +import './utils/ParameterUtil.sol'; /** * @title Plan Manager Contract @@ -27,7 +27,7 @@ import './interfaces/IParameter.sol'; * PlanTemplate: PlanTemplate is create and maintenance by owner, we provide a set of PlanTemplates * for Indexer to create the Plan. */ -contract PlanManager is Initializable, OwnableUpgradeable, IPlanManager, IParameter { +contract PlanManager is Initializable, OwnableUpgradeable, IPlanManager, ParameterUtil { /// @dev ### STATES /// @notice ISettings contract which stores SubQuery network contracts address ISettings public settings; diff --git a/contracts/PriceOracle.sol b/contracts/PriceOracle.sol index 0dedf6a4..4b287b0d 100644 --- a/contracts/PriceOracle.sol +++ b/contracts/PriceOracle.sol @@ -7,9 +7,9 @@ import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; import './interfaces/IPriceOracle.sol'; -import './interfaces/IParameter.sol'; +import './utils/ParameterUtil.sol'; -contract PriceOracle is IPriceOracle, Initializable, OwnableUpgradeable, IParameter { +contract PriceOracle is IPriceOracle, Initializable, OwnableUpgradeable, ParameterUtil { ///@notice the price of assetTo in assetFrom mapping(address => mapping(address => uint256)) public prices; diff --git a/contracts/PurchaseOfferMarket.sol b/contracts/PurchaseOfferMarket.sol index 5ab95367..e5f5378d 100644 --- a/contracts/PurchaseOfferMarket.sol +++ b/contracts/PurchaseOfferMarket.sol @@ -18,7 +18,7 @@ import './interfaces/IEraManager.sol'; import './interfaces/IStakingManager.sol'; import './Constants.sol'; import './utils/MathUtil.sol'; -import './interfaces/IParameter.sol'; +import './utils/ParameterUtil.sol'; /** * @title Purchase Offer Market Contract @@ -47,7 +47,7 @@ contract PurchaseOfferMarket is Initializable, OwnableUpgradeable, IPurchaseOfferMarket, - IParameter + ParameterUtil { using SafeERC20 for IERC20; diff --git a/contracts/RewardsBooster.sol b/contracts/RewardsBooster.sol index 35a3f37b..35275102 100644 --- a/contracts/RewardsBooster.sol +++ b/contracts/RewardsBooster.sol @@ -24,14 +24,14 @@ import './interfaces/IProjectRegistry.sol'; import './utils/FixedMath.sol'; import './utils/MathUtil.sol'; import './utils/StakingUtil.sol'; -import './interfaces/IParameter.sol'; +import './utils/ParameterUtil.sol'; /** * @title Rewards for running * @notice ### Overview * The RewardsRunning using the Cobb-Douglas production function for staking & running */ -contract RewardsBooster is Initializable, OwnableUpgradeable, IRewardsBooster, IParameter { +contract RewardsBooster is Initializable, OwnableUpgradeable, IRewardsBooster, ParameterUtil { using ERC165CheckerUpgradeable for address; using SafeERC20 for IERC20; using MathUtil for uint256; diff --git a/contracts/RewardsDistributor.sol b/contracts/RewardsDistributor.sol index d17210ac..013330bc 100644 --- a/contracts/RewardsDistributor.sol +++ b/contracts/RewardsDistributor.sol @@ -20,7 +20,7 @@ import './interfaces/IStaking.sol'; import './interfaces/IStakingManager.sol'; import './Constants.sol'; import './utils/MathUtil.sol'; -import './interfaces/IParameter.sol'; +import './utils/ParameterUtil.sol'; /** * @title Rewards Distributer Contract @@ -56,7 +56,12 @@ import './interfaces/IParameter.sol'; * * Runner's commission is treated as unbond request to Staking Contract, which applies a lock period on it. */ -contract RewardsDistributor is IRewardsDistributor, Initializable, OwnableUpgradeable, IParameter { +contract RewardsDistributor is + IRewardsDistributor, + Initializable, + OwnableUpgradeable, + ParameterUtil +{ using SafeERC20 for IERC20; using MathUtil for uint256; diff --git a/contracts/RewardsPool.sol b/contracts/RewardsPool.sol index 8593eeaf..165d2901 100644 --- a/contracts/RewardsPool.sol +++ b/contracts/RewardsPool.sol @@ -18,14 +18,14 @@ import './interfaces/ISQToken.sol'; import './utils/FixedMath.sol'; import './utils/MathUtil.sol'; import './utils/StakingUtil.sol'; -import './interfaces/IParameter.sol'; +import './utils/ParameterUtil.sol'; /** * @title Rewards Pool Contract * @notice ### Overview * The Rewards Pool using the Cobb-Douglas production function for PAYG and Open Agreement */ -contract RewardsPool is IRewardsPool, Initializable, OwnableUpgradeable, IParameter { +contract RewardsPool is IRewardsPool, Initializable, OwnableUpgradeable, ParameterUtil { using ERC165CheckerUpgradeable for address; using SafeERC20 for IERC20; using MathUtil for uint256; diff --git a/contracts/SQTRedeem.sol b/contracts/SQTRedeem.sol index 3e04b83d..cc1eef23 100644 --- a/contracts/SQTRedeem.sol +++ b/contracts/SQTRedeem.sol @@ -10,9 +10,9 @@ import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import './interfaces/ISQTGift.sol'; -import './interfaces/IParameter.sol'; +import './utils/ParameterUtil.sol'; -contract SQTRedeem is Initializable, OwnableUpgradeable, IParameter { +contract SQTRedeem is Initializable, OwnableUpgradeable, ParameterUtil { address public sqtoken; /// @notice redeemable status of the contract diff --git a/contracts/Staking.sol b/contracts/Staking.sol index 51691f26..26986bea 100644 --- a/contracts/Staking.sol +++ b/contracts/Staking.sol @@ -16,7 +16,7 @@ import './interfaces/ISQToken.sol'; import './interfaces/IDisputeManager.sol'; import './Constants.sol'; import './utils/MathUtil.sol'; -import './interfaces/IParameter.sol'; +import './utils/ParameterUtil.sol'; /** * @title Staking Contract @@ -67,7 +67,7 @@ import './interfaces/IParameter.sol'; * Tokens will transfer to user's account after the lockPeriod when users apply withdraw. * Every widthdraw will cost a fix rate fees(unbondFeeRate), and these fees will be transferred to treasury. */ -contract Staking is IStaking, Initializable, OwnableUpgradeable, IParameter { +contract Staking is IStaking, Initializable, OwnableUpgradeable, ParameterUtil { using SafeERC20 for IERC20; using MathUtil for uint256; diff --git a/contracts/StateChannel.sol b/contracts/StateChannel.sol index ff5a5974..72c64692 100644 --- a/contracts/StateChannel.sol +++ b/contracts/StateChannel.sol @@ -17,7 +17,7 @@ import './interfaces/IRewardsPool.sol'; import './interfaces/IConsumerRegistry.sol'; import './interfaces/IRewardsBooster.sol'; import './utils/MathUtil.sol'; -import './interfaces/IParameter.sol'; +import './utils/ParameterUtil.sol'; /** * @title State Channel Contract @@ -25,7 +25,7 @@ import './interfaces/IParameter.sol'; * The contact for Pay-as-you-go service for Indexer and Consumer. * The consumer is not only a account, but also a contract */ -contract StateChannel is Initializable, OwnableUpgradeable, IParameter { +contract StateChannel is Initializable, OwnableUpgradeable, ParameterUtil { using ERC165CheckerUpgradeable for address; using SafeERC20 for IERC20; diff --git a/contracts/l2/EraManager.sol b/contracts/l2/EraManager.sol index bf732e30..ce947759 100644 --- a/contracts/l2/EraManager.sol +++ b/contracts/l2/EraManager.sol @@ -8,13 +8,13 @@ import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; import '../interfaces/IEraManager.sol'; import '../interfaces/ISettings.sol'; -import '../interfaces/IParameter.sol'; +import '../utils/ParameterUtil.sol'; /** * @title EraManager contract * @notice Produce epochs based on a period to coordinate contracts. Staking and reward distributing are running based on Eras */ -contract EraManager is Initializable, OwnableUpgradeable, IEraManager, IParameter { +contract EraManager is Initializable, OwnableUpgradeable, IEraManager, ParameterUtil { /// @dev ### STATES /// @notice ISettings contract which stores SubQuery network contracts address ISettings public settings; diff --git a/contracts/interfaces/IParameter.sol b/contracts/utils/ParameterUtil.sol similarity index 87% rename from contracts/interfaces/IParameter.sol rename to contracts/utils/ParameterUtil.sol index fbedbaff..663f9a84 100644 --- a/contracts/interfaces/IParameter.sol +++ b/contracts/utils/ParameterUtil.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.15; -abstract contract IParameter { +abstract contract ParameterUtil { /// @notice Emitted when parameter change. event Parameter(string name, bytes value); } From b859b52281dc92f1a344820fdefd84368621f502 Mon Sep 17 00:00:00 2001 From: Ian He <39037239+ianhe8x@users.noreply.github.com> Date: Thu, 16 May 2024 15:40:37 +1200 Subject: [PATCH 3/3] rename --- contracts/Airdropper.sol | 4 ++-- contracts/ConsumerHost.sol | 4 ++-- contracts/DisputeManager.sol | 4 ++-- contracts/IndexerRegistry.sol | 4 ++-- contracts/PermissionedExchange.sol | 4 ++-- contracts/PlanManager.sol | 4 ++-- contracts/PriceOracle.sol | 4 ++-- contracts/PurchaseOfferMarket.sol | 4 ++-- contracts/RewardsBooster.sol | 4 ++-- contracts/RewardsDistributor.sol | 9 ++------- contracts/RewardsPool.sol | 4 ++-- contracts/SQTRedeem.sol | 4 ++-- contracts/Staking.sol | 4 ++-- contracts/StateChannel.sol | 4 ++-- contracts/l2/EraManager.sol | 4 ++-- contracts/utils/{ParameterUtil.sol => SQParameter.sol} | 2 +- 16 files changed, 31 insertions(+), 36 deletions(-) rename contracts/utils/{ParameterUtil.sol => SQParameter.sol} (87%) diff --git a/contracts/Airdropper.sol b/contracts/Airdropper.sol index 9ec92a2b..afdc2576 100644 --- a/contracts/Airdropper.sol +++ b/contracts/Airdropper.sol @@ -8,9 +8,9 @@ import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; -import './utils/ParameterUtil.sol'; +import './utils/SQParameter.sol'; -contract Airdropper is Initializable, OwnableUpgradeable, ParameterUtil { +contract Airdropper is Initializable, OwnableUpgradeable, SQParameter { using SafeERC20 for IERC20; // -- Data -- diff --git a/contracts/ConsumerHost.sol b/contracts/ConsumerHost.sol index 66b54433..d26ec748 100644 --- a/contracts/ConsumerHost.sol +++ b/contracts/ConsumerHost.sol @@ -15,7 +15,7 @@ import './interfaces/IConsumer.sol'; import './interfaces/IEraManager.sol'; import './interfaces/ISettings.sol'; import './interfaces/IConsumerRegistry.sol'; -import './utils/ParameterUtil.sol'; +import './utils/SQParameter.sol'; /** * @title Consumer Host Contract @@ -26,7 +26,7 @@ import './utils/ParameterUtil.sol'; * Other contracts can verify the consumer and safeTransfer SQT. * */ -contract ConsumerHost is Initializable, OwnableUpgradeable, IConsumer, ERC165, ParameterUtil { +contract ConsumerHost is Initializable, OwnableUpgradeable, IConsumer, ERC165, SQParameter { using SafeERC20 for IERC20; // -- Structs -- diff --git a/contracts/DisputeManager.sol b/contracts/DisputeManager.sol index dcc7fb02..510cec8e 100644 --- a/contracts/DisputeManager.sol +++ b/contracts/DisputeManager.sol @@ -13,9 +13,9 @@ import './interfaces/ISettings.sol'; import './interfaces/IEraManager.sol'; import './interfaces/ISQToken.sol'; import './interfaces/IDisputeManager.sol'; -import './utils/ParameterUtil.sol'; +import './utils/SQParameter.sol'; -contract DisputeManager is IDisputeManager, Initializable, OwnableUpgradeable, ParameterUtil { +contract DisputeManager is IDisputeManager, Initializable, OwnableUpgradeable, SQParameter { using SafeERC20 for IERC20; enum DisputeType { diff --git a/contracts/IndexerRegistry.sol b/contracts/IndexerRegistry.sol index 1c54df81..9dc5eba9 100644 --- a/contracts/IndexerRegistry.sol +++ b/contracts/IndexerRegistry.sol @@ -15,7 +15,7 @@ import './Constants.sol'; import './interfaces/IRewardsStaking.sol'; import './interfaces/IStakingManager.sol'; import './utils/MathUtil.sol'; -import './utils/ParameterUtil.sol'; +import './utils/SQParameter.sol'; /** * @title Indexer Registry Contract @@ -45,7 +45,7 @@ import './utils/ParameterUtil.sol'; * Indexer must set a appropriate commission rate and stake enough SQT Token when registering. * Indexer need to make sure all the query projects with NOT INDEXING status before unregister. */ -contract IndexerRegistry is Initializable, OwnableUpgradeable, ParameterUtil { +contract IndexerRegistry is Initializable, OwnableUpgradeable, SQParameter { using SafeERC20 for IERC20; using MathUtil for uint256; diff --git a/contracts/PermissionedExchange.sol b/contracts/PermissionedExchange.sol index 90a0cd50..4b66a5c1 100644 --- a/contracts/PermissionedExchange.sol +++ b/contracts/PermissionedExchange.sol @@ -10,14 +10,14 @@ import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; import './interfaces/ISettings.sol'; import './interfaces/IEraManager.sol'; -import './utils/ParameterUtil.sol'; +import './utils/SQParameter.sol'; /** * @title PermissionedExchange Contract * @notice For now PermissionedExchange contract allows traders trade their SQTs on admin sent orders, later on we may allow others to send their orders. Controllers may set the trade quota for trader, and trader cannot trade over the their quota. * It provides a way for indexers to swap their rewards(SQT) to stable token with a fixed exchange rate. */ -contract PermissionedExchange is Initializable, OwnableUpgradeable, ParameterUtil { +contract PermissionedExchange is Initializable, OwnableUpgradeable, SQParameter { using SafeERC20 for IERC20; struct ExchangeOrder { diff --git a/contracts/PlanManager.sol b/contracts/PlanManager.sol index b2cb8de4..11cb354f 100644 --- a/contracts/PlanManager.sol +++ b/contracts/PlanManager.sol @@ -13,7 +13,7 @@ import './interfaces/ISettings.sol'; import './interfaces/IPlanManager.sol'; import './interfaces/IEraManager.sol'; import './interfaces/IPriceOracle.sol'; -import './utils/ParameterUtil.sol'; +import './utils/SQParameter.sol'; /** * @title Plan Manager Contract @@ -27,7 +27,7 @@ import './utils/ParameterUtil.sol'; * PlanTemplate: PlanTemplate is create and maintenance by owner, we provide a set of PlanTemplates * for Indexer to create the Plan. */ -contract PlanManager is Initializable, OwnableUpgradeable, IPlanManager, ParameterUtil { +contract PlanManager is Initializable, OwnableUpgradeable, IPlanManager, SQParameter { /// @dev ### STATES /// @notice ISettings contract which stores SubQuery network contracts address ISettings public settings; diff --git a/contracts/PriceOracle.sol b/contracts/PriceOracle.sol index 4b287b0d..3aff56ff 100644 --- a/contracts/PriceOracle.sol +++ b/contracts/PriceOracle.sol @@ -7,9 +7,9 @@ import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; import './interfaces/IPriceOracle.sol'; -import './utils/ParameterUtil.sol'; +import './utils/SQParameter.sol'; -contract PriceOracle is IPriceOracle, Initializable, OwnableUpgradeable, ParameterUtil { +contract PriceOracle is IPriceOracle, Initializable, OwnableUpgradeable, SQParameter { ///@notice the price of assetTo in assetFrom mapping(address => mapping(address => uint256)) public prices; diff --git a/contracts/PurchaseOfferMarket.sol b/contracts/PurchaseOfferMarket.sol index e5f5378d..5a0401fd 100644 --- a/contracts/PurchaseOfferMarket.sol +++ b/contracts/PurchaseOfferMarket.sol @@ -18,7 +18,7 @@ import './interfaces/IEraManager.sol'; import './interfaces/IStakingManager.sol'; import './Constants.sol'; import './utils/MathUtil.sol'; -import './utils/ParameterUtil.sol'; +import './utils/SQParameter.sol'; /** * @title Purchase Offer Market Contract @@ -47,7 +47,7 @@ contract PurchaseOfferMarket is Initializable, OwnableUpgradeable, IPurchaseOfferMarket, - ParameterUtil + SQParameter { using SafeERC20 for IERC20; diff --git a/contracts/RewardsBooster.sol b/contracts/RewardsBooster.sol index 35275102..1ad34742 100644 --- a/contracts/RewardsBooster.sol +++ b/contracts/RewardsBooster.sol @@ -24,14 +24,14 @@ import './interfaces/IProjectRegistry.sol'; import './utils/FixedMath.sol'; import './utils/MathUtil.sol'; import './utils/StakingUtil.sol'; -import './utils/ParameterUtil.sol'; +import './utils/SQParameter.sol'; /** * @title Rewards for running * @notice ### Overview * The RewardsRunning using the Cobb-Douglas production function for staking & running */ -contract RewardsBooster is Initializable, OwnableUpgradeable, IRewardsBooster, ParameterUtil { +contract RewardsBooster is Initializable, OwnableUpgradeable, IRewardsBooster, SQParameter { using ERC165CheckerUpgradeable for address; using SafeERC20 for IERC20; using MathUtil for uint256; diff --git a/contracts/RewardsDistributor.sol b/contracts/RewardsDistributor.sol index 013330bc..74d95702 100644 --- a/contracts/RewardsDistributor.sol +++ b/contracts/RewardsDistributor.sol @@ -20,7 +20,7 @@ import './interfaces/IStaking.sol'; import './interfaces/IStakingManager.sol'; import './Constants.sol'; import './utils/MathUtil.sol'; -import './utils/ParameterUtil.sol'; +import './utils/SQParameter.sol'; /** * @title Rewards Distributer Contract @@ -56,12 +56,7 @@ import './utils/ParameterUtil.sol'; * * Runner's commission is treated as unbond request to Staking Contract, which applies a lock period on it. */ -contract RewardsDistributor is - IRewardsDistributor, - Initializable, - OwnableUpgradeable, - ParameterUtil -{ +contract RewardsDistributor is IRewardsDistributor, Initializable, OwnableUpgradeable, SQParameter { using SafeERC20 for IERC20; using MathUtil for uint256; diff --git a/contracts/RewardsPool.sol b/contracts/RewardsPool.sol index 165d2901..3c571442 100644 --- a/contracts/RewardsPool.sol +++ b/contracts/RewardsPool.sol @@ -18,14 +18,14 @@ import './interfaces/ISQToken.sol'; import './utils/FixedMath.sol'; import './utils/MathUtil.sol'; import './utils/StakingUtil.sol'; -import './utils/ParameterUtil.sol'; +import './utils/SQParameter.sol'; /** * @title Rewards Pool Contract * @notice ### Overview * The Rewards Pool using the Cobb-Douglas production function for PAYG and Open Agreement */ -contract RewardsPool is IRewardsPool, Initializable, OwnableUpgradeable, ParameterUtil { +contract RewardsPool is IRewardsPool, Initializable, OwnableUpgradeable, SQParameter { using ERC165CheckerUpgradeable for address; using SafeERC20 for IERC20; using MathUtil for uint256; diff --git a/contracts/SQTRedeem.sol b/contracts/SQTRedeem.sol index cc1eef23..a490b4ec 100644 --- a/contracts/SQTRedeem.sol +++ b/contracts/SQTRedeem.sol @@ -10,9 +10,9 @@ import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import './interfaces/ISQTGift.sol'; -import './utils/ParameterUtil.sol'; +import './utils/SQParameter.sol'; -contract SQTRedeem is Initializable, OwnableUpgradeable, ParameterUtil { +contract SQTRedeem is Initializable, OwnableUpgradeable, SQParameter { address public sqtoken; /// @notice redeemable status of the contract diff --git a/contracts/Staking.sol b/contracts/Staking.sol index 26986bea..cff86a94 100644 --- a/contracts/Staking.sol +++ b/contracts/Staking.sol @@ -16,7 +16,7 @@ import './interfaces/ISQToken.sol'; import './interfaces/IDisputeManager.sol'; import './Constants.sol'; import './utils/MathUtil.sol'; -import './utils/ParameterUtil.sol'; +import './utils/SQParameter.sol'; /** * @title Staking Contract @@ -67,7 +67,7 @@ import './utils/ParameterUtil.sol'; * Tokens will transfer to user's account after the lockPeriod when users apply withdraw. * Every widthdraw will cost a fix rate fees(unbondFeeRate), and these fees will be transferred to treasury. */ -contract Staking is IStaking, Initializable, OwnableUpgradeable, ParameterUtil { +contract Staking is IStaking, Initializable, OwnableUpgradeable, SQParameter { using SafeERC20 for IERC20; using MathUtil for uint256; diff --git a/contracts/StateChannel.sol b/contracts/StateChannel.sol index 72c64692..597ba14d 100644 --- a/contracts/StateChannel.sol +++ b/contracts/StateChannel.sol @@ -17,7 +17,7 @@ import './interfaces/IRewardsPool.sol'; import './interfaces/IConsumerRegistry.sol'; import './interfaces/IRewardsBooster.sol'; import './utils/MathUtil.sol'; -import './utils/ParameterUtil.sol'; +import './utils/SQParameter.sol'; /** * @title State Channel Contract @@ -25,7 +25,7 @@ import './utils/ParameterUtil.sol'; * The contact for Pay-as-you-go service for Indexer and Consumer. * The consumer is not only a account, but also a contract */ -contract StateChannel is Initializable, OwnableUpgradeable, ParameterUtil { +contract StateChannel is Initializable, OwnableUpgradeable, SQParameter { using ERC165CheckerUpgradeable for address; using SafeERC20 for IERC20; diff --git a/contracts/l2/EraManager.sol b/contracts/l2/EraManager.sol index ce947759..5dd42528 100644 --- a/contracts/l2/EraManager.sol +++ b/contracts/l2/EraManager.sol @@ -8,13 +8,13 @@ import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; import '../interfaces/IEraManager.sol'; import '../interfaces/ISettings.sol'; -import '../utils/ParameterUtil.sol'; +import '../utils/SQParameter.sol'; /** * @title EraManager contract * @notice Produce epochs based on a period to coordinate contracts. Staking and reward distributing are running based on Eras */ -contract EraManager is Initializable, OwnableUpgradeable, IEraManager, ParameterUtil { +contract EraManager is Initializable, OwnableUpgradeable, IEraManager, SQParameter { /// @dev ### STATES /// @notice ISettings contract which stores SubQuery network contracts address ISettings public settings; diff --git a/contracts/utils/ParameterUtil.sol b/contracts/utils/SQParameter.sol similarity index 87% rename from contracts/utils/ParameterUtil.sol rename to contracts/utils/SQParameter.sol index 663f9a84..14ac32ff 100644 --- a/contracts/utils/ParameterUtil.sol +++ b/contracts/utils/SQParameter.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.15; -abstract contract ParameterUtil { +abstract contract SQParameter { /// @notice Emitted when parameter change. event Parameter(string name, bytes value); }