# Models

## The ResponseEnvelope object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"ResponseEnvelope":{"type":"object","description":"Standard response envelope shared by every endpoint.","required":["code","msg","data"],"properties":{"code":{"type":"string","description":"`\"0\"` for success. Non-zero indicates an error code — see [Error Codes](/reference/error-codes)."},"msg":{"type":"string","description":"Empty on success; human-readable error description on failure."},"data":{"description":"Endpoint-specific payload on success; `null` on failure.","nullable":true},"trace_code":{"type":"string","description":"Backend trace identifier. Empty on success; populated on failure for support diagnostics."}}}}}}
```

## The Signature object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"Signature":{"type":"object","description":"ECDSA signature components `(r, s, v)` over the EIP-712 signing hash.","required":["r","s","v"],"properties":{"r":{"type":"string","description":"32-byte hex string with `0x` prefix."},"s":{"type":"string","description":"32-byte hex string with `0x` prefix."},"v":{"type":"integer","description":"Recovery identifier — typically 27 or 28.","enum":[27,28]}}}}}}
```

## The WriteCommonParams object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"WriteCommonParams":{"type":"object","required":["address","nonce","expires_after","signature"],"properties":{"address":{"type":"string","description":"Signer's Ethereum address (`0x`-prefixed, lowercase hex). The node uses `ecrecover` to verify this matches the recovered signer.","pattern":"^0x[a-fA-F0-9]{40}$"},"nonce":{"type":"integer","format":"int64","description":"Millisecond Unix timestamp (`Date.now()`). Tracked **per signer** — each Agent Key has an independent nonce space."},"expires_after":{"type":"integer","format":"int64","description":"Expiration timestamp (ms). Recommended `Date.now() + 600_000` (10 minutes)."},"target_address":{"type":"string","description":"Optional target account address. Omit to operate on the signer's own account.\nUsed when an Agent operates on a sub-account.\n**Conditionally signed**: it does not enter `actionHash`, but when present it must be\nincluded as `Agent.targetAddress` in the EIP-712 struct (6-field Agent — see Signing\nMethod A). **Not allowed** on private-key-only endpoints.\n","pattern":"^0x[a-fA-F0-9]{40}$"},"signature":{"$ref":"#/components/schemas/Signature"}}},"Signature":{"type":"object","description":"ECDSA signature components `(r, s, v)` over the EIP-712 signing hash.","required":["r","s","v"],"properties":{"r":{"type":"string","description":"32-byte hex string with `0x` prefix."},"s":{"type":"string","description":"32-byte hex string with `0x` prefix."},"v":{"type":"integer","description":"Recovery identifier — typically 27 or 28.","enum":[27,28]}}}}}}
```

## The OrderTpslParams object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"OrderTpslParams":{"type":"object","description":"Take-profit / stop-loss parameters. Required when `algo_order_type` is `tpsl` or `attached_tpsl`; optional for normal/conditional orders.","properties":{"tpsl_mode":{"type":"string","enum":["full","partial"],"description":"`full` closes the full position when triggered; `partial` closes only the original quantity."},"tp_trigger_price":{"type":"string","description":"Take-profit trigger price (decimal string)."},"tp_trigger_by":{"type":"string","enum":["last_price","mark_price","index_price"],"description":"Spot supports `last_price` only; perp supports all three."},"tp_order_type":{"type":"string","enum":["market","limit"]},"tp_order_price":{"type":"string","description":"Take-profit limit price (required when `tp_order_type=limit`)."},"sl_trigger_price":{"type":"string","description":"Stop-loss trigger price."},"sl_trigger_by":{"type":"string","enum":["last_price","mark_price","index_price"],"description":"Spot supports `last_price` only; perp supports all three."},"sl_order_type":{"type":"string","enum":["market","limit"]},"sl_order_price":{"type":"string"}}}}}}
```

