@nktkas/hyperliquid 0.20.0 → 0.21.1

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.
Files changed (76) hide show
  1. package/README.md +40 -50
  2. package/esm/mod.d.ts +3 -4
  3. package/esm/mod.d.ts.map +1 -1
  4. package/esm/mod.js +3 -4
  5. package/{script/src/clients/wallet.d.ts → esm/src/clients/exchange.d.ts} +100 -100
  6. package/esm/src/clients/exchange.d.ts.map +1 -0
  7. package/esm/src/clients/{wallet.js → exchange.js} +41 -41
  8. package/esm/src/clients/{public.d.ts → info.d.ts} +100 -100
  9. package/esm/src/clients/info.d.ts.map +1 -0
  10. package/esm/src/clients/{public.js → info.js} +51 -51
  11. package/{script/src/clients/event.d.ts → esm/src/clients/subscription.d.ts} +60 -78
  12. package/esm/src/clients/subscription.d.ts.map +1 -0
  13. package/esm/src/clients/{event.js → subscription.js} +57 -79
  14. package/esm/src/signing.d.ts +0 -1
  15. package/esm/src/signing.d.ts.map +1 -1
  16. package/esm/src/signing.js +0 -1
  17. package/esm/src/transports/base.d.ts +5 -7
  18. package/esm/src/transports/base.d.ts.map +1 -1
  19. package/esm/src/transports/websocket/_reconnecting_websocket.d.ts +3 -2
  20. package/esm/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
  21. package/esm/src/transports/websocket/_reconnecting_websocket.js +11 -5
  22. package/esm/src/transports/websocket/_websocket_async_request.d.ts +6 -4
  23. package/esm/src/transports/websocket/_websocket_async_request.d.ts.map +1 -1
  24. package/esm/src/transports/websocket/_websocket_async_request.js +47 -28
  25. package/esm/src/transports/websocket/websocket_transport.d.ts +24 -21
  26. package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  27. package/esm/src/transports/websocket/websocket_transport.js +60 -57
  28. package/esm/src/types/info/accounts.d.ts +12 -0
  29. package/esm/src/types/info/accounts.d.ts.map +1 -1
  30. package/esm/src/types/mod.d.ts +0 -1
  31. package/esm/src/types/mod.d.ts.map +1 -1
  32. package/esm/src/types/mod.js +1 -1
  33. package/package.json +1 -1
  34. package/script/mod.d.ts +3 -4
  35. package/script/mod.d.ts.map +1 -1
  36. package/script/mod.js +4 -5
  37. package/{esm/src/clients/wallet.d.ts → script/src/clients/exchange.d.ts} +100 -100
  38. package/script/src/clients/exchange.d.ts.map +1 -0
  39. package/script/src/clients/{wallet.js → exchange.js} +43 -43
  40. package/script/src/clients/{public.d.ts → info.d.ts} +100 -100
  41. package/script/src/clients/info.d.ts.map +1 -0
  42. package/script/src/clients/{public.js → info.js} +53 -53
  43. package/{esm/src/clients/event.d.ts → script/src/clients/subscription.d.ts} +60 -78
  44. package/script/src/clients/subscription.d.ts.map +1 -0
  45. package/script/src/clients/{event.js → subscription.js} +59 -81
  46. package/script/src/signing.d.ts +0 -1
  47. package/script/src/signing.d.ts.map +1 -1
  48. package/script/src/signing.js +52 -53
  49. package/script/src/transports/base.d.ts +5 -7
  50. package/script/src/transports/base.d.ts.map +1 -1
  51. package/script/src/transports/websocket/_reconnecting_websocket.d.ts +3 -2
  52. package/script/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
  53. package/script/src/transports/websocket/_reconnecting_websocket.js +11 -5
  54. package/script/src/transports/websocket/_websocket_async_request.d.ts +6 -4
  55. package/script/src/transports/websocket/_websocket_async_request.d.ts.map +1 -1
  56. package/script/src/transports/websocket/_websocket_async_request.js +47 -28
  57. package/script/src/transports/websocket/websocket_transport.d.ts +24 -21
  58. package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  59. package/script/src/transports/websocket/websocket_transport.js +60 -57
  60. package/script/src/types/info/accounts.d.ts +12 -0
  61. package/script/src/types/info/accounts.d.ts.map +1 -1
  62. package/script/src/types/mod.d.ts +0 -1
  63. package/script/src/types/mod.d.ts.map +1 -1
  64. package/script/src/types/mod.js +24 -25
  65. package/esm/_dnt.polyfills.d.ts +0 -20
  66. package/esm/_dnt.polyfills.d.ts.map +0 -1
  67. package/esm/_dnt.polyfills.js +0 -12
  68. package/esm/src/clients/event.d.ts.map +0 -1
  69. package/esm/src/clients/public.d.ts.map +0 -1
  70. package/esm/src/clients/wallet.d.ts.map +0 -1
  71. package/script/_dnt.polyfills.d.ts +0 -20
  72. package/script/_dnt.polyfills.d.ts.map +0 -1
  73. package/script/_dnt.polyfills.js +0 -23
  74. package/script/src/clients/event.d.ts.map +0 -1
  75. package/script/src/clients/public.d.ts.map +0 -1
  76. package/script/src/clients/wallet.d.ts.map +0 -1
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Event client for subscribing to various Hyperliquid events.
2
+ * Subscription client for subscribing to various Hyperliquid events.
3
3
  * @typeParam T The type of transport used to connect to the Hyperliquid Websocket API.
