Omniscia Beanstalk Audit
OracleFacet Code Style Findings
OracleFacet Code Style Findings
OFT-01C: Redundant Condition Evaluation
Type | Severity | Location |
---|---|---|
Gas Optimization | OracleFacet.sol:L56-L58 |
Description:
The updateOracle
function validates whether either of the reserves of the pair
is zero and if so, yields an equillibrium point for the price between USDC
and BEAN
.
Example:
protocol/contracts/farm/facets/OracleFacet.sol
53function updateOracle() internal returns (Decimal.D256 memory, Decimal.D256 memory) {54 (Decimal.D256 memory bean_price, Decimal.D256 memory usdc_price) = updatePrice();55 (uint112 reserve0, uint112 reserve1,) = IUniswapV2Pair(s.c.pair).getReserves();56 if (reserve0 == 0 || reserve1 == 0) {57 return (Decimal.one(),Decimal.one());58 }59 return (bean_price, usdc_price);60}
Recommendation:
This condition only materializes during the very beginning of the contract's launch as it is impossible to empty out the reserves of a Uniswap V2 pair once it has been set up properly. As such, we advise the conditional to be omitted for gas optimization and codebase legibility purposes.
Alleviation:
The conditional has been safely omitted from the codebase thereby optimizing it.