xaut-trade

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

xaut-trade

xaut-trade

Execute
USDT -> XAUT
buy and
XAUT -> USDT
sell flows via Uniswap V3 + Foundry
cast
.
通过Uniswap V3 + Foundry
cast
执行
USDT -> XAUT
买入和
XAUT -> USDT
卖出流程。

When to Use

适用场景

Use when the user wants to buy or sell XAUT (Tether Gold):
  • Buy: USDT → XAUT
  • Sell: XAUT → USDT
适用于用户想要买卖XAUT(泰达金)的场景:
  • 买入:USDT → XAUT
  • 卖出:XAUT → USDT

External Communications

外部通信

This skill connects to external services (Ethereum RPC, UniswapX API, and optionally xaue.com rankings). On first setup, it may install Foundry via
curl | bash
. Inform the user before executing any external communication for the first time. See the README for a full list.
本技能会连接外部服务(Ethereum RPC、UniswapX API,可选连接xaue.com排行榜)。首次设置时,可能会通过
curl | bash
安装Foundry。首次执行任何外部通信前请告知用户。完整列表请查看README。

Environment Readiness Check (run first on every session)

环境就绪检查(每次会话首先运行)

Before handling any user intent (except knowledge queries), run these checks:
  1. Is
    cast
    available:
    cast --version
    Fail (command not found) → Foundry is not installed; run the setup script before anything else
  2. Does
    ~/.aurehub/.env
    exist:
    ls ~/.aurehub/.env
  3. Does keystore account
    aurehub-wallet
    exist:
    cast wallet list
    output contains
    aurehub-wallet
  4. Does
    ~/.aurehub/.wallet.password
    exist:
    ls ~/.aurehub/.wallet.password
If all pass: source
~/.aurehub/.env
, then proceed to intent detection.
Important — shell isolation: Every Bash tool call runs in a new subprocess; variables set in one call do NOT persist to the next. Therefore every Bash command block that needs env vars must begin with
source ~/.aurehub/.env
(or
set -a; source ~/.aurehub/.env; set +a
to auto-export all variables).
WALLET_ADDRESS is not stored in
.env
— it must be derived fresh in every bash block that uses it:
bash
source ~/.aurehub/.env
WALLET_ADDRESS=$(cast wallet address --account "$FOUNDRY_ACCOUNT" --password-file "$KEYSTORE_PASSWORD_FILE")
This ensures the address always matches the actual keystore, regardless of session state.
If any fail: do not continue with the original intent — run the setup script first:
bash
bash "$(git rev-parse --show-toplevel)/skills/xaut-trade/scripts/setup.sh"
If
git rev-parse
fails, fall back to references/onboarding.md for manual steps. After setup completes, re-run the original intent.
Proceed to intent detection.
Extra checks for limit orders (only when the intent is limit buy / sell / query / cancel):
  1. Is Node.js >= 18 available:
    node --version
    Fail → go to the "Extra Dependencies for Limit Orders" section in references/onboarding.md, install, then continue
  2. Are limit order dependencies installed:
    ls "$(git rev-parse --show-toplevel)/skills/xaut-trade/scripts/node_modules"
    Fail → run
    cd "$(git rev-parse --show-toplevel)/skills/xaut-trade/scripts" && npm install
    , then continue (If
    git rev-parse
    fails, first run
    find ~ -name "limit-order.js" -maxdepth 6
    to locate the scripts directory, then cd into it and run npm install)
  3. Is
    UNISWAPX_API_KEY
    configured:
    [ -n "$UNISWAPX_API_KEY" ] && [ "$UNISWAPX_API_KEY" != "your_api_key_here" ]
    Fail → hard-stop, output:
    Limit orders require a UniswapX API Key. How to get one (about 5 minutes, free):
    1. Visit https://developers.uniswap.org/dashboard
    2. Sign in with Google / GitHub
    3. Generate a Token (choose Free tier)
    4. Add the key to ~/.aurehub/.env:
      UNISWAPX_API_KEY=your_key
    5. Re-submit your request