4
4
  */
5
- export class EventClient {
5
+ export class SubscriptionClient {
6
6
  transport;
7
7
  /**
8
8
  * Initialises a new instance.
@@ -13,7 +13,7 @@ export class EventClient {
13
13
  * import * as hl from "@nktkas/hyperliquid";
14
14
  *
15
15
  * const transport = new hl.WebSocketTransport();
16
- * const client = new hl.EventClient({ transport });
16
+ * const subsClient = new hl.SubscriptionClient({ transport });
17
17
  * ```
18
18
  */
19
19
  constructor(args) {
@@ -23,7 +23,6 @@ export class EventClient {
23
23
  * Subscribe to context updates for a specific perpetual asset.
24
24
  * @param args - The parameters for the subscription.
25
25
  * @param listener - The callback function to be called when the event is received.
26
- * @param signal - An optional abort signal for canceling the subscription request.
27
26
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
28
27
  *
29
28
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
@@ -32,14 +31,14 @@ export class EventClient {
32
31
  * import * as hl from "@nktkas/hyperliquid";
33
32
  *
34
33
  * const transport = new hl.WebSocketTransport();
35
- * const client = new hl.EventClient({ transport });
34
+ * const subsClient = new hl.SubscriptionClient({ transport });
36
35
  *
37
36
  * const sub = await client.activeAssetCtx({ coin: "BTC" }, (data) => {
38
37
  * console.log(data);
39
38
  * });
40
39
  * ```
41
40
  */
42
- activeAssetCtx(args, listener, signal) {
41
+ activeAssetCtx(args, listener) {
43
42
  const channel = args.coin.startsWith("@") ? "activeSpotAssetCtx" : "activeAssetCtx";
44
43
  const payload = {
45
44
  type: "activeAssetCtx",
@@ -49,13 +48,12 @@ export class EventClient {
49
48
  if (e.detail.coin === args.coin) {
50
49
  listener(e.detail);
51
50
  }
52
- }, signal);
51
+ });
53
52
  }
54
53
  /**
55
54
  * Subscribe to trading data updates for a specific asset and user.
56
55
  * @param args - The parameters for the subscription.
57
56
  * @param listener - The callback function to be called when the event is received.
58
- * @param signal - An optional abort signal for canceling the subscription request.
59
57
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
60
58
  *
61
59
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
@@ -64,14 +62,14 @@ export class EventClient {
64
62
  * import * as hl from "@nktkas/hyperliquid";
65
63
  *
66
64
  * const transport = new hl.WebSocketTransport();
67
- * const client = new hl.EventClient({ transport });
65
+ * const subsClient = new hl.SubscriptionClient({ transport });
68
66
  *
69
67
  * const sub = await client.activeAssetData({ coin: "BTC", user: "0x..." }, (data) => {
70
68
  * console.log(data);
71
69
  * });
72
70
  * ```
73
71
  */
74
- activeAssetData(args, listener, signal) {
72
+ activeAssetData(args, listener) {
75
73
  const payload = {
76
74
  type: "activeAssetData",
77
75
  coin: args.coin,
@@ -81,29 +79,23 @@ export class EventClient {
81
79
  if (e.detail.coin === args.coin && e.detail.user === args.user.toLowerCase()) {
82
80
  listener(e.detail);
83
81
  }
84
- }, signal);
82
+ });
85
83
  }
86
- allMids(args_or_listener, listener_or_signal, maybeSignal) {
84
+ allMids(args_or_listener, maybeListener) {
87
85
  const args = typeof args_or_listener === "function" ? {} : args_or_listener;
88
- const listener = typeof args_or_listener === "function"
89
- ? args_or_listener
90
- : listener_or_signal;
91
- const signal = typeof args_or_listener === "function"
92
- ? listener_or_signal
93
- : maybeSignal;
86
+ const listener = typeof args_or_listener === "function" ? args_or_listener : maybeListener;
94
87
  const payload = {
95
88
  type: "allMids",
96
89
  dex: args.dex,
97
90
  };
98
91
  return this.transport.subscribe(payload.type, payload, (e) => {
99
92
  listener(e.detail);
100
- }, signal);
93
+ });
101
94
  }
102
95
  /**
103
96
  * Subscribe to best bid and offer updates for a specific asset.
104
97
  * @param args - The parameters for the subscription.
105
98
  * @param listener - The callback function to be called when the event is received.
106
- * @param signal - An optional abort signal for canceling the subscription request.
107
99
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
108
100
  *
109
101
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
@@ -112,14 +104,14 @@ export class EventClient {
112
104
  * import * as hl from "@nktkas/hyperliquid";
113
105
  *
114
106
  * const transport = new hl.WebSocketTransport();
115
- * const client = new hl.EventClient({ transport });
107
+ * const subsClient = new hl.SubscriptionClient({ transport });
116
108
  *
117
109
  * const sub = await client.bbo({ coin: "BTC" }, (data) => {
118
110
  * console.log(data);
119
111
  * });
120
112
  * ```
121
113
  */
122
- bbo(args, listener, signal) {
114
+ bbo(args, listener) {
123
115
  const payload = {
124
116
  type: "bbo",
125
117
  coin: args.coin,
@@ -128,13 +120,12 @@ export class EventClient {
128
120
  if (e.detail.coin === args.coin) {
129
121
  listener(e.detail);
130
122
  }
131
- }, signal);
123
+ });
132
124
  }
133
125
  /**
134
126
  * Subscribe to candlestick data updates for a specific asset.
135
127
  * @param args - The parameters for the subscription.
136
128
  * @param listener - The callback function to be called when the event is received.
137
- * @param signal - An optional abort signal for canceling the subscription request.
138
129
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
139
130
  *
140
131
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
@@ -143,14 +134,14 @@ export class EventClient {
143
134
  * import * as hl from "@nktkas/hyperliquid";
144
135
  *
145
136
  * const transport = new hl.WebSocketTransport();
146
- * const client = new hl.EventClient({ transport });
137
+ * const subsClient = new hl.SubscriptionClient({ transport });
147
138
  *
148
139
  * const sub = await client.candle({ coin: "BTC", interval: "1h" }, (data) => {
149
140
  * console.log(data);
150
141
  * });
151
142
  * ```
152
143
  */
153
- candle(args, listener, signal) {
144
+ candle(args, listener) {
154
145
  const payload = {
155
146
  type: "candle",
156
147
  coin: args.coin,
@@ -160,12 +151,11 @@ export class EventClient {
160
151
  if (e.detail.s === args.coin && e.detail.i === args.interval) {
161
152
  listener(e.detail);
162
153
  }
163
- }, signal);
154
+ });
164
155
  }
165
156
  /**
166
157
  * Subscribe to explorer block updates.
167
158
  * @param listener - The callback function to be called when the event is received.
168
- * @param signal - An optional abort signal for canceling the subscription request.
169
159
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
170
160
  * @note Make sure the endpoint in the {@link transport} supports this method.
171
161
  *
@@ -175,25 +165,24 @@ export class EventClient {
175
165
  * import * as hl from "@nktkas/hyperliquid";
176
166
  *
177
167
  * const transport = new hl.WebSocketTransport();
178
- * const client = new hl.EventClient({ transport });
168
+ * const subsClient = new hl.SubscriptionClient({ transport });
179
169
  *
180
170
  * const sub = await client.explorerBlock((data) => {
181
171
  * console.log(data);
182
172
  * });
183
173
  * ```
184
174
  */
185
- explorerBlock(listener, signal) {
175
+ explorerBlock(listener) {
186
176
  const payload = {
187
177
  type: "explorerBlock",
188
178
  };
189
179
  return this.transport.subscribe("_explorerBlock", payload, (e) => {
190
180
  listener(e.detail);
191
- }, signal);
181
+ });
192
182
  }
