Core Contracts

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

No check if the new liquidityIndex < 1 and breaks invariant

Summary

The ReserveLibrary::updateReserveInterests performs a check to see if if oldLiquidityIndex < 1 but doesn't perform this check again after the index has been updated

Vulnerability Details

The ReserveLibrary::updateReserveInterests performs a check to see if if oldLiquidityIndex < 1 but doesn't perform this check again after the index has been updated. It should perform this check again after updating the liquidIndex to make sure the invariant of the liquidityIndex not being less than 1 isn't broken.

Impact

The updated liquidityIndex might break the invariant of the liquidityIndex not being less than 1

Tools Used

Manual review

Recommendations

/**
* @notice Updates the liquidity and usage indices of the reserve.
* @dev Should be called before any operation that changes the state of the reserve.
* @param reserve The reserve data.
* @param rateData The reserve rate parameters.
*/
function updateReserveInterests(ReserveData storage reserve,ReserveRateData storage rateData) internal {
uint256 timeDelta = block.timestamp - uint256(reserve.lastUpdateTimestamp);
if (timeDelta < 1) {
return;
}
uint256 oldLiquidityIndex = reserve.liquidityIndex;
if (oldLiquidityIndex < 1) revert LiquidityIndexIsZero();
// Update liquidity index using linear interest
reserve.liquidityIndex = calculateLiquidityIndex(
rateData.currentLiquidityRate,
timeDelta,
reserve.liquidityIndex
); // @audit no check if the new liquidityIndex < 1
// Update usage index (debt index) using compounded interest
reserve.usageIndex = calculateUsageIndex(
rateData.currentUsageRate,
timeDelta,
reserve.usageIndex
);
+ if (reserve.liquidityIndex < 1) revert LiquidityIndexIsZero();
// Update the last update timestamp
reserve.lastUpdateTimestamp = uint40(block.timestamp);
emit ReserveInterestsUpdated(reserve.liquidityIndex, reserve.usageIndex);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Out of scope

Support

FAQs

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