Skip to main content
The CoW Protocol Composable SDK enables sophisticated trading strategies through conditional orders that execute automatically when specified conditions are met. This allows you to build advanced trading logic without constant monitoring.

Installation

Core Components

ConditionalOrderFactory

Registry-based factory for creating different types of conditional orders:

Multiplexer

Manages batches of conditional orders using merkle trees:

ConditionalOrder

Base class for implementing custom conditional order types:

Basic Usage

Order Types

Stop-Loss Orders

Automatically sell when price drops below a threshold:

Limit Orders

Execute trades at specific price points:

DCA (Dollar Cost Averaging)

Regularly buy or sell assets at predetermined intervals:
See the TWAP Orders page for detailed information about Time-Weighted Average Price orders.

Merkle Tree Management

Conditional orders are stored in merkle trees for efficient on-chain verification:

Order Validation

Validate conditional orders before execution:

Context Dependencies

Orders can depend on external data sources:

Order Registry Management

Register custom order types:

Smart Contract Integration

ComposableCoW Contract

Proof Generation and Storage

Complete Example

Here’s a complete example setting up a stop-loss order:

Best Practices

Use the isValid() method to catch configuration errors early:
Generate and store merkle proofs off-chain to enable watchtowers to execute your orders:
Set context factories for orders that need on-chain data:

Next Steps

TWAP Orders

Learn about Time-Weighted Average Price orders

Hooks

Execute custom logic with pre and post hooks