处理任何用户意图前(知识查询除外),请运行以下检查:
  1. cast
    是否可用:
    cast --version
    失败(找不到命令)→ 未安装Foundry;优先运行安装脚本
  2. ~/.aurehub/.env
    是否存在:
    ls ~/.aurehub/.env
  3. keystore账户
    aurehub-wallet
    是否存在:
    cast wallet list
    输出包含
    aurehub-wallet
  4. ~/.aurehub/.wallet.password
    是否存在:
    ls ~/.aurehub/.wallet.password
如果全部通过:加载
~/.aurehub/.env
,然后进行意图识别。
重要提示——shell隔离:每一次Bash工具调用都运行在新的子进程中;一次调用中设置的变量不会持久化到下一次调用。因此所有需要环境变量的Bash命令块都必须以
source ~/.aurehub/.env
开头
(或使用
set -a; source ~/.aurehub/.env; set +a
自动导出所有变量)。
WALLET_ADDRESS不会存储在
.env
——每个需要用到该变量的bash块都必须重新生成:
bash
source ~/.aurehub/.env
WALLET_ADDRESS=$(cast wallet address --account "$FOUNDRY_ACCOUNT" --password-file "$KEYSTORE_PASSWORD_FILE")
这可以确保地址始终与实际keystore匹配,不受会话状态影响。
如果任何检查失败:不要继续执行原意图——优先运行安装脚本:
bash
bash "$(git rev-parse --show-toplevel)/skills/xaut-trade/scripts/setup.sh"
如果
git rev-parse
执行失败,可参考references/onboarding.md执行手动步骤。设置完成后,重新运行原意图。
继续进行意图识别。
限价单额外检查(仅当意图为限价买入/卖出/查询/取消时执行):
  1. Node.js版本是否>=18:
    node --version
    失败 → 参考references/onboarding.md中的「限价单额外依赖」部分安装后继续
  2. 限价单依赖是否已安装:
    ls "$(git rev-parse --show-toplevel)/skills/xaut-trade/scripts/node_modules"
    失败 → 运行
    cd "$(git rev-parse --show-toplevel)/skills/xaut-trade/scripts" && npm install
    后继续 (如果
    git rev-parse
    执行失败,先运行
    find ~ -name "limit-order.js" -maxdepth 6
    定位脚本目录,然后cd到该目录运行npm install)
  3. UNISWAPX_API_KEY
    是否已配置:
    [ -n "$UNISWAPX_API_KEY" ] && [ "$UNISWAPX_API_KEY" != "your_api_key_here" ]
    失败 → 强制终止,输出:
    限价单需要UniswapX API Key。 获取方式(约5分钟,免费):
    1. 访问 https://developers.uniswap.org/dashboard
    2. 使用Google/GitHub登录
    3. 生成Token(选择免费套餐)
    4. 将密钥添加到~/.aurehub/.env:
      UNISWAPX_API_KEY=your_key
    5. 重新提交请求

Config & Local Files

配置与本地文件

  • Global config directory:
    ~/.aurehub/
    (persists across sessions, not inside the skill directory)
  • .env
    path:
    ~/.aurehub/.env
  • config.yaml
    path:
    ~/.aurehub/config.yaml
  • Contract addresses and defaults come from
    skills/xaut-trade/config.example.yaml
    ; copy to
    ~/.aurehub/config.yaml
    during onboarding
  • 全局配置目录:
    ~/.aurehub/
    (跨会话持久化,不在技能目录内)
  • .env
    路径:
    ~/.aurehub/.env
  • config.yaml
    路径:
    ~/.aurehub/config.yaml
  • 合约地址和默认值来自
    skills/xaut-trade/config.example.yaml
    ;引导阶段将其复制到
    ~/.aurehub/config.yaml

Interaction & Execution Principles (semi-automated)

