Real-time micro-prediction markets on yellow network with LMSR + P2P and decentralized liquidity
PulsePlay is a decentralized micro-betting platform that enables real-time wagering on individual sports plays — whether the next pitch is a ball or strike, whether a penalty will score, whether a free throw goes in. These micro-markets last 5-15 seconds, making them impossible on traditional blockchains where confirmation times exceed the market's entire lifespan.
PulsePlay solves this by using Yellow Network's state channel infrastructure to make every bet instant and gasless. Users connect their wallet, sign one authentication message, and can then place unlimited bets with no additional signatures or gas fees. The only moment a user relinquishes custody is the exact bet amount, locked in a state channel between them and the market maker.
Two Market-Making Models:
Liquidity Pool: A third category of participant — Liquidity Providers — deposit capital that backs the LMSR market maker. The pool size directly controls the LMSR's b-parameter (price sensitivity). LPs earn transaction fees from every bet and can withdraw when no markets are active. This introduces a genuinely decentralized market-making model where facilitators earn from volume, not from betting against users.
Session Data Auditability: Every app session carries a 3-version data lifecycle (V1: bet intent, V2: LMSR confirmation with exact shares/odds/fees, V3: resolution with payout/profit). This creates a complete, cryptographically verifiable audit trail for every bet, stored in Yellow Network.
Multi-Sport Support: While the demo focuses on baseball, the platform supports any sport with configurable outcomes per category (binary for pitching, N-outcome for other play types). Games, teams, and categories are fully managed through an admin interface.
Developer Simulator: A full interactive terminal TUI (built with Ink/React) that manages wallet pools, automates multi-user betting simulations, and provides a bird's-eye view of every app session, state transition, and settlement in real-time.
PulsePlay is a TypeScript monorepo (pnpm workspaces) with four integrated packages:
Hub (Backend — Fastify + SQLite/Drizzle ORM): The Hub is the central coordinator. The LMSR engine is implemented as pure stateless functions using the log-sum-exp trick for numerical stability. The Market Manager handles the PENDING→OPEN→CLOSED→RESOLVED state machine. The Position Tracker is backed by SQLite with Drizzle ORM, including a full settlement audit trail. The Clearnode Client uses a lazy-connect pattern — it auto-connects on first RPC call and self-heals after disconnections, with no upfront dependency. The P2P Order Book uses SQLite's single-writer property for atomic matching (no race conditions). Resolution processes losers before winners so the MM has funds available for winner payouts.
Frontend (Next.js 14 + Tailwind CSS): The frontend handles both Clearnode and Hub WebSocket connections simultaneously. The ClearnodeProvider implements a 3-step EIP-712 authentication flow, stores session keys, and includes a 30-second keepalive heartbeat to prevent idle disconnects. It uses wagmi for MetaMask integration with a private-key fallback for testing. Every bet creates a real Yellow Network app session via the Clearnode SDK, and the Hub is notified with the session ID. The UI is a Polymarket/Kalshi-inspired design with real-time WebSocket odds updates, per-market subscriptions, and a tabbed LMSR/Order Book interface for binary markets.
Simulator (Ink + React terminal TUI): The Simulator is a fullscreen interactive developer tool with vim-style command bar, scrollable panels, and keyboard navigation. It manages a ClearnodePool that handles wallet creation, authentication, and balance tracking for up to 20+ concurrent simulated users. The SimulationEngine generates randomized bets with configurable bias, timing, and mode (LMSR/P2P/mixed). Every WebSocket message is parsed and displayed in real-time with color-coded event logs. Developers can inspect individual app sessions with accordion-expanded session data showing V1/V2/V3 state transitions.
Key Technical Decisions:
Testing: 1,213+ tests across all packages (hub: 612, frontend: 436, simulator: 165) including unit, integration, and live Clearnode tests. TypeScript strict mode throughout.
Technologies: TypeScript, pnpm workspaces, Fastify, Next.js 14, Tailwind CSS, SQLite + Drizzle ORM, Jest, Ink (React for CLI), wagmi/viem, Yellow Network Clearnode SDK (@erc7824/nitrolite), WebSocket (ws)

