GET /api/v1/lmsr/preview
Preview the result of an LMSR AMM trade without executing it. Use this endpoint to show estimated costs or payouts in the UI before the user confirms a trade.
Authenticationβ
None. This endpoint is publicly accessible.
Requestβ
Query Parametersβ
| Parameter | Type | Required | Description |
|---|---|---|---|
market_id | int64 | Yes | ID of the market to preview the 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"). |
Exampleβ
curl "https://intotes.com/api/v1/lmsr/preview?market_id=42&side=buy_yes&amount_type=spend&amount=1000"
Responseβ
200 OKβ
{
"cost_or_payout_cents": 1000,
"shares_delta": 1538
}
Response Fieldsβ
| Field | Type | Description |
|---|---|---|
cost_or_payout_cents | int | For buys: the estimated cost in cents. For sells: the estimated payout in cents. |
shares_delta | int | Estimated number of shares that would be bought or sold. |
Notesβ
- The preview reflects the current state of the AMM. Actual execution prices may differ slightly if other trades occur between the preview and the trade.
- No authentication is required, so this can be called for anonymous users browsing the market.
Errorsβ
| Status | Code | Description |
|---|---|---|
| 400 | INVALID_AMOUNT | Amount must be a positive integer. |
| 400 | INVALID_SIDE | Side must be one of buy_yes, sell_yes, buy_no, sell_no. |
| 404 | MARKET_NOT_FOUND | No market found with the given ID. |