@0xarchive/sdk 0.9.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -464,10 +464,11 @@ interface PriceHistoryParams extends CursorPaginationParams {
464
464
  *
465
465
  * - ticker/all_tickers: real-time only
466
466
  * - liquidations: historical only (May 2025+)
467
+ * - hip3_liquidations: historical only (Feb 2026+)
467
468
  * - open_interest, funding, lighter_open_interest, lighter_funding,
468
469
  * hip3_open_interest, hip3_funding: historical only (replay/stream)
469
470
  */
470
- type WsChannel = 'orderbook' | 'trades' | 'candles' | 'liquidations' | 'ticker' | 'all_tickers' | 'open_interest' | 'funding' | 'lighter_orderbook' | 'lighter_trades' | 'lighter_candles' | 'lighter_open_interest' | 'lighter_funding' | 'hip3_orderbook' | 'hip3_trades' | 'hip3_candles' | 'hip3_open_interest' | 'hip3_funding';
471
+ type WsChannel = 'orderbook' | 'trades' | 'candles' | 'liquidations' | 'ticker' | 'all_tickers' | 'open_interest' | 'funding' | 'lighter_orderbook' | 'lighter_trades' | 'lighter_candles' | 'lighter_open_interest' | 'lighter_funding' | 'lighter_l3_orderbook' | 'hip3_orderbook' | 'hip3_trades' | 'hip3_candles' | 'hip3_open_interest' | 'hip3_funding' | 'hip3_liquidations' | 'l4_diffs' | 'l4_orders' | 'hip3_l4_diffs' | 'hip3_l4_orders';
471
472
  /** Subscribe message from client */
472
473
  interface WsSubscribe {
473
474
  op: 'subscribe';
@@ -703,8 +704,24 @@ interface WsGapDetected {
703
704
  /** Gap duration in minutes */
704
705
  duration_minutes: number;
705
706
  }
707
+ /** L4 snapshot (sent on l4_diffs/hip3_l4_diffs subscription) */
708
+ interface WsL4Snapshot {
709
+ type: 'l4_snapshot';
710
+ channel: WsChannel;
711
+ coin: string;
712
+ last_block_number: number;
713
+ timestamp: number;
714
+ data: any;
715
+ }
716
+ /** L4 batched data (all L4 channels) */
717
+ interface WsL4Batch {
718
+ type: 'l4_batch';
719
+ channel: WsChannel;
720
+ coin: string;
721
+ data: any[];
722
+ }
706
723
  /** Server message union type */
707
- type WsServerMessage = WsSubscribed | WsUnsubscribed | WsPong | WsError | WsData | WsReplayStarted | WsReplayPaused | WsReplayResumed | WsReplayCompleted | WsReplayStopped | WsReplaySnapshot | WsHistoricalData | WsHistoricalTickData | WsStreamStarted | WsStreamProgress | WsHistoricalBatch | WsStreamCompleted | WsStreamStopped | WsGapDetected;
724
+ type WsServerMessage = WsSubscribed | WsUnsubscribed | WsPong | WsError | WsData | WsReplayStarted | WsReplayPaused | WsReplayResumed | WsReplayCompleted | WsReplayStopped | WsReplaySnapshot | WsHistoricalData | WsHistoricalTickData | WsStreamStarted | WsStreamProgress | WsHistoricalBatch | WsStreamCompleted | WsStreamStopped | WsGapDetected | WsL4Snapshot | WsL4Batch;
708
725
  /**
709
726
  * WebSocket connection options.
710
727
  *
@@ -1332,17 +1349,17 @@ declare class OrderBookResource {
1332
1349
  private coinTransform;
1333
1350
  constructor(http: HttpClient, basePath?: string, coinTransform?: (coin: string) => string);
1334
1351
  /**
1335
- * Get order book snapshot for a coin
1352
+ * Get order book snapshot for a symbol
1336
1353
  *
1337
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1354
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1338
1355
  * @param params - Optional parameters
1339
1356
  * @returns Order book snapshot
1340
1357
  */
1341
- get(coin: string, params?: GetOrderBookParams): Promise<OrderBook>;
1358
+ get(symbol: string, params?: GetOrderBookParams): Promise<OrderBook>;
1342
1359
  /**
1343
1360
  * Get historical order book snapshots with cursor-based pagination
1344
1361
  *
1345
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1362
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1346
1363
  * @param params - Time range and cursor pagination parameters (start and end are required)
1347
1364
  * @returns CursorResponse with order book snapshots and nextCursor for pagination
1348
1365
  *
@@ -1366,7 +1383,7 @@ declare class OrderBookResource {
1366
1383
  * }
1367
1384
  * ```
1368
1385
  */
1369
- history(coin: string, params: OrderBookHistoryParams): Promise<CursorResponse<OrderBook[]>>;
1386
+ history(symbol: string, params: OrderBookHistoryParams): Promise<CursorResponse<OrderBook[]>>;
1370
1387
  /**
1371
1388
  * Get raw tick-level orderbook data (Enterprise tier only).
1372
1389
  *
@@ -1376,7 +1393,7 @@ declare class OrderBookResource {
1376
1393
  *
1377
1394
  * For automatic reconstruction, use `historyReconstructed()` instead.
1378
1395
  *
1379
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1396
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1380
1397
  * @param params - Time range parameters
1381
1398
  * @returns Tick data with checkpoint and deltas
1382
1399
  *
@@ -1396,7 +1413,7 @@ declare class OrderBookResource {
1396
1413
  * }
1397
1414
  * ```
1398
1415
  */
1399
- historyTick(coin: string, params: TickHistoryParams): Promise<TickData>;
1416
+ historyTick(symbol: string, params: TickHistoryParams): Promise<TickData>;
1400
1417
  /**
1401
1418
  * Get reconstructed tick-level orderbook history (Enterprise tier only).
1402
1419
  *
@@ -1406,7 +1423,7 @@ declare class OrderBookResource {
1406
1423
  * For large time ranges, consider using `historyTick()` with the
1407
1424
  * `OrderBookReconstructor.iterate()` method for memory efficiency.
1408
1425
  *
1409
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1426
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1410
1427
  * @param params - Time range parameters
1411
1428
  * @param options - Reconstruction options
1412
1429
  * @returns Array of reconstructed orderbook snapshots
@@ -1430,7 +1447,7 @@ declare class OrderBookResource {
1430
1447
  * );
1431
1448
  * ```
1432
1449
  */
1433
- historyReconstructed(coin: string, params: TickHistoryParams, options?: ReconstructOptions): Promise<ReconstructedOrderBook[]>;
1450
+ historyReconstructed(symbol: string, params: TickHistoryParams, options?: ReconstructOptions): Promise<ReconstructedOrderBook[]>;
1434
1451
  /**
1435
1452
  * Create a reconstructor for streaming tick-level data.
1436
1453
  *
@@ -1465,7 +1482,7 @@ declare class OrderBookResource {
1465
1482
  * per API request and yielding reconstructed orderbook snapshots one at a time.
1466
1483
  * Memory-efficient for processing large time ranges.
1467
1484
  *
1468
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1485
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1469
1486
  * @param params - Time range parameters
1470
1487
  * @param depth - Maximum price levels to include in output snapshots
1471
1488
  * @yields Reconstructed orderbook snapshots
@@ -1488,7 +1505,7 @@ declare class OrderBookResource {
1488
1505
  * }
1489
1506
  * ```
1490
1507
  */
1491
- iterateTickHistory(coin: string, params: TickHistoryParams, depth?: number): AsyncGenerator<ReconstructedOrderBook, void, undefined>;
1508
+ iterateTickHistory(symbol: string, params: TickHistoryParams, depth?: number): AsyncGenerator<ReconstructedOrderBook, void, undefined>;
1492
1509
  }
1493
1510
 
1494
1511
  /**
@@ -1525,12 +1542,12 @@ declare class TradesResource {
1525
1542
  private coinTransform;
1526
1543
  constructor(http: HttpClient, basePath?: string, coinTransform?: (coin: string) => string);
1527
1544
  /**
1528
- * Get trade history for a coin using cursor-based pagination
1545
+ * Get trade history for a symbol using cursor-based pagination
1529
1546
  *
1530
1547
  * Uses cursor-based pagination by default, which is more efficient for large datasets.
1531
1548
  * Use the `nextCursor` from the response as the `cursor` parameter to get the next page.
1532
1549
  *
1533
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1550
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1534
1551
  * @param params - Time range and cursor pagination parameters (start and end are required)
1535
1552
  * @returns Object with trades array and nextCursor for pagination
1536
1553
  *
@@ -1554,20 +1571,20 @@ declare class TradesResource {
1554
1571
  * }
1555
1572
  * ```
1556
1573
  */
1557
- list(coin: string, params: GetTradesCursorParams): Promise<CursorResponse<Trade[]>>;
1574
+ list(symbol: string, params: GetTradesCursorParams): Promise<CursorResponse<Trade[]>>;
1558
1575
  /**
1559
- * Get most recent trades for a coin.
1576
+ * Get most recent trades for a symbol.
1560
1577
  *
1561
1578
  * Note: This method is available for Lighter (client.lighter.trades.recent())
1562
1579
  * and HIP-3 (client.hyperliquid.hip3.trades.recent()) which have real-time data
1563
1580
  * ingestion. Hyperliquid uses hourly backfill so this endpoint is not available
1564
1581
  * for Hyperliquid.
1565
1582
  *
1566
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1583
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1567
1584
  * @param limit - Number of trades to return (default: 100)
1568
1585
  * @returns Array of recent trades
1569
1586
  */
1570
- recent(coin: string, limit?: number): Promise<Trade[]>;
1587
+ recent(symbol: string, limit?: number): Promise<Trade[]>;
1571
1588
  }
