Core Contracts

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

The calculation of debt does not consider the full interest fee, resulting in less debt than expected during liquidation.

Summary

The function LendingPool::closeLiquidation allows users to repay their debt and make their position non-liquidatable.

Vulnerability Details

In the function LendingPool::closeLiquidation, the debt is calculated as follows:

uint256 userDebt = user.scaledDebtBalance.rayMul(reserve.usageIndex);

However, if we analyze how user.scaledDebtBalance is accounted for, it is computed as:
borrowedAmount / index

This method calculates the less than the debt actually the user have let's take with the example,

Let's say user takes a debt of 10,000 tokens, with currentIndex = 1.09,

user.scaledDebtBalance = 10000/1.09 = 9,174.31192

Later when the currentIndex = 1.14 the debt will be ,

currentDebt = 9174.31192 \* 1.14 = 10,458.7155 = 10,000 + 458.71(Interest)

While the actual interest the user has to pay is = (1.14 - 1.09) \* 10,000 = 500(interest)
Hence the calculated Debt(Interest+ debt) will always be less that it should be.

This incorrect calculation also appears in the function:

function getUserDebt(address userAddress) public view returns (uint256) {
UserData storage user = userData[userAddress];
return user.scaledDebtBalance.rayMul(reserve.usageIndex);
}

As a result, even if a position is liquidatable, it may not be liquidated, leading to potential losses for the protocol. As the debt calculated will be less than the real debt.

Impact

The incorrect debt calculation prevents liquidations, allowing undercollateralized positions to remain open, which can lead to protocol insolvency and financial losses. Malicious users may exploit this to accumulate bad debt, putting lenders and liquidity providers at risk.

Tools Used

Manual Review

Recommendations

  • Correct the debt calculation by ensuring that user.scaledDebtBalance is multiplied by the index twice.

Updates

Lead Judging Commences

inallhonesty Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
inallhonesty Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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