trade

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Trade / Swap Tokens

代币交易/兑换

Use this skill to exchange one token for another. It uses the Fibrous Finance aggregator to find the best route.
使用此技能可以将一种代币兑换为另一种代币。它借助Fibrous Finance聚合器寻找最优交易路径。

Hard Rules (CRITICAL)

硬性规则(至关重要)

  1. Pre-Flight Check: Before ANY trade, you MUST run:
    • npx fibx status
    • npx fibx balance
      (ensure you have the source token)
  2. Chain Specification:
    • If the user mentions a specific chain (e.g., "on Monad", "for my Citrea wallet"), you MUST include the
      --chain <name>
      parameter.
    • If the user DOES NOT mention a chain, you MUST either:
      • Explicitly state the default: "I will perform this trade on Base. Is that correct?"
      • OR ask for clarification: "Which chain would you like to trade on? Base, Citrea, HyperEVM, or Monad?"
  3. Slippage Safety: The default slippage is 0.5%. If you need to change this (e.g., for volatile tokens), you MUST ask the user for confirmation first.
  4. Approval Limits: The CLI defaults to "Exact Approval" (approves only the amount to be swapped).
    • Do NOT use
      --approve-max
      unless the user explicitly requests "infinite approval" or "max approval".
  5. Simulation & Verification: The CLI performs a route check before swapping. If this fails, do not proceed. After swapping, verify the transaction with the
    tx-status
    skill.
  1. 交易前检查:在进行任何交易之前,你必须运行以下命令:
    • npx fibx status
    • npx fibx balance
      (确保你拥有足够的源代币)
  2. 链指定规则
    • 如果用户提到特定链(例如“在Monad上”、“为我的Citrea钱包”),你必须添加
      --chain <name>
      参数。
    • 如果用户提及链,你必须
      • 明确告知默认链:“我将在Base链上执行此交易。是否确认?”
      • 或者询问用户确认:“你希望在哪个链上进行交易?Base、Citrea、HyperEVM还是Monad?”
  3. 滑点安全设置:默认滑点为0.5%。如果需要修改(例如针对高波动代币),你必须先征得用户确认。
  4. 授权限额规则:CLI默认采用“精确授权”(仅授权本次兑换所需的代币数量)。
    • 除非用户明确要求“无限授权”或“最大授权”,否则禁止使用
      --approve-max
      参数。
  5. 模拟与验证:CLI会在兑换前进行路径检查。如果检查失败,请勿继续交易。兑换完成后,使用
    tx-status
    技能验证交易状态。

Usage

使用方法

bash
npx fibx trade <amount> <from_token> <to_token> [options]
bash
npx fibx trade <amount> <from_token> <to_token> [options]

Arguments

参数说明

ArgumentDescription
amount
Amount to swap (e.g.,
1.5
,
100
).
from_token
Source token symbol (
ETH
,
USDC
) or address.
to_token
Destination token symbol (
WETH
,
DAI
) or address.
参数描述
amount
兑换数量(例如
1.5
100
)。
from_token
源代币符号(
ETH
USDC
)或地址。
to_token
目标代币符号(
WETH
DAI
)或地址。

Options

可选参数

OptionDescription
--chain <network>
Network:
base
,
citrea
,
hyperevm
,
monad
. Default:
base
.
--slippage <n>
Slippage tolerance in percentage (e.g.,
1.0
). Default
0.5
.
--approve-max
Force infinite approval. Use with caution.
--json
Output result as JSON.
选项描述
--chain <network>
网络:
base
citrea
hyperevm
monad
。默认值:
base
--slippage <n>
滑点容忍度(百分比,例如
1.0
)。默认值为
0.5
--approve-max
强制开启无限授权。请谨慎使用。
--json
以JSON格式输出结果。

Examples

示例

Standard Swap (Base)

标准兑换(Base链)

User: "Swap 0.1 ETH for USDC"
Agent Actions:
  1. npx fibx status
  2. npx fibx balance
  3. npx fibx trade 0.1 ETH USDC
  4. npx fibx tx-status <hash>
用户: "兑换0.1 ETH为USDC"
Agent操作:
  1. npx fibx status
  2. npx fibx balance
  3. npx fibx trade 0.1 ETH USDC
  4. npx fibx tx-status <hash>

Swap with Custom Slippage

自定义滑点兑换

User: "Swap 1000 DEGEN to ETH with 2% slippage"
Agent Actions:
  1. Checks info.
  2. Agent: "Confirming: You want to swap 1000 DEGEN to ETH with 2% slippage. Is this correct?"
  3. User confirms.
  4. npx fibx trade 1000 DEGEN ETH --slippage 2
用户: "将1000 DEGEN兑换为ETH,滑点设置为2%"
Agent操作:
  1. 检查相关信息。
  2. Agent: "确认:你希望将1000 DEGEN兑换为ETH,滑点设置为2%。是否正确?"
  3. 用户确认。
  4. npx fibx trade 1000 DEGEN ETH --slippage 2

Swap on Monad

Monad链上兑换

User: "Buy USDC with 1 MON on Monad"
Agent Actions:
  1. npx fibx status --chain monad
  2. npx fibx trade 1 MON USDC --chain monad
用户: "在Monad链上用1 MON购买USDC"
Agent操作:
  1. npx fibx status --chain monad
  2. npx fibx trade 1 MON USDC --chain monad

Error Handling

错误处理

  • "No route found": The trade path might not exist or liquidity is too low.
  • "Insufficient balance": Check
    balance
    again.
  • "Slippage exceeded": The price moved unfavorably; suggest retrying with higher slippage (after user confirmation).
  • "No route found":交易路径不存在或流动性过低。
  • "Insufficient balance":再次运行
    balance
    命令检查余额。
  • "Slippage exceeded":价格出现不利波动;建议在征得用户确认后,提高滑点重试。