Assessment reports>Carina Smart Contracts>Threat Model>_cancelOrder

Function: _cancelOrder(Order order, bool revertIfInvalidCancellation)

This function cancels an existing order. Only the owner of the order can cancel it before it expires. This function can be reached in two ways, either through the external function cancelOrdersIgnoreInvalidCancellation(), which takes an array of orders to cancel, or through cancelOrder(), which takes a single order to cancel. Both of these outer functions are non-reentrant.

The owner will be refunded for their order, and wrapped tokens will be unwrapped in order to accomplish this.

Inputs

  • order

    • Control: Almost full control — order.tokenIn is set to WRAPPED_NATIVE_TOKEN inside toSettlementOrder(). However, the original struct is still used in some places.

    • Constraints: There are no direct constraints, but the hash of the settlement order must map to an order with status "created"; otherwise, the function returns early. If the order's validto field is in the future, only the owner can cancel it.

    • Impact: The order to cancel.

  • revertIfInvalidCancellation

    • Control: Indirectly controllable by picking which external function to run.

    • Constraints: Boolean. Only true or false.

    • Impact: Decides if an error during cancellation should just return or revert. Do note that it can still revert if the refund to the owner is unsuccessful.

Branches and code coverage

Intended branches

Negative behavior

Zellic © 2025Back to top ↑