Open code423n4 opened 2 years ago
Only marginal gas improvements.
Saves 3 gas
100 gas saved * 2 = 200
Saves 30 gas for the calculation
Would have liked to see further detail here, as there's potential downsides to applying this advice, for this reason will not give it any points
Agree, this would save STATICCALL + the Storage check = 200 gas
Total Gas Saved 433
> 0
is less efficient than!= 0
for uint in require conditionRef: https://twitter.com/GalloDaSballo/status/1485430908165443590 https://github.com/skalenetwork/ima-c4-audit/blob/11d6a6ae5bf16af552edd75183791375e501915f/contracts/mainnet/DepositBoxes/DepositBoxEth.sol#L122
Reuse value from storage
https://github.com/skalenetwork/ima-c4-audit/blob/11d6a6ae5bf16af552edd75183791375e501915f/contracts/mainnet/CommunityPool.sol#L98
https://github.com/skalenetwork/ima-c4-audit/blob/11d6a6ae5bf16af552edd75183791375e501915f/contracts/mainnet/CommunityPool.sol#L171
Precalc keeack constant
The
keccak256(abi.encodePacked("Mainnet"))
can be precalculated as constant https://github.com/skalenetwork/ima-c4-audit/blob/11d6a6ae5bf16af552edd75183791375e501915f/contracts/mainnet/DepositBox.solSave gas by using schainName hash as input directly
It is a bit wasteful to use string schainName as input and hash it repeatedly onchain
Optimistic erc20 transfer
Can save some gas by skiping the balance check and let it revert during the transfer https://github.com/skalenetwork/ima-c4-audit/blob/11d6a6ae5bf16af552edd75183791375e501915f/contracts/mainnet/DepositBoxes/DepositBoxERC20.sol#L157