Skip to main content

Orders

CoW Protocol uses an intent-based order system where users express trading preferences off-chain, and solvers compete to find the best execution.

Order Structure

Orders contain 12 parameters defining trading intent:
ParameterTypeDescription
sellTokenaddressToken to sell (ERC20)
buyTokenaddressToken to buy (ERC20)
sellAmountuint256Amount of sell token
buyAmountuint256Minimum/maximum amount of buy token
validTouint32Order expiration timestamp
appDatabytes32Application-specific metadata
feeAmountuint256Fee amount in sell token
kindbytes32Order kind (sell or buy)
partiallyFillableboolWhether the order can be partially filled
sellTokenBalancebytes32Source of sell tokens
buyTokenBalancebytes32Destination of buy tokens
receiveraddressRecipient of bought tokens

Order Types

Sell Orders

Specify an exact amount to sell with a minimum buy amount guaranteed:
  • sellAmount is the exact amount of sell tokens to exchange
  • buyAmount is the minimum acceptable amount of buy tokens

Buy Orders

Specify an exact amount to buy with a maximum sell amount capped:
  • buyAmount is the exact amount of buy tokens to receive
  • sellAmount is the maximum amount of sell tokens to spend

Order UID

Each order receives a unique 56-byte UID combining:
  • Order digest (32 bytes) - EIP-712 hash of the order
  • Owner address (20 bytes) - The order creator
  • Validity timestamp (4 bytes) - Expiration time

EIP-712 Signing

Orders use typed EIP-712 signatures enabling hardware wallet support. The protocol hashes order data with a domain separator to create an order digest.
bytes32 orderDigest = keccak256(
    abi.encodePacked(
        "\x19\x01",
        domainSeparator,
        orderStructHash
    )
);

Signature Schemes

CoW Protocol supports four signing methods:
SchemeUse Case
EIP-712Standard typed data signing (recommended)
eth_signLegacy signing for compatibility
EIP-1271Smart contract wallet validation (e.g., Gnosis Safe)
PreSignOn-chain pre-authorization

Balance Sources

Users can source tokens from three different balance types:
  • ERC20 - Standard ERC20 token balances
  • External - Balancer Vault external balances
  • Internal - Balancer Vault internal balances

Order Validation

During settlement, five checks occur:
  1. Signature validity - Verifies the order was signed by the owner
  2. Expiration status - Ensures validTo has not passed
  3. Limit price compliance - Checks that clearing prices respect order limits
  4. Fill amount verification - Prevents overfilling
  5. Sufficient balance - Confirms the user has enough tokens

Order Lifecycle

  • Created - Order signed off-chain
  • Submitted - Order sent to the order pool
  • Filled - Order completely executed
  • PartiallyFilled - Order partially executed (if partiallyFillable is true)
  • Expired - Order validTo timestamp has passed
  • Cancelled - Order invalidated by the owner
Last modified on March 4, 2026