The calculateRaacRewards function in StabilityPool.sol uses mismatched token decimals in its reward calculation formula. The function uses userDeposits (in RToken decimals) and totalDeposits (in deToken decimals) without normalizing their decimal places, leading to significantly incorrect reward calculations when the tokens have different decimal precisions.
The vulnerability exists in the calculateRaacRewards function of the StabilityPool contract:
The core issue arises from using two values with potentially different decimal places in a division operation:
userDeposits[user]: Tracks deposits in RToken decimals
deToken.totalSupply(): Returns total deposits in deToken decimals
The contract explicitly declares support for different decimal places between tokens:
This is further evidenced by decimal normalization in other functions like calculateDeCRVUSDAmount:
However, this critical decimal normalization is missing in the rewards calculation, despite the contract being explicitly designed to handle tokens with different decimals.
For example, if:
RToken has 18 decimals
deToken has 6 decimals
User deposits 100 RTokens (100e18)
Total deposits are 1000 deTokens (1000e6)
Available rewards are 200 RAAC (200e18)
The calculation becomes:
This result is drastically higher than intended because the division uses incompatible decimal scales. The user deposit should first be converted to deToken representation for correct calculation.
Severe miscalculation of user rewards leading to incorrect distributions or dos on withdrawals as the result of rewards will always be higher that the contact RAAC balance and thus a revert when try to withdraw since withdraw do an automatic rewards claim
Users could receive significantly more or fewer rewards than intended
Foundry
Manual Review
Use the deToken balance of the user instead of raw deposit amount to ensure decimal consistency:
This ensures both values in the division operation use the same decimal scale, resulting in correct reward calculations.
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.