quote
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseKyberSwap Quote Skill
KyberSwap报价技能
Fetch swap quotes from the KyberSwap Aggregator. Given a token pair and amount, retrieve the best route and present a clear summary including expected output, exchange rate, and gas cost.
从KyberSwap Aggregator获取兑换报价。给定代币对和兑换数量,检索最优路径并给出清晰的摘要,包含预期输出、汇率和Gas成本。
Input Parsing
输入解析
The user will provide input like:
1 ETH to USDC on ethereum100 USDC to WBTC on arbitrum0.5 WBTC to DAI on polygon- (default chain: ethereum)
1000 USDT to ETH
Extract these fields:
- amount — the human-readable amount to swap
- tokenIn — the input token symbol
- tokenOut — the output token symbol
- chain — the chain slug (default: )
ethereum
用户会提供类似如下的输入:
1 ETH to USDC on ethereum100 USDC to WBTC on arbitrum0.5 WBTC to DAI on polygon- (默认链:ethereum)
1000 USDT to ETH
提取以下字段:
- amount — 用户输入的可读兑换数量
- tokenIn — 输入代币符号
- tokenOut — 输出代币符号
- chain — 链标识(默认:)
ethereum
Workflow
工作流
Step 1: Resolve Token Addresses
步骤1:解析代币地址
Read the token registry at .
${CLAUDE_PLUGIN_ROOT}/references/token-registry.mdLook up and for the specified chain. Match case-insensitively. Note the decimals for each token.
tokenIntokenOutAliases to handle:
- "ETH" on Ethereum/Arbitrum/Optimism/Base/Linea/Unichain → native token address
- "MATIC" or "POL" on Polygon → native token address
- "BNB" on BSC → native token address
- "AVAX" on Avalanche → native token address
- "MNT" on Mantle → native token address
- "S" on Sonic → native token address
- "BERA" on Berachain → native token address
- "RON" on Ronin → native token address
- "XTZ" on Etherlink → native token address
- "MON" on Monad → native token address
If a token is not found in the registry:
Use the fallback sequence described at the bottom of :
${CLAUDE_PLUGIN_ROOT}/references/token-registry.md- KyberSwap Token API (preferred) — search whitelisted tokens first: via WebFetch. Pick the result whose
https://token-api.kyberswap.com/api/v1/public/tokens?chainIds={chainId}&name={symbol}&isWhitelisted=truematches exactly with the highestsymbol. If no whitelisted match, retry withoutmarketCap(only trust verified or market-cap tokens). If still nothing, browseisWhitelisted(try up to 3 pages).page=1&pageSize=100 - CoinGecko API (secondary fallback) — search CoinGecko for verified contract addresses if the Token API doesn't have it.
- Ask user manually (final fallback) — if CoinGecko also fails, ask the user to provide the contract address. Never guess or fabricate addresses.
读取处的代币注册表。
${CLAUDE_PLUGIN_ROOT}/references/token-registry.md查询指定链下的和,不区分大小写匹配。记录每个代币的小数位数(decimals)。
tokenIntokenOut需要处理的别名:
- Ethereum/Arbitrum/Optimism/Base/Linea/Unichain上的"ETH" → 原生代币地址
- Polygon上的"MATIC"或"POL" → 原生代币地址
- BSC上的"BNB" → 原生代币地址
- Avalanche上的"AVAX" → 原生代币地址
- Mantle上的"MNT" → 原生代币地址
- Sonic上的"S" → 原生代币地址
- Berachain上的"BERA" → 原生代币地址
- Ronin上的"RON" → 原生代币地址
- Etherlink上的"XTZ" → 原生代币地址
- Monad上的"MON" → 原生代币地址
如果在注册表中找不到对应代币:
使用底部描述的降级查询流程:
${CLAUDE_PLUGIN_ROOT}/references/token-registry.md- KyberSwap代币API(优先)—— 首先搜索白名单代币:通过WebFetch调用。选择
https://token-api.kyberswap.com/api/v1/public/tokens?chainIds={chainId}&name={symbol}&isWhitelisted=true完全匹配且symbol最高的结果。如果没有白名单匹配结果,移除marketCap参数重试(仅信任已验证或高市值代币)。如果仍无结果,尝试isWhitelisted(最多尝试3页)。page=1&pageSize=100 - CoinGecko API(次选降级方案)—— 如果代币API没有对应结果,在CoinGecko搜索已验证的合约地址。
- 手动询问用户(最终降级方案)—— 如果CoinGecko也查询失败,请求用户提供合约地址。绝对不要猜测或编造地址。
Step 2: Check Token Safety
步骤2:检查代币安全性
For any token not in the built-in registry and not a native token, check the honeypot/FOT API. (Note: registry tokens are assumed safe, but a compromised proxy token could theoretically be updated. For high-value swaps involving proxy tokens, consider checking the safety API even for registry tokens.)
GET https://token-api.kyberswap.com/api/v1/public/tokens/honeypot-fot-info?chainId={chainId}&address={tokenAddress}Via WebFetch, check both and :
tokenIntokenOut- If — warn the user that this token is flagged as a honeypot (cannot be sold after buying). Display the warning prominently.
isHoneypot: true - If — warn the user that this token has a fee-on-transfer (tax:
isFOT: true). The actual received amount will be less than the quoted output. Display the adjusted estimate:{tax}%. Example: if the quote shows 100 USDC and tax is 5%, display "~95 USDC after tax".adjustedAmount = quotedAmount * (1 - tax/100)
对于任何不在内置注册表中且不是原生代币的代币,调用蜜罐/转账手续费(FOT)API。(注:注册表中的代币默认是安全的,但被入侵的代理代币理论上可能被篡改。对于涉及代理代币的高价值兑换,即使是注册表内的代币也建议调用安全API检查。)
GET https://token-api.kyberswap.com/api/v1/public/tokens/honeypot-fot-info?chainId={chainId}&address={tokenAddress}通过WebFetch同时检查和:
tokenIntokenOut- 如果—— 警告用户该代币被标记为蜜罐代币(买入后无法卖出),需显著展示该警告。
isHoneypot: true - 如果—— 警告用户该代币存在转账手续费(税率:
isFOT: true),实际到账金额会低于报价输出。展示调整后的预估金额:{tax}%。示例:如果报价显示可兑换100 USDC,税率为5%,则展示「税后约95 USDC」。adjustedAmount = quotedAmount * (1 - tax/100)
Step 3: Convert Amount to Wei
步骤3:将金额转换为Wei
amountInWei = amount * 10^(tokenIn decimals)The result must be a plain integer string with no decimals, no scientific notation, and no separators.
For wei conversion, use a deterministic method instead of relying on AI mental math:
bash
python3 -c "print(int(AMOUNT * 10**DECIMALS))"amountInWei = amount * 10^(tokenIn decimals)结果必须是纯整数字符串,不含小数、科学计数法和分隔符。
Wei转换请使用确定性方法,不要依赖AI心算:
bash
python3 -c "print(int(AMOUNT * 10**DECIMALS))"or
或
echo "AMOUNT * 10^DECIMALS" | bc
**Verify known reference values:** 1 ETH = 1000000000000000000 (18 decimals), 1 USDC = 1000000 (6 decimals)
Examples:
- 1 ETH (18 decimals) = `1000000000000000000`
- 100 USDC (6 decimals) = `100000000`
- 0.5 WBTC (8 decimals) = `50000000`echo "AMOUNT * 10^DECIMALS" | bc
**验证已知参考值:** 1 ETH = 1000000000000000000(18位小数),1 USDC = 1000000(6位小数)
示例:
- 1 ETH(18位小数)= `1000000000000000000`
- 100 USDC(6位小数)= `100000000`
- 0.5 WBTC(8位小数)= `50000000`Step 4: Call the Routes API (GET request)
步骤4:调用路径API(GET请求)
Read the API reference at for the full specification.
${CLAUDE_PLUGIN_ROOT}/references/api-reference.mdMake the request using WebFetch:
URL: https://aggregator-api.kyberswap.com/{chain}/api/v1/routes?tokenIn={tokenInAddress}&tokenOut={tokenOutAddress}&amountIn={amountInWei}&source=ai-agent-skills
Prompt: Return the full JSON response body读取处的API参考文档获取完整规范。
${CLAUDE_PLUGIN_ROOT}/references/api-reference.md使用WebFetch发起请求:
URL: https://aggregator-api.kyberswap.com/{chain}/api/v1/routes?tokenIn={tokenInAddress}&tokenOut={tokenOutAddress}&amountIn={amountInWei}&source=ai-agent-skills
Prompt: Return the full JSON response bodyStep 5: Handle Errors
步骤5:错误处理
Check the field in the JSON response and handle common errors inline:
code| Code | Message | Quick Fix |
|---|---|---|
| 4008 | Route not found | No liquidity for this pair/amount. Remove source filters ( |
| 4011 | Token not found | Verify the token address is correct for this chain. Use |
| 4000 | Bad request | Read the |
| 4010 / 40011 | No eligible pools / Filtered sources (observed behavior, not in public API docs) | Remove |
| 404 | Chain not found | Check chain slug spelling. Supported: |
| 4990 | Request canceled | Retry the request. Likely a timeout or network issue. |
| 500 | Internal server error | Verify all addresses are valid hex. Retry — may be transient. |
For any error code not listed above, or for deeper troubleshooting, refer to for the comprehensive error reference.
${CLAUDE_PLUGIN_ROOT}/skills/error-handling/SKILL.md检查JSON响应中的字段,就地处理常见错误:
code| 代码 | 消息 | 快速修复方案 |
|---|---|---|
| 4008 | 未找到路径 | 该代币对/兑换数量没有流动性。移除源筛选条件( |
| 4011 | 未找到代币 | 验证该链下的代币地址是否正确。原生代币请使用地址 |
| 4000 | 错误请求 | 查看响应中的 |
| 4010 / 40011 | 无符合条件的池 / 源被筛选(观测到的行为,未在公开API文档中列出) | 移除 |
| 404 | 未找到链 | 检查链标识拼写。支持的链包括: |
| 4990 | 请求被取消 | 重试请求,大概率是超时或网络问题。 |
| 500 | 内部服务错误 | 验证所有地址都是有效的十六进制字符串。重试——可能是临时故障。 |
对于未列出的错误代码,或需要深入排查的问题,请参考****获取完整的错误参考。
${CLAUDE_PLUGIN_ROOT}/skills/error-handling/SKILL.mdStep 5b: Dust Amount Warning
步骤5b:小额兑换警告
After getting a successful route, check the USD values from the response:
- If < $0.10 — warn the user: "This swap amount is extremely small (
amountInUsd$X). Gas fees ($Y) will far exceed the swap value. Consider using a larger amount." - If >
gasUsd— warn the user: "Gas cost (amountInUsd$Y) exceeds the swap value ($X). This trade is uneconomical."
Still show the quote, but include the warning prominently before the results table.
成功获取路径后,检查响应中的美元价值:
- 如果< 0.10美元 —— 警告用户:「该兑换金额极小(约$X),Gas费用(约$Y)会远高于兑换价值,建议使用更大的金额。」
amountInUsd - 如果>
gasUsd—— 警告用户:「Gas成本(约$Y)超过兑换价值(约$X),该交易不划算。」amountInUsd
仍然展示报价,但需要在结果表格前显著展示警告。
Step 6: Format the Output
步骤6:格式化输出
Present the results in this format:
undefined按照以下格式展示结果:
undefinedKyberSwap Quote
KyberSwap报价
{amount} {tokenIn} → {amountOut} {tokenOut} on {Chain}
| Detail | Value |
|---|---|
| Input | {amount} {tokenIn} (~${amountInUsd}) |
| Output | {amountOut} {tokenOut} (~${amountOutUsd}) |
| Rate | 1 {tokenIn} = {rate} {tokenOut} |
| Gas estimate | {gas} units (~${gasUsd}) |
| L1 fee (L2 only) | ~${l1FeeUsd} (omit this row on L1 chains or if |
| Router | |
{amount} {tokenIn} → {amountOut} {tokenOut} on {Chain}
| 详情 | 数值 |
|---|---|
| 输入 | {amount} {tokenIn} (~${amountInUsd}) |
| 输出 | {amountOut} {tokenOut} (~${amountOutUsd}) |
| 汇率 | 1 {tokenIn} = {rate} {tokenOut} |
| Gas预估 | {gas} units (~${gasUsd}) |
| L1手续费(仅L2链) | ~${l1FeeUsd} (L1链或 |
| 路由地址 | |
Route
兑换路径
{For each split in the route, show: tokenIn → tokenOut via [exchange name]}
**Calculating the output amount:**
Convert `amountOut` from wei back to human-readable using tokenOut's decimals:humanAmount = amountOut / 10^(tokenOut decimals)
**Calculating the rate:**rate = humanAmountOut / humanAmountIn
Display rates with appropriate precision (up to 6 significant digits).{路径中的每一笔拆分展示为:tokenIn → tokenOut via [交易所名称]}
**计算输出金额:**
使用tokenOut的小数位数将`amountOut`从Wei转换为可读格式:humanAmount = amountOut / 10^(tokenOut decimals)
**计算汇率:**rate = humanAmountOut / humanAmountIn
汇率展示时保留合适的精度(最多6位有效数字)。Structured JSON Output
结构化JSON输出
After the markdown table, always include a JSON code block so other plugins or agents can consume the result programmatically:
```json
{
"type": "kyberswap-quote",
"chain": "{chain}",
"tokenIn": {
"symbol": "{tokenIn}",
"address": "{tokenInAddress}",
"decimals": {tokenInDecimals},
"amount": "{amount}",
"amountWei": "{amountInWei}",
"amountUsd": "{amountInUsd}"
},
"tokenOut": {
"symbol": "{tokenOut}",
"address": "{tokenOutAddress}",
"decimals": {tokenOutDecimals},
"amount": "{amountOut}",
"amountWei": "{amountOutWei}",
"amountUsd": "{amountOutUsd}"
},
"rate": "{rate}",
"gas": "{gas}",
"gasUsd": "{gasUsd}",
"routerAddress": "{routerAddress}"
}
```This JSON block enables downstream agents or plugins to parse the quote result without scraping the markdown table.
在Markdown表格之后,始终包含一个JSON代码块,方便其他插件或Agent程序化消费结果:
```json
{
"type": "kyberswap-quote",
"chain": "{chain}",
"tokenIn": {
"symbol": "{tokenIn}",
"address": "{tokenInAddress}",
"decimals": {tokenInDecimals},
"amount": "{amount}",
"amountWei": "{amountInWei}",
"amountUsd": "{amountInUsd}"
},
"tokenOut": {
"symbol": "{tokenOut}",
"address": "{tokenOutAddress}",
"decimals": {tokenOutDecimals},
"amount": "{amountOut}",
"amountWei": "{amountOutWei}",
"amountUsd": "{amountOutUsd}"
},
"rate": "{rate}",
"gas": "{gas}",
"gasUsd": "{gasUsd}",
"routerAddress": "{routerAddress}"
}
```该JSON块让下游Agent或插件无需解析Markdown表格即可读取报价结果。
Important Notes
重要提示
- Always read both and
${CLAUDE_PLUGIN_ROOT}/references/token-registry.mdbefore making API calls.${CLAUDE_PLUGIN_ROOT}/references/api-reference.md - Never guess token addresses. Always verify from the registry or via the Token API / search.
- If the user doesn't specify a chain, default to .
ethereum - If the user specifies a chain not listed in , query
references/api-reference.mdvia WebFetch to check if the chain is supported. Look for a matchinghttps://common-service.kyberswap.com/api/v1/aggregator/supported-chainswithchainNameorstate: "active". Use thestate: "new"value as the path slug.chainName - The quote is informational only — no transaction is built or submitted.
- 发起API调用前,请务必同时阅读和
${CLAUDE_PLUGIN_ROOT}/references/token-registry.md。${CLAUDE_PLUGIN_ROOT}/references/api-reference.md - 绝对不要猜测代币地址,始终通过注册表或代币API/搜索验证。
- 如果用户未指定链,默认使用。
ethereum - 如果用户指定的链不在的列表中,通过WebFetch查询
references/api-reference.md检查该链是否被支持。寻找https://common-service.kyberswap.com/api/v1/aggregator/supported-chains或state: "active"的匹配state: "new",使用chainName的值作为路径标识。chainName - 该报价仅作参考,不会构建或提交任何交易。
Additional Resources
额外资源
Reference Files
参考文件
- — Full API specification, error codes, rate limiting
${CLAUDE_PLUGIN_ROOT}/references/api-reference.md - — Token addresses and decimals by chain
${CLAUDE_PLUGIN_ROOT}/references/token-registry.md
- —— 完整API规范、错误码、速率限制
${CLAUDE_PLUGIN_ROOT}/references/api-reference.md - —— 按链分类的代币地址和小数位数
${CLAUDE_PLUGIN_ROOT}/references/token-registry.md
Example Files
示例文件
Working examples in :
${CLAUDE_PLUGIN_ROOT}/skills/quote/references/- — Simple ETH to USDC quote on Ethereum
basic-quote.md - — Quote on L2 chain with L1 fee
multi-chain-quote.md
${CLAUDE_PLUGIN_ROOT}/skills/quote/references/- —— Ethereum上ETH兑换USDC的基础报价
basic-quote.md - —— L2链上包含L1手续费的报价
multi-chain-quote.md
Troubleshooting
故障排查
For error codes not covered in Step 5, or for advanced debugging (PMM/RFQ errors, edge cases), refer to .
${CLAUDE_PLUGIN_ROOT}/skills/error-handling/SKILL.md对于步骤5未覆盖的错误代码,或需要高级调试的场景(PMM/RFQ错误、边缘情况),请参考****。
${CLAUDE_PLUGIN_ROOT}/skills/error-handling/SKILL.md