In the contract contracts/core/pools/StabilityPool/MarketCreator.sol , functions redeemFromMarket() and calculateReward
The market.reward amount is not updated after a successful Redeemed event
This issue will case
Unfair rewards distribution
Pool's RAAC token drained -- because the total rewards to the participants will exceed the number when a Market created
High
After the redeemFromMarket, the contract didn't update the latest market.rewards balance within the market.
This will cause the calculateReward() function using the same (wrong) market.reward number to calcuate rewards everytime.
A quick examaple to demonstrate this:
Given a Market with total reward 300 RAAC
Users Alice, Bob, Cindy deposits 100 USDC each (300 USDC in total)
In a fair condition, the RAAC rewards distribution should be 100 RAAC tokens to Alice, Bob, Cindy each.
However, based on the contract's calculations, the redeems will become the following:
Alice redeem
Reward: 100 * 300 / 300 = 100 RAAC Token
market.totalDeposits = 200 USDC
Bob redeem:
Reward: 100 * 300 / 200 = 150 RAAC (50 RAAC tokens more)
market.totalDeposits = 100 USDC
Cindy redeem:
Reward: 100 * 300 / 100 = 300 RAAC (200 RAAC tokens more)
market.totalDeposits = 0 USDC
The total RAAC token rewards are 100+150+200 = 450 RAAC tokens, which is more than the assumption 300 RAAC tokens.
A successful attack could result shows the following
Incorrect rewards distribution -- Being the last one the redeem and get the highest RAAC tokens
By doing this repeatively, an attacker could drain the RAAC Pool
Manual review
To solve the issue, using the actual reward balance to calculate the rewards
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.