The RToken contract stores user balances in a scaled form based on a liquidity index but fails to correctly adjust the reported balances in its balanceOf
and totalSupply
functions. As a result, users see significantly lower balances than expected, which can lead to incorrect fund distributions during withdrawals.
The RToken contract is designed to store balances in a scaled form using a liquidity index. In the _update
function, the amount is scaled by dividing by the current normalized income:
Then, the balanceOf
and totalSupply
functions should convert the stored scaled values back to actual balances by multiplying by the current liquidity index:
Due to an implementation error, the actual adjustments are not being correctly applied. Consequently, users see the raw scaled balances rather than the properly adjusted actual balances.
Initial Deposit:
A user deposits 100 crvUSD when the liquidity index is 1e27 (RAY).
The _update
function scales the amount as follows:
Expected Behavior:
The actual balance should be recovered by multiplying the scaled balance by the liquidity index:
Actual Behavior:
Due to missing or incorrect index adjustment, balanceOf(user)
erroneously returns approximately 1e-7 tokens, which is far lower than the expected 100 tokens.
Index Increase:
Later, the liquidity index increases to 1.1e27.
Expected Actual Balance:
Actual Behavior:
The system still reports the balance as the raw scaled value (≈1e-7 tokens), ignoring the updated liquidity index.
Withdrawal Attempt:
When the user attempts to withdraw tokens, the incorrect balance causes the system to miscalculate the withdrawal amount, leading to significant underpayment.
Users see drastically lower token balances than they should, leading to potential financial losses during withdrawals.
Manual Review
Ensure that the balanceOf
and totalSupply
functions properly apply the liquidity index when converting stored scaled balances to actual balances. Verify the implementation of rayDiv
and rayMul
functions and ensure they are used consistently in all balance-related operations. The intended functions should look like this:
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.