Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas Optimizations #303

Open
code423n4 opened this issue May 25, 2022 · 0 comments
Open

Gas Optimizations #303

code423n4 opened this issue May 25, 2022 · 0 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

  1. Title : Title : Using ++i than i++ for saving more gas

Using 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 than i++.

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

  1. Title : Title : change uint256 i = 0 into uint256 i for saving more gas

using 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

  1. Title : Value can be set as constant

Since kickRewardPerEpoch and kickRewardEpochDelay 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

  1. Title : Saving gas by removing = 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

  1. Using short reason string can be used for saving more gas

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

  1. betterway epochIndex for cost less gas

epochIndex = i + 1; can be changed as epochIndex++ or it can be prefix ++epochIndex it can cost less gas than this implementation.

##Tool Used
Manual Review

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels May 25, 2022
code423n4 added a commit that referenced this issue May 25, 2022
@0xMaharishi 0xMaharishi added the duplicate This issue or pull request already exists label May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

2 participants