A prediction market that pools liquidity across correlated events using a single joint-outcome AMM.
This project is a Unified Liquidity Multi-Dimensional Prediction Market that solves the critical problem of liquidity fragmentation in traditional prediction markets. Instead of running separate markets for correlated events (like "Will Khamenei be ousted?" and "Will the US strike Iran?"), this platform pools liquidity across all outcomes through a single joint-outcome AMM that prices 8 "world states" (all combinations of three Yes/No questions).
The innovation lies in treating multiple correlated prediction questions as a single coherent probability distribution. Users can still trade simple binary markets ("Event A = Yes"), but under the hood, all bets are executed as basket trades across a shared "world table" of joint outcomes. This architecture delivers three key benefits: (1) Unified liquidity pool — all correlated markets share depth, eliminating wide spreads; (2) Coherent probabilities — prices update together across related events, preventing arbitrage opportunities; (3) Rich bet types — users can bet on exact scenarios ("A=Yes, B=Yes, C=No"), partial slices ("A=Yes AND B=Yes regardless of C"), or simple marginals, all settling from the same liquidity source.
The platform leverages Liquidity-Sensitive LMSR (LS-LMSR), an upgraded market-making algorithm where the liquidity parameter grows with trading volume, allowing whale trades with less slippage as markets mature. All contracts pay $1 per share if they win — "bigger upside" comes from buying more shares at lower prices (more specific scenarios cost less but win less often). The system supports market resolution through oracles and automatic payout distribution to winning position holders.
This project integrates three HackMoney 2026 partner tracks into a cohesive full-stack prediction market platform, combining custom smart contracts, off-chain compute, and novel Web3 UX patterns.
The heart of the system is a custom Liquidity-Sensitive Logarithmic Market Scoring Rule written in pure JavaScript (server/market/lmsr.js). This implements:
8-corner softmax pricing using log-sum-exp for numerical stability Dynamic liquidity parameter b = α × Volume that grows with trading activity Basket trade execution where marginal/slice bets decompose into multi-corner trades Cost function C(q) = b × ln(Σ exp(q_i / b)) for calculating trade prices Unlike traditional AMMs, LS-LMSR maintains a coherent joint probability distribution (all 8 corner prices sum to 1.0) and automatically updates derived markets when any corner is traded.
Built with Node.js + Express (server.js), the CLOB acts as a "robot market maker" that:
Places AMM-calculated fair prices as limit orders on the book Allows users to undercut AMM orders (best price wins) Implements step-ladder liquidity (iceberg orders representing slippage) Handles JIT minting of outcome tokens when users trade against the AMM Manages position accounting in corner-space (automatic netting of offsetting positions) 3. Smart Contracts (Solidity)
Deployed on Sepolia testnet:
SwapRouter.sol (hardhat/contracts/SwapRouter.sol) — Main entry point; creates markets with 8 corner tokens using ERC1167 minimal proxies (Clones pattern) for gas efficiency OutcomeToken.sol — ERC20 tokens representing shares in each corner outcome CornerReceiver.sol — Payable forwarders that enable ENS subdomain purchases (explained below)
Partner Track Integrations Yellow Network — Gasless State Channel Trading
We integrated the Yellow Network Nitrolite SDK (@erc7824/nitrolite) to enable high-frequency betting sessions without gas fees:
Custom Hook (hooks/useYellowSession.ts) — 895-line React hook managing the full lifecycle: wallet connection, EIP-712 authentication, session key generation, WebSocket RPC messaging, and app session state.
Off-Chain Settlement — When a user opens a betting session, we establish a P2P state channel between their wallet and the CLOB server. Each bet is an off-chain signed message (no gas). Only on session close does one on-chain transaction settle the final state.
Co-Signing Pattern — The CLOB server co-signs all state updates using the SDK's createSubmitAppStateMessage and createCloseAppSessionMessage RPC methods. This implements the Nitro protocol's "app session" model where both parties must agree to balance updates.
CLOB Server Integration (server.js) — The CLOB authenticates with Yellow Network on startup, generates its own session key, and exposes POST endpoints (/api/sign) for co-signing user operations.
Hacky Detail: We use navigator.sendBeacon in a beforeunload handler to force-close sessions if the user closes their browser tab, preventing stuck channels.
ENS — Human-Readable Markets & Wallet-Native Buying
ENS provides two UX innovations:
User Profiles — We resolve vitalik.eth throughout the UI for leaderboards, trade history, and position displays using custom hooks (lib/ens/useEnsAvailable.ts).
Market Subdomains = Direct Token Purchase — This is the most novel integration:
Each market gets a parent domain (e.g., iranwar.eth) We register subdomains for each corner: iranwar-000.eth, iranwar-001.eth, ..., iranwar-111.eth Each subdomain's ENS resolver points to a CornerReceiver contract address Users can send ETH directly from Metamask to iranwar-111.eth and receive YES-YES-YES outcome tokens — no dApp UI needed Implementation:
server/market/ensListener.js polls SwapRouter for CornerPurchased events When detected, it automatically credits the buyer's CLOB session and executes a market buy components/MarketSubdomainForm.tsx lets market creators register subdomains via ENS Registrar contracts Hacky Detail: We use the ENS setAddr function to point subdomains at contract addresses, but because Metamask doesn't natively detect ERC20 mints from contract interactions, we emit events that the ENS listener picks up to bridge ENS payments into the CLOB order book.
Particularly Hacky/Notable Bits Corner-Space Position Accounting (server/market/state.js) — All positions are stored as exposure vectors across 8 corners. When a user buys a marginal (e.g., "Event A = Yes"), we decompose it into +1 shares for corners {100, 101, 110, 111}. If they later sell corner 111, it automatically cancels out through vector addition—no manual "merge/split" logic needed.
Calibration Bootstrap (server/market/api.js) — The market starts in "seeding" status where the CLOB must first fund all 8 corners with liquidity. Once all corners have sell orders, the calibrateAMM function runs once to set initial AMM prices based on order book depth. This hybrid model combines AMM pricing with CLOB execution.
Dockerized Deployment — The entire stack (frontend + CLOB server + hardhat node) runs in Docker Compose (docker-compose.yml) for easy setup. The CLOB server's private key is mounted via env var, and it auto-deploys contracts on first run.
Session Liquidation — On Yellow session close, we automatically liquidate all user shares back to USD using the current AMM mid-price (hooks/useYellowSession.ts:722-736), ensuring users can always exit to cash.

