The liquidateBorrower function in StabilityPool incorrectly scales the user's debt amount when retrieving it from the LendingPool. The getUserDebt function in LendingPool already returns a scaled value, but the liquidateBorrower function applies additional scaling using getNormalizedDebt. This results in an overestimated debt calculation, which may cause liquidation transactions to revert, even when the stability pool has sufficient funds.
The function getUserDebt in LendingPool already scales the debt balance:
However, in liquidateBorrower, the returned value is again multiplied by getNormalizedDebt(), resulting in an excessive debt calculation.
Overestimated debt amount can cause the liquidation process to revert due to the InsufficientBalance check.
Stability pool may fail to liquidate users, even when it has enough funds.
Assume a borrower has a scaled debt of 1000.
getUserDebt(user) returns 1000 * reserve.usageIndex = 1200 (if usageIndex = 1.2).
liquidateBorrower further scales it: 1200 * getNormalizedDebt() = 1440 (if getNormalizedDebt() = 1.2).
If the stability pool has only 1200 tokens, the liquidation incorrectly fails due to InsufficientBalance().
Remove the extra scaling when retrieving user 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.