Core Contracts

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

Inconsistent scaling in `DebtToken::totalSupply` and `DebtToken::balanceOf`

Summary

The DebtToken::totalSupply and DebtToken::balanceOf functions apply inconsistent scaling directions when adjusting values using getNormalizedDebt(). balanceOf scales up using rayMul, while totalSupply scales down using rayDiv, leading to discrepancies in debt tracking.

Vulnerability Details

Problem description

  • DebtToken::balanceOf applies rayMul(getNormalizedDebt()), scaling up the balance value.

  • DebtToken::totalSupply applies rayDiv(getNormalizedDebt()), scaling down the supply value.

  • This inconsistency results in mismatched debt calculations between individual users and the overall total supply.

Affected Code in DebtToken

function balanceOf(address account) public view override(ERC20, IERC20) returns (uint256)
uint256 scaledBalance = super.balanceOf(account);
// @audit-issue scaling by multiplication
@> return scaledBalance.rayMul(ILendingPool(_reservePool).getNormalizedDebt());
}
function totalSupply() public view override(ERC20, IERC20) returns (uint256) {
uint256 scaledSupply = super.totalSupply();
// @audit-issue scaling by division
@> return scaledSupply.rayDiv(ILendingPool(_reservePool).getNormalizedDebt());
}

Impact

  • Incorrect total supply representation: The total supply does not align with individual balances.

  • Potential accounting errors: Debt tracking mechanisms relying on totalSupply may operate with incorrect values.

  • Inconsistencies in debt calculations: Users may observe discrepancies in their individual debt balances versus the protocol’s overall reported debt.

Tools Used

Manual Review

Recommendations

  1. Use the same scaling operation (rayMul or rayDiv) in both functions to maintain consistency.

  2. Adjust either totalSupply or balanceOf to match the scaling direction of the other.

  3. Verify and test that the sum of individual balances aligns with the total supply.

Updates

Lead Judging Commences

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