calculateRcrvUSDAmount is implemented incorrectly when the 2 tokens have different decimals. Depending which has more, there are 2 outcomes - users lose funds and receive nothing or user withdrawals are DoS'd
When depositing in a stability pool, a decimal correction is performed to account for differences between rToken and deToken
There is the reverse conversion when initiating a withdrawal via calculateRcrvUSDAmount.
However the latter formula is implemented incorrectly.
Let's observe a case where rToken has 18 decimals and deToken has 6. Depositing 1e18 rToken would yield 1e6 deToken. If we attempt a withdrawal the conversion in calculateRcrvUSDAmount will round down to 0 since scalingFactor = 10**(18 + 18 - 6) = 1e30 whereas deCRVUSDAmount * exchangeRate = 1e24. Execution will continue, user's deToken will be burnt and they will receive nothing in return.
Let's check the reverse case - rToken has 6 decimals and deToken has 18. Depositing 1e6 rToken would yield 1e18 deToken. If we attempt to withdraw our 1e6 deToken calculateRcrvUSDAmount will return 1e18 * 1e18 / 1e6 = 1e30 rTokens to be received. This withdraw will not go through and will end up reverting due to this check
Permanent loss of funds, DoS
Rewrite the scaling factor calculation in calculateRcrvUSDAmount.
Both tokens have 18 decimals. Info
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.