Skip to main content

What is ComposableCoW?

ComposableCoW is a powerful framework for creating conditional orders on CoW Protocol. It provides a unified interface for stateless, composable conditional orders that execute automatically when predefined conditions are met. Conditional orders are smart contract-based trading strategies that monitor on-chain conditions and generate discrete orders for CoW Protocol when those conditions are satisfied. ComposableCoW is designed to work seamlessly with Safe multisigs and the ExtensibleFallbackHandler, providing secure and flexible automated trading capabilities.
ComposableCoW is the evolution of the conditional-smart-orders project, offering improved composability and extensibility.

Why Use ComposableCoW?

Automated Trading Strategies

Execute complex trading strategies without manual intervention. Set your conditions once and let the protocol handle the rest.

Composable Order Types

ComposableCoW supports multiple order types out of the box:
  • TWAP (Time-Weighted Average Price): Split large orders into smaller parts executed over time
  • Good After Time: Orders that become valid after a specific timestamp
  • Stop Loss: Automatically sell when price falls below a threshold using oracle data
  • Trade Above Threshold: Execute trades when token balance exceeds a minimum
  • Perpetual Stable Swap: Continuously maintain stable token positions

Safe Integration

Built specifically for Safe multisigs with strong security guarantees. Your funds remain under the full control of your Safe while enabling automated trading.

Gas Efficient

Orders are stateless and validated off-chain by watchtowers. Only successful trades result in on-chain transactions, minimizing gas costs.

Extensible Architecture

Create custom conditional order types by implementing the IConditionalOrder interface. The framework is designed for maximum flexibility.

Key Features

Two Authorization Modes

ComposableCoW supports two ways to authorize conditional orders:

Single Orders

Create individual conditional orders by calling ComposableCoW.create(). Ideal for simple use cases with a few orders.

Merkle Trees

Authorize multiple orders efficiently using a Merkle root. Perfect for managing large numbers of conditional orders with minimal on-chain storage.

Swap Guards

Implement additional validation logic with swap guards. These optional contracts provide extra security by verifying orders before execution:
interface ISwapGuard {
    function verify(
        GPv2Order.Data calldata order,
        bytes32 ctx,
        IConditionalOrder.ConditionalOrderParams calldata params,
        bytes calldata offchainInput
    ) external view returns (bool);
}

On-Chain Context Storage

Store dynamic values on-chain using the “cabinet” storage system. This allows conditional orders to reference time-dependent data like order creation timestamps:
// Store context when creating an order
composableCow.createWithContext(
    params,
    factory,    // IValueFactory to generate the value
    data,       // Data for the factory
    dispatch    // Emit events for watchtowers
);

// Access stored context in order handlers
uint256 startTime = uint256(composableCow.cabinet(owner, ctx));

Watchtower Integration

When creating orders with dispatch = true, events are emitted that watchtowers monitor. Watchtowers continuously check if conditional orders can generate valid discrete orders and submit them to the CoW Protocol API automatically.

How It Works

1

Setup Safe

Configure your Safe with ExtensibleFallbackHandler and set ComposableCoW as the domain verifier for CoW Protocol orders.
2

Create Conditional Order

Define your order parameters including the handler (order type), a unique salt, and static input data specific to your strategy.
3

Authorize the Order

Use either create() for single orders or setRoot() for Merkle tree-based authorization.
4

Approve Tokens

Grant GPv2VaultRelayer approval to spend the tokens you want to trade.
5

Watchtowers Monitor

Watchtowers continuously check if your conditional order can generate a valid discrete order.
6

Automatic Execution

When conditions are met, watchtowers submit the discrete order to CoW Protocol, which executes the trade.

Deployed Contracts

ComposableCoW is deployed across multiple networks:
ContractAddress
ExtensibleFallbackHandler0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5
ComposableCoW0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74
TWAP0x6cF1e9cA41f7611dEf408122793c358a3d11E5a5
GoodAfterTime0xdaf33924925e03c9cc3a10d434016d6cfad0add5
StopLoss0x412c36e5011cd2517016d243a2dfb37f73a242e7
PerpetualStableSwap0x519BA24e959E33b3B6220CA98bd353d8c2D89920
TradeAboveThreshold0x812308712a6d1367f437e1c1e4af85c854e1e9f6
These addresses are consistent across Ethereum Mainnet, Gnosis Chain, Sepolia, Arbitrum One, Base, BSC, Avalanche, Optimism, Polygon, and Lens.

Security

ComposableCoW has been audited by:
  • Ackee Blockchain: CoW Protocol - ComposableCoW and ExtensibleFallbackHandler
  • Gnosis Internal Audit (May/July 2023): ComposableCoW initial review
  • Gnosis Internal Audit (August 2024): ComposableCoW diff review
All audit reports are available in the repository’s audits/ directory.

Next Steps

Quickstart

Follow our step-by-step guide to create your first conditional order

Architecture

Dive deep into the system design and component interactions

Build docs developers (and LLMs) love