Users attempting to withdraw their full balance of reserve tokens may fail to fully redeem all RTokens due to a scaling mismatch between the queried balance and the actual balance at burn time. This issue arises because the liquidity index is likely to increase between the time a user queries their balance and when the withdrawal is executed, resulting in a small residual dust amount that remains in their balance. This forces users to either manually overshoot their withdrawal request or repeatedly withdraw smaller amounts to eliminate dust, leading to poor user experience and inefficiencies.
The issue occurs in LendingPool.withdraw()
, which burns RTokens based on the user’s input amount:
Users typically query their balance using balanceOf()
before initiating a withdrawal. However, balanceOf()
scales up the user’s balance using the liquidity index at the time of querying, which may differ from the index used when burning RTokens:
Later, in RToken.burn()
, the contract ensures users cannot burn more than their updated balance:
Since balanceOf(from)
now uses an updated liquidity index, the user's originally queried balance (from an earlier index) is lower than the real-time balance, causing a mismatch. This results in a small unburned dust balance remaining in the user’s account.
Users Cannot Fully Withdraw Their Funds
Users attempting to withdraw their entire balance may always leave a small dust amount unless they manually adjust for scaling.
Repeated Transactions Needed to Eliminate Dust
Users must manually repeat withdrawals or overshoot their input to clear their balance, causing inefficiencies.
Degraded UX and Poor Protocol Design
Users unfamiliar with liquidity index scaling may assume the contract is malfunctioning when their full balance is not withdrawable.
Manual
With onlyValidAmount
visibility in withdraw()
, implementing the following function will be the best and cleanest 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.