Gas Optimizations #303
Labels
bug
Something isn't working
duplicate
This issue or pull request already exists
G (Gas Optimization)
++i
thani++
for saving more gasUsing
i++
instead++i
for all the loops, the variable i is incremented using i++. It is known that implementation by using++i
costs less gas per iteration thani++
.Tools Used
Manual Review
Occurances
AuraClaimZap.sol#L143
AuraClaimZap.sol#L147
AuraClaimZap.sol#L151
AuraLocker.sol#L174
AuraLocker.sol#L306
AuraLocker.sol#L410
AuraLocker.sol#L696
AuraLocker.sol#L773
AuraVestedEscrow.sol#L100
BalLiquidityProvider.sol#L51
ExtraRewardsDistributor.sol#L233
uint256 i = 0
intouint256 i
for saving more gasusing this implementation can saving more gas for each loops.
Tool Used
Manual Review
Recommended Mitigation
Change it
Occurances
AuraClaimZap.sol#L143
AuraClaimZap.sol#L147
AuraClaimZap.sol#L151
AuraLocker.sol#L174
AuraLocker.sol#L773
AuraVestedEscrow.sol#L100
BalLiquidityProvider.sol#L51
Since
kickRewardPerEpoch
andkickRewardEpochDelay
can be set as constant, cause of values assigned at compile time and will not allow for any modifications at runtime.Tool Used
Manual Review, VSC
= 0
This implementation code can be saving more gas by removing = 0, it because If a variable was not set/initialized, it is assumed to have default value to 0
Tool Used
Manual Review
Mitigation Step
Remove
= 0
Occurances
AuraBalRewardPool.sol#L35
AuraBalRewardPool.sol#L38
AuraBalRewardPool.sol#L39
AuraBalRewardPool.sol#L197
Aura.sol#L74
AuraLocker.sol#L72
AuraLocker.sol#L310
AuraLocker.sol#L381
AuraLocker.sol#L842
ExtraRewardsDistributor.sol#L231
Every reason string takes at least 32 bytes. Use short reason strings that fits in 32 bytes or it will become more expensive.
Tool Used
Manual Review
Occurances
AuraBalRewardPool.sol#L121
AuraBalRewardPool.sol#L139
AuraBalRewardPool.sol#L157
AuraLocker.sol#L197
AuraLocker.sol#L232
AuraLocker.sol#L233
AuraLocker.sol#L598
AuraLocker.sol#L616
AuraLocker.sol#L850
epochIndex
for cost less gasepochIndex = i + 1;
can be changed asepochIndex++
or it can be prefix++epochIndex
it can cost less gas than this implementation.##Tool Used
Manual Review
The text was updated successfully, but these errors were encountered: