OrderBook

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

L-2 Redundant and Conflicting Status Logic in getOrderDetailsString

Root + Impact

Redundant Conditional Logic in Order Status Evaluation

Description

The getOrderDetailsString function includes a block of logic responsible for generating a human-readable order status (Active, Expired, Inactive, etc.). However, the current implementation contains redundant and potentially conflicting conditional logic that can lead to confusion, code bloat, and inconsistent behavior if modified in the future.

Initially, the status string is assigned using a nested ternary expression:

string memory status = order.isActive
? (block.timestamp < order.deadlineTimestamp ? "Active" : "Expired (Active but past deadline)")
: "Inactive (Filled/Cancelled)";
//Immediately after, this value is overwritten by a second set of if-else conditions:
if (order.isActive && block.timestamp >= order.deadlineTimestamp) {
status = "Expired (Awaiting Cancellation)";
} else if (!order.isActive) {
status = "Inactive (Filled/Cancelled)";
} else {
status = "Active";
}

This makes the original ternary assignment useless, and results in redundant computation and hard-to-read logic flow.

Risk

Likelihood:

  • This code will always execute, and developers or auditors will encounter this redundancy on review.

Impact:

  • No direct impact on contract behavior or user funds.

  • Risk is limited to code maintainability, developer confusion, and technical debt accumulation.

Proof of Concept

For any order, the status variable is first initialized based on active and deadline conditions, then immediately overwritten, for example:

  1. For an active order with an expired deadline, the first line assigns:

    status = "Expired (Active but past deadline)";

    But the next block immediately replaces it with:

    status = "Expired (Awaiting Cancellation)";

    For an inactive order, the value is assigned twice with no added benefit:

    1. `status = "Inactive (Filled/Cancelled)"; // assigned twice unnecessarily `&#x20;
    <br />

    This behavior adds unnecessary complexity without improving clarity or functionality.

Recommended Mitigation

Refactor the status logic to use only one clear and unambiguous conditional block:

Benefits:

  • Simplifies code

  • Easier to maintain and audit

  • Eliminates logical duplication

Updates

Lead Judging Commences

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

Support

FAQs

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