Core Contracts

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

Incorrect return value in `ReserveLibrary::getNormalizedDebt` when timeDelta is zero

Summary

The ReserveLibrary::getNormalizedDebt function incorrectly returns reserve.totalUsage instead of reserve.usageIndex when timeDelta < 1. This leads to inaccurate calculations for normalized debt, potentially affecting borrowing and repayment logic.

Vulnerability Details

Problem description

  • The function getNormalizedDebt is designed to calculate the normalized debt based on the reserve’s state.

  • When timeDelta < 1, the function returns reserve.totalUsage, which is incorrect.

  • The correct return value should be reserve.usageIndex, as usageIndex represents the normalized debt scaling factor.

  • This issue can lead to incorrect debt calculations and affect lending protocol operations.

Affected Code in getNormalizedDebt

/**
* @notice Gets the normalized debt of the reserve.
* @param reserve The reserve data.
* @return The normalized debt (in underlying asset units).
*/
function getNormalizedDebt(ReserveData storage reserve, ReserveRateData storage rateData) internal view returns (uint256) {
uint256 timeDelta = block.timestamp - uint256(reserve.lastUpdateTimestamp);
if (timeDelta < 1) {
return reserve.totalUsage; // @audit-issue should return `reserve.usageIndex` not `reserve.totalUsage`
}
return calculateCompoundedInterest(rateData.currentUsageRate, timeDelta).rayMul(reserve.usageIndex);
}

Steps to reproduce

  1. Call getNormalizedDebt when timeDelta < 1.

  2. Observe that the function returns reserve.totalUsage instead of reserve.usageIndex.

  3. Confirm that reserve.usageIndex is the correct scaling factor for normalized debt.

Impact

Inaccurate debt calculations: Borrowers and lenders are affected due to incorrect debt tracking.

Tools Used

Manual Review

Recommendations

  1. Change the return value when timeDelta < 1 to reserve.usageIndex.

  2. Verify that the usageIndex is correctly updated in other parts of the contract.

  3. Test the function to ensure proper calculations of normalized debt.

Updates

Lead Judging Commences

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

getNormalizedDebt returns totalUsage (amount) instead of usageIndex (rate) when timeDelta < 1, breaking interest calculations across the protocol

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

getNormalizedDebt returns totalUsage (amount) instead of usageIndex (rate) when timeDelta < 1, breaking interest calculations across the protocol

Support

FAQs

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