15,000 USDC
View results
Submission Details
Severity: low
Valid

Unnecessary precision loss in _calculateHealthFactor

Summary

Due to division before multiplication precision loss may cause _calculateHealthFactor to return slightly inaccurate results.

Vulnerability Details

_calculateHealthFactor breaks up the health factor calculation into 2 lines both of which involve a division. Each one can result in a small amount of token losses. This can be reduced by refactoring both lines into 1 and completing the division last.

Impact

Due to collateralValueInUsd having 18 decimals the actual value of tokens lost will be minimal. However as the calculation does not need division to be done twice I believe the code should be refactored to reduce these losses.

Tools Used

Manual Review

Recommendation

Combine the last 2 lines into 1 and complete the division last to minimise precision loss.

return ((collateralValueInUsd * LIQUIDATION_THRESHOLD * 1e18) / (totalDscMinted * LIQUIDATION_PRECISION);

Support

FAQs

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