Skip to main content

Overview

The Composable SDK enables advanced order types like TWAP (Time-Weighted Average Price) and custom programmatic orders using the ComposableCoW framework. It provides tools for creating, managing, and polling programmatic orders.

Installation

ConditionalOrder

Abstract base class for all programmatic orders.

Creating Orders

Properties

string
Address of the handler contract for this programmatic order
string
32-byte salt for uniqueness (auto-generated if not provided)
D
Order-specific data in user-friendly format
S
Order data formatted as contract struct
boolean
Whether the order requires off-chain input
string
Unique order ID (keccak256 hash of serialized order)
string
Descriptive name of the order type (e.g., ‘twap’)
boolean
Whether this is a single order (vs part of a merkle tree)

Methods

createCalldata

Get calldata for creating the programmatic order on-chain.
string
Encoded function call to create the order (emits ConditionalOrderCreated event)

removeCalldata

Get calldata for removing the programmatic order.
string
Encoded function call to remove the order

poll()

Poll the programmatic order to check if it’s tradeable.
SupportedChainId
required
Chain ID where the order exists
string
required
Owner address (typically a Safe)
Provider
required
Ethereum provider for blockchain calls
OrderBookApi
required
OrderBook API instance
string
Off-chain input if required by the order type
string[]
Merkle proof if order is part of a tree
BlockInfo
Current block info for validation
PollResult
Poll result indicating order status

isAuthorized()

Check if the owner authorized this programmatic order.
boolean
True if the owner authorized the order

serialize()

Serialize the order into ABI-encoded form.
string
ABI-encoded order params

Twap

Time-Weighted Average Price order implementation.

Creating TWAP Orders

TwapData Parameters

string
required
Sell token contract address
string
required
Buy token contract address
string
required
Address to receive the bought tokens
bigint
required
Total amount to sell across all parts (in token atoms)
bigint
required
Minimum total amount to buy across all parts (in token atoms)
bigint
required
Number of parts to split the order into (must be > 1)
bigint
required
Duration between each part in seconds (max 1 year)
StartTime
required
When the TWAP should start
DurationOfPart
required
How long each part remains valid
string
required
keccak256 hash of app data document

TWAP Methods

fromParams()

Create TWAP from ConditionalOrderParams.

deserialize()

Deserialize a TWAP from ABI-encoded form.

TWAP Constants

Multiplexer

Manages multiple programmatic orders using a Merkle tree.

Creating a Multiplexer

SupportedChainId
required
Chain ID for ComposableCoW
Record<string, ConditionalOrder>
Optional initial orders (Record of string keys to ConditionalOrder values)
string
Optional Merkle root to verify against
ProofLocation
PRIVATE | EMITTED | SWARM | WAKU | IPFS

Adding Orders

Removing Orders

Updating Orders

Accessing Orders

Preparing Proofs

Generate proofs for setting the Merkle root on-chain.
ComposableCoW.ProofStruct

Serialization

ConditionalOrderFactory

Factory for creating and deploying programmatic orders.

Types

PollResultCode

Enum for poll result status.

ProofLocation

Enum for proof storage location.

ConditionalOrderParams

Parameters for a programmatic order.

Examples

Create and Deploy TWAP

Multiple Programmatic orders

Watch Tower Integration

Custom Programmatic order

Last modified on March 12, 2026