Open code423n4 opened 2 years ago
Do not recalculate constant results 6 gas
StakingRewards.sol rewardPerToken() — rewardPerTokenStored -> Disagree it's used as either or notifyRewardAmount() — rewardsDuration, periodFinish - Agree for both, using a cached version would save 94 * 2 = 188 gas updateReward() — rewardPerTokenStored (cache the new value) - Agree it would save another 94 gas
USDMPegRecovery.sol Caching would save another 94 gas * 2 = 188 (not using storage would save way more bug warden didn't provide that as a recommendation)
StakingRewards.sol
97 gas * 2 = 188
Total: 664 gas from these recommendation
Do not recalculate constant results
Since results are constant, the code should not calculate them over and over again.
https://github.com/code-423n4/2022-02-concur/blob/main/contracts/ConvexStakingWrapper.sol#L116-L117
StakingRewards.sol
cache variables to save gasBy caching variables, loads from storage can be avoided to save gas.
USDMPegRecovery.sol
cache variables to save gasBy caching variables, loads from storage can be avoided to save gas.
At setters emit input rather than from storage to save gas
In
StakingRewards.sol
: