The missing validation in UsdPrice
returned by LibUsdOracle.getUsdPrice(barnRaiseToken)
ineErtilizerFacet::
can lead to mint Fertilizer (FertilizerFacet::mintFertilizer
) failure.
The FertilizerFacet::_getMintFertilizerOut
function called in FertilizerFacet::mintFertilizer
the performs a division operation using the result of LibUsdOracle.getUsdPrice(barnRaiseToken)
. If the getUsdPrice
function returns a 0 value for the given barnRaiseToken
, the division operation will attempt to divide by 0, which is undefined in Solidity, reverting the transaction.
If the UsdPrice
of the barnRaiseToken
returned by the LibUsdOracle.getUsdPrice(barnRaiseToken)
is zero, the calculation of fertilizerAmountOut
in _getMintFertilizerOut
would result in a division by zero error. This is because of the denominator in the calculation. When the usdPrice is zero (due a some market condition) the contract would revert with an error because dividing by zero is not defined in Solidity. The mintFertilizer
function reverts too failing the minting.
Manual review
Add a check to ensure that the price returned by LibUsdOracle.getUsdPrice(barnRaiseToken)
is not 0 before performing the division.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.