@nktkas/hyperliquid 0.13.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.
Files changed (145) hide show
  1. package/CONTRIBUTING.md +59 -0
  2. package/LICENSE +21 -0
  3. package/README.md +363 -0
  4. package/SECURITY.md +7 -0
  5. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts +2 -0
  6. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts.map +1 -0
  7. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js +1 -0
  8. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts +95 -0
  9. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts.map +1 -0
  10. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.js +10 -0
  11. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts +23 -0
  12. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts.map +1 -0
  13. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.js +43 -0
  14. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.d.ts +55 -0
  15. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.d.ts.map +1 -0
  16. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.js +65 -0
  17. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.d.ts +2 -0
  18. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.d.ts.map +1 -0
  19. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.js +1 -0
  20. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.d.ts +52 -0
  21. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.d.ts.map +1 -0
  22. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.js +283 -0
  23. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/utils.d.ts +120 -0
  24. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/utils.d.ts.map +1 -0
  25. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/utils.js +211 -0
  26. package/esm/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts +19 -0
  27. package/esm/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts.map +1 -0
  28. package/esm/deps/jsr.io/@std/bytes/1.0.4/concat.js +32 -0
  29. package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.d.ts +2 -0
  30. package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.d.ts.map +1 -0
  31. package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.js +26 -0
  32. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts +37 -0
  33. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts.map +1 -0
  34. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.js +109 -0
  35. package/esm/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts +37 -0
  36. package/esm/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts.map +1 -0
  37. package/esm/deps/jsr.io/@std/msgpack/1.0.2/encode.js +237 -0
  38. package/esm/mod.d.ts +24 -0
  39. package/esm/mod.d.ts.map +1 -0
  40. package/esm/mod.js +9 -0
  41. package/esm/package.json +3 -0
  42. package/esm/src/clients/event.d.ts +374 -0
  43. package/esm/src/clients/event.d.ts.map +1 -0
  44. package/esm/src/clients/event.js +490 -0
  45. package/esm/src/clients/public.d.ts +695 -0
  46. package/esm/src/clients/public.d.ts.map +1 -0
  47. package/esm/src/clients/public.js +704 -0
  48. package/esm/src/clients/wallet.d.ts +682 -0
  49. package/esm/src/clients/wallet.d.ts.map +1 -0
  50. package/esm/src/clients/wallet.js +984 -0
  51. package/esm/src/transports/base.d.ts +55 -0
  52. package/esm/src/transports/base.d.ts.map +1 -0
  53. package/esm/src/transports/base.js +14 -0
  54. package/esm/src/transports/http/http_transport.d.ts +78 -0
  55. package/esm/src/transports/http/http_transport.d.ts.map +1 -0
  56. package/esm/src/transports/http/http_transport.js +170 -0
  57. package/esm/src/transports/websocket/hyperliquid_event_target.d.ts +66 -0
  58. package/esm/src/transports/websocket/hyperliquid_event_target.d.ts.map +1 -0
  59. package/esm/src/transports/websocket/hyperliquid_event_target.js +33 -0
  60. package/esm/src/transports/websocket/reconnecting_websocket.d.ts +160 -0
  61. package/esm/src/transports/websocket/reconnecting_websocket.d.ts.map +1 -0
  62. package/esm/src/transports/websocket/reconnecting_websocket.js +370 -0
  63. package/esm/src/transports/websocket/websocket_request_dispatcher.d.ts +63 -0
  64. package/esm/src/transports/websocket/websocket_request_dispatcher.d.ts.map +1 -0
  65. package/esm/src/transports/websocket/websocket_request_dispatcher.js +201 -0
  66. package/esm/src/transports/websocket/websocket_transport.d.ts +117 -0
  67. package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -0
  68. package/esm/src/transports/websocket/websocket_transport.js +233 -0
  69. package/esm/src/utils/key_sort.d.ts +21 -0
  70. package/esm/src/utils/key_sort.d.ts.map +1 -0
  71. package/esm/src/utils/key_sort.js +124 -0
  72. package/esm/src/utils/signing.d.ts +109 -0
  73. package/esm/src/utils/signing.d.ts.map +1 -0
  74. package/esm/src/utils/signing.js +164 -0
  75. package/package.json +34 -0
  76. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts +2 -0
  77. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts.map +1 -0
  78. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js +17 -0
  79. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts +95 -0
  80. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts.map +1 -0
  81. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.js +14 -0
  82. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts +23 -0
  83. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts.map +1 -0
  84. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.js +49 -0
  85. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.d.ts +55 -0
  86. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.d.ts.map +1 -0
  87. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.js +88 -0
  88. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.d.ts +2 -0
  89. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.d.ts.map +1 -0
  90. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.js +4 -0
  91. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.d.ts +52 -0
  92. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.d.ts.map +1 -0
  93. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.js +288 -0
  94. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/utils.d.ts +120 -0
  95. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/utils.d.ts.map +1 -0
  96. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/utils.js +235 -0
  97. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts +19 -0
  98. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts.map +1 -0
  99. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.js +35 -0
  100. package/script/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.d.ts +2 -0
  101. package/script/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.d.ts.map +1 -0
  102. package/script/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.js +29 -0
  103. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts +37 -0
  104. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts.map +1 -0
  105. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.js +113 -0
  106. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts +37 -0
  107. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts.map +1 -0
  108. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.js +240 -0
  109. package/script/mod.d.ts +24 -0
  110. package/script/mod.d.ts.map +1 -0
  111. package/script/mod.js +27 -0
  112. package/script/package.json +3 -0
  113. package/script/src/clients/event.d.ts +374 -0
  114. package/script/src/clients/event.d.ts.map +1 -0
  115. package/script/src/clients/event.js +494 -0
  116. package/script/src/clients/public.d.ts +695 -0
  117. package/script/src/clients/public.d.ts.map +1 -0
  118. package/script/src/clients/public.js +708 -0
  119. package/script/src/clients/wallet.d.ts +682 -0
  120. package/script/src/clients/wallet.d.ts.map +1 -0
  121. package/script/src/clients/wallet.js +989 -0
  122. package/script/src/transports/base.d.ts +55 -0
  123. package/script/src/transports/base.d.ts.map +1 -0
  124. package/script/src/transports/base.js +18 -0
  125. package/script/src/transports/http/http_transport.d.ts +78 -0
  126. package/script/src/transports/http/http_transport.d.ts.map +1 -0
  127. package/script/src/transports/http/http_transport.js +175 -0
  128. package/script/src/transports/websocket/hyperliquid_event_target.d.ts +66 -0
  129. package/script/src/transports/websocket/hyperliquid_event_target.d.ts.map +1 -0
  130. package/script/src/transports/websocket/hyperliquid_event_target.js +37 -0
  131. package/script/src/transports/websocket/reconnecting_websocket.d.ts +160 -0
  132. package/script/src/transports/websocket/reconnecting_websocket.d.ts.map +1 -0
  133. package/script/src/transports/websocket/reconnecting_websocket.js +374 -0
  134. package/script/src/transports/websocket/websocket_request_dispatcher.d.ts +63 -0
  135. package/script/src/transports/websocket/websocket_request_dispatcher.d.ts.map +1 -0
  136. package/script/src/transports/websocket/websocket_request_dispatcher.js +206 -0
  137. package/script/src/transports/websocket/websocket_transport.d.ts +117 -0
  138. package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -0
  139. package/script/src/transports/websocket/websocket_transport.js +237 -0
  140. package/script/src/utils/key_sort.d.ts +21 -0
  141. package/script/src/utils/key_sort.d.ts.map +1 -0
  142. package/script/src/utils/key_sort.js +127 -0
  143. package/script/src/utils/signing.d.ts +109 -0
  144. package/script/src/utils/signing.d.ts.map +1 -0
  145. package/script/src/utils/signing.js +172 -0
