Skip to content

Latest commit

 

History

History
46 lines (30 loc) · 1.3 KB

File metadata and controls

46 lines (30 loc) · 1.3 KB

Swap Workflow

Use this workflow when the user wants to swap tokens on the same chain.

Reference command syntax in references/swap.md.

Flow

  1. Quote.
  2. Confirm with the user.
  3. Execute and track status.

Do not skip the quote review step. It is where the user sees output amount, fees, route, and slippage.

Quote

mm-dev swap quote --from ETH --to USDC --amount 1 --from-chain 1

Required flags: --from, --to, --amount, and --from-chain.

Persist the quote id for execution. Show the quote to the user before execution. Confirm source token, destination token, amount, chain, slippage, expected output, fees, and route.

Execute

mm-dev swap execute --quote-id "$QUOTE_ID"

Prefer executing by quote ID. Re-quote-and-execute flags exist, but quote ID execution keeps the reviewed quote tied to the submitted action.

Status

mm-dev swap status --quote-id "$QUOTE_ID"

Edge Cases

  • Quote expired: re-quote and ask the user to review the new quote.
  • Insufficient balance: surface the error verbatim.
  • Slippage exceeded: only increase --slippage if the user explicitly accepts more slippage. Always warn the user if slippage is increased above 1% that it will affect the minimum received.
  • Missing chain: use mm-dev chains list before guessing a chain ID.