In the finalizeLiquidation function of the LendingPool contract, if the value of the liquidated NFTs exceeds the debt owed by the user, the excess value is not returned to the user. Instead, any surplus collateral is transferred to the stabilityPool, leading to potential financial loss for over-collateralized users.
The current implementation of finalizeLiquidation does not check if the total value of the liquidated NFTs exceeds the user's debt. As a result, any excess collateral is not refunded to the user but is instead transferred to the stabilityPool. While the liquidation process ensures the user’s debt is cleared, it lacks a mechanism to return surplus collateral.
Excess collateral can arise in two ways between the initiation and finalization of liquidation. If the value of an NFT increases after liquidation has started but before it is finalized, the position could become over-collateralized again. However, the contract does not account for this increase and still liquidates the NFTs. Additionally, there is no restriction preventing a user from depositing new NFTs after liquidation has been initiated. The depositNFT function lacks a check to prevent deposits when a user is flagged for liquidation. As a result, newly deposited NFTs can be lost, as they are transferred to the stabilityPool upon liquidation, even if they were sufficient to restore a healthy collateral position.
depositNFT Function:Since the function does not verify whether the user is in isUnderLiquidation mode, users can deposit new NFTs, which will be lost upon liquidation.
finalizeLiquidation Function:PoC
Add the following test to test/unit/core/pools/LendingPool/LendingPool.test.js.
A test demonstrating that an increase in NFT price after liquidation starts does not prevent liquidation
and does not refund excess value.
Over-collateralized users risk losing excess value since the liquidation process does not refund surplus collateral. The stability pool benefits at the expense of liquidated users, reducing fairness in the system. NFTs deposited after liquidation begins are lost without benefiting the user.
To address these issues, calculate and refund any excess value before liquidating the user's NFTs. This can be achieved by summing the value of all NFTs and returning any surplus beyond the debt owed. Additionally, prevent deposits during liquidation by adding a check in depositNFT to revert if isUnderLiquidation[userAddress] is true. Lastly, improve liquidation logic by re-evaluating collateral before liquidation is executed. By implementing these changes, the liquidation process will be more fair and transparent, ensuring that users do not lose excess collateral unnecessarily.
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.