Instant prediction markets for live streams powered by Panta.
[ Live Demo ] ─── <!-- TODO(owner): insert live demo link -->
[ Walkthrough Video ] ─── <!-- TODO(owner): insert video link -->
Live-stream chats are filled with debate, speculation, and arguments over live outcomes ("Will he defeat the boss on this attempt?", "Does this raid wipe in phase 2?"). Viewers participate with fleeting chat comments, while creators receive little direct monetization from viewer consensus.
LiveEdge transforms that live chat energy into real-time prediction markets. A streamer or the automated engine launches a binary YES/NO market based on live stream events. Viewers take positions in a single tap, market odds adjust in real time alongside the video feed, and winners claim their payouts upon market resolution while creators earn volume-based fees.
- Market Creation: A creator or automated broadcast engine launches a question tied to the active stream.
- Instant Bet: Viewers choose YES or NO with play money (
sim_usdc). - Dynamic Odds: Prices update in real time via an LMSR market-maker curve alongside the live video.
- Outcome Resolution: The market resolves once the outcome occurs.
- Settlement & Claims: Winning positions claim payouts, and creators claim earned fees.
Panta operates non-custodially: Panta returns unsigned Solana transactions, the user signs via their own wallet, the client broadcasts to an RPC, and the transaction signature is submitted back for verification.
sequenceDiagram
autonumber
actor User as Viewer (User)
participant Client as Web App (React)
participant Server as LiveEdge Server
participant Panta as Panta API
participant Solana as Solana RPC
User->>Client: Tap YES or NO
Client->>Server: POST /api/orders/quote
Server->>Panta: POST /primaryorderquote/
Panta-->>Server: quoteId, avgPrice, feeUsdc
Server-->>Client: Quote parameters
Client->>Server: POST /api/orders/build
Server->>Panta: POST /primaryorderbuild/
Panta-->>Server: Unsigned VersionedTransaction
Server-->>Client: signPayload (Base64 transaction)
Client->>User: Request wallet signature
User-->>Client: Signed transaction
Client->>Solana: Broadcast transaction
Solana-->>Client: Transaction signature (txHash)
Client->>Server: POST /api/orders/submit (txHash)
Server-->>Client: Position credited & trade logged
Note: In Door 1 mode (sim and hybrid), settlement runs against an in-app simulated balance (sim_usdc), avoiding mainnet financial risk while preserving the exact Panta transaction and quote flow.
LiveEdge integrates the Panta Prediction Market API (docs.panta.market) under the Door 1 paradigm: real market data and real Panta API contract shapes coupled with simulated settlement.
| Panta Capability | LiveEdge Implementation | Mode Support | Source File |
|---|---|---|---|
| Market Catalog & Detail | Fetches live market batches (GET /markets/) and market details (GET /markets/{id}/) |
HYBRID / LIVE (Real) SIM (Simulated) |
server/src/panta/liveClient.js server/src/services/pantaSync.js |
| Real-Time Prices & Quotes | Syncs primary market prices; requests quotes (POST /primaryorderquote/) |
HYBRID / LIVE (Real) SIM (Simulated) |
server/src/panta/liveClient.js server/src/panta/hybrid.js |
| Market Creation Quotes & Build | Requests fee quote (POST /markets/create/quote/) and builds creation tx (POST /markets/create/build/) |
HYBRID / LIVE (Real preview) SIM (Simulated) |
server/src/panta/liveClient.js server/src/panta/hybrid.js |
| Primary Buy Order Build | Constructs unsigned Solana VersionedTransaction (POST /primaryorderbuild/) |
HYBRID / LIVE (Real build) SIM (Simulated) |
server/src/panta/liveClient.js server/src/panta/hybrid.js |
| Wallet Positions | Queries active positions (GET /positions/?wallet=) |
HYBRID / LIVE (Real query) SIM (Simulated) |
server/src/panta/liveClient.js server/src/panta/hybrid.js |
| Trade Tape / Activity | Reads historical trade records (GET /markets/{id}/trades/) |
HYBRID / LIVE (Real reads) SIM (Local tape) |
server/src/panta/liveClient.js |
| Order Settlement & Execution | Settle buy orders into sim_usdc balances |
SIMULATED | server/src/panta/simClient.js |
| Win Claims | Verify eligibility and credit winning positions in sim_usdc |
SIMULATED | server/src/panta/simClient.js |
| Creator Fee Claims | Release volume-graduated creator fees into creator balance | SIMULATED | server/src/panta/simClient.js |
- Live Stream Prediction Hub: Synchronized video embeds (Kick primary, YouTube fallback) alongside live betting boards.
- Logarithmic Market Scoring Rule (LMSR): Automated market-maker algorithm providing bounded liquidity and continuous price discovery.
- AI Broadcast Market Engine: Auto-generates contextual prediction markets from live broadcast data using a resilient provider chain (Gemini with Cloudflare Workers AI and OpenRouter failover).
-
Opening Line Priors: Gemini supplies an informed initial probability distribution
$\pi_y$ , setting an executable opening price without distorting LMSR invariant math. - Real-Time Data Streaming: Server-Sent Events (SSE) push odds updates and trade tape feeds without client polling.
- Dual Wallet & Auth Support: Ephemeral Ed25519 guest keypairs for instant trial, plus Privy authentication for persistent profiles.
- Honesty: No synthetic views, fake streamers, or fabricated activity. When external feeds or market data are unreachable, the UI marks them as empty or stale rather than displaying generated data.
-
Play Money Only (Panta Door 1): Real outcomes with simulated settlement. Accounts operate with
sim_usdc(zero cash value) to enable frictionless entertainment and regulatory clarity. -
Money Conservation: The internal ledger adheres to strict double-entry conservation verified down to integer micro-units (
$10^{-6}$ ):
This rule is enforced by server/test/invariant.test.js.
graph TD
Client["React 18 SPA (Vite + Tailwind)"] -->|REST API / SSE| API["Express 4 Server"]
API -->|Persistence| DB["PostgreSQL / PGlite"]
API -->|Live Reads & Builds| PantaAPI["Panta Market API"]
API -->|Market Generation| LLM["LLM Chain (Gemini / CF / OpenRouter)"]
API -->|Stream Aggregation| Aggregator["Stream Hub (Kick / YouTube / Livepeer)"]
.
├── docs/ # Specifications, architecture, and guides
├── scripts/ # Dev server runner, smoke tests, security checks
├── server/
│ ├── src/ # Express backend, LMSR engine, Panta client, routes
│ └── test/ # node:test test suite and invariant tests
└── web/
├── public/ # Static assets
└── src/ # React frontend (components, pages, lib, hooks)
- Hanson's Logarithmic Market Scoring Rule (LMSR) determines prices:
$p_{\text{yes}} = \frac{1}{1 + e^{-(q_y - q_n)/b}}$ . - Opening lines incorporate an initial prior
$\pi_y$ via quantity shift:$C_{\text{prior}}(q) = C_{\text{uniform}}(q + b \ln \pi)$ . - At
$q = 0$ , the market opens exactly at the probability supplied by the engine ($\pi_y$ ). - The displayed price directly matches the execution price for incoming orders.
- Worst-case subsidy is bounded at
$b \ln(1 / \min(\pi_y, \pi_n))$ . - If the AI engine is unavailable, the market degrades safely to a neutral
$0.50$ opening line.
- Node.js 20+ (
node -v) - pnpm 9.12+ (
corepack enableornpm install -g pnpm)
-
Clone repository and install dependencies:
pnpm install
-
Configure environment:
# PowerShell Copy-Item .env.example .env # Bash cp .env.example .env
-
Launch development servers:
pnpm dev
-
Verify instances:
- Web interface: http://localhost:5173
- API endpoints: http://localhost:4000/health
| Environment Variable | Purpose | Default | Required Mode |
|---|---|---|---|
NODE_ENV |
Runtime environment (development, test, production) |
development |
All |
PORT |
API server listen port | 4000 |
All |
DATABASE_URL |
PostgreSQL connection string (uses embedded PGlite if unset) | "" |
Production |
JWT_SECRET |
Session authentication secret (min 32 chars) | dev placeholder | Production |
PANTA_MODE |
Integration mode: sim, hybrid, live |
sim |
All |
PANTA_BASE_URL |
Panta API endpoint | https://live-api.panta.market/api/v1 |
All |
PANTA_API_KEY |
Panta API authentication key | "" |
Hybrid, Live |
PANTA_REALTIME_ENABLED |
Enables live Panta market background polling | false |
Hybrid (optional) |
KICK_CLIENT_ID |
Kick Developer Client ID | "" |
Stream browsing |
KICK_CLIENT_SECRET |
Kick Developer Client Secret | "" |
Stream browsing |
YOUTUBE_API_KEY |
Google Cloud API Key for YouTube Live search | "" |
YouTube streams |
GEMINI_API_KEY |
Google Gemini API key for automated market engine | "" |
AI engine |
PRIVY_APP_ID |
Privy Application ID for wallet authentication | "" |
Privy auth |
PRIVY_APP_SECRET |
Privy App Secret (server-side only) | "" |
Privy auth |
| Mode | Panta Reads | Trades & Claims | Key Required | Target Audience |
|---|---|---|---|---|
sim (default) |
Simulated DB | Local sim_usdc simulation |
No | Local development, CI testing |
hybrid |
Real Panta API | Local sim_usdc simulation |
Yes (PANTA_API_KEY) |
Demo preview with real market data |
live |
Real Panta API | Panta API / chain execution | Yes (API Key + Funded Wallet) | Full production |
Run the standard test gates from the repository root:
pnpm test # Runs all server and web test suites
pnpm build # Builds production bundle
pnpm lint # Runs ESLint analysis across workspace
pnpm check-secrets # Scans repository for leaked credentials
pnpm smoke # Executes end-to-end user lifecycle smoke test- Server Unit & Route Tests: 431 passed, 94 suites (
node --test) - Web Frontend Tests: 181 passed, 16 test files (
vitest run) - Money Invariant Test: 3 passed, 1 suite (
node --test test/invariant.test.js) - E2E Smoke Verification: 26 passed (
scripts/smoke.mjs) - Build: 0 errors
- Linter: 0 errors (1 warning)
- Secrets Audit: Passed (
scripts/check-secrets.mjs)
- Play Money Only: LiveEdge balances use
sim_usdcwith zero cash value. It is not an exchange or real-money wagering application. - Simulated Settlement: In
simandhybridmodes, resolution and claims are handled by internal simulator logic rather than on-chain settlement contracts. - Provider Degradation: When external services (Gemini, Kick, YouTube) are offline or unconfigured, LiveEdge degrades gracefully to cached data, flat 50/50 opening lines, or curated feeds.
- On-Chain Settlement Bridge: Graduate high-volume play-money markets into direct Panta Solana contracts.
- Creator Dashboard: Expanded real-time analytics for streamers to monitor market engagement and fee distributions.
- Automated Outcome Oracles: Stream video multi-modal recognition for instant event verification and automated resolution.
This project is submitted to the Colosseum Crypto World's Fair and specifically targets the Panta API Sidetrack on Superteam Earn.
| Criterion | Implementation in LiveEdge |
|---|---|
| Panta API Integration | Direct utilization of Panta's catalog, quote, transaction builder, and positions endpoints (server/src/panta/liveClient.js). |
| Technical Execution | Monorepo architecture with mathematically verified LMSR pricing curves and integer micro-unit money conservation invariants. |
| Product & UX | Live streaming interface allowing one-tap market participation beside live video with real-time SSE odds updates. |
| Originality | Blends live stream creator tools with automated LLM-generated prediction markets and opening-line prior pricing. |
| Impact Potential | Introduces audience-driven monetization for streamers without requiring audience risk capital. |
| Traction | Fully working interactive prototype with zero-setup local storage (PGlite) and end-to-end automated smoke validation. |
- GitHub: sidneycodes1
- X: @Sidney_codes
(License unassigned — refer to repository owner).