gate-dex-trade

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gate 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

🎯 双模式架构

ModeConnection MethodAdvantagesUse Cases
🔗 MCP Modegate-wallet MCP ServerUnified authentication, wallet ecosystem integrationComplete trading process, cross-Skill collaboration
OpenAPI ModeAK/SK direct callsIndependent execution, complete lifecycleFast 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:
PriorityConditionSelected ModeRouting Target
1Explicitly mentions "OpenAPI", "AK/SK"⚡ OpenAPI
references/openapi.md
2Exists
~/.gate-dex-openapi/config.json
⚡ OpenAPI
references/openapi.md
3From wallet Skills cross-Skill calls🔗 MCPCurrent SKILL.md main process
4Default scenario🔗 MCPCurrent SKILL.md main process
User Preferences:
  • Pursue complete ecosystem integration → MCP mode
  • Pursue independent fast execution → OpenAPI mode

系统会根据以下优先级自动选择调用模式:
优先级条件选中模式路由目标
1明确提及"OpenAPI"、"AK/SK"⚡ OpenAPI
references/openapi.md
2存在
~/.gate-dex-openapi/config.json
文件
⚡ OpenAPI
references/openapi.md
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"})
ResultHandling
SuccessMCP Server available, subsequent operations directly call business tools, no need to probe again
FailureDisplay 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 TypeKeywordsHandling
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

如果后续操作中业务工具调用失败(返回连接错误、超时等),按照以下规则处理:
错误类型关键词处理方式
MCP Server未配置
server not found
unknown server
展示MCP Server配置指引
远程服务不可达
connection refused
timeout
DNS error
提示检查服务状态和网络连接
认证失败
401
unauthorized
x-api-key
提示联系管理员获取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 to
    gate-dex-wallet/references/auth
    to complete login then return
  • If
    mcp_token
    expired (MCP Server returns token expired error) → First try
    auth.refresh_token
    silent refresh, guide re-login if failed

MCP模式下所有操作需要
mcp_token
,调用任何工具前必须确认用户已登录。
  • 如果当前无
    mcp_token
    → 引导至
    gate-dex-wallet/references/auth
    完成登录后返回
  • 如果
    mcp_token
    过期(MCP Server返回token过期错误) → 先尝试
    auth.refresh_token
    静默刷新,失败则引导重新登录

MCP Tool Call Specification (Main Process)

MCP工具调用规范(主流程)

1.
tx.quote
— Get Swap Quote

1.
tx.quote
— 获取Swap报价

Get Swap quote from input token to output token.
FieldDescription
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 }
ReturnQuote details including exchange rate, slippage, routing path, estimated Gas etc
获取输入代币到输出代币的Swap报价。
字段描述
工具名
tx.quote
参数
{ 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 }
返回值包含汇率、滑点、路由路径、预估Gas等的报价详情

2.
tx.swap
— Execute Swap

2.
tx.swap
— 执行Swap

One-shot Swap execution (Quote→Build→Sign→Submit single call).
FieldDescription
Tool Name
tx.swap
ParametersSame as
tx.quote
+
account_id
ReturnTransaction result
一站式Swap执行(报价→构建交易→签名→提交单次调用)。
字段描述
工具名
tx.swap
参数
tx.quote
参数一致,额外增加
account_id
返回值交易结果

3.
tx.swap_detail
— Query Swap Status

3.
tx.swap_detail
— 查询Swap状态

(Other MCP tool specifications...)

(其他MCP工具规范...)

Sub-module Routing

子模块路由

Route to specific implementation based on mode detection result and user intent:
Routing ConditionTargetDescription
OpenAPI environment + related intentreferences/openapi.mdComplete OpenAPI call specification
MCP environment + trading intentCurrent SKILL.md main processMCP 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 process
text
首次会话检测(如需执行)
环境检测:
  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_detail

text
认证检查 → 余额校验 → 交易对确认 
  → tx.quote → 报价展示 → 签名授权确认 
    → tx.swap → tx.swap_detail

Cross-Skill Collaboration

跨Skill协作

CallerScenarioTool Used
gate-dex-wallet
User views balance then wants to exchange tokensMCP mode call
gate-dex-market
User views market then wants to buy certain tokenMCP mode call

调用方场景使用工具
gate-dex-wallet
用户查看余额后想要兑换代币MCP模式调用
gate-dex-market
用户查看行情后想要买入指定代币MCP模式调用

Supported Chains

支持的链

Chain IDNetwork NameMCP SupportOpenAPI 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

链ID网络名称MCP支持OpenAPI支持
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

安全规则

  1. Mode selection transparency: Clearly inform users of current calling mode and reason
  2. Authentication isolation: MCP mode uses
    mcp_token
    , OpenAPI mode uses AK/SK
  3. Three-step confirmation gating: MCP mode includes trading pair confirmation → quote display → signature authorization confirmation
  4. Balance verification: Mandatory check asset sufficiency before trading
  5. Risk alerts: Mandatory warning when price difference > 5%, high slippage MEV risk alerts
  1. 模式选择透明:明确告知用户当前调用模式及选择原因
  2. 认证隔离:MCP模式使用
    mcp_token
    ,OpenAPI模式使用AK/SK
  3. 三步确认风控:MCP模式包含交易对确认 → 报价展示 → 签名授权确认三个校验节点
  4. 余额校验:交易前强制检查资产充足性
  5. 风险预警:当价差>5%时强制预警,高滑点MEV风险预警