Omniscia Beanstalk Audit

LPSilo Code Style Findings

LPSilo Code Style Findings

LPS-01C: Inexistent Usage of Constant

TypeSeverityLocation
Code StyleLPSilo.sol:L54, L55

Description:

The linked statements utilise the 10000 value literal as a representation of the stalks per LP bean, a constant that should exist in C.

Example:

protocol/contracts/farm/facets/SiloFacet/LPSilo.sol
54if (season() == _s) depositSiloAssets(msg.sender, seeds, lpb.mul(10000));
55else depositSiloAssets(msg.sender, seeds, lpb.mul(10000).add(season().sub(_s).mul(seeds)));

Recommendation:

We advise the code to be updated to properly utilise a central constant increasing the legibility and maintainability of the codebase.

Alleviation:

The code now properly utilizes the getStalkPerBean constant of C.

LPS-02C: Redundant Re-Calculation

TypeSeverityLocation
Gas OptimizationLPSilo.sol:L53, L57

Description:

The linked code calculates the same value twice.

Example:

protocol/contracts/farm/facets/SiloFacet/LPSilo.sol
53uint256 seeds = lpb.mul(C.getSeedsPerLPBean());
54if (season() == _s) depositSiloAssets(msg.sender, seeds, lpb.mul(10000));
55else depositSiloAssets(msg.sender, seeds, lpb.mul(10000).add(season().sub(_s).mul(seeds)));
56
57addLPDeposit(msg.sender, _s, amount, lpb.mul(C.getSeedsPerLPBean()));

Recommendation:

We advise the first instance to be utilised directly in the second one.

Alleviation:

The optimization denoted was applied as advised in the _depositLP function implementation of LPSilo.