The system uses 2 different thresholds to determine if a user is healthy.
The system defines liquidatabale in 2 different ways:
1️⃣ If a user's collateral is worth less than 80% of their debt. (80% == BASE_LIQUIDATION_THRESHOLD == liquidationThreshold
, by default is set to 80%)
2️⃣ If a user's health factors is less than 1e18. (BASE_HEALTH_FACTOR_LIQUIDATION_THRESHOLD == 1e18
, by default even though can be changed)
These 2 are different because the way the health factor is calculated has nothing to due with the collateral value being worth less than 80% of the debt.
Let's see how the heath factor is calculated here:
Now in borrow()
we see that the check to avoid users becoming instantly liquidatable is done like so:
These are different checks providing different results:
Debt value: 100.
Collateral value: 110.
1️⃣ 80% of the debt is 80. The collateral is worth more than 80% of the debt -> Not liquidatable.
2️⃣ The health factor is 0.8*110 / 100 = 0.88. The health factor is less than 1 -> Liquidatable.
Some users will be liquidatable according to the logic in some functions and not liquditable according to the logic in other functions.
Choose one and stick to it. I would recommend the one in calculateHealthFactor()
as it is a more conservative approach to avoid bad debt.
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.