193
183
  /**
194
184
  * Subscribe to explorer transaction updates.
195
185
  * @param listener - The callback function to be called when the event is received.
196
- * @param signal - An optional abort signal for canceling the subscription request.
197
186
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
198
187
  * @note Make sure the endpoint in the {@link transport} supports this method.
199
188
  *
@@ -203,26 +192,25 @@ export class EventClient {
203
192
  * import * as hl from "@nktkas/hyperliquid";
204
193
  *
205
194
  * const transport = new hl.WebSocketTransport();
206
- * const client = new hl.EventClient({ transport });
195
+ * const subsClient = new hl.SubscriptionClient({ transport });
207
196
  *
208
197
  * const sub = await client.explorerTxs((data) => {
209
198
  * console.log(data);
210
199
  * });
211
200
  * ```
212
201
  */
213
- explorerTxs(listener, signal) {
202
+ explorerTxs(listener) {
214
203
  const payload = {
215
204
  type: "explorerTxs",
216
205
  };
217
206
  return this.transport.subscribe("_explorerTxs", payload, (e) => {
218
207
  listener(e.detail);
219
- }, signal);
208
+ });
220
209
  }
221
210
  /**
222
211
  * Subscribe to L2 order book updates for a specific asset.
223
212
  * @param args - The parameters for the subscription.
224
213
  * @param listener - The callback function to be called when the event is received.
225
- * @param signal - An optional abort signal for canceling the subscription request.
226
214
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
227
215
  *
228
216
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
@@ -231,14 +219,14 @@ export class EventClient {
231
219
  * import * as hl from "@nktkas/hyperliquid";
232
220
  *
233
221
  * const transport = new hl.WebSocketTransport();
234
- * const client = new hl.EventClient({ transport });
222
+ * const subsClient = new hl.SubscriptionClient({ transport });
235
223
  *
236
224
  * const sub = await client.l2Book({ coin: "BTC" }, (data) => {
237
225
  * console.log(data);
238
226
  * });
239
227
  * ```
240
228
  */
