You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
better use contatnt error intsead stinrg erro in solidy 0.8.4 higher
custom error from solidity 0.8.4 are cheaper than revert strings, custom error are defined using the error statement can use insideand outside the contract.
Custom errors are defined using the error statement, which can be used inside and outside of contracts
Consider making some constants as non-public to save gas
Reducing from public to private or internal can save gas when a constant isn’t used outside of its contract. I suggest changing the visibility from public to internal or private
POC :
> 0 is less efficient then !=0 for unsignet interger
While it may seem that > 0 is cheaper than !=, this is only true without the optimizer enabled and outside a require statement. If you
enable the optimizer at 10k AND you’re in a require statement, this will save gas.
custom error from solidity 0.8.4 are cheaper than revert strings, custom error are defined using the
error
statement can use insideand outside the contract.Custom errors are defined using the error statement, which can be used inside and outside of contracts
source https://blog.soliditylang.org/2021/04/21/custom-errors/
i suggestreplacing revert error strings with custom error.
POC :
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/Aura.sol#L66
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/Aura.sol#L67
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/Aura.sol#L68
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/Aura.sol#L69
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/Aura.sol#L92
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/Aura.sol#L129
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraBalRewardPool.sol#L77
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraBalRewardPool.sol#L121
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraBalRewardPool.sol#L139
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraBalRewardPool.sol#L157
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraBalRewardPool.sol#L206
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraBalRewardPool.sol#L210
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraClaimZap.sol#L96
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraClaimZap.sol#L137
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMath.sol#L40
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMath.sol#L45
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMath.sol#L50
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMath.sol#L55
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMath.sol#L60
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L196
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L197
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L210
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L232
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L233
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L259
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L260
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L353
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L359
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L431
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L471
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L472
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L475
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L476
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L598
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L616
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L655
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L719
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L821
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L822
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L849
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L850
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L851
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMerkleDrop.sol#L69
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMerkleDrop.sol#L78
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMerkleDrop.sol#L84
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMerkleDrop.sol#L85
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMerkleDrop.sol#L91
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMerkleDrop.sol#L97
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMerkleDrop.sol#L98
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMerkleDrop.sol#L105
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMerkleDrop.sol#L119
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMerkleDrop.sol#L120
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMerkleDrop.sol#L121
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMerkleDrop.sol#L122
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMerkleDrop.sol#L123
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMerkleDrop.sol#L126
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMerkleDrop.sol#L152
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraMinter.sol#L32
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraPenaltyForwarder.sol#L48
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraStakingProxy.sol#L89
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraStakingProxy.sol#L90
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraStakingProxy.sol#L100
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraStakingProxy.sol#L108
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraStakingProxy.sol#L116
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraStakingProxy.sol#L117
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraStakingProxy.sol#L128
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraStakingProxy.sol#L129
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraStakingProxy.sol#L138
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraStakingProxy.sol#L158
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraStakingProxy.sol#L159
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraStakingProxy.sol#L172
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraStakingProxy.sol#L203
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraVestedEscrow.sol#L56
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraVestedEscrow.sol#L57
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraVestedEscrow.sol#L66
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraVestedEscrow.sol#L78
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraVestedEscrow.sol#L87
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraVestedEscrow.sol#L97
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraVestedEscrow.sol#L117
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraVestedEscrow.sol#L118
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraVestedEscrow.sol#L185
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/BalLiquidityProvider.sol#L47
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/BalLiquidityProvider.sol#L48
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/BalLiquidityProvider.sol#L49
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/BalLiquidityProvider.sol#L53
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/BalLiquidityProvider.sol#L57
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/BalLiquidityProvider.sol#L65
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/BalLiquidityProvider.sol#L70
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/BalLiquidityProvider.sol#L79
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/BalLiquidityProvider.sol#L89
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/ClaimFeesHelper.sol#L45
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/CrvDepositorWrapper.sol#L42
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/CrvDepositorWrapper.sol#L119
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/ExtraRewardsDistributor.sol#L68
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/ExtraRewardsDistributor.sol#L74
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/ExtraRewardsDistributor.sol#L171
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/ExtraRewardsDistributor.sol#L172
Reducing from public to private or internal can save gas when a constant isn’t used outside of its contract. I suggest changing the visibility from public to internal or private
POC :
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/Aura.sol#L28
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/Aura.sol#L29
> 0
is less efficient then!=0
for unsignet intergerWhile it may seem that
> 0
is cheaper than!=
, this is only true without the optimizer enabled and outside a require statement. If youenable the optimizer at 10k AND you’re in a require statement, this will save gas.
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L259
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L822
https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraLocker.sol#L851
The text was updated successfully, but these errors were encountered: