Core Contracts

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

Incorrect Usage Rate Calculation Due to Faulty Debt Total Supply Formula

Summary

A miscalculation in the total borrow amount leads to an incorrect utilization rate and usage rate. The totalSupply function incorrectly divides scaledSupply by usageIndex instead of multiplying by it, resulting in an underestimation of the total debt amount.

Impact

  • The miscalculation affects totalUsage, which is used in determining utilization rate.

  • Utilization rate directly impacts interest rate calculations, leading to incorrect borrowing and lending rates.

Affected Code

function totalSupply() public view override(ERC20, IERC20) returns (uint256) {
uint256 scaledSupply = super.totalSupply();
return scaledSupply.rayDiv(ILendingPool(_reservePool).getNormalizedDebt()); // Incorrect calculation
}

Attack Scenario

  1. A user borrows a significant amount, increasing the debt.

  2. The system underestimates the total debt amount due to incorrect division.

  3. Utilization rate appears lower than it actually is, leading to artificially low borrowing rates.

  4. The attacker benefits from lower interests.

Recommended Fix

Modify the totalSupply function to correctly multiply by usageIndex instead of dividing:

function totalSupply() public view override(ERC20, IERC20) returns (uint256) {
uint256 scaledSupply = super.totalSupply();
return scaledSupply.rayMul(ILendingPool(_reservePool).getNormalizedDebt()); // Correct calculation
}

This ensures proper tracking of the total debt, leading to accurate utilization and interest rate calculations.

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!