Protocol Architecture
System Overview
Actors, deterministic vs. AI division of labor, market lifecycle state machine, and V5.0 gas reduction benchmarks.
Agentic Market V5.0 is engineered around a strict division between deterministic on-chain smart contracts, stateless public read APIs, and isolated off-chain operational workers.
System Actors & Trust Boundaries
| Actor | Role | Execution Environment |
|---|---|---|
| Autonomous AI Agents & Users | Discover markets, quote via fresh RPC, sign trades & batch redemptions locally | User-controlled wallets (direct BinaryEngine calls) |
Storefront (agenticmarket.fun) & Read API (api.agenticmarket.fun) | Strictly read-only discovery, live charts, quotes, and unsigned calldata generation | Stateless public servers (zero private keys, zero auth) |
Price Engine + Keeper (KEEPER) | Launches UTC-aligned BTC 1h/4h markets and resolves via Chainlink historical rounds | Isolated worker (workers/ --mode=keeper) |
AI Curator & Resolver (RESOLVER) | Drafts trend markets and submits bonded proposals through deterministic validation firewalls | Isolated worker (workers/ --mode=curator) |
Guardian (GUARDIAN) | Submits emergency pause(key) exclusively via MEV-protected private BSC RPC | Isolated worker (workers/ --mode=guardian) |
| Solvency Watcher | Continuously verifies INV-1 ledger balance vs. USDT.balanceOf(BinaryEngine) | Isolated read-only worker (workers/ --mode=watcher) |
Governance (GOV) & Arbiter (ARBITER) | Manages Vault limits, AdapterRegistry 48h timelock, and single-round trend disputes | Phase 0 Operator → Phase 1 2-of-3 Multisig + 48h timelock |
Deterministic Code vs. AI Division
- 100% Deterministic (Zero LLM): All AMM math, dynamic/opening fees, Vault Leaky Bucket enforcement, BTC 1h/4h Price Engine scheduling, Chainlink bracketing resolution, TWAP Void payouts, and
INV-1global solvency verification. - AI-Assisted (Firewalled): Trend market ideation and external truth-source summarization. Every AI output must pass a deterministic TypeBox + rule-engine firewall (domain allowlist, adaptive probability/seed bounds, MECE slot-5
"Other", pre-match cutoff buffers, cross-source quorum, and prompt-injection stripping) before touching the chain.
Market Lifecycle State Machine
Every market starts as Active upon launch and reaches a permanent terminal state (Final or Void):
Active ──(block.timestamp >= cutoffTime, 0 gas)──> TradingClosed
│ │
│ (Guardian pause via private RPC) ├──(Price: Chainlink bracketing)──> Final
▼ ├──(Trend: bonded propose + 24h)──> Proposed ──> Final
Paused │ │
├──(Rapid VOID proposal + 6h window)──> Void │ (1-round dispute)
└──(72h PAUSE_EXPIRY permissionless)──> Void │ ▼
│ Disputed
│ ├──(Arbiter)──> Final / Void
│ └──(7d timeout)──> Void
└──(sourceTimeout permissionless)──> VoidV5.0 Gas Efficiency Benchmarks
| Operation | V4.1 Baseline | V5.0 Max-Optimized | Reduction |
|---|---|---|---|
| Create + Seed + Init TWAP (Binary) | ~380k – 450k gas | ~55k – 75k gas (~45k batch) | -83% |
| Create + Seed + Init TWAP (Multi-5) | ~650k – 800k gas | ~95k – 125k gas (~80k batch) | -84% |
| Buy / Sell (Binary — Direct USDT) | ~150k – 200k gas | ~55k – 70k gas | -64% |
| Sell (Multi-5 — Hint Verified) | ~230k – 320k gas | ~75k – 95k gas | -68% |
| Close Trading | 0 – 50k gas | 0 gas (virtual cutoffTime) | -100% |
| Resolve + Sweep (Atomic) | ~240k – 300k gas | ~40k – 55k gas (0 ERC-20 transfer) | -82% |
| Redeem (Single / Batch Incremental) | ~95k – 120k gas | ~45k / ~15k extra (delete refund) | -57% to -85% |
Backend Architecture
How the ElysiaJS + Bun + Viem Agent Read Layer indexes assembly log3 events, mirrors BinaryEngine BigInt math, and enforces zero-custody isolation.
Smart Contracts (V5.0)
Immutable Dual Singletons, Commit-to-ID MarketKey, 6-decimal internal scaling, bit-packed storage, EIP-1153 reentrancy protection, and AdapterRegistry.