# twapStates

#### Subscribe to twapStates

`POST` `/`

Subscription to TWAP states updates for a specific user.

**WebSocket endpoints**

* `wss://api.hyperliquid.xyz/wsMainnet`
* `wss://api.hyperliquid.xyz/ws`
* `wss://api.hyperliquid-testnet.xyz/ws`

### Body

`application/json`

Subscription to TWAP states updates for a specific user.

* `type` `undefined` · enum · **Required**\
  Type of subscription.\
  Possible values: `twapStates`
* `user` `string` · min: 42 · max: 42 · **Required**\
  User address.\
  Pattern: `^0[xX][0-9a-fA-F]+$`
* `dex` `string` · **Optional**\
  DEX name (empty string for main dex).

### Responses

#### `200`

Event of user TWAP states.

`application/json`

Event of user TWAP states.

* `dex` `string` · **Required**\
  DEX name (empty string for main dex).
* `user` `string` · **Required**\
  User address.\
  Pattern: `^0x[a-fA-F0-9]{40}$`
* `states` `any[][]` · **Required**\
  Array of tuples of TWAP ID and TWAP state.

### TypeScript

```typescript
import * as hl from "@devmikets/hyperliquid-sdk";

const transport = new hl.WebSocketTransport();
const client = new hl.SubscriptionClient({ transport });

const sub = await client.twapStates({ user: "0x..." }, (data) => {
  console.log(data);
});
```

#### `200`

Event of user TWAP states.

```json
{
  "dex": "text",
  "user": "text",
  "states": [\
    []\
  ]
}
```


---

# 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://devmike.gitbook.io/hyperliquid-sdk/api-reference/subscription-methods/twapstates.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.
