Gas Optimizations #93
Labels
bug
Something isn't working
G (Gas Optimization)
resolved
Finding has been patched by sponsor (sponsor pls link to PR containing fix)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Gas optimizations
Use unchecked lib to increment safe variables
PoolMigrationZap.sol
You can add the unchecked math lib like you do on the others contracts to safely increment the
i
var, saving gas and make contract consistent with the others by enforcing the same style.Recommendation, add
using UncheckedMath for uint256
And on line
PoolMigrationZap.sol#L22
change;To
TopUpKeeperHelper.sol
On line TopUpKeeperHelper.sol#L52 you coul use unchecked math lib to increment the variable.
Change:
topupsAdded++;
To:
KeeperGauge.sol
On lines #L98 and L59 you could use unchecked math lib, consider change;
epoch++;
To;
Use unchecked for decrement
i
On BkdLocker.sol#L140 you can do a unchecked decrement (or add a function to the Unchecked math to do it) change;
to;
Cache
.length
You could cache lenght of arrays to save gas;
RewardHandler.sol#L41-L42
StakerVault.sol#L259
VestedEscrow.sol#L94
Use
require(foo != 0)
instead ofrequire(foo > 0)
>0
is less gas efficient than!0
if you enable the optimizer at 10k AND you’re in a require statement.BkdLocker.sol#L91
BkdLocker.sol#L92
BkdLocker.sol#L137
VestedEscrow.sol#L84
KeeperGauge.sol#L140
AmmGauge.sol#L104
AmmGauge.sol#L125
The text was updated successfully, but these errors were encountered: