Summary
A user cannot prevent liquidation by depositing nft collateral.
Vulnerability Details
LendingPool.sol#initiateLiquidation() function is as follows.
function initiateLiquidation(address userAddress) external nonReentrant whenNotPaused {
if (isUnderLiquidation[userAddress]) revert UserAlreadyUnderLiquidation();
ReserveLibrary.updateReserveState(reserve, rateData);
UserData storage user = userData[userAddress];
uint256 healthFactor = calculateHealthFactor(userAddress);
if (healthFactor >= healthFactorLiquidationThreshold) revert HealthFactorTooLow();
@> isUnderLiquidation[userAddress] = true;
liquidationStartTime[userAddress] = block.timestamp;
emit LiquidationInitiated(msg.sender, userAddress);
}
Liquidator can trigger liquidation of user's debt which health factor is under liquidation threshold.
And LendingPool.sol#closeLiquidation function allows the user to repay and close liquidation.
function closeLiquidation() external nonReentrant whenNotPaused {
address userAddress = msg.sender;
if (!isUnderLiquidation[userAddress]) revert NotUnderLiquidation();
ReserveLibrary.updateReserveState(reserve, rateData);
if (block.timestamp > liquidationStartTime[userAddress] + liquidationGracePeriod) {
revert GracePeriodExpired();
}
UserData storage user = userData[userAddress];
uint256 userDebt = user.scaledDebtBalance.rayMul(reserve.usageIndex);
if (userDebt > DUST_THRESHOLD) revert DebtNotZero();
isUnderLiquidation[userAddress] = false;
liquidationStartTime[userAddress] = 0;
emit LiquidationClosed(userAddress);
}
But from some reason, he can not repay all debt.
So he wants to push additional collateral or repay partially for preventing liquidation.
But this is impossible.
This implementation is not standard.
Impact
Users suffer from full repayment for preventing liquidation.
Tools Used
Manual review
Recommendations
Add a logic so that a user can repay partially or add collateral to close liquidation.