1572
1589
 
1573
1590
  /**
@@ -1704,20 +1721,20 @@ declare class FundingResource {
1704
1721
  private coinTransform;
1705
1722
  constructor(http: HttpClient, basePath?: string, coinTransform?: (coin: string) => string);
1706
1723
  /**
1707
- * Get funding rate history for a coin with cursor-based pagination
1724
+ * Get funding rate history for a symbol with cursor-based pagination
1708
1725
  *
1709
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1726
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1710
1727
  * @param params - Time range and cursor pagination parameters (start and end are required)
1711
1728
  * @returns CursorResponse with funding rate records and nextCursor for pagination
1712
1729
  */
1713
- history(coin: string, params: FundingHistoryParams): Promise<CursorResponse<FundingRate[]>>;
1730
+ history(symbol: string, params: FundingHistoryParams): Promise<CursorResponse<FundingRate[]>>;
1714
1731
  /**
1715
- * Get current funding rate for a coin
1732
+ * Get current funding rate for a symbol
1716
1733
  *
1717
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1734
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1718
1735
  * @returns Current funding rate
1719
1736
  */
1720
- current(coin: string): Promise<FundingRate>;
1737
+ current(symbol: string): Promise<FundingRate>;
1721
1738
  }
1722
1739
 
1723
1740
  /**
@@ -1754,20 +1771,20 @@ declare class OpenInterestResource {
1754
1771
  private coinTransform;
1755
1772
  constructor(http: HttpClient, basePath?: string, coinTransform?: (coin: string) => string);
1756
1773
  /**
1757
- * Get open interest history for a coin with cursor-based pagination
1774
+ * Get open interest history for a symbol with cursor-based pagination
1758
1775
  *
1759
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1776
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1760
1777
  * @param params - Time range and cursor pagination parameters (start and end are required)
1761
1778
  * @returns CursorResponse with open interest records and nextCursor for pagination
1762
1779
  */
