Skip to main content

AMM Trading (LMSR)

Markets configured with the LMSR (Logarithmic Market Scoring Rule) automated market maker allow trades to execute directly against the AMM, with no counterparty required. The AMM always provides a price, making it ideal for markets with lower liquidity.

How LMSR Works​

The LMSR AMM uses a cost function to determine prices:

C(q) = b * ln(sum of e^(q_i / b) for each outcome i)

Where:

  • q_i is the number of outstanding shares for outcome i (YES or NO).
  • b is the liquidity parameter that controls price sensitivity. A larger b means prices move less per trade.

The price of a token is the partial derivative of the cost function with respect to that outcome's share quantity. As more YES tokens are bought, the YES price increases and the NO price decreases, always summing to approximately 10000 (100%).

Price Impact​

Unlike orderbook markets where you can set a fixed price, AMM trades experience price impact. The more you buy, the higher the average price you pay. This is an inherent property of the LMSR formula -- each incremental share costs slightly more than the last.

Use the preview endpoint (described below) to estimate the cost and effective price before committing to a trade.

Trading Endpoint​

POST /api/v1/lmsr/trade
Authorization: Bearer <token>
Content-Type: application/json

Request Body​

FieldTypeRequiredDescription
market_idintegerYesThe LMSR market to trade on.
sidestringYesOne of: "buy_yes", "sell_yes", "buy_no", "sell_no".
amount_typestringYes"spend" (specify budget) or "shares" (specify share count).
amountintegerYesAmount in cents. If amount_type is "spend", this is the budget. If "shares", this is the number of share-cents.
use_bonusbooleanNoIf true, deducts from bonus balance. Defaults to false.

Side Values​

SideAction
buy_yesBuy YES tokens (long position on the event happening)
sell_yesSell YES tokens you hold
buy_noBuy NO tokens (long position on the event not happening)
sell_noSell NO tokens you hold

Example: Buy YES Tokens​

curl -X POST https://api.intotes.com/api/v1/lmsr/trade \
-H "Authorization: Bearer eyJhbG..." \
-H "Content-Type: application/json" \
-d '{
"market_id": 100,
"side": "buy_yes",
"amount_type": "spend",
"amount": 50000
}'

This spends up to 50000 cents to buy YES tokens at the current AMM price (including price impact and fees).

Preview Endpoint​

Before executing a trade, use the preview endpoint to see the estimated cost, shares received, and effective price:

GET /api/v1/lmsr/preview
Authorization: Bearer <token>

Query Parameters​

ParameterTypeRequiredDescription
market_idintegerYesThe market to preview.
sidestringYesSame values as the trade endpoint.
amount_typestringYes"spend" or "shares".
amountintegerYesAmount in cents.

Example: Preview a Trade​

curl "https://api.intotes.com/api/v1/lmsr/preview?\
market_id=100&\
side=buy_yes&\
amount_type=spend&\
amount=50000" \
-H "Authorization: Bearer eyJhbG..."

The response includes the estimated number of shares you would receive, the total cost, the effective average price per share, and the fee breakdown. Always preview before large trades to understand the price impact.

Bonus Balance Restriction​

When use_bonus is set to true, there is a time-based restriction for sport events: bonus balance cannot be used within 2 hours of a sport match start time. This prevents bonus abuse on events with near-certain outcomes. Attempts to use bonus balance during this window will be rejected.

Fees​

The same fee percentage applies to LMSR trades as to orderbook trades:

  • Buying: cost = amm_price * (1 + fee%)
  • Selling: payout = amm_price * (1 - fee%)

Referral fee distribution follows the same structure (15% L1, 4% L2, 1% L3).

See Also​