## The OrderConditionalParams object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"OrderConditionalParams":{"type":"object","description":"Conditional order trigger. Required when `algo_order_type=conditional`.","required":["trigger_price","trigger_by"],"properties":{"trigger_price":{"type":"string"},"trigger_by":{"type":"string","enum":["last_price","mark_price","index_price"],"description":"Spot supports `last_price` only; perp supports all three."}}}}}}
```

## The Order object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"Order":{"type":"object","description":"Full Order object returned by query endpoints and the `order` WebSocket channel.","properties":{"order_id":{"type":"string","description":"System-generated order ID."},"client_order_id":{"type":"string","nullable":true,"description":"Custom client order ID (≤ 36 chars)."},"address":{"type":"string"},"created_time":{"type":"integer","format":"int64"},"updated_time":{"type":"integer","format":"int64"},"symbol_id":{"type":"integer"},"is_buy":{"type":"boolean"},"order_type":{"type":"string","enum":["market","limit"]},"algo_order_type":{"type":"string","nullable":true,"enum":["conditional","tpsl","attached_tpsl",null]},"time_in_force":{"type":"string","nullable":true,"enum":["gtc","ioc","fok",null]},"quantity":{"type":"string"},"price":{"type":"string","nullable":true},"price_match":{"type":"string","nullable":true,"enum":["queue_1","queue_5","counter_party_1","counter_party_5",null]},"position_side":{"type":"string","nullable":true,"enum":["both","long","short",null]},"margin_mode":{"type":"string","nullable":true,"enum":["cross","isolated",null]},"market_order_type":{"type":"string","enum":["base","quote"],"description":"Perp defaults to `base`; spot is required (`base` / `quote`)."},"stp_mode":{"type":"string","nullable":true,"enum":["cancel_maker","cancel_taker","cancel_both","none",null]},"flags":{"type":"array","nullable":true,"items":{"type":"string","enum":["post_only","reduce_only"]}},"state":{"type":"string","description":"Order state — see [Order Object](/reference/order-object) for full state machine.","enum":["pending_new","new","partially_filled","filled","pending_cancel","canceled","rejected","inactive","pending_trigger","triggered"]},"cum_filled_quantity":{"type":"string"},"cum_filled_amount":{"type":"string"},"remaining_quantity":{"type":"string"},"original_quantity":{"type":"string"},"cum_fee":{"type":"string"},"order_source":{"type":"string","nullable":true},"conditional":{"$ref":"#/components/schemas/OrderConditionalParams","nullable":true},"tpsl":{"$ref":"#/components/schemas/OrderTpslParams","nullable":true},"parent_order_id":{"type":"string","nullable":true},"slippage":{"type":"string","nullable":true},"tx_hash":{"type":"string","description":"Creation/last-update transaction hash."}}},"OrderConditionalParams":{"type":"object","description":"Conditional order trigger. Required when `algo_order_type=conditional`.","required":["trigger_price","trigger_by"],"properties":{"trigger_price":{"type":"string"},"trigger_by":{"type":"string","enum":["last_price","mark_price","index_price"],"description":"Spot supports `last_price` only; perp supports all three."}}},"OrderTpslParams":{"type":"object","description":"Take-profit / stop-loss parameters. Required when `algo_order_type` is `tpsl` or `attached_tpsl`; optional for normal/conditional orders.","properties":{"tpsl_mode":{"type":"string","enum":["full","partial"],"description":"`full` closes the full position when triggered; `partial` closes only the original quantity."},"tp_trigger_price":{"type":"string","description":"Take-profit trigger price (decimal string)."},"tp_trigger_by":{"type":"string","enum":["last_price","mark_price","index_price"],"description":"Spot supports `last_price` only; perp supports all three."},"tp_order_type":{"type":"string","enum":["market","limit"]},"tp_order_price":{"type":"string","description":"Take-profit limit price (required when `tp_order_type=limit`)."},"sl_trigger_price":{"type":"string","description":"Stop-loss trigger price."},"sl_trigger_by":{"type":"string","enum":["last_price","mark_price","index_price"],"description":"Spot supports `last_price` only; perp supports all three."},"sl_order_type":{"type":"string","enum":["market","limit"]},"sl_order_price":{"type":"string"}}}}}}
```

## The Position object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"Position":{"type":"object","description":"Open position.","properties":{"symbol_id":{"type":"integer"},"address":{"type":"string"},"position_side":{"type":"string","enum":["both","long","short"]},"margin_mode":{"type":"string","enum":["cross","isolated"]},"open_size":{"type":"string","description":"Position size. Positive = long, negative = short."},"avg_price":{"type":"string","description":"Average open price."},"leverage":{"type":"integer"},"cum_realized_pnl":{"type":"string"},"cum_close_size":{"type":"string"},"cum_close_value":{"type":"string"},"cum_fee":{"type":"string"},"cum_funding_fee":{"type":"string"},"max_size":{"type":"string"},"isolated_margin":{"type":"string","nullable":true,"description":"Isolated margin (only present when `margin_mode=isolated`)."},"adl_level":{"type":"integer","minimum":1,"maximum":5},"created_time":{"type":"integer","format":"int64"},"updated_time":{"type":"integer","format":"int64"}}}}}}
```

## The PositionHistory object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"PositionHistory":{"type":"object","properties":{"symbol_id":{"type":"integer"},"position_side":{"type":"string","enum":["both","long","short"]},"margin_mode":{"type":"string","enum":["cross","isolated"]},"max_size":{"type":"string"},"avg_entry_price":{"type":"string"},"avg_close_price":{"type":"string"},"leverage":{"type":"integer"},"realized_pnl":{"type":"string"},"cum_fee":{"type":"string"},"cum_funding_fee":{"type":"string"},"open_time":{"type":"integer","format":"int64"},"close_time":{"type":"integer","format":"int64"}}}}}}
```

