The RToken
minting and burning dynamics are forked from AAVE, and allow these tokens to automatically calculate deposit interests. This is done by scaling and normalizing the amounts to mint and burn based on deposit indexes. The RToken
is combined with the DebtToken
to allow dynamic calculations of borrowing and deposit rates, however, deposit rates are calculated based on linear interest, whereas borrowings are calculated with compounding interest. Because of this when depositing, borrowing, and repaying, there are scenarios where repayments will be higher than what depositors will take in as interest, which allows for extra RTokens
to accumulate in the contract. This is why the protocol has added the transferAccruedDust
function to prevent stuck funds. However, this function does not properly carry out scaling and normalization leading to invalid returns.
Let's look at what the calculateDustAmount()
function is doing:
First, we take the contract balance, excluding any accrued deposit interests, and then we take the totalSupply
, which returns the normalized total supply of RTokens
. Scaling the contractBalance
and doing the second rayMul
on the already normalized amount is incorrect, as it over-inflates the amount. Because of this, the function will never transfer the full dust amount and there will always be leftovers.
Broken dust withdrawal functionality.
Manual review
Do not double scale the RToken
total supply and the curvUSD
balance.
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.