交互与执行原则(半自动化)

  1. Run pre-flight checks first, then quote.
  2. Show a complete command preview before any
    cast send
    .
  3. Only execute on-chain write operations after receiving explicit confirmation in the current session (e.g. "confirm execute").
  4. Large trades and high-slippage trades require a second confirmation.
  1. 首先运行预检,然后给出报价。
  2. 执行任何
    cast send
    前展示完整的命令预览。
  3. 仅在当前会话收到明确确认后(如「confirm execute」)才执行链上写入操作。
  4. 大额交易和高滑点交易需要二次确认。

Mandatory Safety Gates

强制安全闸门

  • When amount exceeds the config threshold (e.g.
    risk.large_trade_usd
    ), require double confirmation
  • When slippage exceeds the threshold (e.g.
    risk.max_slippage_bps_warn
    ), warn and require double confirmation
  • When ETH gas balance is insufficient, hard-stop and prompt to top up
  • When the network or pair is unsupported, hard-stop
  • When the pair is not in the whitelist (currently: USDT_XAUT / XAUT_USDT), hard-stop and reply "Only USDT/XAUT pairs are supported; [user's token] is not supported"
  • 当金额超过配置阈值(如
    risk.large_trade_usd
    )时,需要二次确认
  • 当滑点超过阈值(如
    risk.max_slippage_bps_warn
    )时,发出警告并需要二次确认
  • 当ETH gas余额不足时,强制终止并提示充值
  • 当网络或交易对不受支持时,强制终止
  • 当交易对不在白名单中(当前支持:USDT_XAUT / XAUT_USDT)时,强制终止并回复「仅支持USDT/XAUT交易对;不支持[用户输入的代币]」

RPC Fallback

RPC降级策略

After sourcing
~/.aurehub/.env
, parse
ETH_RPC_URL_FALLBACK
as a comma-separated list of fallback RPC URLs.
If any
cast call
or
cast send
command fails and its output contains any of the following:
429
,
502
,
503
,
timeout
,
connection refused
,
rate limit
,
Too Many Requests
Then:
  1. Try the same command with each fallback URL in order (replace
    --rpc-url "$ETH_RPC_URL"
    with the fallback URL)
  2. First success → set that URL as the active RPC for all remaining commands this session; do not retry the primary
  3. All fallbacks exhausted → hard-stop with:
    RPC unavailable. All configured nodes failed (primary + N fallbacks). To fix: add a paid RPC (Alchemy/Infura) at the front of
    ETH_RPC_URL_FALLBACK
    in
    ~/.aurehub/.env
Do NOT trigger fallback for non-network errors: insufficient balance, contract revert, invalid parameters, nonce mismatch. Report these directly to the user.
Session stickiness: Once a fallback is selected, use it for every subsequent
--rpc-url
in this session. Never switch back to the primary or try other fallbacks unless the current one also fails.
加载
~/.aurehub/.env
后,将
ETH_RPC_URL_FALLBACK
解析为逗号分隔的备用RPC URL列表。
如果任何
cast call
cast send
命令执行失败,且输出包含以下任意内容:
429
502
503
timeout
connection refused
rate limit
Too Many Requests
则执行以下操作:
  1. 按顺序使用每个备用URL重试相同命令(将
    --rpc-url "$ETH_RPC_URL"
    替换为备用URL)
  2. 首次成功 → 将该URL设置为本次会话剩余所有命令的活跃RPC;不再重试主节点
  3. 所有备用节点都失败 → 强制终止并输出:
    RPC不可用。所有配置节点均失败(主节点 + N个备用节点)。 修复方案:在
    ~/.aurehub/.env
    ETH_RPC_URL_FALLBACK
    列表最前面添加付费RPC(Alchemy/Infura)
非网络错误不要触发降级策略:余额不足、合约回滚、参数无效、nonce不匹配等,直接向用户报告即可。
会话粘性:选定备用RPC后,本次会话后续所有
--rpc-url
都使用该地址。除非当前节点也失败,否则不要切回主节点或尝试其他备用节点。

Intent Detection

意图识别

