@nktkas/hyperliquid 0.13.0 → 0.13.2

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 (206) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +42 -17
  3. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +9 -0
  4. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +1 -0
  5. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.js +2 -0
  6. package/esm/deps/jsr.io/@std/bytes/{1.0.4 → 1.0.5}/concat.d.ts +3 -1
  7. package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +1 -0
  8. package/esm/deps/jsr.io/@std/bytes/{1.0.4 → 1.0.5}/concat.js +1 -1
  9. package/esm/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts +9 -0
  10. package/esm/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts.map +1 -0
  11. package/esm/deps/jsr.io/@std/encoding/1.0.7/_types.js +2 -0
  12. package/esm/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.d.ts.map +1 -1
  13. package/esm/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.js +1 -1
  14. package/{script/deps/jsr.io/@std/encoding/1.0.6 → esm/deps/jsr.io/@std/encoding/1.0.7}/hex.d.ts +3 -1
  15. package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +1 -0
  16. package/esm/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/hex.js +1 -1
  17. package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts +9 -0
  18. package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts.map +1 -0
  19. package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.js +2 -0
  20. package/esm/deps/jsr.io/@std/msgpack/{1.0.2 → 1.0.3}/encode.d.ts +3 -1
  21. package/esm/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts.map +1 -0
  22. package/esm/deps/jsr.io/@std/msgpack/{1.0.2 → 1.0.3}/encode.js +2 -2
  23. package/esm/mod.d.ts +15 -14
  24. package/esm/mod.d.ts.map +1 -1
  25. package/esm/src/clients/event.d.ts +64 -21
  26. package/esm/src/clients/event.d.ts.map +1 -1
  27. package/esm/src/clients/event.js +76 -18
  28. package/esm/src/clients/public.d.ts +244 -52
  29. package/esm/src/clients/public.d.ts.map +1 -1
  30. package/esm/src/clients/public.js +243 -47
  31. package/esm/src/clients/wallet.d.ts +122 -53
  32. package/esm/src/clients/wallet.d.ts.map +1 -1
  33. package/esm/src/clients/wallet.js +201 -65
  34. package/esm/src/transports/http/http_transport.d.ts.map +1 -1
  35. package/esm/src/transports/http/http_transport.js +4 -1
  36. package/esm/src/transports/websocket/hyperliquid_event_target.d.ts +27 -21
  37. package/esm/src/transports/websocket/hyperliquid_event_target.d.ts.map +1 -1
  38. package/esm/src/transports/websocket/hyperliquid_event_target.js +37 -0
  39. package/esm/src/transports/websocket/websocket_request_dispatcher.d.ts.map +1 -1
  40. package/esm/src/transports/websocket/websocket_request_dispatcher.js +4 -4
  41. package/esm/src/transports/websocket/websocket_transport.d.ts +7 -10
  42. package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  43. package/esm/src/transports/websocket/websocket_transport.js +41 -35
  44. package/esm/src/types/common.d.ts +3 -0
  45. package/esm/src/types/common.d.ts.map +1 -0
  46. package/esm/src/types/common.js +1 -0
  47. package/esm/src/types/exchange/common.d.ts +36 -0
  48. package/esm/src/types/exchange/common.d.ts.map +1 -0
  49. package/esm/src/types/exchange/common.js +1 -0
  50. package/esm/src/types/exchange/requests.d.ts +502 -0
  51. package/esm/src/types/exchange/requests.d.ts.map +1 -0
  52. package/esm/src/types/exchange/requests.js +1 -0
  53. package/esm/src/types/exchange/responses.d.ts +141 -0
  54. package/esm/src/types/exchange/responses.d.ts.map +1 -0
  55. package/esm/src/types/exchange/responses.js +1 -0
  56. package/esm/src/types/explorer/common.d.ts +37 -0
  57. package/esm/src/types/explorer/common.d.ts.map +1 -0
  58. package/esm/src/types/explorer/common.js +1 -0
  59. package/esm/src/types/explorer/requests.d.ts +35 -0
  60. package/esm/src/types/explorer/requests.d.ts.map +1 -0
  61. package/esm/src/types/explorer/requests.js +1 -0
  62. package/esm/src/types/explorer/responses.d.ts +23 -0
  63. package/esm/src/types/explorer/responses.d.ts.map +1 -0
  64. package/esm/src/types/explorer/responses.js +1 -0
  65. package/esm/src/types/info/accounts.d.ts +489 -0
  66. package/esm/src/types/info/accounts.d.ts.map +1 -0
  67. package/esm/src/types/info/accounts.js +1 -0
  68. package/esm/src/types/info/assets.d.ts +275 -0
  69. package/esm/src/types/info/assets.d.ts.map +1 -0
  70. package/esm/src/types/info/assets.js +1 -0
  71. package/esm/src/types/info/delegations.d.ts +117 -0
  72. package/esm/src/types/info/delegations.d.ts.map +1 -0
  73. package/esm/src/types/info/delegations.js +1 -0
  74. package/esm/src/types/info/orders.d.ts +209 -0
  75. package/esm/src/types/info/orders.d.ts.map +1 -0
  76. package/esm/src/types/info/orders.js +1 -0
  77. package/esm/src/types/info/requests.d.ts +445 -0
  78. package/esm/src/types/info/requests.d.ts.map +1 -0
  79. package/esm/src/types/info/requests.js +1 -0
  80. package/esm/src/types/info/vaults.d.ts +90 -0
  81. package/esm/src/types/info/vaults.d.ts.map +1 -0
  82. package/esm/src/types/info/vaults.js +1 -0
  83. package/esm/src/types/subscriptions/common.d.ts +208 -0
  84. package/esm/src/types/subscriptions/common.d.ts.map +1 -0
  85. package/esm/src/types/subscriptions/common.js +1 -0
  86. package/esm/src/types/subscriptions/requests.d.ts +134 -0
  87. package/esm/src/types/subscriptions/requests.d.ts.map +1 -0
  88. package/esm/src/types/subscriptions/requests.js +1 -0
  89. package/esm/src/utils/key_sort.d.ts +3 -3
  90. package/esm/src/utils/key_sort.d.ts.map +1 -1
  91. package/esm/src/utils/signing.d.ts +1 -1
  92. package/esm/src/utils/signing.js +2 -2
  93. package/package.json +2 -2
  94. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js +13 -3
  95. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.js +23 -13
  96. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.js +55 -45
  97. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.js +97 -87
  98. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.js +14 -4
  99. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.js +288 -278
  100. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/utils.js +238 -228
  101. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +9 -0
  102. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +1 -0
  103. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.js +13 -0
  104. package/script/deps/jsr.io/@std/bytes/{1.0.4 → 1.0.5}/concat.d.ts +3 -1
  105. package/script/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +1 -0
  106. package/script/deps/jsr.io/@std/bytes/1.0.5/concat.js +45 -0
  107. package/script/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts +9 -0
  108. package/script/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts.map +1 -0
  109. package/script/deps/jsr.io/@std/encoding/1.0.7/_types.js +13 -0
  110. package/script/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.d.ts.map +1 -1
  111. package/script/deps/jsr.io/@std/encoding/1.0.7/_validate_binary_like.js +39 -0
  112. package/{esm/deps/jsr.io/@std/encoding/1.0.6 → script/deps/jsr.io/@std/encoding/1.0.7}/hex.d.ts +3 -1
  113. package/script/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +1 -0
  114. package/script/deps/jsr.io/@std/encoding/1.0.7/hex.js +123 -0
  115. package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts +9 -0
  116. package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts.map +1 -0
  117. package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.js +13 -0
  118. package/script/deps/jsr.io/@std/msgpack/{1.0.2 → 1.0.3}/encode.d.ts +3 -1
  119. package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts.map +1 -0
  120. package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.js +250 -0
  121. package/script/mod.d.ts +15 -14
  122. package/script/mod.d.ts.map +1 -1
  123. package/script/mod.js +23 -13
  124. package/script/src/clients/event.d.ts +64 -21
  125. package/script/src/clients/event.d.ts.map +1 -1
  126. package/script/src/clients/event.js +551 -483
  127. package/script/src/clients/public.d.ts +244 -52
  128. package/script/src/clients/public.d.ts.map +1 -1
  129. package/script/src/clients/public.js +914 -708
  130. package/script/src/clients/wallet.d.ts +122 -53
  131. package/script/src/clients/wallet.d.ts.map +1 -1
  132. package/script/src/clients/wallet.js +1121 -975
  133. package/script/src/transports/base.js +25 -15
  134. package/script/src/transports/http/http_transport.d.ts.map +1 -1
  135. package/script/src/transports/http/http_transport.js +174 -161
  136. package/script/src/transports/websocket/hyperliquid_event_target.d.ts +27 -21
  137. package/script/src/transports/websocket/hyperliquid_event_target.d.ts.map +1 -1
  138. package/script/src/transports/websocket/hyperliquid_event_target.js +80 -33
  139. package/script/src/transports/websocket/reconnecting_websocket.js +364 -354
  140. package/script/src/transports/websocket/websocket_request_dispatcher.d.ts.map +1 -1
  141. package/script/src/transports/websocket/websocket_request_dispatcher.js +196 -186
  142. package/script/src/transports/websocket/websocket_transport.d.ts +7 -10
  143. package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  144. package/script/src/transports/websocket/websocket_transport.js +236 -220
  145. package/script/src/types/common.d.ts +3 -0
  146. package/script/src/types/common.d.ts.map +1 -0
  147. package/script/src/types/common.js +12 -0
  148. package/script/src/types/exchange/common.d.ts +36 -0
  149. package/script/src/types/exchange/common.d.ts.map +1 -0
  150. package/script/src/types/exchange/common.js +12 -0
  151. package/script/src/types/exchange/requests.d.ts +502 -0
  152. package/script/src/types/exchange/requests.d.ts.map +1 -0
  153. package/script/src/types/exchange/requests.js +12 -0
  154. package/script/src/types/exchange/responses.d.ts +141 -0
  155. package/script/src/types/exchange/responses.d.ts.map +1 -0
  156. package/script/src/types/exchange/responses.js +12 -0
  157. package/script/src/types/explorer/common.d.ts +37 -0
  158. package/script/src/types/explorer/common.d.ts.map +1 -0
  159. package/script/src/types/explorer/common.js +12 -0
  160. package/script/src/types/explorer/requests.d.ts +35 -0
  161. package/script/src/types/explorer/requests.d.ts.map +1 -0
  162. package/script/src/types/explorer/requests.js +12 -0
  163. package/script/src/types/explorer/responses.d.ts +23 -0
  164. package/script/src/types/explorer/responses.d.ts.map +1 -0
  165. package/script/src/types/explorer/responses.js +12 -0
  166. package/script/src/types/info/accounts.d.ts +489 -0
  167. package/script/src/types/info/accounts.d.ts.map +1 -0
  168. package/script/src/types/info/accounts.js +12 -0
  169. package/script/src/types/info/assets.d.ts +275 -0
  170. package/script/src/types/info/assets.d.ts.map +1 -0
  171. package/script/src/types/info/assets.js +12 -0
  172. package/script/src/types/info/delegations.d.ts +117 -0
  173. package/script/src/types/info/delegations.d.ts.map +1 -0
  174. package/script/src/types/info/delegations.js +12 -0
  175. package/script/src/types/info/orders.d.ts +209 -0
  176. package/script/src/types/info/orders.d.ts.map +1 -0
  177. package/script/src/types/info/orders.js +12 -0
  178. package/script/src/types/info/requests.d.ts +445 -0
  179. package/script/src/types/info/requests.d.ts.map +1 -0
  180. package/script/src/types/info/requests.js +12 -0
  181. package/script/src/types/info/vaults.d.ts +90 -0
  182. package/script/src/types/info/vaults.d.ts.map +1 -0
  183. package/script/src/types/info/vaults.js +12 -0
  184. package/script/src/types/subscriptions/common.d.ts +208 -0
  185. package/script/src/types/subscriptions/common.d.ts.map +1 -0
  186. package/script/src/types/subscriptions/common.js +12 -0
  187. package/script/src/types/subscriptions/requests.d.ts +134 -0
  188. package/script/src/types/subscriptions/requests.d.ts.map +1 -0
  189. package/script/src/types/subscriptions/requests.js +12 -0
  190. package/script/src/utils/key_sort.d.ts +3 -3
  191. package/script/src/utils/key_sort.d.ts.map +1 -1
  192. package/script/src/utils/key_sort.js +133 -123
  193. package/script/src/utils/signing.d.ts +1 -1
  194. package/script/src/utils/signing.js +172 -162
  195. package/esm/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts.map +0 -1
  196. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts.map +0 -1
  197. package/esm/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts.map +0 -1
  198. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts.map +0 -1
  199. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.js +0 -35
  200. package/script/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.js +0 -29
  201. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts.map +0 -1
  202. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.js +0 -113
  203. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts.map +0 -1
  204. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.js +0 -240
  205. /package/esm/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.d.ts +0 -0
  206. /package/script/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.d.ts +0 -0
