Expand description
cow-rs — Rust SDK for the CoW Protocol (façade crate).
This is the Layer 6 façade of the workspace — it re-exports every
layered cow-* crate under one ergonomic entry point and contains no
logic of its own. Users who want tighter tree-shaking can depend on
the individual cow-* crates directly.
Two naming conventions are exposed in parallel:
- Clean layered names aligned with the architecture doc (
chains,signing,orderbook,primitives,http, …) - Legacy module names kept for backwards compatibility with pre-split call sites
(
config,order_signing,order_book, …)
Both forms reach the same underlying crates.
| Layer | Clean name | Legacy alias | Crate |
|---|---|---|---|
| L0 | primitives | — | cow_primitives |
| L0 | chains | config | cow_chains |
| L0 | error | — | cow_errors |
| L1 | types | — | cow_types |
| L2 | signing | order_signing | cow_signing |
| L2 | app_data | — | cow_app_data |
| L2 | permit, erc20, ethflow, weiroll, cow_shed, settlement | — | respective cow-* crates |
| L3 | http | — | cow_http |
| L4 | orderbook | order_book | cow_orderbook |
| L4 | subgraph, onchain | — | respective cow-* crates |
| L5 | trading, composable, bridging, flash_loans | — | respective cow-* crates |
§Quick start — TradingSdk
use alloy_primitives::U256;
use cow_rs::{OrderKind, SupportedChainId, TradeParameters, TradingSdk, TradingSdkConfig};
let sdk = TradingSdk::new(
TradingSdkConfig::prod(SupportedChainId::Sepolia, "MyApp"),
"0xdeadbeef...",
)?;
let result = sdk
.post_swap_order(TradeParameters {
kind: OrderKind::Sell,
sell_token: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14".parse()?,
sell_token_decimals: 18,
buy_token: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238".parse()?,
buy_token_decimals: 6,
amount: U256::from(100_000_000_000_000_u64),
slippage_bps: Some(50),
receiver: None,
valid_for: None,
valid_to: None,
partially_fillable: None,
partner_fee: None,
})
.await?;
println!("order: {}", result.order_id);Re-exports§
pub use trading_swap_quoter::TradingSwapQuoter;pub use settlement::reader::AllowListReader;pub use settlement::reader::SettlementReader;pub use traits::CowSigner;pub use traits::IpfsClient;pub use traits::OrderbookClient;pub use traits::RpcProvider;pub use cow_primitives as primitives;pub use cow_http as http;pub use cow_chains as chains;pub use cow_signing as signing;pub use cow_orderbook as orderbook;
Modules§
- app_
data CoWProtocol order app-data — metadata schema and hash generation.- bridging
- Cross-chain bridge aggregator and provider abstractions.
- browser_
wallet - EIP-1193 browser wallet adapter and WASM bindings.
- common
- Common utility functions ported from the
TypeScriptSDKcommonpackage. - composable
CoWProtocol composable (conditional) orders.- config
- Chain configuration, contract addresses and endpoints.
- cow_
shed CoWShed proxy contract helpers.- cross_
chain_ post post_cross_chain_order— post-time orchestration for a hook-based bridge order.- erc20
- ERC-20 and EIP-2612 calldata builders.
- error
- Unified error type for the SDK.
- ethflow
EthFlownative-currency order encoding.- flash_
loans - Flash loan orchestration helpers.
- onchain
- JSON-RPC
eth_callreader for on-chain state queries. - order_
book CoWProtocol orderbook API client and types.- order_
signing - EIP-712 order signing, EIP-1271, and
OrderUidcomputation. - permit
- EIP-2612 permit utilities.
- prelude
- Curated prelude of the most commonly used items.
- settlement
- Settlement encoding and contract interaction layer for
CoWProtocol. - subgraph
CoWProtocol subgraphGraphQLclient.- trading
- High-level trading SDK.
- trading_
swap_ quoter TradingSwapQuoter— newtype wrapper that adaptscow_trading::TradingSdkto thecow_bridging::SwapQuotertrait.- traits
- Injectable trait abstractions for testing and composition.
- types
- Protocol enums and primitive constants.
- wasm
wasm-bindgenexports (WASM-only).- weiroll
- Weiroll script builder and encoding.
Structs§
- Amounts
- Amounts at a specific stage of the fee pipeline.
- ApiContext
- The
CoWProtocol API context. - AppData
Doc - Root document for
CoWProtocol order app-data (schema v1.14.0). - AppData
Info - Full app-data information derived from an
AppDataDoc. - AppData
Object - Response from
GET /api/v1/app_data/{appDataHash}andPUT /api/v1/app_data/{appDataHash}. - Auction
- A batch auction returned by
GET /api/v1/auction. - Block
Info - Block information used for conditional order validation.
- Bridging
Sdk - High-level cross-chain bridge aggregator.
- Build
AppData Params - Parameters for building the app-data document for a trade.
- Bundle
- Aggregate price bundle — contains the current ETH/USD price.
- Chain
Contract - An on-chain contract reference with an optional creation block.
- Chain
Contracts - Well-known contracts on an EVM chain.
- Chain
RpcUrls - RPC URL configuration for an EVM chain.
- Chain
Token Info - Token info used in chain metadata.
- CidComponents
- Parsed components of an IPFS Content Identifier (CID).
- Competition
Auction - The set of order UIDs and reference prices that make up a competition auction.
- Competition
Order Status - Response from
GET /api/v1/orders/{UID}/status. - Conditional
Order Factory - Instantiates conditional orders from
ConditionalOrderParams. - Conditional
Order Params - ABI-encoded parameters identifying a conditional order on-chain.
- CowHook
- A single
CoWProtocol pre- or post-settlement interaction hook. - CowShed
Call - A single call to be executed by the
CowShedproxy contract. - CowShed
Hook Params - Parameters for a
CowShedexecution bundle. - CowShed
Sdk - High-level helper for building
CowShedproxy interactions. - CowSwap
Config - Configuration for the
CoWProtocol swap executor. - Daily
Total - Full per-day protocol statistics entity from the subgraph.
- Daily
Volume - Per-day volume snapshot.
- Encoded
Interaction - An encoded interaction ready for inclusion in a settlement.
- Erc20
Permit Info - EIP-712 domain metadata for an ERC-20 token that implements
EIP-2612. - EthFlow
Order Data - Parameters for a native-currency sell order submitted through the
EthFlowcontract. - EthFlow
Transaction - Ready-to-send transaction for submitting a native-currency order.
- Ethflow
Data - Additional data present on
EthFlow(native sell) orders. - EvmCall
- An EVM call with a target address, calldata, and value.
- EvmChain
Info - Metadata for an EVM chain.
- Flash
Loan Params - Parameters for a flash loan pre-interaction hook.
- Flash
Loan Sdk - Helper for building flash loan pre-interaction hooks.
- GatData
- Parameters for a
GoodAfterTime(GAT) conditional order. - GatOrder
- A
GoodAfterTimeconditional order ready for submission toComposableCow. - GetOrders
Request - Query parameters for
GET /api/v1/account/{owner}/orders. - GetTrades
Request - Query parameters for
GET /api/v2/trades. - GpV2
Order Struct - Raw on-chain
GPv2Order.DataStructas emitted by theGPv2Settlementcontract. - Hourly
Total - Full per-hour protocol statistics entity from the subgraph.
- Hourly
Volume - Per-hour volume snapshot.
- Interaction
Data - A single on-chain interaction (pre- or post-settlement hook).
- Ipfs
- IPFS connection parameters for upload/fetch operations.
- Ipfs
Config - IPFS configuration for reading and writing app data.
- Ipfs
Upload Result - Result of uploading metadata to IPFS (legacy).
- Limit
Order Advanced Settings - Advanced overrides for limit order submission.
- Limit
Trade Parameters - Parameters for a limit order (fixed price, no slippage).
- Limit
Trade Parameters From Quote - Simplified limit order parameters derived directly from a quote response.
- Metadata
- Metadata container — all fields are optional.
- Metadata
Api - High-level facade mirroring
MetadataApifrom theTypeScriptSDK. - Multiplexer
- Manages a set of conditional orders and computes their Merkle root.
- Network
Fee - Network fee expressed in both currencies.
- NonEvm
Chain Info - Metadata for a non-EVM chain (e.g. Bitcoin, Solana).
- Onchain
Order Data - On-chain placement metadata for orders submitted directly on-chain (as opposed to the off-chain API).
- Onchain
Reader - Reads on-chain state from an Ethereum node via JSON-RPC
eth_call. - Onchain
Token Info - Aggregate on-chain token information gathered in a single round of concurrent
eth_callrequests. - Order
- A full order record returned by
GET /api/v1/orders/{uid}. - Order
Book Api - Async HTTP client for the
CoWProtocol orderbook REST API. - Order
Cancellations - Request body for
DELETE /api/v1/orders— batch cancellation of orders. - Order
Creation - Request body for
POST /api/v1/orders— a signed order ready to submit. - Order
Domain - The EIP-712 domain for
CoWProtocol orders. - Order
Flags - Order flags extracted from a bitfield.
- Order
Interaction Hooks - Pre- and post-settlement interaction hooks.
- Order
Interactions - Pre- and post-settlement interaction hooks attached to an order.
- Order
Posting Result - The result of a successful order submission.
- Order
Proof - Merkle inclusion proof for a single conditional order.
- Order
Quote Request - Request body for
POST /api/v1/quote. - Order
Quote Response - Response from
POST /api/v1/quote. - Order
Refund - Refund claim for a
CoWProtocol order. - Order
Typed Data - The full EIP-712 typed data envelope for a
CoWProtocol order. - Order
Uid - The unique order identifier returned by
POST /api/v1/orders. - Order
UidParams - Parameters extracted from a 56-byte order UID.
- Pair
Daily - Per-day statistics for a token pair.
- Pair
Hourly - Per-hour statistics for a token pair.
- Partner
FeeCost - Partner fee cost component.
- Partner
FeeEntry - A single partner fee policy entry (schema v1.14.0).
- Partner
FeeResult - Result of partner-fee calculation.
- Permit
Hook Data - Pre-interaction hook data that
CoWProtocol appends to an order to trigger anEIP-2612permit call before settlement. - Permit
Info - Core parameters for an EIP-2612 permit operation.
- Post
Trade Additional Params - Additional parameters for posting orders.
- Proof
Struct - On-chain
Proofargument passed toComposableCow::setRoot. - Proof
With Params - Proof and params bundled for watchtower export.
- Protocol
FeeAmount Params - Parameters for
get_protocol_fee_amount. - Protocol
FeeCost - Protocol fee cost component.
- Protocol
Options - Protocol-level options for overriding
CoWProtocol contract addresses and environment. - Quote
- Quote-level slippage settings embedded in app-data.
- Quote
Amounts - Sell and buy amounts at a particular fee stage.
- Quote
Amounts AndCosts - Full fee and amount breakdown for a quoted trade, mirroring the
CoWSDK’sQuoteAmountsAndCostsstructure. - Quote
Amounts AndCosts Params - Parameters for
get_quote_amounts_and_costs. - Quote
Amounts AndCosts Result - Complete breakdown of quote amounts at every fee stage.
- Quote
Bridge Request - Request for a cross-chain bridge quote.
- Quote
Bridge Response - A bridge quote from a single provider.
- Quote
Costs - All cost components of a quote.
- Quote
Data - The core quote amounts returned by the orderbook.
- Quote
FeeComponent - A single fee component: absolute amount and its BPS rate.
- Quote
Network Fee - Network fee expressed in both sell and buy currency.
- Quote
Order Params - Order parameters needed by the quote-amount calculations.
- Quote
Results - The result of a successful quote, bundled with posting capability.
- Quote
Results With Signer - Quote results bundled with the signer that produced them.
- Quote
Side - The directional “side” of a quote request.
- Quoter
Parameters - Trader information extracted from swap parameters.
- Rate
Limiter - A shared token-bucket rate limiter.
- Replaced
Order - Links this order to a previously submitted order it supersedes.
- Retry
Policy - Exponential-backoff retry policy for transient HTTP failures.
- Settlement
Encoder - Orchestrates building a complete
GPv2Settlement.settle()calldata payload. - Sign
Order Cancellation Params - Parameters for signing a single order cancellation.
- Sign
Order Cancellations Params - Parameters for signing multiple order cancellations in bulk.
- Sign
Order Params - Parameters for signing a
CoWProtocol order. - Signing
Result - The result of signing an order — signature bytes and the scheme used.
- Simulation
Result - Result of simulating a settlement transaction via
eth_call. - Slippage
Tolerance Request - Request parameters for a slippage tolerance suggestion.
- Slippage
Tolerance Response - Response from a slippage tolerance suggestion.
- Solver
Competition - Solver competition response from
GET /api/v1/solver_competition/{auctionId}. - Solver
Execution - Per-solver execution amounts within the competition.
- Solver
Settlement - A single solver’s proposed settlement within a competition.
- Stop
Loss Data - Parameters for a stop-loss conditional order.
- Stop
Loss Order - A stop-loss conditional order ready to be submitted to
ComposableCow. - Subgraph
Api GraphQLclient for theCoWProtocol subgraph.- Subgraph
Block - Block information returned by the subgraph
_metafield. - Subgraph
Meta - Top-level subgraph indexing metadata returned by the
_metafield. - Subgraph
Order - An order indexed by the subgraph.
- Subgraph
Pair - A trading pair (two tokens) indexed by the subgraph.
- Subgraph
Settlement - An on-chain batch settlement transaction.
- Subgraph
Token - An ERC-20 token indexed by the subgraph.
- Subgraph
Trade - A single trade executed within a batch settlement.
- Subgraph
User - A trader address indexed by the subgraph.
- Swap
Advanced Settings - Advanced overrides for swap and quote operations.
- Swap
Quote Outcome - Minimal swap-quote response returned by a
SwapQuoter. Carries just enough to build the outerQuoteBridgeResponseand upstream app-data attribution. - Swap
Quote Params - Minimal swap-quote request passed from the bridging orchestrator to
a
SwapQuoter. Mirrors the subset ofTradeParametersthe bridging layer needs for the intermediate hop. - Test
Conditional Order Params - Parameters for creating a test conditional order.
- Themed
Image - A themed image with light and dark variants.
- Token
Daily Total - Per-day volume and price statistics for a specific token.
- Token
Hourly Total - Per-hour volume and price statistics for a specific token.
- Token
Info - Minimal token metadata used for order size calculations.
- Token
Registry - A registry mapping asset ticker symbols to their ERC-20 token metadata.
- Token
Trading Event - A price-changing event for a token (used to reconstruct OHLC data).
- Total
- Protocol-wide singleton accumulator entity from the subgraph.
- Total
Surplus - Response from
GET /api/v1/users/{address}/total_surplus. - Totals
- Protocol-wide aggregate statistics.
- Trade
- A single trade event returned by
GET /api/v1/tradesorGET /api/v2/trades. - Trade
Flags - Trade flags: order flags plus a signing scheme.
- Trade
Parameters - Parameters for requesting a swap quote.
- Trade
Simulator - Simulates settlement execution to estimate gas costs and detect reverts.
- Trading
AppData Info - App-data document and its
keccak256hash. - Trading
Sdk - High-level
CoWProtocol trading interface. - Trading
SdkConfig - Configuration for
TradingSdk. - Trading
Transaction Params - A raw Ethereum transaction object produced by the
CoWSDK on-chain helpers. - Twap
Data - Parameters for a Time-Weighted Average Price (
TWAP) order. - Twap
Order - A
TWAPorder ready to be submitted toComposableCow. - Twap
Struct - On-chain
TwapStructrepresentation with per-part amounts. - Uniswap
Pool - A Uniswap pool entity indexed by the
CoWProtocol subgraph. - Uniswap
Token - A Uniswap token entity indexed by the
CoWProtocol subgraph. - Unsigned
Order - An unsigned
CoWProtocol order ready to be hashed and signed. - Utm
- UTM campaign tracking parameters.
- Validation
Result - Result of validating an
AppDataDocagainst its schema. - WebUrl
- A named URL.
- Weiroll
Command - A single command in a Weiroll script (32-byte packed encoding).
- Weiroll
Contract Ref - A Weiroll-compatible contract reference with a default call mode.
- Weiroll
Planner - Builder that accumulates commands and state slots into a Weiroll script.
- Weiroll
Script - A complete Weiroll script ready for on-chain execution.
- Widget
- Widget integration metadata.
Enums§
- Additional
Target Chain Id - Chains where you can buy tokens using bridge functionality but that are not
directly supported by
CoWProtocol for selling. - Bridge
Error - Errors specific to bridging operations.
- Chain
Info - A chain on the network – either an EVM chain or a non-EVM chain.
- Competition
Order Status Kind - Fine-grained lifecycle state of an order within the current batch auction.
- Conditional
Order Kind - A conditional order decoded from on-chain
ConditionalOrderParams. - CowError
- Errors that can occur when interacting with the
CoWProtocol SDK. - Duration
OfPart - Duration constraint for each individual
TWAPpart. - Ecdsa
Signing Scheme - ECDSA-only signing schemes (EIP-712 or EIP-191).
- Env
- Orderbook API environment.
- EvmChains
- All EVM chains supported by
CoWProtocol or available for bridging. - Flash
Loan Provider - Supported flash loan providers.
- Interaction
Stage - The three interaction stages in a
CoWProtocol settlement. - IsValid
Result - Result of validating a conditional order.
- NonEvm
Chains - All non-EVM chains available for bridging only.
- Order
Class - Order class assigned by the orderbook.
- Order
Class Kind - High-level classification of the order’s intent.
- Order
Kind - Whether to sell an exact input amount or buy an exact output amount.
- Order
Status - Lifecycle state of an order on the orderbook.
- Partner
Fee - Partner fee attached to a
CoWProtocol order (schema v1.14.0). - Poll
Result - Result returned when polling a conditional order for tradability.
- Price
Quality - Quote price-quality hint passed to the orderbook.
- Proof
Location - Where the Merkle proof for a conditional order is stored / communicated.
- Quote
Strategy - Strategy variant for quote retrieval.
- Referrer
- Partner referral tracking information.
- Refund
Type - The contract path to use for an order refund.
- Signing
Scheme - Signing scheme for a
CoWProtocol order. - Supported
Chain Id - Chains supported by the
CoWProtocol orderbook. - Target
Chain Id - A chain ID that is either a
SupportedChainIdor anAdditionalTargetChainId. - Token
Balance - The ERC-20 balance source/destination for
sellTokenandbuyToken. - Twap
Start Time - Start time specification for a
TWAPorder. - Validation
Error - A specific constraint violation found when validating an
AppDataDoc. - Weiroll
Command Flags - Flags that modify the execution mode of a Weiroll command.
Constants§
- ACROSS_
DEPOSIT_ EVENT_ INTERFACE - Alias for
ACROSS_FUNDS_DEPOSITED_TOPICmatching theTypeScriptACROSS_DEPOSIT_EVENT_INTERFACEexport. - ATTESTATION_
PREFIX_ CONST - Near Intents attestation prefix constant.
- ATTESTATOR_
ADDRESS - Near Intents attestator address.
- ATTESTION_
VERSION_ BYTE - Near Intents attestation version byte.
- BARN_
ETH_ FLOW - The staging (barn)
EthFlowcontract address. - BTC_
CURRENCY_ ADDRESS - Sentinel address for BTC native currency.
- BUY_
ETH_ ADDRESS - Marker address to indicate that an order is buying Ether (native currency).
- COMPOSABLE_
COW - The
ComposableCowfactory contract address. - COMPOSABLE_
COW_ ADDRESS ComposableCowfactory contract — same address on all supported chains.- COW_
TRADE_ EVENT_ INTERFACE - Alias for
COW_TRADE_EVENT_SIGNATUREmatching theTypeScriptCOW_TRADE_EVENT_INTERFACEexport. - CURRENT_
BLOCK_ TIMESTAMP_ FACTORY_ ADDRESS CurrentBlockTimestampFactorycontract address.- DEFAULT_
FEE_ SLIPPAGE_ FACTOR_ PCT - Default fee-based slippage multiplier: 50 % of the quoted fee amount.
- DEFAULT_
IPFS_ READ_ URI - Default IPFS gateway used when none is provided.
- DEFAULT_
IPFS_ WRITE_ URI - Default IPFS write URI (Pinata).
- DEFAULT_
QUOTE_ VALIDITY - Default order TTL in seconds (30 minutes).
- DEFAULT_
RETRY_ STATUS_ CODES - HTTP status codes that the upstream
TypeScriptSDK retries on. MirrorsSTATUS_CODES_TO_RETRYinpackages/order-book/src/request.ts. - DEFAULT_
SLIPPAGE_ BPS - Default slippage in basis points (0.5 %).
- DEFAULT_
VOLUME_ SLIPPAGE_ BPS - Default volume-based slippage in basis points (0.5 %).
- DEPLOYER_
CONTRACT - The
CREATE2deployer contract address. - EIP1271_
MAGICVALUE - Value returned by a call to
isValidSignatureif the signature was verified successfully (EIP-1271). - ETH_
FLOW_ DEFAULT_ SLIPPAGE_ BPS - Default slippage for ETH flow (native-currency sell) orders, in basis points.
- ETH_
FLOW_ PROD - The production
EthFlowcontract address. - ETH_
FLOW_ STAGING - The staging (barn)
EthFlowcontract address. - EVM_
NATIVE_ CURRENCY_ ADDRESS - The standard address used to represent native currency on EVM chains.
- EXTENSIBLE_
FALLBACK_ HANDLER - The
ExtensibleFallbackHandlercontract address. - GAS_
LIMIT_ DEFAULT - Fallback gas limit for smart-contract wallet interactions (150 000 gas).
- GAT_
HANDLER_ ADDRESS GoodAfterTimehandler contract address.- HUNDRED_
THOUSANDS - Scale factor: 100 000.
- LAST_
DAYS_ VOLUME_ QUERY GraphQLquery for daily volume snapshots over the last N days.- LAST_
HOURS_ VOLUME_ QUERY GraphQLquery for hourly volume snapshots over the last N hours.- LATEST_
APP_ DATA_ VERSION - Latest app-data schema version this crate targets.
- LIMIT_
CONCURRENT_ REQUESTS - Maximum concurrent requests to the
CoWProtocol API. - MAX_
FREQUENCY - Maximum allowed
part_durationin seconds (1 year). - MAX_
SLIPPAGE_ BPS - Maximum allowed suggested slippage (100 %).
- MAX_
UINT32 - Maximum
u32value as aU256(2^32 - 1 = 4 294 967 295). - MAX_
UINT256 - Maximum
U256value (2^256 - 1). - MAX_
VALID_ TO_ EPOCH - Maximum valid-to epoch value (
u32::MAX). - NATIVE_
CURRENCY_ ADDRESS - The sentinel address used to represent the native currency (ETH, xDAI, AVAX, …).
- ONE
U256one.- ONE_
HUNDRED_ BPS - One hundred basis points expressed as a
U256(100 * 100 = 10 000). - ORDER_
PRIMARY_ TYPE - EIP-712 primary type for
CoWProtocol orders. - ORDER_
TYPE_ HASH - Pre-computed EIP-712 type hash for a Gnosis Protocol v2 order.
- ORDER_
UID_ LENGTH - The byte length of an order UID (32 bytes order digest + 20 bytes owner + 4 bytes validTo).
- PERMIT_
GAS_ LIMIT - Estimated gas required for a single
EIP-2612permitcall. - PRE_
SIGNED - Marker value indicating a presignature is set.
- RAW_
CHAINS_ FILES_ PATH - CDN path for chain data.
- RAW_
FILES_ PATH - Base CDN path for SDK files.
- SALT
- The deterministic deployment salt.
- SETTLEMENT_
CONTRACT - The
CoWProtocolGPv2Settlementcontract address. - SETTLEMENT_
CONTRACT_ STAGING - The staging
CoWProtocolGPv2Settlementcontract address. - SOL_
NATIVE_ CURRENCY_ ADDRESS - Sentinel address for SOL native currency.
- STOP_
LOSS_ HANDLER_ ADDRESS StopLosshandler contract address (Ethereum mainnet).- TOKEN_
LIST_ IMAGES_ PATH - CDN path for token list images.
- TOTALS_
QUERY GraphQLquery for protocol-wide aggregate statistics.- TWAP_
HANDLER_ ADDRESS - Default
TWAPhandler contract address. - VAULT_
ACTIONS - The Balancer V2 Vault function names used by
GPv2Settlement. - VAULT_
RELAYER - The
CoWProtocol Vault Relayer contract address. - VAULT_
RELAYER_ STAGING - The staging
CoWProtocol Vault Relayer contract address. - WEIROLL_
ADDRESS - The default Weiroll executor contract address deployed across supported chains.
- ZERO
U256zero.- ZERO_
ADDRESS - The zero address (
0x0000…0000). - ZERO_
HASH - The 32-byte zero hash.
Traits§
- Bridge
Provider - Trait implemented by cross-chain bridge providers (Across, Bungee, NEAR Intents, …).
- Swap
Quoter - Trait implemented by any “thing that can quote an intermediate swap”.
Functions§
- additional_
target_ chain_ info - Return the
ChainInfofor anAdditionalTargetChainId. - adjust_
eth_ flow_ limit_ order_ params - Adjust limit-order parameters for ETH-flow by replacing the sell token with the wrapped native currency.
- adjust_
eth_ flow_ order_ params - Adjust trade parameters for ETH-flow orders by replacing the sell token with the wrapped native currency for the given chain.
- all_
additional_ target_ chain_ ids - Return all chain IDs for additional target chains (bridge-only).
- all_
additional_ target_ chains - Return chain info for all additional target chains (bridge-only).
- all_
chain_ ids - Return all known chain IDs as
TargetChainIdvalues. - all_
chains - Return chain info for all known chains (both supported and bridge-only).
- all_
supported_ chain_ ids - Return all supported chain IDs as a
Vec. - all_
supported_ chains - Return chain info for all supported chains.
- api_
base_ url - Return the orderbook API base URL (no trailing slash) for
chaininenv. - api_url
- Return the orderbook API base URL for a chain and environment.
- app_
data_ hex_ to_ cid_ legacy Deprecated - Convert an
appDataHexto aCIDv1string using the legacy encoding. - appdata_
hex - Serialise
docto canonical JSON with sorted keys, then returnkeccak256(json_bytes). - appdata_
hex_ to_ cid - Convert an
appDataHexvalue (the 32-bytekeccak256stored in the order struct) into aCIDv1string. - appdata_
json - Return the canonical JSON string for
docwith all object keys sorted alphabetically and no extraneous whitespace. - apply_
percentage - Apply a percentage value to
value. - apply_
settings_ to_ limit_ trade_ parameters - Apply
LimitOrderAdvancedSettingsoverrides to limit order parameters. - assert_
cid - Validate that a CID string is non-empty.
- balance_
to_ string - Reverse-map a
keccak256-hashed token-balance string back to its name. - bps_
to_ percentage - Convert basis points to a percentage value.
- build_
app_ data - Build app-data for a trade, including slippage, order class, and optional partner fee.
- build_
app_ data_ doc - Build the
0x-prefixed app-data hex string with the givenapp_codeandMetadata. - build_
app_ data_ doc_ full - Build the canonical JSON app-data document together with its
keccak256hash. - build_
eip2612_ nonces_ calldata - Build calldata for
EIP-2612.nonces(address owner). - build_
eip2612_ version_ calldata - Build calldata for
EIP-2612.version()— a 4-byte selector-only call. - build_
erc20_ allowance_ calldata - Build calldata for
ERC20.allowance(address owner, address spender). - build_
erc20_ approve_ calldata - Build calldata for
ERC20.approve(address spender, uint256 amount). - build_
erc20_ balance_ of_ calldata - Build calldata for
ERC20.balanceOf(address account). - build_
erc20_ decimals_ calldata - Build calldata for
ERC20.decimals()— a 4-byte selector-only call. - build_
erc20_ name_ calldata - Build calldata for
ERC20.name()— a 4-byte selector-only call. - build_
erc20_ transfer_ calldata - Build calldata for
ERC20.transfer(address to, uint256 amount). - build_
erc20_ transfer_ from_ calldata - Build calldata for
ERC20.transferFrom(address from, address to, uint256 amount). - build_
eth_ flow_ transaction - Build a complete
EthFlowTransactionforcontract_address. - build_
order_ app_ data - Build the
0x-prefixed app-data hex string for an order identified byapp_code. - build_
order_ typed_ data - Build a complete
OrderTypedDataenvelope fororderonchain_id. - build_
permit_ calldata - ABI-encode the
permit(address,address,uint256,uint256,uint256,uint8,bytes32,bytes32)call. - build_
permit_ hook - Sign and build a
PermitHookDataready for attachment to aCoWProtocol order. - calculate_
gas_ margin - Add a 20 % safety margin to a gas estimate.
- calculate_
unique_ order_ id - Calculate a unique order ID for ETH-flow orders.
- cancellations_
hash - Compute the EIP-712 struct hash for a batch of order cancellations.
- cid_
to_ appdata_ hex - Extract the digest from a
CIDv1string and return it as0x-prefixed hex. - composable_
cow - Return the
ComposableCowcontract address forchain. - composable_
cow_ contract_ address - Return the
ComposableCowcontract address for a given chain. - compute_
order_ uid - Compute the
CoWProtocol order UID (56-byte hex string). - cow_
protocol_ settlement_ contract_ address - Return the
CoWProtocol settlement contract address for a given chain. - cow_
protocol_ vault_ relayer_ address - Return the
CoWProtocol Vault Relayer address for a given chain. - cow_
protocol_ vault_ relayer_ address_ staging - Return the staging
CoWProtocol Vault Relayer address for a given chain. - create_
calldata - Encode calldata for
ComposableCow::create. - create_
set_ domain_ verifier_ tx - Encode a
setDomainVerifier(bytes32 domain, address verifier)call. - create_
strategies - Create all available quote strategies.
- create_
test_ conditional_ order - Create a test
ConditionalOrderParamswith optional overrides. - create_
weiroll_ contract - Create a
WeirollContractReffor a standardCALLcontract. - create_
weiroll_ delegate_ call - Build a Weiroll delegate-call
EvmCallby running a planner callback. - create_
weiroll_ library - Create a
WeirollContractReffor a Weiroll library (DELEGATECALL). - create_
with_ context_ calldata - Encode calldata for
ComposableCow::createWithContext. - data_
to_ struct - Convert
TwapData(user-facing, total amounts) into aTwapStruct(per-part amounts). - decode_
cid - Decode raw CID bytes into their constituent
CidComponents. - decode_
gat_ static_ input - ABI-decode a 448-byte
staticInputbuffer into aGatData. - decode_
order_ flags - Decode order flags from a bitfield.
- decode_
params - ABI-decode a hex string into
ConditionalOrderParams. - decode_
signature_ owner - Extract the owner (verifier) address from an EIP-1271 packed signature.
- decode_
signing_ scheme - Decode a
SigningSchemefrom a trade-flags bitfield. - decode_
stop_ loss_ static_ input - ABI-decode a 416-byte
staticInputbuffer into aStopLossData. - decode_
trade_ flags - Decode trade flags from a bitfield.
- decode_
twap_ static_ input - ABI-decode a 320-byte
staticInputbuffer intoTwapData. - decode_
twap_ struct - ABI-decode a 320-byte
staticInputbuffer into the rawTwapStruct. - default_
token_ formatter - Default token formatter: produces
"{amount}@{address}". - define_
read_ only - Apply a mutation to a value and return it — a porting convenience for builder-style field assignments.
- deterministic_
deployment_ address - Compute the deterministic
CREATE2deployment address for a contract. - domain_
separator - Compute the EIP-712 domain separator for
CoWProtocol onchain_id. - domain_
separator_ from - Compute the EIP-712 domain separator from a custom
OrderDomain. - eip1271_
result - Build a
SigningResultfor an EIP-1271 smart-contract-wallet order. - encode_
eth_ flow_ create_ order - Encode the
EthFlow.createOrder(order, quoteId)calldata. - encode_
gat_ struct - ABI-encode a
GatDatastruct into thestaticInputbytes expected by the on-chainGoodAfterTimehandler. - encode_
order_ flags - Encode order flags as a single byte bitfield.
- encode_
params - ABI-encode
ConditionalOrderParamsinto a0x-prefixed hex string. - encode_
signing_ scheme - Encode a
SigningSchemeinto its flag bits. - encode_
stop_ loss_ struct - ABI-encode a
StopLossDatastruct into the 416-bytestaticInputbytes expected by the on-chainStopLosshandler. - encode_
trade_ flags - Encode trade flags (order flags + signing scheme) as a single byte bitfield.
- encode_
twap_ struct - ABI-encode a
TwapStructinto the 320-bytestaticInputbytes expected by the on-chainTWAPhandler. - eth_
flow_ for_ env - Return the
EthFlowcontract address forchainin a given environment. - ethflow_
refund_ calldata - Build calldata for
CoWSwapEthFlow.invalidateOrder(bytes orderUid). - extensible_
fallback_ handler - Return the
ExtensibleFallbackHandlercontract address forchain. - extensible_
fallback_ handler_ contract_ address - Return the
ExtensibleFallbackHandlercontract address for a given chain. - extract_
digest - Extract the multihash digest from a CID string and return it as
0x-prefixed hex. - extract_
order_ uid_ params - Extract order UID parameters from a 56-byte hex-encoded string.
- fetch_
doc_ from_ app_ data_ hex - Fetch an
AppDataDocfrom IPFS using a hexappDatavalue. - fetch_
doc_ from_ app_ data_ hex_ legacy Deprecated - Fetch an
AppDataDocfrom IPFS using the legacy CID derivation method. - fetch_
doc_ from_ cid - Fetch an
AppDataDocfrom IPFS by itsCIDv1. - format_
epoch - Format a Unix timestamp as an
RFC 3339/ISO 8601date-time string. - from_
struct_ to_ order - Decode a raw on-chain
GpV2OrderStructinto a typedUnsignedOrder. - generate_
app_ data_ from_ doc - Compute the
keccak256hash and full JSON string from an app-data document value. - generate_
order_ id - Generate the order ID (UID) for a given order, chain, and owner.
- get_
app_ data_ info - Derive the full
AppDataInfofrom a document. - get_
app_ data_ info_ legacy Deprecated - Derive
AppDataInfousing the legacy method. - get_
app_ data_ schema - Get the app-data schema for a given version.
- get_
block_ info - Get block information (number and timestamp) for constructing conditional orders.
- get_
cache_ key - Compute a cache key for a bridge request.
- get_
chain_ info - Return the chain info for a given chain ID, or
Noneif the chain is not known. - get_
default_ slippage_ bps - Return the default slippage tolerance in basis points for a given chain and flow type.
- get_
default_ utm_ params - Return the default
UTMparameters embedded in orders by theCoWProtocolSDK. - get_
domain - Return the EIP-712
OrderDomainfor theCoWProtocol onchain_id. - get_
domain_ verifier - Alias for
get_domain_verifier_calldata. - get_
domain_ verifier_ calldata - Get the domain verifier address for a Safe from the
ExtensibleFallbackHandler. - get_
eth_ flow_ cancellation - Build an on-chain cancellation transaction for an ETH-flow order.
- get_
eth_ flow_ contract - Resolve the ETH-flow contract address for a given chain and environment.
- get_
is_ eth_ flow_ order - Return
trueifsell_tokenis the native currency sentinel address. - get_
is_ valid_ result - Check whether an
IsValidResultrepresents a valid state. - get_
order_ deadline_ from_ now - Compute the absolute Unix timestamp at which an order expires.
- get_
order_ to_ sign - Build an
UnsignedOrderfrom limit-order parameters and a quote context. - get_
order_ typed_ data - Build the EIP-712 typed data for an order, ready for signing.
- get_
partner_ fee_ bps - Extract the first
volumeBpsvalue from an optionalPartnerFee. - get_
protocol_ fee_ amount - Derive the absolute protocol-fee amount from the quote response.
- get_
quote_ amounts_ after_ partner_ fee - Calculate the partner-fee amount and adjust quote amounts accordingly.
- get_
quote_ amounts_ after_ slippage - Apply slippage tolerance to amounts after all fees.
- get_
quote_ amounts_ and_ costs - Calculate all quote-amount stages and costs from a
/quoteAPI response. - get_
quote_ raw - Fetch a raw order quote directly from the orderbook API.
- get_
quote_ with_ signer - Get a quote using a specific signer.
- get_
quote_ without_ signer - Fetch a full
QuoteResultsfor an arbitraryowneraddress — no signer required. - get_
settlement_ cancellation - Build an on-chain cancellation transaction for a settlement order.
- get_
settlement_ contract - Resolve the settlement contract address for a given chain and environment.
- get_
slippage_ percent - Compute the slippage percentage from absolute slippage amounts.
- get_
static - Look up a value by key in a static registry of
(key, value)pairs. - get_
trade_ parameters_ after_ quote - Restore the original sell token in trade parameters after an ETH-flow quote.
- get_
trader - Extract the trader’s account address from swap parameters.
- get_
wrapped_ token_ for_ chain - Return the wrapped native currency for
chain, orNoneif unknown. - grant_
role_ calldata - ABI-encode
grantRole(bytes32 role, address account)calldata. - hash_
order - Compute the EIP-712 struct hash for
order. - hash_
order_ cancellation - Compute the EIP-712 signing hash for a single order cancellation.
- hash_
order_ cancellations - Compute the EIP-712 signing hash for a batch of order cancellations.
- hash_
typed_ data - Compute the EIP-712 typed data hash:
keccak256("\x19\x01" || domainSep || structHash). - hashify
- Convert a numeric app-data value to a zero-padded 32-byte hash.
- implementation_
address_ slot - Build
eth_getStorageAtcalldata to read the EIP-1967 implementation address. - import_
schema - Import (look up) an app-data schema by version string.
- invalidate_
order_ calldata - Build calldata for
GPv2Settlement.invalidateOrder(bytes orderUid). - is_
additional_ target_ chain - Check if a chain ID is a bridge-only target chain.
- is_
btc_ chain - Check if a chain ID represents Bitcoin.
- is_
chain_ deprecated - Check if a chain is deprecated (no new trading; chain remains for history/Explorer).
- is_
chain_ under_ development - Check if a chain is under development.
- is_
composable_ cow - Returns
trueifaddressis the canonicalComposableCowfactory address. - is_
eth_ flow_ order - Returns
trueiforderis anEthFlow(native sell) order. - is_
eth_ flow_ order_ data - Check whether on-chain data is present, indicating an
EthFloworder. - is_
evm_ chain - Check if a chain ID represents an EVM chain (including bridge-only ones like Optimism).
- is_
evm_ chain_ info - Check if a
ChainInforepresents an EVM chain. - is_
extensible_ fallback_ handler - Returns
trueifaddressis the canonicalExtensibleFallbackHandlercontract. - is_
non_ evm_ chain - Check if a chain ID represents a non-EVM chain (Bitcoin, Solana).
- is_
non_ evm_ chain_ info - Check if a
ChainInforepresents a non-EVM chain. - is_
supported_ chain - Check if a chain ID is directly supported by
CoWProtocol for trading. - is_
target_ chain_ id - Check if a chain ID is either a supported chain or a bridge target.
- is_
valid_ abi - Returns
trueifhexis a plausibly valid ABI-encodedConditionalOrderParams. - is_
zk_ sync_ chain - Check if a chain is zkSync-based.
- kind_
to_ string - Reverse-map a
keccak256-hashed order-kind string back to its name. - map_
address_ to_ supported_ networks - Map an address to all supported networks.
- map_
all_ networks - Map a value across all target chains (supported + additional), returning a
Vecof(TargetChainId, T)pairs. - map_
quote_ amounts_ and_ costs - Apply a mapping function to every amount in a
QuoteAmountsAndCosts. - map_
supported_ networks - Map a value across all supported chains, returning a
Vecof(SupportedChainId, T)pairs. - merge_
app_ data_ doc - Deep-merge
otherintobaseand return the result. - normalize_
buy_ token_ balance - Normalize the buy token balance, converting
ExternaltoErc20. - normalize_
order - Normalize an
UnsignedOrderfor EIP-712 hashing, filling defaults. - order_
explorer_ link - Build a
CoWProtocol Explorer link for an order. - order_
hash - Compute the EIP-712 struct hash for
order. - order_
id - Compute the on-chain order ID from
ConditionalOrderParams. - owner_
address_ slot - Build
eth_getStorageAtcalldata to read the EIP-1967 admin/owner address. - pack_
order_ uid_ params - Pack order UID parameters into a 56-byte hex-encoded string.
- parse_
cid - Parse a CID string into its constituent
CidComponents. - percentage_
to_ bps - Convert a percentage value to basis points (rounded).
- permit_
digest - Compute the EIP-712 signing digest for a
Permitstruct. - permit_
domain_ separator - Compute the EIP-712 domain separator for a token that implements
EIP-2612. - permit_
type_ hash - Compute
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"). - pin_
json_ in_ pinata_ ipfs - Upload an
AppDataDocto IPFS via the Pinata pinning service. - post_
co_ w_ protocol_ trade - Post a signed order to the
CoWProtocol orderbook. - post_
cow_ protocol_ trade - Post a signed order to the
CoWProtocol orderbook. - post_
sell_ native_ currency_ order - Post a native-currency sell order via the ETH-flow contract.
- presign_
result - Build a
SigningResultfor a pre-sign order. - remove_
calldata - Encode calldata for
ComposableCow::remove(bytes32 id). - required_
vault_ role_ calls - Generate all
grantRolecalls needed to authorize an account on the Balancer Vault. - required_
vault_ role_ selectors - Return the function selectors for the Vault methods that require authorization.
- resolve_
order_ book_ api - Resolve an
OrderBookApifor the given chain and environment. - resolve_
signer - Resolve a signer from an optional hex private key.
- resolve_
slippage_ suggestion - Resolve the slippage suggestion for a trade.
- revoke_
role_ calldata - ABI-encode
revokeRole(bytes32 role, address account)calldata. - safe_
call_ best_ quote_ callback - Safely invoke a “best quote” callback, catching panics.
- safe_
call_ progressive_ callback - Safely invoke a “progressive quote” callback, catching panics.
- set_
pre_ signature_ calldata - Build calldata for
GPv2Settlement.setPreSignature(bytes orderUid, bool signed). - set_
root_ calldata - Encode calldata for
ComposableCow::setRoot. - set_
root_ with_ context_ calldata - Encode calldata for
ComposableCow::setRootWithContext. - settlement_
contract - Return the production settlement contract address for
chain. - settlement_
contract_ for_ env - Return the settlement contract address for
chainin a given environment. - settlement_
refund_ calldata - Build calldata for
GPv2Settlement.freeFilledAmountStorage(bytes orderUid). - sign_
order - Sign
orderusing EIP-712 typed data and return the encodedSigningResult. - sign_
order_ cancellation - Sign a single order cancellation using EIP-712 typed data.
- sign_
order_ cancellations - Sign one or more order cancellations using EIP-712 typed data.
- sign_
permit - Sign an
EIP-2612permit and return the raw 65-byter ‖ s ‖ vsignature. - signing_
digest - Compute the final signing digest:
"\x19\x01" ‖ domainSep ‖ orderHash. - stringify_
deterministic - Serialise
docto a deterministic JSON string with all object keys sorted alphabetically at every nesting level. - struct_
to_ data - Convert a
TwapStruct(per-part, on-chain view) back intoTwapData. - suggest_
slippage_ bps - Suggest a slippage tolerance for a trade, combining fee- and volume-based components.
- suggest_
slippage_ from_ fee - Compute the fee-based slippage component.
- suggest_
slippage_ from_ volume - Compute the volume-based slippage component.
- supported_
chain_ info - Return the
ChainInfofor aSupportedChainId. - swap_
params_ to_ limit_ order_ params - Convert
TradeParameters+ a raw quote response intoLimitTradeParametersFromQuote. - tradable_
supported_ chain_ ids - Return chain IDs where new trading is allowed (excludes deprecated chains).
- tradable_
supported_ chains - Return chain info for tradable supported chains (excludes deprecated).
- transform_
data_ to_ struct - Transform raw contract data bytes into a
ConditionalOrderParamsstruct. - transform_
order - Enrich an
Orderby computing itstotal_feefield. - transform_
struct_ to_ data - Transform a
ConditionalOrderParamsstruct back into ABI-encoded hex. - unsigned_
order_ for_ signing - Convert an
UnsignedOrderinto a form suitable for on-chain signing. - upload_
app_ data_ to_ pinata - Upload an
AppDataDocto IPFS via the Pinata pinning service. - upload_
metadata_ doc_ to_ ipfs_ legacy Deprecated - Upload an
AppDataDocto IPFS via Pinata using the legacy method. - validate_
app_ data_ doc - Validate an
AppDataDocagainst allCoWProtocol app-data rules. - vault_
relayer - Return the vault relayer contract address for
chain. - vault_
relayer_ for_ env - Return the vault relayer contract address for
chainin a given environment. - vault_
role_ hash - Compute the Balancer Vault action-ID hash for a given vault and function selector.
- wrapped_
native_ currency - Return the wrapped native currency
TokenInfoforchain.
Type Aliases§
- Address
PerChain - Per-chain address mapping for supported chains.
- ApiBase
Urls - Per-chain base URL mapping for supported chains.