Documentation Index
Fetch the complete documentation index at: https://cowswap-mintlify-docs-quality-audit-1774257282.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
swap_tokens
Swap tokens using the CoW Protocol. This is the main high-level function for executing token swaps.CowContractAddress.VAULT_RELAYER needs to be approved to spend the sell token before calling this function.Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
amount | Wei | Yes | - | Amount of tokens to sell (in Wei) |
account | LocalAccount | Yes | - | Ethereum account to sign the order with |
chain | Chain | Yes | - | Blockchain network to execute on |
sell_token | ChecksumAddress | Yes | - | Address of the token to sell |
buy_token | ChecksumAddress | Yes | - | Address of the token to buy |
safe_address | ChecksumAddress | None | No | None | Safe address (uses pre-signature scheme if provided) |
app_data | str | No | DEFAULT_APP_DATA_HASH | Application metadata hash |
valid_to | int | None | No | None | Order expiration (Unix timestamp). Uses quote validity if not set |
env | Envs | No | "prod" | Environment ("prod", "staging") |
slippage_tolerance | float | No | 0.005 | Slippage tolerance (0.005 = 0.5%) |
partially_fillable | bool | No | False | Allow partial fills |
Returns
Returns aCompletedOrder object.
Usage
With Safe Multi-Sig
CompletedOrder
A Pydantic model representing a successfully created order.Fields
| Field | Type | Description |
|---|---|---|
uid | UID | Unique order identifier (56 bytes) |
url | str | CoW Explorer URL for tracking |
Explorer URLs
The URL points to CoW Explorer based on the chain:- Mainnet:
https://explorer.cow.fi/ethereum/orders/{uid} - Gnosis Chain:
https://explorer.cow.fi/gc/orders/{uid} - Arbitrum:
https://explorer.cow.fi/arb1/orders/{uid}