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_iis the number of outstanding shares for outcomei(YES or NO).bis the liquidity parameter that controls price sensitivity. A largerbmeans 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β
| Field | Type | Required | Description |
|---|---|---|---|
market_id | integer | Yes | The LMSR market to trade on. |
side | string | Yes | One of: "buy_yes", "sell_yes", "buy_no", "sell_no". |
amount_type | string | Yes | "spend" (specify budget) or "shares" (specify share count). |
amount | integer | Yes | Amount in cents. If amount_type is "spend", this is the budget. If "shares", this is the number of share-cents. |
use_bonus | boolean | No | If true, deducts from bonus balance. Defaults to false. |
Side Valuesβ
| Side | Action |
|---|---|
buy_yes | Buy YES tokens (long position on the event happening) |
sell_yes | Sell YES tokens you hold |
buy_no | Buy NO tokens (long position on the event not happening) |
sell_no | Sell 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β
| Parameter | Type | Required | Description |
|---|---|---|---|
market_id | integer | Yes | The market to preview. |
side | string | Yes | Same values as the trade endpoint. |
amount_type | string | Yes | "spend" or "shares". |
amount | integer | Yes | Amount 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β
- Overview -- When to use AMM vs. orderbook markets
- Fees and Commissions -- Complete fee breakdown
- Positions and PnL -- Tracking positions from AMM trades