The current reward calculation in the calculateReward function can lead to distributing more rewards than the intended market.reward. This is a significant issue that compromises the contract's reward distribution mechanism.
The reward for a user is calculated as (amount * market.reward) / market.totalDeposits
.
However, as users redeem, totalDeposits decreases, which affects subsequent reward calculations.
This can lead to over-distribution of rewards, exceeding the market.reward.
Example
Assume market.reward = 1000 RAAC tokens
.
User A deposits 100 tokens, totalDeposits = 100
.
User B deposits 100 tokens, totalDeposits = 200
.
When User A reedems
Reward = (100 * 1000) / 200 = 500 RAAC.
totalDeposits
becomes 100 after redemption.
When User B redeems:
Reward = (100 * 1000) / 100 = 1000 RAAC
.
Total distributed = 500 + 1000 = 1500 RAAC, which exceeds market.reward = 1000 RAAC.
The contract can distribute more RAAC tokens than intended, potentially draining the contract's RAAC balance and violating the reward pool constraints.
In calculateReward (updated):
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.