The StabilityPool contract contains an incorrect scaling factor calculation in the calculateRcrvUSDAmount function, which is used when converting deTokens back to rTokens during withdrawals. This leads to incorrect token conversion calculations and potential value loss for users.
The StabilityPool implements two conversion functions for depositing and withdrawing:
The issue is that calculateRcrvUSDAmount uses an incorrect inverse scaling factor. For the conversion to be symmetrical:
Both functions should use the same scaling factor
The withdrawal function should multiply by exchange rate and divide by the same scaling factor
Instead, it uses a different scaling factor that doesn't properly reverse the deposit calculation
In the calculation the output will have the following decimals 2* deTokenDecimals - rTokenDecimals instead of rTokenDecimals.
This vulnerability results in:
Incorrect conversion of deTokens back to rTokens during withdrawals
Users receiving wrong amounts when withdrawing
Manual Review
Fix the scaling factor:
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.