Open code423n4 opened 2 years ago
I don't believe the suggestion will work, in lack of POC I'm not giving it points The suggested change goes out of bounds (last element of array is array.length - 1)
Saves 3 gas 3 * 3 = 9
Only for Requires, listed below
contracts\BkdLocker.sol#L91 contracts\BkdLocker.sol#L92 contracts\BkdLocker.sol#L137 contracts\tokenomics\AmmGauge.sol#L104 contracts\tokenomics\AmmGauge.sol#L125 contracts\tokenomics\KeeperGauge.sol#L140 contracts\tokenomics\VestedEscrow.sol#L84
3 * 7 = 21
In lack of POC I can't give it any points
3 per instance
3 * 6 = 18
Would save 20 gas
Total Gas Saved 68
--length; if(i != length) { stashedWithdraws[i] = stashedWithdraws[length]; }
From the logic of the contract, "totalKeeperPoolWeight" will be always non-negative. Even if this value could be negative, it will be revoked with underflow error before.
Use != 0 instead of > 0 for uint variables contracts\BkdLocker.sol#L91 contracts\BkdLocker.sol#L92 contracts\BkdLocker.sol#L137 contracts\BkdLocker.sol#L139 contracts\BkdLocker.sol#L254 contracts\BkdLocker.sol#L301 contracts\tokenomics\AmmGauge.sol#L88 contracts\tokenomics\AmmGauge.sol#L104 contracts\tokenomics\AmmGauge.sol#L125 contracts\tokenomics\AmmGauge.sol#L147 contracts\tokenomics\FeeBurner.sol#L117 contracts\tokenomics\KeeperGauge.sol#L140 contracts\tokenomics\LpGauge.sol#L68 contracts\tokenomics\LpGauge.sol#L114 contracts\tokenomics\VestedEscrow.sol#L84 contracts\RewardHandler.sol#L63
Change storage to memory if possible contracts\BkdLocker.sol#L251
An array’s length should be cached to save gas in for-loops contracts\StakerVault.sol#L259 contracts\tokenomics\FeeBurner.sol#L56 contracts\tokenomics\InflationManager.sol#L116 contracts\tokenomics\VestedEscrow.sol#L94 contracts\zaps\PoolMigrationZap.sol#L22 contracts\zaps\PoolMigrationZap.sol#L39
Usage of unchecked can reduce the gas cost contracts\StakerVault.sol#L387
allowances[src][msg.sender] = allowance.uncheckedSub(unstaked);