This is due to the improper calculations in the RToken::calculateDustAmount function
As seen here, the transferAccruedDust function depends on the calculateDustAmount to properly calculate the dust amount of asset token. As we take a look at the function, we find this:
The function scales asset amount as well as the total supply of RTokens. This is useless and even leads to improper calculation at the end, since the totalSupply function returns the total supply of RTokens denominated in assets and scaling both values again will lead to calculation that is way off the actual amount of dust accrued
This leads to improper calculations every time when ILendingPool(_reservePool).getNormalizedIncome() is different than 1 Ray and may even lead to users being unable it withdraw funds in some very extreme conditions where everybody withdraw their funds from the protocol
Manual Review
Don't call the rayMul on totalRealBalance as it is already denominated in asset token as seen here:
and don't call rayDiv on the total balance of assets, since it is denominated in assets.
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.