Gate DEX CLI — Swap
General Rules
⚠️ STOP — You MUST read and strictly follow the shared runtime rules before proceeding.
Do NOT select or call any tool until all rules are read. These rules have the highest priority.
→ Read
gate-runtime-rules.md
- Only call MCP tools explicitly listed in this skill. Tools not documented here must NOT be called, even if they
exist in the MCP server.
- Only use the CLI subcommands explicitly listed in this skill and its references. Commands not documented here must NOT be run for these workflows, even if other interfaces expose them.
One-shot DEX swap via CLI. GV checkin + sign + broadcast are all built into the
command. No external
binary needed. Supports EVM and Solana.
Skill Boundaries
| This skill | Route to other skill |
|---|
| Swap tokens (same-chain) | Auth / login issues → |
| Cross-chain bridge | Balance, address, token list → |
| Swap quote (preview) | Token transfers (send) → |
| Swap / bridge history & order detail | K-line, token info, token security → |
| Swappable & bridge token discovery | — |
Applicable Scenarios
- "Swap ETH for USDT", "exchange tokens", "buy SOL", "convert", "trade"
- Get a swap quote before executing
- View swap history or a specific swap order detail
- List swappable tokens or cross-chain bridge tokens
CLI Commands
Quote (preview only, no signing)
bash
# EVM: swap native ETH → USDT on Ethereum (chain_id = 1)
gate-dex quote --from-chain 1 --to-chain 1 --from - --to 0xdAC17F958D2ee523a2206206994597C13D831ec7 --amount 0.01
# EVM: swap USDT → USDC on Arbitrum
gate-dex quote --from-chain 42161 --to-chain 42161 \
--from 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9 \
--to 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 \
--amount 100
# Solana: swap native SOL → USDC
gate-dex quote --from-chain 501 --to-chain 501 --from - \
--to EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v --amount 0.1
# Cross-chain bridge: ETH on Ethereum → USDT on Arbitrum
gate-dex quote --from-chain 1 --to-chain 42161 --from - \
--to 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9 --amount 0.1 \
--to-wallet 0xYourArbitrumAddress
Returns estimated output amount, price impact, route, and fee. No signing.
One-Shot Swap (quote + GV checkin + sign + broadcast)
bash
# EVM: swap native ETH → USDT
gate-dex swap --from-chain 1 --to-chain 1 --from - \
--to 0xdAC17F958D2ee523a2206206994597C13D831ec7 --amount 0.01
# EVM: swap ERC20 with custom slippage
gate-dex swap --from-chain 42161 --to-chain 42161 \
--from 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9 \
--to 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 \
--amount 100 --slippage 0.005
# Solana: swap SOL → USDC
gate-dex swap --from-chain 501 --to-chain 501 --from - \
--to EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v --amount 0.05
# Cross-chain bridge: ETH on Ethereum → USDT on Arbitrum
gate-dex swap --from-chain 1 --to-chain 42161 --from - \
--to 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9 --amount 0.1 \
--to-wallet 0xYourArbitrumAddress
| Option | Required | Description |
|---|
| Yes | Source chain ID |
| No | Destination chain ID (defaults to same as from-chain) |
| Yes | Source token contract; use for native token (ETH/SOL/BNB) |
| Yes | Destination token contract |
| Yes | Human-readable input amount |
| No | Slippage tolerance as decimal (default 0.03 = 3%) |
| No | if source token is native (ETH/SOL); default |
| No | if destination token is native; default |
| No | Source wallet address (auto-detected from auth) |
| No | Destination wallet address (required for cross-chain bridge) |
Swap History
Swap Order Detail
bash
gate-dex swap-detail <order_id>
List Swappable Tokens
bash
gate-dex swap-tokens
gate-dex swap-tokens --chain eth
gate-dex swap-tokens --chain sol --search USDC
Use
to look up a token address by symbol.
List Cross-Chain Bridge Tokens
bash
gate-dex bridge-tokens
gate-dex bridge-tokens --src-chain eth --dest-chain arb
Internal Flow of Command
The agent does not run any of these steps manually — the CLI handles everything:
EVM same-chain flow:
1. Load auth; fetch wallet address
2. Get quote
3. Check if ERC20 approve is needed → auto-approve if needed (GV checkin for approve)
4. Re-quote after approve
5. Build swap transaction
6. GV security checkin (built-in) for swap tx
7. Server-side signing
8. Broadcast
9. Print tx hash + order ID
EVM cross-chain bridge flow (from-chain ≠ to-chain):
1. Load auth; fetch wallet address
2. Get cross-chain bridge quote (--from-chain / --to-chain / --to-wallet required)
3. Check if ERC20 approve is needed on source chain → auto-approve if needed
4. Build bridge transaction on source chain
5. GV security checkin (built-in)
6. Server-side signing
7. Broadcast on source chain
8. Print source tx hash + order ID (destination arrival is async, monitor via swap-detail)
Solana flow:
1. Load auth; fetch Solana address
2. Get quote
3. Build transaction (base64 → base58 conversion handled internally)
4. GV security checkin (built-in, includes priority fee)
5. Server-side signing
6. Broadcast via Solana mainnet RPC
7. Print tx hash + order ID
CRITICAL: There is no
binary to run. Do NOT attempt to run a checkin binary before
. The CLI has GV checkin built in.
Chain IDs
| Chain | ID | Native Token |
|---|
| Ethereum | 1 | ETH |
| BSC | 56 | BNB |
| Polygon | 137 | MATIC |
| Arbitrum | 42161 | ETH |
| Optimism | 10 | ETH |
| Avalanche | 43114 | AVAX |
| Base | 8453 | ETH |
| Solana | 501 | SOL |
Native token address: Use
as the token address for native tokens (ETH, SOL, BNB, etc.).
Slippage Guidelines
| Token type | Recommended slippage |
|---|
| Stablecoins (USDT ↔ USDC) | 0.005 (0.5%) |
| Major tokens (ETH, BTC, SOL) | 0.01–0.03 (1%–3%) |
| Mid-cap tokens | 0.03 (3%) |
| Meme / low-liquidity tokens | 0.05–0.10 (5%–10%) |
Common Token Addresses
| Chain | USDT | USDC |
|---|
| Ethereum (1) | 0xdAC17F958D2ee523a2206206994597C13D831ec7
| 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
|
| Arbitrum (42161) | 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9
| 0xaf88d065e77c8cC2239327C5EDb3A432268e5831
|
| BSC (56) | 0x55d398326f99059fF775485246999027B3197955
| 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d
|
| Solana (501) | Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB
| EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
|
Workflow
Step 1: Auth check
Call
to verify the session.
Key data to extract:
- : boolean
- If not logged in → instruct the user to run (delegated to ).
Step 2: Collect parameters
Required:
,
(defaults to
),
,
,
. Optional:
,
(cross-chain only).
If a token symbol is given without an address → call
gate-dex swap-tokens --chain <chain> --search <symbol>
and confirm the resolved address with the user.
Key data to extract:
Step 3: Get quote
Call
gate-dex quote --from-chain <id> --to-chain <id> --from <token> --to <token> --amount <n>
.
Key data to extract:
Step 4: User confirmation in chat (MANDATORY)
Render the Swap Confirmation Template and wait for an explicit "confirm" reply.
- "cancel" → abort.
- "modify" → return to Step 2.
Step 5: Execute
Call
gate-dex swap --from-chain <id> --to-chain <id> --from <token> --to <token> --amount <n> [--slippage <n>] [--to-wallet <addr>]
. The CLI handles GV check-in, signing, and broadcast internally.
Key data to extract:
Step 6: Render the report
Format the output per Report Template below. Surface the mandatory Risk Disclosure.
NEVER run before receiving explicit user confirmation in Step 4.
Judgment Logic Summary
| User Intent | Trigger Phrases | Action |
|---|
| Same-chain swap | "swap", "exchange", "convert", "buy", "sell" + same chain | quote → confirm → swap (Steps 3–5) |
| Cross-chain bridge | "bridge", "cross-chain", different from-chain / to-chain | bridge-tokens → quote (with ) → confirm → swap |
| Quote only | "how much would I get", "estimate", "preview" with no execution intent | Step 3 only; do not execute |
| Resolve token address | "what's the address", "find token X" | gate-dex swap-tokens --search
|
| List swappable tokens | "what tokens can I swap" | |
| List bridge pairs | "what cross-chain pairs are supported" | |
| Order history | "my swap history", "past trades" | |
| Order detail | "details of order X", bridge settlement check | gate-dex swap-detail <order_id>
|
| Authentication failure | from CLI | Route to for login |
Swap Confirmation Template
========== Swap Confirmation ==========
From: {amount} {from_symbol} on {from_chain}
To: ~{estimated_out} {to_symbol} on {to_chain}
Slippage: {slippage}%
Route: {route_path}
Fee: {fee_usd} USD
========================================
Reply "confirm" to execute, "cancel" to abort.
Report Template
========== Swap Result ==========
Status: Submitted
From: {amount} {from_symbol} on {from_chain}
To: ~{estimated_out} {to_symbol} on {to_chain}
Tx hash: {tx_hash}
Explorer: {explorer_url}
Order ID: {order_id}
=================================
{Cross-chain note (if applicable): destination arrival is asynchronous; track via gate-dex swap-detail <order_id>.}
Risk Disclosure: Digital asset trading involves significant risk and may result in partial or total loss of your investment. For informational purposes only; not investment, financial, tax, or legal advice.
========== Swap Quote (Preview) ==========
{Same fields as Swap Confirmation Template}
==========================================
No transaction has been signed or broadcast.
For
/
: render a compact list/table of order id, chain pair, token pair, status, timestamp.
Conversation Examples
Example 1: Swap ETH → USDT on Ethereum
User: "Swap 0.01 ETH for USDT on Ethereum"
gate-dex quote --from-chain 1 --to-chain 1 --from - --to 0xdAC17... --amount 0.01
- Show quote to user; wait for "confirm".
gate-dex swap --from-chain 1 --to-chain 1 --from - --to 0xdAC17... --amount 0.01
- Display tx hash + etherscan link + order ID.
Example 2: Swap SOL → USDC
User: "Swap 0.1 SOL for USDC"
gate-dex quote --from-chain 501 --to-chain 501 --from - --to EPjFWdd5... --amount 0.1
- Show quote; user confirms.
gate-dex swap --from-chain 501 --to-chain 501 --from - --to EPjFWdd5... --amount 0.1
- Display tx hash + solscan link.
Example 3: Unknown token symbol
User: "Swap 10 USDT for ARB on Arbitrum"
gate-dex swap-tokens --chain arb --search ARB
→ get ARB contract address.
- Proceed with quote and swap using the resolved address.
Example 4: Cross-chain bridge ETH (Ethereum) → USDT (Arbitrum)
User: "Bridge 0.1 ETH from Ethereum to USDT on Arbitrum"
gate-dex bridge-tokens --src-chain eth --dest-chain arb
→ confirm the token pair is supported.
gate-dex quote --from-chain 1 --to-chain 42161 --from - --to 0xFd086bC7... --amount 0.1 --to-wallet 0xYourAddress
- Show quote to user; wait for "confirm".
gate-dex swap --from-chain 1 --to-chain 42161 --from - --to 0xFd086bC7... --amount 0.1 --to-wallet 0xYourAddress
- Display source chain tx hash; note that destination arrival is async — user can track via
gate-dex swap-detail <order_id>
.
Error Handling
| Error | Handling |
|---|
| Run |
| Insufficient balance | Abort; show shortfall |
| Quote expired | CLI re-quotes automatically before signing |
| Slippage too low | Suggest higher slippage (0.05 for volatile tokens) |
| GV checkin failed (built-in) | CLI displays error; suggest retry |
| Broadcast failed | Display error code; do not auto-retry |
| User cancels | Abort immediately |
Security Rules
- Confirm before swap: Always get explicit user confirmation before running . Without explicit user confirmation in chat, no command may be executed — only and other read-only commands are allowed.
- Show quote first: Always run first so the user can see estimated output.
- No tx-checkin binary: CLI handles GV checkin internally — do not run any external binary.
- Audit unfamiliar tokens: Recommend before swapping unknown tokens.
- Transaction irreversibility: On-chain swaps and bridges are generally irreversible. Always re-verify chain, token addresses, amount, and (for bridge) destination wallet with the user before executing.
Risk Disclosure
Mandatory in trade output: Digital asset trading involves significant risk and may result in partial or total loss of your investment. Cross-chain bridge transactions add settlement-time and counterparty risk; destination arrival is asynchronous.
The above is for informational purposes only and does not constitute investment, financial, tax, or legal advice. AI-assisted outputs are for general information only and do not constitute any representation, warranty, or guarantee by Gate. This skill is intended for users aged 18 or above with full civil capacity; availability may vary by jurisdiction.