@@ -0,0 +1,374 @@
1
+ import type { ISubscriptionTransport, Subscription } from "../transports/base.js";
2
+ import type { WsActiveAssetCtxRequest, WsActiveAssetDataRequest, WsCandleRequest, WsL2BookRequest, WsNotificationRequest, WsOrderUpdatesRequest, WsTradesRequest, WsUserEventsRequest, WsUserFillsRequest, WsUserFundingsRequest, WsUserNonFundingLedgerUpdatesRequest, WsUserTwapHistoryRequest, WsUserTwapSliceFillsRequest, WsWebData2Request } from "../types/subscriptions/requests";
3
+ import type { WsActiveAssetCtx, WsActiveAssetData, WsActiveSpotAssetCtx, WsAllMids, WsNotification, WsTrade, WsUserEvent, WsUserFills, WsUserFundings, WsUserNonFundingLedgerUpdates, WsUserTwapHistory, WsUserTwapSliceFills, WsWebData2 } from "../types/subscriptions/common";
4
+ import type { Candle } from "../types/info/assets";
5
+ import type { Book, Order, OrderStatus } from "../types/info/orders";
6
+ /** Parameters for the {@linkcode EventClient} constructor. */
7
+ export interface EventClientParameters<T extends ISubscriptionTransport = ISubscriptionTransport> {
8
+ /** The transport used to connect to the Hyperliquid API. */
9
+ transport: T;
10
+ }
11
+ /** Parameters for the {@linkcode EventClient.activeAssetCtx} method. */
12
+ export type EventActiveAssetCtxParameters = Omit<WsActiveAssetCtxRequest, "type">;
13
+ /** Parameters for the {@linkcode EventClient.activeAssetData} method. */
14
+ export type EventActiveAssetDataParameters = Omit<WsActiveAssetDataRequest, "type">;
15
+ /** Parameters for the {@linkcode EventClient.candle} method. */
16
+ export type EventCandleParameters = Omit<WsCandleRequest, "type">;
17
+ /** Parameters for the {@linkcode EventClient.l2Book} method. */
18
+ export type EventL2BookParameters = Omit<WsL2BookRequest, "type">;
19
+ /** Parameters for the {@linkcode EventClient.notification} method. */
20
+ export type EventNotificationParameters = Omit<WsNotificationRequest, "type">;
21
+ /** Parameters for the {@linkcode EventClient.orderUpdates} method. */
22
+ export type EventOrderUpdatesParameters = Omit<WsOrderUpdatesRequest, "type">;
23
+ /** Parameters for the {@linkcode EventClient.trades} method. */
24
+ export type EventTradesParameters = Omit<WsTradesRequest, "type">;
25
+ /** Parameters for the {@linkcode EventClient.userEvents} method. */
26
+ export type EventUserEventsParameters = Omit<WsUserEventsRequest, "type">;
27
+ /** Parameters for the {@linkcode EventClient.userFills} method. */
28
+ export type EventUserFillsParameters = Omit<WsUserFillsRequest, "type">;
29
+ /** Parameters for the {@linkcode EventClient.userFundings} method. */
30
+ export type EventUserFundingsParameters = Omit<WsUserFundingsRequest, "type">;
31
+ /** Parameters for the {@linkcode EventClient.userNonFundingLedgerUpdates} method. */
32
+ export type EventUserNonFundingLedgerUpdatesParameters = Omit<WsUserNonFundingLedgerUpdatesRequest, "type">;
33
+ /** Parameters for the {@linkcode EventClient.userTwapHistory} method. */
34
+ export type EventUserTwapHistory = Omit<WsUserTwapHistoryRequest, "type">;
35
+ /** Parameters for the {@linkcode EventClient.userTwapSliceFills} method. */
36
+ export type EventUserTwapSliceFills = Omit<WsUserTwapSliceFillsRequest, "type">;
37
+ /** Parameters for the {@linkcode EventClient.webData2} method. */
38
+ export type EventWebData2Parameters = Omit<WsWebData2Request, "type">;
39
+ /**
40
+ * Event client for subscribing to various Hyperliquid events.
41
+ * @typeParam T - The type of transport used to connect to the Hyperliquid Websocket API.
42
+ */
43
+ export declare class EventClient<T extends ISubscriptionTransport = ISubscriptionTransport> {
44
+ /** The transport used to connect to the Hyperliquid API. */
45
+ transport: T;
46
+ /**
47
+ * Initialises a new instance.
48
+ * @param args - The arguments for initialisation.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * import * as hl from "@nktkas/hyperliquid";
53
+ *
54
+ * const transport = new hl.WebSocketTransport();
55
+ * const client = new hl.EventClient({ transport });
56
+ * ```
57
+ */
58
+ constructor(args: EventClientParameters<T>);
59
+ /**
60
+ * Subscribe to context updates for a specific perpetual asset.
61
+ * @param args - The parameters for the subscription.
62
+ * @param listener - The callback function to be called when the event is received.
63
+ * @param signal - An optional abort signal for canceling the subscription request.
64
+ * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
65
+ *
66
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | Hyperliquid GitBook}
67
+ * @example
68
+ * ```ts
69
+ * import * as hl from "@nktkas/hyperliquid";
70
+ *
71
+ * const transport = new hl.WebSocketTransport();
72
+ * const client = new hl.EventClient({ transport });
73
+ *
74
+ * const sub = await client.activeAssetCtx({ coin: "BTC" }, (data) => {
75
+ * console.log(data);
76
+ * });
77
+ * ```
78
+ */
79
+ activeAssetCtx(args: EventActiveAssetCtxParameters, listener: (data: WsActiveAssetCtx | WsActiveSpotAssetCtx) => void, signal?: AbortSignal): Promise<Subscription>;
80
+ /**
81
+ * Subscribe to trading data updates for a specific asset and user.
82
+ * @param args - The parameters for the subscription.
83
+ * @param listener - The callback function to be called when the event is received.
84
+ * @param signal - An optional abort signal for canceling the subscription request.
85
+ * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
86
+ *
87
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | Hyperliquid GitBook}
88
+ * @example
89
+ * ```ts
90
+ * import * as hl from "@nktkas/hyperliquid";
91
+ *
92
+ * const transport = new hl.WebSocketTransport();
93
+ * const client = new hl.EventClient({ transport });
94
+ *
95
+ * const sub = await client.activeAssetData({ coin: "BTC", user: "0x..." }, (data) => {
96
+ * console.log(data);
97
+ * });
98
+ * ```
99
+ */
100
+ activeAssetData(args: EventActiveAssetDataParameters, listener: (data: WsActiveAssetData) => void, signal?: AbortSignal): Promise<Subscription>;
101
+ /**
102
+ * Subscribe to mid prices for all actively traded assets.
103
+ * @param listener - The callback function to be called when the event is received.
104
+ * @param signal - An optional abort signal for canceling the subscription request.
105
+ * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
106
+ *
107
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | Hyperliquid GitBook}
108
+ * @example
109
+ * ```ts
110
+ * import * as hl from "@nktkas/hyperliquid";
111
+ *
112
+ * const transport = new hl.WebSocketTransport();
113
+ * const client = new hl.EventClient({ transport });
114
+ *
115
+ * const sub = await client.allMids((data) => {
116
+ * console.log(data);
117
+ * });
118
+ * ```
119
+ */
120
+ allMids(listener: (data: WsAllMids) => void, signal?: AbortSignal): Promise<Subscription>;
121
+ /**
122
+ * Subscribe to candlestick data updates for a specific asset.
123
+ * @param args - The parameters for the subscription.
124
+ * @param listener - The callback function to be called when the event is received.
125
+ * @param signal - An optional abort signal for canceling the subscription request.
126
+ * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
127
+ *
128
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | Hyperliquid GitBook}
129
+ * @example
130
+ * ```ts
131
+ * import * as hl from "@nktkas/hyperliquid";
132
+ *
133
+ * const transport = new hl.WebSocketTransport();
134
+ * const client = new hl.EventClient({ transport });
135
+ *
136
+ * const sub = await client.candle({ coin: "BTC", interval: "1h" }, (data) => {
137
+ * console.log(data);
138
+ * });
139
+ * ```
140
+ */
141
+ candle(args: EventCandleParameters, listener: (data: Candle) => void, signal?: AbortSignal): Promise<Subscription>;
142
+ /**
143
+ * Subscribe to L2 order book updates for a specific asset.
144
+ * @param args - The parameters for the subscription.
145
+ * @param listener - The callback function to be called when the event is received.
146
+ * @param signal - An optional abort signal for canceling the subscription request.
147
+ * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
148
+ *
149
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | Hyperliquid GitBook}
150
+ * @example
151
+ * ```ts
152
+ * import * as hl from "@nktkas/hyperliquid";
153
+ *
154
+ * const transport = new hl.WebSocketTransport();
155
+ * const client = new hl.EventClient({ transport });
156
+ *
157
+ * const sub = await client.l2Book({ coin: "BTC" }, (data) => {
158
+ * console.log(data);
159
+ * });
160
+ * ```
161
+ */
162
+ l2Book(args: EventL2BookParameters, listener: (data: Book) => void, signal?: AbortSignal): Promise<Subscription>;
163
+ /**
164
+ * Subscribe to user notification.
165
+ * @param args - The parameters for the subscription.
166
+ * @param listener - The callback function to be called when the event is received.
167
+ * @param signal - An optional abort signal for canceling the subscription request.
168
+ * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
169
+ *
170
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | Hyperliquid GitBook}
171
+ * @example
172
+ * ```ts
173
+ * import * as hl from "@nktkas/hyperliquid";
174
+ *
175
+ * const transport = new hl.WebSocketTransport();
176
+ * const client = new hl.EventClient({ transport });
177
+ *
178
+ * const sub = await client.notification({ user: "0x..." }, (data) => {
179
+ * console.log(data);
180
+ * });
181
+ * ```
182
+ */
183
+ notification(args: EventNotificationParameters, listener: (data: WsNotification) => void, signal?: AbortSignal): Promise<Subscription>;
184
+ /**
185
+ * Subscribe to order status updates for a specific user.
186
+ * @param args - The parameters for the subscription.
187
+ * @param listener - The callback function to be called when the event is received.
188
+ * @param signal - An optional abort signal for canceling the subscription request.
189
+ * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
190
+ *
191
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | Hyperliquid GitBook}
192
+ * @example
193
+ * ```ts
194
+ * import * as hl from "@nktkas/hyperliquid";
195
+ *
196
+ * const transport = new hl.WebSocketTransport();
197
+ * const client = new hl.EventClient({ transport });
198
+ *
199
+ * const sub = await client.orderUpdates({ user: "0x..." }, (data) => {
200
+ * console.log(data);
201
+ * });
202
+ * ```
203
+ */
204
+ orderUpdates(args: EventOrderUpdatesParameters, listener: (data: OrderStatus<Order>[]) => void, signal?: AbortSignal): Promise<Subscription>;
205
+ /**
206
+ * Subscribe to real-time trade updates for a specific asset.
207
+ * @param args - The parameters for the subscription.
208
+ * @param listener - The callback function to be called when the event is received.
209
+ * @param signal - An optional abort signal for canceling the subscription request.
210
+ * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
211
+ *
212
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | Hyperliquid GitBook}
213
+ * @example
214
+ * ```ts
215
+ * import * as hl from "@nktkas/hyperliquid";
216
+ *
217
+ * const transport = new hl.WebSocketTransport();
218
+ * const client = new hl.EventClient({ transport });
219
+ *
220
+ * const sub = await client.trades({ coin: "BTC" }, (data) => {
221
+ * console.log(data);
222
+ * });
223
+ * ```
224
+ */
225
+ trades(args: EventTradesParameters, listener: (data: WsTrade[]) => void, signal?: AbortSignal): Promise<Subscription>;
226
+ /**
227
+ * Subscribe to all events for a specific user.
228
+ * @param args - The parameters for the subscription.
229
+ * @param listener - The callback function to be called when the event is received.
230
+ * @param signal - An optional abort signal for canceling the subscription request.
231
+ * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
232
+ *
233
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | Hyperliquid GitBook}
234
+ * @example
235
+ * ```ts
236
+ * import * as hl from "@nktkas/hyperliquid";
237
+ *
238
+ * const transport = new hl.WebSocketTransport();
239
+ * const client = new hl.EventClient({ transport });
240
+ *
241
+ * const sub = await client.userEvents({ user: "0x..." }, (data) => {
242
+ * console.log(data);
243
+ * });
244
+ * ```
245
+ */
246
+ userEvents(args: EventUserEventsParameters, listener: (data: WsUserEvent) => void, signal?: AbortSignal): Promise<Subscription>;
247
+ /**
248
+ * Subscribe to trade fill updates for a specific user.
249
+ * @param args - The parameters for the subscription.
250
+ * @param listener - The callback function to be called when the event is received.
251
+ * @param signal - An optional abort signal for canceling the subscription request.
252
+ * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
253
+ *
254
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | Hyperliquid GitBook}
255
+ * @example
256
+ * ```ts
257
+ * import * as hl from "@nktkas/hyperliquid";
258
+ *
259
+ * const transport = new hl.WebSocketTransport();
260
+ * const client = new hl.EventClient({ transport });
261
+ *
262
+ * const sub = await client.userFills({ user: "0x..." }, (data) => {
263
+ * console.log(data);
264
+ * });
265
+ * ```
266
+ */
267
+ userFills(args: EventUserFillsParameters, listener: (data: WsUserFills) => void, signal?: AbortSignal): Promise<Subscription>;
268
+ /**
269
+ * Subscribe to funding payment updates for a specific user.
270
+ * @param args - The parameters for the subscription.
271
+ * @param listener - The callback function to be called when the event is received.
272
+ * @param signal - An optional abort signal for canceling the subscription request.
273
+ * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
274
+ *
275
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | Hyperliquid GitBook}
276
+ * @example
277
+ * ```ts
278
+ * import * as hl from "@nktkas/hyperliquid";
279
+ *
280
+ * const transport = new hl.WebSocketTransport();
281
+ * const client = new hl.EventClient({ transport });
282
+ *
283
+ * const sub = await client.userFundings({ user: "0x..." }, (data) => {
284
+ * console.log(data);
285
+ * });
286
+ * ```
287
+ */
288
+ userFundings(args: EventUserFundingsParameters, listener: (data: WsUserFundings) => void, signal?: AbortSignal): Promise<Subscription>;
289
+ /**
290
+ * Subscribe to non-funding ledger updates for a specific user.
291
+ * @param args - The parameters for the subscription.
292
+ * @param listener - The callback function to be called when the event is received.
293
+ * @param signal - An optional abort signal for canceling the subscription request.
294
+ * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
295
+ *
296
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | Hyperliquid GitBook}
297
+ * @example
298
+ * ```ts
299
+ * import * as hl from "@nktkas/hyperliquid";
300
+ *
301
+ * const transport = new hl.WebSocketTransport();
302
+ * const client = new hl.EventClient({ transport });
303
+ *
304
+ * const sub = await client.userNonFundingLedgerUpdates({ user: "0x..." }, (data) => {
305
+ * console.log(data);
306
+ * });
307
+ * ```
308
+ */
309
+ userNonFundingLedgerUpdates(args: EventUserNonFundingLedgerUpdatesParameters, listener: (data: WsUserNonFundingLedgerUpdates) => void, signal?: AbortSignal): Promise<Subscription>;
310
+ /**
311
+ * Subscribe to TWAP order history updates for a specific user.
312
+ * @param args - The parameters for the subscription.
313
+ * @param listener - The callback function to be called when the event is received.
314
+ * @param signal - An optional abort signal for canceling the subscription request.
315
+ * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
316
+ *
317
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | Hyperliquid GitBook}
318
+ * @example
319
+ * ```ts
320
+ * import * as hl from "@nktkas/hyperliquid";
321
+ *
322
+ * const transport = new hl.WebSocketTransport();
323
+ * const client = new hl.EventClient({ transport });
324
+ *
325
+ * const sub = await client.userTwapHistory({ user: "0x..." }, (data) => {
326
+ * console.log(data);
327
+ * });
328
+ * ```
329
+ */
330
+ userTwapHistory(args: EventUserTwapHistory, listener: (data: WsUserTwapHistory) => void, signal?: AbortSignal): Promise<Subscription>;
331
+ /**
332
+ * Subscribe to TWAP execution updates for a specific user.
333
+ * @param args - The parameters for the subscription.
334
+ * @param listener - The callback function to be called when the event is received.
335
+ * @param signal - An optional abort signal for canceling the subscription request.
336
+ * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
337
+ *
338
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | Hyperliquid GitBook}
339
+ * @example
340
+ * ```ts
341
+ * import * as hl from "@nktkas/hyperliquid";
342
+ *
343
+ * const transport = new hl.WebSocketTransport();
344
+ * const client = new hl.EventClient({ transport });
345
+ *
346
+ * const sub = await client.userTwapSliceFills({ user: "0x..." }, (data) => {
347
+ * console.log(data);
348
+ * });
349
+ * ```
350
+ */
351
+ userTwapSliceFills(args: EventUserTwapSliceFills, listener: (data: WsUserTwapSliceFills) => void, signal?: AbortSignal): Promise<Subscription>;
352
+ /**
353
+ * Subscribe to comprehensive user and market data updates.
354
+ * @param args - The parameters for the subscription.
355
+ * @param listener - The callback function to be called when the event is received.
356
+ * @param signal - An optional abort signal for canceling the subscription request.
357
+ * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
358
+ *
359
+ * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions | Hyperliquid GitBook}
360
+ * @example
361
+ * ```ts
362
+ * import * as hl from "@nktkas/hyperliquid";
363
+ *
364
+ * const transport = new hl.WebSocketTransport();
365
+ * const client = new hl.EventClient({ transport });
366
+ *
367
+ * const sub = await client.webData2({ user: "0x..." }, (data) => {
368
+ * console.log(data);
369
+ * });
370
+ * ```
371
+ */
372
+ webData2(args: EventWebData2Parameters, listener: (data: WsWebData2) => void, signal?: AbortSignal): Promise<Subscription>;
373
+ }
374
+ //# sourceMappingURL=event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/src/clients/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,KAAK,EACR,uBAAuB,EACvB,wBAAwB,EAExB,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,oCAAoC,EACpC,wBAAwB,EACxB,2BAA2B,EAC3B,iBAAiB,EACpB,MAAM,iCAAiC,CAAC;AACz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