## The Execution object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"Execution":{"type":"object","properties":{"trade_id":{"type":"string"},"order_id":{"type":"string"},"symbol_id":{"type":"integer"},"is_buy":{"type":"boolean","description":"`true` = buy, `false` = sell."},"price":{"type":"string"},"quantity":{"type":"string"},"amount":{"type":"string"},"fee":{"type":"string"},"fee_coin_id":{"type":"integer"},"is_maker":{"type":"boolean"},"tx_hash":{"type":"string"},"time":{"type":"integer","format":"int64"}}}}}}
```

## The Ticker object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"Ticker":{"type":"object","properties":{"symbol_id":{"type":"integer"},"last_price":{"type":"string"},"mark_price":{"type":"string","nullable":true,"description":"Mark price (perp only)."},"oracle_price":{"type":"string","nullable":true,"description":"Oracle/index price (perp only)."},"best_bid_price":{"type":"string"},"best_bid_quantity":{"type":"string"},"best_ask_price":{"type":"string"},"best_ask_quantity":{"type":"string"},"high_24h":{"type":"string"},"low_24h":{"type":"string"},"volume_24h":{"type":"string","description":"24h volume in base currency."},"turnover_24h":{"type":"string","description":"24h turnover in quote currency."},"price_change_24h":{"type":"string"},"open_interest":{"type":"string","nullable":true,"description":"Open interest (perp only)."},"funding_rate":{"type":"string","nullable":true},"next_funding_time":{"type":"integer","format":"int64","nullable":true},"time":{"type":"integer","format":"int64"}}}}}}
```

## The L2Book object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"L2Book":{"type":"object","properties":{"symbol_id":{"type":"integer"},"asks":{"type":"array","description":"Ask side `[price, qty]`, sorted ascending by price.","items":{"type":"array","items":{"type":"string"}}},"bids":{"type":"array","description":"Bid side `[price, qty]`, sorted descending by price.","items":{"type":"array","items":{"type":"string"}}},"merge":{"type":"integer","description":"Current merge multiplier applied to the snapshot."},"seq":{"type":"integer","format":"int64","description":"Snapshot version (corresponds to the WS `l2_book` incremental version)."},"time":{"type":"integer","format":"int64"}}}}}}
```

## The TradeTick object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"TradeTick":{"type":"object","properties":{"trade_id":{"type":"string"},"price":{"type":"string"},"quantity":{"type":"string"},"amount":{"type":"string"},"is_buyer_maker":{"type":"boolean"},"time":{"type":"integer","format":"int64"},"tx_hash":{"type":"string"}}}}}}
```

## The Kline object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"Kline":{"type":"object","properties":{"start":{"type":"integer","format":"int64","description":"Open time (ms)."},"interval":{"type":"string"},"open":{"type":"string"},"close":{"type":"string"},"high":{"type":"string"},"low":{"type":"string"},"volume":{"type":"string"},"turnover":{"type":"string"}}}}}}
```

## The FundingRateHistory object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"FundingRateHistory":{"type":"object","properties":{"symbol_id":{"type":"integer"},"funding_rate":{"type":"string"},"mark_price":{"type":"string"},"time":{"type":"integer","format":"int64"}}}}}}
```