241
- l2Book(args, listener, signal) {
229
+ l2Book(args, listener) {
242
230
  const payload = {
243
231
  type: "l2Book",
244
232
  coin: args.coin,
@@ -249,13 +237,12 @@ export class EventClient {
249
237
  if (e.detail.coin === args.coin) {
250
238
  listener(e.detail);
251
239
  }
252
- }, signal);
240
+ });
253
241
  }
254
242
  /**
255
243
  * Subscribe to notification updates for a specific user.
256
244
  * @param args - The parameters for the subscription.
257
245
  * @param listener - The callback function to be called when the event is received.
258
- * @param signal - An optional abort signal for canceling the subscription request.
259
246
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
260
247
  *
261
248
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
@@ -264,27 +251,26 @@ export class EventClient {
264
251
  * import * as hl from "@nktkas/hyperliquid";
265
252
  *
266
253
  * const transport = new hl.WebSocketTransport();
267
- * const client = new hl.EventClient({ transport });
254
+ * const subsClient = new hl.SubscriptionClient({ transport });
268
255
  *
269
256
  * const sub = await client.notification({ user: "0x..." }, (data) => {
270
257
  * console.log(data);
271
258
  * });
272
259
  * ```
273
260
  */
274
- notification(args, listener, signal) {
261
+ notification(args, listener) {
275
262
  const payload = {
276
263
  type: "notification",
277
264
  user: args.user,
278
265
  };
279
266
  return this.transport.subscribe(payload.type, payload, (e) => {
280
267
  listener(e.detail);
281
- }, signal);
268
+ });
282
269
  }
