DeFiFoundry
20,000 USDC
View results
Submission Details
Severity: medium
Invalid

First stakers can receive more points for epochs when `totalStaked` was 0

Summary

The first stakers can receive an unexpectedly big amount of FjordPoints for all epochs when totalStaked was zero.

Vulnerability Details

The distributePoints function distributes points for weeksPending period which reflects how many epochs were passed from the last distribution even totalStaked was zero. This way the first stakers will receive points for all previous epochs.

function distributePoints() public {
if (block.timestamp < lastDistribution + EPOCH_DURATION) {
return;
}
if (totalStaked == 0) {
>> return;
}
uint256 weeksPending = (block.timestamp - lastDistribution) / EPOCH_DURATION;
pointsPerToken =
pointsPerToken.add(weeksPending * (pointsPerEpoch.mul(PRECISION_18).div(totalStaked)));
totalPoints = totalPoints.add(pointsPerEpoch * weeksPending);
>> lastDistribution = lastDistribution + (weeksPending * 1 weeks);
emit PointsDistributed(pointsPerEpoch, pointsPerToken);
}

Impact

Unexpected FjordPoints distribution

Tools used

Manual Review

Recommendations

Consider updating lastDistribution even if totalStaked == 0 but without totalPoints increasing.

Updates

Lead Judging Commences

inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.