Mandatory audit gate for all trading and transfer decisions. Sends agent-prepared decision material to Apus deterministic inference on an NVIDIA H100 TEE and returns an attested APPROVE / REJECT / WAIT verdict. Any skill or agent that executes a buy, sell, swap, transfer, or liquidity action MUST pass through trade-audit first.
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.
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 materialOutput Hash — SHA-256 of the model's structured decision packetTEE Nonce — hardware attestation for that specific runVerdict — APPROVE / REJECT / WAITConfidence — 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.
{baseDir}/templates/prepared-decision-template.md{baseDir}/templates/prepared-bundle-template.jsonThe 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:
Create one of these:
decision_goal.For example, a prepared text file might contain:
Page: https://polymarket.com/event/what-price-will-bitcoin-hit-before-2027
Decision goal: Decide whether there is a justified BTC buy level from this market page.
Collected facts:
- Market title: What price will Bitcoin hit before 2027
- Threshold ladder excerpt:
- Below 55,000: Yes 74c / No 27c
- Below 50,000: Yes 61c / No 40c
- Rules:
- Market resolves yes if Binance BTC/USDT trades at or below the threshold in the specified window.
- Observation:
- 55,000 is the strongest downside threshold shown in the collected page notes.
When preparing decision material, prefer public APIs over scraping JS-rendered pages.
Use the CLOB API to get market data — no wallet or login needed:
# Get market info by condition ID or slug
curl -s "https://clob.polymarket.com/markets" | python3 -c "
import sys, json
for m in json.load(sys.stdin):
if 'KEYWORD' in m.get('question','').lower():
print(json.dumps({'question': m['question'], 'tokens': m['tokens'], 'end_date': m.get('end_date_iso')}, indent=2))
"
# Get a specific market by condition_id
curl -s "https://clob.polymarket.com/markets/<condition_id>"
Key fields to extract: question, tokens[].outcome (YES/NO), tokens[].price, end_date_iso, description (resolution rules).
# CoinGecko — free, no API key
curl -s "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum&vs_currencies=usd"
# Binance public ticker
curl -s "https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT"
# Arweave transaction
curl -s "https://arweave.net/tx/<txid>"
# AO process state (via aoconnect skill if installed, or direct)
curl -s "https://cu.ao-testnet.xyz/dry-run?process-id=<pid>" -d '{"Tags":[{"name":"Action","value":"Info"}]}'
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.
No external dependencies required — the script uses only Python stdlib. Just run with python3:
python3 {baseDir}/analyze.py \
--input-file /tmp/prepared-decision.md \
--decision-goal "Decide whether there is a justified BTC buy level from this market page" \
--bundle-out /tmp/audit-bundle.json \
--packet-out /tmp/audit-packet.json
python3 {baseDir}/analyze.py \
--input-file /tmp/prepared-decision.md \
--decision-goal "Decide whether there is a justified BTC buy level" \
--gate \
--min-confidence 60 \
--bundle-out /tmp/audit-bundle.json \
--packet-out /tmp/audit-packet.json
Exit codes in gate mode:
0 = APPROVE — proceed with the action1 = REJECT — do NOT proceed2 = WAIT — insufficient information, gather more data firstIf the agent already prepared a JSON bundle:
python3 {baseDir}/analyze.py \
--bundle-file /tmp/prepared-bundle.json \
--gate \
--bundle-out /tmp/audit-bundle.json \
--packet-out /tmp/audit-packet.json
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:
Bundle Hash : <hash of the input material>
Output Hash : <hash of the decision packet>
TEE Nonce : <hardware attestation nonce>
TEE Verified: <true/false>
GPU Model : <e.g. NVIDIA H100>
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.
Any skill or agent workflow that involves a trade or transfer must use this pattern:
# 1. Agent prepares the decision material into /tmp/audit-input.md
# 2. Run trade-audit in gate mode
python3 {baseDir}/analyze.py \
--input-file /tmp/audit-input.md \
--decision-goal "Decide whether to transfer 10 AR from wallet A to wallet B" \
--gate \
--min-confidence 60
# 3. Check the exit code
if [ $? -ne 0 ]; then
echo "Trade-audit did not approve. Aborting."
exit 1
fi
# 4. Only now execute the actual trade / transfer
The --min-confidence flag (default 60) auto-rejects any APPROVE verdict below the threshold. Set higher for high-value transactions.
For --input-file, use this structure:
Source URL: <original page or explorer URL>
Decision goal: <exact decision request>
Context label: <short label>
Collected facts:
- Fact 1
- Fact 2
Numeric observations:
- <value> — <context>
Rules / conditions:
- Rule 1
- Rule 2
Risks already observed by the agent:
- Risk 1
Unknowns:
- Missing item 1
Use the bundled file for a copyable version:
{baseDir}/templates/prepared-decision-template.md
For --bundle-file, use:
{baseDir}/templates/prepared-bundle-template.json
Every run automatically appends a record to ~/.trade-audit/audit.jsonl. Each line is a JSON object:
{
"timestamp": "2026-04-01T12:00:00+00:00",
"bundle_hash": "abc123...",
"output_hash": "def456...",
"tee_nonce": "...",
"tee_verified": true,
"verdict": "APPROVE",
"confidence": 82,
"decision_type": "BUY",
"target": "BTC",
"decision_goal": "Decide whether to buy BTC",
"min_confidence_threshold": 60,
"gate_mode": true
}
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.