283
270
  /**
284
271
  * Subscribe to order status updates for a specific user.
285
272
  * @param args - The parameters for the subscription.
286
273
  * @param listener - The callback function to be called when the event is received.
287
- * @param signal - An optional abort signal for canceling the subscription request.
288
274
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
289
275
  *
290
276
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
@@ -293,27 +279,26 @@ export class EventClient {
293
279
  * import * as hl from "@nktkas/hyperliquid";
294
280
  *
295
281
  * const transport = new hl.WebSocketTransport();
296
- * const client = new hl.EventClient({ transport });
282
+ * const subsClient = new hl.SubscriptionClient({ transport });
297
283
  *
298
284
  * const sub = await client.orderUpdates({ user: "0x..." }, (data) => {
299
285
  * console.log(data);
300
286
  * });
301
287
  * ```
302
288
  */
303
- orderUpdates(args, listener, signal) {
289
+ orderUpdates(args, listener) {
304
290
  const payload = {
305
291
  type: "orderUpdates",
306
292
  user: args.user,
307
293
  };
308
294
  return this.transport.subscribe(payload.type, payload, (e) => {
309
295
  listener(e.detail);
310
- }, signal);
296
+ });
311
297
  }
312
298
  /**
313
299
  * Subscribe to real-time trade updates for a specific asset.
314
300
  * @param args - The parameters for the subscription.
315
301
  * @param listener - The callback function to be called when the event is received.
316
- * @param signal - An optional abort signal for canceling the subscription request.
317
302
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
318
303
  *
319
304
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
@@ -322,14 +307,14 @@ export class EventClient {
322
307
  * import * as hl from "@nktkas/hyperliquid";
323
308
  *
324
309
  * const transport = new hl.WebSocketTransport();
325
- * const client = new hl.EventClient({ transport });
310
+ * const subsClient = new hl.SubscriptionClient({ transport });
326
311
  *
327
312
  * const sub = await client.trades({ coin: "BTC" }, (data) => {
328
313
  * console.log(data);
329
314
  * });
330
315
  * ```
331
316
  */
332
- trades(args, listener, signal) {
317
+ trades(args, listener) {
333
318
  const payload = {
334
319
  type: "trades",
335
320
  coin: args.coin,
@@ -338,13 +323,12 @@ export class EventClient {
338
323
  if (e.detail[0]?.coin === args.coin) {
339
324
  listener(e.detail);
340
325
  }
341
- }, signal);
326
+ });
342
327
  }
343
328
  /**
344
329
  * Subscribe to non-order events for a specific user.
345
330
  * @param args - The parameters for the subscription.
346
331
  * @param listener - The callback function to be called when the event is received.
347
- * @param signal - An optional abort signal for canceling the subscription request.
348
332
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
349
333
  *
350
334
  * @note Different subscriptions cannot be distinguished from each other.
@@ -355,27 +339,26 @@ export class EventClient {
355
339
  * import * as hl from "@nktkas/hyperliquid";
356
340
  *
357
341
  * const transport = new hl.WebSocketTransport();
358
- * const client = new hl.EventClient({ transport });
342
+ * const subsClient = new hl.SubscriptionClient({ transport });
359
343
  *
360
344
  * const sub = await client.userEvents({ user: "0x..." }, (data) => {
361
345
  * console.log(data);
362
346
  * });
363
347
  * ```
364
348
  */
365
- userEvents(args, listener, signal) {
349
+ userEvents(args, listener) {
366
350
  const payload = {
367
351
  type: "userEvents",
368
352
  user: args.user,
369
353
  };
370
354
  return this.transport.subscribe("user", payload, (e) => {
371
355
  listener(e.detail);
372
- }, signal);
356
+ });
373
357
  }
374
358
  /**
375
359
  * Subscribe to trade fill updates for a specific user.
376
360
  * @param args - The parameters for the subscription.
377
361
  * @param listener - The callback function to be called when the event is received.
378
- * @param signal - An optional abort signal for canceling the subscription request.
379
362
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
380
363
  *
381
364
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
@@ -384,14 +367,14 @@ export class EventClient {
384
367
  * import * as hl from "@nktkas/hyperliquid";
385
368
  *
386
369
  * const transport = new hl.WebSocketTransport();
387
- * const client = new hl.EventClient({ transport });
370
+ * const subsClient = new hl.SubscriptionClient({ transport });
388
371
  *
389
372
  * const sub = await client.userFills({ user: "0x..." }, (data) => {
390
373
  * console.log(data);
391
374
  * });
392
375
  * ```
393
376
  */
