Core Contracts

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

Unnecessary double scaling leads to potential amount errors

Summary

Unnecessary double scaling leads to potential amount errors.

Vulnerability Details

// Calculate the user's debt (for the onBehalfOf address)
uint256 userDebt = IDebtToken(reserve.reserveDebtTokenAddress).balanceOf(onBehalfOf);
uint256 userScaledDebt = userDebt.rayDiv(reserve.usageIndex);
// If amount is greater than userDebt, cap it at userDebt
uint256 actualRepayAmount = amount > userScaledDebt ? userScaledDebt : amount;
uint256 scaledAmount = actualRepayAmount.rayDiv(reserve.usageIndex);

In the _repay function, the code performs an unnecessary second scaling operation after calculating the actualRepayAmount. This happens because the debt amount (userScaledDebt) is already adjusted for the reserve.usageIndex, and applying another rayDiv(reserve.usageIndex) to actualRepayAmount leads to a double scaling issue.

The double scaling could result in incorrect repayment amounts, potentially causing underpayments or overpayments depending.

Impact

Tools Used

Manual review

Recommendations

Remove the redundant scaling step (scaledAmount = actualRepayAmount.rayDiv(reserve.usageIndex)) from the code.

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

LendingPool::_repay double scales the debt

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

LendingPool::_repay double scales the debt

Support

FAQs

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