In _calculateHealthFactor()
, division before multiplication is done. To avoid precision loss, division in solidity should always be done at the end.
The current code looks like this:
This effectively results in return of the value (((collateralValueInUsd * LIQUIDATION_THRESHOLD) / LIQUIDATION_PRECISION) * 1e18) / totalDscMinted
.
The multiplication with 1e18 should be done first.
Loss of precision and incorrect health factor calculation.
Manual review
Perform the calculation in one step and return ((collateralValueInUsd * LIQUIDATION_THRESHOLD) * 1e18) / totalDscMinted / LIQUIDATION_PRECISION;
.
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.