Core Contracts

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

Double Interest Calculation in DebtToken Leads to Overstated Debt

Summary

The DebtToken's mint function incorrectly calculates interest by using an already interest-adjusted balance to compute additional interest, leading to overstated debt amounts due to compound interest being applied twice.

Vulnerability Details

The mint() function on DebtToken compounds interest twice:

  1. This already includes interest adjustment

uint256 amountScaled = amount.rayDiv(index);
  1. calculates interest again using already adjusted balance

if (_userState[onBehalfOf].index != 0 && _userState[onBehalfOf].index < index) {
balanceIncrease = scaledBalance.rayMul(index) - scaledBalance.rayMul(_userState[onBehalfOf].index);
}
  1. mints the inflated amount:

uint256 amountToMint = amount + balanceIncrease;
_mint(onBehalfOf, amountToMint.toUint128());

Example scenario:

Initial State:

  • User has 100 debt tokens

  • Old index = 1.0

  • New index = 1.5
    Current Implementation:

  1. scaledBalance = balanceOf():

    • Returns 100 1.5 = 150 (already includes interest)

  2. balanceIncrease calculation:

    • 150*1.5 = 225 (applies interest again)

    • 150*1.0 = 150

    • balanceIncrease = 225 - 150 = 75

  3. New debt = 100 + 75 = 175

    • mints 175 debtToken

Should Be:
* Use unscaled balance (100)
* balanceIncrease = (100 1.5) - (100 1.0) = 50
* New debt = 100 + 50 = 150

Impact

Users accrue significantly more debt than they should because the contract applies interest calculations twice on the same balance, leading to inflated debt positions and potentially unfair liquidations.

Tools Used

Manual Review

Recommendations

Use unscaled balance for interest calculations

Updates

Lead Judging Commences

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

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

inallhonesty Lead Judge about 2 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.