@@ -1,708 +1,914 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PublicClient = void 0;
4
- /**
5
- * Public client for interacting with the Hyperliquid API.
6
- * @typeParam T - The type of transport used to connect to the Hyperliquid API.
7
- */
8
- class PublicClient {
9
- /**
10
- * Initialises a new instance.
11
- * @param args - The arguments for initialisation.
12
- *
13
- * @example
14
- * ```ts
15
- * import * as hl from "@nktkas/hyperliquid";
16
- *
17
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
18
- * const client = new hl.PublicClient({ transport });
19
- * ```
20
- */
21
- constructor(args) {
22
- /** The transport used to connect to the Hyperliquid API. */
23
- Object.defineProperty(this, "transport", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: void 0
28
- });
29
- this.transport = args.transport;
30
- }
31
- // ———————————————Info API———————————————
32
- /**
33
- * Request mid coin prices.
34
- * @param signal - An optional abort signal.
35
- * @returns Mid coin prices.
36
- *
37
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-mids-for-all-coins | Hyperliquid GitBook}
38
- * @example
39
- * ```ts
40
- * import * as hl from "@nktkas/hyperliquid";
41
- *
42
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
43
- * const client = new hl.PublicClient({ transport });
44
- *
45
- * const allMids = await client.allMids();
46
- * ```
47
- */
48
- allMids(signal) {
49
- return this.transport.request("info", { type: "allMids" }, signal);
50
- }
51
- /**
52
- * Request candlestick snapshots.
53
- * @param args - The parameters for the request.
54
- * @param signal - An optional abort signal.
55
- * @returns Array of candlestick data points.
56
- *
57
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#candle-snapshot | Hyperliquid GitBook}
58
- * @example
59
- * ```ts
60
- * import * as hl from "@nktkas/hyperliquid";
61
- *
62
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
63
- * const client = new hl.PublicClient({ transport });
64
- *
65
- * const candles = await client.candleSnapshot({
66
- * coin: "ETH",
67
- * interval: "1h",
68
- * startTime: Date.now() - 1000 * 60 * 60 * 24
69
- * });
70
- * ```
71
- */
72
- candleSnapshot(args, signal) {
73
- return this.transport.request("info", { type: "candleSnapshot", req: args }, signal);
74
- }
75
- /**
76
- * Request clearinghouse state.
77
- * @param args - The parameters for the request.
78
- * @param signal - An optional abort signal.
79
- * @returns Account summary for perpetual trading.
80
- *
81
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-users-perpetuals-account-summary | Hyperliquid GitBook}
82
- * @example
83
- * ```ts
84
- * import * as hl from "@nktkas/hyperliquid";
85
- *
86
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
87
- * const client = new hl.PublicClient({ transport });
88
- *
89
- * const state = await client.clearinghouseState({ user: "0x..." });
90
- * ```
91
- */
92
- clearinghouseState(args, signal) {
93
- return this.transport.request("info", { type: "clearinghouseState", ...args }, signal);
94
- }
95
- /**
96
- * Request user's extra agents.
97
- * @param args - The parameters for the request.
98
- * @param signal - An optional abort signal.
99
- * @returns User's extra agents.
100
- *
101
- * @example
102
- * ```ts
103
- * import * as hl from "@nktkas/hyperliquid";
104
- *
105
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
106
- * const client = new hl.PublicClient({ transport });
107
- *
108
- * const extraAgents = await client.extraAgents({ user: "0x..." });
109
- * ```
110
- */
111
- extraAgents(args, signal) {
112
- return this.transport.request("info", { type: "extraAgents", ...args }, signal);
113
- }
114
- /**
115
- * Request frontend open orders.
116
- * @param args - The parameters for the request.
117
- * @param signal - An optional abort signal.
118
- * @returns Array of open orders with additional frontend information.
119
- *
120
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-open-orders-with-additional-frontend-info | Hyperliquid GitBook}
121
- * @example
122
- * ```ts
123
- * import * as hl from "@nktkas/hyperliquid";
124
- *
125
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
126
- * const client = new hl.PublicClient({ transport });
127
- *
128
- * const orders = await client.frontendOpenOrders({ user: "0x..." });
129
- * ```
130
- */
131
- frontendOpenOrders(args, signal) {
132
- return this.transport.request("info", { type: "frontendOpenOrders", ...args }, signal);
133
- }
134
- /**
135
- * Request funding history.
136
- * @param args - The parameters for the request.
137
- * @param signal - An optional abort signal.
138
- * @returns Array of historical funding rate data for an asset.
139
- *
140
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-historical-funding-rates | Hyperliquid GitBook}
141
- * @example
142
- * ```ts
143
- * import * as hl from "@nktkas/hyperliquid";
144
- *
145
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
146
- * const client = new hl.PublicClient({ transport });
147
- *
148
- * const funding = await client.fundingHistory({
149
- * coin: "ETH",
150
- * startTime: Date.now() - 1000 * 60 * 60 * 24
151
- * });
152
- * ```
153
- */
154
- fundingHistory(args, signal) {
155
- return this.transport.request("info", { type: "fundingHistory", ...args }, signal);
156
- }
157
- /**
158
- * Request user's historical orders.
159
- * @param args - The parameters for the request.
160
- * @param signal - An optional abort signal.
161
- * @returns Array of user's historical orders.
162
- *
163
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-historical-orders | Hyperliquid GitBook}
164
- * @example
165
- * ```ts
166
- * import * as hl from "@nktkas/hyperliquid";
167
- *
168
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
169
- * const client = new hl.PublicClient({ transport });
170
- *
171
- * const orders = await client.historicalOrders({ user: "0x..." });
172
- * ```
173
- */
174
- historicalOrders(args, signal) {
175
- return this.transport.request("info", { type: "historicalOrders", ...args }, signal);
176
- }
177
- /**
178
- * Request L2 order book.
179
- * @param args - The parameters for the request.
180
- * @param signal - An optional abort signal.
181
- * @returns L2 order book snapshot.
182
- *
183
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#l2-book-snapshot | Hyperliquid GitBook}
184
- * @example
185
- * ```ts
186
- * import * as hl from "@nktkas/hyperliquid";
187
- *
188
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
189
- * const client = new hl.PublicClient({ transport });
190
- *
191
- * const book = await client.l2Book({ coin: "ETH", nSigFigs: 2 });
192
- * ```
193
- */
194
- l2Book(args, signal) {
195
- return this.transport.request("info", { type: "l2Book", ...args }, signal);
196
- }
197
- /**
198
- * Request builder fee approval.
199
- * @param args - The parameters for the request.
200
- * @param signal - An optional abort signal.
201
- * @returns Maximum builder fee approval.
202
- *
203
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#check-builder-fee-approval | Hyperliquid GitBook}
204
- * @example
205
- * ```ts
206
- * import * as hl from "@nktkas/hyperliquid";
207
- *
208
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
209
- * const client = new hl.PublicClient({ transport });
210
- *
211
- * const maxBuilderFee = await client.maxBuilderFee({ user: "0x...", builder: "0x..." });
212
- * ```
213
- */
214
- maxBuilderFee(args, signal) {
215
- return this.transport.request("info", { type: "maxBuilderFee", ...args }, signal);
216
- }
217
- /**
218
- * Request trading metadata.
219
- * @param signal - An optional abort signal.
220
- * @returns Metadata for perpetual assets.
221
- *
222
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-metadata | Hyperliquid GitBook}
223
- * @example
224
- * ```ts
225
- * import * as hl from "@nktkas/hyperliquid";
226
- *
227
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
228
- * const client = new hl.PublicClient({ transport });
229
- *
230
- * const meta = await client.meta();
231
- * ```
232
- */
233
- meta(signal) {
234
- return this.transport.request("info", { type: "meta" }, signal);
235
- }
236
- /**
237
- * Request metadata and asset contexts.
238
- * @param signal - An optional abort signal.
239
- * @returns Metadata and context information for each perpetual asset.
240
- *
241
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc | Hyperliquid GitBook}
242
- * @example
243
- * ```ts
244
- * import * as hl from "@nktkas/hyperliquid";
245
- *
246
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
247
- * const client = new hl.PublicClient({ transport });
248
- *
249
- * const [meta, assetCtxs] = await client.metaAndAssetCtxs();
250
- * ```
251
- */
252
- metaAndAssetCtxs(signal) {
253
- return this.transport.request("info", { type: "metaAndAssetCtxs" }, signal);
254
- }
255
- /**
256
- * Request open orders.
257
- * @param args - The parameters for the request.
258
- * @param signal - An optional abort signal.
259
- * @returns Array of open order.
260
- *
261
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-open-orders | Hyperliquid GitBook}
262
- * @example
263
- * ```ts
264
- * import * as hl from "@nktkas/hyperliquid";
265
- *
266
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
267
- * const client = new hl.PublicClient({ transport });
268
- *
269
- * const orders = await client.openOrders({ user: "0x..." });
270
- * ```
271
- */
272
- openOrders(args, signal) {
273
- return this.transport.request("info", { type: "openOrders", ...args }, signal);
274
- }
275
- /**
276
- * Request order status.
277
- * @param args - The parameters for the request.
278
- * @param signal - An optional abort signal.
279
- * @returns Result of an order status lookup.
280
- *
281
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-order-status-by-oid-or-cloid | Hyperliquid GitBook}
282
- * @example
283
- * ```ts
284
- * import * as hl from "@nktkas/hyperliquid";
285
- *
286
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
287
- * const client = new hl.PublicClient({ transport });
288
- *
289
- * const status = await client.orderStatus({ user: "0x...", oid: 12345 });
290
- * ```
291
- */
292
- orderStatus(args, signal) {
293
- return this.transport.request("info", { type: "orderStatus", ...args }, signal);
294
- }
295
- /**
296
- * Request predicted funding rates.
297
- * @param signal - An optional abort signal.
298
- * @returns Array of predicted funding rates.
299
- *
300
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-predicted-funding-rates-for-different-venues | Hyperliquid GitBook}
301
- * @example
302
- * ```ts
303
- * import * as hl from "@nktkas/hyperliquid";
304
- *
305
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
306
- * const client = new hl.PublicClient({ transport });
307
- *
308
- * const predictedFundings = await client.predictedFundings();
309
- * ```
310
- */
311
- predictedFundings(signal) {
312
- return this.transport.request("info", { type: "predictedFundings" }, signal);
313
- }
314
- /**
315
- * Request user referral.
316
- * @param args - The parameters for the request.
317
- * @param signal - An optional abort signal.
318
- * @returns Referral information for a user.
319
- *
320
- * @example
321
- * ```ts
322
- * import * as hl from "@nktkas/hyperliquid";
323
- *
324
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
325
- * const client = new hl.PublicClient({ transport });
326
- *
327
- * const referral = await client.referral({ user: "0x..." });
328
- * ```
329
- */
330
- referral(args, signal) {
331
- return this.transport.request("info", { type: "referral", ...args }, signal);
332
- }
333
- /**
334
- * Request spot clearinghouse state.
335
- * @param args - The parameters for the request.
336
- * @param signal - An optional abort signal.
337
- * @returns Balances for spot tokens.
338
- *
339
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-a-users-token-balances | Hyperliquid GitBook}
340
- * @example
341
- * ```ts
342
- * import * as hl from "@nktkas/hyperliquid";
343
- *
344
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
345
- * const client = new hl.PublicClient({ transport });
346
- *
347
- * const state = await client.spotClearinghouseState({ user: "0x..." });
348
- * ```
349
- */
350
- spotClearinghouseState(args, signal) {
351
- return this.transport.request("info", { type: "spotClearinghouseState", ...args }, signal);
352
- }
353
- /**
354
- * Request spot deploy state.
355
- * @param args - The parameters for the request.
356
- * @param signal - An optional abort signal.
357
- * @returns The deploy state of a user.
358
- *
359
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-information-about-the-spot-deploy-auction | Hyperliquid GitBook}
360
- */
361
- spotDeployState(args, signal) {
362
- return this.transport.request("info", { type: "spotDeployState", ...args }, signal);
363
- }
364
- /**
365
- * Request spot trading metadata.
366
- * @param signal - An optional abort signal.
367
- * @returns Metadata for spot assets.
368
- *
369
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-metadata | Hyperliquid GitBook}
370
- * @example
371
- * ```ts
372
- * import * as hl from "@nktkas/hyperliquid";
373
- *
374
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
375
- * const client = new hl.PublicClient({ transport });
376
- *
377
- * const meta = await client.spotMeta();
378
- * ```
379
- */
380
- spotMeta(signal) {
381
- return this.transport.request("info", { type: "spotMeta" }, signal);
382
- }
383
- /**
384
- * Request spot metadata and asset contexts.
385
- * @param signal - An optional abort signal.
386
- * @returns Metadata and context information for each spot asset.
387
- *
388
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts | Hyperliquid GitBook}
389
- * @example
390
- * ```ts
391
- * import * as hl from "@nktkas/hyperliquid";
392
- *
393
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
394
- * const client = new hl.PublicClient({ transport });
395
- *
396
- * const [meta, assetCtxs] = await client.spotMetaAndAssetCtxs();
397
- * ```
398
- */
399
- spotMetaAndAssetCtxs(signal) {
400
- return this.transport.request("info", { type: "spotMetaAndAssetCtxs" }, signal);
401
- }
402
- /**
403
- * Request user sub-accounts.
404
- * @param args - The parameters for the request.
405
- * @param signal - An optional abort signal.
406
- * @returns Array of user sub-account.
407
- *
408
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-subaccounts | Hyperliquid GitBook}
409
- * @example
410
- * ```ts
411
- * import * as hl from "@nktkas/hyperliquid";
412
- *
413
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
414
- * const client = new hl.PublicClient({ transport });
415
- *
416
- * const subAccounts = await client.subAccounts({ user: "0x..." });
417
- * ```
418
- */
419
- subAccounts(args, signal) {
420
- return this.transport.request("info", { type: "subAccounts", ...args }, signal);
421
- }
422
- /**
423
- * Request token details.
424
- * @param args - The parameters for the request.
425
- * @param signal - An optional abort signal.
426
- * @returns The details of a token.
427
- *
428
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-information-about-a-token | Hyperliquid GitBook}
429
- * @example
430
- * ```ts
431
- * import * as hl from "@nktkas/hyperliquid";
432
- *
433
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
434
- * const client = new hl.PublicClient({ transport });
435
- *
436
- * const details = await client.tokenDetails({ tokenId: "0x..." });
437
- * ```
438
- */
439
- tokenDetails(args, signal) {
440
- return this.transport.request("info", { type: "tokenDetails", ...args }, signal);
441
- }
442
- /**
443
- * Request twap history of a user.
444
- * @param args - The parameters for the request.
445
- * @param signal - An optional abort signal.
446
- * @returns The twap history of a user.
447
- *
448
- * @example
449
- * ```ts
450
- * import * as hl from "@nktkas/hyperliquid";
451
- *
452
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
453
- * const client = new hl.PublicClient({ transport });
454
- *
455
- * const twapHistory = await client.twapHistory({ user: "0x..." });
456
- * ```
457
- */
458
- twapHistory(args, signal) {
459
- return this.transport.request("info", { type: "twapHistory", ...args }, signal);
460
- }
461
- /**
462
- * Request user fees.
463
- * @param args - The parameters for the request.
464
- * @param signal - An optional abort signal.
465
- * @returns User fees.
466
- *
467
- * @example
468
- * ```ts
469
- * import * as hl from "@nktkas/hyperliquid";
470
- *
471
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
472
- * const client = new hl.PublicClient({ transport });
473
- *
474
- * const userFees = await client.userFees({ user: "0x..." });
475
- * ```
476
- */
477
- userFees(args, signal) {
478
- return this.transport.request("info", { type: "userFees", ...args }, signal);
479
- }
480
- /**
481
- * Request user fills.
482
- * @param args - The parameters for the request.
483
- * @param signal - An optional abort signal.
484
- * @returns Array of user's trade fill.
485
- *
486
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-fills | Hyperliquid GitBook}
487
- * @example
488
- * ```ts
489
- * import * as hl from "@nktkas/hyperliquid";
490
- *
491
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
492
- * const client = new hl.PublicClient({ transport });
493
- *
494
- * const fills = await client.userFills({ user: "0x..." });
495
- * ```
496
- */
497
- userFills(args, signal) {
498
- return this.transport.request("info", { type: "userFills", ...args }, signal);
499
- }
500
- /**
501
- * Request user fills by time.
502
- * @param args - The parameters for the request.
503
- * @param signal - An optional abort signal.
504
- * @returns Array of user's trade fill.
505
- *
506
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-fills-by-time | Hyperliquid GitBook}
507
- * @example
508
- * ```ts
509
- * import * as hl from "@nktkas/hyperliquid";
510
- *
511
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
512
- * const client = new hl.PublicClient({ transport });
513
- *
514
- * const fills = await client.userFillsByTime({
515
- * user: "0x...",
516
- * startTime: Date.now() - 1000 * 60 * 60 * 24
517
- * });
518
- * ```
519
- */
520
- userFillsByTime(args, signal) {
521
- return this.transport.request("info", { type: "userFillsByTime", ...args }, signal);
522
- }
523
- /**
524
- * Request user funding.
525
- * @param args - The parameters for the request.
526
- * @param signal - An optional abort signal.
527
- * @returns Array of user's funding ledger update.
528
- *
529
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-a-users-funding-history-or-non-funding-ledger-updates | Hyperliquid GitBook}
530
- * @example
531
- * ```ts
532
- * import * as hl from "@nktkas/hyperliquid";
533
- *
534
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
535
- * const client = new hl.PublicClient({ transport });
536
- *
537
- * const funding = await client.userFunding({
538
- * user: "0x...",
539
- * startTime: Date.now() - 1000 * 60 * 60 * 24
540
- * });
541
- * ```
542
- */
543
- userFunding(args, signal) {
544
- return this.transport.request("info", { type: "userFunding", ...args }, signal);
545
- }
546
- /**
547
- * Request user non-funding ledger updates.
548
- * @param args - The parameters for the request.
549
- * @param signal - An optional abort signal.
550
- * @returns Array of user's non-funding ledger update.
551
- *
552
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-a-users-funding-history-or-non-funding-ledger-updates | Hyperliquid GitBook}
553
- * @example
554
- * ```ts
555
- * import * as hl from "@nktkas/hyperliquid";
556
- *
557
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
558
- * const client = new hl.PublicClient({ transport });
559
- *
560
- * const funding = await client.userNonFundingLedgerUpdates({
561
- * user: "0x...",
562
- * startTime: Date.now() - 1000 * 60 * 60 * 24
563
- * });
564
- * ```
565
- */
566
- userNonFundingLedgerUpdates(args, signal) {
567
- return this.transport.request("info", { type: "userNonFundingLedgerUpdates", ...args }, signal);
568
- }
569
- /**
570
- * Request user rate limits.
571
- * @param args - The parameters for the request.
572
- * @param signal - An optional abort signal.
573
- * @returns User's rate limits.
574
- *
575
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-user-rate-limits | Hyperliquid GitBook}
576
- * @example
577
- * ```ts
578
- * import * as hl from "@nktkas/hyperliquid";
579
- *
580
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
581
- * const client = new hl.PublicClient({ transport });
582
- *
583
- * const rateLimit = await client.userRateLimit({ user: "0x..." });
584
- * ```
585
- */
586
- userRateLimit(args, signal) {
587
- return this.transport.request("info", { type: "userRateLimit", ...args }, signal);
588
- }
589
- /**
590
- * Request user twap slice fills.
591
- * @param args - The parameters for the request.
592
- * @param signal - An optional abort signal.
593
- * @returns Array of user's twap slice fill.
594
- *
595
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-twap-slice-fills | Hyperliquid GitBook}
596
- * @example
597
- * ```ts
598
- * import * as hl from "@nktkas/hyperliquid";
599
- *
600
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
601
- * const client = new hl.PublicClient({ transport });
602
- *
603
- * const fills = await client.userTwapSliceFills({ user: "0x..." });
604
- * ```
605
- */
606
- userTwapSliceFills(args, signal) {
607
- return this.transport.request("info", { type: "userTwapSliceFills", ...args }, signal);
608
- }
609
- /**
610
- * Request user vault deposits.
611
- * @param args - The parameters for the request.
612
- * @param signal - An optional abort signal.
613
- * @returns Array of user's vault deposits.
614
- *
615
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-vault-deposits | Hyperliquid GitBook}
616
- * @example
617
- * ```ts
618
- * import * as hl from "@nktkas/hyperliquid";
619
- *
620
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
621
- * const client = new hl.PublicClient({ transport });
622
- *
623
- * const deposits = await client.userVaultDeposits({ user: "0x..." });
624
- * ```
625
- */
626
- userVaultEquities(args, signal) {
627
- return this.transport.request("info", { type: "userVaultEquities", ...args }, signal);
628
- }
629
- /**
630
- * Request details of a vault.
631
- * @param args - The parameters for the request.
632
- * @param signal - An optional abort signal.
633
- * @returns Details of a vault.
634
- *
635
- * @see {@link https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-details-for-a-vault | Hyperliquid GitBook}
636
- * @example
637
- * ```ts
638
- * import * as hl from "@nktkas/hyperliquid";
639
- *
640
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
641
- * const client = new hl.PublicClient({ transport });
642
- *
643
- * const vault = await client.vaultDetails({ vaultAddress: "0x..." });
644
- * ```
645
- */
646
- vaultDetails(args, signal) {
647
- return this.transport.request("info", { type: "vaultDetails", ...args }, signal);
648
- }
649
- /**
650
- * Request a list of vaults less than 2 hours old.
651
- * @param args - The parameters for the request.
652
- * @param signal - An optional abort signal.
653
- * @returns Array of vault summaries.
654
- *
655
- * @example
656
- * ```ts
657
- * import * as hl from "@nktkas/hyperliquid";
658
- *
659
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
660
- * const client = new hl.PublicClient({ transport });
661
- *
662
- * const vaults = await client.vaultSummaries();
663
- * ```
664
- */
665
- vaultSummaries(signal) {
666
- return this.transport.request("info", { type: "vaultSummaries" }, signal);
667
- }
668
- // ———————————————Explorer API———————————————
669
- /**
670
- * Gets the details of a block.
671
- * @param args - The parameters for the request.
672
- * @param signal - An optional abort signal.
673
- * @returns A promise that resolves with the details of the block.
674
- *
675
- * @example
676
- * ```ts
677
- * import * as hl from "@nktkas/hyperliquid";
678
- *
679
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
680
- * const client = new hl.PublicClient({ transport });
681
- *
682
- * const { blockDetails } = await client.blockDetails({ height: 123 });
683
- * ```
684
- */
685
- blockDetails(args, signal) {
686
- return this.transport.request("explorer", { type: "blockDetails", ...args }, signal);
687
- }
688
- /**
689
- * Gets the details of a transaction.
690
- * @param args - The parameters for the request.
691
- * @param signal - An optional abort signal.
692
- * @returns A promise that resolves with the details of the transaction.
693
- *
694
- * @example
695
- * ```ts
696
- * import * as hl from "@nktkas/hyperliquid";
697
- *
698
- * const transport = new hl.HttpTransport(); // or WebSocketTransport
699
- * const client = new hl.PublicClient({ transport });
700
- *
701
- * const { tx } = await client.txDetails({ hash: "0x..." });
702
- * ```
703
- */
704
- txDetails(args, signal) {
705
- return this.transport.request("explorer", { type: "txDetails", ...args }, signal);
706
- }
707
- }
708
- exports.PublicClient = PublicClient;
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PublicClient = void 0;
13
+ // ——————————————— Client ———————————————
14
+ /**
15
+ * Public client for interacting with the Hyperliquid API.
16
+ * @typeParam T - The type of transport used to connect to the Hyperliquid API.
17
+ */
18
+ class PublicClient {
19
+ /**
20
+ * Initialises a new instance.
21
+ * @param args - The arguments for initialisation.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import * as hl from "@nktkas/hyperliquid";
26
+ *
27
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
28
+ * const client = new hl.PublicClient({ transport });
29
+ * ```
30
+ */
31
+ constructor(args) {
32
+ /** The transport used to connect to the Hyperliquid API. */
33
+ Object.defineProperty(this, "transport", {
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true,
37
+ value: void 0
38
+ });
39
+ this.transport = args.transport;
40
+ }
41
+ // ——————————————— Info API ———————————————
42
+ /**
43
+ * Request mid coin prices.
44
+ * @param signal - An optional abort signal.
45
+ * @returns Mid coin prices.
46
+ *
47
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-mids-for-all-coins
48
+ * @example
49
+ * ```ts
50
+ * import * as hl from "@nktkas/hyperliquid";
51
+ *
52
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
53
+ * const client = new hl.PublicClient({ transport });
54
+ *
55
+ * const allMids = await client.allMids();
56
+ * ```
57
+ */
58
+ allMids(signal) {
59
+ return this.transport.request("info", { type: "allMids" }, signal);
60
+ }
61
+ /**
62
+ * Request candlestick snapshots.
63
+ * @param args - The parameters for the request.
64
+ * @param signal - An optional abort signal.
65
+ * @returns Array of candlestick data points.
66
+ *
67
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#candle-snapshot
68
+ * @example
69
+ * ```ts
70
+ * import * as hl from "@nktkas/hyperliquid";
71
+ *
72
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
73
+ * const client = new hl.PublicClient({ transport });
74
+ *
75
+ * const candleSnapshot = await client.candleSnapshot({
76
+ * coin: "ETH",
77
+ * interval: "1h",
78
+ * startTime: Date.now() - 1000 * 60 * 60 * 24
79
+ * });
80
+ * ```
81
+ */
82
+ candleSnapshot(args, signal) {
83
+ return this.transport.request("info", { type: "candleSnapshot", req: args }, signal);
84
+ }
85
+ /**
86
+ * Request clearinghouse state.
87
+ * @param args - The parameters for the request.
88
+ * @param signal - An optional abort signal.
89
+ * @returns Account summary for perpetual trading.
90
+ *
91
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-users-perpetuals-account-summary
92
+ * @example
93
+ * ```ts
94
+ * import * as hl from "@nktkas/hyperliquid";
95
+ *
96
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
97
+ * const client = new hl.PublicClient({ transport });
98
+ *
99
+ * const clearinghouseState = await client.clearinghouseState({ user: "0x..." });
100
+ * ```
101
+ */
102
+ clearinghouseState(args, signal) {
103
+ return this.transport.request("info", { type: "clearinghouseState", ...args }, signal);
104
+ }
105
+ /**
106
+ * Request user staking delegations.
107
+ * @param args - The parameters for the request.
108
+ * @param signal - An optional abort signal.
109
+ * @returns Array of user's delegations to validators.
110
+ *
111
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-user-staking-delegations
112
+ * @example
113
+ * ```ts
114
+ * import * as hl from "@nktkas/hyperliquid";
115
+ *
116
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
117
+ * const client = new hl.PublicClient({ transport });
118
+ *
119
+ * const delegations = await client.delegations({ user: "0x..." });
120
+ * ```
121
+ */
122
+ delegations(args, signal) {
123
+ return this.transport.request("info", { type: "delegations", ...args }, signal);
124
+ }
125
+ /**
126
+ * Request user staking history.
127
+ * @param args - The parameters for the request.
128
+ * @param signal - An optional abort signal.
129
+ * @returns Array of user's staking updates.
130
+ *
131
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-user-staking-history
132
+ * @example
133
+ * ```ts
134
+ * import * as hl from "@nktkas/hyperliquid";
135
+ *
136
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
137
+ * const client = new hl.PublicClient({ transport });
138
+ *
139
+ * const delegatorHistory = await client.delegatorHistory({ user: "0x..." });
140
+ * ```
141
+ */
142
+ delegatorHistory(args, signal) {
143
+ return this.transport.request("info", { type: "delegatorHistory", ...args }, signal);
144
+ }
145
+ /**
146
+ * Request user staking rewards.
147
+ * @param args - The parameters for the request.
148
+ * @param signal - An optional abort signal.
149
+ * @returns Array of user's staking rewards.
150
+ *
151
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-user-staking-rewards
152
+ * @example
153
+ * ```ts
154
+ * import * as hl from "@nktkas/hyperliquid";
155
+ *
156
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
157
+ * const client = new hl.PublicClient({ transport });
158
+ *
159
+ * const delegatorRewards = await client.delegatorRewards({ user: "0x..." });
160
+ * ```
161
+ */
162
+ delegatorRewards(args, signal) {
163
+ return this.transport.request("info", { type: "delegatorRewards", ...args }, signal);
164
+ }
165
+ /**
166
+ * Request user staking summary.
167
+ * @param args - The parameters for the request.
168
+ * @param signal - An optional abort signal.
169
+ * @returns Summary of a user's staking delegations.
170
+ *
171
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-user-staking-summary
172
+ * @example
173
+ * ```ts
174
+ * import * as hl from "@nktkas/hyperliquid";
175
+ *
176
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
177
+ * const client = new hl.PublicClient({ transport });
178
+ *
179
+ * const delegatorSummary = await client.delegatorSummary({ user: "0x..." });
180
+ * ```
181
+ */
182
+ delegatorSummary(args, signal) {
183
+ return this.transport.request("info", { type: "delegatorSummary", ...args }, signal);
184
+ }
185
+ /**
186
+ * Request user's extra agents.
187
+ * @param args - The parameters for the request.
188
+ * @param signal - An optional abort signal.
189
+ * @returns User's extra agents.
190
+ *
191
+ * @see null - no documentation
192
+ * @example
193
+ * ```ts
194
+ * import * as hl from "@nktkas/hyperliquid";
195
+ *
196
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
197
+ * const client = new hl.PublicClient({ transport });
198
+ *
199
+ * const extraAgents = await client.extraAgents({ user: "0x..." });
200
+ * ```
201
+ */
202
+ extraAgents(args, signal) {
203
+ return this.transport.request("info", { type: "extraAgents", ...args }, signal);
204
+ }
205
+ /**
206
+ * Request frontend open orders.
207
+ * @param args - The parameters for the request.
208
+ * @param signal - An optional abort signal.
209
+ * @returns Array of open orders with additional frontend information.
210
+ *
211
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-open-orders-with-additional-frontend-info
212
+ * @example
213
+ * ```ts
214
+ * import * as hl from "@nktkas/hyperliquid";
215
+ *
216
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
217
+ * const client = new hl.PublicClient({ transport });
218
+ *
219
+ * const frontendOpenOrders = await client.frontendOpenOrders({ user: "0x..." });
220
+ * ```
221
+ */
222
+ frontendOpenOrders(args, signal) {
223
+ return this.transport.request("info", { type: "frontendOpenOrders", ...args }, signal);
224
+ }
225
+ /**
226
+ * Request funding history.
227
+ * @param args - The parameters for the request.
228
+ * @param signal - An optional abort signal.
229
+ * @returns Array of historical funding rate data for an asset.
230
+ *
231
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-historical-funding-rates
232
+ * @example
233
+ * ```ts
234
+ * import * as hl from "@nktkas/hyperliquid";
235
+ *
236
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
237
+ * const client = new hl.PublicClient({ transport });
238
+ *
239
+ * const fundingHistory = await client.fundingHistory({
240
+ * coin: "ETH",
241
+ * startTime: Date.now() - 1000 * 60 * 60 * 24
242
+ * });
243
+ * ```
244
+ */
245
+ fundingHistory(args, signal) {
246
+ return this.transport.request("info", { type: "fundingHistory", ...args }, signal);
247
+ }
248
+ /**
249
+ * Request user's historical orders.
250
+ * @param args - The parameters for the request.
251
+ * @param signal - An optional abort signal.
252
+ * @returns Array of user's historical orders.
253
+ *
254
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-historical-orders
255
+ * @example
256
+ * ```ts
257
+ * import * as hl from "@nktkas/hyperliquid";
258
+ *
259
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
260
+ * const client = new hl.PublicClient({ transport });
261
+ *
262
+ * const historicalOrders = await client.historicalOrders({ user: "0x..." });
263
+ * ```
264
+ */
265
+ historicalOrders(args, signal) {
266
+ return this.transport.request("info", { type: "historicalOrders", ...args }, signal);
267
+ }
268
+ /**
269
+ * Request L2 order book.
270
+ * @param args - The parameters for the request.
271
+ * @param signal - An optional abort signal.
272
+ * @returns L2 order book snapshot.
273
+ *
274
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#l2-book-snapshot
275
+ * @example
276
+ * ```ts
277
+ * import * as hl from "@nktkas/hyperliquid";
278
+ *
279
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
280
+ * const client = new hl.PublicClient({ transport });
281
+ *
282
+ * const l2Book = await client.l2Book({ coin: "ETH", nSigFigs: 2 });
283
+ * ```
284
+ */
285
+ l2Book(args, signal) {
286
+ return this.transport.request("info", { type: "l2Book", ...args }, signal);
287
+ }
288
+ /**
289
+ * Request builder fee approval.
290
+ * @param args - The parameters for the request.
291
+ * @param signal - An optional abort signal.
292
+ * @returns Maximum builder fee approval.
293
+ *
294
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#check-builder-fee-approval
295
+ * @example
296
+ * ```ts
297
+ * import * as hl from "@nktkas/hyperliquid";
298
+ *
299
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
300
+ * const client = new hl.PublicClient({ transport });
301
+ *
302
+ * const maxBuilderFee = await client.maxBuilderFee({ user: "0x...", builder: "0x..." });
303
+ * ```
304
+ */
305
+ maxBuilderFee(args, signal) {
306
+ return this.transport.request("info", { type: "maxBuilderFee", ...args }, signal);
307
+ }
308
+ /**
309
+ * Request trading metadata.
310
+ * @param signal - An optional abort signal.
311
+ * @returns Metadata for perpetual assets.
312
+ *
313
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-metadata
314
+ * @example
315
+ * ```ts
316
+ * import * as hl from "@nktkas/hyperliquid";
317
+ *
318
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
319
+ * const client = new hl.PublicClient({ transport });
320
+ *
321
+ * const meta = await client.meta();
322
+ * ```
323
+ */
324
+ meta(signal) {
325
+ return this.transport.request("info", { type: "meta" }, signal);
326
+ }
327
+ /**
328
+ * Request metadata and asset contexts.
329
+ * @param signal - An optional abort signal.
330
+ * @returns Metadata and context information for each perpetual asset.
331
+ *
332
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
333
+ * @example
334
+ * ```ts
335
+ * import * as hl from "@nktkas/hyperliquid";
336
+ *
337
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
338
+ * const client = new hl.PublicClient({ transport });
339
+ *
340
+ * const [meta, assetCtxs] = await client.metaAndAssetCtxs();
341
+ * ```
342
+ */
343
+ metaAndAssetCtxs(signal) {
344
+ return this.transport.request("info", { type: "metaAndAssetCtxs" }, signal);
345
+ }
346
+ /**
347
+ * Request open orders.
348
+ * @param args - The parameters for the request.
349
+ * @param signal - An optional abort signal.
350
+ * @returns Array of open order.
351
+ *
352
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-open-orders
353
+ * @example
354
+ * ```ts
355
+ * import * as hl from "@nktkas/hyperliquid";
356
+ *
357
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
358
+ * const client = new hl.PublicClient({ transport });
359
+ *
360
+ * const openOrders = await client.openOrders({ user: "0x..." });
361
+ * ```
362
+ */
363
+ openOrders(args, signal) {
364
+ return this.transport.request("info", { type: "openOrders", ...args }, signal);
365
+ }
366
+ /**
367
+ * Request order status.
368
+ * @param args - The parameters for the request.
369
+ * @param signal - An optional abort signal.
370
+ * @returns Result of an order status lookup.
371
+ *
372
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-order-status-by-oid-or-cloid
373
+ * @example
374
+ * ```ts
375
+ * import * as hl from "@nktkas/hyperliquid";
376
+ *
377
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
378
+ * const client = new hl.PublicClient({ transport });
379
+ *
380
+ * const orderStatus = await client.orderStatus({ user: "0x...", oid: 12345 });
381
+ * ```
382
+ */
383
+ orderStatus(args, signal) {
384
+ return this.transport.request("info", { type: "orderStatus", ...args }, signal);
385
+ }
386
+ /**
387
+ * Request portfolio.
388
+ * @param args - The parameters for the request.
389
+ * @param signal - An optional abort signal.
390
+ * @returns Portfolio of a user.
391
+ *
392
+ * @see null - no documentation
393
+ * @example
394
+ * ```ts
395
+ * import * as hl from "@nktkas/hyperliquid";
396
+ *
397
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
398
+ * const client = new hl.PublicClient({ transport });
399
+ *
400
+ * const portfolio = await client.portfolio({ user: "0x..." });
401
+ * ```
402
+ */
403
+ portfolio(args, signal) {
404
+ return this.transport.request("info", { type: "portfolio", ...args }, signal);
405
+ }
406
+ /**
407
+ * Request perpetuals at open interest cap.
408
+ * @param args - The parameters for the request.
409
+ * @param signal - An optional abort signal.
410
+ * @returns Array of perpetuals at open interest caps.
411
+ *
412
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#query-perps-at-open-interest-caps
413
+ * @example
414
+ * ```ts
415
+ * import * as hl from "@nktkas/hyperliquid";
416
+ *
417
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
418
+ * const client = new hl.PublicClient({ transport });
419
+ *
420
+ * const perpsAtOpenInterestCap = await client.perpsAtOpenInterestCap();
421
+ * ```
422
+ */
423
+ perpsAtOpenInterestCap(signal) {
424
+ return this.transport.request("info", { type: "perpsAtOpenInterestCap" }, signal);
425
+ }
426
+ /**
427
+ * Request predicted funding rates.
428
+ * @param signal - An optional abort signal.
429
+ * @returns Array of predicted funding rates.
430
+ *
431
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-predicted-funding-rates-for-different-venues
432
+ * @example
433
+ * ```ts
434
+ * import * as hl from "@nktkas/hyperliquid";
435
+ *
436
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
437
+ * const client = new hl.PublicClient({ transport });
438
+ *
439
+ * const predictedFundings = await client.predictedFundings();
440
+ * ```
441
+ */
442
+ predictedFundings(signal) {
443
+ return this.transport.request("info", { type: "predictedFundings" }, signal);
444
+ }
445
+ /**
446
+ * Request user referral.
447
+ * @param args - The parameters for the request.
448
+ * @param signal - An optional abort signal.
449
+ * @returns Referral information for a user.
450
+ *
451
+ * @see null - no documentation
452
+ * @example
453
+ * ```ts
454
+ * import * as hl from "@nktkas/hyperliquid";
455
+ *
456
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
457
+ * const client = new hl.PublicClient({ transport });
458
+ *
459
+ * const referral = await client.referral({ user: "0x..." });
460
+ * ```
461
+ */
462
+ referral(args, signal) {
463
+ return this.transport.request("info", { type: "referral", ...args }, signal);
464
+ }
465
+ /**
466
+ * Request spot clearinghouse state.
467
+ * @param args - The parameters for the request.
468
+ * @param signal - An optional abort signal.
469
+ * @returns Balances for spot tokens.
470
+ *
471
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-a-users-token-balances
472
+ * @example
473
+ * ```ts
474
+ * import * as hl from "@nktkas/hyperliquid";
475
+ *
476
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
477
+ * const client = new hl.PublicClient({ transport });
478
+ *
479
+ * const spotClearinghouseState = await client.spotClearinghouseState({ user: "0x..." });
480
+ * ```
481
+ */
482
+ spotClearinghouseState(args, signal) {
483
+ return this.transport.request("info", { type: "spotClearinghouseState", ...args }, signal);
484
+ }
485
+ /**
486
+ * Request spot deploy state.
487
+ * @param args - The parameters for the request.
488
+ * @param signal - An optional abort signal.
489
+ * @returns The deploy state of a user.
490
+ *
491
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-information-about-the-spot-deploy-auction
492
+ * @example
493
+ * ```ts
494
+ * import * as hl from "@nktkas/hyperliquid";
495
+ *
496
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
497
+ * const client = new hl.PublicClient({ transport });
498
+ *
499
+ * const spotDeployState = await client.spotDeployState({ user: "0x..." });
500
+ * ```
501
+ */
502
+ spotDeployState(args, signal) {
503
+ return this.transport.request("info", { type: "spotDeployState", ...args }, signal);
504
+ }
505
+ /**
506
+ * Request spot trading metadata.
507
+ * @param signal - An optional abort signal.
508
+ * @returns Metadata for spot assets.
509
+ *
510
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-metadata
511
+ * @example
512
+ * ```ts
513
+ * import * as hl from "@nktkas/hyperliquid";
514
+ *
515
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
516
+ * const client = new hl.PublicClient({ transport });
517
+ *
518
+ * const spotMeta = await client.spotMeta();
519
+ * ```
520
+ */
521
+ spotMeta(signal) {
522
+ return this.transport.request("info", { type: "spotMeta" }, signal);
523
+ }
524
+ /**
525
+ * Request spot metadata and asset contexts.
526
+ * @param signal - An optional abort signal.
527
+ * @returns Metadata and context information for each spot asset.
528
+ *
529
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts
530
+ * @example
531
+ * ```ts
532
+ * import * as hl from "@nktkas/hyperliquid";
533
+ *
534
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
535
+ * const client = new hl.PublicClient({ transport });
536
+ *
537
+ * const [spotMeta, spotAssetCtxs] = await client.spotMetaAndAssetCtxs();
538
+ * ```
539
+ */
540
+ spotMetaAndAssetCtxs(signal) {
541
+ return this.transport.request("info", { type: "spotMetaAndAssetCtxs" }, signal);
542
+ }
543
+ /**
544
+ * Request user sub-accounts.
545
+ * @param args - The parameters for the request.
546
+ * @param signal - An optional abort signal.
547
+ * @returns Array of user sub-account.
548
+ *
549
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-subaccounts
550
+ * @example
551
+ * ```ts
552
+ * import * as hl from "@nktkas/hyperliquid";
553
+ *
554
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
555
+ * const client = new hl.PublicClient({ transport });
556
+ *
557
+ * const subAccounts = await client.subAccounts({ user: "0x..." });
558
+ * ```
559
+ */
560
+ subAccounts(args, signal) {
561
+ return this.transport.request("info", { type: "subAccounts", ...args }, signal);
562
+ }
563
+ /**
564
+ * Request token details.
565
+ * @param args - The parameters for the request.
566
+ * @param signal - An optional abort signal.
567
+ * @returns The details of a token.
568
+ *
569
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-information-about-a-token
570
+ * @example
571
+ * ```ts
572
+ * import * as hl from "@nktkas/hyperliquid";
573
+ *
574
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
575
+ * const client = new hl.PublicClient({ transport });
576
+ *
577
+ * const tokenDetails = await client.tokenDetails({ tokenId: "0x..." });
578
+ * ```
579
+ */
580
+ tokenDetails(args, signal) {
581
+ return this.transport.request("info", { type: "tokenDetails", ...args }, signal);
582
+ }
583
+ /**
584
+ * Request twap history of a user.
585
+ * @param args - The parameters for the request.
586
+ * @param signal - An optional abort signal.
587
+ * @returns The twap history of a user.
588
+ *
589
+ * @see null - no documentation
590
+ * @example
591
+ * ```ts
592
+ * import * as hl from "@nktkas/hyperliquid";
593
+ *
594
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
595
+ * const client = new hl.PublicClient({ transport });
596
+ *
597
+ * const twapHistory = await client.twapHistory({ user: "0x..." });
598
+ * ```
599
+ */
600
+ twapHistory(args, signal) {
601
+ return this.transport.request("info", { type: "twapHistory", ...args }, signal);
602
+ }
603
+ /**
604
+ * Request user fees.
605
+ * @param args - The parameters for the request.
606
+ * @param signal - An optional abort signal.
607
+ * @returns User fees.
608
+ *
609
+ * @see null - no documentation
610
+ * @example
611
+ * ```ts
612
+ * import * as hl from "@nktkas/hyperliquid";
613
+ *
614
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
615
+ * const client = new hl.PublicClient({ transport });
616
+ *
617
+ * const fees = await client.userFees({ user: "0x..." });
618
+ * ```
619
+ */
620
+ userFees(args, signal) {
621
+ return this.transport.request("info", { type: "userFees", ...args }, signal);
622
+ }
623
+ /**
624
+ * Request user fills.
625
+ * @param args - The parameters for the request.
626
+ * @param signal - An optional abort signal.
627
+ * @returns Array of user's trade fill.
628
+ *
629
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-fills
630
+ * @example
631
+ * ```ts
632
+ * import * as hl from "@nktkas/hyperliquid";
633
+ *
634
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
635
+ * const client = new hl.PublicClient({ transport });
636
+ *
637
+ * const fills = await client.userFills({ user: "0x..." });
638
+ * ```
639
+ */
640
+ userFills(args, signal) {
641
+ return this.transport.request("info", { type: "userFills", ...args }, signal);
642
+ }
643
+ /**
644
+ * Request user fills by time.
645
+ * @param args - The parameters for the request.
646
+ * @param signal - An optional abort signal.
647
+ * @returns Array of user's trade fill.
648
+ *
649
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-fills-by-time
650
+ * @example
651
+ * ```ts
652
+ * import * as hl from "@nktkas/hyperliquid";
653
+ *
654
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
655
+ * const client = new hl.PublicClient({ transport });
656
+ *
657
+ * const fills = await client.userFillsByTime({
658
+ * user: "0x...",
659
+ * startTime: Date.now() - 1000 * 60 * 60 * 24
660
+ * });
661
+ * ```
662
+ */
663
+ userFillsByTime(args, signal) {
664
+ return this.transport.request("info", { type: "userFillsByTime", ...args }, signal);
665
+ }
666
+ /**
667
+ * Request user funding.
668
+ * @param args - The parameters for the request.
669
+ * @param signal - An optional abort signal.
670
+ * @returns Array of user's funding ledger update.
671
+ *
672
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-a-users-funding-history-or-non-funding-ledger-updates
673
+ * @example
674
+ * ```ts
675
+ * import * as hl from "@nktkas/hyperliquid";
676
+ *
677
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
678
+ * const client = new hl.PublicClient({ transport });
679
+ *
680
+ * const funding = await client.userFunding({
681
+ * user: "0x...",
682
+ * startTime: Date.now() - 1000 * 60 * 60 * 24
683
+ * });
684
+ * ```
685
+ */
686
+ userFunding(args, signal) {
687
+ return this.transport.request("info", { type: "userFunding", ...args }, signal);
688
+ }
689
+ /**
690
+ * Request user non-funding ledger updates.
691
+ * @param args - The parameters for the request.
692
+ * @param signal - An optional abort signal.
693
+ * @returns Array of user's non-funding ledger update.
694
+ *
695
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-a-users-funding-history-or-non-funding-ledger-updates
696
+ * @example
697
+ * ```ts
698
+ * import * as hl from "@nktkas/hyperliquid";
699
+ *
700
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
701
+ * const client = new hl.PublicClient({ transport });
702
+ *
703
+ * const nonFundingLedgerUpdates = await client.userNonFundingLedgerUpdates({
704
+ * user: "0x...",
705
+ * startTime: Date.now() - 1000 * 60 * 60 * 24
706
+ * });
707
+ * ```
708
+ */
709
+ userNonFundingLedgerUpdates(args, signal) {
710
+ return this.transport.request("info", { type: "userNonFundingLedgerUpdates", ...args }, signal);
711
+ }
712
+ /**
713
+ * Request user rate limits.
714
+ * @param args - The parameters for the request.
715
+ * @param signal - An optional abort signal.
716
+ * @returns User's rate limits.
717
+ *
718
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-user-rate-limits
719
+ * @example
720
+ * ```ts
721
+ * import * as hl from "@nktkas/hyperliquid";
722
+ *
723
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
724
+ * const client = new hl.PublicClient({ transport });
725
+ *
726
+ * const rateLimit = await client.userRateLimit({ user: "0x..." });
727
+ * ```
728
+ */
729
+ userRateLimit(args, signal) {
730
+ return this.transport.request("info", { type: "userRateLimit", ...args }, signal);
731
+ }
732
+ /**
733
+ * Request user role.
734
+ * @param args - The parameters for the request.
735
+ * @param signal - An optional abort signal.
736
+ * @returns User's role.
737
+ *
738
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#query-a-users-role
739
+ * @example
740
+ * ```ts
741
+ * import * as hl from "@nktkas/hyperliquid";
742
+ *
743
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
744
+ * const client = new hl.PublicClient({ transport });
745
+ *
746
+ * const userRole = await client.userRole({ user: "0x..." });
747
+ * ```
748
+ */
749
+ userRole(args, signal) {
750
+ return this.transport.request("info", { type: "userRole", ...args }, signal);
751
+ }
752
+ /**
753
+ * Request user twap slice fills.
754
+ * @param args - The parameters for the request.
755
+ * @param signal - An optional abort signal.
756
+ * @returns Array of user's twap slice fill.
757
+ *
758
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-twap-slice-fills
759
+ * @example
760
+ * ```ts
761
+ * import * as hl from "@nktkas/hyperliquid";
762
+ *
763
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
764
+ * const client = new hl.PublicClient({ transport });
765
+ *
766
+ * const twapSliceFills = await client.userTwapSliceFills({ user: "0x..." });
767
+ * ```
768
+ */
769
+ userTwapSliceFills(args, signal) {
770
+ return this.transport.request("info", { type: "userTwapSliceFills", ...args }, signal);
771
+ }
772
+ /**
773
+ * Request user vault deposits.
774
+ * @param args - The parameters for the request.
775
+ * @param signal - An optional abort signal.
776
+ * @returns Array of user's vault deposits.
777
+ *
778
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-vault-deposits
779
+ * @example
780
+ * ```ts
781
+ * import * as hl from "@nktkas/hyperliquid";
782
+ *
783
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
784
+ * const client = new hl.PublicClient({ transport });
785
+ *
786
+ * const userVaultEquities = await client.userVaultDeposits({ user: "0x..." });
787
+ * ```
788
+ */
789
+ userVaultEquities(args, signal) {
790
+ return this.transport.request("info", { type: "userVaultEquities", ...args }, signal);
791
+ }
792
+ /**
793
+ * Request validator summaries.
794
+ * @param args - The parameters for the request.
795
+ * @returns Array of validator summaries.
796
+ *
797
+ * @see null - no documentation
798
+ * @example
799
+ * ```ts
800
+ * import * as hl from "@nktkas/hyperliquid";
801
+ *
802
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
803
+ * const client = new hl.PublicClient({ transport });
804
+ *
805
+ * const validatorSummaries = await client.validatorSummaries();
806
+ * ```
807
+ */
808
+ validatorSummaries(signal) {
809
+ return this.transport.request("info", { type: "validatorSummaries" }, signal);
810
+ }
811
+ /**
812
+ * Request details of a vault.
813
+ * @param args - The parameters for the request.
814
+ * @param signal - An optional abort signal.
815
+ * @returns Details of a vault.
816
+ *
817
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-details-for-a-vault
818
+ * @example
819
+ * ```ts
820
+ * import * as hl from "@nktkas/hyperliquid";
821
+ *
822
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
823
+ * const client = new hl.PublicClient({ transport });
824
+ *
825
+ * const vaultDetails = await client.vaultDetails({ vaultAddress: "0x..." });
826
+ * ```
827
+ */
828
+ vaultDetails(args, signal) {
829
+ return this.transport.request("info", { type: "vaultDetails", ...args }, signal);
830
+ }
831
+ /**
832
+ * Request a list of vaults less than 2 hours old.
833
+ * @param args - The parameters for the request.
834
+ * @param signal - An optional abort signal.
835
+ * @returns Array of vault summaries.
836
+ *
837
+ * @see null - no documentation
838
+ * @example
839
+ * ```ts
840
+ * import * as hl from "@nktkas/hyperliquid";
841
+ *
842
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
843
+ * const client = new hl.PublicClient({ transport });
844
+ *
845
+ * const vaultSummaries = await client.vaultSummaries();
846
+ * ```
847
+ */
848
+ vaultSummaries(signal) {
849
+ return this.transport.request("info", { type: "vaultSummaries" }, signal);
850
+ }
851
+ // ——————————————— Explorer API ———————————————
852
+ /**
853
+ * Gets the details of a block.
854
+ * @param args - The parameters for the request.
855
+ * @param signal - An optional abort signal.
856
+ * @returns A promise that resolves with the details of the block.
857
+ *
858
+ * @see null - no documentation
859
+ * @example
860
+ * ```ts
861
+ * import * as hl from "@nktkas/hyperliquid";
862
+ *
863
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
864
+ * const client = new hl.PublicClient({ transport });
865
+ *
866
+ * const { blockDetails } = await client.blockDetails({ height: 123 });
867
+ * ```
868
+ */
869
+ blockDetails(args, signal) {
870
+ return this.transport.request("explorer", { type: "blockDetails", ...args }, signal);
871
+ }
872
+ /**
873
+ * Gets the details of a transaction.
874
+ * @param args - The parameters for the request.
875
+ * @param signal - An optional abort signal.
876
+ * @returns A promise that resolves with the details of the transaction.
877
+ *
878
+ * @see null - no documentation
879
+ * @example
880
+ * ```ts
881
+ * import * as hl from "@nktkas/hyperliquid";
882
+ *
883
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
884
+ * const client = new hl.PublicClient({ transport });
885
+ *
886
+ * const { tx } = await client.txDetails({ hash: "0x..." });
887
+ * ```
888
+ */
889
+ txDetails(args, signal) {
890
+ return this.transport.request("explorer", { type: "txDetails", ...args }, signal);
891
+ }
892
+ /**
893
+ * Request user details.
894
+ * @param args - The parameters for the request.
895
+ * @param signal - An optional abort signal.
896
+ * @returns User details.
897
+ *
898
+ * @see null - no documentation
899
+ * @example
900
+ * ```ts
901
+ * import * as hl from "@nktkas/hyperliquid";
902
+ *
903
+ * const transport = new hl.HttpTransport(); // or WebSocketTransport
904
+ * const client = new hl.PublicClient({ transport });
905
+ *
906
+ * const { txs } = await client.userDetails({ user: "0x..." });
907
+ * ```
908
+ */
909
+ userDetails(args, signal) {
910
+ return this.transport.request("explorer", { type: "userDetails", ...args }, signal);
911
+ }
912
+ }
913
+ exports.PublicClient = PublicClient;
914
+ });