From cd6833bfd5c69a37186e53c25615b59fe40aa160 Mon Sep 17 00:00:00 2001 From: SamAg19 Date: Wed, 11 Sep 2024 13:00:22 +0530 Subject: [PATCH] chore: lint fixes --- contracts/Core/BlockManager.sol | 17 +++------- contracts/Core/CollectionManager.sol | 32 ++++-------------- contracts/Core/RewardManager.sol | 6 +--- contracts/Core/StakeManager.sol | 33 +++---------------- contracts/Core/StateManager.sol | 6 +--- contracts/Core/VoteManager.sol | 12 ++----- .../Core/interface/ICollectionManager.sol | 18 ++-------- contracts/Core/interface/IStakeManager.sol | 28 +++------------- contracts/Core/interface/IVoteManager.sol | 12 ++----- contracts/Core/parameters/Governance.sol | 6 +--- .../parameters/child/BlockManagerParams.sol | 4 +-- .../parameters/child/RewardManagerParams.sol | 2 +- .../parameters/child/StakeManagerParams.sol | 10 ++---- .../parameters/child/VoteManagerParams.sol | 2 +- .../interfaces/IStakeManagerParams.sol | 6 +--- contracts/Delegator.sol | 12 +------ contracts/IDelegator.sol | 9 +---- contracts/tokenization/IStakedToken.sol | 6 +--- contracts/tokenization/StakedToken.sol | 12 ++----- 19 files changed, 41 insertions(+), 192 deletions(-) diff --git a/contracts/Core/BlockManager.sol b/contracts/Core/BlockManager.sol index 37c9bb72..72af118e 100644 --- a/contracts/Core/BlockManager.sol +++ b/contracts/Core/BlockManager.sol @@ -511,12 +511,7 @@ contract BlockManager is Initializable, BlockStorage, StateManager, BlockManager * @param biggestStake biggest Stake that was revealed * @return isAdded : whether the block was added to the array */ - function _insertAppropriately( - uint32 epoch, - uint32 blockId, - uint256 iteration, - uint256 biggestStake - ) internal returns (bool isAdded) { + function _insertAppropriately(uint32 epoch, uint32 blockId, uint256 iteration, uint256 biggestStake) internal returns (bool isAdded) { uint8 sortedProposedBlockslength = uint8(sortedProposedBlockIds[epoch].length); if (sortedProposedBlockslength == 0) { @@ -570,11 +565,7 @@ contract BlockManager is Initializable, BlockStorage, StateManager, BlockManager * @param blockIndex index of the block that is disputed * @param blockId id of the block being disputed */ - function _executeDispute( - uint32 epoch, - uint8 blockIndex, - uint32 blockId - ) internal { + function _executeDispute(uint32 epoch, uint8 blockIndex, uint32 blockId) internal { proposedBlocks[epoch][blockId].valid = false; uint8 sortedProposedBlocksLength = uint8(sortedProposedBlockIds[epoch].length); @@ -627,12 +618,12 @@ contract BlockManager is Initializable, BlockStorage, StateManager, BlockManager // stake * 2^32 < prng * 2^32 * biggestStake // multiplying by 2^32 since seed2 is bytes32 so rand2 goes from 0 to 2^32 bytes32 seed2 = Random.prngHash(salt, keccak256(abi.encode(stakerId, iteration))); - uint256 rand2 = Random.prng(2**32, seed2); + uint256 rand2 = Random.prng(2 ** 32, seed2); uint256 biggestStake = voteManager.getStakeSnapshot(epoch, biggestStakerId); uint256 stake = voteManager.getStakeSnapshot(epoch, stakerId); // Below line can't be tested since it can't be assured if it returns true or false - if (rand2 * (biggestStake) > stake * (2**32)) return (false); + if (rand2 * (biggestStake) > stake * (2 ** 32)) return (false); return true; } } diff --git a/contracts/Core/CollectionManager.sol b/contracts/Core/CollectionManager.sol index 3a605950..3cb55ba5 100644 --- a/contracts/Core/CollectionManager.sol +++ b/contracts/Core/CollectionManager.sol @@ -147,12 +147,10 @@ contract CollectionManager is Initializable, CollectionStorage, StateManager, Co * @param assetStatus the status that needs to be set for the collection * @param id the collection id for which the status needs to change */ - function setCollectionStatus(bool assetStatus, uint16 id) - external - initialized - onlyRole(COLLECTION_MODIFIER_ROLE) - checkState(State.Confirm, buffer) - { + function setCollectionStatus( + bool assetStatus, + uint16 id + ) external initialized onlyRole(COLLECTION_MODIFIER_ROLE) checkState(State.Confirm, buffer) { require(id != 0, "ID cannot be 0"); require(id <= numCollections, "ID does not exist"); @@ -286,16 +284,7 @@ contract CollectionManager is Initializable, CollectionStorage, StateManager, Co } /// @inheritdoc ICollectionManager - function getResult(bytes32 _name) - external - view - override - returns ( - uint256, - int8, - uint256 - ) - { + function getResult(bytes32 _name) external view override returns (uint256, int8, uint256) { uint16 id = ids[_name]; return getResultFromID(id); } @@ -379,16 +368,7 @@ contract CollectionManager is Initializable, CollectionStorage, StateManager, Co } /// @inheritdoc ICollectionManager - function getResultFromID(uint16 _id) - public - view - override - returns ( - uint256, - int8, - uint256 - ) - { + function getResultFromID(uint16 _id) public view override returns (uint256, int8, uint256) { (uint256 result, uint256 timestamp) = blockManager.getLatestResults(_id); return (result, collections[_id].power, timestamp); } diff --git a/contracts/Core/RewardManager.sol b/contracts/Core/RewardManager.sol index 1ea2454b..2308c5d5 100644 --- a/contracts/Core/RewardManager.sol +++ b/contracts/Core/RewardManager.sol @@ -164,11 +164,7 @@ contract RewardManager is Initializable, Constants, RewardManagerParams, IReward * @param stakeValue The Stake that staker had in last epoch * @param ageValue The age that staker had in last epoch */ - function _calculateInactivityPenalties( - uint32 epochs, - uint256 stakeValue, - uint32 ageValue - ) internal view returns (uint256, uint32) { + function _calculateInactivityPenalties(uint32 epochs, uint256 stakeValue, uint32 ageValue) internal view returns (uint256, uint32) { uint256 penalty = ((epochs) * (stakeValue * penaltyNotRevealNum)) / BASE_DENOMINATOR; uint256 newStake = penalty < stakeValue ? stakeValue - penalty : 0; uint256 penaltyAge = (uint256(epochs) * (uint256(ageValue) * uint256(penaltyAgeNotRevealNum))) / BASE_DENOMINATOR; diff --git a/contracts/Core/StakeManager.sol b/contracts/Core/StakeManager.sol index 26f5fef8..28847d06 100644 --- a/contracts/Core/StakeManager.sol +++ b/contracts/Core/StakeManager.sol @@ -424,12 +424,7 @@ contract StakeManager is Initializable, StakeStorage, StateManager, Pause, Stake } /// @inheritdoc IStakeManager - function srzrTransfer( - address from, - address to, - uint256 amount, - uint32 stakerId - ) external override initialized onlyRole(STOKEN_ROLE) { + function srzrTransfer(address from, address to, uint256 amount, uint32 stakerId) external override initialized onlyRole(STOKEN_ROLE) { emit SrzrTransfer(from, to, amount, stakerId); } @@ -513,11 +508,7 @@ contract StakeManager is Initializable, StakeStorage, StateManager, Pause, Stake } /// @inheritdoc IStakeManager - function slash( - uint32 epoch, - uint32 stakerId, - address bountyHunter - ) external override initialized onlyRole(STAKE_MODIFIER_ROLE) { + function slash(uint32 epoch, uint32 stakerId, address bountyHunter) external override initialized onlyRole(STAKE_MODIFIER_ROLE) { uint256 _stake = stakers[stakerId].stake; uint256 bounty; @@ -631,13 +622,7 @@ contract StakeManager is Initializable, StakeStorage, StateManager, Pause, Stake * @param _id of the staker * @param _stake the amount of Razor tokens staked */ - function _setStakerStake( - uint32 _epoch, - uint32 _id, - Constants.StakeChanged reason, - uint256 _prevStake, - uint256 _stake - ) internal { + function _setStakerStake(uint32 _epoch, uint32 _id, Constants.StakeChanged reason, uint256 _prevStake, uint256 _stake) internal { stakers[_id].stake = _stake; emit StakeChange(_epoch, _id, reason, _prevStake, _stake, block.timestamp); } @@ -667,11 +652,7 @@ contract StakeManager is Initializable, StakeStorage, StateManager, Pause, Stake * @param _sAmount The Amount in sRZR * @param _currentStake The cuurent stake of associated staker */ - function _convertSRZRToRZR( - uint256 _sAmount, - uint256 _currentStake, - uint256 _totalSupply - ) internal pure returns (uint256) { + function _convertSRZRToRZR(uint256 _sAmount, uint256 _currentStake, uint256 _totalSupply) internal pure returns (uint256) { return ((_sAmount * _currentStake) / _totalSupply); } @@ -681,11 +662,7 @@ contract StakeManager is Initializable, StakeStorage, StateManager, Pause, Stake * @param _currentStake The cuurent stake of associated staker * @param _totalSupply The totalSupply of sRZR */ - function _convertRZRtoSRZR( - uint256 _amount, - uint256 _currentStake, - uint256 _totalSupply - ) internal pure returns (uint256) { + function _convertRZRtoSRZR(uint256 _amount, uint256 _currentStake, uint256 _totalSupply) internal pure returns (uint256) { // Follwoing require is included to cover case where // CurrentStake Becomes zero beacues of penalties, //this is likely scenario when staker stakes is slashed to 0 for invalid block. diff --git a/contracts/Core/StateManager.sol b/contracts/Core/StateManager.sol index d8fd0c3a..fecb5223 100644 --- a/contracts/Core/StateManager.sol +++ b/contracts/Core/StateManager.sol @@ -38,11 +38,7 @@ contract StateManager is Constants { /** @notice a check to ensure the epoch value sent in the function is of the currect epoch * and was called in the state specified */ - modifier checkEpochAndState( - State state, - uint32 epoch, - uint8 buffer - ) { + modifier checkEpochAndState(State state, uint32 epoch, uint8 buffer) { // slither-disable-next-line incorrect-equality require(epoch == _getEpoch(), "incorrect epoch"); // slither-disable-next-line incorrect-equality diff --git a/contracts/Core/VoteManager.sol b/contracts/Core/VoteManager.sol index b3a652b7..cf6896aa 100644 --- a/contracts/Core/VoteManager.sol +++ b/contracts/Core/VoteManager.sol @@ -230,21 +230,13 @@ contract VoteManager is Initializable, VoteStorage, StateManager, VoteManagerPar } /// @inheritdoc IVoteManager - function getVoteValue( - uint32 epoch, - uint32 stakerId, - uint16 leafId - ) external view override returns (uint256) { + function getVoteValue(uint32 epoch, uint32 stakerId, uint16 leafId) external view override returns (uint256) { //epoch -> stakerid -> asserId return votes[epoch][stakerId][leafId]; } /// @inheritdoc IVoteManager - function getVoteWeight( - uint32 epoch, - uint16 leafId, - uint256 voteValue - ) external view override returns (uint256) { + function getVoteWeight(uint32 epoch, uint16 leafId, uint256 voteValue) external view override returns (uint256) { //epoch -> leafId -> voteValue -> weight return (voteWeights[epoch][leafId][voteValue]); } diff --git a/contracts/Core/interface/ICollectionManager.sol b/contracts/Core/interface/ICollectionManager.sol index bae7962e..ac66e95c 100644 --- a/contracts/Core/interface/ICollectionManager.sol +++ b/contracts/Core/interface/ICollectionManager.sol @@ -73,14 +73,7 @@ interface ICollectionManager { * @return timestamp of the collection * @return power of the resultant collection */ - function getResult(bytes32 _name) - external - view - returns ( - uint256, - int8, - uint256 - ); + function getResult(bytes32 _name) external view returns (uint256, int8, uint256); /** * @notice returns the result of the collection based on the id sent by the client @@ -89,14 +82,7 @@ interface ICollectionManager { * @return timestamp of the collection when latest result was set * @return power of the resultant collection */ - function getResultFromID(uint16 _id) - external - view - returns ( - uint256, - int8, - uint256 - ); + function getResultFromID(uint16 _id) external view returns (uint256, int8, uint256); /** * @return epoch in which the registry needs to be updated diff --git a/contracts/Core/interface/IStakeManager.sol b/contracts/Core/interface/IStakeManager.sol index 86c17430..7de6be88 100644 --- a/contracts/Core/interface/IStakeManager.sol +++ b/contracts/Core/interface/IStakeManager.sol @@ -14,13 +14,7 @@ interface IStakeManager { * @param prevStake previous stake of the staker * @param _stake updated stake of the staker */ - function setStakerStake( - uint32 _epoch, - uint32 _id, - Constants.StakeChanged reason, - uint256 prevStake, - uint256 _stake - ) external; + function setStakerStake(uint32 _epoch, uint32 _id, Constants.StakeChanged reason, uint256 prevStake, uint256 _stake) external; /** * @notice The function is used by the Votemanager reveal function and BlockManager FinalizeDispute @@ -29,11 +23,7 @@ interface IStakeManager { * @param stakerId The ID of the staker who is penalised * @param bountyHunter The address of the bounty hunter */ - function slash( - uint32 epoch, - uint32 stakerId, - address bountyHunter - ) external; + function slash(uint32 epoch, uint32 stakerId, address bountyHunter) external; /** * @notice External function for setting staker age of the staker @@ -43,12 +33,7 @@ interface IStakeManager { * @param _age the updated new age * @param reason the reason for age change */ - function setStakerAge( - uint32 _epoch, - uint32 _id, - uint32 _age, - Constants.AgeChanged reason - ) external; + function setStakerAge(uint32 _epoch, uint32 _id, uint32 _age, Constants.AgeChanged reason) external; /** * @notice External function for setting stakerReward of the staker @@ -86,12 +71,7 @@ interface IStakeManager { * @param amount srzr amount being transferred * @param stakerId of the staker */ - function srzrTransfer( - address from, - address to, - uint256 amount, - uint32 stakerId - ) external; + function srzrTransfer(address from, address to, uint256 amount, uint32 stakerId) external; /** * @param _address Address of the staker diff --git a/contracts/Core/interface/IVoteManager.sol b/contracts/Core/interface/IVoteManager.sol index 55eedbd0..85305275 100644 --- a/contracts/Core/interface/IVoteManager.sol +++ b/contracts/Core/interface/IVoteManager.sol @@ -24,11 +24,7 @@ interface IVoteManager { * @param leafId seq position of collection in merkle tree * @return vote value */ - function getVoteValue( - uint32 epoch, - uint32 stakerId, - uint16 leafId - ) external view returns (uint256); + function getVoteValue(uint32 epoch, uint32 stakerId, uint16 leafId) external view returns (uint256); /** * @notice returns vote weight of the value of the collection reported @@ -37,11 +33,7 @@ interface IVoteManager { * @param voteValue one of the values of the collection being reported * @return vote weight of the vote */ - function getVoteWeight( - uint32 epoch, - uint16 leafId, - uint256 voteValue - ) external view returns (uint256); + function getVoteWeight(uint32 epoch, uint16 leafId, uint256 voteValue) external view returns (uint256); /** * @notice returns snapshot of influence of the staker when they revealed diff --git a/contracts/Core/parameters/Governance.sol b/contracts/Core/parameters/Governance.sol index 05e93a6a..504d10f3 100644 --- a/contracts/Core/parameters/Governance.sol +++ b/contracts/Core/parameters/Governance.sol @@ -86,11 +86,7 @@ contract Governance is Initializable, ACL, Constants { * @param _burn updated percent value to be set for burn * @param _keep updated percent value to be set for keep */ - function setSlashParams( - uint32 _bounty, - uint32 _burn, - uint32 _keep - ) external initialized onlyRole(GOVERNER_ROLE) { + function setSlashParams(uint32 _bounty, uint32 _burn, uint32 _keep) external initialized onlyRole(GOVERNER_ROLE) { require(_bounty + _burn + _keep <= BASE_DENOMINATOR, "Slash nums addtion exceeds 10mil"); emit ParameterChanged(msg.sender, "bountySlashNum", _bounty, block.timestamp); emit ParameterChanged(msg.sender, "burnSlashNum", _burn, block.timestamp); diff --git a/contracts/Core/parameters/child/BlockManagerParams.sol b/contracts/Core/parameters/child/BlockManagerParams.sol index b265545a..c0bdaa0d 100644 --- a/contracts/Core/parameters/child/BlockManagerParams.sol +++ b/contracts/Core/parameters/child/BlockManagerParams.sol @@ -9,9 +9,9 @@ abstract contract BlockManagerParams is ACL, IBlockManagerParams, Constants { uint8 public maxAltBlocks = 5; uint8 public buffer = 5; /// @notice reward given to staker whose block is confirmed - uint256 public blockReward = 100 * (10**18); + uint256 public blockReward = 100 * (10 ** 18); /// @notice minimum amount of stake required to participate - uint256 public minStake = 20000 * (10**18); + uint256 public minStake = 20000 * (10 ** 18); /// @inheritdoc IBlockManagerParams function setMaxAltBlocks(uint8 _maxAltBlocks) external override onlyRole(GOVERNANCE_ROLE) { diff --git a/contracts/Core/parameters/child/RewardManagerParams.sol b/contracts/Core/parameters/child/RewardManagerParams.sol index 19f33351..c9536e6b 100644 --- a/contracts/Core/parameters/child/RewardManagerParams.sol +++ b/contracts/Core/parameters/child/RewardManagerParams.sol @@ -12,7 +12,7 @@ abstract contract RewardManagerParams is ACL, IRewardManagerParams, Constants { /// @notice maximum age a staker can have uint32 public maxAge = 100 * 10000; /// @notice reward given to staker whose block is confirmed - uint256 public blockReward = 100 * (10**18); + uint256 public blockReward = 100 * (10 ** 18); /// @notice maximum percentage deviation allowed from medians for all collections uint32 public maxTolerance = 1_000_000; /// @notice maximum commission stakers can charge from delegators on their profits diff --git a/contracts/Core/parameters/child/StakeManagerParams.sol b/contracts/Core/parameters/child/StakeManagerParams.sol index 8d86be70..36fa74e2 100644 --- a/contracts/Core/parameters/child/StakeManagerParams.sol +++ b/contracts/Core/parameters/child/StakeManagerParams.sol @@ -37,16 +37,12 @@ abstract contract StakeManagerParams is ACL, IStakeManagerParams, Constants { /// @notice slashing params being used if staker is slashed. Slash Penalty = bounty + burned + kept == 100% SlashNums public slashNums = SlashNums(500_000, 9_500_000, 0); /// @notice minimum amount of stake required to participate - uint256 public minStake = 20000 * (10**18); + uint256 public minStake = 20000 * (10 ** 18); /// @notice minimum amount of stake required to become a staker - uint256 public minSafeRazor = 10000 * (10**18); + uint256 public minSafeRazor = 10000 * (10 ** 18); /// @inheritdoc IStakeManagerParams - function setSlashParams( - uint32 _bounty, - uint32 _burn, - uint32 _keep - ) external override onlyRole(GOVERNANCE_ROLE) { + function setSlashParams(uint32 _bounty, uint32 _burn, uint32 _keep) external override onlyRole(GOVERNANCE_ROLE) { require(_bounty + _burn + _keep <= BASE_DENOMINATOR, "params sum exceeds denominator"); // slither-disable-next-line events-maths slashNums = SlashNums(_bounty, _burn, _keep); diff --git a/contracts/Core/parameters/child/VoteManagerParams.sol b/contracts/Core/parameters/child/VoteManagerParams.sol index cb05b868..8fd917d3 100644 --- a/contracts/Core/parameters/child/VoteManagerParams.sol +++ b/contracts/Core/parameters/child/VoteManagerParams.sol @@ -9,7 +9,7 @@ abstract contract VoteManagerParams is ACL, IVoteManagerParams, Constants { /// @notice maximum number of collections that can be assigned to the staker uint16 public toAssign = 3; /// @notice minimum amount of stake required to participate - uint256 public minStake = 20000 * (10**18); + uint256 public minStake = 20000 * (10 ** 18); /// @inheritdoc IVoteManagerParams function setMinStake(uint256 _minStake) external override onlyRole(GOVERNANCE_ROLE) { diff --git a/contracts/Core/parameters/interfaces/IStakeManagerParams.sol b/contracts/Core/parameters/interfaces/IStakeManagerParams.sol index 5270e24b..95a167da 100644 --- a/contracts/Core/parameters/interfaces/IStakeManagerParams.sol +++ b/contracts/Core/parameters/interfaces/IStakeManagerParams.sol @@ -9,11 +9,7 @@ interface IStakeManagerParams { * @param _burn updated percent value to be set for burn * @param _keep updated percent value to be set for keep */ - function setSlashParams( - uint32 _bounty, - uint32 _burn, - uint32 _keep - ) external; + function setSlashParams(uint32 _bounty, uint32 _burn, uint32 _keep) external; /** * @notice changing the number of epochs for which the RAZORs are locked after initiating withdraw diff --git a/contracts/Delegator.sol b/contracts/Delegator.sol index e4df3496..8a394dc2 100644 --- a/contracts/Delegator.sol +++ b/contracts/Delegator.sol @@ -50,17 +50,7 @@ contract Delegator is Pause, IDelegator { } /// @inheritdoc IDelegator - function getResultFromID(uint16 _id) - external - view - override - whenNotPaused - returns ( - uint256, - int8, - uint256 - ) - { + function getResultFromID(uint16 _id) external view override whenNotPaused returns (uint256, int8, uint256) { return collectionManager.getResultFromID(_id); } diff --git a/contracts/IDelegator.sol b/contracts/IDelegator.sol index 6928829d..02981144 100644 --- a/contracts/IDelegator.sol +++ b/contracts/IDelegator.sol @@ -46,14 +46,7 @@ interface IDelegator { * @param _id collection ID * @return result of the collection, its power and last updated timestamp */ - function getResultFromID(uint16 _id) - external - view - returns ( - uint256, - int8, - uint256 - ); + function getResultFromID(uint16 _id) external view returns (uint256, int8, uint256); /** * @return ids of active collections in the oracle diff --git a/contracts/tokenization/IStakedToken.sol b/contracts/tokenization/IStakedToken.sol index 1e07a9f5..2f562165 100644 --- a/contracts/tokenization/IStakedToken.sol +++ b/contracts/tokenization/IStakedToken.sol @@ -17,11 +17,7 @@ interface IStakedToken is IERC20 { * * - `account` cannot be the zero address. */ - function mint( - address account, - uint256 amount, - uint256 razorDeposited - ) external returns (bool); + function mint(address account, uint256 amount, uint256 razorDeposited) external returns (bool); /** * @dev Destroys `amount` tokens from `account`, reducing the diff --git a/contracts/tokenization/StakedToken.sol b/contracts/tokenization/StakedToken.sol index 65c43235..8069b223 100644 --- a/contracts/tokenization/StakedToken.sol +++ b/contracts/tokenization/StakedToken.sol @@ -36,11 +36,7 @@ contract StakedToken is ERC20, IStakedToken { } /// @inheritdoc IStakedToken - function mint( - address account, - uint256 amount, - uint256 _razorDeposited - ) external override onlyOwner returns (bool) { + function mint(address account, uint256 amount, uint256 _razorDeposited) external override onlyOwner returns (bool) { razorDeposited[account] = razorDeposited[account] + _razorDeposited; _mint(account, amount); return true; @@ -65,11 +61,7 @@ contract StakedToken is ERC20, IStakedToken { * @param to address where sRZR is being transferred to * @param amount amount sRZR being transferred */ - function _beforeTokenTransfer( - address from, - address to, - uint256 amount - ) internal virtual override { + function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { //mint : addition, would happen in case of delegate or stake //burn : subtraction, would happeen when staker calls withdraw //transfer : add and sub