Soyara DEX Developer Docs
DocsSoyara DEX Ecosystem1. Overview & Architecture

1. Overview & Architecture

Soyara DEX is the flagship AI-native Decentralized Exchange Aggregator and Automated Market Maker built natively for the GenLayer Bradbury Testnet (Chain ID 4221). By combining high-speed EVM AMM liquidity with GenLayer Intelligent Contracts (ICs) executing in the Python-powered GenVM sandbox, Soyara DEX creates an un-hackable, intent-driven execution environment for both human traders and autonomous AI agents.

The Paradigm Shift: From Blind AMMs to Cognitive Market Makers
Traditional smart contracts are blind: they execute raw bytecode without evaluating economic rationale, contextual risk, or malicious MEV slippage. Soyara DEX introduces Decentralized Intelligent Contracts that evaluate trade proposals across independent validator nodes using Optimistic Democracy consensus before committing state on-chain.

The 3-Tiered Hybrid Architecture

Soyara DEX divides decentralized finance into three modular layers: Intent Formulation, Consensus-Enforced Validation, and Atomic Settlement.

Tier 1: Intent & AI Agents

Agent Interaction Layer

Conversational LLMs and external autonomous bots convert user intents or algorithmic signals into structured, normalized Execution Proposals with zero raw calldata ambiguity.

Tier 2: GenVM Consensus

Intelligent Contracts (ICs)

AgentValidator.py checks every order on GenLayer validator nodes against live pool state, with deterministic rules and LLM consensus (gl.eq_principle.strict_eq), and delivers its verdict to the settlement contract itself.

Tier 3: EVM Settlement

AgentExecutor → AGGFlow Router

AgentExecutor refuses any agent trade the validator did not authorise, then runs the route through the AGGFlow bytecode router across SoyaraDex V2 and V3 pools, atomically.

Complete High-Level Flow Diagram

text
[ Autonomous AI Agent / User ]
                │
                ▼ (1. Intent → best-route quote → the exact order)
   SwapOrder: route program, fee, collector, recipient, quote, deadline
                │
                ▼ (2. Choose the authority, before any round is opened)
   ┌────────────────────────────────────────────────────────────┐
   │ Covered by a mandate an earlier round issued?              │
   │   yes → rail "mandate"   (no new round)                    │
   │   no  → rail "consensus": validate_swap on AgentValidator  │
   │         · decodes the route, verifies every pool on chain  │
   │         · re-derives the quote from live reserves          │
   │         · LLM coherence review under strict_eq             │
   │         · emits recordVerdict to AgentExecutor on finality │
   └────────────────────────────────────────────────────────────┘
                │
                ▼ (3. Settlement: AgentExecutor, and nothing else)
   ┌────────────────────────────────────────────────────────────┐
   │ consensus → executeSwap(order, program)                    │
   │             re-derives the commitment, consumes the        │
   │             single-use verdict, reverts if none            │
   │ mandate   → executeSwapUnderMandate(id, amount, ...)       │
   │             checks size, budget, fee, route against the    │
   │             mandate and prices the trade from the pool     │
   │ → AGGFlowEntrypoint → SoyaraDex V2 / V3 pools              │
   └────────────────────────────────────────────────────────────┘
                │
                ▼ (4. Output lands at the recipient in the order)