POST /api/v1/lmsr/trade
Execute an LMSR (Logarithmic Market Scoring Rule) AMM trade. The LMSR provides guaranteed liquidity so trades are filled instantly at a price determined by the automated market maker.
Authenticationβ
Required. Bearer token in Authorization header.
Requestβ
Body Parametersβ
| Parameter | Type | Required | Description |
|---|---|---|---|
market_id | int64 | Yes | ID of the market to trade in. |
side | string | Yes | Trade direction: "buy_yes", "sell_yes", "buy_no", or "sell_no". |
amount_type | string | Yes | "spend" (how much to pay in cents) or "shares" (how many tokens to buy/sell). |
amount | int | Yes | The amount in cents (if "spend") or number of shares (if "shares"). |
use_bonus | bool | No | If true, uses bonus balance to fund the trade. Defaults to false. |
Exampleβ
curl -X POST https://intotes.com/api/v1/lmsr/trade \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"market_id": 42,
"side": "buy_yes",
"amount_type": "spend",
"amount": 1000
}'
Responseβ
200 OKβ
{
"cost_or_payout_cents": 1000,
"shares_delta": 1538,
"new_position_yes": 1538,
"new_position_no": 0
}
Response Fieldsβ
| Field | Type | Description |
|---|---|---|
cost_or_payout_cents | int | For buys: the cost charged in cents. For sells: the payout received in cents. |
shares_delta | int | Number of shares bought or sold. |
new_position_yes | int | User's updated YES token position after the trade. |
new_position_no | int | User's updated NO token position after the trade. |
How LMSR Pricing Worksβ
The LMSR cost function is:
C(q) = b * ln(sum of e^(q_i / b))
- Buy cost = AMM price * (1 + fee%)
- Sell payout = AMM price * (1 - fee%)
The b parameter controls market liquidity. Higher b means more liquidity and smaller price impact per trade. The fee percent is configured server-side.
Errorsβ
| Status | Code | Description |
|---|---|---|
| 400 | INVALID_AMOUNT | Amount must be a positive integer. |
| 402 | INSUFFICIENT_BALANCE | User does not have enough balance for the trade. |
| 409 | MARKET_PAUSED | The market is currently paused for trading. |
| 409 | MARKET_RESOLVED | The market has already been resolved. |