quote

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

KyberSwap 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 ethereum
  • 100 USDC to WBTC on arbitrum
  • 0.5 WBTC to DAI on polygon
  • 1000 USDT to ETH
    (default chain: ethereum)
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 ethereum
  • 100 USDC to WBTC on arbitrum
  • 0.5 WBTC to DAI on polygon
  • 1000 USDT to ETH
    (默认链:ethereum)
提取以下字段:
  • amount — 用户输入的可读兑换数量
  • tokenIn — 输入代币符号
  • tokenOut — 输出代币符号
  • chain — 链标识(默认:
    ethereum

Workflow

工作流

Step 1: Resolve Token Addresses

步骤1:解析代币地址

Read the token registry at
${CLAUDE_PLUGIN_ROOT}/references/token-registry.md
.
Look up
tokenIn
and
tokenOut
for the specified chain. Match case-insensitively. Note the decimals for each token.
Aliases 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
:
  1. KyberSwap Token API (preferred) — search whitelisted tokens first:
    https://token-api.kyberswap.com/api/v1/public/tokens?chainIds={chainId}&name={symbol}&isWhitelisted=true
    via WebFetch. Pick the result whose
    symbol
    matches exactly with the highest
    marketCap
    . If no whitelisted match, retry without
    isWhitelisted
    (only trust verified or market-cap tokens). If still nothing, browse
    page=1&pageSize=100
    (try up to 3 pages).
  2. CoinGecko API (secondary fallback) — search CoinGecko for verified contract addresses if the Token API doesn't have it.
  3. 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
处的代币注册表。
查询指定链下的
tokenIn
tokenOut
,不区分大小写匹配。记录每个代币的小数位数(decimals)
需要处理的别名:
  • 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
底部描述的降级查询流程:
  1. KyberSwap代币API(优先)—— 首先搜索白名单代币:通过WebFetch调用
    https://token-api.kyberswap.com/api/v1/public/tokens?chainIds={chainId}&name={symbol}&isWhitelisted=true
    。选择
    symbol
    完全匹配且
    marketCap
    最高的结果。如果没有白名单匹配结果,移除
    isWhitelisted
    参数重试(仅信任已验证或高市值代币)。如果仍无结果,尝试
    page=1&pageSize=100
    (最多尝试3页)。
  2. CoinGecko API(次选降级方案)—— 如果代币API没有对应结果,在CoinGecko搜索已验证的合约地址。
  3. 手动询问用户(最终降级方案)—— 如果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
tokenIn
and
tokenOut
:
  • If
    isHoneypot: true
    warn the user that this token is flagged as a honeypot (cannot be sold after buying). Display the warning prominently.
  • If
    isFOT: true
    — warn the user that this token has a fee-on-transfer (tax:
    {tax}%
    ). The actual received amount will be less than the quoted output. Display the adjusted estimate:
    adjustedAmount = quotedAmount * (1 - tax/100)
    . Example: if the quote shows 100 USDC and tax is 5%, display "~95 USDC after tax".
对于任何不在内置注册表中不是原生代币的代币,调用蜜罐/转账手续费(FOT)API。(注:注册表中的代币默认是安全的,但被入侵的代理代币理论上可能被篡改。对于涉及代理代币的高价值兑换,即使是注册表内的代币也建议调用安全API检查。)
GET https://token-api.kyberswap.com/api/v1/public/tokens/honeypot-fot-info?chainId={chainId}&address={tokenAddress}
通过WebFetch同时检查
tokenIn
tokenOut
  • 如果
    isHoneypot: true
    —— 警告用户该代币被标记为蜜罐代币(买入后无法卖出),需显著展示该警告。
  • 如果
    isFOT: true
    —— 警告用户该代币存在转账手续费(税率:
    {tax}%
    ),实际到账金额会低于报价输出。展示调整后的预估金额:
    adjustedAmount = quotedAmount * (1 - tax/100)
    。示例:如果报价显示可兑换100 USDC,税率为5%,则展示「税后约95 USDC」。

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
${CLAUDE_PLUGIN_ROOT}/references/api-reference.md
for the full specification.
Make 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
读取
${CLAUDE_PLUGIN_ROOT}/references/api-reference.md
处的API参考文档获取完整规范。
使用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

Step 5: Handle Errors

步骤5:错误处理

Check the
code
field in the JSON response and handle common errors inline:
CodeMessageQuick Fix
4008Route not foundNo liquidity for this pair/amount. Remove source filters (
includedSources
/
excludedSources
), try a smaller amount, or retry after a few seconds.
4011Token not foundVerify the token address is correct for this chain. Use
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
for native tokens. Check spelling and
0x
prefix.
4000Bad requestRead the
fieldViolations
array in the response. Common issues:
amountIn
must be a plain integer string in wei (no decimals, no scientific notation), addresses must be 42-char hex with lowercase
0x
.
4010 / 40011No eligible pools / Filtered sources (observed behavior, not in public API docs)Remove
includedSources
/
excludedSources
filters. The pair may have liquidity only on specific DEXs.
404Chain not foundCheck chain slug spelling. Supported:
ethereum
,
bsc
,
polygon
,
arbitrum
,
optimism
,
avalanche
,
base
,
linea
,
mantle
,
sonic
,
berachain
,
ronin
,
unichain
,
hyperevm
,
plasma
,
etherlink
,
monad
,
megaeth
.
4990Request canceledRetry the request. Likely a timeout or network issue.
500Internal server errorVerify all addresses are valid hex. Retry — may be transient.
For any error code not listed above, or for deeper troubleshooting, refer to
${CLAUDE_PLUGIN_ROOT}/skills/error-handling/SKILL.md
for the comprehensive error reference.
检查JSON响应中的
code
字段,就地处理常见错误:
代码消息快速修复方案
4008未找到路径该代币对/兑换数量没有流动性。移除源筛选条件(
includedSources
/
excludedSources
),尝试更小的兑换金额,或等待几秒后重试。
4011未找到代币验证该链下的代币地址是否正确。原生代币请使用地址
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
。检查拼写和
0x
前缀。
4000错误请求查看响应中的
fieldViolations
数组。常见问题:
amountIn
必须是Wei格式的纯整数字符串(无小数、无科学计数法),地址必须是带小写
0x
前缀的42位十六进制字符串。
4010 / 40011无符合条件的池 / 源被筛选(观测到的行为,未在公开API文档中列出)移除
includedSources
/
excludedSources
筛选条件。该代币对可能仅在特定DEX上有流动性。
404未找到链检查链标识拼写。支持的链包括:
ethereum
,
bsc
,
polygon
,
arbitrum
,
optimism
,
avalanche
,
base
,
linea
,
mantle
,
sonic
,
berachain
,
ronin
,
unichain
,
hyperevm
,
plasma
,
etherlink
,
monad
,
megaeth
4990请求被取消重试请求,大概率是超时或网络问题。
500内部服务错误验证所有地址都是有效的十六进制字符串。重试——可能是临时故障。
对于未列出的错误代码,或需要深入排查的问题,请参考**
${CLAUDE_PLUGIN_ROOT}/skills/error-handling/SKILL.md
**获取完整的错误参考。

Step 5b: Dust Amount Warning

步骤5b:小额兑换警告

After getting a successful route, check the USD values from the response:
  • If
    amountInUsd
    < $0.10 — warn the user: "This swap amount is extremely small ($X). Gas fees ($Y) will far exceed the swap value. Consider using a larger amount."
  • If
    gasUsd
    >
    amountInUsd
    — warn the user: "Gas cost ($Y) exceeds the swap value ($X). This trade is uneconomical."
Still show the quote, but include the warning prominently before the results table.
成功获取路径后,检查响应中的美元价值:
  • 如果
    amountInUsd
    < 0.10美元 —— 警告用户:「该兑换金额极小(约$X),Gas费用(约$Y)会远高于兑换价值,建议使用更大的金额。」
  • 如果
    gasUsd
    >
    amountInUsd
    —— 警告用户:「Gas成本(约$Y)超过兑换价值(约$X),该交易不划算。」
仍然展示报价,但需要在结果表格前显著展示警告。

Step 6: Format the Output

步骤6:格式化输出

Present the results in this format:
undefined
按照以下格式展示结果:
undefined

KyberSwap Quote

KyberSwap报价

{amount} {tokenIn} → {amountOut} {tokenOut} on {Chain}
DetailValue
Input{amount} {tokenIn} (~${amountInUsd})
Output{amountOut} {tokenOut} (~${amountOutUsd})
Rate1 {tokenIn} = {rate} {tokenOut}
Gas estimate{gas} units (~${gasUsd})
L1 fee (L2 only)~${l1FeeUsd} (omit this row on L1 chains or if
l1FeeUsd
is
"0"
)
Router
{routerAddress}
{amount} {tokenIn} → {amountOut} {tokenOut} on {Chain}
详情数值
输入{amount} {tokenIn} (~${amountInUsd})
输出{amountOut} {tokenOut} (~${amountOutUsd})
汇率1 {tokenIn} = {rate} {tokenOut}
Gas预估{gas} units (~${gasUsd})
L1手续费(仅L2链)~${l1FeeUsd} (L1链或
l1FeeUsd
"0"
时省略该行)
路由地址
{routerAddress}

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
    ${CLAUDE_PLUGIN_ROOT}/references/token-registry.md
    and
    ${CLAUDE_PLUGIN_ROOT}/references/api-reference.md
    before making API calls.
  • 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
    references/api-reference.md
    , query
    https://common-service.kyberswap.com/api/v1/aggregator/supported-chains
    via WebFetch to check if the chain is supported. Look for a matching
    chainName
    with
    state: "active"
    or
    state: "new"
    . Use the
    chainName
    value as the path slug.
  • 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
  • 如果用户指定的链不在
    references/api-reference.md
    的列表中,通过WebFetch查询
    https://common-service.kyberswap.com/api/v1/aggregator/supported-chains
    检查该链是否被支持。寻找
    state: "active"
    state: "new"
    的匹配
    chainName
    ,使用
    chainName
    的值作为路径标识。
  • 该报价仅作参考,不会构建或提交任何交易。

Additional Resources

额外资源

Reference Files

参考文件

  • ${CLAUDE_PLUGIN_ROOT}/references/api-reference.md
    — Full API specification, error codes, rate limiting
  • ${CLAUDE_PLUGIN_ROOT}/references/token-registry.md
    — Token addresses and decimals by chain
  • ${CLAUDE_PLUGIN_ROOT}/references/api-reference.md
    —— 完整API规范、错误码、速率限制
  • ${CLAUDE_PLUGIN_ROOT}/references/token-registry.md
    —— 按链分类的代币地址和小数位数

Example Files

示例文件

Working examples in
${CLAUDE_PLUGIN_ROOT}/skills/quote/references/
:
  • basic-quote.md
    — Simple ETH to USDC quote on Ethereum
  • multi-chain-quote.md
    — Quote on L2 chain with L1 fee
${CLAUDE_PLUGIN_ROOT}/skills/quote/references/
下的可用示例:
  • basic-quote.md
    —— Ethereum上ETH兑换USDC的基础报价
  • multi-chain-quote.md
    —— L2链上包含L1手续费的报价

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
**。