Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
041: Analytics: Sniper Trade Performance
Objective
Build a real, wired x402 use case that calls the /api/x402/analytics endpoint on three.ws, pays with the autonomous loop seed wallet, records the result to x402_autonomous_log, and extracts actionable signal data.
x402 Endpoint
- Path:
/api/x402/analytics - Method: POST
- Body:
{"report":"sniper_trades","period":"24h"}
What to Build
Pay to retrieve sniper trade analytics: win rate, avg profit, worst loss, total volume snipped. Extract { win_rate, avg_profit_usdc, total_volume_sol }. Useful for strategy auto-tuning — if win_rate drops below 40%, the loop should log an alert.
Implementation Requirements
Add to registry — Add an entry in
api/_lib/x402/autonomous-registry.jsunderSELF_ENDPOINTSwith:id: unique kebab-case stringpath:/api/x402/analyticsbody:{"report":"sniper_trades","period":"24h"}cooldown_s: appropriate cooldown (300–3600 depending on signal volatility)priority: 50–99 (oracle pipeline ≥ 85, health 40–60, volume 65–75)pipeline: one of'oracle' | 'health' | 'volume' | 'sniper'extractSignal: function that parses the response body and returns a plain object with the key fields described above
Make real payments — The autonomous loop (
api/cron/x402-autonomous-loop.js) uses the seed keypair (X402_SEED_SOLANA_SECRET_BASE58) to pay real USDC. No mocks. If the endpoint does not exist yet, build it first.Record to log — Every call is recorded to
x402_autonomous_logwithpipeline,signal_data(fromextractSignal), andsuccessfields. Verify the insert in the DB after first run.Extract value — The extracted signal must be actionable. If this is an oracle pipeline entry, upsert the signal into
oracle_intel_signalswith an appropriatetopicso the sniper gate can consume it.Respect cooldowns — Set a cooldown that matches the signal's update frequency. Price data: 300s. Macro intel: 900s. Health checks: 300–600s. Audit-style calls: 1800–3600s.
Handle errors — Probe the endpoint before paying. If the endpoint returns a non-402 error, log it and skip payment. Never throw on a failed call — return
{ success: false, error_msg }and continue.
Definition of Done
- Entry added to
SELF_ENDPOINTSinautonomous-registry.js -
extractSignalfunction tested with a real response payload - Autonomous loop cron triggered manually and the entry appears in
x402_autonomous_log - If oracle pipeline: row visible in
oracle_intel_signalswith correcttopicandsignal - No console errors from this entry in the cron logs
-
git diffreviewed — no unrelated changes committed