The calculateRcrvUSDAmount function incorrectly computes the scaling factor when converting between deCRVUSD and rCRVUSD.
The scaling factor is calculated as:
This formula incorrectly applies the decimal adjustment, leading to incorrect conversion values. The correct formula should be:
This ensures that deCRVUSD is correctly scaled down or up to match rCRVUSD's decimal precision.
Assume:
deTokenDecimals = 6
rTokenDecimals = 18
deCRVUSDAmount = 1,000,000
getExchangeRate() = 2
With the incorrect formula:
Thus, the incorrect formula may result in zero or massively inflated values, depending on the token pair.
Users may receive incorrect rCRVUSD amounts upon withdrawal, leading to financial losses.
If the result is rounded to zero, withdrawals will fail for small amounts.
If the result is too high, it could drain the contract’s rCRVUSD balance.
Manual review
Update the formula to:
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.