Omniscia Beanstalk Audit
LibConvert Code Style Findings
LibConvert Code Style Findings
LCT-01C: Redundant Future Trade Timestamp
Type | Severity | Location |
---|---|---|
Gas Optimization | LibConvert.sol:L66 |
Description:
The linked addition of 1
to the current block.timestamp
for the Uniswap trade execution is redundant as the trade system of Uniswap [simply evaluates that the value passed in is greater-than-or-equal (>=
) the current block.timestamp
].
Example:
59(beanAmount, ethAmount) = IUniswapV2Router02(ds.router).removeLiquidity(60 ds.bean,61 ds.weth,62 liqudity,63 1,64 1,65 address(this),66 block.timestamp.add(1)67);
Recommendation:
We advise the addition to be removed optimising the codebase.
Alleviation:
The block.timestamp
value is now directly utilized as advised.
LCT-02C: Ternary Operator Optimization
Type | Severity | Location |
---|---|---|
Gas Optimization | LibConvert.sol:L113 |
Description:
The linked ternary operators (a ? b : c
) can be optimized to a single one by adjusting their structure.
Example:
110function reserves() private view returns (uint256, uint256) {111 AppStorage storage s = LibAppStorage.diamondStorage();112 (uint112 reserve0, uint112 reserve1,) = IUniswapV2Pair(s.c.pair).getReserves();113 return (s.index == 0 ? reserve1 : reserve0, s.index == 0 ? reserve0 : reserve1);114}
Recommendation:
We advise them to be adjusted by evaluating the s.index() == 0
equality once and then returning a tuple of the two values (i.e. either (reserve0, reserve1)
or (reserve1, reserve0)
depending on the required case).
Alleviation:
The ternary operator has been optimized as advised.
LCT-03C: Variable Typo
Type | Severity | Location |
---|---|---|
Code Style | LibConvert.sol:L54, L62 |
Description:
The linked variable declaration contains a typographic error.
Example:
54function removeLiquidityToBeanstalk(uint256 liqudity)55 private56 returns (uint256 beanAmount, uint256 ethAmount)57{58 LibMarket.DiamondStorage storage ds = LibMarket.diamondStorage();59 (beanAmount, ethAmount) = IUniswapV2Router02(ds.router).removeLiquidity(60 ds.bean,61 ds.weth,62 liqudity,63 1,64 1,65 address(this),66 block.timestamp.add(1)67 );68}
Recommendation:
We advise it to be corrected.
Alleviation:
The variable typographic mistake has been corrected alleviating this exhibit.