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;
if (oldLiquidityIndex < 1) revert LiquidityIndexIsZero();
reserve.liquidityIndex =
calculateLiquidityIndex(rateData.currentLiquidityRate, timeDelta, reserve.liquidityIndex);
reserve.usageIndex = calculateUsageIndex(rateData.currentUsageRate, timeDelta, reserve.usageIndex);
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();