Core Contracts

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

Improper Debt Scaling in `mint` Function Can Cause Debt Inflation and System Instability

The mint function is responsible for issuing new debt tokens, ensuring that a borrower’s debt balance is accurately tracked while incorporating interest accrual via a usage index. However, the function incorrectly scales debt amounts due to improper order of operations when calculating amountToMint. Specifically, the function calculates amountScaled using amount.rayDiv(index), but then adds an unscaled balanceIncrease directly to amountToMint, leading to an overestimation of debt issuance. Below is the relevant code snippet:

uint256 amountScaled = amount.rayDiv(index);
if (amountScaled == 0) revert InvalidAmount();
uint256 scaledBalance = balanceOf(onBehalfOf);
bool isFirstMint = scaledBalance == 0;
uint256 balanceIncrease = 0;
if (_userState[onBehalfOf].index != 0 && _userState[onBehalfOf].index < index) {
balanceIncrease = scaledBalance.rayMul(index) - scaledBalance.rayMul(_userState[onBehalfOf].index);
}
_userState[onBehalfOf].index = index.toUint128();
uint256 amountToMint = amount + balanceIncrease; // @audit Incorrect scaling: `amount` is in raw units, while `balanceIncrease` is interest-adjusted

This results in amountToMint being larger than it should be, meaning that:

  1. More debt tokens are minted than the borrower actually borrowed.

  2. The borrower’s recorded debt becomes inflated, leading to incorrect accounting of total outstanding debt.

  3. Over time, the protocol accumulates unintended excess debt, increasing systemic risk.

Impact

Debt balances become overestimated, leading to inflation of the total supply of debt tokens.

Mitigation

Ensure amountToMint correctly accounts for scaling by applying rayDiv(index) consistently to both amount and balanceIncrease before summing them.

Updates

Lead Judging Commences

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

DebtToken::mint miscalculates debt by applying interest twice, inflating borrow amounts and risking premature liquidations

Support

FAQs

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

Give us feedback!