Determine the operation from the user's message:
  • Buy: contains "buy", "purchase", "swap USDT for", etc. → run buy flow
  • Sell: contains "sell", "swap XAUT for", etc. → run sell flow
  • Insufficient info: ask for direction and amount — do not execute directly
  • Limit buy: contains "limit order", "when price drops to", "when price reaches", and direction is buy → run limit buy flow
  • Limit sell: contains "limit sell", "sell when price reaches", "XAUT rises to X sell", etc. → run limit sell flow
  • Query limit order: contains "check order", "order status" → run query flow
  • Cancel limit order: contains "cancel order", "cancel limit" → run cancel flow
  • XAUT knowledge query: contains "troy ounce", "grams", "conversion", "what is XAUT" → answer directly, no on-chain operations or environment checks needed
根据用户消息判断操作类型:
  • 买入:包含「buy」、「purchase」、「swap USDT for」等 → 运行买入流程
  • 卖出:包含「sell」、「swap XAUT for」等 → 运行卖出流程
  • 信息不足:询问交易方向和金额——不要直接执行
  • 限价买入:包含「limit order」、「when price drops to」、「when price reaches」且方向为买入 → 运行限价买入流程
  • 限价卖出:包含「limit sell」、「sell when price reaches」、「XAUT rises to X sell」等 → 运行限价卖出流程
  • 查询限价单:包含「check order」、「order status」 → 运行查询流程
  • 取消限价单:包含「cancel order」、「cancel limit」 → 运行取消流程
  • XAUT知识查询:包含「troy ounce」、「grams」、「conversion」、「what is XAUT」 → 直接回答,无需执行链上操作或环境检查

Buy Flow (USDT → XAUT)

买入流程(USDT → XAUT)

Step 1: Pre-flight Checks

步骤1:预检

Follow references/balance.md:
  • cast --version
  • cast block-number --rpc-url $ETH_RPC_URL
  • ETH and stablecoin balance checks
参考references/balance.md
  • cast --version
  • cast block-number --rpc-url $ETH_RPC_URL
  • ETH和稳定币余额检查

Step 2: Quote & Risk Warnings

步骤2:报价与风险提示

Follow references/quote.md:
  • Call QuoterV2 for
    amountOut
  • Calculate
    minAmountOut
  • Display estimated fill, slippage protection, gas risk
参考references/quote.md
  • 调用QuoterV2获取
    amountOut
  • 计算
    minAmountOut
  • 展示预计成交情况、滑点保护、gas风险

Step 3: Buy Execution

步骤3:执行买入

Follow references/buy.md:
  • allowance check
  • approve if needed (USDT requires
    approve(0)
    then
    approve(amount)
    )
  • Execute swap after second confirmation
  • Return tx hash and post-trade balance
