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

The time calculation in ThePredicter.makePrediction() is wrong

Description

The contest details state that Every day from 20:00:00 UTC one match is played. Until 19:00:00 UTC on the day of the match, predictions can be made by any approved Player. But the calculation made is not accurate.

Impact

Function will revert earlier than it should, preventing Players to make their prediction up until the expected time.

PoC

Add this test at the end of the test file and run it using :

forge test --mt testCalcTimeStamps

function testCalcTimeStamps() public pure {
uint256 START_TIME = 1723752000;
uint32[9] memory actualWrongTimeStampThresholdPerMatch = [
1723683600, // 15/08/2024 03:00:00
1723752000, // 15/08/2024 22:00:00
1723820400, // 16/08/2024 17:00:00
1723888800, // 17/08/2024 12:00:00
1723957200, // 18/08/2024 07:00:00
1724025600, // 19/08/2024 02:00:00
1724094000, // 19/08/2024 21:00:00
1724162400, // 20/08/2024 16:00:00
1724230800 // 21/08/2024 11:00:00
];
uint32[9] memory expectedTimeStampThresholdPerMatch =
[1723748400, 1723834800, 1723921200, 1724007600, 1724094000, 1724180400, 1724266800, 1724353200, 1724439600];
// 1723748400 - 15/08/2024 19:00:00
// 1723834800 - 16/08/2024 19:00:00
// ...
for (uint256 matchNumber = 0; matchNumber < 9; matchNumber++) {
// `actualTimeStamp` is the calculation used in ThePredicter.makePrediction() to define if the prediction is open or close
// It should return the date of the current match at 19 UTC, but doesn't
uint256 actualTimeStamp = START_TIME + matchNumber * 68400 - 68400;
assertEq(actualWrongTimeStampThresholdPerMatch[matchNumber], actualTimeStamp);
}
for (uint256 matchNumber = 0; matchNumber < 9; matchNumber++) {
uint256 ONE_HOUR = 3600;
uint256 ONE_DAY = 86400;
// This is the correct calculation that needs to be made
uint256 actualTimeStamp = START_TIME + matchNumber * ONE_DAY - ONE_HOUR;
assertEq(expectedTimeStampThresholdPerMatch[matchNumber], actualTimeStamp);
}
}

Recommendations

Update the calculation as shown in the PoC

Updates

Lead Judging Commences

NightHawK Lead Judge 11 months 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.