1763
- history(coin: string, params: OpenInterestHistoryParams): Promise<CursorResponse<OpenInterest[]>>;
1780
+ history(symbol: string, params: OpenInterestHistoryParams): Promise<CursorResponse<OpenInterest[]>>;
1764
1781
  /**
1765
- * Get current open interest for a coin
1782
+ * Get current open interest for a symbol
1766
1783
  *
1767
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1784
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1768
1785
  * @returns Current open interest
1769
1786
  */
1770
- current(coin: string): Promise<OpenInterest>;
1787
+ current(symbol: string): Promise<OpenInterest>;
1771
1788
  }
1772
1789
 
1773
1790
  /**
@@ -1810,11 +1827,11 @@ declare class CandlesResource {
1810
1827
  /**
1811
1828
  * Get historical OHLCV candle data with cursor-based pagination
1812
1829
  *
1813
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1830
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1814
1831
  * @param params - Time range, interval, and cursor pagination parameters (start and end are required)
1815
1832
  * @returns CursorResponse with candle records and nextCursor for pagination
1816
1833
  */
1817
- history(coin: string, params: CandleHistoryParams): Promise<CursorResponse<Candle[]>>;
1834
+ history(symbol: string, params: CandleHistoryParams): Promise<CursorResponse<Candle[]>>;
1818
1835
  }
1819
1836
 
1820
1837
  /**
@@ -1855,15 +1872,16 @@ declare class CandlesResource {
1855
1872
  declare class LiquidationsResource {
1856
1873
  private http;
1857
1874
  private basePath;
1858
- constructor(http: HttpClient, basePath?: string);
1875
+ private coinTransform;
1876
+ constructor(http: HttpClient, basePath?: string, coinTransform?: (coin: string) => string);
1859
1877
  /**
1860
- * Get liquidation history for a coin with cursor-based pagination
1878
+ * Get liquidation history for a symbol with cursor-based pagination
1861
1879
  *
1862
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1880
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1863
1881
  * @param params - Time range and cursor pagination parameters (start and end are required)
1864
1882
  * @returns CursorResponse with liquidation records and nextCursor for pagination
1865
1883
  */
1866
- history(coin: string, params: LiquidationHistoryParams): Promise<CursorResponse<Liquidation[]>>;
1884
+ history(symbol: string, params: LiquidationHistoryParams): Promise<CursorResponse<Liquidation[]>>;
1867
1885
  /**
1868
1886
  * Get liquidation history for a specific user
1869
1887
  *
@@ -1882,11 +1900,11 @@ declare class LiquidationsResource {
1882
1900
  * Returns pre-aggregated data with total/long/short USD volumes per bucket,
1883
1901
  * reducing data transfer by 100-1000x compared to individual liquidation records.
1884
1902
  *
1885
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1903
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1886
1904
  * @param params - Time range, cursor, and interval parameters
1887
1905
  * @returns CursorResponse with liquidation volume buckets
1888
1906
  */
1889
- volume(coin: string, params: LiquidationVolumeParams): Promise<CursorResponse<LiquidationVolume[]>>;
1907
+ volume(symbol: string, params: LiquidationVolumeParams): Promise<CursorResponse<LiquidationVolume[]>>;
1890
1908
  }
1891
1909
 
