RToken::transfer
get's the current live liquidityIndex
for scaling on transfer amounts, while RToken::transferFrom
relies on the RToken
's global variable _liquidityIndex
The issue that arises is the missmatch between liquidity indexes if RToken::updateLiquidityIndex
hasn't been called. This function needs to be called and manually updated making it at risk of becoming a stale index, while transfer
is always up to date which will lead to different transfer ratios.
Example:
Scaled with current liquidityIndex (1.0537e27)
scaledAmount = 50e18 / 1.0537e27 = 47.45e18
Result:
User1: 50.054 RTokens (scaled up due to accrued interest)
User2: 49.890 RTokens (transfer fee + scaling)
Using transferFrom():
Scaled with stale _liquidityIndex (1e27)
scaledAmount = 50e18 / 1e27 = 50e18
Result:
User1: 50.000 RTokens (no interest accrual applied)
User2: 49.945 RTokens (only transfer fee)
Users can game the system by choosing the more favorable method or get unexpected token amounts
Protocol revenue/accounting affected by inconsistent scaling
Foundry
Change transferFrom
so both functions use getNormalizedIncome
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.