LSAMM Algorithm Explained: The Logarithmic Scoring AMM Behind Modern Prediction Markets

Published on May 09, 202615 min read
LSAMM Algorithm Explained: The Logarithmic Scoring AMM Behind Modern Prediction Markets

What problem does LSAMM solve?

Order-book markets struggle in long-tail prediction markets. There simply are not enough simultaneous buyers and sellers to keep books deep, especially for the niche questions that prediction markets are uniquely suited to answer — things like "Will Brazil's central bank cut rates twice in Q3?" or "Will OpenAI ship GPT-6 before December?". Automated market makers (AMMs) solve this by acting as the always-on counterparty for every trade.

LSAMM (Logarithmic Scoring Automated Market Maker) is a modern descendant of Robin Hanson's LMSR. It keeps every desirable property of LMSR — bounded loss for the operator, additive subsidies, smooth pricing — and adds dynamic liquidity so the market expands as volume grows. The result is an AMM that quotes useful prices from the very first trade and still behaves rationally when daily volume reaches millions of dollars.

The cleanest mental model is this: LSAMM is softmax for prediction markets, with a temperature that scales with the size of the market.

That sentence is doing a lot of work. By the end of this article you will see exactly why it is true, what the implementation looks like, and where LSAMM beats — and loses to — its alternatives. If you are new to the broader landscape, start with our introduction to prediction markets before continuing.

A 30-second LMSR refresher

Hanson's original Logarithmic Market Scoring Rule defines a cost function:

C(q1, q2, ..., qn) = b * ln(Σ exp(qi / b))

Where qi is the number of outstanding shares of outcome i and b is a fixed liquidity parameter. The price of outcome i is the partial derivative ∂C/∂qi, which simplifies to:

p_i = exp(qi / b) / Σ exp(qj / b)

That is just a softmax over share counts. The operator's maximum loss is b * ln(n) for n outcomes, so picking b is equivalent to budgeting how much subsidy you are willing to commit to the market.

LMSR is elegant, provably bounded, and has been deployed in production for two decades. But it has one important limitation: b is fixed at market creation. Pick it too low and prices whip around on small trades. Pick it too high and you subsidise fewer trades than you would like — and worse, late participants pay nearly the same slippage as the very first trader. LSAMM fixes exactly that.

The LSAMM cost function

LSAMM is built around a single cost function:

C(q1, q2, ..., qn) = L_dynamic * (q_max / L_dynamic + ln(Σ exp((qi - q_max) / L_dynamic)))

Where:

  • qi — the effective quantity of outcome i (real shares + virtual liquidity reserve)
  • q_max — the maximum quantity across all outcomes
  • L_dynamic = α × Σ qi — liquidity that scales with total market size
  • α — the liquidity coefficient (calibrated per market)

A trader buying Δq of outcome i pays exactly C(after) − C(before). The market never quotes a negative price and never sums to a probability above 1. The shift by q_max before exponentiation is a numerical-stability trick borrowed straight from the softmax implementations in modern deep learning frameworks.

If you find the algebraic form intimidating, here is the same idea in pseudo-code:

def lsamm_cost(quantities, alpha):
    q_max = max(quantities)
    L = alpha * sum(quantities)
    if L <= 1e-12:
        return 0.0
    stabilised = [(q - q_max) / L for q in quantities]
    return L * (q_max / L + math.log(sum(math.exp(s) for s in stabilised)))

The function is monotonic, convex, and continuous. That is enough to guarantee a well-behaved price quote at every state of the market.

Why the logarithm?

The logarithm gives LSAMM two superpowers, both of which fall out of basic calculus.

Convexity protects the market from whales

Buying more shares costs progressively more, which prevents a single well-capitalised actor from cornering an outcome cheaply. The marginal cost grows with quantity, so an attacker trying to push the price from 50¢ to 90¢ pays exponentially more than the implied probability shift would suggest. This is the same property that keeps order-book markets stable when a large order eats through the book.

