For AI agents: a documentation index is available at /llms.txt. A markdown version of this page is available at the same URL with .md appended (or via Accept: text/markdown).
Skip to main content

Swap and bridge tokens

Get a quote, review the route, and execute a same-chain swap or cross-chain bridge.

Ask your agent

You (to your agent): "Swap 0.1 ETH to USDC"

For a cross-chain bridge:

You (to your agent): "Bridge 10 USDC from Base to Arbitrum"

Your agent fetches a quote, shows you the route and output, then executes after you confirm.

Prerequisites

  • Quickstart completed
  • Sufficient balance of the source token on the source chain

Same-chain swap

  1. Request a quote:

    mm swap quote --from <TOKEN> --to <TOKEN> --amount <AMOUNT> --from-chain <CHAIN_ID> [--slippage <PERCENT>]
  2. Review the quoted output, fees, and route in the command output. Note the quoteId.

  3. Execute the swap:

    mm swap execute --quote-id <QUOTE_ID>
  4. Optionally check status:

    mm swap status --quote-id <QUOTE_ID>

Cross-chain bridge

Include --to-chain when requesting a quote:

mm swap quote --from USDC --to USDC --amount 10 --from-chain 8453 --to-chain 42161
mm swap execute --quote-id <QUOTE_ID>

Send bridged tokens to another address

Add --to-address to send output tokens to a recipient other than your wallet. Only valid for cross-chain bridges (--to-chain differs from --from-chain):

mm swap quote --from USDC --to USDC --amount 10 --from-chain 8453 --to-chain 42161 --to-address 0x742d35Cc6634C0532925a3b844Bc454e4438f08e

Top up destination gas (refuel)

When bridging to a chain where you hold no native gas token, add --refuel to bundle a small destination native-gas top-up into the quote:

mm swap quote --from USDC --to USDC --amount 50 --from-chain 1 --to-chain 42161 --refuel

Refuel is opt-in and cross-chain only. Do not use --refuel when the destination token is the destination chain's native gas asset (for example, bridging ETH to Arbitrum ETH). The backend returns NO_QUOTES in that case.

Compare quotes

Use --all-quotes to see all available routes ranked by your preferred strategy:

mm swap quote --from ETH --to USDC --amount 0.5 --from-chain 1 --all-quotes --strategy cost,speed

A ★ marks the recommended quote. Execute a specific quote by its ID:

mm swap execute --quote-id <QUOTE_ID>

Available strategies: cost, speed, impact, output. The default is cost,speed.

Gasless swaps

When your wallet's native balance cannot cover gas, the CLI automatically uses gasless execution via the EIP-7702 relay for eligible quotes. No additional flags are required.

Common pitfalls

Verify the quote step succeeded

If mm swap quote returns an error or no quote ID, do not call mm swap execute with a fabricated or expired quote ID. The execute step fails and no transaction is submitted, even when partial output is printed.

See mm swap in the commands reference.