Omniscia Beanstalk Audit

LibConvert Code Style Findings

LibConvert Code Style Findings

LCT-01C: Redundant Future Trade Timestamp

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:

protocol/contracts/libraries/LibConvert.sol
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

Description:

The linked ternary operators (a ? b : c) can be optimized to a single one by adjusting their structure.

Example:

protocol/contracts/libraries/LibConvert.sol
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

TypeSeverityLocation
Code StyleLibConvert.sol:L54, L62

Description:

The linked variable declaration contains a typographic error.

Example:

protocol/contracts/libraries/LibConvert.sol
54function removeLiquidityToBeanstalk(uint256 liqudity)
55 private
56 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.