The current implementation allows users to clear their debts to a point below or equal to a defined DUST_THRESHOLD within a grace period. However, if a user successfully repays their debt but fails to call the closeLiquidation() function before the grace period expires (possibly due to timeout), they may remain queued for liquidation. This causes issues downstream.
Users have grace period within which they can close liquidation after paying their debt to below or equal to DUST_THRESHOLD:
However, their is a chance that a user can repay their whole debt but just before they call closeLiquidation(), their grace period elapses blocking them from existing the liquidation train.
Now an issue comes when the liquidateBorrower() is invoked on a user.
Notice that if the userDebt is 0, this operation will revert.
Now we have a situation where a user has no debt but is still queued for liquidation. This becomes a problem in the following manner:
Scenario:
Alice has cleared her debt i.e userDebt == 0 but is till staged for liquidation as time ran out before she could opt out.
When a manager or owner tries to liquidate her, this fails.
Also, the borrow() & withdrawNFT() functions both have this check:
This means that Alice cannot take any loans or withdraw her NFTS.
The result is, a user remains unable to take loans, and their NFTs remain stuck in the contract. This is total loss.
Manual Review
Implement a check in the liquidateBorrower() function to ensure that users who have cleared their debts are removed from the liquidation queue.
1.Add a new function in the LendingPool contract to reset the liquidation status and start time
2.Modify the liquidateBorrower() function in the StabilityPool contract to call this new function:
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.