Obedient Lava Monkey
Medium
A lack of a zero-check for totalLiquidity
in cumulateToLiquidityIndex
will cause a transaction revert for protocol users, as the function will attempt to divide by zero during liquidity index updates.
In ReserveLogic.sol, the amount.wadToRay().rayDiv(totalLiquidity.wadToRay())
computation does not check if totalLiquidity
is zero, resulting in a revert.
- The reserve must have
totalLiquidity
set to exactly0
(e.g., during initialization or if fully drained). - A function invoking
cumulateToLiquidityIndex
(e.g., fee accumulation) must be called.
- No liquidity providers have deposited into the reserve, or all liquidity has been withdrawn.
- Any user or external contract calls a function that attempts to accumulate income to the liquidity index.
- The call triggers
cumulateToLiquidityIndex
, which attempts to divideamount
bytotalLiquidity
. - As
totalLiquidity
is zero, the transaction reverts, halting the operation.
The protocol functionality halts, preventing fees (e.g., flash loan fees) from being distributed and disrupting reserve operations. No direct loss occurs, but user actions dependent on this functionality (e.g., supply or withdrawal) are blocked.
Add a guard condition to ensure totalLiquidity
is non-zero before performing the division.