The RToken
contract implements an interest-bearing token for the RAAC lending protocol. However, there is an inconsistency in the interest calculation between the transfer
and transferFrom
functions. While transfer
uses the real-time normalized income from the ILendingPool
contract to scale token amounts, transferFrom
uses a fixed _liquidityIndex
. This inconsistency can lead to users losing accrued interest when using transferFrom
, as the fixed index may not reflect the latest interest rates.
The transfer
function scales the amount
using ILendingPool(_reservePool).getNormalizedIncome()
, which is a real-time value representing the current liquidity index (cumulative interest).
This ensures that the transferred amount is adjusted based on the latest interest rates, preventing users from losing accrued interest.
The transferFrom
function scales the amount
using _liquidityIndex
, which is a fixed value representing the liquidity index at the time of the last update.
If _liquidityIndex
is not updated frequently, users may lose accrued interest when using transferFrom
, as the scaling does not reflect the latest interest rates.
add the following test case into RToken.test.js
run npx hardhat test --grep "call transferFrom will lost interest"
After calling transferFrom, the scaledBalance is much smaller than expected.
Loss of Accrued Interest: Users who rely on transferFrom
to transfer tokens may lose a portion of their accrued interest if _liquidityIndex
is outdated.
Inconsistent Behavior: The inconsistency between transfer
and transferFrom
can lead to confusion and unexpected results for users.
The impact is High, the likelihood is High, so the severity is High.
Manual Review
Consider following fix:
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.