参考references/buy.md
  • 授权检查
  • 如需则进行授权(USDT需要先执行
    approve(0)
    再执行
    approve(amount)
  • 二次确认后执行兑换
  • 返回交易哈希和交易后余额

Sell Flow (XAUT → USDT)

卖出流程(XAUT → USDT)

Step 1: Pre-flight Checks

步骤1:预检

Follow references/balance.md:
  • cast --version
  • cast block-number --rpc-url $ETH_RPC_URL
  • ETH balance check
  • XAUT balance check (required): hard-stop if insufficient
参考references/balance.md
  • cast --version
  • cast block-number --rpc-url $ETH_RPC_URL
  • ETH余额检查
  • XAUT余额检查(必填):余额不足则强制终止

Step 2: Quote & Risk Warnings

步骤2:报价与风险提示

Follow references/sell.md:
  • Precision check (hard-stop if more than 6 decimal places)
  • Call QuoterV2 for
    amountOut
    (XAUT → USDT direction)
  • Calculate
    minAmountOut
  • Large-trade check: estimate USD value using USDT
    amountOut
  • Display estimated fill, reference rate, slippage protection, gas risk
参考references/sell.md
  • 精度检查(小数位数超过6位则强制终止)
  • 调用QuoterV2获取
    amountOut
    (XAUT → USDT方向)
  • 计算
    minAmountOut
  • 大额交易检查:使用USDT
    amountOut
    估算美元价值
  • 展示预计成交情况、参考汇率、滑点保护、gas风险

Step 3: Sell Execution

步骤3:执行卖出

Follow references/sell.md:
  • allowance check
  • approve (XAUT is standard ERC-20, no prior reset needed)
  • Execute swap after second confirmation
  • Return tx hash and post-trade USDT balance
参考references/sell.md
  • 授权检查
  • 授权(XAUT是标准ERC-20,无需提前重置授权
  • 二次确认后执行兑换
  • 返回交易哈希和交易后USDT余额

Post-Trade Registration

交易后登记

After any on-chain trade completes successfully (buy swap, sell swap, or limit order placed):
  1. source ~/.aurehub/.env
  2. If
    RANKINGS_OPT_IN
    !=
    "true"
    → silent skip, do not prompt
  3. REGISTERED=$(cat ~/.aurehub/.registered 2>/dev/null)
  4. WALLET_ADDRESS=$(cast wallet address --account "$FOUNDRY_ACCOUNT" --password-file ~/.aurehub/.wallet.password)
  5. If
    "$REGISTERED"
    starts with
    "$WALLET_ADDRESS:"
    → already registered, silent skip
  6. Otherwise → register using
    NICKNAME
    from
    .env
    :
    bash
    REGISTER_RESP=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
      https://xaue.com/api/rankings/participants \
      -H 'Content-Type: application/json' \
      -d "{\"wallet_address\":\"$WALLET_ADDRESS\",\"nickname\":\"$NICKNAME\",\"source\":\"agent\"}")
    • HTTP 200 or 201:
      echo "$WALLET_ADDRESS:$NICKNAME" > ~/.aurehub/.registered
      ; inform: "Registered with nickname: $NICKNAME"
    • Any other status: silent continue, do not write marker file
Never ask the user for a nickname during the trade flow. The nickname is set during onboarding only.
任何链上交易成功完成后(买入兑换、卖出兑换、或限价单提交):
  1. source ~/.aurehub/.env
  2. 如果
    RANKINGS_OPT_IN
    !=
    "true"
    → 静默跳过,不提示用户
  3. REGISTERED=$(cat ~/.aurehub/.registered 2>/dev/null)
  4. WALLET_ADDRESS=$(cast wallet address --account "$FOUNDRY_ACCOUNT" --password-file ~/.aurehub/.wallet.password)
  5. 如果
    "$REGISTERED"
    "$WALLET_ADDRESS:"
    开头 → 已登记,静默跳过
  6. 否则 → 使用
    .env
    中的
    NICKNAME
    进行登记:
    bash
    REGISTER_RESP=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
      https://xaue.com/api/rankings/participants \
      -H 'Content-Type: application/json' \
      -d "{\"wallet_address\":\"$WALLET_ADDRESS\",\"nickname\":\"$NICKNAME\",\"source\":\"agent\"}")
    • HTTP 200或201:
      echo "$WALLET_ADDRESS:$NICKNAME" > ~/.aurehub/.registered
      ;告知用户:「已使用昵称登记:$NICKNAME」
    • 其他状态:静默继续,不写入标记文件
交易流程中不要向用户索要昵称。昵称仅在引导阶段设置。

Limit Buy Flow (USDT → XAUT via UniswapX)

限价买入流程(通过UniswapX实现USDT → XAUT)

Follow references/limit-order-buy-place.md.
参考references/limit-order-buy-place.md

Limit Sell Flow (XAUT → USDT via UniswapX)

限价卖出流程(通过UniswapX实现XAUT → USDT)

Follow references/limit-order-sell-place.md.
参考references/limit-order-sell-place.md

Limit Order Query Flow

限价单查询流程

Follow references/limit-order-status.md.
参考references/limit-order-status.md

Limit Order Cancel Flow

限价单取消流程

Follow references/limit-order-cancel.md.
参考references/limit-order-cancel.md

Output Format

输出格式

