Skip to content

agentswap trade is the CLI path for User Proxy agent orders. It requests a quote from the AgentSwap service, signs an AgentOrder EIP-712 message, and optionally broadcasts the signed order for on-chain execution. That flow is separate from Intent Settler orders documented under Build and open intents documented under Agent intents.

The signed struct, typehash, and on-chain checks are defined in Agent delegation — this page covers the CLI interface only, not the field list.

Item Value
Default --mode agent-order
Proxy --proxy or AGENTSWAP_PROXY — the User Proxy the order is bound to
Order type AgentOrder (nine fields; includes current policy generation)
EIP-712 domain User Proxy agent-order domain
Default --deadline-secs 120 seconds from signing
Terminal window
export AGENTSWAP_PROXY=0xYourUserProxy
agentswap trade --chainid 8453 --from USDC --to WETH --amount 1000000 \
--proxy "$AGENTSWAP_PROXY" --key-file ./agent-signer.txt

--from, --to, and --amount select the swap legs. --amount is amountIn in raw token units. --slippage is optional and is sent to the quote step before signing.

Execution is opt-in. Two global flags define the boundary between a signing preview and a spend.

Without --allow-trade, trade is forced to dry-run: it will not broadcast on-chain. Pass --allow-trade on each invocation (or wrap the binary) when you intend real execution.

Terminal window
# Preview only — no --allow-trade. --min-out may be omitted here.
agentswap trade --chainid 8453 --from USDC --to WETH --amount 1000000 \
--proxy 0xYourUserProxy --key-file ./agent-signer.txt
# Sign and self-submit. --min-out is REQUIRED once the trade can move funds.
agentswap --allow-trade trade --chainid 8453 --from USDC --to WETH --amount 1000000 \
--min-out 240000000000000000 \
--proxy 0xYourUserProxy --self-submit --key-file ./agent-signer.txt

--min-out is mandatory whenever the trade is not a dry run. Without it the CLI refuses to sign, and the refusal is deliberate: the only other source of a floor is the quote server’s own output, and a protection floor taken from the party being protected against is not a floor. In dry-run the CLI will derive a preview floor from --slippage (default 50 bps); that derived value is for inspection, never for execution.

--dry-run on the trade subcommand forces preview even if --allow-trade is set.

--max-amount (AGENTSWAP_TRADE_MAX_AMOUNT) caps amountIn per trade in raw input-token units. If the requested --amount exceeds the cap, the CLI refuses to sign or submit.

Terminal window
export AGENTSWAP_TRADE_MAX_AMOUNT=5000000 # 5 USDC with 6 decimals
agentswap --allow-trade --max-amount "$AGENTSWAP_TRADE_MAX_AMOUNT" \
trade --chainid 8453 --from USDC --to WETH --amount 1000000 \
--min-out 240000000000000000 \
--proxy 0xYourUserProxy --key-file ./agent-signer.txt

This cap also applies to trades initiated through the MCP server (below). That is the case that matters: an MCP client is a model, not a person. Set --max-amount before handing an agent agentswap mcp with --allow-trade.

Flag Env Effect
--allow-trade — Required for any non-dry-run submission. Not required for signing — see the caution above
--max-amount AGENTSWAP_TRADE_MAX_AMOUNT Upper bound on amountIn; enforced for CLI and MCP

Provide the agent’s private key with --key-file (per-command or global AGENTSWAP_KEY_FILE). Do not pass keys on the command line.

Terminal window
agentswap --allow-trade --key-file ./agent-signer.txt \
trade --chainid 8453 --from USDC --to WETH --amount 1000000 \
--min-out 240000000000000000 \
--proxy 0xYourUserProxy

Optional --nonce sets the agent order nonce. Omit it and the CLI generates eight random bytes — it does not read the proxy’s nonce bitmap, so the value is unused only with overwhelming probability, not by verification. Pass --nonce explicitly when you are tracking nonces yourself. isAgentNonceUsed(agent, nonce) on the proxy is what actually answers the question.

After signing, broadcast on-chain with --self-submit.

Flag Env Behaviour
--self-submit — Broadcast on-chain transaction calling executeAsAgent (dry-run returns calldata preview)
Terminal window
# Local calldata preview (dry-run)
agentswap trade --chainid 8453 --from USDC --to WETH --amount 1000000 \
--proxy 0xYourUserProxy --self-submit --key-file ./agent-signer.txt
# Broadcast on-chain from local signer
agentswap --allow-trade \
trade --chainid 8453 --from USDC --to WETH --amount 1000000 \
--min-out 240000000000000000 \
--proxy 0xYourUserProxy --self-submit --key-file ./agent-signer.txt

When --allow-trade is set, --self-submit broadcasts the executeAsAgent transaction directly to the network using the RPC configured for the chain, waits for the receipt, and reports the transaction hash. In dry-run mode, --self-submit returns the target address and encoded calldata for inspection.

agentswap mcp exposes quote, trade, intent, and policy tools over the Model Context Protocol on stdio. Wire it into an MCP-capable host the same way as any other stdio server:

Terminal window
agentswap --allow-trade --max-amount 5000000 \
--key-file ./agent-signer.txt mcp

Available tools over MCP:

  • quote and batch_quote: swap quotes from the service
  • tokens and pools: token and pool inspection
  • trade: quote and sign User Proxy AgentOrder
  • intent_place: sign and announce open intents
  • intent_list: list announced intents (requires --owner or --agent)
  • intent_status: inspect intent state by bytes32 id
  • policy: read an agent’s permissions, generation, and token budgets

The MCP server receives settings from global flags:

  • No --allow-trade — trades and intents through MCP stay in dry-run.
  • --max-amount — enforced on MCP-initiated trades and intents; bounds any client cap.
  • --key-file / AGENTSWAP_KEY_FILE — agent signer for order signatures.
  • -k / SR_API_KEY — service authentication for quotes.

A conservative setup for an agent host:

Terminal window
export AGENTSWAP_TRADE_MAX_AMOUNT=1000000
export AGENTSWAP_KEY_FILE=/path/to/agent-signer.txt
agentswap --allow-trade --max-amount "$AGENTSWAP_TRADE_MAX_AMOUNT" mcp

Omit --allow-trade when the agent should quote and inspect but never move funds. See Install for credentials and Commands for the subcommand index. The AgentOrder field list is on Agent delegation.