Numerical stability at extreme volumes

By subtracting q_max before exponentiation, you avoid exp(huge) overflow even for trillions of shares. Floating-point arithmetic in IEEE-754 starts to fail around exp(709), so without the shift, any market with quantities above ~700 would crash. With the shift, you can run a market with effective quantities in the quadrillions without overflowing. This is the same trick used in softmax for neural networks and the cross-entropy loss in PyTorch.

Marginal price equals market probability

The marginal price for outcome i is the partial derivative of the cost function. For non-maximum outcomes it simplifies beautifully:

∂C / ∂qi = exp((qi - q_max) / L_dynamic) / Σ exp((qj - q_max) / L_dynamic)

That is literally the softmax of effective quantities. Marginal prices always sum to 1 across outcomes — a clean probability distribution by construction. Every trader who buys outcome i pushes its price up and every other outcome's price down, and the system always remains a valid probability simplex.

This is the property that lets you read a prediction market price as a probability without doing any extra math. It is also why an LSAMM market is a strictly better information aggregation tool than a vig-charging sportsbook, where prices are warped by the bookmaker's risk-balancing objective. For a deeper comparison of pricing engines, see our breakdown in comparing AMM liquidity models.

Dynamic liquidity in practice

In LMSR, the liquidity parameter b is fixed at market creation. LSAMM ties liquidity to total bet quantity:

L_dynamic = α × Q_total

The result is a self-regulating market that behaves correctly across the full lifecycle of a trading question.

PhaseQ_totalPrice behaviourWhy it is good
Cold startSmallVery responsiveEarly information moves the market quickly toward truth.
MatureLargeStabilises around consensusLate traders see tighter spreads and lower slippage.
News shockSpikesSmooth re-pricingConvexity grows with size, blocking manipulators.
Resolution-dayOften peaksAsymptotically tightFinal price reflects the deepest pool of capital.

This is the difference that makes LSAMM production-ready. An LMSR market with b = 100 quotes the same slippage on the 10,000th trade as on the 1st trade. An LSAMM market with α = 0.05 behaves like an b = 100 LMSR when the market is empty and an b = 10,000 LMSR when it has aggregated $200k in volume — without any operator intervention.

Choosing the liquidity coefficient α

α is the only tunable parameter, and it determines two things at once: the subsidy budget and the slippage curve. A reasonable default range is 0.02 ≤ α ≤ 0.10. Lower values produce more responsive prices and lower subsidy budgets; higher values produce smoother prices and require more upfront capital from the operator.

A practical calibration loop:

  1. Estimate the expected daily notional traded on the market.
  2. Pick an acceptable round-trip slippage at, say, 1% of daily notional.
  3. Solve numerically for the α that delivers that slippage with Q_total equal to the typical mid-day inventory.
  4. Backtest the choice on historical price tapes from similar markets — your own, or public order books on Polymarket.

If you have no historical data, start with α = 0.05 and adjust after the first 10 markets ship.

Stability tricks the production code handles

When you actually ship LSAMM, several edge cases must be handled. Skipping them is the single biggest cause of production incidents in market-maker code.

  • Empty market (Q_total ≈ 0) → return uniform prices 1/n. Without this guard, the cost function evaluates 0/0 and you get a NaN at market creation.
  • Tiny α → guard against L_dynamic ≤ ε to avoid divide-by-zero. A market with α = 0.001 and Q_total = 1 has L_dynamic = 0.001, which can underflow before the next trade lands.
  • Extreme imbalance → normalise exponentials by q_max before summing. Otherwise the exp(qi/L) term in the cost function will overflow once qi/L exceeds ~709 in double-precision arithmetic.
  • Trade splitting → very large orders should be priced as a single integral, not as a sequence of small trades. Otherwise the slippage formula has rounding errors at the 10⁻⁶ level that accumulate over millions of trades.
  • Rounding to settlement currency → always round up the cost charged to the user, never down. A 1-cent rounding error on 100,000 trades becomes a $1,000 hole in operator P&L.

