Core Contracts

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

Wrong check in `updateReserveInterests` function in ReserveLibrary.

Summary

updateReserveInterests function in ReserveLibrary is defined as follows:

function updateReserveInterests(ReserveData storage reserve, ReserveRateData storage rateData) internal {
uint256 timeDelta = block.timestamp - uint256(reserve.lastUpdateTimestamp);
if (timeDelta < 1) {
return;
}
uint256 oldLiquidityIndex = reserve.liquidityIndex;
// @audit: should be `oldLiquidityIndex < WadRayMath.RAY`
if (oldLiquidityIndex < 1) revert LiquidityIndexIsZero();
// Update liquidity index using linear interest
reserve.liquidityIndex =
calculateLiquidityIndex(rateData.currentLiquidityRate, timeDelta, reserve.liquidityIndex);
// Update usage index (debt index) using compounded interest
reserve.usageIndex = calculateUsageIndex(rateData.currentUsageRate, timeDelta, reserve.usageIndex);
// Update the last update timestamp
reserve.lastUpdateTimestamp = uint40(block.timestamp);
emit ReserveInterestsUpdated(reserve.liquidityIndex, reserve.usageIndex);
}

The problem arises because of the following check:

if (oldLiquidityIndex < 1) revert LiquidityIndexIsZero();

This is incorrect as indexes use RAY units, meaning an index of 1 is 1e27.

Impact

The impact of this issue is low as this check doesn't seem strictly necessary. But current check is wrong and doesn't check against the right value.

Tools Used

Manual review.

Recommendations

Make sure to compare oldLiquidityIndex with RAY value:

if (oldLiquidityIndex < 1e27) revert LiquidityIndexIsZero();
Updates

Lead Judging Commences

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

ReserveLibrary::updateReserveInterests compares liquidityIndex against 1 instead of RAY (1e27), potentially allowing severely undervalued indices

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

ReserveLibrary::updateReserveInterests compares liquidityIndex against 1 instead of RAY (1e27), potentially allowing severely undervalued indices

Appeal created

inallhonesty Lead Judge
6 months ago
inallhonesty Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
Assigned finding tags:

ReserveLibrary::updateReserveInterests compares liquidityIndex against 1 instead of RAY (1e27), potentially allowing severely undervalued indices

Support

FAQs

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

Give us feedback!