Core Contracts

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

DebtToken Contract's totalSupply Function Implementation Issue

Summary

The totalSupply function in the DebtToken contract contains an implementation flaw. Instead of returning the scaled total supply by multiplying the scaled balance with the normalized debt, it incorrectly attempts to divide the total supply by the normalized debt. This error can lead to incorrect calculations in functionality that relies on this result, potentially causing economic losses for users.

Vulnerability Details

The current implementation computes the total supply using division instead of the correct scaling methodology, which involves multiplication. Specifically, it attempts to return scaledSupply.rayDiv(ILendingPool(_reservePool).getNormalizedDebt()) instead of the appropriate scaledBalance.rayMul(ILendingPool(_reservePool).getNormalizedDebt()).

/**
* @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()); // Incorrect implementation
}

Impact

The impact of this vulnerability is significant, as it could lead to users and other dependent contracts making decisions based on erroneously reported total supply values. This could result in economic losses.

Recommendations

The correct implementation should use multiplication as follows:

function totalSupply() public view override(ERC20, IERC20) returns (uint256) {
uint256 scaledBalance = super.totalSupply();
return scaledBalance.rayMul(ILendingPool(_reservePool).getNormalizedDebt()); // Corrected implementation
}
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!