The calculateHealthFactor() function’s integer division truncates small collateral values to a health factor of 0, risking false liquidations. This medium-impact, medium-likelihood issue assumes collateralValue is in WAD (1e18); if in RAY (1e27), it may not apply, but precision loss still threatens fairness.
The function scales collateralThreshold (WAD) by 1e18 and divides by userDebt (RAY, 1e27), losing precision. Example:
NFT value 1000e18 (WAD), liquidationThreshold = 80_00, debt 1e27 (RAY).
collateralThreshold = 800e18, (800e18 * 1e18) / 1e27 = 0.
Health factor 0 triggers liquidation despite sufficient collateral (1000e18 > 800e18).
User loses 1000 crvUSD unfairly.
Users face unjust liquidations (e.g., 1000 crvUSD lost), a medium-impact issue. The medium likelihood occurs with small collateral or large debt, a common edge case that could unfairly penalize borrowers.
Static Analysis Tools: Slither to detect precision loss in division.
Manual Code Review: To analyze scaling in calculateHealthFactor().
Testing Frameworks: Foundry to test edge cases with small values.
Adjust to RAY precision (assuming WAD input):
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.