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

# Token Top Traders

> Stream top traders ranked by PnL.

> [!NOTE]
>
> **Room ID:** `top_traders` \
> **Endpoint:** `wss://staging-api.struct.to/ws`

Live top traders for a token, ranked by PnL for the selected timeframe. You get a snapshot, then row updates as trades in the subscribed pool and updated PnL values arrive. PnL values may update separately from trade events.

### Migrations

A `pool_id` subscription follows migrations. When the pool migrates (for example a bonding curve graduating to an AMM pool), the list moves to the destination pool for the same token and options automatically; later updates carry the new `pool_id`. This room sends no migration event: watch the [address room](https://docs.struct.to/websockets/rooms/address.md) (an `address_update` for the destination pool with `migrated_from_pool_id`, dirty kind `pool`) to be notified. Your list is kept: the next update arrives as a normal delta, or as the destination list's snapshot (`reset=true`) when one already existed. A pool that had already migrated when you subscribe is followed immediately: the subscribe response's `pool_id` is the destination and `migrations` lists each hop.

## Subscribe

Requires `token_address`, `pool_id`, and an explicit chain selector.

### Filters

| Filter | Type | Required | Description |
| - | - | - | - |
| `chain` | `string` | No\* | Chain name: `solana`, `bnb`, `base`, `ethereum`, `robinhood`, `arc` |
| `chain_id` | `integer` | No\* | Chain id: `-1`, `56`, `8453`, `1`, `4663`, `5042` |
| `token_address` | `string` | Yes | Token mint or 0x address |
| `pool_id` | `string` | Yes | Pool address; followed through migrations |
| `timeframe` | `string` | No | `1d`, `3d`, `7d`, `14d`, `30d`, `lifetime` |
| `tags` | `string` | No | One canonical tag filter |
| `include_pnl` | `boolean` | No | Default `true` |
| `include_funding` | `boolean` | No | Default `true` |
| `limit` | `integer` | No | Page size, 1-100 |

Provide either `chain` or `chain_id`. Do not send both.

### Example

```json theme={null}
{
  "type": "join_room",
  "payload": {
    "room_id": "top_traders"
  }
}
```

```json theme={null}
{
  "type": "room_message",
  "payload": {
    "room_id": "top_traders",
    "message": {
      "action": "subscribe",
      "chain": "solana",
      "token_address": "TokenMint111111111111111111111111111111111",
      "pool_id": "7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"
    }
  }
}
```

## Events

Every `subscribe` is answered with `top_traders_subscribe_response` (keys are always long). Here the subscribed pool had already migrated:

```json theme={null}
{
  "type": "top_traders_subscribe_response",
  "room_id": "top_traders",
  "data": {
    "token_address": "TokenMint111111111111111111111111111111111",
    "pool_id": "9h1Yf7uTzK5vf5JEn7vznsAKBDmkQxXS4v53jviDm4pk",
    "timeframe": "30d",
    "tags": null,
    "limit": 50,
    "migrations": [
      {
        "chain": "solana",
        "chain_id": -1,
        "old_pool_id": "7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj",
        "new_pool_id": "9h1Yf7uTzK5vf5JEn7vznsAKBDmkQxXS4v53jviDm4pk",
        "token_address": "TokenMint111111111111111111111111111111111"
      }
    ]
  }
}
```

The room emits a top-traders update. Same update shape as [Token Holders](https://docs.struct.to/websockets/rooms/holders.md). Pick **Response (Long)** or **Response (Short)** in the right-hand panel. WebSocket defaults to short. See [long and short field names](https://docs.struct.to/api-reference/response-format.md#long-and-short-field-names).

```json Response (Long) theme={null}
{
  "type": "top_traders_update",
  "room_id": "top_traders",
  "chain_id": -1,
  "token_address": "TokenMint111111111111111111111111111111111",
  "pool_id": "7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj",
  "timeframe": "lifetime",
  "tag": "sniper",
  "data": {
    "seq": 18,
    "reset": true,
    "upserts": [
      {
        "wallet": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
        "rank": 1,
        "token_balance": 1250.5,
        "token_balance_usd": 120.77,
        "token_balance_raw": "1250500000",
        "token_balance_supply_percentage": 0.125,
        "native_balance": 2.4,
        "native_balance_usd": 355.73,
        "native_balance_raw": "2400000000",
        "tags": [
          "Dev",
          "Sniper"
        ],
        "funding": {
          "funder": "0x92C5A42cF503b572955BcfA10E15D47cA5682387",
          "funder_type": "cex",
          "funder_name": "Binance",
          "amount": 0.5,
          "amount_raw": "500000000000000000",
          "decimals": 18,
          "name": "Ether",
          "symbol": "ETH",
          "hash": "0x1111111111111111111111111111111111111111111111111111111111111111",
          "block": 12345678,
          "timestamp": 1784216300000
        },
        "bot_name": "GMGN",
        "pnl": {
          "buy_count": 8,
          "sell_count": 5,
          "buy_native": 1.2,
          "buy_usd": 178.0,
          "buy_tokens": 680000,
          "sell_native": 1.6,
          "sell_usd": 237.0,
          "sell_tokens": 420000,
          "pnl_native": 0.4,
          "pnl_usd": 59.0,
          "pnl_native_percent": 33.33,
          "pnl_usd_percent": 33.15,
          "average_buy_price_native": 1.76e-06,
          "average_buy_price_usd": 0.00026176,
          "average_sell_price_native": 3.81e-06,
          "average_sell_price_usd": 0.00056429,
          "overall_average_price_native": 2.54e-06,
          "overall_average_price_usd": 0.00037727,
          "average_buy_market_cap_native": 1760,
          "average_buy_market_cap_usd": 261760,
          "average_sell_market_cap_native": 3810,
          "average_sell_market_cap_usd": 564290,
          "overall_average_market_cap_native": 2540,
          "overall_average_market_cap_usd": 377270,
          "first_active": 1705000000000,
          "last_active": 1710000000000,
          "last_pool": "7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj",
          "first_tx_hash": "5xFirstTx11111111111111111111111111111111111",
          "opening_price_native": 1.2e-06,
          "opening_price_usd": 0.00018,
          "closing_price_native": 3.81e-06,
          "closing_price_usd": 0.00056429,
          "high_price_native": 4.2e-06,
          "high_price_usd": 0.00063,
          "low_price_native": 1.1e-06,
          "low_price_usd": 0.000165,
          "total_priority_fees": 0.014,
          "total_bot_fees": 0.008,
          "total_tip_amount": 0.002,
          "timeframe": "lifetime",
          "current_price_native": 3.81e-06,
          "current_price_usd": 0.00056429,
          "token_supply": 1000000000
        }
      }
    ],
    "removed_wallets": [
      "So11111111111111111111111111111111111111112"
    ],
    "total_holders": 1842,
    "has_more": true,
    "pagination_key": "eyJ3Ijoib2Zmc2V0In0",
    "generated_at_ms": 1710000000000
  }
}
```

```jsonc Response (Short) theme={null}
{
  "type": "top_traders_update",
  "room_id": "top_traders",
  "chain_id": -1,
  "token_address": "TokenMint111111111111111111111111111111111",
  "pool_id": "7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj",
  "timeframe": "lifetime",
  "tag": "sniper",
  "data": {
    "s": 18,
    "rst": true,
    "up": [
      {
        "w": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
        "rk": 1,
        "tb": 1250.5,
        "tbu": 120.77,
        "tbr": "1250500000",
        "tbs": 0.125,
        "nb": 2.4,
        "nbu": 355.73,
        "nbr": "2400000000",
        "tg": [
          "Dev",
          "Sniper"
        ],
        "f": {
          "a": "0x92C5A42cF503b572955BcfA10E15D47cA5682387",
          "t": "cex",
          "f": "Binance",
          "v": 0.5,
          "r": "500000000000000000",
          "d": 18,
          "n": "Ether",
          "s": "ETH",
          "h": "0x1111111111111111111111111111111111111111111111111111111111111111",
          "b": 12345678,
          "c": 1784216300000
        },
        "bn": "GMGN",
        "pnl": {
          "bc": 8,
          "sc": 5,
          "bn": 1.2,
          "bu": 178.0,
          "bt": 680000,
          "sn": 1.6,
          "su": 237.0,
          "st": 420000,
          "pn": 0.4,
          "pu": 59.0,
          "pnp": 33.33,
          "pup": 33.15,
          "abpn": 1.76e-06,
          "abpu": 0.00026176,
          "aspn": 3.81e-06,
          "aspu": 0.00056429,
          "oapn": 2.54e-06,
          "oapu": 0.00037727,
          "abmcn": 1760,
          "abmcu": 261760,
          "asmcn": 3810,
          "asmcu": 564290,
          "oamcn": 2540,
          "oamcu": 377270,
          "fa": 1705000000000,
          "la": 1710000000000,
          "lpo": "7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj",
          "fth": "5xFirstTx11111111111111111111111111111111111",
          "opn": 1.2e-06,
          "opu": 0.00018,
          "clpn": 3.81e-06,
          "clpu": 0.00056429,
          "hpn": 4.2e-06,
          "hpu": 0.00063,
          "lpn": 1.1e-06,
          "lpu": 0.000165,
          "tpf": 0.014,
          "tbf": 0.008,
          "tta": 0.002,
          "tf": "lifetime",
          "cpn": 3.81e-06,
          "cpu": 0.00056429,
          "ts": 1000000000
        }
      }
    ],
    "rw": [
      "So11111111111111111111111111111111111111112"
    ],
    "th": 1842,
    "hm": true,
    "pk": "eyJ3Ijoib2Zmc2V0In0",
    "ga": 1710000000000
  }
}
```


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