The MarketCreator contract implements a market system where users can deposit quote assets and receive RAAC token rewards after a lock period. The reward distribution is proportional to the user's deposit amount relative to the total deposits in the market.
The redeemFromMarket() function contains a critical flaw in its reward distribution mechanism. When users redeem their positions, the function calculates rewards based on the current total deposits but fails to decrease the market's reward pool. This means that subsequent redemptions will calculate rewards using the original reward amount against a decreased total deposit amount, leading to inflated rewards for later redeemers.
The root cause lies in the calculateReward() function, which uses the full market.reward amount for each redemption calculation without accounting for previously distributed rewards. This creates a scenario where the last user to redeem could receive disproportionately large rewards.
High. This vulnerability can lead to significant economic implications:
Unfair distribution of rewards, where later redeemers receive more tokens than they should
Potential depletion of the contract's RAAC token balance beyond intended amounts
Possible denial of service for later redeemers if the contract runs out of RAAC tokens
High. This issue will manifest every time multiple users redeem from the same market with non-zero rewards, making it a frequently occurring problem under normal operation conditions.
Consider a market with the following parameters:
Total RAAC reward: 100 tokens
Alice and Bob each deposit 50 quote tokens
Total deposits: 100 quote tokens
Sequence of events:
Alice redeems first:
calculateReward() returns: (50 * 100) / 100 = 50 RAAC tokens
totalDeposits reduces to 50
Bob redeems second:
calculateReward() returns: (50 * 100) / 50 = 100 RAAC tokens
Total rewards distributed: 150 RAAC tokens (50 + 100)
The intended distribution should have been 50 RAAC tokens each, totaling 100 RAAC tokens.
Update the redeemFromMarket() function to decrease the market's reward pool after each redemption:
This solution ensures that rewards are calculated based on the remaining reward amount, maintaining fair distribution among all participants.
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.