Skip to main content

Overview

Composable orders enable you to create programmatic orders (sometimes called conditional orders) that execute based on custom logic rather than executing immediately. These orders leverage the ComposableCoW smart contract framework to define conditions that must be met before an order becomes tradeable. Key benefits of composable orders:
  • Programmatic Execution — Orders only execute when specific conditions are met
  • Advanced Strategies — Build complex trading strategies like TWAP, DCA, or custom logic
  • Gas Efficiency — Reduce on-chain transactions by batching order logic
  • Merkle Tree Storage — Efficiently store multiple orders using Merkle proofs

ConditionalOrder Base Class

All composable orders inherit from the ConditionalOrder abstract base class:

Key Properties and Methods

Order Identification

Creating Orders

Generate calldata to create a programmatic order on-chain:

Polling Orders

Check if a programmatic order is ready to be executed:

Authorization

ComposableCow Contract Integration

Multiplexer for Multiple Orders

The Multiplexer class enables efficient management of multiple programmatic orders using Merkle trees:

Custom Handler Implementation

Best Practices

Validate Order Parameters: Always implement thorough validation in the is_valid() method to catch errors before submitting orders on-chain.
  • Handle Polling Errors Gracefully: Use appropriate PollResultCode values to signal whether polling should be retried, delayed, or stopped entirely.
  • Test with Testnets First: Always test programmatic orders on testnets (like Sepolia) before deploying to mainnet.
  • Use Salt for Uniqueness: The salt parameter ensures each order has a unique ID even if other parameters are identical.
Last modified on March 12, 2026