Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Invalid

The `ScoreBoard::getPlayerScore` function does not return `score` value, this makes the protocol unable to give the score (points) of predictions made by the players.

Summary

The ScoreBoard::getPlayerScore function should give the number of points made by each players prediction. If a player gets the prediction right, the player gets 2 points but if the player gets the prediction wrong the player gets -1 point. The points determine the sharing formula for each player that makes prediction. Hence The ScoreBoard::getPlayerScore function makes it impossible for the protocol to determine each player's point.

Vulnerability Details

There must be a return score statement in the ScoreBoard::getPlayerScore function to get players prediction points.

function getPlayerScore(address player) public view returns (int8 score) {
for (uint256 i = 0; i < NUM_MATCHES; ++i) {
if (playersPredictions[player].isPaid[i] && playersPredictions[player].predictions[i] != Result.Pending) {
score += playersPredictions[player].predictions[i] == results[i]
// @audit --> Is this right?
? int8(2)
: -1;
}
}
}

Impact

There would be no reward for players that got their predictions right, making them be in the same position as player that got their predictions wrong (negative points).

Tools Used

manual review

Recommendations

function getPlayerScore(address player) public view returns (int8 score) {
for (uint256 i = 0; i < NUM_MATCHES; ++i) {
if (playersPredictions[player].isPaid[i] && playersPredictions[player].predictions[i] != Result.Pending) {
score += playersPredictions[player].predictions[i] == results[i]
// @audit --> Is this right?
? int8(2)
: -1;
}
}
+ return score;
}
Updates

Lead Judging Commences

NightHawK Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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