Skip to main content

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​

ParameterTypeRequiredDescription
market_idint64YesID of the market to trade in.
sidestringYesTrade direction: "buy_yes", "sell_yes", "buy_no", or "sell_no".
amount_typestringYes"spend" (how much to pay in cents) or "shares" (how many tokens to buy/sell).
amountintYesThe amount in cents (if "spend") or number of shares (if "shares").
use_bonusboolNoIf 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​

FieldTypeDescription
cost_or_payout_centsintFor buys: the cost charged in cents. For sells: the payout received in cents.
shares_deltaintNumber of shares bought or sold.
new_position_yesintUser's updated YES token position after the trade.
new_position_nointUser'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​

StatusCodeDescription
400INVALID_AMOUNTAmount must be a positive integer.
402INSUFFICIENT_BALANCEUser does not have enough balance for the trade.
409MARKET_PAUSEDThe market is currently paused for trading.
409MARKET_RESOLVEDThe market has already been resolved.