Perpetual market for predicting future distributions of arbitrary continuous variables.
Perpetual Share Distribution Prediction Market 🚩 The Problem Traditional prediction markets are designed around discrete events: Will candidate X win?, Will GDP grow above 2%? etc. While useful, they can't naturally represent continuous phenomena such as asset shares in an index, usage of a protocol over time, or the distribution of attention across competing platforms.
Real-world systems are often about relative change within a bounded total:
How the market share of an asset changes
How a protocol metric grows relative to others
How probability mass shifts across competing outcomes
These are distributions over continuous variables, and the core insight is that predicting those distributions is a richer and more expressive forecasting task.
💡 The Idea This project implements a perpetual, on-chain prediction market where users can trade on their beliefs about the future share (or weight) of a continuous metric within a normalized distribution.
The key features are:
Continuous targets: The market doesn’t predict single-point outcomes but entire distributions over multiple objects (e.g., the future proportion of asset A in a portfolio).
Perpetual structure: The market pays out continuously over time, using a geometric decay (parameterized by gamma) to weight near-term predictions more heavily but still reward longer-term accuracy.
AMM-based pricing: Inspired by LMSR-style cost functions, the system uses a liquidity-sensitive automated market maker to ensure price updates reflect aggregate belief shifts.
Normalized payouts: Users are rewarded proportionally to how the share of their predicted variable evolves in the reference distribution (e.g., if asset A grows from 0.2 to 0.4, the user is rewarded for that change).
🔧 Mechanics Reference metric: An external oracle supplies periodic updates of normalized continuous variables (e.g., prices, usage stats). These are used to compute the evolving target distribution.
Payouts: Rather than a single final payout, the system performs integrated or streaming payouts based on how the predicted distribution matches the realized one over time. Think of it as getting paid the area under the curve of your prediction accuracy.
Lazily-evaluated accounting: To keep gas costs manageable, payouts are computed lazily—on user interactions—by tracking each participant's last checkpoint time and adjusting share value accordingly.
Anti-manipulation: The design assumes data volatility control (oracle quality) and makes predictions backward-looking—i.e., payouts are based on finalized past data, reducing incentive to manipulate incoming data.
📈 Example Use Cases DeFi indexes: Predict which token in a basket will increase its share of total market cap over the next month.
Social media metrics: Forecast relative attention share across trending topics or influencers.
Protocol metrics: Predict how usage, gas share, or adoption shifts across L2 chains.
🧮 Theoretical Foundation Builds on liquidity-sensitive LMSR ideas (see CMU paper)
Connects to recent work on unresolvable prediction markets where ground-truth resolution is continuous or probabilistic (arXiv:2306.04305)
📋 Status and Next Steps Simulation of payout mechanics to validate that the proposed effective LMSR and streaming payout logic produce rational, incentive-aligned behaviors.
On-chain prototype, focusing on lazy accounting, use of exp/log, and identifying optimal chains with low gas for LMSR ops.
Oracle integration with safeguards to avoid gaming or latency effects.
User design: UI/UX to show shifting distributions and incentive trajectories over time.
Stop-loss & reinvestment mechanics: Exploring optional features to let users automate defensive or compounding strategies.
🛠 How It’s Made – Under the Hood of the Perpetual Distribution Prediction Market This project brings together precise financial math, robust oracle infrastructure, and perpetual DeFi mechanics to build a prediction market where users forecast how continuous variables evolve relative to each other—not just binary outcomes.
⚙️ Smart Contract Layer Language: Contracts written in Solidity, using Foundry for development, testing, and deployment.
Market Mechanism:
Implemented a custom AMM based on a generalized LMSR to price shares over a normalized distribution of continuous variables.
The LMSR-based mechanism supports fractional share predictions, useful for relative behavior forecasting (e.g., predicting which asset gains market share).
Streaming (geometric decay) payouts over time based on evolving reference distributions.
Math Library:
All math operations are powered by PRBMath SD59x18, enabling high-precision fixed-point arithmetic with signed decimals—perfect for LMSR’s exp, log, and ratio math in an on-chain context.
Replaces older floating-point or 64x64 libraries for improved accuracy and gas predictability.
Payout Architecture:
Lazily evaluated payouts: Instead of pushing rewards continuously, users have a lastCheckpoint state. When interacting (buy, sell, claim), payouts are computed as the integral of prediction accuracy weighted by gamma decay.
Reduces gas, makes perpetual markets viable, and separates prediction lifecycle from oracle update cadence.
🔌 Oracle Layer (Dual Setup) To enable predictions on any real-world continuous metric, we implemented a dual-oracle strategy:
Enabled high-resolution, tamper-resistant, normalized input for target distribution construction.
Offered complete oracle freedom: almost any metric can become a prediction market.
Hedera’s timestamping and data availability ensured strong finality.
Ideal for adjustable and lightweight deployments—especially for experimentation with different market targets or batch update logic.
🌐 Frontend (Built with Svelte) UI Framework: Svelte for minimal reactivity overhead and fast build iterations.
Features:
Live distribution plots (predicted vs. actual shares)
Trade panel for buying/selling predictions
Streaming rewards view with real-time gamma sliders
Integrated Ethers.js for wallet and on-chain interaction
🧪 Simulation & Modeling Before deploying contracts, we built an off-chain simulation suite using:
Python + Jupyter, with NumPy/Matplotlib to:
Simulate agent strategies under different oracle schedules
Analyze long-run behavior of gamma-weighted streaming payouts
Validate that predictions align with theoretical reward curves under noise
This step confirmed that normalized payout mechanics converge to rational expectations and that lazy evaluation stays consistent with real-time oracle input.
🧠 Notable Engineering Hacks Gamma-decay + Lazy payout trick: Gas-efficient integration of prediction accuracy over time without needing to trigger global state updates every block.
Oracle-agnostic modularity: Designed so that any continuous metric can be transformed into a normalized distribution and injected via either oracle pathway.
PRBMath as math backbone: Critical for enabling accurate exponential/log math under constrained gas without sacrificing correctness.