394
- userFills(args, listener, signal) {
377
+ userFills(args, listener) {
395
378
  const payload = {
396
379
  type: "userFills",
397
380
  user: args.user,
@@ -401,13 +384,12 @@ export class EventClient {
401
384
  if (e.detail.user === args.user.toLowerCase()) {
402
385
  listener(e.detail);
403
386
  }
404
- }, signal);
387
+ });
405
388
  }
406
389
  /**
407
390
  * Subscribe to funding payment updates for a specific user.
408
391
  * @param args - The parameters for the subscription.
409
392
  * @param listener - The callback function to be called when the event is received.
410
- * @param signal - An optional abort signal for canceling the subscription request.
411
393
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
412
394
  *
413
395
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
@@ -416,14 +398,14 @@ export class EventClient {
416
398
  * import * as hl from "@nktkas/hyperliquid";
417
399
  *
418
400
  * const transport = new hl.WebSocketTransport();
419
- * const client = new hl.EventClient({ transport });
401
+ * const subsClient = new hl.SubscriptionClient({ transport });
420
402
  *
421
403
  * const sub = await client.userFundings({ user: "0x..." }, (data) => {
422
404
  * console.log(data);
423
405
  * });
424
406
  * ```
425
407
  */
426
- userFundings(args, listener, signal) {
408
+ userFundings(args, listener) {
427
409
  const payload = {
428
410
  type: "userFundings",
429
411
  user: args.user,
@@ -432,13 +414,12 @@ export class EventClient {
432
414
  if (e.detail.user === args.user.toLowerCase()) {
433
415
  listener(e.detail);
434
416
  }
435
- }, signal);
417
+ });
436
418
  }
437
419
  /**
438
420
  * Subscribe to non-funding ledger updates for a specific user.
439
421
  * @param args - The parameters for the subscription.
440
422
  * @param listener - The callback function to be called when the event is received.
441
- * @param signal - An optional abort signal for canceling the subscription request.
442
423
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
443
424
  *
444
425
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
@@ -447,14 +428,14 @@ export class EventClient {
447
428
  * import * as hl from "@nktkas/hyperliquid";
448
429
  *
449
430
  * const transport = new hl.WebSocketTransport();
450
- * const client = new hl.EventClient({ transport });
431
+ * const subsClient = new hl.SubscriptionClient({ transport });
451
432
  *
452
433
  * const sub = await client.userNonFundingLedgerUpdates({ user: "0x..." }, (data) => {
453
434
  * console.log(data);
454
435
  * });
455
436
  * ```
456
437
  */
457
- userNonFundingLedgerUpdates(args, listener, signal) {
438
+ userNonFundingLedgerUpdates(args, listener) {
458
439
  const payload = {
459
440
  type: "userNonFundingLedgerUpdates",
460
441
  user: args.user,
@@ -463,13 +444,12 @@ export class EventClient {
463
444
  if (e.detail.user === args.user.toLowerCase()) {
464
445
  listener(e.detail);
465
446
  }
466
- }, signal);
447
+ });
467
448
  }
468
449
  /**
469
450
  * Subscribe to TWAP order history updates for a specific user.
470
451
  * @param args - The parameters for the subscription.
471
452
  * @param listener - The callback function to be called when the event is received.
472
- * @param signal - An optional abort signal for canceling the subscription request.
473
453
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
474
454
  *
475
455
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
@@ -478,14 +458,14 @@ export class EventClient {
478
458
  * import * as hl from "@nktkas/hyperliquid";
479
459
  *
480
460
  * const transport = new hl.WebSocketTransport();
481
- * const client = new hl.EventClient({ transport });
461
+ * const subsClient = new hl.SubscriptionClient({ transport });
482
462
  *
483
463
  * const sub = await client.userTwapHistory({ user: "0x..." }, (data) => {
484
464
  * console.log(data);
485
465
  * });
486
466
  * ```
487
467
  */
488
- userTwapHistory(args, listener, signal) {
468
+ userTwapHistory(args, listener) {
489
469
  const payload = {
490
470
  type: "userTwapHistory",
491
471
  user: args.user,
@@ -494,13 +474,12 @@ export class EventClient {
494
474
  if (e.detail.user === args.user.toLowerCase()) {
495
475
  listener(e.detail);
496
476
  }
497
- }, signal);
477
+ });
498
478
  }
