15,000 USDC
View results
Submission Details
Severity: medium

Precision in health factor calculation

Summary

There is a precision loss in _calculateHealthFactor function leading to collateral being liquidated when it does not need to be.

Vulnerability Details

The function _calculateHealthFactor is an important function that is used throughout the code. It is responsible for calculating the health factor of an account. However, there is a precision loss that occurs during the multiplication and division process, the affected code is used to check if the account has a good health factor and is not at risk of being liquidated.

Impact

The precision loss issue results in collateral being liquidated when it does not need to be.

Tools Used

Manual Review

Recommendations

It is recommended to multiply first than divide:

- uint256 collateralAdjustedForThreshold = (collateralValueInUsd * LIQUIDATION_THRESHOLD) / LIQUIDATION_PRECISION;
- return (collateralAdjustedForThreshold * 1e18) / totalDscMinted;
+ return (collateralValueInUsd * LIQUIDATION_THRESHOLD * 1e18) / (LIQUIDATION_PRECISION * totalDscMinted);

Support

FAQs

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