The LendingPool contract requires borrowers to manually invoke closeLiquidation after repaying their debt during the liquidation grace period. An edge case arises when a borrower repays their debt at the last moment of the grace period but does not have enough time to call closeLiquidation before the grace period expires. This leads to an unintended liquidation, even though the borrower has fully repaid their debt.
Manual Closure of Liquidation Required
Edge Case: The function enforces a strict grace period check:
Problem: If the borrower repays at the last moment of the grace period, the grace period may expire before they manage to call closeLiquidation().
This results in an unfair liquidation, even though the borrower has repaid their debt in full.
The user is flagged for liquidation and provided with a grace period to repay their debt.
The user repays the full debt at the very last moment of the grace period.
The grace period expires immediately after repayment, preventing the borrower from calling closeLiquidation().
As closeLiquidation() cannot be called after the grace period expires, the borrower remains flagged for liquidation even after repayment.
The borrower is unfairly liquidated, as they had no opportunity to remove the liquidation flag.
Unfair Liquidations: Borrowers may be liquidated despite fully repaying their debt due to timing issues.
Loss of Collateral: Borrowers lose their collateral despite having cleared their debt.
closeLiquidation in repayModify the repay function to automatically call **closeLiquidation**if user who is paying debt is already liquidated, which prevents them to call the function twice.
Fix:
closeLiquidationInstead of enforcing a strict grace period check, validate the borrower's health factor before finalizing liquidation, like how its done in intiate liquidation, because user collateral value may get increase, then they don't need to repay any amount
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.