Prediction markets need a way to price contracts and provide liquidity without waiting for a counterparty. The Logarithmic Market Scoring Rule (LMSR) solves this by acting as an automated market maker that adjusts prices based on trades. Understanding LMSR helps you build efficient prediction markets that balance liquidity depth with bounded risk.
The Hanson 2003 paper, simplified
Robin Hanson introduced LMSR in 2003 to create a self-funding market maker. The core idea is simple: the market maintains a cost function that tracks total exposure, and traders pay the difference in cost when they change their position. This means the market always has liquidity, and prices move smoothly as information arrives.
The cost function uses a logarithm to ensure prices stay between zero and one, naturally representing probabilities. When you buy shares predicting an outcome, you increase the market’s exposure to that outcome, and the cost function rises. The liquidity parameter controls how quickly prices move in response to trades.
Cost function and liquidity parameter
The liquidity parameter (often called beta or b) determines how much money moves prices. A higher parameter means the market absorbs large trades with smaller price changes, providing deeper liquidity. A lower parameter makes prices more responsive but increases slippage on big orders. Most implementations set this parameter based on expected trading volume and desired market depth.
LMSR vs AMM tradeoffs
Constant product automated market makers (like Uniswap’s x times y equals k formula) work well for token swaps but struggle with prediction markets. LMSR offers bounded loss for the market maker, meaning the maximum subsidy is known upfront. This predictability matters when you’re seeding markets with capital.
However, LMSR requires more complex math than simple AMMs. The logarithmic calculations demand careful implementation to avoid numerical errors. Gas costs on blockchains can also be higher due to exponential operations in the pricing formula.
Solidity implementation pattern
Smart contract developers typically use fixed-point arithmetic libraries to handle LMSR calculations safely. You need to compute exponentials and logarithms without floating-point numbers, which Solidity lacks. Libraries like ABDKMath64x64 provide the necessary precision for prediction market contracts.
The basic pattern involves storing share quantities for each outcome, calculating the cost function before and after a trade, then charging the trader the difference. You must also handle edge cases where probabilities approach zero or one to prevent numerical overflow.
Capital efficiency and worst-case loss
LMSR’s worst-case loss equals the liquidity parameter times the natural log of the number of outcomes. For a binary market with a liquidity parameter of 100, the maximum subsidy is about 69 units. This predictable loss bound lets market operators budget liquidity precisely.
Capital efficiency improves when you set the liquidity parameter based on expected volume. Too high wastes capital on unused depth, while too low creates excessive slippage that discourages trading. Many platforms adjust this parameter dynamically as markets mature.