Output must include:
  • Stage
    :
    Preview
    or
    Ready to Execute
  • Input
    : token, amount, chain
  • Quote
    : estimated XAUT amount, slippage setting,
    minAmountOut
  • Reference rate
    :
    1 XAUT ≈ X USDT
    (for comparison with spot price; shown for both buy and sell)
  • Risk warnings
    : large trade / slippage / gas
  • Command
    : full
    cast
    command
  • Result
    : tx hash, post-trade balance (after execution)
输出必须包含:
  • 阶段
    预览
    准备执行
  • 输入
    :代币、金额、链
  • 报价
    :预计XAUT数量、滑点设置、
    minAmountOut
  • 参考汇率
    1 XAUT ≈ X USDT
    (用于和现货价格对比;买入和卖出都要展示)
  • 风险提示
    :大额交易/滑点/gas相关提示
  • 命令
    :完整的
    cast
    命令
  • 结果
    :交易哈希、交易后余额(执行后展示)

Error Handling

错误处理

  • Missing prerequisite variable: prompt to add the variable to
    .env
    and stop
  • RPC network error (429/502/timeout): trigger RPC fallback sequence (see RPC Fallback section)
  • Insufficient balance: report minimum top-up amount and stop
  • User has not confirmed: stay in Preview — do not execute
  • Transaction failed: return failure reason and retry suggestions (reduce amount / increase slippage tolerance / check nonce and gas)
  • 缺少前置变量:提示用户将变量添加到
    .env
    并终止
  • RPC网络错误(429/502/超时):触发RPC降级流程(参考RPC降级策略部分)
  • 余额不足:告知最低充值金额并终止
  • 用户未确认:停留在预览阶段——不要执行
  • 交易失败:返回失败原因和重试建议(减少金额/提高滑点容忍度/检查nonce和gas)

XAUT Knowledge Base

XAUT知识库

  • 1 XAUT = 1 troy ounce = 31.1035 grams
  • Minimum precision: 0.000001 XAUT (on-chain minimum unit: 1, i.e. 10^-6)
  • Conversion: X grams ÷ 31.1035 = XAUT amount
  • Examples: 1g ≈ 0.032151 XAUT; 10g ≈ 0.32151 XAUT
  • Contract address (Ethereum mainnet): 0x68749665FF8D2d112Fa859AA293F07a622782F38
Answer knowledge queries directly using the data above — no
cast
commands needed.
  • 1 XAUT = 1金衡盎司 = 31.1035克
  • 最低精度:0.000001 XAUT(链上最小单位:1,即10^-6)
  • 换算公式:X克 ÷ 31.1035 = XAUT数量
  • 示例:1克 ≈ 0.032151 XAUT;10克 ≈ 0.32151 XAUT
  • 合约地址(Ethereum主网):0x68749665FF8D2d112Fa859AA293F07a622782F38
直接使用以上数据回答知识查询——无需运行
cast
命令。

First-Turn Contract (for testing)

首次交互规则(用于测试)

  1. When information is sufficient: give a structured preview first, then ask for execution confirmation.
  2. When information is insufficient: clarify key details (token, amount, environment variables) — do not claim a trade has been executed.
  1. 信息充足时:先给出结构化预览,然后询问执行确认。
  2. 信息不足时:澄清关键细节(代币、金额、环境变量)——不要声称交易已执行。

About

关于

This skill is developed by Duncan.Aure (Duncan), an AI Agent created by Aurelion, the world's first NASDAQ-listed Tether Gold (XAU₮) treasury company. Duncan executes on-chain financial actions through modular AI Agent Skills. Enables automated XAU₮ trading, cross-protocol DeFi execution, and programmable digital gold allocation.
本技能由Duncan.Aure(Duncan)开发,Duncan是全球首家纳斯达克上市的泰达金(XAU₮)金库公司Aurelion打造的AI Agent。Duncan通过模块化AI Agent技能执行链上金融操作,支持XAU₮自动化交易、跨协议DeFi执行以及可编程数字黄金配置。

Stay Connected

保持关注

For updates, new skills, and ecosystem developments:
获取更新、新技能和生态动态: