The transferFrom() function in the RToken contract is intended to scale transfer amounts based on the current liquidity index to reflect accrued interest. However, because the liquidity index (_liquidityIndex) is never updated in RToken.sol and remains fixed at its initial value (1e27), the scaling operation effectively does nothing. As a result, user balances are not correctly adjusted for interest accrual.
Stale Liquidity Index: The _liquidityIndex is set during contract initialization and is meant to be updated by updateLiquidityIndex(). However, this function is never invoked by the LendingPool or any other contract, leaving _liquidityIndex permanently at 1e27.
Ineffective Scaling in transferFrom(): The function attempts to scale the transfer amount by dividing it by _liquidityIndex using rayDiv(), but since _liquidityIndex remains at 1e27, the scaling does not reflect any accrued interest.
Root Cause Code Snippet (RToken.sol):
Affected Code Snippet (RToken.sol):
Run the test below in LendingPool.test.js with command:
Incorrect Balance Transfers: Users’ balances are transferred without proper scaling, which undermines the interest-bearing feature of the RToken.
Accounting Inaccuracies: Downstream functions such as balanceOf() and other transfer-related logic that depend on scaled balances will not accurately represent users’ holdings, jeopardizing the integrity of the lending and borrowing mechanisms.
Manual review, Hardhat
Dynamic Liquidity Index: Instead of relying on the stale _liquidityIndex, the function should fetch the current liquidity index from the reserve pool using getNormalizedIncome(). This ensures that transfers are scaled according to the actual accrued interest.
Update Index Mechanism: Alternatively, ensure that updateLiquidityIndex() is regularly called (for example, via automated triggers or integrated into common user actions) so that _liquidityIndex reflects the current interest conditions.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.