The rewards distribution mechanism in StabilityPool incorrectly calculates user rewards based on rToken deposits instead of deToken holdings. This leads to an unfair allocation of rewards, disproportionately benefiting users who deposit more rToken rather than those who hold more deToken, which is the correct metric for rewards distribution.
When users deposit rToken, they receive deToken based on a predefined exchange rate (e.g., 1 deToken per 2 rToken).
The contract currently calculates user rewards as:
https://github.com/Cyfrin/2025-02-raac/blob/89ccb062e2b175374d40d824263a4c0b601bcb7f/contracts/core/pools/StabilityPool/StabilityPool.sol#L252
where userDeposit is the rToken amount deposited by the user, and totalDeposits is the total supply of deToken.
exchangeRate is 2
User A deposits 100 rToken, receiving 50 deToken.
User B deposits 900 rToken, receiving 450 deToken.
Total rewards = 100.
Total deToken supply = 500.
User A’s reward: 100 * 100 / 500 = 20
User B’s reward: 900 * 100 / 500 = 180
The total reward is 100 but 200 share.
Incorrect reward distribution
Manual code review.
Update the reward calculation formula to be based on deToken holdings:
User A’s reward: 50 * 100 / 500 = 10
User B’s reward: 450 * 100 / 500 = 90
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.