xaut-trade
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesexaut-trade
xaut-trade
Execute buy and sell flows via Uniswap V3 + Foundry .
USDT -> XAUTXAUT -> USDTcast通过Uniswap V3 + Foundry 执行买入和卖出流程。
castUSDT -> XAUTXAUT -> USDTWhen 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 . Inform the user before executing any external communication for the first time. See the README for a full list.
curl | bash本技能会连接外部服务(Ethereum RPC、UniswapX API,可选连接xaue.com排行榜)。首次设置时,可能会通过安装Foundry。首次执行任何外部通信前请告知用户。完整列表请查看README。
curl | bashEnvironment Readiness Check (run first on every session)
环境就绪检查(每次会话首先运行)
Before handling any user intent (except knowledge queries), run these checks:
- Is available:
castFail (command not found) → Foundry is not installed; run the setup script before anything elsecast --version - Does exist:
~/.aurehub/.envls ~/.aurehub/.env - Does keystore account exist:
aurehub-walletoutput containscast wallet listaurehub-wallet - Does exist:
~/.aurehub/.wallet.passwordls ~/.aurehub/.wallet.password
If all pass: source , then proceed to intent detection.
~/.aurehub/.envImportant — 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(orsource ~/.aurehub/.envto auto-export all variables).set -a; source ~/.aurehub/.env; set +aWALLET_ADDRESS is not stored in— it must be derived fresh in every bash block that uses it:.envbashsource ~/.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 fails, fall back to references/onboarding.md for manual steps. After setup completes, re-run the original intent.
git rev-parseProceed to intent detection.
Extra checks for limit orders (only when the intent is limit buy / sell / query / cancel):
- Is Node.js >= 18 available: Fail → go to the "Extra Dependencies for Limit Orders" section in references/onboarding.md, install, then continue
node --version - Are limit order dependencies installed: Fail → run
ls "$(git rev-parse --show-toplevel)/skills/xaut-trade/scripts/node_modules", then continue (Ifcd "$(git rev-parse --show-toplevel)/skills/xaut-trade/scripts" && npm installfails, first rungit rev-parseto locate the scripts directory, then cd into it and run npm install)find ~ -name "limit-order.js" -maxdepth 6 - Is configured:
UNISWAPX_API_KEYFail → hard-stop, output:[ -n "$UNISWAPX_API_KEY" ] && [ "$UNISWAPX_API_KEY" != "your_api_key_here" ]Limit orders require a UniswapX API Key. How to get one (about 5 minutes, free):- Visit https://developers.uniswap.org/dashboard
- Sign in with Google / GitHub
- Generate a Token (choose Free tier)
- Add the key to ~/.aurehub/.env:
UNISWAPX_API_KEY=your_key - Re-submit your request
处理任何用户意图前(知识查询除外),请运行以下检查:
- 是否可用:
cast失败(找不到命令)→ 未安装Foundry;优先运行安装脚本cast --version - 是否存在:
~/.aurehub/.envls ~/.aurehub/.env - keystore账户是否存在:
aurehub-wallet输出包含cast wallet listaurehub-wallet - 是否存在:
~/.aurehub/.wallet.passwordls ~/.aurehub/.wallet.password
如果全部通过:加载,然后进行意图识别。
~/.aurehub/.env重要提示——shell隔离:每一次Bash工具调用都运行在新的子进程中;一次调用中设置的变量不会持久化到下一次调用。因此所有需要环境变量的Bash命令块都必须以开头(或使用source ~/.aurehub/.env自动导出所有变量)。set -a; source ~/.aurehub/.env; set +aWALLET_ADDRESS不会存储在中——每个需要用到该变量的bash块都必须重新生成:.envbashsource ~/.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"如果执行失败,可参考references/onboarding.md执行手动步骤。设置完成后,重新运行原意图。
git rev-parse继续进行意图识别。
限价单额外检查(仅当意图为限价买入/卖出/查询/取消时执行):
- Node.js版本是否>=18:失败 → 参考references/onboarding.md中的「限价单额外依赖」部分安装后继续
node --version - 限价单依赖是否已安装:失败 → 运行
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定位脚本目录,然后cd到该目录运行npm install)find ~ -name "limit-order.js" -maxdepth 6 - 是否已配置:
UNISWAPX_API_KEY失败 → 强制终止,输出:[ -n "$UNISWAPX_API_KEY" ] && [ "$UNISWAPX_API_KEY" != "your_api_key_here" ]限价单需要UniswapX API Key。 获取方式(约5分钟,免费):- 访问 https://developers.uniswap.org/dashboard
- 使用Google/GitHub登录
- 生成Token(选择免费套餐)
- 将密钥添加到~/.aurehub/.env:
UNISWAPX_API_KEY=your_key - 重新提交请求
Config & Local Files
配置与本地文件
- Global config directory: (persists across sessions, not inside the skill directory)
~/.aurehub/ - path:
.env~/.aurehub/.env - path:
config.yaml~/.aurehub/config.yaml - Contract addresses and defaults come from ; copy to
skills/xaut-trade/config.example.yamlduring onboarding~/.aurehub/config.yaml
- 全局配置目录:(跨会话持久化,不在技能目录内)
~/.aurehub/ - 路径:
.env~/.aurehub/.env - 路径:
config.yaml~/.aurehub/config.yaml - 合约地址和默认值来自;引导阶段将其复制到
skills/xaut-trade/config.example.yaml~/.aurehub/config.yaml
Interaction & Execution Principles (semi-automated)
交互与执行原则(半自动化)
- Run pre-flight checks first, then quote.
- Show a complete command preview before any .
cast send - Only execute on-chain write operations after receiving explicit confirmation in the current session (e.g. "confirm execute").
- Large trades and high-slippage trades require a second confirmation.
- 首先运行预检,然后给出报价。
- 执行任何前展示完整的命令预览。
cast send - 仅在当前会话收到明确确认后(如「confirm execute」)才执行链上写入操作。
- 大额交易和高滑点交易需要二次确认。
Mandatory Safety Gates
强制安全闸门
- When amount exceeds the config threshold (e.g. ), require double confirmation
risk.large_trade_usd - When slippage exceeds the threshold (e.g. ), warn and require double confirmation
risk.max_slippage_bps_warn - 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 , parse as a comma-separated list of fallback RPC URLs.
~/.aurehub/.envETH_RPC_URL_FALLBACKIf any or command fails and its output contains any of the following:
, , , , , ,
cast callcast send429502503timeoutconnection refusedrate limitToo Many RequestsThen:
- Try the same command with each fallback URL in order (replace with the fallback URL)
--rpc-url "$ETH_RPC_URL" - First success → set that URL as the active RPC for all remaining commands this session; do not retry the primary
- 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 ofin
ETH_RPC_URL_FALLBACK~/.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 in this session. Never switch back to the primary or try other fallbacks unless the current one also fails.
--rpc-url加载后,将解析为逗号分隔的备用RPC URL列表。
~/.aurehub/.envETH_RPC_URL_FALLBACK如果任何或命令执行失败,且输出包含以下任意内容:
、、、、、、
cast callcast send429502503timeoutconnection refusedrate limitToo Many Requests则执行以下操作:
- 按顺序使用每个备用URL重试相同命令(将替换为备用URL)
--rpc-url "$ETH_RPC_URL" - 首次成功 → 将该URL设置为本次会话剩余所有命令的活跃RPC;不再重试主节点
- 所有备用节点都失败 → 强制终止并输出:
RPC不可用。所有配置节点均失败(主节点 + N个备用节点)。 修复方案:在的
~/.aurehub/.env列表最前面添加付费RPC(Alchemy/Infura)ETH_RPC_URL_FALLBACK
非网络错误不要触发降级策略:余额不足、合约回滚、参数无效、nonce不匹配等,直接向用户报告即可。
会话粘性:选定备用RPC后,本次会话后续所有都使用该地址。除非当前节点也失败,否则不要切回主节点或尝试其他备用节点。
--rpc-urlIntent 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 --versioncast block-number --rpc-url $ETH_RPC_URL- ETH and stablecoin balance checks
参考references/balance.md:
cast --versioncast 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 then
approve(0))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 --versioncast block-number --rpc-url $ETH_RPC_URL- ETH balance check
- XAUT balance check (required): hard-stop if insufficient
参考references/balance.md:
cast --versioncast 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 (XAUT → USDT direction)
amountOut - 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获取(XAUT → USDT方向)
amountOut - 计算
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):
source ~/.aurehub/.env- If !=
RANKINGS_OPT_IN→ silent skip, do not prompt"true" REGISTERED=$(cat ~/.aurehub/.registered 2>/dev/null)WALLET_ADDRESS=$(cast wallet address --account "$FOUNDRY_ACCOUNT" --password-file ~/.aurehub/.wallet.password)- If starts with
"$REGISTERED"→ already registered, silent skip"$WALLET_ADDRESS:" - Otherwise → register using from
NICKNAME:.envbashREGISTER_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: ; inform: "Registered with nickname: $NICKNAME"
echo "$WALLET_ADDRESS:$NICKNAME" > ~/.aurehub/.registered - Any other status: silent continue, do not write marker file
- HTTP 200 or 201:
Never ask the user for a nickname during the trade flow. The nickname is set during onboarding only.
任何链上交易成功完成后(买入兑换、卖出兑换、或限价单提交):
source ~/.aurehub/.env- 如果!=
RANKINGS_OPT_IN→ 静默跳过,不提示用户"true" REGISTERED=$(cat ~/.aurehub/.registered 2>/dev/null)WALLET_ADDRESS=$(cast wallet address --account "$FOUNDRY_ACCOUNT" --password-file ~/.aurehub/.wallet.password)- 如果以
"$REGISTERED"开头 → 已登记,静默跳过"$WALLET_ADDRESS:" - 否则 → 使用中的
.env进行登记:NICKNAMEbashREGISTER_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:;告知用户:「已使用昵称登记:$NICKNAME」
echo "$WALLET_ADDRESS:$NICKNAME" > ~/.aurehub/.registered - 其他状态:静默继续,不写入标记文件
- HTTP 200或201:
交易流程中不要向用户索要昵称。昵称仅在引导阶段设置。
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:
- :
StageorPreviewReady to Execute - : token, amount, chain
Input - : estimated XAUT amount, slippage setting,
QuoteminAmountOut - :
Reference rate(for comparison with spot price; shown for both buy and sell)1 XAUT ≈ X USDT - : large trade / slippage / gas
Risk warnings - : full
Commandcommandcast - : tx hash, post-trade balance (after execution)
Result
输出必须包含:
- :
阶段或预览准备执行 - :代币、金额、链
输入 - :预计XAUT数量、滑点设置、
报价minAmountOut - :
参考汇率(用于和现货价格对比;买入和卖出都要展示)1 XAUT ≈ X USDT - :大额交易/滑点/gas相关提示
风险提示 - :完整的
命令命令cast - :交易哈希、交易后余额(执行后展示)
结果
Error Handling
错误处理
- Missing prerequisite variable: prompt to add the variable to and stop
.env - 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 commands needed.
cast- 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
直接使用以上数据回答知识查询——无需运行命令。
castFirst-Turn Contract (for testing)
首次交互规则(用于测试)
- When information is sufficient: give a structured preview first, then ask for execution confirmation.
- When information is insufficient: clarify key details (token, amount, environment variables) — do not claim a trade has been executed.
- 信息充足时:先给出结构化预览,然后询问执行确认。
- 信息不足时:澄清关键细节(代币、金额、环境变量)——不要声称交易已执行。
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:
- X: Aure_duncan
- Telegram: @aure_duncanbot
- Aurelion: aurelion.com
获取更新、新技能和生态动态:
- X:Aure_duncan
- Telegram:@aure_duncanbot
- Aurelion:aurelion.com