PulsePlay

Real-time micro-prediction markets on yellow network with LMSR + P2P and decentralized liquidity

PulsePlay

Created At

HackMoney 2026

Winner of

ETHGlobal

ETHGlobal - 🏆 HackMoney 2026 Finalist

Project Description

What it does

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:

  • LMSR (Logarithmic Market Scoring Rule): An automated market maker that guarantees liquidity at all times. Odds adjust dynamically based on demand. Anyone can provide liquidity to the LMSR pool and earn transaction fees without taking directional risk.
  • P2P Central Limit Order Book (CLOB): Users post limit orders specifying their maximum cost per share. When complementary orders on opposite outcomes sum to ≥$1.00, the matching engine pairs them with price improvement. The market maker acts as escrow via app sessions but takes zero directional risk.

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.

How it's Made

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:

  • App sessions use a [0, 100] quorum weight split (bettor: 0, MM: 100), meaning only the Hub can update or close sessions — the user's funds are locked but can't be stolen
  • Session data is encoded as JSON strings in the app session's data field, creating an on-protocol audit trail
  • The faucet module implements retry with exponential backoff + global request serialization to handle sandbox rate limits
  • WebSocket state synchronization uses a message queue pattern (ref + version counter) to prevent React state batching from dropping messages
  • LMSR b-parameter auto-scales with pool value (b = poolValue Ă— sensitivityFactor), so more liquidity = more stable odds
  • Transaction fees are configurable at the admin level and properly split through V2 allocations and V3 resolution

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)

background image mobile

Join the mailing list

Get the latest news and updates

PulsePlay | ETHGlobal