1892
1910
  /**
@@ -2138,6 +2156,226 @@ declare class Web3Resource {
2138
2156
  subscribe(tier: 'build' | 'pro', paymentSignature: string): Promise<Web3SubscribeResult>;
2139
2157
  }
2140
2158
 
2159
+ interface OrderHistoryParams extends CursorPaginationParams {
2160
+ user?: string;
2161
+ status?: string;
2162
+ order_type?: string;
2163
+ }
2164
+ interface OrderFlowParams {
2165
+ start: number | string;
2166
+ end: number | string;
2167
+ interval?: string;
2168
+ limit?: number;
2169
+ }
2170
+ interface TpslParams extends CursorPaginationParams {
2171
+ user?: string;
2172
+ triggered?: boolean;
2173
+ }
2174
+ /**
2175
+ * Orders API resource
2176
+ *
2177
+ * @example
2178
+ * ```typescript
2179
+ * // Get order history
2180
+ * const result = await client.hyperliquid.orders.history('BTC', {
2181
+ * start: Date.now() - 86400000,
2182
+ * end: Date.now(),
2183
+ * limit: 1000
2184
+ * });
2185
+ *
2186
+ * // Get order flow
2187
+ * const flow = await client.hyperliquid.orders.flow('BTC', {
2188
+ * start: Date.now() - 86400000,
2189
+ * end: Date.now(),
2190
+ * interval: '1h'
2191
+ * });
2192
+ *
2193
+ * // Get TP/SL orders
2194
+ * const tpsl = await client.hyperliquid.orders.tpsl('BTC', {
2195
+ * start: Date.now() - 86400000,
2196
+ * end: Date.now()
2197
+ * });
2198
+ * ```
2199
+ */
2200
+ declare class OrdersResource {
2201
+ private http;
2202
+ private basePath;
2203
+ private coinTransform;
2204
+ constructor(http: HttpClient, basePath?: string, coinTransform?: (s: string) => string);
2205
+ /**
2206
+ * Get order history for a symbol with cursor-based pagination
2207
+ *
2208
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
2209
+ * @param params - Time range, cursor pagination, and filter parameters
2210
+ * @returns CursorResponse with order records and nextCursor for pagination
2211
+ */
2212
+ history(symbol: string, params: OrderHistoryParams): Promise<CursorResponse<any[]>>;
2213
+ /**
2214
+ * Get order flow for a symbol
2215
+ *
2216
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
2217
+ * @param params - Time range and interval parameters
2218
+ * @returns CursorResponse with order flow records
2219
+ */
2220
+ flow(symbol: string, params: OrderFlowParams): Promise<CursorResponse<any[]>>;
2221
+ /**
2222
+ * Get TP/SL orders for a symbol with cursor-based pagination
2223
+ *
2224
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
2225
+ * @param params - Time range, cursor pagination, and filter parameters
2226
+ * @returns CursorResponse with TP/SL order records
2227
+ */
2228
+ tpsl(symbol: string, params: TpslParams): Promise<CursorResponse<any[]>>;
2229
+ }
2230
+
2231
+ interface L4OrderBookParams {
2232
+ timestamp?: number | string;
2233
+ depth?: number;
2234
+ }
2235
+ /**
2236
+ * L4 Order Book API resource
2237
+ *
2238
+ * Access L4 orderbook snapshots, diffs, and history.
2239
+ *
2240
+ * @example
2241
+ * ```typescript
2242
+ * // Get current L4 orderbook
2243
+ * const orderbook = await client.hyperliquid.l4Orderbook.get('BTC');
2244
+ *
2245
+ * // Get L4 orderbook diffs
2246
+ * const diffs = await client.hyperliquid.l4Orderbook.diffs('BTC', {
2247
+ * start: Date.now() - 86400000,
2248
+ * end: Date.now(),
2249
+ * limit: 1000
2250
+ * });
2251
+ *
2252
+ * // Get L4 orderbook history
2253
+ * const history = await client.hyperliquid.l4Orderbook.history('BTC', {
2254
+ * start: Date.now() - 86400000,
2255
+ * end: Date.now(),
2256
+ * limit: 1000
2257
+ * });
2258
+ * ```
2259
+ */
2260
+ declare class L4OrderBookResource {
2261
+ private http;
2262
+ private basePath;
2263
+ private coinTransform;
2264
+ constructor(http: HttpClient, basePath?: string, coinTransform?: (s: string) => string);
2265
+ /**
2266
+ * Get L4 order book snapshot for a symbol
2267
+ *
2268
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
2269
+ * @param params - Optional parameters (timestamp, depth)
2270
+ * @returns L4 order book snapshot
2271
+ */
2272
+ get(symbol: string, params?: L4OrderBookParams): Promise<any>;
2273
+ /**
2274
+ * Get L4 order book diffs with cursor-based pagination
2275
+ *
2276
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
2277
+ * @param params - Time range and cursor pagination parameters
2278
+ * @returns CursorResponse with L4 orderbook diffs and nextCursor for pagination
2279
+ */
2280
+ diffs(symbol: string, params: CursorPaginationParams): Promise<CursorResponse<any[]>>;
2281
+ /**
2282
+ * Get L4 order book history with cursor-based pagination
2283
+ *
2284
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
2285
+ * @param params - Time range and cursor pagination parameters
2286
+ * @returns CursorResponse with L4 orderbook snapshots and nextCursor for pagination
2287
+ */
2288
+ history(symbol: string, params: CursorPaginationParams): Promise<CursorResponse<any[]>>;
2289
+ }
2290
+
2291
+ interface L2OrderBookParams {
2292
+ timestamp?: number | string;
2293
+ depth?: number;
2294
+ }
2295
+ /**
2296
+ * L2 Full-Depth Order Book API resource (derived from L4 data)
2297
+ *
2298
+ * Access aggregated price-level orderbook snapshots, history, and tick-level diffs.
2299
+ * Data available from March 10, 2026.
2300
+ *
2301
+ * @example
2302
+ * ```typescript
2303
+ * // Get current full-depth L2 orderbook
2304
+ * const orderbook = await client.hyperliquid.l2Orderbook.get('BTC');
2305
+ *
2306
+ * // Get L2 orderbook at a historical timestamp
2307
+ * const historical = await client.hyperliquid.l2Orderbook.get('BTC', {
2308
+ * timestamp: 1711900800000
2309
+ * });
2310
+ *
2311
+ * // Get L2 orderbook history
2312
+ * const history = await client.hyperliquid.l2Orderbook.history('BTC', {
2313
+ * start: Date.now() - 86400000,
2314
+ * end: Date.now(),
2315
+ * limit: 100
2316
+ * });
2317
+ * ```
2318
+ */
2319
+ declare class L2OrderBookResource {
2320
+ private http;
2321
+ private basePath;
2322
+ private coinTransform;
2323
+ constructor(http: HttpClient, basePath?: string, coinTransform?: (s: string) => string);
2324
+ /** Get full-depth L2 order book snapshot. */
2325
+ get(symbol: string, params?: L2OrderBookParams): Promise<any>;
2326
+ /** Get paginated L2 full-depth history. */
2327
+ history(symbol: string, params: CursorPaginationParams & {
2328
+ depth?: number;
2329
+ }): Promise<CursorResponse<any[]>>;
2330
+ /** Get tick-level L2 order book diffs. */
2331
+ diffs(symbol: string, params: CursorPaginationParams): Promise<CursorResponse<any[]>>;
2332
+ }
2333
+
2334
+ interface L3OrderBookParams {
2335
+ timestamp?: number | string;
2336
+ depth?: number;
2337
+ }
2338
+ /**
2339
+ * L3 Order Book API resource (Lighter only)
2340
+ *
2341
+ * Access L3 orderbook snapshots and history from Lighter.xyz.
2342
+ *
2343
+ * @example
2344
+ * ```typescript
2345
+ * // Get current L3 orderbook
2346
+ * const orderbook = await client.lighter.l3Orderbook.get('BTC');
2347
+ *
2348
+ * // Get L3 orderbook history
2349
+ * const history = await client.lighter.l3Orderbook.history('BTC', {
2350
+ * start: Date.now() - 86400000,
2351
+ * end: Date.now(),
2352
+ * limit: 1000
2353
+ * });
2354
+ * ```
2355
+ */
2356
+ declare class L3OrderBookResource {
2357
+ private http;
2358
+ private basePath;
2359
+ private coinTransform;
2360
+ constructor(http: HttpClient, basePath?: string, coinTransform?: (s: string) => string);
2361
+ /**
2362
+ * Get L3 order book snapshot for a symbol
2363
+ *
2364
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
2365
+ * @param params - Optional parameters (timestamp, depth)
2366
+ * @returns L3 order book snapshot
2367
+ */
2368
+ get(symbol: string, params?: L3OrderBookParams): Promise<any>;
2369
+ /**
2370
+ * Get L3 order book history with cursor-based pagination
2371
+ *
2372
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
2373
+ * @param params - Time range and cursor pagination parameters
2374
+ * @returns CursorResponse with L3 orderbook snapshots and nextCursor for pagination
2375
+ */
2376
+ history(symbol: string, params: CursorPaginationParams): Promise<CursorResponse<any[]>>;
2377
+ }
2378
+
2141
2379
  /**
2142
2380
  * Hyperliquid exchange client
2143
2381
  *
@@ -2179,6 +2417,18 @@ declare class HyperliquidClient {
2179
2417
  * Liquidation events (May 2025+)
2180
2418
  */
