The LendingPool contract requires borrowers to manually call closeLiquidation
after repaying their debt during the liquidation grace period. However, an edge case arises when the borrower repays their debt at the very end of the grace period but does not get the chance to call closeLiquidation
before the grace period expires. This results in an unintended liquidation, even though the borrower has fully repaid their debt.
Manual Closure of Liquidation is Required
The function enforces a strict grace period check:
If the borrower repays at the last moment of the grace period, the grace period can expire before they manage to call closeLiquidation()
. This results in an unfair liquidation, even though the borrower has fully repaid.
User is flagged for liquidation and given a grace period to repay the debt.
User repays the full debt at the very last moment of the grace period.
Grace period expires immediately after repayment, preventing the borrower from calling closeLiquidation()
.
Since closeLiquidation()
cannot be called after grace period expiration, the borrower remains flagged for liquidation despite having repaid.
The borrower is unfairly liquidated, as they never got a chance to remove the liquidation flag.
Unfair Liquidations Borrowers who successfully repay their debt may still be liquidated due to timing constraints.
Loss of Collateral Even though the borrower cleared their debt, they are wrongfully subjected to forced liquidation.
Solution 1 Automatically Call closeLiquidation
in repay
Modify repay
to automatically call closeLiquidation
after full debt repayment, avoiding the edge case.
Solution 2 Remove Grace Period Check in closeLiquidation
if Debt is Zero
Modify closeLiquidation()
so that if the user has repaid their debt, the function can still be executed even after the grace period expires.
Solution 3 Add Health Factor Check in closeLiquidation
Instead of enforcing a strict grace period check, validate the borrower's health factor before finalizing liquidation.
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.