$npx -y skills add gate/gate-skills --skill gate-dex-tradeExecutes on-chain token swaps via Gate DEX. Use when user wants to swap, buy, sell, exchange, or convert tokens, or bridge cross-chain. Covers full swap flow: price quotes, transaction build, signing, and submission. Do NOT use for read-only data lookups or wallet account managem
| 1 | # Gate DEX Trade |
| 2 | |
| 3 | |
| 4 | > **Pure Routing Layer** — Swap EXECUTION only. Every operation produces an on-chain transaction. All specifications in `references/`. |
| 5 | |
| 6 | ## General Rules |
| 7 | |
| 8 | ⚠️ STOP — You MUST read and strictly follow the shared runtime rules before proceeding. |
| 9 | Do NOT select or call any tool until all rules are read. These rules have the highest priority. |
| 10 | → Read [gate-runtime-rules.md](https://github.com/gate/gate-skills/blob/master/skills/gate-runtime-rules.md) |
| 11 | - **Only call MCP tools explicitly listed in this skill.** Tools not documented here must NOT be called, even if they |
| 12 | exist in the MCP server. |
| 13 | |
| 14 | **Trigger Scenarios**: Use when the user wants to **execute a token exchange** that modifies blockchain state: |
| 15 | - Swap: "swap ETH for USDT", "exchange 100 USDC to DAI", "convert my BNB" |
| 16 | - Buy/Sell: "buy ETH", "sell my USDT", "purchase SOL" |
| 17 | - Cross-chain: "bridge ETH from Arbitrum to Base", "cross-chain swap" |
| 18 | - Swap quote: "how much USDT will I get for 1 ETH" (with intent to trade) |
| 19 | |
| 20 | ## Project convention — MCP only (this workspace) |
| 21 | |
| 22 | **Do not use OpenAPI** for swap unless user explicitly asks OpenAPI/AK/SK. MCP unavailable → `references/setup.md` only. |
| 23 | |
| 24 | --- |
| 25 | |
| 26 | **NOT this skill** (common misroutes): |
| 27 | - "what is the price of ETH" → `gate-dex-market` (read-only lookup, no trade intent) |
| 28 | - "check my swap history" → `gate-dex-wallet` (account query) |
| 29 | - "transfer ETH to 0xABC..." → `gate-dex-wallet` (direct transfer, not swap) |
| 30 | - "approve contract" (outside swap context) → `gate-dex-wallet` (DApp interaction) |
| 31 | |
| 32 | --- |
| 33 | |
| 34 | ## Routing Flow |
| 35 | |
| 36 | ```text |
| 37 | User triggers trading intent |
| 38 | ↓ |
| 39 | Step 1: Has user explicitly specified a mode? |
| 40 | ├─ Explicitly mentions "OpenAPI" / "AK/SK" / "API Key" → OpenAPI mode |
| 41 | ├─ Otherwise → MCP only (Step 2) |
| 42 | └─ Not specified → Step 2 |
| 43 | ↓ |
| 44 | Step 2: Is this a cross-chain swap? |
| 45 | ├─ Cross-chain → Must use MCP mode (OpenAPI doesn't support cross-chain), proceed to Step 3 |
| 46 | └─ Same-chain / uncertain → Step 3 |
| 47 | ↓ |
| 48 | Step 3: Gate Wallet MCP Server Discovery & Detection |
| 49 | a) Scan configured MCP Server list for Servers providing `dex_tx_swap_quote`, `dex_tx_swap_prepare`, and staged swap signing tools (and the Gate GV MCP that exposes `tx_checkin` for staged check-in; see MCP Mode below) |
| 50 | b) If found → Record server identifier, verify with: |
| 51 | CallMcpTool(server="<identifier>", toolName="dex_chain_config", arguments={chain: "ETH"}) |
| 52 | ├─ Success → MCP mode |
| 53 | └─ Failed → Step 4 |
| 54 | c) No matching Server → Step 4 |
| 55 | ↓ |
| 56 | Step 4: MCP unavailable → setup guide only (`references/setup.md`), no OpenAPI fallback |
| 57 | ``` |
| 58 | |
| 59 | --- |
| 60 | |
| 61 | ## Mode Dispatch |
| 62 | |
| 63 | ### MCP Mode |
| 64 | |
| 65 | **Read and strictly follow** `references/mcp.md`, execute according to its complete workflow. |
| 66 | |
| 67 | Includes: connection detection, authentication (mcp_token), MCP Resource/tool calls (`dex_tx_swap_quote` / `dex_tx_swap_prepare` / `dex_tx_swap_checkin_preview` / staged sign-submit / `dex_tx_swap_detail`), token address resolution, native_in/native_out rules, three-step confirmation gateway (SOP), quote templates, risk warnings, cross-Skill collaboration, security rules. |
| 68 | |
| 69 | **Staged swap check-in** — after each `dex_tx_swap_checkin_preview` (per stage: `approve` then `swap` as required), call the **Gate Web3 GV MCP** tool **`tx_checkin`** using the preview fields. The user environment must include that MCP server (discover via `tools/list`). **Parameter mapping:** `references/mcp.md` §4.3 — map preview `mcp_token` → `authorization` as `Bearer <token>`; `user_wallet` → `wallet_address`; `checkin_message` → `message`; set `source` to **integer `3`**; pass `chain` / `chain_category` as returned; set `type` to **`""`** unless GV/product documents a required non-empty value. Read **`data.checkin_token`** (and handle **`need_otp`**) from the tool result, then call `dex_tx_swap_sign_approve` / `dex_tx_swap_sign_swap`. **Do not** reimplement GV check-in with raw `curl` or custom signing. |
| 70 | |
| 71 | ### OpenAPI Mode (Progressive Loading) |
| 72 | |
| 73 | **Default off in this workspace** — explicit OpenAPI request only. |
| 74 | |
| 75 | **Limitation: OpenAPI mode only supports same-chain Swap, does not support cross-chain exchanges.** |
| 76 | |
| 77 | Load files progressively — only load what the current step needs: |
| 78 | |
| 79 | 1. **Always load first**: `references/openapi/_shared.md` — env detection, credentials, API call method (via helper script) |
| 80 | 2. **Then load based on swap stage**: |
| 81 | |
| 82 | | Stage | Load File | When | |
| 83 | |-------|-----------|------| |
| 84 | | Query (chain/gas) | `references/openapi/quote.md` | User asks about chains or gas | |
| 85 | | Swap: get quote | `references/openapi/quote.md` + `references/openapi/sop.md` | User initiates swap | |
| 86 | | Swap: build tx | `references/openapi/build.md` | After quote |