These guard rails make LSAMM a robust default for production workloads. Get them wrong and you ship an AMM that crashes the first time a $1M trade hits an empty market.

How LSAMM differs from LMSR and CPMM

LSAMM sits in a family with several other AMMs. Here is how it compares.

AspectLMSRCPMM (Uniswap-style)LSAMM
Liquidity parameterFixed bReserve ratioDynamic α × Q_total
Subsidy requiredYes (operator funds b)No (LP-funded)Small (operator-funded but smaller than LMSR)
Behaviour at scaleSlippage stays constantSlippage shrinks with TVLSlippage shrinks with volume
Probability invariantSums to 1Does not sum to 1 cleanlySums to 1
ImplementationSimplerTrivialSlightly more math
Best forLong-tail prediction marketsDeFi token swapsHigh-volume prediction markets

LMSR remains a great primer; CPMMs are the right choice when you want LP-funded liquidity and do not need a probability simplex; LSAMM is what you reach for when production traffic on a prediction market gets serious.

If you want to think about the trade-offs in more depth — including hybrid designs that combine LSAMM with an order book — see our companion piece on market microstructure for forecasting.

Worked example: a 3-outcome election market

Imagine an election with three candidates A, B, and C, and an initial seed of 1,000 virtual shares on each side. With α = 0.05:

  • Q_total = 3000, so L_dynamic = 150
  • All qi = 1000, so each price is exp(0) / (3 * exp(0)) = 1/3 ≈ 33.3%

Now suppose a trader buys 100 shares of candidate A. The new state is q = [1100, 1000, 1000], Q_total = 3100, L_dynamic = 155. The new price for A is:

p_A = exp((1100 - 1100) / 155) / (exp(0) + exp(-100/155) + exp(-100/155))
    = 1 / (1 + 2 * exp(-0.645))
    = 1 / (1 + 2 * 0.525)
    ≈ 0.488

A's price jumped from 33.3% to 48.8% on a 100-share purchase. That is a meaningful move — exactly what you want in an early-stage market where new information should be priced quickly. The same trade in a mature market with Q_total = 30,000 would move A's price by only ~1.5 percentage points, because L_dynamic would be 10x larger.

This is the LSAMM signature: responsive when small, robust when large.

Implementation patterns and pitfalls

If you are implementing LSAMM from scratch, a few hard-won lessons.

Use 128-bit fixed-point arithmetic for on-chain deployments. Solidity's native 256-bit integers are fine for cost computations, but the floating-point version of the cost function is dangerous on EVM. The Polymarket contracts and Gnosis Conditional Tokens both use fixed-point arithmetic with extensive overflow guards.

Pre-compute q_max lazily. Every trade recomputes it, but you only need to refresh q_max on the outcome being traded. Lazy updates save 30–50% of gas on busy markets.

Cache L_dynamic between consecutive trades that do not change Q_total materially. For a high-frequency market this saves another 10–20% of compute.

Snapshot before the trade. Compute C_before from a deterministic snapshot of (qi) before the user's transaction is applied, otherwise concurrent trades will produce inconsistent settlement amounts.

Test the underflow boundary. Write property-based tests that hammer the system with quantities approaching 2^256 and with single-share trades on markets containing trillions of shares. The bugs in LSAMM implementations almost always live at the extremes.

When LSAMM is the wrong choice

LSAMM is not universal. Reach for a different design when:

  • You want LP-funded liquidity. LSAMM is operator-funded. If you want users to provide liquidity in exchange for fees, look at CPMM-style designs or hybrid order books.
  • The market has only two outcomes and very deep liquidity. A central limit order book will quote tighter prices at scale, which is why Kalshi and the Iowa Electronic Markets both use order books.
  • The market resolves continuously, not at a fixed point. LSAMM assumes a single resolution event. Streaming markets — like a continuous Brier-score betting game — need an entirely different cost function.
  • The market needs to support partial redemption of contracts (e.g., scoring rules tied to mortality tables). Use a proper scoring rule directly rather than an AMM wrapped around one.

