Due to incorrect if comparison sell period will always be extended by 1 unit and cut withdrawal time by the same amount.
In the phase comparison:
three ifs determine which phase it is using the current roundTime (which is a timestamp remainder). But because incorrect comparison sign "<=" is used it always extends the first phase interval (sellInterval). Look at "Tools Used" for an example case.
This also returns incorrect "Time till next phase", last of the three parameters. As both Sell and Buy phases, can reach 0.
Incorrect phase calculation only shifts 1 second from last to first phase. But because Base blocks at the time of writing are minted every 2 seconds, the error will be more significant because (block.timestamp updated frequently - higher chance to fall in the shifted seconds):
Transactions that are meant for "Buy" phase - can fall in the extended "Sell" phase and fail.
If "Withdrawal" phase is set to 1 seconds - it will be skipped (never reached).
Even if "Sell" interval is set to 0 seconds and should skip, it will still be reached.
The comparison is at the core of the protocol and often used, can cause failing transactions and invalid protocol functionality (skipping "Withdrawal"). But no loss of funds (apart from gas) - Medium.
Manual review + hardhat tests
The following test prints out:
As we can see even though all phases should take the same amount of time - Sell is always extended buy 1 and Withdraw phase cut short buy one.
Replace comparison from "<=" to "<" in both sellInterval and buyInterval.
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.