Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: medium
Valid

A user will lose their positions when they cannot prevent liquidation

Summary

The design choice to not allow partial repayment or additional collateral will cause a complete loss of positions for borrowers as liquidators can trigger liquidation without options to restore health factor.

Root Cause

In LendingPool.sol the initiateLiquidation() and closeLiquidation() functions don't provide mechanisms for users to:

  1. Partially repay their debt

  2. Add more collateral
    to prevent liquidation once initiated.

function initiateLiquidation(address userAddress) external nonReentrant whenNotPaused {
if (isUnderLiquidation[userAddress]) revert UserAlreadyUnderLiquidation();
// update state
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);
}
function closeLiquidation() external nonReentrant whenNotPaused {
address userAddress = msg.sender;
if (!isUnderLiquidation[userAddress]) revert NotUnderLiquidation();
// update state
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);
}

Internal pre-conditions

  1. User's health factor needs to be below healthFactorLiquidationThreshold

  2. User must be under liquidation status

  3. User needs full debt repayment to close liquidation

Impact

The borrowers are forced to repay full debt amount to prevent liquidation, which may be impossible in many cases, leading to unnecessary liquidations and loss of collateral.

Mitigation

Add functionality to:

  1. Allow partial debt repayment

  2. Allow additional collateral deposits

  3. Recalculate health factor after these actions

  4. Close liquidation if health factor is restored above threshold

Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

LendingPool::finalizeLiquidation() never checks if debt is still unhealthy

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!