Core Contracts

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

Incorrect DebtToken::totalSupply Calculation

01. Relevant GitHub Links

02. Summary

The totalSupply() function in DebtToken returns the wrong total supply because it uses rayDiv instead of rayMul. This leads to an incorrect result when the actual intention is to scale the supply upwards by getNormalizedDebt(). As a result, any logic depending on this total supply value—such as updating reserve.totalUsage in the lending pool—receives invalid data.

03. Vulnerability Details

/**
* @notice Returns the scaled total supply
* @return The total supply (scaled by the usage index)
*/
function totalSupply() public view override(ERC20, IERC20) returns (uint256) {
uint256 scaledSupply = super.totalSupply();
return scaledSupply.rayDiv(ILendingPool(_reservePool).getNormalizedDebt());
}

super.totalSupply() already returns a scaled amount. To get the correct total supply, it should multiply by getNormalizedDebt() rather than dividing by it.

The returned total supply becomes incorrect, which cascades into other functions (such as mint and burn return values) and distorts how reserve.totalUsage is determined in the lending pool contract.

04. Impact

  • Incorrect Accounting: Any calculation relying on DebtToken::totalSupply() is skewed.

  • Misleading Reserve Data: The lending pool’s reserve.totalUsage uses a wrong total supply and may trigger logic errors related to interest rate calculations or debt thresholds.

  • Possible Financial Mismatch: Over time, improper debt or interest calculations can lead to financial imbalances and affect user positions.

05. Tools Used

Manual Code Review and Foundry

07. Recommended Mitigation

/**
* @notice Returns the scaled total supply
* @return The total supply (scaled by the usage index)
*/
function totalSupply() public view override(ERC20, IERC20) returns (uint256) {
uint256 scaledSupply = super.totalSupply();
- return scaledSupply.rayDiv(ILendingPool(_reservePool).getNormalizedDebt());
+ return scaledSupply.rayMul(ILendingPool(_reservePool).getNormalizedDebt());
}
Updates

Lead Judging Commences

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

DebtToken::totalSupply incorrectly uses rayDiv instead of rayMul, severely under-reporting total debt and causing lending protocol accounting errors

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

DebtToken::totalSupply incorrectly uses rayDiv instead of rayMul, severely under-reporting total debt and causing lending protocol accounting errors

Support

FAQs

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

Give us feedback!