The function _calculateHealthFactor
calculates the health factor for the system based on the provided parameters totalDscMinted
and collateralValueInUsd
. However, there is a risk of potential loss of precision when performing a multiplication on the result of a division operation. In Solidity, division results in truncated integers, and when used in further calculations, it can lead to inaccuracies or loss of precision in the final result.
In this function, the multiplication (collateralValueInUsd * LIQUIDATION_THRESHOLD) / LIQUIDATION_PRECISION
could suffer from a loss of precision due to the division operation right after. As a result, the health factor calculation may not be as accurate as desired, potentially leading to incorrect health factor assessments for the system.
Manual review and slither
We can prevent truncation and ensure accurate health factor calculation if we reorder the execution for better precision
we can also use a fixed-point arithmetic or utilizing libraries that support fixed-point operations. By using fixed-point arithmetic, you can maintain the desired level of precision throughout the calculation process.
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.