Open code423n4 opened 2 years ago
Context:
Description:
Some gas can be saved by using an unchecked {} block if an underflow isn't possible because of a previous require() or if-statement.
if(minAmountRewardToken[rewardToken] == 0) revert Errors.TokenNotWhitelisted(); if(rewardPerVote < minAmountRewardToken[rewardToken]) revert Errors.RewardPerVoteTooLow();
https://github.com/code-423n4/2022-10-paladin/blob/main/contracts/WardenPledge.sol#L312-L313
Recommendation:
Change:
to:
uint256 _minAmountRewardToken = minAmountRewardToken[rewardToken] if(_minAmountRewardToken == 0) revert Errors.TokenNotWhitelisted(); if(rewardPerVote < _minAmountRewardToken) revert Errors.RewardPerVoteTooLow();
Read the state variable from storage.
kirk-baird marked the issue as grade-b
Report
Gas Optimizations
[G-01]: Place subtractions where the operands can't underflow in unchecked {} block
Context:
Description:
Some gas can be saved by using an unchecked {} block if an underflow isn't possible because of a previous require() or if-statement.
[G-02]: Catch a value inside a mapping/array in local memory
Context:
https://github.com/code-423n4/2022-10-paladin/blob/main/contracts/WardenPledge.sol#L312-L313
Recommendation:
Change:
to:
[G-03]: No need to catch state variable in local memory if it only use once
Context:
Recommendation:
Read the state variable from storage.