Core Contracts

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

Incorrect Return Value in burn Function Leads to Liquidity and Interest Rate Miscalculations

Summary

The burn function of the RToken contract returns (amount, totalSupply(), amount), but it should return (amountScaled, totalSupply(), amount) to correctly reflect the scaled value in the first return parameter. This discrepancy can lead to miscalculations in liquidity and interest rate adjustments within the withdraw function of the ReserveLibrary.

Vulnerability Details

In the burn function of the RToken contract:

return (amount, totalSupply(), amount);

The first return value is expected to be the scaled amount, which is calculated using:

uint256 amountScaled = amount.rayMul(index);

However, the function incorrectly returns amount instead of amountScaled.

This incorrect return value propagates to withdraw in ReserveLibrary:

(
uint256 burnedScaledAmount,
uint256 newTotalSupply,
uint256 amountUnderlying
) = IRToken(reserve.reserveRTokenAddress).burn(
recipient,
recipient,
amount,
reserve.liquidityIndex
);

Here, burnedScaledAmount is assigned the first return value of burn, which is incorrect because it should represent the scaled value of amount.

This mistake leads to inconsistencies when updating total liquidity and interest rates, as these calculations depend on scaled values. As a result, the system may miscalculate available liquidity, interest accruals, and borrowing rates, potentially leading to incorrect fund distributions and imbalances in the lending pool.

Impact

  • Incorrect liquidity tracking: The lending pool may not correctly account for the liquidity being withdrawn, leading to inaccurate liquidity calculations.

  • Incorrect interest rate adjustments: Since scaled values are used for interest rate calculations, the mistake can cause improper rate updates, affecting both lenders and borrowers.

  • Potential fund misallocations: If future computations rely on the incorrect burnedScaledAmount, users withdrawing funds may receive incorrect amounts.

Tools Used

Manual code review

Recommendations

Modify the return statement in burn to return amountScaled in the first position:

return (amountScaled, totalSupply(), amount);
Updates

Lead Judging Commences

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

RToken::burn returns incorrect underlying asset amount (amount instead of amountScaled), leading to wrong interest rate calculations

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

RToken::burn returns incorrect underlying asset amount (amount instead of amountScaled), leading to wrong interest rate calculations

Support

FAQs

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