Omniscia Beanstalk Audit

ConvertSilo Code Style Findings

ConvertSilo Code Style Findings

CSO-01C: Inexistent Usage of Constant

TypeSeverityLocation
Code StyleConvertSilo.sol:L40, L41

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/ConvertFacet/ConvertSilo.sol
40if (season() == _s) depositSiloAssets(msg.sender, seeds, lpb.mul(10000));
41else 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 getStalkperBean constant from the C implementation is now correctly utilized.

CSO-02C: Redundant Usage of SafeMath

Description:

The linked SafeMath operations are guaranteed to be performed safely by their surrounding if clauses and general logical constraints.

Example:

protocol/contracts/farm/facets/ConvertFacet/ConvertSilo.sol
147while ((i < crates.length) && (beansRemoved < maxBeans)) {
148 if (beansRemoved.add(amounts[i]) < maxBeans)
149 crateBeans = removeBeanDeposit(msg.sender, crates[i], amounts[i]);
150 else
151 crateBeans = removeBeanDeposit(msg.sender, crates[i], maxBeans.sub(beansRemoved));

Recommendation:

We advise them to be performed without the usage of SafeMath to optimise the code.

Alleviation:

The redundant SafeMath instance was appropriately removed.