Trade-Audit — Mandatory Audit Gate for Trading & Transfer Decisions
When to use
This skill is designed for auditing financial decisions — buy, sell, swap, transfer, liquidity pool entry/exit, or any on-chain value movement. The user may ask you to run it before executing a trade or transfer, or to always use it as a pre-check for financial actions.
What this skill does
Takes agent-prepared decision material and sends it to the Apus deterministic inference API running on an NVIDIA H100 TEE. Returns a structured, hardware-attested decision packet with:
- -
Bundle Hash — SHA-256 of the normalized decision material - INLINECODE1 — SHA-256 of the model's structured decision packet
- INLINECODE2 — hardware attestation for that specific run
- INLINECODE3 — APPROVE / REJECT / WAIT
- INLINECODE4 — 1-100 integer, gated by
--min-confidence (default 60)
Every run is logged to ~/.trade-audit/audit.jsonl.
No wallet or API key required. This skill only reads public data and calls the Apus inference API. It does not execute any transactions.
Important boundary:
The script is at {baseDir}/analyze.py.
- - The agent collects the page contents, address information, pool details, rules, and relevant facts.
- The agent organizes that material into either a text/markdown file or a JSON decision bundle.
- This script does not fetch pages or explorer data itself.
- Reuse the bundled templates when preparing inputs:
- Markdown template:
{baseDir}/templates/prepared-decision-template.md
- JSON template: INLINECODE9
Step 1 — Prepare the decision material
The audit model (gemma-3-27b-it) performs best with concise, focused inputs. The agent MUST distill raw data into core decision points before submitting.
Data preparation rules:
- - Extract only: prices, thresholds, numeric values, rules/conditions, addresses, risk factors
- Strip out: page chrome, disclaimers, marketing text, navigation, repeated boilerplate
- Keep material under 4,000 characters when possible (warning at 4k, hard truncation at 12k)
- Each fact should be one short bullet — no paragraphs
- If a page has 50 data points, pick the 5-10 that directly affect the decision
Create one of these:
- 1. A text or markdown file containing the organized facts.
- A JSON bundle containing the organized facts plus
decision_goal.
For example, a prepared text file might contain:
CODEBLOCK0
Common data sources (no auth required)
When preparing decision material, prefer public APIs over scraping JS-rendered pages.
Polymarket
Use the CLOB API to get market data — no wallet or login needed:
CODEBLOCK1
Key fields to extract: question, tokens[].outcome (YES/NO), tokens[].price, end_date_iso, description (resolution rules).
Crypto prices
CODEBLOCK2
On-chain data
CODEBLOCK3
The agent should fetch data from these APIs, extract the core numbers, and organize them into the decision material template. Do not pass raw API responses directly — distill to key facts first.
Step 2 — Run the audit
No external dependencies required — the script uses only Python stdlib. Just run with python3:
Standard mode (always returns exit 0 on success)
CODEBLOCK4
Gate mode (exit code reflects verdict)
CODEBLOCK5
Exit codes in gate mode:
- -
0 = APPROVE — proceed with the action - INLINECODE19 = REJECT — do NOT proceed
- INLINECODE20 = WAIT — insufficient information, gather more data first
If the agent already prepared a JSON bundle:
CODEBLOCK6
Print the full terminal output to the user exactly as it appears.
After the audit completes, the agent MUST include these TEE attestation fields in the response to the user:
CODEBLOCK7
These fields prove the decision was made inside a Trusted Execution Environment. Omitting them defeats the purpose of using this skill. Always show them alongside the verdict summary.
Step 3 — Integration pattern for other skills
Any skill or agent workflow that involves a trade or transfer must use this pattern:
CODEBLOCK8
The --min-confidence flag (default 60) auto-rejects any APPROVE verdict below the threshold. Set higher for high-value transactions.
Step 4 — Agent preparation templates
For --input-file, use this structure:
CODEBLOCK9
Use the bundled file for a copyable version:
INLINECODE23
For --bundle-file, use:
INLINECODE25
Step 5 — Audit log
Every run automatically appends a record to ~/.trade-audit/audit.jsonl. Each line is a JSON object:
CODEBLOCK10
Step 6 — Explain the attestation
After the report, add this note:
Reading the hashes in the report
| Field | Meaning |
|---|
| Bundle Hash | Hash of the normalized source bundle used as model input |
| Output Hash |
Hash of the structured decision packet JSON |
|
TEE Nonce | Hardware attestation proving the run came from an NVIDIA H100 TEE |
To reproduce the decision exactly, rerun the skill on the same saved bundle with the same decision goal. If the bundle is identical, the Output Hash should match. The TEE Nonce changes on each run because it is bound to that specific execution.
交易审计 — 交易与转账决策的强制性审计关口
何时使用
本技能专为审计金融决策而设计——买入、卖出、兑换、转账、流动性池进出或任何链上价值转移。用户可能要求你在执行交易或转账前运行此技能,或始终将其作为金融操作的预检步骤。
本技能的功能
获取代理准备的决策材料,并将其发送至运行在NVIDIA H100 TEE上的Apus确定性推理API。返回一个结构化的、经硬件认证的决策包,包含:
- - Bundle Hash — 标准化决策材料的SHA-256哈希值
- Output Hash — 模型结构化决策包的SHA-256哈希值
- TEE Nonce — 该次特定运行的硬件认证随机数
- Verdict — 批准/拒绝/等待
- Confidence — 1-100整数,受--min-confidence(默认60)限制
每次运行都会记录到~/.trade-audit/audit.jsonl。
无需钱包或API密钥。 本技能仅读取公共数据并调用Apus推理API。不执行任何交易。
重要边界:
脚本位于{baseDir}/analyze.py。
- - 代理收集页面内容、地址信息、池详情、规则和相关事实。
- 代理将这些材料整理为文本/标记文件或JSON决策包。
- 此脚本本身不获取页面或浏览器数据。
- 准备输入时复用捆绑模板:
- Markdown模板:{baseDir}/templates/prepared-decision-template.md
- JSON模板:{baseDir}/templates/prepared-bundle-template.json
步骤1 — 准备决策材料
审计模型(gemma-3-27b-it)在简洁、聚焦的输入下表现最佳。代理必须在提交前将原始数据提炼为核心决策点。
数据准备规则:
- - 仅提取:价格、阈值、数值、规则/条件、地址、风险因素
- 剔除:页面装饰、免责声明、营销文本、导航、重复模板内容
- 尽量将材料控制在4,000字符以内(4k时发出警告,12k时强制截断)
- 每个事实应为简短要点——不要段落
- 如果页面有50个数据点,选择直接影响决策的5-10个
创建以下之一:
- 1. 包含组织后事实的文本或markdown文件。
- 包含组织后事实及decision_goal的JSON包。
例如,准备好的文本文件可能包含:
text
页面:https://polymarket.com/event/what-price-will-bitcoin-hit-before-2027
决策目标:判断此市场页面是否存在合理的BTC买入水平。
收集的事实:
- - 市场标题:比特币在2027年前将达到什么价格
- 阈值阶梯摘录:
- 低于55,000:是74c / 否27c
- 低于50,000:是61c / 否40c
- 如果币安BTC/USDT在指定窗口内交易价格达到或低于阈值,市场判定为是。
- 55,000是收集的页面注释中显示的最强下行阈值。
常见数据源(无需认证)
准备决策材料时,优先使用公共API而非抓取JS渲染页面。
Polymarket
使用CLOB API获取市场数据——无需钱包或登录:
bash
按条件ID或slug获取市场信息
curl -s https://clob.polymarket.com/markets | python3 -c
import sys, json
for m in json.load(sys.stdin):
if 关键词 in m.get(question,).lower():
print(json.dumps({question: m[question], tokens: m[tokens], end
date: m.get(enddate_iso)}, indent=2))
按condition_id获取特定市场
curl -s https://clob.polymarket.com/markets/
关键提取字段:question、tokens[].outcome(是/否)、tokens[].price、enddateiso、description(解析规则)。
加密货币价格
bash
CoinGecko — 免费,无需API密钥
curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum&vs_currencies=usd
币安公共行情
curl -s https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT
链上数据
bash
Arweave交易
curl -s https://arweave.net/tx/
AO进程状态(通过aoconnect技能(如已安装)或直接调用)
curl -s https://cu.ao-testnet.xyz/dry-run?process-id= -d {Tags:[{name:Action,value:Info}]}
代理应从这些API获取数据,提取核心数字,并组织到决策材料模板中。不要直接传递原始API响应——先提炼为关键事实。
步骤2 — 运行审计
无需外部依赖——脚本仅使用Python标准库。直接用python3运行:
标准模式(成功时始终返回退出码0)
bash
python3 {baseDir}/analyze.py \
--input-file /tmp/prepared-decision.md \
--decision-goal 判断此市场页面是否存在合理的BTC买入水平 \
--bundle-out /tmp/audit-bundle.json \
--packet-out /tmp/audit-packet.json
关口模式(退出码反映裁决结果)
bash
python3 {baseDir}/analyze.py \
--input-file /tmp/prepared-decision.md \
--decision-goal 判断是否存在合理的BTC买入水平 \
--gate \
--min-confidence 60 \
--bundle-out /tmp/audit-bundle.json \
--packet-out /tmp/audit-packet.json
关口模式下的退出码:
- - 0 = 批准 — 继续执行操作
- 1 = 拒绝 — 不要继续
- 2 = 等待 — 信息不足,先收集更多数据
如果代理已准备好JSON包:
bash
python3 {baseDir}/analyze.py \
--bundle-file /tmp/prepared-bundle.json \
--gate \
--bundle-out /tmp/audit-bundle.json \
--packet-out /tmp/audit-packet.json
将完整的终端输出原样打印给用户。
审计完成后,代理必须在回复中包含以下TEE认证字段:
Bundle Hash : <输入材料的哈希值>
Output Hash : <决策包的哈希值>
TEE Nonce : <硬件认证随机数>
TEE Verified:
GPU Model : <例如 NVIDIA H100>
这些字段证明决策是在可信执行环境内做出的。省略它们将违背使用此技能的目的。始终将其与裁决摘要一起展示。
步骤3 — 其他技能的集成模式
任何涉及交易或转账的技能或代理工作流必须使用此模式:
bash
1. 代理将决策材料准备到 /tmp/audit-input.md
2. 以关口模式运行trade-audit
python3 {baseDir}/analyze.py \
--input-file /tmp/audit-input.md \
--decision-goal 判断是否将10个AR从钱包A转账到钱包B \
--gate \
--min-confidence 60
3. 检查退出码
if [ $? -ne 0 ]; then
echo 交易审计未批准。中止。
exit 1
fi
4. 仅在此后执行实际交易/转账
--min-confidence标志(默认60)会自动拒绝低于阈值的任何批准裁决。对于高价值交易可设置更高值。
步骤4 — 代理准备模板
对于--input-file,使用此结构:
text
来源URL:<原始页面或浏览器URL>
决策目标:<确切的决策请求>
上下文标签:<简短标签>
收集的事实:
数值观察:
规则/条件:
代理已观察到的风险:
未知项:
使用捆绑文件获取可复制版本:
{baseDir}/templates/prepared-decision-template.md
对于--bundle-file,使用:
{baseDir}/templates/prepared-bundle-template.json
步骤5 — 审计日志
每次运行会自动追加一条记录到~/.trade-audit/audit.jsonl。每行是一个JSON对象:
json
{
timestamp: 2026-04-01T12:00:00+00:00,
bundle_hash: abc123...,
output_hash: def456...,
tee_nonce: ...,
tee_verified: true,
ver