## The Symbol object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"Symbol":{"type":"object","properties":{"symbol_id":{"type":"integer"},"status":{"type":"string","enum":["pre_launch","trading","suspended","delisted"]},"base_coin_id":{"type":"integer"},"quote_coin_id":{"type":"integer"},"settle_coin_id":{"type":"integer","description":"Settlement coin (perp only)."},"price_precision":{"type":"integer"},"qty_precision":{"type":"integer"},"price_step":{"type":"string"},"qty_step":{"type":"string"},"min_size":{"type":"string"},"max_size":{"type":"string"},"max_leverage":{"type":"integer","nullable":true},"default_leverage":{"type":"integer","nullable":true},"taker_fee_rate":{"type":"string"},"maker_fee_rate":{"type":"string"},"price_limit_pct":{"type":"string","nullable":true},"funding_interval":{"type":"integer","nullable":true},"funding_rate_cap":{"type":"string","nullable":true},"funding_rate_floor":{"type":"string","nullable":true},"clamp_deviation":{"type":"string","nullable":true},"impact_margin_notional":{"type":"string","nullable":true},"price_step_merge_multiplier":{"type":"array","items":{"type":"string"},"description":"Allowed merge multipliers for L2 order book. `\"1\"` = no merge."}}}}}}
```

## The CoinChain object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"CoinChain":{"type":"object","properties":{"chain_id":{"type":"integer"},"min_deposit":{"type":"string"},"min_withdraw":{"type":"string"},"deposit_fee":{"type":"string"},"withdraw_fee":{"type":"string"},"enable_deposit":{"type":"boolean"},"enable_withdraw":{"type":"boolean"}}}}}}
```

## The Coin object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"Coin":{"type":"object","description":"Only deposit/withdraw-capable coins are returned.","properties":{"coin_id":{"type":"integer"},"precision":{"type":"integer"},"default_leverage":{"type":"integer"},"enable_collateral":{"type":"boolean"},"chains":{"type":"array","items":{"$ref":"#/components/schemas/CoinChain"}}}},"CoinChain":{"type":"object","properties":{"chain_id":{"type":"integer"},"min_deposit":{"type":"string"},"min_withdraw":{"type":"string"},"deposit_fee":{"type":"string"},"withdraw_fee":{"type":"string"},"enable_deposit":{"type":"boolean"},"enable_withdraw":{"type":"boolean"}}}}}}
```

## The AssetFlow object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"AssetFlow":{"type":"object","properties":{"flow_id":{"type":"string"},"coin_id":{"type":"integer"},"flow_type":{"type":"string","description":"See [Enums](/reference/enums) for the full list of flow types.","enum":["deposit","withdraw","pnl","spot_buy","spot_sell","fee","funding_fee","liquidation","transfer","interest","isolated_open","isolated_close","isolated_margin_change","system_adjust"]},"balance_delta":{"type":"string","description":"Positive = increase, negative = decrease."},"balance_after":{"type":"string"},"biz_id":{"type":"string"},"tx_hash":{"type":"string"},"update_time":{"type":"integer","format":"int64"}}}}}}
```

## The BalanceCoin object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"BalanceCoin":{"type":"object","properties":{"coin_id":{"type":"integer"},"balance":{"type":"string"},"spot_order_frozen":{"type":"string"},"transfer_frozen":{"type":"string"},"isolated_balance":{"type":"string","description":"Sum of isolated margins for this coin."},"created_time":{"type":"integer","format":"int64"},"updated_time":{"type":"integer","format":"int64"}}}}}}
```

## The AccountAgent object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"AccountAgent":{"type":"object","properties":{"agent_address":{"type":"string"},"authorized_address":{"type":"string"},"label":{"type":"string"},"approved_at":{"type":"integer","format":"int64"},"expires_at":{"type":"integer","format":"int64"}}}}}}
```

## The AccountChild object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"AccountChild":{"type":"object","properties":{"address":{"type":"string"},"type":{"type":"string","enum":["sub"]},"label":{"type":"string","description":"Sub-account label (only present when `type=sub`)."},"linked_at":{"type":"integer","format":"int64"}}}}}}
```

## The LeverageBracket object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"LeverageBracket":{"type":"object","properties":{"notional_cap":{"type":"string"},"max_leverage":{"type":"integer"},"mmr":{"type":"string"}}}}}}
```

## The ExplorerTx object

```json
{"openapi":"3.0.3","info":{"title":"Lynx DEX API","version":"1.5.0"},"components":{"schemas":{"ExplorerTx":{"type":"object","properties":{"tx_hash":{"type":"string","description":"EIP-712 signing hash."},"address":{"type":"string"},"action_type":{"type":"string"},"action":{"type":"object","description":"Original action parameters."},"seq_no":{"type":"integer","description":"Within-block sequence number."},"time":{"type":"integer","format":"int64"},"error":{"type":"string","nullable":true,"description":"`null` = success."},"block_height":{"type":"integer","format":"int64","description":"Present when fetched via /tx or /address/txs."}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lynxtrade.world/rest-api/models.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
