The claimRewards
function in the FeeCollector
contract has a logical flaw that prevents users from claiming their fair share of rewards over multiple distribution periods. Specifically, the function sets userRewards[user]
to totalDistributed
after a claim, which incorrectly assumes the user has claimed all rewards up to the current totalDistributed
. This results in users losing their share of rewards distributed between claims.
In the claimRewards
function, it will call _calculatePendingRewards
function to calculayte the pending rewards. The _calculatePendingRewards
function use the following code to calculate the pending rewards:
This formula ensures that users only receive rewards for the portion of totalDistributed
that they haven't already claimed.
After calculating pendingReward
, the claimRewards
function sets userRewards[user] = totalDistributed
:
This resets the user's reward tracking to the current totalDistributed
, which skips this incremental calculation and results in the user receiving no rewards.
Scenario
First Distribution:
totalDistributed = 1000
userVotingPower = 50
totalVotingPower = 100
share = (1000 * 50) / 100 = 500
Since userRewards[user] = 0
, pendingReward = 500 - 0 = 500
After claiming, userRewards[user]
is set to totalDistributed = 1000
.
Second Distribution:
totalDistributed = 2000
userVotingPower = 50
totalVotingPower = 100
share = (2000 * 50) / 100 = 1000
Since userRewards[user] = 1000
, pendingReward = 1000 - 1000 = 0
The user receives no rewards in the second claim.
The user should receive their share of the newly distributed rewards (from totalDistributed = 1000
to totalDistributed = 2000
):
However, the user receives no rewards in the second claim because userRewards[user]
is incorrectly set to totalDistributed
.
Users lose their fair share of rewards distributed between claims.
This undermines the fairness and integrity of the reward distribution mechanism.
The impact is High, the likelihood is High, so the severity is High.
Manual Review
To resolve this issue, userRewards[user]
should be updated to reflect the user's claimed share of totalDistributed
instead of being set to totalDistributed
directly.
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.