The process of liquidation in LendingPool.sol:
Anyone can call initiateLiquidation()
if a user's health factor is below the threshold, it will trigger isUnderLiquidation[address(userA)] = true
Then there is a period when a user can repay his debt, or another user can repay the debt by calling repayOnBehalf()
Then the user needs to call closeLiquidation()
to trigger isUnderLiquidation[address(userA)] = false
and been removed from the state of liquidation
The issue here is that a userB can repay on behalf of userA, but the userA can still be liquidated as there is no check of his current debt in finalizeLiquidation()
A user can repay his debt but still be liquidated, and the issue is that there is no way for userB to call closeLiquidation()
for userA as it checks only for msg.sender.
There is a function repayOnBehalf()
It allows a user to repay the debt of another one, but there is no way to cancel the liquidation process unless it's the user in liquidation who calls it. There could be gatekeeper services for users to subscribe to avoid any liquidation in case of a market move, but those services would be useless if another account cannot call closeLiquidation()
on behalf of users. The presence of repayOnBehalf()
shows that it's something who have been thought about but is not working in the end
userA deposit nft, borrow X amount
userA subscribes to external insurance against liquidation, let's call it userB
userB sees that userA enter liquidation state because of market price movement
userB repayOnBehalf()
of userA
userA does not have access to the internet at the moment and cannot closeLiquidation()
userA gets liquidated even though his healthFactor > healthFactorLiquidationThreshold
A user can be unfairly liquidated and the function repayOnBehalf()
will not work as it should, i.e avoid liquidation of certain users in case of big market movement.
Manual
it should be possible to call closeLiquidation()
on behalf of a user
finalizeLiquidation()
should check healthFactor :
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.