Skip to main content
ComposableCoW provides a flexible framework for creating conditional orders on CoW Protocol. Each order type implements specific trading logic that determines when and how orders are executed.

Available Order Types

TWAP (Time-Weighted Average Price)

Split a large order into smaller parts executed at fixed intervals to minimize price impact and achieve better average execution prices.

TWAP Orders

Execute orders in scheduled parts over a specified time period
Use Cases:
  • Large trades that need to be split over time
  • Reducing price impact on low-liquidity pairs
  • Dollar-cost averaging strategies

Stop Loss

Automatically trigger a sell order when the price of a token falls below a specified threshold, protecting against further losses.

Stop Loss Orders

Protect positions with oracle-based price triggers
Use Cases:
  • Risk management and loss prevention
  • Automated exit strategies
  • Portfolio protection during volatile markets

Good After Time

Schedule orders to become valid only after a specific timestamp, with optional price validation using Milkman price checkers.

Good After Time Orders

Delay order execution until a specified time
Use Cases:
  • Time-locked trading strategies
  • Scheduled rebalancing
  • Post-event trading (e.g., after token unlocks)

Perpetual Stable Swap

Maintain a balanced position between two stablecoins by automatically trading whichever token has the higher balance back to the other.

Perpetual Stable Swap

Automatically rebalance between two stablecoins
Use Cases:
  • Liquidity provision with rebalancing
  • Earning spread on stablecoin pairs
  • Maintaining balanced dual-token positions

Trade Above Threshold

Automatically sell tokens whenever your balance exceeds a specified threshold, useful for regular conversions or yield harvesting.

Trade Above Threshold

Execute trades when token balance exceeds a limit
Use Cases:
  • Automated yield harvesting
  • Regular conversions of earned tokens
  • Threshold-based portfolio management

Order Type Characteristics

Order TypeRepeatableRequires OraclePartial Fill Support
TWAPYes (multiple parts)NoNo
Stop LossNo (one-time)Yes (Chainlink)Optional
Good After TimeYes (via buyAmount)Optional (Milkman)Optional
Perpetual Stable SwapYes (continuous)NoNo
Trade Above ThresholdYes (continuous)NoNo

Implementation

All order types inherit from BaseConditionalOrder and implement the getTradeableOrder function:
function getTradeableOrder(
    address owner,
    address sender,
    bytes32 ctx,
    bytes calldata staticInput,
    bytes calldata offchainInput
) public view returns (GPv2Order.Data memory order);

Parameters

owner
address
The address that owns the conditional order
sender
address
The address that triggered the order (often unused)
ctx
bytes32
Context hash for the order (used for state management)
staticInput
bytes
ABI-encoded order parameters specific to each order type
offchainInput
bytes
Dynamic data provided by off-chain watchers (optional, order-type dependent)

Error Handling

Conditional orders can revert with specific errors to indicate order status:
  • OrderNotValid(string) - Order conditions are not met and will never be valid
  • PollTryNextBlock(string) - Order is temporarily invalid, try again in the next block
  • PollTryAtEpoch(uint256, string) - Order will be valid at a specific timestamp
Each order type has its own set of validation rules and error messages. See individual order type pages for details.

Build docs developers (and LLMs) love