Most prediction market platforms do not hit these edges. For everything else, LSAMM is the modern default.

Frequently Asked Questions

Is LSAMM the same as LMSR?

LSAMM is a generalisation of LMSR. LMSR uses a fixed liquidity parameter b; LSAMM uses a liquidity parameter L_dynamic = α × Q_total that scales with total quantity. When the market is small, LSAMM behaves like an LMSR with a small b; when the market is large, it behaves like an LMSR with a large b. The math is otherwise identical — both reduce to a log-sum-exp cost function whose prices are a softmax over share counts.

Can LSAMM lose more than its initial subsidy?

No. Like LMSR, LSAMM has provably bounded loss for the operator. The maximum loss is L_dynamic * ln(n) at any moment, and since L_dynamic grows only with Q_total, the subsidy scales smoothly. In practice the operator's loss is offset by trading fees once volume is non-trivial, which is why several platforms ship LSAMM with a 1–2% fee on traded notional.

How do I pick the right α?

Start with α = 0.05 as a default. Increase it if traders complain about slippage on small markets; decrease it if you want sharper price discovery on cold-start markets. The most rigorous calibration is to run an A/B test on two parallel markets at α = 0.03 and α = 0.07 and measure trader satisfaction plus operator subsidy burn over a 30-day window.

Does LSAMM work with continuous outcomes?

Not directly. LSAMM is defined over a discrete set of mutually exclusive outcomes. To handle continuous outcomes (e.g., "What will the closing price of Bitcoin be on December 31?"), you can either bucket the outcome space into discrete bins and run LSAMM on the bins, or use a different mechanism like the LMSR-tree designs that handle structured outcome spaces.

How does LSAMM compare to Uniswap's CPMM?

Different goals, different math. Uniswap's x*y=k is optimised for token swaps and does not naturally produce a probability simplex — the prices do not sum to 1 across outcomes. LSAMM is optimised for prediction markets and guarantees the probability invariant by construction. You would not use Uniswap to price a binary election, and you would not use LSAMM to swap two ERC-20 tokens.

What is the connection between LSAMM and softmax in machine learning?

They are literally the same function. The LSAMM marginal price formula is the softmax of effective quantities divided by L_dynamic. In machine learning, softmax converts logits into class probabilities; in LSAMM, softmax converts share counts into outcome probabilities. The L_dynamic parameter plays the role of an inverse temperature — high L_dynamic produces flatter distributions, low L_dynamic produces sharper ones.

Is LSAMM open source?

Several implementations are open source, including the reference contracts in the Gnosis Conditional Tokens Framework and the Polymarket AMM. Most production deployments build on those primitives with custom fee tiers, KYC integrations, and resolution oracles. The math itself is public — the production hardening is where the engineering work lives.

How does LSAMM handle multi-outcome markets with very different outcome popularity?

The softmax structure handles asymmetry automatically. If outcome A has 10,000 shares and outcomes B and C have 100 each, A's price will be very close to 1 and B/C will be near 0 — but never exactly there. There is always some non-zero price on the tail outcomes, which is mathematically necessary to keep the simplex closed and economically useful because it lets contrarian traders bet against the crowd. This is one of the elegant properties LSAMM inherits from LMSR and the broader scoring rule literature.

Where to go next

You now have a working mental model of LSAMM. The natural next steps:

If you take one thing away, take this: LSAMM is softmax, but for prediction markets — and the temperature scales with the size of the market. Once that picture clicks, the rest of the math is just bookkeeping.

Written by Editorial Team
ET
Editorial TeamEditorial

We write about prediction markets, automated market makers and the math behind forecasting.

Related articles