499
479
  /**
500
480
  * Subscribe to TWAP execution updates for a specific user.
501
481
  * @param args - The parameters for the subscription.
502
482
  * @param listener - The callback function to be called when the event is received.
503
- * @param signal - An optional abort signal for canceling the subscription request.
504
483
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
505
484
  *
506
485
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
@@ -509,14 +488,14 @@ export class EventClient {
509
488
  * import * as hl from "@nktkas/hyperliquid";
510
489
  *
511
490
  * const transport = new hl.WebSocketTransport();
512
- * const client = new hl.EventClient({ transport });
491
+ * const subsClient = new hl.SubscriptionClient({ transport });
513
492
  *
514
493
  * const sub = await client.userTwapSliceFills({ user: "0x..." }, (data) => {
515
494
  * console.log(data);
516
495
  * });
517
496
  * ```
518
497
  */
519
- userTwapSliceFills(args, listener, signal) {
498
+ userTwapSliceFills(args, listener) {
520
499
  const payload = {
521
500
  type: "userTwapSliceFills",
522
501
  user: args.user,
@@ -525,13 +504,12 @@ export class EventClient {
525
504
  if (e.detail.user === args.user.toLowerCase()) {
526
505
  listener(e.detail);
527
506
  }
528
- }, signal);
507
+ });
529
508
  }
530
509
  /**
531
510
  * Subscribe to comprehensive user and market data updates.
532
511
  * @param args - The parameters for the subscription.
533
512
  * @param listener - The callback function to be called when the event is received.
534
- * @param signal - An optional abort signal for canceling the subscription request.
535
513
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
536
514
  *
537
515
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
@@ -540,14 +518,14 @@ export class EventClient {
540
518
  * import * as hl from "@nktkas/hyperliquid";
541
519
  *
542
520
  * const transport = new hl.WebSocketTransport();
543
- * const client = new hl.EventClient({ transport });
521
+ * const subsClient = new hl.SubscriptionClient({ transport });
544
522
  *
545
523
  * const sub = await client.webData2({ user: "0x..." }, (data) => {
546
524
  * console.log(data);
547
525
  * });
548
526
  * ```
549
527
  */
550
- webData2(args, listener, signal) {
528
+ webData2(args, listener) {
551
529
  const payload = {
552
530
  type: "webData2",
553
531
  user: args.user,
@@ -556,7 +534,7 @@ export class EventClient {
556
534
  if (e.detail.user === args.user.toLowerCase()) {
557
535
  listener(e.detail);
558
536
  }
559
- }, signal);
537
+ });
560
538
  }
