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

Incorrect Prediction Time Calculation

Summary

The protocol specifies that predictions should close at 7 PM every day, which is one hour before the match's start time. However, the current logic does not adhere to this requirement.

Vulnerability Details

Incorrect Time Calculation:

  • The time calculation START_TIME + matchNumber * 68400 - 68400 is incorrect for determining the closing time for predictions.

  • The variable 68400 is intended to represent the number of seconds in 19 hours, but it does not align with the protocol's requirement of closing predictions 1 hour before the match starts. This calculations only allows players to make predictions 19hours before the match time on the first day and at a longer time for other days.

function setPrediction(
address player,
uint256 matchNumber,
Result result
) public {
if (block.timestamp <= START_TIME + matchNumber * 68400 - 68400)
playersPredictions[player].predictions[matchNumber] = result;
playersPredictions[player].predictionsCount = 0; //
for (uint256 i = 0; i < NUM_MATCHES; ++i) {
if (
playersPredictions[player].predictions[i] != Result.Pending &&
playersPredictions[player].isPaid[i]
) ++playersPredictions[player].predictionsCount;
}
}

Proof Of Code

function test_predictionTime() public {
uint256 START_TIME = 1723752000;
ScoreBoard.Result result = ScoreBoard.Result.Pending;
vm.startPrank(newStranger);
vm.warp(START_TIME - 3600);
vm.expectRevert();
thePredicter.makePrediction{value: 0.0001 ether}(0, result); // This line reverts
vm.stopPrank()
}

Impact

Players are unable to make predictions starting 18 hours and 59 seconds before the match time on the first day and even longer on subsequent days of the tournament. This violates the protocol's design, which allows players to make and set predictions up until 1 hour before the START_TIME. This issue can lead to missed opportunities and player dissatisfaction.Tools Used

Foundry

Recommendations

This should be the correct calculation to for calculating the time

if (block.timestamp <= START_TIME + matchNumber * 86400 - 3600)
Updates

Lead Judging Commences

NightHawK Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Match timestamps are incorrect

In both contracts there is a similar error in the computation of the timestamps of the matches.

Support

FAQs

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