Non-binary outcome markets, also known as scalar markets or multiple-choice markets, allow users to bet on events with more than two possible results. Unlike a simple yes/no market, these markets can resolve to a range of values, such as the final score of a game, the percentage of votes a candidate receives, or the exact price of an asset at a future time. Designing a protocol for this requires a robust mechanism for liquidity provision, price discovery, and dispute resolution that can handle a spectrum of potential outcomes. The core challenge is creating a system that is both capital-efficient for liquidity providers and intuitive for traders.
How to Design a Protocol for Non-Binary Outcome Markets
How to Design a Protocol for Non-Binary Outcome Markets
This guide explains the core concepts and technical architecture for building a decentralized prediction market protocol that supports non-binary outcomes.
The foundation of a non-binary market is its outcome space. This is typically defined as a set of discrete, mutually exclusive outcomes or a continuous range. For a discrete market (e.g., "Which team will win the World Cup?"), the protocol must mint a unique token for each possible team. For a continuous scalar market (e.g., "What will ETH's price be on December 31?"), the range is divided into intervals or 'bins,' each representing a token. A common approach is to use a liquidity pool based on a constant product market maker (CPMM) or logarithmic market scoring rule (LMSR) adapted for multiple assets, where the price of each outcome token reflects its perceived probability.
A critical design choice is the liquidity mechanism. A simple CPMM for n outcomes would require liquidity for n*(n-1)/2 trading pairs, which is inefficient. Advanced designs like LMSR-based automated market makers (AMMs) or liquidity-sensitive LMSR (LS-LMSR) create a single, combined liquidity pool for all outcomes. In an LS-LMSR, the cost function C(q) = b * log(exp(q1/b) + exp(q2/b) + ... + exp(qn/b)) determines prices, where q is the vector of outstanding shares for each outcome and b is a liquidity parameter. This allows traders to buy shares in any outcome directly from the pool, with prices updating algorithmically based on the remaining inventory.
The resolution and settlement process must be trust-minimized and resistant to manipulation. Many protocols use a dispute resolution system like Kleros or UMA's Optimistic Oracle to determine the correct outcome. After a predefined event end time, an initial resolution can be proposed. This enters a challenge period where users can stake collateral to dispute the result, triggering a decentralized arbitration process. Once finalized, the protocol automatically redeems each outcome token: tokens for the winning outcome are worth 1 unit of collateral (e.g., 1 DAI), while all other tokens become worthless. This design ensures payouts are accurate and enforceable via smart contracts.
For developers, implementing this requires careful smart contract architecture. A typical system has a MarketFactory contract to deploy new markets, a Market contract holding liquidity and state for a specific event, and an Oracle or Resolution module. The Market contract's core function is a trade method that accepts collateral, updates the internal state vector q, and mints/burns outcome tokens for the user. Below is a simplified code snippet for a trade function in a discrete market using a constant product invariant for two outcomes, demonstrating the state update logic.
solidityfunction buyTokens(uint outcomeIndex, uint collateralAmount) external { require(outcomeIndex < numOutcomes, "Invalid outcome"); // Calculate token amount based on CPMM invariant: x * y = k uint newReserve = reserves[outcomeIndex] + collateralAmount; uint tokenAmount = (k / newReserve) - totalSupply[outcomeIndex]; // Update reserves and mint tokens reserves[outcomeIndex] = newReserve; _mint(msg.sender, outcomeIndex, tokenAmount); }
Successful non-binary market protocols like Polymarket and PlotX demonstrate the real-world application of these principles. Key considerations for protocol designers include minimizing gas costs for frequent trades, designing incentive mechanisms for liquidity providers (e.g., trading fees), and ensuring scalability to support numerous concurrent markets. The end goal is a system where users can gain exposure to nuanced real-world events, providing a powerful tool for hedging, speculation, and collective forecasting, all secured by decentralized blockchain infrastructure.
Prerequisites and Core Assumptions
Before designing a protocol for non-binary outcome markets, you must understand the core concepts and technical requirements. This section outlines the foundational knowledge and assumptions necessary for building a robust, decentralized prediction platform.
Non-binary outcome markets, also known as categorical or scalar markets, allow users to speculate on events with more than two possible results. Unlike a simple yes/no prediction, these markets can represent multi-choice elections, sports scores, or token price ranges. The core challenge is designing a bonding curve or automated market maker (AMM) that can efficiently price and trade multiple, mutually exclusive outcomes. A successful design must handle liquidity fragmentation, ensure proper incentive alignment, and resolve outcomes accurately using decentralized oracles like Chainlink or UMA.
Key prerequisites include a strong grasp of smart contract development on EVM-compatible chains (Ethereum, Arbitrum, Polygon) or alternatives like Solana. You should be familiar with Solidity or Rust, the ERC-20 token standard for representing outcome shares, and the security patterns for handling user funds. Understanding existing designs is crucial: study conditional tokens (as used by Polymarket), liquidity pool-based AMMs (like those in PlotX), or order book models. Each architecture makes different trade-offs between capital efficiency, complexity, and user experience.
The primary technical assumption is the availability of a reliable, cryptoeconomically secure oracle. The protocol cannot determine real-world outcomes on-chain; it must depend on an external data feed. Your design must include a robust resolution mechanism that specifies the oracle source, challenge periods, and fallback procedures. Furthermore, assume participants are economically rational and may attempt to manipulate liquidity or oracle reporting. Incorporate safeguards like liquidity provider incentives, gradual resolution phases, and dispute resolution systems to mitigate these risks.
From a game theory perspective, assume the market's purpose is to aggregate dispersed information into a price signal. The protocol's rules must incentivize truthful participation. This involves designing a proper scoring rule (e.g., a logarithmic or quadratic scoring rule) for market makers and ensuring the liquidity mechanism does not create predictable arbitrage losses for liquidity providers. The choice between a continuous market (always tradable) and a parimutuel system (settled at closing) will define your core economic model and user flow.
Finally, consider the user experience and regulatory assumptions. Design for clear market creation interfaces, transparent fee structures (e.g., 1-2% on trades), and composability with other DeFi primitives. Be aware that prediction markets exist in a complex legal landscape; a decentralized, permissionless design that uses governance tokens for curation can help mitigate regulatory risk. Your protocol should be built with upgradeability in mind, using proxy patterns or a robust DAO, to adapt to future insights and challenges.
Data Structures for Multiple Outcome Shares
Designing a prediction market for events with more than two possible outcomes requires specialized data structures to manage liquidity, pricing, and settlement efficiently.
A non-binary outcome market allows users to bet on events with multiple discrete results, such as "Which candidate will win the election?" or "What will the final score be?". Unlike a simple yes/no market, the protocol must track a set of mutually exclusive and collectively exhaustive outcomes. The core data structure is an array or mapping that represents each possible outcome as a distinct share token. For example, a market on a football match with three outcomes (Team A Win, Draw, Team B Win) would mint three separate ERC-20 tokens, each representing a claim on the collateral pool if that specific outcome occurs.
The pricing mechanism for these shares is typically based on an automated market maker (AMM) curve, most commonly a constant product market maker (CPMM) adapted for multiple assets. Instead of a single liquidity pool for a token pair, you create a pool containing collateral (e.g., USDC) and all outcome share tokens. The invariant might be k = (reserve_collateral) * (reserve_share_1) * (reserve_share_2) * ... * (reserve_share_n). When a user buys shares for Outcome A, they deposit collateral, the protocol mints new Outcome A shares for them, and the reserve of Outcome A shares in the pool decreases, increasing its price according to the curve.
Settlement is a critical function. When the real-world event resolves, the protocol must redeem the winning shares. A trusted oracle (e.g., Chainlink, UMA) or a decentralized dispute system submits the winning outcome index. The contract then allows holders of the winning share token to redeem each token for 1 unit of collateral. All other outcome share tokens become worthless. Efficient settlement requires a state flag (e.g., MarketState { Open, Resolved }) and a function to lock the market and execute the payout batch.
From a smart contract perspective, a basic struct for a market might look like this in Solidity:
soliditystruct MultiOutcomeMarket { address collateralToken; address[] shareTokens; // Array of ERC20 tokens, one per outcome uint256[] reserves; // Collateral reserve followed by reserves for each share uint256 resolutionTimestamp; int256 resolvedOutcome; // -1 for unresolved, else index of winning outcome uint256 k; // Constant product invariant }
The buyShares function would adjust the relevant reserves and mint tokens, enforcing the k invariant.
Key design considerations include liquidity fragmentation (capital is split across many outcomes, potentially leading to low depth), oracle security (the integrity of the entire market depends on a correct resolution), and gas efficiency (looping over arrays of outcomes can be expensive). Protocols like Polymarket and Augur v2 implement variations of these structures, often using batch operations and bonding curves optimized for categorical markets.
To optimize, consider using a liquidity-sensitive AMM like Logit Market Scoring Rule (LMSR) for better liquidity provision in sparse markets, or implementing liquidity mining incentives for less popular outcomes. Always include a market creator role to initialize the outcome set and seed initial liquidity, and design a clear fee structure (e.g., a percentage on trades) to incentivize liquidity providers. The goal is to create a system where probabilities are accurately reflected in share prices, providing a useful forecasting tool and a liquid trading environment for all possible outcomes.
AMM Designs for Categorical and Scalar Markets
Designing Automated Market Makers (AMMs) for markets with more than two outcomes requires specialized mechanisms to manage liquidity and pricing. This guide covers the core concepts and practical implementations for categorical (multiple discrete outcomes) and scalar (continuous outcome) prediction markets.
Constant Product AMM for Scalar Ranges
For scalar markets (e.g., "What will the temperature be?"), a Constant Product curve can be adapted to price a continuous range. Instead of trading token pairs, the AMM holds collateral and mints a continuous range of outcome tokens.
- Design: The bonding curve defines a price for every point on a numerical interval.
- Implementation: Requires integrating over the price curve to calculate token payouts, which can be gas-intensive.
- Example: This model is used in UMA's Range Tokens for financial indices.
Combinatorial Markets & Partitioning
Markets with interdependent outcomes (e.g., "Team A wins AND Player X scores") require combinatorial designs. The solution is to partition the outcome space into atomic states.
- Atomic States: Every possible combination of outcomes is represented as a unique token.
- Challenge: The number of states grows exponentially (
2^nfor binary events). - Optimization: Use conditional token frameworks (like those from UMA or Gnosis) to mint tokens only for relevant combinations, reducing complexity.
Dynamic AMMs with Liquidity Mining
Static liquidity parameters can lead to high slippage. Dynamic AMMs adjust the liquidity sensitivity (b parameter in LMSR) based on market activity and volatility.
- Mechanism: Use an oracle or volume-based formula to increase
bduring high volatility, reducing slippage. - Incentives: Pair with liquidity mining rewards to bootstrap deep liquidity in nascent markets.
- Benefit: Creates more resilient markets that can handle large trades without excessive price impact.
Security Considerations for Non-Binary AMMs
Complex AMM designs introduce unique attack vectors.
- Oracle Manipulation: Scalar and categorical settlements are oracle-dependent. Use UMA's Optimistic Oracle or Chainlink Data Feeds for robust resolution.
- Liquidity Attacks: Thin liquidity across many outcomes can be exploited for information leakage or to manipulate prices before resolution.
- Mitigation: Implement gradual resolution mechanisms and liquidity requirements to prevent last-minute attacks.
Implementation with Solidity and Foundry
A practical guide to building a categorical AMM contract.
- Core Contract: Implement an LMSR cost function with a
buy()andsell()function for outcome shares. - Testing: Use Foundry's fuzzing to test edge cases in pricing calculations.
- Gas Optimization: Pre-compute and store expensive
exp()operations where possible, or use approximations like the ABDKMath64x64 library. - Reference Code: Study open-source implementations from Polymarket or Omen on GitHub.
Comparison of Non-Binary Market Types
Key design trade-offs for different market structures beyond simple yes/no outcomes.
| Feature | Scalar Markets | Categorical Markets | Combinatorial Markets |
|---|---|---|---|
Outcome Resolution | Single numeric value | One of N discrete options | Multiple correlated outcomes |
Oracle Complexity | Medium (single feed) | Low (discrete selection) | High (multiple data points) |
Liquidity Fragmentation | Low (single market) | High (N markets) | Very High (exponential markets) |
Use Case Example | ETH price at date X | Election winner | Sports parlay or portfolio performance |
Settlement Gas Cost | ~80k gas | ~120k gas |
|
Trading Interface Complexity | Simple slider/range | N option buttons | Complex matrix UI |
Common Implementation | UMA, Gnosis Conditional Tokens | Polymarket, Augur v2 | Custom, research-stage protocols |
How to Design a Protocol for Non-Binary Outcome Markets
A guide to designing smart contract logic for markets with multiple or continuous outcomes, moving beyond simple yes/no predictions.
Non-binary outcome markets allow participants to speculate on events with more than two possible results, such as election results, sports tournament winners, or continuous price ranges. Unlike binary markets that settle to 0 (NO) or 1 (YES), these require a more sophisticated payout function to distribute the collateral pool fairly among winning shares. The core design challenge is creating a settlement mechanism that is deterministic, resistant to manipulation, and can handle a variable number of valid outcomes. Common implementations include scalar markets for numerical ranges and categorical markets for discrete options.
The settlement process requires a trusted oracle or data source to report the final outcome. For a categorical market with options A, B, and C, the oracle must report the index of the winning option (e.g., 1 for option B). The smart contract's settleMarket function uses this input to calculate payouts. All collateral locked in losing shares is forfeited and redistributed to holders of the winning share type, proportional to their stake. A key security consideration is ensuring the oracle is decentralized or uses a delay to prevent last-minute manipulation attempts before resolution.
Implementing a scalar market for a continuous outcome, like "What will the ETH price be on date X?", involves defining a payout curve. A simple linear model can be used: if the outcome is O, a share minted for prediction P pays out collateral * (1 - |O - P| / range), with payouts capped at zero. More complex logarithmic or polynomial curves can be designed for different risk profiles. All calculations must be performed using fixed-point arithmetic to avoid rounding errors, as Solidity does not natively support decimals.
Here is a simplified code snippet for settling a categorical market, assuming an oracle provides the winningOutcomeIndex:
solidityfunction settleMarket(uint256 winningOutcomeIndex) external onlyOracle { require(!settled, "Market already settled"); settled = true; uint256 totalWinningShares = outcomeShares[winningOutcomeIndex]; require(totalWinningShares > 0, "No winning shares"); uint256 totalCollateral = totalShares * SHARE_PRICE; uint256 payoutPerShare = totalCollateral / totalWinningShares; // Logic to allow winners to claim payoutPerShare for each share they burn }
This function calculates the value of each winning share based on the total collateral and the number of winning shares minted.
Designers must also plan for invalid outcome scenarios, such as a cancelled event or oracle failure. A common solution is to implement a fallback resolution where the market settles to a predefined default (e.g., split collateral equally among all participants) or enters a dispute period. Integrating with a decentralized oracle network like Chainlink, which uses multiple nodes, increases reliability. The choice of resolution source is a critical trust assumption and should be transparent to users before they deposit funds.
Finally, consider the user experience for trading before settlement. An automated market maker (AMM) curve, like a logarithmic market scoring rule (LMSR), can provide continuous liquidity for all outcome shares. This allows traders to exit positions early at a price reflecting the market's current probability estimate. The final settlement payout logic must be compatible with the chosen AMM's internal accounting to ensure a smooth transition from a liquid trading market to a finalized state where users claim their winnings.
Key Implementation Considerations
Building a non-binary outcome market requires careful architectural decisions. These are the core technical components you need to design.
Security & Economic Attacks
Non-binary markets introduce unique attack vectors. Your protocol must be resilient against:
- Oracle manipulation attacks – the incentive to corrupt the data source is higher with granular outcomes.
- Liquidity-based attacks – manipulating the market price to influence the perceived likelihood of an outcome.
- Settlement griefing – users may attempt to delay or dispute resolution to freeze funds.
- Parameter exploitation – fine-tuning the payout curve or resolution granularity can be gamed. Extensive simulation and formal verification are recommended.
Frequently Asked Questions
Common questions and technical clarifications for developers building prediction markets, insurance protocols, and other conditional logic systems on-chain.
A non-binary outcome market allows for more than two possible resolution states, unlike a simple binary (yes/no) market. This is essential for modeling complex real-world events.
Key Differences:
- Resolution Granularity: A binary market resolves to
0(NO) or1(YES). A non-binary market resolves to a range of values (e.g.,0toN) or a specific outcome from a set (e.g.,"Team A","Team B","Draw"). - Use Cases: Non-binary markets are used for multi-winner predictions (e.g., election results), scalar outcomes (e.g., final score of a game), or categorical events (e.g., which DeFi protocol will be hacked next).
- Implementation Complexity: Non-binary designs require more sophisticated oracle integration and settlement logic, often using a resolution manager contract to map oracle data to the correct outcome index.
Resources and Further Reading
Primary papers, protocols, and tooling references for designing and implementing non-binary outcome markets, including categorical, scalar, and multi-dimensional designs.
Conclusion and Next Steps
This guide has outlined the core architecture for non-binary outcome markets. The next step is to implement and test your design.
Designing a protocol for non-binary outcome markets requires careful consideration of oracle integration, liquidity mechanisms, and dispute resolution. The core challenge is accurately mapping real-world, continuous outcomes—like election vote shares or commodity price ranges—onto a discrete set of tradable contracts. A robust design uses a bonding curve or automated market maker (AMM) to provide liquidity for all possible outcomes, ensuring users can always enter and exit positions. The settlement process must be trust-minimized, relying on a decentralized oracle like Chainlink Functions or a custom optimistic oracle to resolve the final outcome.
For implementation, start with a minimal viable product (MVP) on a testnet. Use a framework like Foundry or Hardhat for development and testing. A basic smart contract structure might include: a MarketFactory to deploy new markets, a ConditionalToken contract (ERC-1155) representing outcome shares, and a LiquidityPool implementing a constant product AMM. Critical functions to implement are createMarket(bytes32 questionId, string[] outcomes), mintShares(address recipient, uint256 outcomeIndex), and resolveMarket(uint256 outcomeIndex, bytes calldata oracleData). Thoroughly test oracle callback logic and edge cases in settlement.
Security is paramount. Conduct audits on the oracle integration and funds escrow mechanisms. Use formal verification tools like Certora for critical state transitions. Implement circuit breakers and timelocks for administrative functions. For user protection, design clear frontends that visually explain the probability distribution of outcomes and potential returns. Transparency in fees—including protocol fees, liquidity provider rewards, and oracle gas costs—builds trust. Consider integrating with identity or attestation protocols for markets requiring participant KYC.
The next evolution for these markets is composability. Your protocol's outcome tokens can become primitive for more complex DeFi derivatives. For example, a prediction on "ETH price between $3,000-$3,500" could collateralize a loan or be used in an options strategy. Explore integrating with debt markets like Aave (for lending outcome shares) or index protocols like Set Protocol (to create baskets of predictions). This transforms prediction markets from isolated betting venues into a foundational layer for real-world data-driven finance.
To continue learning, study live implementations such as Polymarket's conditional token framework or UMA's optimistic oracle design patterns. Engage with the developer communities on Discord and forum posts for these projects. Experiment by forking their repositories and modifying parameters. The field of non-binary markets is rapidly advancing; contributing to open-source designs or publishing your audit findings are valuable next steps for both personal growth and ecosystem development.