Open code423n4 opened 1 year ago
berndartmueller marked the issue as grade-a
berndartmueller marked the issue as selected for report
Some of the instances described in this gas report are false and the report saves less gas than claimed.
storage
instead of memory
for structs/arrays saves gasFile: src/core/libraries/Position.sol
47: Position.Info memory _positionInfo = positionInfo;
All of _positionInfo
's fields are read, so no gas will be saved. size
is read on line 50, rewardPerPositionPaid
is read on line 70 (inside newTokensOwed()
) and tokensOwed
is read on line 64.
File: src/periphery/LiquidityManager.sol
211: Position memory position = positions[msg.sender][lendgine]; // SLOAD
All of position
's fields are read, so no gas will be saved. size
is read on line 214, rewardPerPositionPaid
is read on line 214 and tokensOwed
is read on line 214.
Total gas actually saved: 4200
File: src/core/Pair.sol
/// @audit swapCallback()
127: ISwapCallback(msg.sender).swapCallback(amount0Out, amount1Out, data);
swapCallback()
doesn't have a return value so the optimization doesn't apply here and no gas will be saved.
File: src/periphery/Payment.sol
/// @audit withdraw()
30: IWETH9(weth).withdraw(balanceWETH);
withdraw()
doesn't have a return value so the optimization doesn't apply here and no gas will be saved.
Total gas actually saved: 1800
Overall, this gas report actually saves a total of 6730 gas. Therefore, I think report #98 is better and should be selected for the report.
I invite @IllIllI000 to add feedback here.
noamyakov is right about the second G-02, and both of the G-03s (the G-03 bugs I've fixed). I haven't looked at his report so I can't vouch for correctness, but if his numbers are right, then yes, he should be selected
I will reconsider my decision to select this gas submission for the report. Thanks @noamyakov, for pointing out the inaccuracies, and big thanks to @IllIllI000 for being such a collegial fellow warden.
G-02: No possible gas savings in both mentioned cases by Noam
G-03: Due to safety precautions, the EXTCODESIZE
check done by Solidity is valid in the case of swapCallback()
and withdraw
to ensure a contract exists at the target address. Hence, the gas optimization recommendations are invalid.
berndartmueller marked the issue as not selected for report
See the markdown file with the details of this report here.