Core Contracts

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

The `amountMinted` should be add to `user.scaledDebtBalance` state instead of `scaledAmount` in the `LendingPool::borrow` function

Vulnerability Details

In the DebtToken::mint function, there is a calculation for balanceIncrease, and this variable is added to the amount. Therefore, scaledAmount and amountMinted are not necessarily the same. As a result, amountMinted should be added to user.scaledDebtBalance state here.

Impact

This can lead to incorrect calculations.

Tools Used

Manual review.

Recommendations

Make the following changes to the LendingPool::borrow function.

uint256 scaledAmount = amount.rayDiv(reserve.usageIndex);
// Mint DebtTokens to the user (scaled amount)
(bool isFirstMint, uint256 amountMinted, uint256 newTotalSupply) = IDebtToken(reserve.reserveDebtTokenAddress).mint(msg.sender, msg.sender, amount, reserve.usageIndex);
// Transfer borrowed amount to user
IRToken(reserve.reserveRTokenAddress).transferAsset(msg.sender, amount);
- user.scaledDebtBalance += scaledAmount;
+ user.scaledDebtBalance += amountMinted;
Updates

Lead Judging Commences

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

LendingPool::borrow tracks debt as user.scaledDebtBalance += scaledAmount while DebtToken mints amount+interest, leading to accounting mismatch and preventing full debt repayment

Support

FAQs

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