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

Incorrect Calculation of `totalDollars` in `LibFertilizer::getTotalRecapDollarsNeeded` function

Vulnerability Details

The core issue lies in the calculation of totalDollars in the getTotalRecapDollarsNeeded function. The expression used in the code is:

totalDollars = totalDollars / 1e6 * 1e6;

Incorrect Calculation:

  • The current expression effectively cancels out the operations, resulting in totalDollars remaining unchanged.

  • For instance, given totalDollars = 1000000:

    • totalDollars / 1e6 * 1e6 results in 1000000, which does not modify the value as intended.

Correct Calculation:

  • The intended operation seems to be scaling down totalDollars for precision purposes. The correct way to perform this operation would be:

    totalDollars = totalDollars / (1e6 * 1e6);

Impact

The incorrect calculation causes erroneous values in the logic where totalDollars is used, particularly affecting the redemption logic in getPenalizedUnderlying.

Tools Used

Manual Review

Recommendations

  1. Fix the Calculation in getTotalRecapDollarsNeeded:

    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.