@nktkas/hyperliquid 0.20.0 → 0.21.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/README.md +40 -50
- package/esm/mod.d.ts +3 -4
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +3 -4
- package/{script/src/clients/wallet.d.ts → esm/src/clients/exchange.d.ts} +100 -100
- package/esm/src/clients/exchange.d.ts.map +1 -0
- package/esm/src/clients/{wallet.js → exchange.js} +41 -41
- package/esm/src/clients/{public.d.ts → info.d.ts} +100 -100
- package/esm/src/clients/info.d.ts.map +1 -0
- package/esm/src/clients/{public.js → info.js} +51 -51
- package/{script/src/clients/event.d.ts → esm/src/clients/subscription.d.ts} +60 -78
- package/esm/src/clients/subscription.d.ts.map +1 -0
- package/esm/src/clients/{event.js → subscription.js} +57 -79
- package/esm/src/signing.d.ts +0 -1
- package/esm/src/signing.d.ts.map +1 -1
- package/esm/src/signing.js +0 -1
- package/esm/src/transports/base.d.ts +5 -7
- package/esm/src/transports/base.d.ts.map +1 -1
- package/esm/src/transports/websocket/_reconnecting_websocket.d.ts +3 -2
- package/esm/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
- package/esm/src/transports/websocket/_reconnecting_websocket.js +11 -5
- package/esm/src/transports/websocket/_websocket_async_request.d.ts +6 -4
- package/esm/src/transports/websocket/_websocket_async_request.d.ts.map +1 -1
- package/esm/src/transports/websocket/_websocket_async_request.js +47 -28
- package/esm/src/transports/websocket/websocket_transport.d.ts +24 -21
- package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/esm/src/transports/websocket/websocket_transport.js +60 -57
- package/esm/src/types/info/accounts.d.ts +1 -0
- package/esm/src/types/info/accounts.d.ts.map +1 -1
- package/esm/src/types/mod.d.ts +0 -1
- package/esm/src/types/mod.d.ts.map +1 -1
- package/esm/src/types/mod.js +1 -1
- package/package.json +1 -1
- package/script/mod.d.ts +3 -4
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +4 -5
- package/{esm/src/clients/wallet.d.ts → script/src/clients/exchange.d.ts} +100 -100
- package/script/src/clients/exchange.d.ts.map +1 -0
- package/script/src/clients/{wallet.js → exchange.js} +43 -43
- package/script/src/clients/{public.d.ts → info.d.ts} +100 -100
- package/script/src/clients/info.d.ts.map +1 -0
- package/script/src/clients/{public.js → info.js} +53 -53
- package/{esm/src/clients/event.d.ts → script/src/clients/subscription.d.ts} +60 -78
- package/script/src/clients/subscription.d.ts.map +1 -0
- package/script/src/clients/{event.js → subscription.js} +59 -81
- package/script/src/signing.d.ts +0 -1
- package/script/src/signing.d.ts.map +1 -1
- package/script/src/signing.js +52 -53
- package/script/src/transports/base.d.ts +5 -7
- package/script/src/transports/base.d.ts.map +1 -1
- package/script/src/transports/websocket/_reconnecting_websocket.d.ts +3 -2
- package/script/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
- package/script/src/transports/websocket/_reconnecting_websocket.js +11 -5
- package/script/src/transports/websocket/_websocket_async_request.d.ts +6 -4
- package/script/src/transports/websocket/_websocket_async_request.d.ts.map +1 -1
- package/script/src/transports/websocket/_websocket_async_request.js +47 -28
- package/script/src/transports/websocket/websocket_transport.d.ts +24 -21
- package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/script/src/transports/websocket/websocket_transport.js +60 -57
- package/script/src/types/info/accounts.d.ts +1 -0
- package/script/src/types/info/accounts.d.ts.map +1 -1
- package/script/src/types/mod.d.ts +0 -1
- package/script/src/types/mod.d.ts.map +1 -1
- package/script/src/types/mod.js +24 -25
- package/esm/_dnt.polyfills.d.ts +0 -20
- package/esm/_dnt.polyfills.d.ts.map +0 -1
- package/esm/_dnt.polyfills.js +0 -12
- package/esm/src/clients/event.d.ts.map +0 -1
- package/esm/src/clients/public.d.ts.map +0 -1
- package/esm/src/clients/wallet.d.ts.map +0 -1
- package/script/_dnt.polyfills.d.ts +0 -20
- package/script/_dnt.polyfills.d.ts.map +0 -1
- package/script/_dnt.polyfills.js +0 -23
- package/script/src/clients/event.d.ts.map +0 -1
- package/script/src/clients/public.d.ts.map +0 -1
- package/script/src/clients/wallet.d.ts.map +0 -1
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.SubscriptionClient = void 0;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Subscription client for subscribing to various Hyperliquid events.
|
|
15
15
|
* @typeParam T The type of transport used to connect to the Hyperliquid Websocket API.
|
|
16
16
|
*/
|
|
17
|
-
class
|
|
17
|
+
class SubscriptionClient {
|
|
18
18
|
transport;
|
|
19
19
|
/**
|
|
20
20
|
* Initialises a new instance.
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* import * as hl from "@nktkas/hyperliquid";
|
|
26
26
|
*
|
|
27
27
|
* const transport = new hl.WebSocketTransport();
|
|
28
|
-
* const
|
|
28
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
constructor(args) {
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
* Subscribe to context updates for a specific perpetual asset.
|
|
36
36
|
* @param args - The parameters for the subscription.
|
|
37
37
|
* @param listener - The callback function to be called when the event is received.
|
|
38
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
39
38
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
40
39
|
*
|
|
41
40
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
@@ -44,14 +43,14 @@
|
|
|
44
43
|
* import * as hl from "@nktkas/hyperliquid";
|
|
45
44
|
*
|
|
46
45
|
* const transport = new hl.WebSocketTransport();
|
|
47
|
-
* const
|
|
46
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
48
47
|
*
|
|
49
48
|
* const sub = await client.activeAssetCtx({ coin: "BTC" }, (data) => {
|
|
50
49
|
* console.log(data);
|
|
51
50
|
* });
|
|
52
51
|
* ```
|
|
53
52
|
*/
|
|
54
|
-
activeAssetCtx(args, listener
|
|
53
|
+
activeAssetCtx(args, listener) {
|
|
55
54
|
const channel = args.coin.startsWith("@") ? "activeSpotAssetCtx" : "activeAssetCtx";
|
|
56
55
|
const payload = {
|
|
57
56
|
type: "activeAssetCtx",
|
|
@@ -61,13 +60,12 @@
|
|
|
61
60
|
if (e.detail.coin === args.coin) {
|
|
62
61
|
listener(e.detail);
|
|
63
62
|
}
|
|
64
|
-
}
|
|
63
|
+
});
|
|
65
64
|
}
|
|
66
65
|
/**
|
|
67
66
|
* Subscribe to trading data updates for a specific asset and user.
|
|
68
67
|
* @param args - The parameters for the subscription.
|
|
69
68
|
* @param listener - The callback function to be called when the event is received.
|
|
70
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
71
69
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
72
70
|
*
|
|
73
71
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
@@ -76,14 +74,14 @@
|
|
|
76
74
|
* import * as hl from "@nktkas/hyperliquid";
|
|
77
75
|
*
|
|
78
76
|
* const transport = new hl.WebSocketTransport();
|
|
79
|
-
* const
|
|
77
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
80
78
|
*
|
|
81
79
|
* const sub = await client.activeAssetData({ coin: "BTC", user: "0x..." }, (data) => {
|
|
82
80
|
* console.log(data);
|
|
83
81
|
* });
|
|
84
82
|
* ```
|
|
85
83
|
*/
|
|
86
|
-
activeAssetData(args, listener
|
|
84
|
+
activeAssetData(args, listener) {
|
|
87
85
|
const payload = {
|
|
88
86
|
type: "activeAssetData",
|
|
89
87
|
coin: args.coin,
|
|
@@ -93,29 +91,23 @@
|
|
|
93
91
|
if (e.detail.coin === args.coin && e.detail.user === args.user.toLowerCase()) {
|
|
94
92
|
listener(e.detail);
|
|
95
93
|
}
|
|
96
|
-
}
|
|
94
|
+
});
|
|
97
95
|
}
|
|
98
|
-
allMids(args_or_listener,
|
|
96
|
+
allMids(args_or_listener, maybeListener) {
|
|
99
97
|
const args = typeof args_or_listener === "function" ? {} : args_or_listener;
|
|
100
|
-
const listener = typeof args_or_listener === "function"
|
|
101
|
-
? args_or_listener
|
|
102
|
-
: listener_or_signal;
|
|
103
|
-
const signal = typeof args_or_listener === "function"
|
|
104
|
-
? listener_or_signal
|
|
105
|
-
: maybeSignal;
|
|
98
|
+
const listener = typeof args_or_listener === "function" ? args_or_listener : maybeListener;
|
|
106
99
|
const payload = {
|
|
107
100
|
type: "allMids",
|
|
108
101
|
dex: args.dex,
|
|
109
102
|
};
|
|
110
103
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
111
104
|
listener(e.detail);
|
|
112
|
-
}
|
|
105
|
+
});
|
|
113
106
|
}
|
|
114
107
|
/**
|
|
115
108
|
* Subscribe to best bid and offer updates for a specific asset.
|
|
116
109
|
* @param args - The parameters for the subscription.
|
|
117
110
|
* @param listener - The callback function to be called when the event is received.
|
|
118
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
119
111
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
120
112
|
*
|
|
121
113
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
@@ -124,14 +116,14 @@
|
|
|
124
116
|
* import * as hl from "@nktkas/hyperliquid";
|
|
125
117
|
*
|
|
126
118
|
* const transport = new hl.WebSocketTransport();
|
|
127
|
-
* const
|
|
119
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
128
120
|
*
|
|
129
121
|
* const sub = await client.bbo({ coin: "BTC" }, (data) => {
|
|
130
122
|
* console.log(data);
|
|
131
123
|
* });
|
|
132
124
|
* ```
|
|
133
125
|
*/
|
|
134
|
-
bbo(args, listener
|
|
126
|
+
bbo(args, listener) {
|
|
135
127
|
const payload = {
|
|
136
128
|
type: "bbo",
|
|
137
129
|
coin: args.coin,
|
|
@@ -140,13 +132,12 @@
|
|
|
140
132
|
if (e.detail.coin === args.coin) {
|
|
141
133
|
listener(e.detail);
|
|
142
134
|
}
|
|
143
|
-
}
|
|
135
|
+
});
|
|
144
136
|
}
|
|
145
137
|
/**
|
|
146
138
|
* Subscribe to candlestick data updates for a specific asset.
|
|
147
139
|
* @param args - The parameters for the subscription.
|
|
148
140
|
* @param listener - The callback function to be called when the event is received.
|
|
149
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
150
141
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
151
142
|
*
|
|
152
143
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
@@ -155,14 +146,14 @@
|
|
|
155
146
|
* import * as hl from "@nktkas/hyperliquid";
|
|
156
147
|
*
|
|
157
148
|
* const transport = new hl.WebSocketTransport();
|
|
158
|
-
* const
|
|
149
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
159
150
|
*
|
|
160
151
|
* const sub = await client.candle({ coin: "BTC", interval: "1h" }, (data) => {
|
|
161
152
|
* console.log(data);
|
|
162
153
|
* });
|
|
163
154
|
* ```
|
|
164
155
|
*/
|
|
165
|
-
candle(args, listener
|
|
156
|
+
candle(args, listener) {
|
|
166
157
|
const payload = {
|
|
167
158
|
type: "candle",
|
|
168
159
|
coin: args.coin,
|
|
@@ -172,12 +163,11 @@
|
|
|
172
163
|
if (e.detail.s === args.coin && e.detail.i === args.interval) {
|
|
173
164
|
listener(e.detail);
|
|
174
165
|
}
|
|
175
|
-
}
|
|
166
|
+
});
|
|
176
167
|
}
|
|
177
168
|
/**
|
|
178
169
|
* Subscribe to explorer block updates.
|
|
179
170
|
* @param listener - The callback function to be called when the event is received.
|
|
180
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
181
171
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
182
172
|
* @note Make sure the endpoint in the {@link transport} supports this method.
|
|
183
173
|
*
|
|
@@ -187,25 +177,24 @@
|
|
|
187
177
|
* import * as hl from "@nktkas/hyperliquid";
|
|
188
178
|
*
|
|
189
179
|
* const transport = new hl.WebSocketTransport();
|
|
190
|
-
* const
|
|
180
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
191
181
|
*
|
|
192
182
|
* const sub = await client.explorerBlock((data) => {
|
|
193
183
|
* console.log(data);
|
|
194
184
|
* });
|
|
195
185
|
* ```
|
|
196
186
|
*/
|
|
197
|
-
explorerBlock(listener
|
|
187
|
+
explorerBlock(listener) {
|
|
198
188
|
const payload = {
|
|
199
189
|
type: "explorerBlock",
|
|
200
190
|
};
|
|
201
191
|
return this.transport.subscribe("_explorerBlock", payload, (e) => {
|
|
202
192
|
listener(e.detail);
|
|
203
|
-
}
|
|
193
|
+
});
|
|
204
194
|
}
|
|
205
195
|
/**
|
|
206
196
|
* Subscribe to explorer transaction updates.
|
|
207
197
|
* @param listener - The callback function to be called when the event is received.
|
|
208
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
209
198
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
210
199
|
* @note Make sure the endpoint in the {@link transport} supports this method.
|
|
211
200
|
*
|
|
@@ -215,26 +204,25 @@
|
|
|
215
204
|
* import * as hl from "@nktkas/hyperliquid";
|
|
216
205
|
*
|
|
217
206
|
* const transport = new hl.WebSocketTransport();
|
|
218
|
-
* const
|
|
207
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
219
208
|
*
|
|
220
209
|
* const sub = await client.explorerTxs((data) => {
|
|
221
210
|
* console.log(data);
|
|
222
211
|
* });
|
|
223
212
|
* ```
|
|
224
213
|
*/
|
|
225
|
-
explorerTxs(listener
|
|
214
|
+
explorerTxs(listener) {
|
|
226
215
|
const payload = {
|
|
227
216
|
type: "explorerTxs",
|
|
228
217
|
};
|
|
229
218
|
return this.transport.subscribe("_explorerTxs", payload, (e) => {
|
|
230
219
|
listener(e.detail);
|
|
231
|
-
}
|
|
220
|
+
});
|
|
232
221
|
}
|
|
233
222
|
/**
|
|
234
223
|
* Subscribe to L2 order book updates for a specific asset.
|
|
235
224
|
* @param args - The parameters for the subscription.
|
|
236
225
|
* @param listener - The callback function to be called when the event is received.
|
|
237
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
238
226
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
239
227
|
*
|
|
240
228
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
@@ -243,14 +231,14 @@
|
|
|
243
231
|
* import * as hl from "@nktkas/hyperliquid";
|
|
244
232
|
*
|
|
245
233
|
* const transport = new hl.WebSocketTransport();
|
|
246
|
-
* const
|
|
234
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
247
235
|
*
|
|
248
236
|
* const sub = await client.l2Book({ coin: "BTC" }, (data) => {
|
|
249
237
|
* console.log(data);
|
|
250
238
|
* });
|
|
251
239
|
* ```
|
|
252
240
|
*/
|
|
253
|
-
l2Book(args, listener
|
|
241
|
+
l2Book(args, listener) {
|
|
254
242
|
const payload = {
|
|
255
243
|
type: "l2Book",
|
|
256
244
|
coin: args.coin,
|
|
@@ -261,13 +249,12 @@
|
|
|
261
249
|
if (e.detail.coin === args.coin) {
|
|
262
250
|
listener(e.detail);
|
|
263
251
|
}
|
|
264
|
-
}
|
|
252
|
+
});
|
|
265
253
|
}
|
|
266
254
|
/**
|
|
267
255
|
* Subscribe to notification updates for a specific user.
|
|
268
256
|
* @param args - The parameters for the subscription.
|
|
269
257
|
* @param listener - The callback function to be called when the event is received.
|
|
270
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
271
258
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
272
259
|
*
|
|
273
260
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
@@ -276,27 +263,26 @@
|
|
|
276
263
|
* import * as hl from "@nktkas/hyperliquid";
|
|
277
264
|
*
|
|
278
265
|
* const transport = new hl.WebSocketTransport();
|
|
279
|
-
* const
|
|
266
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
280
267
|
*
|
|
281
268
|
* const sub = await client.notification({ user: "0x..." }, (data) => {
|
|
282
269
|
* console.log(data);
|
|
283
270
|
* });
|
|
284
271
|
* ```
|
|
285
272
|
*/
|
|
286
|
-
notification(args, listener
|
|
273
|
+
notification(args, listener) {
|
|
287
274
|
const payload = {
|
|
288
275
|
type: "notification",
|
|
289
276
|
user: args.user,
|
|
290
277
|
};
|
|
291
278
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
292
279
|
listener(e.detail);
|
|
293
|
-
}
|
|
280
|
+
});
|
|
294
281
|
}
|
|
295
282
|
/**
|
|
296
283
|
* Subscribe to order status updates for a specific user.
|
|
297
284
|
* @param args - The parameters for the subscription.
|
|
298
285
|
* @param listener - The callback function to be called when the event is received.
|
|
299
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
300
286
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
301
287
|
*
|
|
302
288
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
@@ -305,27 +291,26 @@
|
|
|
305
291
|
* import * as hl from "@nktkas/hyperliquid";
|
|
306
292
|
*
|
|
307
293
|
* const transport = new hl.WebSocketTransport();
|
|
308
|
-
* const
|
|
294
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
309
295
|
*
|
|
310
296
|
* const sub = await client.orderUpdates({ user: "0x..." }, (data) => {
|
|
311
297
|
* console.log(data);
|
|
312
298
|
* });
|
|
313
299
|
* ```
|
|
314
300
|
*/
|
|
315
|
-
orderUpdates(args, listener
|
|
301
|
+
orderUpdates(args, listener) {
|
|
316
302
|
const payload = {
|
|
317
303
|
type: "orderUpdates",
|
|
318
304
|
user: args.user,
|
|
319
305
|
};
|
|
320
306
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
321
307
|
listener(e.detail);
|
|
322
|
-
}
|
|
308
|
+
});
|
|
323
309
|
}
|
|
324
310
|
/**
|
|
325
311
|
* Subscribe to real-time trade updates for a specific asset.
|
|
326
312
|
* @param args - The parameters for the subscription.
|
|
327
313
|
* @param listener - The callback function to be called when the event is received.
|
|
328
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
329
314
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
330
315
|
*
|
|
331
316
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
@@ -334,14 +319,14 @@
|
|
|
334
319
|
* import * as hl from "@nktkas/hyperliquid";
|
|
335
320
|
*
|
|
336
321
|
* const transport = new hl.WebSocketTransport();
|
|
337
|
-
* const
|
|
322
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
338
323
|
*
|
|
339
324
|
* const sub = await client.trades({ coin: "BTC" }, (data) => {
|
|
340
325
|
* console.log(data);
|
|
341
326
|
* });
|
|
342
327
|
* ```
|
|
343
328
|
*/
|
|
344
|
-
trades(args, listener
|
|
329
|
+
trades(args, listener) {
|
|
345
330
|
const payload = {
|
|
346
331
|
type: "trades",
|
|
347
332
|
coin: args.coin,
|
|
@@ -350,13 +335,12 @@
|
|
|
350
335
|
if (e.detail[0]?.coin === args.coin) {
|
|
351
336
|
listener(e.detail);
|
|
352
337
|
}
|
|
353
|
-
}
|
|
338
|
+
});
|
|
354
339
|
}
|
|
355
340
|
/**
|
|
356
341
|
* Subscribe to non-order events for a specific user.
|
|
357
342
|
* @param args - The parameters for the subscription.
|
|
358
343
|
* @param listener - The callback function to be called when the event is received.
|
|
359
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
360
344
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
361
345
|
*
|
|
362
346
|
* @note Different subscriptions cannot be distinguished from each other.
|
|
@@ -367,27 +351,26 @@
|
|
|
367
351
|
* import * as hl from "@nktkas/hyperliquid";
|
|
368
352
|
*
|
|
369
353
|
* const transport = new hl.WebSocketTransport();
|
|
370
|
-
* const
|
|
354
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
371
355
|
*
|
|
372
356
|
* const sub = await client.userEvents({ user: "0x..." }, (data) => {
|
|
373
357
|
* console.log(data);
|
|
374
358
|
* });
|
|
375
359
|
* ```
|
|
376
360
|
*/
|
|
377
|
-
userEvents(args, listener
|
|
361
|
+
userEvents(args, listener) {
|
|
378
362
|
const payload = {
|
|
379
363
|
type: "userEvents",
|
|
380
364
|
user: args.user,
|
|
381
365
|
};
|
|
382
366
|
return this.transport.subscribe("user", payload, (e) => {
|
|
383
367
|
listener(e.detail);
|
|
384
|
-
}
|
|
368
|
+
});
|
|
385
369
|
}
|
|
386
370
|
/**
|
|
387
371
|
* Subscribe to trade fill updates for a specific user.
|
|
388
372
|
* @param args - The parameters for the subscription.
|
|
389
373
|
* @param listener - The callback function to be called when the event is received.
|
|
390
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
391
374
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
392
375
|
*
|
|
393
376
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
@@ -396,14 +379,14 @@
|
|
|
396
379
|
* import * as hl from "@nktkas/hyperliquid";
|
|
397
380
|
*
|
|
398
381
|
* const transport = new hl.WebSocketTransport();
|
|
399
|
-
* const
|
|
382
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
400
383
|
*
|
|
401
384
|
* const sub = await client.userFills({ user: "0x..." }, (data) => {
|
|
402
385
|
* console.log(data);
|
|
403
386
|
* });
|
|
404
387
|
* ```
|
|
405
388
|
*/
|
|
406
|
-
userFills(args, listener
|
|
389
|
+
userFills(args, listener) {
|
|
407
390
|
const payload = {
|
|
408
391
|
type: "userFills",
|
|
409
392
|
user: args.user,
|
|
@@ -413,13 +396,12 @@
|
|
|
413
396
|
if (e.detail.user === args.user.toLowerCase()) {
|
|
414
397
|
listener(e.detail);
|
|
415
398
|
}
|
|
416
|
-
}
|
|
399
|
+
});
|
|
417
400
|
}
|
|
418
401
|
/**
|
|
419
402
|
* Subscribe to funding payment updates for a specific user.
|
|
420
403
|
* @param args - The parameters for the subscription.
|
|
421
404
|
* @param listener - The callback function to be called when the event is received.
|
|
422
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
423
405
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
424
406
|
*
|
|
425
407
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
@@ -428,14 +410,14 @@
|
|
|
428
410
|
* import * as hl from "@nktkas/hyperliquid";
|
|
429
411
|
*
|
|
430
412
|
* const transport = new hl.WebSocketTransport();
|
|
431
|
-
* const
|
|
413
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
432
414
|
*
|
|
433
415
|
* const sub = await client.userFundings({ user: "0x..." }, (data) => {
|
|
434
416
|
* console.log(data);
|
|
435
417
|
* });
|
|
436
418
|
* ```
|
|
437
419
|
*/
|
|
438
|
-
userFundings(args, listener
|
|
420
|
+
userFundings(args, listener) {
|
|
439
421
|
const payload = {
|
|
440
422
|
type: "userFundings",
|
|
441
423
|
user: args.user,
|
|
@@ -444,13 +426,12 @@
|
|
|
444
426
|
if (e.detail.user === args.user.toLowerCase()) {
|
|
445
427
|
listener(e.detail);
|
|
446
428
|
}
|
|
447
|
-
}
|
|
429
|
+
});
|
|
448
430
|
}
|
|
449
431
|
/**
|
|
450
432
|
* Subscribe to non-funding ledger updates for a specific user.
|
|
451
433
|
* @param args - The parameters for the subscription.
|
|
452
434
|
* @param listener - The callback function to be called when the event is received.
|
|
453
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
454
435
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
455
436
|
*
|
|
456
437
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
@@ -459,14 +440,14 @@
|
|
|
459
440
|
* import * as hl from "@nktkas/hyperliquid";
|
|
460
441
|
*
|
|
461
442
|
* const transport = new hl.WebSocketTransport();
|
|
462
|
-
* const
|
|
443
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
463
444
|
*
|
|
464
445
|
* const sub = await client.userNonFundingLedgerUpdates({ user: "0x..." }, (data) => {
|
|
465
446
|
* console.log(data);
|
|
466
447
|
* });
|
|
467
448
|
* ```
|
|
468
449
|
*/
|
|
469
|
-
userNonFundingLedgerUpdates(args, listener
|
|
450
|
+
userNonFundingLedgerUpdates(args, listener) {
|
|
470
451
|
const payload = {
|
|
471
452
|
type: "userNonFundingLedgerUpdates",
|
|
472
453
|
user: args.user,
|
|
@@ -475,13 +456,12 @@
|
|
|
475
456
|
if (e.detail.user === args.user.toLowerCase()) {
|
|
476
457
|
listener(e.detail);
|
|
477
458
|
}
|
|
478
|
-
}
|
|
459
|
+
});
|
|
479
460
|
}
|
|
480
461
|
/**
|
|
481
462
|
* Subscribe to TWAP order history updates for a specific user.
|
|
482
463
|
* @param args - The parameters for the subscription.
|
|
483
464
|
* @param listener - The callback function to be called when the event is received.
|
|
484
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
485
465
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
486
466
|
*
|
|
487
467
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
@@ -490,14 +470,14 @@
|
|
|
490
470
|
* import * as hl from "@nktkas/hyperliquid";
|
|
491
471
|
*
|
|
492
472
|
* const transport = new hl.WebSocketTransport();
|
|
493
|
-
* const
|
|
473
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
494
474
|
*
|
|
495
475
|
* const sub = await client.userTwapHistory({ user: "0x..." }, (data) => {
|
|
496
476
|
* console.log(data);
|
|
497
477
|
* });
|
|
498
478
|
* ```
|
|
499
479
|
*/
|
|
500
|
-
userTwapHistory(args, listener
|
|
480
|
+
userTwapHistory(args, listener) {
|
|
501
481
|
const payload = {
|
|
502
482
|
type: "userTwapHistory",
|
|
503
483
|
user: args.user,
|
|
@@ -506,13 +486,12 @@
|
|
|
506
486
|
if (e.detail.user === args.user.toLowerCase()) {
|
|
507
487
|
listener(e.detail);
|
|
508
488
|
}
|
|
509
|
-
}
|
|
489
|
+
});
|
|
510
490
|
}
|
|
511
491
|
/**
|
|
512
492
|
* Subscribe to TWAP execution updates for a specific user.
|
|
513
493
|
* @param args - The parameters for the subscription.
|
|
514
494
|
* @param listener - The callback function to be called when the event is received.
|
|
515
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
516
495
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
517
496
|
*
|
|
518
497
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
@@ -521,14 +500,14 @@
|
|
|
521
500
|
* import * as hl from "@nktkas/hyperliquid";
|
|
522
501
|
*
|
|
523
502
|
* const transport = new hl.WebSocketTransport();
|
|
524
|
-
* const
|
|
503
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
525
504
|
*
|
|
526
505
|
* const sub = await client.userTwapSliceFills({ user: "0x..." }, (data) => {
|
|
527
506
|
* console.log(data);
|
|
528
507
|
* });
|
|
529
508
|
* ```
|
|
530
509
|
*/
|
|
531
|
-
userTwapSliceFills(args, listener
|
|
510
|
+
userTwapSliceFills(args, listener) {
|
|
532
511
|
const payload = {
|
|
533
512
|
type: "userTwapSliceFills",
|
|
534
513
|
user: args.user,
|
|
@@ -537,13 +516,12 @@
|
|
|
537
516
|
if (e.detail.user === args.user.toLowerCase()) {
|
|
538
517
|
listener(e.detail);
|
|
539
518
|
}
|
|
540
|
-
}
|
|
519
|
+
});
|
|
541
520
|
}
|
|
542
521
|
/**
|
|
543
522
|
* Subscribe to comprehensive user and market data updates.
|
|
544
523
|
* @param args - The parameters for the subscription.
|
|
545
524
|
* @param listener - The callback function to be called when the event is received.
|
|
546
|
-
* @param signal - An optional abort signal for canceling the subscription request.
|
|
547
525
|
* @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
|
|
548
526
|
*
|
|
549
527
|
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
@@ -552,14 +530,14 @@
|
|
|
552
530
|
* import * as hl from "@nktkas/hyperliquid";
|
|
553
531
|
*
|
|
554
532
|
* const transport = new hl.WebSocketTransport();
|
|
555
|
-
* const
|
|
533
|
+
* const subsClient = new hl.SubscriptionClient({ transport });
|
|
556
534
|
*
|
|
557
535
|
* const sub = await client.webData2({ user: "0x..." }, (data) => {
|
|
558
536
|
* console.log(data);
|
|
559
537
|
* });
|
|
560
538
|
* ```
|
|
561
539
|
*/
|
|
562
|
-
webData2(args, listener
|
|
540
|
+
webData2(args, listener) {
|
|
563
541
|
const payload = {
|
|
564
542
|
type: "webData2",
|
|
565
543
|
user: args.user,
|
|
@@ -568,11 +546,11 @@
|
|
|
568
546
|
if (e.detail.user === args.user.toLowerCase()) {
|
|
569
547
|
listener(e.detail);
|
|
570
548
|
}
|
|
571
|
-
}
|
|
549
|
+
});
|
|
572
550
|
}
|
|
573
551
|
async [Symbol.asyncDispose]() {
|
|
574
552
|
await this.transport[Symbol.asyncDispose]?.();
|
|
575
553
|
}
|
|
576
554
|
}
|
|
577
|
-
exports.
|
|
555
|
+
exports.SubscriptionClient = SubscriptionClient;
|
|
578
556
|
});
|
package/script/src/signing.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signing.d.ts","sourceRoot":"","sources":["../../src/src/signing.ts"],"names":[],"mappings":"AAAA;;;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