sherlock-audit / 2024-08-cork-protocol-judging

2 stars 2 forks source link

Mammoth Laurel Nightingale - [GAS-8] Splitting require() statements that use && saves gas #281

Closed sherlock-admin2 closed 2 months ago

sherlock-admin2 commented 2 months ago

Mammoth Laurel Nightingale

Low/Info

[GAS-8] Splitting require() statements that use && saves gas

Summary

Vulnerability Detail

Using multiple require statements is cheaper than using && multiple check combinations. There are more advantages, such as easier to read code and better coverage reports.

Ref: https://code4rena.com/reports/2023-01-ondo#g-15-splitting-require-statements-that-use--saves-gas---saves-8-gas-per-

Impact

Code Snippet

Instances (2):

File: libraries/uni-v2/UniswapV2Library.sol

68:         require(reserveIn > 0 && reserveOut > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY");

83:         require(reserveIn > 0 && reserveOut > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY");

Tool used

Manual Review

Recommendation

siddhpurakaran commented 1 month ago

will not make significant impact on gas savings because majorly both conditions will be true. So will not fix this issue