DeFiHardhat
21,000 USDC
View results
Submission Details
Severity: medium
Invalid

Division before multiplication in getTotalRecapDollarsNeeded() function can lead to percision loss.

Vulnerability Details

In calculation of totalDollars in LibFertilizer :: getTotalRecapDollarsNeeded(uint256 urLPsupply) the division is done before multiplication.

Impact

This can lead to the precision loss while calculating the totalDollars.

  function getTotalRecapDollarsNeeded(uint256 urLPsupply) internal pure returns(uint256) {
    uint256 totalDollars = C
        .dollarPerUnripeLP()
        .mul(urLPsupply)
        .div(DECIMALS);
  // @audit  
    totalDollars = totalDollars / 1e6 * 1e6; // round down to nearest USDC
    return totalDollars;
}

Tools Used

Manual Review.

Recommendations

Consider multiplication before division while calculation. Write the calculation like this .

        totalDollars = totalDollars * 1e6/1e6
Updates

Lead Judging Commences

giovannidisiena Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.