2181
2419
  readonly liquidations: LiquidationsResource;
2420
+ /**
2421
+ * Order history, flow, and TP/SL
2422
+ */
2423
+ readonly orders: OrdersResource;
2424
+ /**
2425
+ * L4 order book (snapshots, diffs, history)
2426
+ */
2427
+ readonly l4Orderbook: L4OrderBookResource;
2428
+ /**
2429
+ * L2 full-depth order book (derived from L4)
2430
+ */
2431
+ readonly l2Orderbook: L2OrderBookResource;
2182
2432
  /**
2183
2433
  * HIP-3 builder-deployed perpetuals (February 2026+)
2184
2434
  */
@@ -2186,27 +2436,27 @@ declare class HyperliquidClient {
2186
2436
  private http;
2187
2437
  constructor(http: HttpClient);
2188
2438
  /**
2189
- * Get per-coin data freshness across all data types
2439
+ * Get per-symbol data freshness across all data types
2190
2440
  *
2191
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
2192
- * @returns Per-coin freshness with last_updated and lag_ms for each data type
2441
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
2442
+ * @returns Per-symbol freshness with last_updated and lag_ms for each data type
2193
2443
  */
2194
- freshness(coin: string): Promise<CoinFreshness>;
2444
+ freshness(symbol: string): Promise<CoinFreshness>;
2195
2445
  /**
2196
2446
  * Get combined market summary (price, funding, OI, volume, liquidations) in one call
2197
2447
  *
2198
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
2448
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
2199
2449
  * @returns Combined market summary
2200
2450
  */
2201
- summary(coin: string): Promise<CoinSummary>;
2451
+ summary(symbol: string): Promise<CoinSummary>;
2202
2452
  /**
2203
2453
  * Get mark/oracle/mid price history (projected from OI data)
2204
2454
  *
2205
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
2455
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
2206
2456
  * @param params - Time range, cursor, and interval parameters
2207
2457
  * @returns CursorResponse with price snapshots
2208
2458
  */
2209
- priceHistory(coin: string, params: PriceHistoryParams): Promise<CursorResponse<PriceSnapshot[]>>;
2459
+ priceHistory(symbol: string, params: PriceHistoryParams): Promise<CursorResponse<PriceSnapshot[]>>;
2210
2460
  }
2211
2461
  /**
2212
2462
  * HIP-3 builder-deployed perpetuals client
@@ -2246,30 +2496,46 @@ declare class Hip3Client {
2246
2496
  * OHLCV candle data
2247
2497
  */
2248
2498
  readonly candles: CandlesResource;
2499
+ /**
2500
+ * Liquidation events
2501
+ */
2502
+ readonly liquidations: LiquidationsResource;
2503
+ /**
2504
+ * Order history, flow, and TP/SL
2505
+ */
2506
+ readonly orders: OrdersResource;
2507
+ /**
2508
+ * L4 order book (snapshots, diffs, history)
2509
+ */
2510
+ readonly l4Orderbook: L4OrderBookResource;
2511
+ /**
2512
+ * L2 full-depth order book (derived from L4)
2513
+ */
2514
+ readonly l2Orderbook: L2OrderBookResource;
2249
2515
  private http;
2250
2516
  constructor(http: HttpClient);
2251
2517
  /**
2252
- * Get per-coin data freshness across all data types
2518
+ * Get per-symbol data freshness across all data types
2253
2519
  *
2254
- * @param coin - The coin symbol (case-sensitive, e.g., 'km:US500')
2255
- * @returns Per-coin freshness with last_updated and lag_ms for each data type
2520
+ * @param symbol - The symbol (case-sensitive, e.g., 'km:US500')
2521
+ * @returns Per-symbol freshness with last_updated and lag_ms for each data type
2256
2522
  */
2257
- freshness(coin: string): Promise<CoinFreshness>;
2523
+ freshness(symbol: string): Promise<CoinFreshness>;
2258
2524
  /**
2259
2525
  * Get combined market summary (price, funding, OI) in one call
2260
2526
  *
2261
- * @param coin - The coin symbol (case-sensitive, e.g., 'km:US500')
2527
+ * @param symbol - The symbol (case-sensitive, e.g., 'km:US500')
2262
2528
  * @returns Combined market summary
2263
2529
  */