561
539
  async [Symbol.asyncDispose]() {
562
540
  await this.transport[Symbol.asyncDispose]?.();
@@ -49,7 +49,6 @@
49
49
  *
50
50
  * @module
51
51
  */
52
- import "../_dnt.polyfills.js";
53
52
  import { type ValueMap, type ValueType } from "../deps/jsr.io/@std/msgpack/1.0.3/encode.js";
54
53
  import type { Hex } from "./base.js";
55
54
  export type { Hex };
@@ -1 +1 @@
1
- {"version":3,"file":"signing.d.ts","sourceRoot":"","sources":["../../src/src/signing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,OAAO,sBAAsB,CAAC;AAI9B,OAAO,EAA2B,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAGrH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAErC,YAAY,EAAE,GAAG,EAAE,CAAC;AACpB,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AAEpC,gEAAgE;AAChE,MAAM,MAAM,cAAc,GACpB,wBAA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,SAAS,CAAC;IACxC,iCAAiC;IACjC,gBAAgB,EAAE,GAAG,CAAC;CACzB,GAAG,OAAO,CAAC;IAAE,CAAC,EAAE,GAAG,CAAC;IAAC,CAAC,EAAE,GAAG,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA+BzC;AAoGD,4DAA4D;AAC5D,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,wBAAwB,CAI9F;AAED,8DAA8D;AAC9D,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,oBAAoB,CAItF;AAED,iEAAiE;AACjE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,sBAAsB,CAI1F;AAED,qGAAqG;AACrG,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,wBAAwB,CAItG;AAED,yEAAyE;AACzE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,sBAAsB,CAI1F"}
@@ -49,7 +49,6 @@
49
49
  *
50
50
  * @module
51
51
  */
52
- import "../_dnt.polyfills.js";
53
52
  import { keccak_256 } from "@noble/hashes/sha3";
54
53
  import { encode as encodeMsgpack } from "../deps/jsr.io/@std/msgpack/1.0.3/encode.js";
55
54
  import { decodeHex, encodeHex } from "../deps/jsr.io/@std/encoding/1.0.10/hex.js";
@@ -29,18 +29,16 @@ export interface ISubscriptionTransport extends Partial<AsyncDisposable> {
29
29
  * @param channel - The event channel to listen to.
30
30
  * @param payload - The payload to send with the subscription request.
31
31
  * @param listener - The function to call when the event is dispatched.
32
- * @param signal - An optional abort signal for canceling the subscription request.
33
32
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
34
33
  */
35
- subscribe<T>(channel: string, payload: unknown, listener: (data: CustomEvent<T>) => void, signal?: AbortSignal): Promise<Subscription>;
34
+ subscribe<T>(channel: string, payload: unknown, listener: (data: CustomEvent<T>) => void): Promise<Subscription>;
36
35
  }
37
36
  /** Controls event subscription lifecycle. */
38
37
  export interface Subscription {
39
- /**
40
- * Unsubscribes from the event and sends an unsubscribe request to the server.
41
- * @param signal - An optional abort signal for canceling the unsubscribe request.
42
- */
43
- unsubscribe(signal?: AbortSignal): Promise<void>;
38
+ /** Unsubscribes from the event and sends an unsubscribe request to the server. */
39
+ unsubscribe(): Promise<void>;
40
+ /** Signal that aborts when resubscription fails during reconnection. */
41
+ resubscribeSignal?: AbortSignal;
44
42
  }
45
43
  /** Base class for all transport-related errors. */
46
44
  export declare class TransportError extends HyperliquidError {
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/src/transports/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAkB,SAAQ,OAAO,CAAC,eAAe,CAAC;IAC/D;;;;;;OAMG;IACH,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC9G;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAuB,SAAQ,OAAO,CAAC,eAAe,CAAC;IACpE;;;;;;;OAOG;IACH,SAAS,CAAC,CAAC,EACP,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,EACxC,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,YAAY,CAAC,CAAC;CAC5B;AAED,6CAA6C;AAC7C,MAAM,WAAW,YAAY;IACzB;;;OAGG;IACH,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED,mDAAmD;AACnD,qBAAa,cAAe,SAAQ,gBAAgB;gBACpC,OAAO,CAAC,EAAE,MAAM;CAI/B"}
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/src/transports/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAkB,SAAQ,OAAO,CAAC,eAAe,CAAC;IAC/D;;;;;;OAMG;IACH,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC9G;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAuB,SAAQ,OAAO,CAAC,eAAe,CAAC;IACpE;;;;;;OAMG;IACH,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACpH;AAED,6CAA6C;AAC7C,MAAM,WAAW,YAAY;IACzB,kFAAkF;IAClF,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,wEAAwE;IACxE,iBAAiB,CAAC,EAAE,WAAW,CAAC;CACnC;AAED,mDAAmD;AACnD,qBAAa,cAAe,SAAQ,gBAAgB;gBACpC,OAAO,CAAC,EAAE,MAAM;CAI/B"}
@@ -35,7 +35,7 @@ export interface ReconnectingWebSocketOptions {
35
35
  }
36
36
  /** Message buffer strategy interface. */
37
37
  export interface MessageBufferStrategy {
38
- push(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
38
+ push(data: string | ArrayBufferLike | Blob | ArrayBufferView, signal?: AbortSignal): void;
39
39
  [Symbol.iterator](): Iterator<string | ArrayBufferLike | Blob | ArrayBufferView>;
40
40
  }
41
41
  /** Error thrown when reconnection problems occur. */
@@ -95,9 +95,10 @@ export declare class ReconnectingWebSocket implements WebSocket {
95
95
  */
96
96
  close(code?: number, reason?: string, permanently?: boolean): void;
97
97
  /**
98
+ * @param signal - `AbortSignal` to cancel sending a message if it was in the buffer.
98
99
  * @note If the connection is not open, the data will be buffered and sent when the connection is established.
99
100
  */
100
- send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
101
+ send(data: string | ArrayBufferLike | Blob | ArrayBufferView, signal?: AbortSignal): void;
101
102
  addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: ((this: ReconnectingWebSocket, ev: WebSocketEventMap[K]) => any) | {
102
103
  handleEvent: (event: WebSocketEventMap[K]) => any;
103
104
  }, options?: boolean | AddEventListenerOptions): void;