OrderBook

First Flight #43
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

### [L-1] Incorrect Deadline Check in `buyOrder`

[L-1] Incorrect Deadline Check in buyOrder

Description

It was intially assumed that the deadline check in buyOrder function should use >=:

if (block.timestamp >= order.deadlineTimestamp) revert OrderExpired();

However ,this is an incorrect behaviour .An order with block.timestamp==deadline should
still be valid and buyable at the exact moment.Using >= prematurely restrict buyers to buy
at exact moment.

Impact:

1.Buyers failes to buy order at precise deadline.

2.Could discourage last-moment trades.

Proof of Concept

1.Seller creates an order with deadlineTimestamp = 3:00 PM.
2.Buyer sends a transaction at exactly 3:00 PM (block.timestamp == deadlineTimestamp).
3.If >= is used, the transaction reverts — though the order should still be valid.

Recommended Mitigation

Use Only >,Which will allow buyers to buy at exact moment and reverting after that.

function buyOrder(uint256 _orderId) public {
Order storage order = orders[_orderId];
// Validation checks
if (order.seller == address(0)) revert OrderNotFound();
if (!order.isActive) revert OrderNotActive();
-if(block.timestamp >= order.deadlineTimestamp) revert OrderExpired();
+if(block.timestamp > order.deadlineTimestamp) revert OrderExpired();
order.isActive = false;
}
Updates

Lead Judging Commences

yeahchibyke Lead Judge 4 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.