Skip to main content

Predicta System Architecture 🧠

Cortex Engine, Hedgehog (Risk), and Mimic (Social) Integration
Overview: Predicta is an autonomous intelligence layer for decentralized prediction markets. It combines AI-driven alpha generation (Cortex), automated risk management (Hedgehog), and community-driven copying (Mimic).

1. Core Ecosystem Components

LayerComponentFile / ContractRole
IntelligenceCortex Braincortex/alpha.py7-factor market analysis (E1-E7)
ExecutionTrader Botcortex/cortex_trader.pyAutonomous portfolio manager
RiskHedgehog (Hedge Engine)cortex/hedge_adapter.pyDelta-neutral hedging via perps (SynFutures/ZEUS)
SocialMimic Modecortex/mimic_relay.pyMulti-user copy trading orchestration
PersistencePersonal Vaultscontracts/PreonVault.solERC-4626 personal trading accounts
TreasuryYield Gatewaycontracts/YieldGateway.solLending integration (Moonwell) for self-funding bets

2. Integrated System Map


3. Key Subsystems

3.1 The Cortex Brain (System 2)

The β€œAnalyst” layer that scores markets from 0 to 1 based on:
  • E1 - Theta: Time decay.
  • E2 - Depth: Order book liquidity.
  • E4 - AI Prob: Domain-aware ML prediction (Crypto/Sports/Politics).
  • E5 - Delusion: Market price vs. AI conviction.
  • E7 - Sentiment: News and social analytics.

3.2 Hedgehog (The Hedge Engine)

Aims for delta-neutrality. When Cortex takes a directional bet on a crypto market (e.g., β€œBTC > $100k”), Hedgehog automatically opens an offsetting short position on a perpetual exchange (SynFutures or ZEUS).

3.3 Mimic Mode (The Social Relay)

Leverages Farcaster social signals.
  • Signal: A Leader places a trade.
  • Relay: The mimic_relay.py service detects the signal.
  • Execution: The relay triggers mirror trades for all followers via their individual PreonVault contracts.

3.4 Yield Gateway & Preon Vaults

Predicta’s treasury management system:
  • Personal Vaults: Each user (or mimic relationship) has a dedicated vault that holds PUSD.
  • Yield Generation: Idle funds in vaults can be routed through the YieldGateway to Moonwell to earn interest, which can then be used to fund β€œRisk-Free” micro-bets.

3.5 Identity & Simulation (V2)

  • Privy: Non-custodial identity provider supporting Email, Social, and Web3 logins.
  • Embedded Wallets: Privy-managed MPC EOAs serve as the signers for Smart Accounts.
  • Simulation Bypass: A headless authentication mechanism for persona-sim agents using deterministic tokens derived from a shared secret.

4. Technical Stack

  • Blockchain: Base (Ethereum L2)
  • Identity: Privy (Non-custodial, Social + Email + Wallet)
  • Account Abstraction: ERC-4337 (Pimlico / Coinbase CDP Paymaster)
  • Smart Contracts: Solidity (Foundry)
  • Backend: Python (FastAPI, Web3.py) & Node.js (Next.js Server Actions)
  • Frontend: Next.js 15, Tailwind CSS, Lucide React
  • Data: Firestore (Real-time sync), Polymarket API (Gamma/CLOB)

5. Directory Structure

β”œβ”€β”€ contracts/          # Smart Contracts (Foundry)
β”œβ”€β”€ cortex/             # AI & Backend Services (Python)
β”‚   β”œβ”€β”€ alpha.py        # Brain logic
β”‚   β”œβ”€β”€ hedge_adapter.py# Risk management
β”‚   └── mimic_relay.py  # Copy trading
β”œβ”€β”€ functions/          # Firebase Cloud Functions (Node.js)
β”œβ”€β”€ persona-sim/        # QA & Persona Simulation Engine
β”œβ”€β”€ src/                # Frontend Application (Next.js)
β”‚   β”œβ”€β”€ components/     # React UI components
β”‚   └── lib/auth/       # Unified Identity (Privy)
└── docs/               # Technical Documentation