OrderBook

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

Redundant/ misleading status assignment in getOrderDetailsString()

Author Revealed upon completion

Root + Impact

The getOrderDetailsString() at function inside OrderBook.sol has redundant logic for computing the status string.

  • Describe the normal behavior in one or more sentences: The normal behavior is to assign a status regarding if the order is active and the deadline is met.

  • The initial ternary assignment is completely overwritten which is pointless

string memory status = order.isActive
? (block.timestamp < order.deadlineTimestamp ? "Active" : "Expired (Active but past deadline)")
: "Inactive (Filled/Cancelled)");
if (order.isActive && block.timestamp >= order.deadlineTimestamp) {
status = "Expired (Awaiting Cancellation)";
} else if (!order.isActive) {
status = "Inactive (Filled/Cancelled)";
} else {
status = "Active";
}

Risk

Likelihood:

  • This code runs every time a user calls getOrderDetailsString()

  • The ternary condition is misleading and unused — could confuse developers or auditors.

Impact:

  • Gas inefficiency

  • Confusing or inaccurate order status display

Proof of Concept

string memory status = order.isActive
? (block.timestamp < order.deadlineTimestamp ? "Active" : "Expired (Active but past deadline)")
: "Inactive (Filled/Cancelled)";
status; // This is overwritten below regardless of condition

Recommended Mitigation

- string memory status = order.isActive
- ? (block.timestamp < order.deadlineTimestamp ? "Active" : "Expired (Active but past deadline)")
- : "Inactive (Filled/Cancelled)";
+ string memory status;
+ if (!order.isActive) {
+ status = "Inactive";
+ } else if (block.timestamp >= order.deadlineTimestamp) {
+ status = "Expired";
+ } else {
+ status = "Active";
+ }
Updates

Lead Judging Commences

yeahchibyke Lead Judge 2 days ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Appeal created

Hawk 1 Submitter
2 days ago
yeahchibyke Lead Judge
2 days ago

Support

FAQs

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