2264
- summary(coin: string): Promise<CoinSummary>;
2530
+ summary(symbol: string): Promise<CoinSummary>;
2265
2531
  /**
2266
2532
  * Get mark/oracle/mid price history (projected from OI data)
2267
2533
  *
2268
- * @param coin - The coin symbol (case-sensitive, e.g., 'km:US500')
2534
+ * @param symbol - The symbol (case-sensitive, e.g., 'km:US500')
2269
2535
  * @param params - Time range, cursor, and interval parameters
2270
2536
  * @returns CursorResponse with price snapshots
2271
2537
  */
2272
- priceHistory(coin: string, params: PriceHistoryParams): Promise<CursorResponse<PriceSnapshot[]>>;
2538
+ priceHistory(symbol: string, params: PriceHistoryParams): Promise<CursorResponse<PriceSnapshot[]>>;
2273
2539
  }
2274
2540
  /**
2275
2541
  * Lighter.xyz exchange client
@@ -2310,30 +2576,34 @@ declare class LighterClient {
2310
2576
  * OHLCV candle data
2311
2577
  */
2312
2578
  readonly candles: CandlesResource;
2579
+ /**
2580
+ * L3 order book (Lighter only)
2581
+ */
2582
+ readonly l3Orderbook: L3OrderBookResource;
2313
2583
  private http;
2314
2584
  constructor(http: HttpClient);
2315
2585
  /**
2316
- * Get per-coin data freshness across all data types
2586
+ * Get per-symbol data freshness across all data types
2317
2587
  *
2318
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
2319
- * @returns Per-coin freshness with last_updated and lag_ms for each data type
2588
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
2589
+ * @returns Per-symbol freshness with last_updated and lag_ms for each data type
2320
2590
  */
2321
- freshness(coin: string): Promise<CoinFreshness>;
2591
+ freshness(symbol: string): Promise<CoinFreshness>;
2322
2592
  /**
2323
2593
  * Get combined market summary (price, funding, OI) in one call
2324
2594
  *
2325
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
2595
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
2326
2596
  * @returns Combined market summary
2327
2597
  */
2328
- summary(coin: string): Promise<CoinSummary>;
2598
+ summary(symbol: string): Promise<CoinSummary>;
2329
2599
  /**
2330
2600
  * Get mark/oracle price history (projected from OI data)
2331
2601
  *
2332
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
2602
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
2333
2603
  * @param params - Time range, cursor, and interval parameters
2334
2604
  * @returns CursorResponse with price snapshots
2335
2605
  */
2336
- priceHistory(coin: string, params: PriceHistoryParams): Promise<CursorResponse<PriceSnapshot[]>>;
2606
+ priceHistory(symbol: string, params: PriceHistoryParams): Promise<CursorResponse<PriceSnapshot[]>>;
2337
2607
  }
2338
2608
 
