> ## Documentation Index
> Fetch the complete documentation index at: https://dexbuilder.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Real-Time Order Updates

> Receive real-time order, trade, position, and settlement-state changes through private WebSocket channels.

Use private `ec.orders` and `ec.usertrades` channels to track the order lifecycle and fills, and use `ec.positions` and `ec.settlements` to track account state.

## Connection

```text theme={null}
wss://broker.dexbuilder.com/ws/dex-builder/event-contracts
```

## Subscribe

Use a Broker API Key and the target user's wallet address. See [Broker WebSocket authentication](https://dexbuilder.mintlify.site/en/event-contracts/websocket/authentication.md):

```json theme={null}
{
  "t": 1720000000123,
  "id": "orders-1",
  "op": "subscribe",
  "ch": "ec.orders",
  "payload": {
    "all": true
  },
  "auth": {
    "method": "broker_api_key",
    "key": "YOUR_BROKER_API_KEY",
    "sign": "HEX_SIGNATURE",
    "wallet_address": "<USER_WALLET>"
  }
}
```

## Update Payloads

Order updates include identifiers, side, price, quantity, status, and timestamps. User trade updates include trade and order identifiers, role, fee rate, execution price, size, and confirmation status. Position updates include quantity, average price, settlement status, available quantity, locked quantity, and claimable amount. This documentation does not define mark-price fields.

## State Recovery

WebSocket provides event updates and does not replace REST queries. After connecting or reconnecting:

1. Subscribe to the required private channels.
2. Query current orders, trades, positions, and account state through the corresponding REST endpoints.
3. Apply subsequent WebSocket updates using identifiers and timestamps.

Do not expose internal user Headers or broker account identifiers in client requests.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.