gate-dex-trade
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGate DEX Trade
Gate DEX 交易
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.
交易综合技能 — 支持MCP + OpenAPI双模式,智能路由选择最优交易方式
触发场景:当用户提及"swap"、"exchange"、"buy"、"sell"、"trade"、"quote"等相关操作时使用。
🎯 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 |
| 模式 | 连接方式 | 优势 | 使用场景 |
|---|---|---|---|
| 🔗 MCP模式 | gate-wallet MCP Server | 统一身份认证、钱包生态集成 | 完整交易流程、跨Skill协作 |
| ⚡ OpenAPI模式 | AK/SK直接调用 | 独立执行、完整生命周期管控 | 快速交易、全链路可控 |
📋 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 | |
| 2 | Exists | ⚡ OpenAPI | |
| 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
系统会根据以下优先级自动选择调用模式:
| 优先级 | 条件 | 选中模式 | 路由目标 |
|---|---|---|---|
| 1 | 明确提及"OpenAPI"、"AK/SK" | ⚡ OpenAPI | |
| 2 | 存在 | ⚡ OpenAPI | |
| 3 | 来自钱包Skill的跨Skill调用 | 🔗 MCP | 当前SKILL.md主流程 |
| 4 | 默认场景 | 🔗 MCP | 当前SKILL.md主流程 |
用户偏好:
- 追求完整生态集成 → MCP模式
- 追求独立快速执行 → OpenAPI模式
MCP Server Connection Detection
MCP Server连接检测
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) |
在会话中首次调用MCP工具前,执行一次连接探测以确认Gate Wallet MCP Server可用性,后续操作无需重复检测。
CallMcpTool(server="gate-wallet", toolName="chain.config", arguments={chain: "eth"})| 结果 | 处理方式 |
|---|---|
| 成功 | MCP Server可用,后续操作直接调用业务工具,无需再次探测 |
| 失败 | 根据错误类型展示配置指引(见下方错误处理) |
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 | | Display MCP Server configuration guidance |
| Remote service unreachable | | Prompt to check server status and network connection |
| Authentication failed | | Prompt to contact administrator for API Key |
如果后续操作中业务工具调用失败(返回连接错误、超时等),按照以下规则处理:
| 错误类型 | 关键词 | 处理方式 |
|---|---|---|
| MCP Server未配置 | | 展示MCP Server配置指引 |
| 远程服务不可达 | | 提示检查服务状态和网络连接 |
| 认证失败 | | 提示联系管理员获取API Key |
Authentication Description
认证说明
All operations in MCP mode require . Must confirm user is logged in before calling any tool.
mcp_token- If currently no → Guide to
mcp_tokento complete login then returngate-dex-wallet/references/auth - If expired (MCP Server returns token expired error) → First try
mcp_tokensilent refresh, guide re-login if failedauth.refresh_token
MCP模式下所有操作需要,调用任何工具前必须确认用户已登录。
mcp_token- 如果当前无→ 引导至
mcp_token完成登录后返回gate-dex-wallet/references/auth - 如果过期(MCP Server返回token过期错误) → 先尝试
mcp_token静默刷新,失败则引导重新登录auth.refresh_token
MCP Tool Call Specification (Main Process)
MCP工具调用规范(主流程)
1. tx.quote
— Get Swap Quote
tx.quote1. tx.quote
— 获取Swap报价
tx.quoteGet Swap quote from input token to output token.
| Field | Description |
|---|---|
| Tool Name | |
| Parameters | |
| Return | Quote details including exchange rate, slippage, routing path, estimated Gas etc |
获取输入代币到输出代币的Swap报价。
| 字段 | 描述 |
|---|---|
| 工具名 | |
| 参数 | |
| 返回值 | 包含汇率、滑点、路由路径、预估Gas等的报价详情 |
2. tx.swap
— Execute Swap
tx.swap2. tx.swap
— 执行Swap
tx.swapOne-shot Swap execution (Quote→Build→Sign→Submit single call).
| Field | Description |
|---|---|
| Tool Name | |
| Parameters | Same as |
| Return | Transaction result |
一站式Swap执行(报价→构建交易→签名→提交单次调用)。
| 字段 | 描述 |
|---|---|
| 工具名 | |
| 参数 | 与 |
| 返回值 | 交易结果 |
3. tx.swap_detail
— Query Swap Status
tx.swap_detail3. tx.swap_detail
— 查询Swap状态
tx.swap_detail(Other MCP tool specifications...)
(其他MCP工具规范...)
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 |
根据模式检测结果和用户意图路由到具体实现:
| 路由条件 | 目标 | 描述 |
|---|---|---|
| OpenAPI环境 + 相关交易意图 | references/openapi.md | 完整OpenAPI调用规范 |
| MCP环境 + 交易意图 | 当前SKILL.md主流程 | MCP工具调用和三步确认流程 |
Operation Process
操作流程
Process A: Smart Mode Selection
流程A:智能模式选择
text
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 processtext
首次会话检测(如需执行)
↓
环境检测:
1. 检查~/.gate-dex-openapi/config.json
2. 检查gate-wallet MCP Server
↓
根据检测结果选择调用模式:
→ OpenAPI模式: references/openapi.md
→ MCP模式: 当前主流程Process B: MCP Swap Execution (Main Process)
流程B:MCP Swap执行(主流程)
text
Authentication check → Balance verification → Trading pair confirmation
→ tx.quote → Quote display → Signature authorization confirmation
→ tx.swap → tx.swap_detailtext
认证检查 → 余额校验 → 交易对确认
→ tx.quote → 报价展示 → 签名授权确认
→ tx.swap → tx.swap_detailCross-Skill Collaboration
跨Skill协作
| Caller | Scenario | Tool Used |
|---|---|---|
| User views balance then wants to exchange tokens | MCP mode call |
| User views market then wants to buy certain token | MCP mode call |
| 调用方 | 场景 | 使用工具 |
|---|---|---|
| 用户查看余额后想要兑换代币 | MCP模式调用 |
| 用户查看行情后想要买入指定代币 | MCP模式调用 |
Supported Chains
支持的链
| Chain ID | Network Name | MCP Support | OpenAPI Support |
|---|---|---|---|
| Ethereum | ✅ | ✅ |
| BNB Smart Chain | ✅ | ✅ |
| Polygon | ✅ | ✅ |
| Arbitrum One | ✅ | ✅ |
| Optimism | ✅ | ✅ |
| Avalanche | ✅ | ✅ |
| Base | ✅ | ✅ |
| Solana | ✅ | ✅ |
| 链ID | 网络名称 | MCP支持 | OpenAPI支持 |
|---|---|---|---|
| Ethereum | ✅ | ✅ |
| BNB Smart Chain | ✅ | ✅ |
| Polygon | ✅ | ✅ |
| Arbitrum One | ✅ | ✅ |
| Optimism | ✅ | ✅ |
| Avalanche | ✅ | ✅ |
| Base | ✅ | ✅ |
| Solana | ✅ | ✅ |
Security Rules
安全规则
- Mode selection transparency: Clearly inform users of current calling mode and reason
- Authentication isolation: MCP mode uses , OpenAPI mode uses AK/SK
mcp_token - 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
- 模式选择透明:明确告知用户当前调用模式及选择原因
- 认证隔离:MCP模式使用,OpenAPI模式使用AK/SK
mcp_token - 三步确认风控:MCP模式包含交易对确认 → 报价展示 → 签名授权确认三个校验节点
- 余额校验:交易前强制检查资产充足性
- 风险预警:当价差>5%时强制预警,高滑点MEV风险预警