LMSR Pricing Model

Logarithmic Market Scoring Rule -- the cost function powering probability pricing across proposals.

Overview

The hook implements Hanson's Logarithmic Market Scoring Rule (LMSR) to price trades across all proposals in a quantum market. LMSR provides automatic market making with bounded loss, making it ideal for prediction markets where traditional order books may lack depth.

Cost Function

The cost function determines how much a trader pays to move a proposal's quantity from one level to another:

Cost(q) = b * ln( sum( exp(q_i / b) ) )

Where:

  • q_i is the outstanding quantity of shares for proposal i
  • b is the liquidity parameter controlling price sensitivity
  • ln and exp are natural logarithm and exponential functions

Price Formula

The instantaneous price (probability) for any proposal is derived from the softmax of all proposal quantities:

Price_i = exp(q_i / b) / sum( exp(q_j / b) )

This ensures all proposal prices sum to 1.0, forming a valid probability distribution. Buying shares of a proposal increases its price while decreasing the relative price of all other proposals.

Liquidity Parameter (b)

The parameter b controls how sensitive prices are to trades:

  • Larger b -- Prices move slowly, requiring larger trades to shift probabilities. More suitable for markets with high liquidity.
  • Smaller b -- Prices move quickly with each trade. Suitable for markets where you want rapid price discovery.

The maximum loss for the market maker is bounded by b * ln(n) where n is the number of proposals.

Implementation Details

All math uses WAD (1e18) fixed-point arithmetic to avoid floating-point precision issues in Solidity. The implementation lives in libraries/LMSR.sol and libraries/FixedPointMathLib.sol.

The custom curve is applied in beforeSwap:

  1. Hook reads the proposal's current amplitude (probability weight)
  2. Applies LMSR pricing based on all proposal amplitudes
  3. Takes the trade amount via poolManager.take()
  4. Returns toBeforeSwapDelta(specifiedDelta, unspecifiedDelta) to adjust the swap