gate-dex-trade
Gate DEX Trade
Trading Comprehensive Skill β MCP + OpenAPI dual mode support, intelligent routing selects optimal trading method
Trigger Scenarios: Use when users mention "swap", "exchange", "buy", "sell", "trade", "quote" and other related operations.
π― Dual Mode Architecture
| Mode | Connection Method | Advantages | Use Cases |
|---|---|---|---|
| π MCP Mode | gate-wallet MCP Server | Unified authentication, wallet ecosystem integration | Complete trading process, cross-Skill collaboration |
| β‘ OpenAPI Mode | AK/SK direct calls | Independent execution, complete lifecycle | Fast trading, full chain control |
π Smart Routing Rules
System automatically selects calling mode based on following priorities:
| Priority | Condition | Selected Mode | Routing Target |
|---|---|---|---|
| 1 | Explicitly mentions "OpenAPI", "AK/SK" | β‘ OpenAPI | references/openapi.md |
| 2 | Exists ~/.gate-dex-openapi/config.json |
β‘ OpenAPI | references/openapi.md |
| 3 | From wallet Skills cross-Skill calls | π MCP | Current SKILL.md main process |
| 4 | Default scenario | π MCP | Current SKILL.md main process |
User Preferences:
- Pursue complete ecosystem integration β MCP mode
- Pursue independent fast execution β OpenAPI mode
MCP Server Connection Detection
First Session Detection
Before first MCP tool call in session, perform one connection probe to confirm Gate Wallet MCP Server availability. No need to repeat detection for subsequent operations.
CallMcpTool(server="gate-wallet", toolName="chain.config", arguments={chain: "eth"})
| Result | Handling |
|---|---|
| Success | MCP Server available, subsequent operations directly call business tools, no need to probe again |
| Failure | Display configuration guidance based on error type (see error handling below) |
Runtime Error Fallback
If business tool calls fail during subsequent operations (returning connection errors, timeouts etc.), handle according to following rules:
| Error Type | Keywords | Handling |
|---|---|---|
| MCP Server not configured | server not found, unknown server |
Display MCP Server configuration guidance |
| Remote service unreachable | connection refused, timeout, DNS error |
Prompt to check server status and network connection |
| Authentication failed | 401, unauthorized, x-api-key |
Prompt to contact administrator for API Key |
Authentication Description
All operations in MCP mode require mcp_token. Must confirm user is logged in before calling any tool.
- If currently no
mcp_tokenβ Guide togate-dex-wallet/references/authto complete login then return - If
mcp_tokenexpired (MCP Server returns token expired error) β First tryauth.refresh_tokensilent refresh, guide re-login if failed
MCP Tool Call Specification (Main Process)
1. tx.quote β Get Swap Quote
Get Swap quote from input token to output token.
| Field | Description |
|---|---|
| Tool Name | tx.quote |
| Parameters | { chain_id_in: string, chain_id_out: string, token_in: string, token_out: string, amount: string, slippage?: number, user_wallet: string, native_in?: boolean, native_out?: boolean, mcp_token: string } |
| Return | Quote details including exchange rate, slippage, routing path, estimated Gas etc |
2. tx.swap β Execute Swap
One-shot Swap execution (QuoteβBuildβSignβSubmit single call).
| Field | Description |
|---|---|
| Tool Name | tx.swap |
| Parameters | Same as tx.quote + account_id |
| Return | Transaction result |
3. tx.swap_detail β Query Swap Status
(Other MCP tool specifications...)
Sub-module Routing
Route to specific implementation based on mode detection result and user intent:
| Routing Condition | Target | Description |
|---|---|---|
| OpenAPI environment + related intent | references/openapi.md | Complete OpenAPI call specification |
| MCP environment + trading intent | Current SKILL.md main process | MCP tool calls and three-step confirmation process |
Operation Process
Process A: Smart Mode Selection
First session detection (if needed)
β
Environment detection:
1. Check ~/.gate-dex-openapi/config.json
2. Check gate-wallet MCP Server
β
Select calling mode based on detection result:
β OpenAPI mode: references/openapi.md
β MCP mode: Current main process
Process B: MCP Swap Execution (Main Process)
Authentication check β Balance verification β Trading pair confirmation
β tx.quote β Quote display β Signature authorization confirmation
β tx.swap β tx.swap_detail
Cross-Skill Collaboration
| Caller | Scenario | Tool Used |
|---|---|---|
gate-dex-wallet |
User views balance then wants to exchange tokens | MCP mode call |
gate-dex-market |
User views market then wants to buy certain token | MCP mode call |
Supported Chains
| Chain ID | Network Name | MCP Support | OpenAPI Support |
|---|---|---|---|
eth / 1 |
Ethereum | β | β |
bsc / 56 |
BNB Smart Chain | β | β |
polygon / 137 |
Polygon | β | β |
arbitrum / 42161 |
Arbitrum One | β | β |
optimism / 10 |
Optimism | β | β |
avax / 43114 |
Avalanche | β | β |
base / 8453 |
Base | β | β |
sol / 501 |
Solana | β | β |
Security Rules
- Mode selection transparency: Clearly inform users of current calling mode and reason
- Authentication isolation: MCP mode uses
mcp_token, OpenAPI mode uses AK/SK - Three-step confirmation gating: MCP mode includes trading pair confirmation β quote display β signature authorization confirmation
- Balance verification: Mandatory check asset sufficiency before trading
- Risk alerts: Mandatory warning when price difference > 5%, high slippage MEV risk alerts