2339
2609
  /**
@@ -2784,6 +3054,109 @@ declare class OxArchiveWs {
2784
3054
  private handleMessage;
2785
3055
  }
2786
3056
 
3057
+ /**
3058
+ * L4 order book reconstructor with matching engine.
3059
+ *
3060
+ * Reconstructs Hyperliquid and HIP-3 L4 order books from checkpoints and diffs.
3061
+ * The same class works for both exchanges — the diff format is identical.
3062
+ *
3063
+ * When a new order crosses the spread, the matching engine filled opposite-side
3064
+ * orders at crossing prices. Without removing them, the reconstructed book will
3065
+ * be "crossed" (best bid > best ask).
3066
+ *
3067
+ * Ref: https://github.com/hyperliquid-dex/order_book_server
3068
+ */
3069
+ interface L4Order {
3070
+ oid: number;
3071
+ userAddress: string;
3072
+ side: 'B' | 'A';
3073
+ price: number;
3074
+ size: number;
3075
+ }
3076
+ interface L2Level {
3077
+ px: number;
3078
+ sz: number;
3079
+ n: number;
3080
+ }
3081
+ interface L4Diff {
3082
+ diff_type?: 'new' | 'update' | 'remove';
3083
+ diffType?: 'new' | 'update' | 'remove';
3084
+ oid: number;
3085
+ side: 'B' | 'A';
3086
+ price: number;
3087
+ new_size?: number | null;
3088
+ newSize?: number | null;
3089
+ user_address?: string;
3090
+ userAddress?: string;
3091
+ block_number?: number;
3092
+ blockNumber?: number;
3093
+ }
3094
+ interface L4Checkpoint {
3095
+ bids: Array<{
3096
+ oid: number;
3097
+ user_address?: string;
3098
+ userAddress?: string;
3099
+ side: string;
3100
+ price: number;
3101
+ size: number;
3102
+ }>;
3103
+ asks: Array<{
3104
+ oid: number;
3105
+ user_address?: string;
3106
+ userAddress?: string;
3107
+ side: string;
3108
+ price: number;
3109
+ size: number;
3110
+ }>;
3111
+ }
3112
+ /**
3113
+ * L4 orderbook reconstructor with matching engine.
3114
+ *
3115
+ * Works identically for Hyperliquid and HIP-3 — same diff format,
3116
+ * same checkpoint format, same crossing logic.
3117
+ *
3118
+ * @example
3119
+ * ```typescript
3120
+ * const book = new L4OrderBookReconstructor();
3121
+ * book.loadCheckpoint(checkpoint);
3122
+ *
3123
+ * // Group diffs by block, apply in order
3124
+ * for (const bn of sortedBlockNumbers) {
3125
+ * const nr = nonRestingByBlock.get(bn);
3126
+ * for (const diff of blocks.get(bn)!) {
3127
+ * book.applyDiff(diff, nr);
3128
+ * }
3129
+ * }
3130
+ *
3131
+ * console.log(book.isCrossed()); // false
3132
+ * const { bids: l2Bids, asks: l2Asks } = book.deriveL2();
3133
+ * ```
3134
+ */
3135
+ declare class L4OrderBookReconstructor {
3136
+ private orders;
3137
+ private bidPrices;
3138
+ private askPrices;
3139
+ /** Initialize from an L4 checkpoint. */
3140
+ loadCheckpoint(checkpoint: L4Checkpoint): void;
3141
+ /** Apply a single L4 diff with matching engine. */
3142
+ applyDiff(diff: L4Diff, nonRestingOids?: Set<number>): void;
3143
+ /** Return bids sorted by price descending. */
3144
+ bids(): L4Order[];
3145
+ /** Return asks sorted by price ascending. */
3146
+ asks(): L4Order[];
3147
+ bestBid(): number | null;
3148
+ bestAsk(): number | null;
3149
+ /** Check if the book is crossed. Should be false after correct reconstruction. */
3150
+ isCrossed(): boolean;
3151
+ get bidCount(): number;
3152
+ get askCount(): number;
3153
+ /** Aggregate L4 orders into L2 price levels. */
3154
+ deriveL2(): {
3155
+ bids: L2Level[];
3156
+ asks: L2Level[];
3157
+ };
3158
+ }
3159
+
2787
3160
  /**
2788
3161
  * Zod schemas for runtime validation of API responses
2789
3162
  *
@@ -5243,4 +5616,4 @@ type ValidatedCandle = z.infer<typeof CandleSchema>;
5243
5616
  type ValidatedLiquidation = z.infer<typeof LiquidationSchema>;
5244
5617
  type ValidatedWsServerMessage = z.infer<typeof WsServerMessageSchema>;
5245
5618
 
5246
- export { type ApiError, type ApiMeta, ApiMetaSchema, type ApiResponse, ApiResponseSchema, type Candle, CandleArrayResponseSchema, type CandleHistoryParams, type CandleInterval, CandleIntervalSchema, CandleSchema, type ClientOptions, type CoinFreshness, CoinFreshnessResponseSchema, CoinFreshnessSchema, type CoinSummary, CoinSummaryResponseSchema, CoinSummarySchema, type CompletenessMetrics, type CoverageGap, type CoverageResponse, type CursorResponse, type DataCadence, type DataFreshness, type DataTypeCoverage, type DataTypeFreshnessInfo, DataTypeFreshnessInfoSchema, type DataTypeStatus, type ExchangeCoverage, type ExchangeLatency, type ExchangeStatus, type FundingHistoryParams, type FundingRate, FundingRateArrayResponseSchema, FundingRateResponseSchema, FundingRateSchema, type GetOrderBookParams, type GetTradesCursorParams, Hip3Client, type Hip3Instrument, HyperliquidClient, type Incident, type IncidentSeverityValue, type IncidentStatusValue, type IncidentsResponse, type Instrument, InstrumentArrayResponseSchema, InstrumentResponseSchema, InstrumentSchema, type InstrumentType, InstrumentTypeSchema, type LatencyResponse, LighterClient, type LighterGranularity, type LighterInstrument, type Liquidation, LiquidationArrayResponseSchema, type LiquidationHistoryParams, LiquidationSchema, LiquidationSideSchema, type LiquidationVolume, LiquidationVolumeArrayResponseSchema, type LiquidationVolumeParams, LiquidationVolumeSchema, type LiquidationsByUserParams, type ListIncidentsParams, type OiFundingInterval, type OpenInterest, OpenInterestArrayResponseSchema, type OpenInterestHistoryParams, OpenInterestResponseSchema, OpenInterestSchema, type OrderBook, OrderBookArrayResponseSchema, type OrderBookHistoryParams, OrderBookReconstructor, OrderBookResponseSchema, OrderBookSchema, type OrderbookDelta, OxArchive, OxArchiveError, OxArchiveWs, type Pagination, type PriceHistoryParams, type PriceLevel, PriceLevelSchema, type PriceSnapshot, PriceSnapshotArrayResponseSchema, PriceSnapshotSchema, type ReconstructOptions, type ReconstructedOrderBook, type RestApiLatency, type SiweChallenge, type SlaActual, type SlaParams, type SlaResponse, type SlaTargets, type StatusResponse, type SymbolCoverageOptions, type SymbolCoverageResponse, type SymbolDataTypeCoverage, type SystemStatusValue, type TickData, type TickHistoryParams, type Timestamp, type TimestampedRecord, TimestampedRecordSchema, type Trade, TradeArrayResponseSchema, type TradeDirection, TradeDirectionSchema, TradeSchema, type TradeSide, TradeSideSchema, type ValidatedApiMeta, type ValidatedCandle, type ValidatedFundingRate, type ValidatedInstrument, type ValidatedLiquidation, type ValidatedOpenInterest, type ValidatedOrderBook, type ValidatedPriceLevel, type ValidatedTrade, type ValidatedWsServerMessage, type Web3ApiKey, type Web3KeysList, type Web3PaymentRequired, type Web3RevokeResult, type Web3SignupResult, type Web3SubscribeResult, type WebSocketLatency, type WsChannel, WsChannelSchema, type WsClientMessage, type WsConnectionState, WsConnectionStateSchema, type WsData, WsDataSchema, type WsError, WsErrorSchema, type WsEventHandlers, type WsGapDetected, type WsHistoricalBatch, WsHistoricalBatchSchema, type WsHistoricalData, WsHistoricalDataSchema, type WsHistoricalTickData, type WsOptions, type WsPing, type WsPong, WsPongSchema, type WsReplay, type WsReplayCompleted, WsReplayCompletedSchema, type WsReplayPause, type WsReplayPaused, WsReplayPausedSchema, type WsReplayResume, type WsReplayResumed, WsReplayResumedSchema, type WsReplaySeek, type WsReplaySnapshot, WsReplaySnapshotSchema, type WsReplayStarted, WsReplayStartedSchema, type WsReplayStop, type WsReplayStopped, WsReplayStoppedSchema, type WsServerMessage, WsServerMessageSchema, type WsStream, type WsStreamCompleted, WsStreamCompletedSchema, type WsStreamProgress, WsStreamProgressSchema, type WsStreamStarted, WsStreamStartedSchema, type WsStreamStop, type WsStreamStopped, WsStreamStoppedSchema, type WsSubscribe, type WsSubscribed, WsSubscribedSchema, type WsUnsubscribe, type WsUnsubscribed, WsUnsubscribedSchema, OxArchive as default, reconstructFinal, reconstructOrderBook };
5619
+ export { type ApiError, type ApiMeta, ApiMetaSchema, type ApiResponse, ApiResponseSchema, type Candle, CandleArrayResponseSchema, type CandleHistoryParams, type CandleInterval, CandleIntervalSchema, CandleSchema, type ClientOptions, type CoinFreshness, CoinFreshnessResponseSchema, CoinFreshnessSchema, type CoinSummary, CoinSummaryResponseSchema, CoinSummarySchema, type CompletenessMetrics, type CoverageGap, type CoverageResponse, type CursorResponse, type DataCadence, type DataFreshness, type DataTypeCoverage, type DataTypeFreshnessInfo, DataTypeFreshnessInfoSchema, type DataTypeStatus, type ExchangeCoverage, type ExchangeLatency, type ExchangeStatus, type FundingHistoryParams, type FundingRate, FundingRateArrayResponseSchema, FundingRateResponseSchema, FundingRateSchema, type GetOrderBookParams, type GetTradesCursorParams, Hip3Client, type Hip3Instrument, HyperliquidClient, type Incident, type IncidentSeverityValue, type IncidentStatusValue, type IncidentsResponse, type Instrument, InstrumentArrayResponseSchema, InstrumentResponseSchema, InstrumentSchema, type InstrumentType, InstrumentTypeSchema, type L2Level, type L2OrderBookParams, L2OrderBookResource, type L4Checkpoint, type L4Diff, type L4Order, L4OrderBookReconstructor, type LatencyResponse, LighterClient, type LighterGranularity, type LighterInstrument, type Liquidation, LiquidationArrayResponseSchema, type LiquidationHistoryParams, LiquidationSchema, LiquidationSideSchema, type LiquidationVolume, LiquidationVolumeArrayResponseSchema, type LiquidationVolumeParams, LiquidationVolumeSchema, type LiquidationsByUserParams, type ListIncidentsParams, type OiFundingInterval, type OpenInterest, OpenInterestArrayResponseSchema, type OpenInterestHistoryParams, OpenInterestResponseSchema, OpenInterestSchema, type OrderBook, OrderBookArrayResponseSchema, type OrderBookHistoryParams, OrderBookReconstructor, OrderBookResponseSchema, OrderBookSchema, type OrderbookDelta, OxArchive, OxArchiveError, OxArchiveWs, type Pagination, type PriceHistoryParams, type PriceLevel, PriceLevelSchema, type PriceSnapshot, PriceSnapshotArrayResponseSchema, PriceSnapshotSchema, type ReconstructOptions, type ReconstructedOrderBook, type RestApiLatency, type SiweChallenge, type SlaActual, type SlaParams, type SlaResponse, type SlaTargets, type StatusResponse, type SymbolCoverageOptions, type SymbolCoverageResponse, type SymbolDataTypeCoverage, type SystemStatusValue, type TickData, type TickHistoryParams, type Timestamp, type TimestampedRecord, TimestampedRecordSchema, type Trade, TradeArrayResponseSchema, type TradeDirection, TradeDirectionSchema, TradeSchema, type TradeSide, TradeSideSchema, type ValidatedApiMeta, type ValidatedCandle, type ValidatedFundingRate, type ValidatedInstrument, type ValidatedLiquidation, type ValidatedOpenInterest, type ValidatedOrderBook, type ValidatedPriceLevel, type ValidatedTrade, type ValidatedWsServerMessage, type Web3ApiKey, type Web3KeysList, type Web3PaymentRequired, type Web3RevokeResult, type Web3SignupResult, type Web3SubscribeResult, type WebSocketLatency, type WsChannel, WsChannelSchema, type WsClientMessage, type WsConnectionState, WsConnectionStateSchema, type WsData, WsDataSchema, type WsError, WsErrorSchema, type WsEventHandlers, type WsGapDetected, type WsHistoricalBatch, WsHistoricalBatchSchema, type WsHistoricalData, WsHistoricalDataSchema, type WsHistoricalTickData, type WsL4Batch, type WsL4Snapshot, type WsOptions, type WsPing, type WsPong, WsPongSchema, type WsReplay, type WsReplayCompleted, WsReplayCompletedSchema, type WsReplayPause, type WsReplayPaused, WsReplayPausedSchema, type WsReplayResume, type WsReplayResumed, WsReplayResumedSchema, type WsReplaySeek, type WsReplaySnapshot, WsReplaySnapshotSchema, type WsReplayStarted, WsReplayStartedSchema, type WsReplayStop, type WsReplayStopped, WsReplayStoppedSchema, type WsServerMessage, WsServerMessageSchema, type WsStream, type WsStreamCompleted, WsStreamCompletedSchema, type WsStreamProgress, WsStreamProgressSchema, type WsStreamStarted, WsStreamStartedSchema, type WsStreamStop, type WsStreamStopped, WsStreamStoppedSchema, type WsSubscribe, type WsSubscribed, WsSubscribedSchema, type WsUnsubscribe, type WsUnsubscribed, WsUnsubscribedSchema, OxArchive as default, reconstructFinal, reconstructOrderBook };