The calculateRcrvUSDAmount function in StabilityPool uses an incorrect scaling factor formula which would cause users to receive much less RTokens than they should when withdrawing their DETokens, particularly when the tokens have different decimals.
The issue is that this function uses the wrong scaling factor formula compared to the deposit function:
Example with DEToken (6 decimals) and RToken (18 decimals):
When a user deposits 1 RToken and then withdraws their 1 DEToken, they would receive only 0.000001 RToken back instead of their original 1 RToken.
Critical. Users withdrawing from the StabilityPool would receive far less RTokens than they should, effectively losing most of their funds when the tokens have different decimals.
Modify calculateRcrvUSDAmount to use the correct scaling formula:
User deposits 1 RToken (1e18)
Receives 1 DEToken (1e6)
User withdraws 1 DEToken (1e6)
With current code, receives 0.000001 RToken instead of 1 RToken
User has lost 99.9999% of their funds
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.