@nktkas/hyperliquid 0.13.2 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +4 -7
- package/README.md +297 -103
- package/esm/mod.d.ts +3 -12
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +2 -2
- package/esm/src/{transports/base.d.ts → base.d.ts} +11 -14
- package/esm/src/base.d.ts.map +1 -0
- package/esm/src/base.js +14 -0
- package/esm/src/clients/event.d.ts +4 -4
- package/esm/src/clients/event.d.ts.map +1 -1
- package/esm/src/clients/event.js +2 -2
- package/esm/src/clients/public.d.ts +109 -6
- package/esm/src/clients/public.d.ts.map +1 -1
- package/esm/src/clients/public.js +106 -3
- package/esm/src/clients/wallet.d.ts +232 -29
- package/esm/src/clients/wallet.d.ts.map +1 -1
- package/esm/src/clients/wallet.js +859 -243
- package/esm/src/signing.d.ts +135 -0
- package/esm/src/signing.d.ts.map +1 -0
- package/esm/src/signing.js +188 -0
- package/esm/src/transports/http/http_transport.d.ts +2 -4
- package/esm/src/transports/http/http_transport.d.ts.map +1 -1
- package/esm/src/transports/http/http_transport.js +8 -13
- package/{script/src/transports/websocket/hyperliquid_event_target.d.ts → esm/src/transports/websocket/_hyperliquid_event_target.d.ts} +7 -15
- package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -0
- package/esm/src/transports/websocket/{hyperliquid_event_target.js → _hyperliquid_event_target.js} +4 -22
- package/esm/src/transports/websocket/{reconnecting_websocket.d.ts → _reconnecting_websocket.d.ts} +26 -26
- package/esm/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -0
- package/esm/src/transports/websocket/{reconnecting_websocket.js → _reconnecting_websocket.js} +91 -76
- package/esm/src/transports/websocket/{websocket_request_dispatcher.d.ts → _websocket_request_dispatcher.d.ts} +3 -7
- package/esm/src/transports/websocket/_websocket_request_dispatcher.d.ts.map +1 -0
- package/esm/src/transports/websocket/{websocket_request_dispatcher.js → _websocket_request_dispatcher.js} +3 -7
- package/esm/src/transports/websocket/websocket_transport.d.ts +13 -16
- package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/esm/src/transports/websocket/websocket_transport.js +49 -49
- package/esm/src/types/exchange/requests.d.ts +172 -20
- package/esm/src/types/exchange/requests.d.ts.map +1 -1
- package/esm/src/types/exchange/responses.d.ts +32 -32
- package/esm/src/types/exchange/responses.d.ts.map +1 -1
- package/esm/src/types/explorer/requests.d.ts +12 -12
- package/esm/src/types/explorer/requests.d.ts.map +1 -1
- package/esm/src/types/explorer/responses.d.ts +36 -1
- package/esm/src/types/explorer/responses.d.ts.map +1 -1
- package/esm/src/types/info/accounts.d.ts +130 -105
- package/esm/src/types/info/accounts.d.ts.map +1 -1
- package/esm/src/types/info/assets.d.ts +154 -152
- package/esm/src/types/info/assets.d.ts.map +1 -1
- package/esm/src/types/info/delegations.d.ts +20 -20
- package/esm/src/types/info/delegations.d.ts.map +1 -1
- package/esm/src/types/info/orders.d.ts +55 -55
- package/esm/src/types/info/orders.d.ts.map +1 -1
- package/esm/src/types/info/requests.d.ts +73 -10
- package/esm/src/types/info/requests.d.ts.map +1 -1
- package/esm/src/types/info/vaults.d.ts +1 -1
- package/esm/src/types/info/vaults.d.ts.map +1 -1
- package/esm/src/types/mod.d.ts +14 -0
- package/esm/src/types/mod.d.ts.map +1 -0
- package/esm/src/types/subscriptions/requests.d.ts +1 -1
- package/esm/src/types/subscriptions/requests.d.ts.map +1 -1
- package/{script/src/types/subscriptions/common.d.ts → esm/src/types/subscriptions/responses.d.ts} +16 -4
- package/esm/src/types/subscriptions/responses.d.ts.map +1 -0
- package/package.json +20 -4
- package/script/mod.d.ts +3 -12
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +3 -5
- package/script/src/{transports/base.d.ts → base.d.ts} +11 -14
- package/script/src/base.d.ts.map +1 -0
- package/script/src/{transports/base.js → base.js} +13 -12
- package/script/src/clients/event.d.ts +4 -4
- package/script/src/clients/event.d.ts.map +1 -1
- package/script/src/clients/event.js +2 -2
- package/script/src/clients/public.d.ts +109 -6
- package/script/src/clients/public.d.ts.map +1 -1
- package/script/src/clients/public.js +106 -3
- package/script/src/clients/wallet.d.ts +232 -29
- package/script/src/clients/wallet.d.ts.map +1 -1
- package/script/src/clients/wallet.js +860 -244
- package/script/src/signing.d.ts +135 -0
- package/script/src/signing.d.ts.map +1 -0
- package/script/src/signing.js +203 -0
- package/script/src/transports/http/http_transport.d.ts +2 -4
- package/script/src/transports/http/http_transport.d.ts.map +1 -1
- package/script/src/transports/http/http_transport.js +9 -14
- package/{esm/src/transports/websocket/hyperliquid_event_target.d.ts → script/src/transports/websocket/_hyperliquid_event_target.d.ts} +7 -15
- package/script/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -0
- package/script/src/transports/websocket/{hyperliquid_event_target.js → _hyperliquid_event_target.js} +4 -22
- package/script/src/transports/websocket/{reconnecting_websocket.d.ts → _reconnecting_websocket.d.ts} +26 -26
- package/script/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -0
- package/script/src/transports/websocket/{reconnecting_websocket.js → _reconnecting_websocket.js} +94 -78
- package/script/src/transports/websocket/{websocket_request_dispatcher.d.ts → _websocket_request_dispatcher.d.ts} +3 -7
- package/script/src/transports/websocket/_websocket_request_dispatcher.d.ts.map +1 -0
- package/script/src/transports/websocket/{websocket_request_dispatcher.js → _websocket_request_dispatcher.js} +4 -8
- package/script/src/transports/websocket/websocket_transport.d.ts +13 -16
- package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/script/src/transports/websocket/websocket_transport.js +55 -55
- package/script/src/types/exchange/requests.d.ts +172 -20
- package/script/src/types/exchange/requests.d.ts.map +1 -1
- package/script/src/types/exchange/responses.d.ts +32 -32
- package/script/src/types/exchange/responses.d.ts.map +1 -1
- package/script/src/types/explorer/requests.d.ts +12 -12
- package/script/src/types/explorer/requests.d.ts.map +1 -1
- package/script/src/types/explorer/responses.d.ts +36 -1
- package/script/src/types/explorer/responses.d.ts.map +1 -1
- package/script/src/types/info/accounts.d.ts +130 -105
- package/script/src/types/info/accounts.d.ts.map +1 -1
- package/script/src/types/info/assets.d.ts +154 -152
- package/script/src/types/info/assets.d.ts.map +1 -1
- package/script/src/types/info/delegations.d.ts +20 -20
- package/script/src/types/info/delegations.d.ts.map +1 -1
- package/script/src/types/info/orders.d.ts +55 -55
- package/script/src/types/info/orders.d.ts.map +1 -1
- package/script/src/types/info/requests.d.ts +73 -10
- package/script/src/types/info/requests.d.ts.map +1 -1
- package/script/src/types/info/vaults.d.ts +1 -1
- package/script/src/types/info/vaults.d.ts.map +1 -1
- package/script/src/types/mod.d.ts +14 -0
- package/script/src/types/mod.d.ts.map +1 -0
- package/script/src/types/subscriptions/requests.d.ts +1 -1
- package/script/src/types/subscriptions/requests.d.ts.map +1 -1
- package/{esm/src/types/subscriptions/common.d.ts → script/src/types/subscriptions/responses.d.ts} +16 -4
- package/script/src/types/subscriptions/responses.d.ts.map +1 -0
- package/esm/src/transports/base.d.ts.map +0 -1
- package/esm/src/transports/base.js +0 -14
- package/esm/src/transports/websocket/hyperliquid_event_target.d.ts.map +0 -1
- package/esm/src/transports/websocket/reconnecting_websocket.d.ts.map +0 -1
- package/esm/src/transports/websocket/websocket_request_dispatcher.d.ts.map +0 -1
- package/esm/src/types/common.d.ts +0 -3
- package/esm/src/types/common.d.ts.map +0 -1
- package/esm/src/types/exchange/common.d.ts +0 -36
- package/esm/src/types/exchange/common.d.ts.map +0 -1
- package/esm/src/types/explorer/common.d.ts +0 -37
- package/esm/src/types/explorer/common.d.ts.map +0 -1
- package/esm/src/types/explorer/common.js +0 -1
- package/esm/src/types/subscriptions/common.d.ts.map +0 -1
- package/esm/src/types/subscriptions/common.js +0 -1
- package/esm/src/utils/key_sort.d.ts +0 -21
- package/esm/src/utils/key_sort.d.ts.map +0 -1
- package/esm/src/utils/key_sort.js +0 -124
- package/esm/src/utils/signing.d.ts +0 -109
- package/esm/src/utils/signing.d.ts.map +0 -1
- package/esm/src/utils/signing.js +0 -164
- package/script/src/transports/base.d.ts.map +0 -1
- package/script/src/transports/websocket/hyperliquid_event_target.d.ts.map +0 -1
- package/script/src/transports/websocket/reconnecting_websocket.d.ts.map +0 -1
- package/script/src/transports/websocket/websocket_request_dispatcher.d.ts.map +0 -1
- package/script/src/types/common.d.ts +0 -3
- package/script/src/types/common.d.ts.map +0 -1
- package/script/src/types/exchange/common.d.ts +0 -36
- package/script/src/types/exchange/common.d.ts.map +0 -1
- package/script/src/types/explorer/common.d.ts +0 -37
- package/script/src/types/explorer/common.d.ts.map +0 -1
- package/script/src/types/explorer/common.js +0 -12
- package/script/src/types/subscriptions/common.d.ts.map +0 -1
- package/script/src/types/subscriptions/common.js +0 -12
- package/script/src/utils/key_sort.d.ts +0 -21
- package/script/src/utils/key_sort.d.ts.map +0 -1
- package/script/src/utils/key_sort.js +0 -137
- package/script/src/utils/signing.d.ts +0 -109
- package/script/src/utils/signing.d.ts.map +0 -1
- package/script/src/utils/signing.js +0 -182
- /package/esm/src/types/{common.js → mod.js} +0 -0
- /package/esm/src/types/{exchange/common.js → subscriptions/responses.js} +0 -0
- /package/script/src/types/{common.js → mod.js} +0 -0
- /package/script/src/types/{exchange/common.js → subscriptions/responses.js} +0 -0
|
@@ -4,18 +4,17 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./
|
|
7
|
+
define(["require", "exports", "./_reconnecting_websocket.js", "./_hyperliquid_event_target.js", "./_websocket_request_dispatcher.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.WebSocketTransport = void 0;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
12
|
+
exports.WebSocketTransport = exports.WebSocketRequestError = void 0;
|
|
13
|
+
const _reconnecting_websocket_js_1 = require("./_reconnecting_websocket.js");
|
|
14
|
+
const _hyperliquid_event_target_js_1 = require("./_hyperliquid_event_target.js");
|
|
15
|
+
const _websocket_request_dispatcher_js_1 = require("./_websocket_request_dispatcher.js");
|
|
16
|
+
Object.defineProperty(exports, "WebSocketRequestError", { enumerable: true, get: function () { return _websocket_request_dispatcher_js_1.WebSocketRequestError; } });
|
|
17
|
+
/** WebSocket implementation of the REST and Subscription transport interfaces. */
|
|
19
18
|
class WebSocketTransport {
|
|
20
19
|
/**
|
|
21
20
|
* Creates a new WebSocket transport instance.
|
|
@@ -27,7 +26,7 @@
|
|
|
27
26
|
enumerable: true,
|
|
28
27
|
configurable: true,
|
|
29
28
|
writable: true,
|
|
30
|
-
value:
|
|
29
|
+
value: null
|
|
31
30
|
});
|
|
32
31
|
/** The WebSocket request dispatcher instance. */
|
|
33
32
|
Object.defineProperty(this, "_wsRequester", {
|
|
@@ -79,9 +78,9 @@
|
|
|
79
78
|
writable: true,
|
|
80
79
|
value: void 0
|
|
81
80
|
});
|
|
82
|
-
this.socket = new
|
|
83
|
-
this._hlEvents = new
|
|
84
|
-
this._wsRequester = new
|
|
81
|
+
this.socket = new _reconnecting_websocket_js_1.ReconnectingWebSocket(options?.url ?? "wss://api.hyperliquid.xyz/ws", undefined, options?.reconnect);
|
|
82
|
+
this._hlEvents = new _hyperliquid_event_target_js_1.HyperliquidEventTarget(this.socket);
|
|
83
|
+
this._wsRequester = new _websocket_request_dispatcher_js_1.WebSocketRequestDispatcher(this.socket, this._hlEvents);
|
|
85
84
|
this.timeout = options?.timeout === undefined ? 10_000 : options.timeout;
|
|
86
85
|
this.keepAlive = {
|
|
87
86
|
interval: options?.keepAlive?.interval === undefined ? 20_000 : options.keepAlive.interval,
|
|
@@ -89,7 +88,7 @@
|
|
|
89
88
|
// Initialize listeners
|
|
90
89
|
this.socket.addEventListener("open", () => {
|
|
91
90
|
// Start keep-alive timer
|
|
92
|
-
if (this.keepAlive.interval &&
|
|
91
|
+
if (this.keepAlive.interval && this._keepAliveTimer === null) {
|
|
93
92
|
this._keepAliveTimer = setInterval(() => {
|
|
94
93
|
this.socket.send(JSON.stringify({ method: "ping" }));
|
|
95
94
|
}, this.keepAlive.interval);
|
|
@@ -97,17 +96,16 @@
|
|
|
97
96
|
});
|
|
98
97
|
this.socket.addEventListener("close", () => {
|
|
99
98
|
// Clear keep-alive timer
|
|
100
|
-
if (this._keepAliveTimer) {
|
|
99
|
+
if (this._keepAliveTimer !== null) {
|
|
101
100
|
clearInterval(this._keepAliveTimer);
|
|
102
|
-
this._keepAliveTimer =
|
|
101
|
+
this._keepAliveTimer = null;
|
|
103
102
|
}
|
|
104
103
|
// Clear all subscriptions
|
|
105
104
|
for (const subscriptionInfo of this._subscriptions.values()) {
|
|
106
|
-
for (const [
|
|
107
|
-
|
|
105
|
+
for (const [_, unsubscribe] of subscriptionInfo.listeners) {
|
|
106
|
+
unsubscribe();
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
|
-
this._subscriptions.clear();
|
|
111
109
|
});
|
|
112
110
|
}
|
|
113
111
|
/**
|
|
@@ -122,14 +120,14 @@
|
|
|
122
120
|
request(type, payload, signal) {
|
|
123
121
|
// Reject explorer requests because they are not supported by the Hyperliquid WebSocket API
|
|
124
122
|
if (type === "explorer") {
|
|
125
|
-
|
|
123
|
+
return Promise.reject(new _websocket_request_dispatcher_js_1.WebSocketRequestError("Explorer requests are not supported in the Hyperliquid WebSocket API."));
|
|
126
124
|
}
|
|
127
125
|
// Send the request and wait for a response
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
?
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
const combinedSignal = this._combineTimeoutWithSignal(this.timeout, signal);
|
|
127
|
+
return this._wsRequester.request("post", {
|
|
128
|
+
type: type === "exchange" ? "action" : type,
|
|
129
|
+
payload,
|
|
130
|
+
}, combinedSignal);
|
|
133
131
|
}
|
|
134
132
|
/**
|
|
135
133
|
* Subscribes to a Hyperliquid event channel.
|
|
@@ -141,62 +139,56 @@
|
|
|
141
139
|
*/
|
|
142
140
|
async subscribe(channel, payload, listener, signal) {
|
|
143
141
|
// Create a unique identifier for the subscription
|
|
144
|
-
const id =
|
|
142
|
+
const id = _websocket_request_dispatcher_js_1.WebSocketRequestDispatcher.requestToId(payload);
|
|
145
143
|
// Initialize new subscription, if it doesn't exist
|
|
146
|
-
let
|
|
147
|
-
if (!
|
|
144
|
+
let subscription = this._subscriptions.get(id);
|
|
145
|
+
if (!subscription) {
|
|
148
146
|
// Send subscription request
|
|
149
|
-
const
|
|
150
|
-
const combinedSignal = timeoutSignal && signal
|
|
151
|
-
? AbortSignal.any([timeoutSignal, signal])
|
|
152
|
-
: timeoutSignal ?? signal;
|
|
147
|
+
const combinedSignal = this._combineTimeoutWithSignal(this.timeout, signal);
|
|
153
148
|
const requestPromise = this._wsRequester.request("subscribe", payload, combinedSignal);
|
|
154
149
|
// Cache subscription info
|
|
155
|
-
|
|
156
|
-
this._subscriptions.set(id,
|
|
150
|
+
subscription = { listeners: new Map(), requestPromise };
|
|
151
|
+
this._subscriptions.set(id, subscription);
|
|
157
152
|
}
|
|
158
153
|
// Initialize new listener, if it doesn't exist
|
|
159
|
-
let
|
|
160
|
-
if (!
|
|
154
|
+
let unsubscribe = subscription.listeners.get(listener);
|
|
155
|
+
if (!unsubscribe) {
|
|
161
156
|
// Create new unsubscribe function
|
|
162
|
-
|
|
157
|
+
unsubscribe = async (signal) => {
|
|
163
158
|
// Remove listener and cleanup
|
|
164
159
|
this._hlEvents.removeEventListener(channel, listener);
|
|
165
|
-
const
|
|
160
|
+
const subscription = this._subscriptions.get(id);
|
|
161
|
+
subscription?.listeners.delete(listener);
|
|
166
162
|
// If no listeners remain, remove subscription entirely
|
|
167
|
-
|
|
168
|
-
if (subscriptionInfo.listeners.size === 0 && isDeleted) {
|
|
163
|
+
if (subscription?.listeners.size === 0) {
|
|
169
164
|
// Cleanup subscription
|
|
170
165
|
this._subscriptions.delete(id);
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
await this._wsRequester.request("unsubscribe", payload, combinedSignal);
|
|
166
|
+
// If the socket is open, send unsubscription request
|
|
167
|
+
if (this.socket.readyState === WebSocket.OPEN) {
|
|
168
|
+
const combinedSignal = this._combineTimeoutWithSignal(this.timeout, signal);
|
|
169
|
+
await this._wsRequester.request("unsubscribe", payload, combinedSignal);
|
|
170
|
+
}
|
|
177
171
|
}
|
|
178
172
|
};
|
|
179
|
-
//
|
|
180
|
-
listenerInfo = { channel, unsubscribe };
|
|
181
|
-
subscriptionInfo.listeners.set(listener, listenerInfo);
|
|
182
|
-
// Add event listener
|
|
173
|
+
// Add listener and cache unsubscribe function
|
|
183
174
|
this._hlEvents.addEventListener(channel, listener);
|
|
175
|
+
subscription.listeners.set(listener, unsubscribe);
|
|
184
176
|
}
|
|
185
177
|
// Wait for the initial subscription request to complete
|
|
186
|
-
await
|
|
178
|
+
await subscription.requestPromise.catch((error) => {
|
|
187
179
|
// Remove listener and cleanup
|
|
188
180
|
this._hlEvents.removeEventListener(channel, listener);
|
|
189
|
-
|
|
181
|
+
const subscription = this._subscriptions.get(id);
|
|
182
|
+
subscription?.listeners.delete(listener);
|
|
190
183
|
// If no listeners remain, remove subscription entirely
|
|
191
|
-
if (
|
|
184
|
+
if (subscription?.listeners.size === 0) {
|
|
192
185
|
this._subscriptions.delete(id);
|
|
186
|
+
}
|
|
193
187
|
// Rethrow the error
|
|
194
188
|
throw error;
|
|
195
189
|
});
|
|
196
190
|
// Return subscription control object
|
|
197
|
-
return {
|
|
198
|
-
unsubscribe: listenerInfo.unsubscribe,
|
|
199
|
-
};
|
|
191
|
+
return { unsubscribe };
|
|
200
192
|
}
|
|
201
193
|
/**
|
|
202
194
|
* Waits until the WebSocket connection is ready.
|
|
@@ -248,6 +240,14 @@
|
|
|
248
240
|
this.socket.close();
|
|
249
241
|
});
|
|
250
242
|
}
|
|
243
|
+
/** Combines a timeout with an optional abort signal. */
|
|
244
|
+
_combineTimeoutWithSignal(timeout, signal) {
|
|
245
|
+
if (typeof timeout !== "number")
|
|
246
|
+
return signal;
|
|
247
|
+
if (!(signal instanceof AbortSignal))
|
|
248
|
+
return AbortSignal.timeout(timeout);
|
|
249
|
+
return AbortSignal.any([AbortSignal.timeout(timeout), signal]);
|
|
250
|
+
}
|
|
251
251
|
}
|
|
252
252
|
exports.WebSocketTransport = WebSocketTransport;
|
|
253
253
|
});
|
|
@@ -1,5 +1,38 @@
|
|
|
1
|
-
import type { Hex } from "
|
|
2
|
-
import type {
|
|
1
|
+
import type { Hex } from "../../base.js";
|
|
2
|
+
import type { TIF } from "../info/orders.js";
|
|
3
|
+
/** Order parameters. */
|
|
4
|
+
export type OrderParams = {
|
|
5
|
+
/** Asset ID. */
|
|
6
|
+
a: number;
|
|
7
|
+
/** Position side (`true` for long, `false` for short). */
|
|
8
|
+
b: boolean;
|
|
9
|
+
/** Price. */
|
|
10
|
+
p: string;
|
|
11
|
+
/** Size (in base currency units). */
|
|
12
|
+
s: string;
|
|
13
|
+
/** Is reduce-only? */
|
|
14
|
+
r: boolean;
|
|
15
|
+
/** Order type. */
|
|
16
|
+
t: {
|
|
17
|
+
/** Limit order parameters. */
|
|
18
|
+
limit: {
|
|
19
|
+
/** Time-in-force. */
|
|
20
|
+
tif: TIF;
|
|
21
|
+
};
|
|
22
|
+
} | {
|
|
23
|
+
/** Trigger order parameters. */
|
|
24
|
+
trigger: {
|
|
25
|
+
/** Is market order? */
|
|
26
|
+
isMarket: boolean;
|
|
27
|
+
/** Trigger price. */
|
|
28
|
+
triggerPx: string;
|
|
29
|
+
/** Indicates whether it is take profit or stop loss. */
|
|
30
|
+
tpsl: "tp" | "sl";
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/** Client Order ID. */
|
|
34
|
+
c?: Hex | null;
|
|
35
|
+
};
|
|
3
36
|
/** Base structure for exchange requests. */
|
|
4
37
|
export interface BaseExchangeRequest {
|
|
5
38
|
/** Action to perform. */
|
|
@@ -84,42 +117,42 @@ export interface BatchModifyRequest extends BaseExchangeRequest {
|
|
|
84
117
|
vaultAddress?: Hex;
|
|
85
118
|
}
|
|
86
119
|
/**
|
|
87
|
-
* Cancel order(s).
|
|
120
|
+
* Cancel order(s) by cloid.
|
|
88
121
|
* @returns {CancelResponse}
|
|
89
|
-
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s
|
|
122
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s-by-cloid
|
|
90
123
|
*/
|
|
91
|
-
export interface
|
|
124
|
+
export interface CancelByCloidRequest extends BaseExchangeRequest {
|
|
92
125
|
/** Action to be performed. */
|
|
93
126
|
action: {
|
|
94
127
|
/** Type of action. */
|
|
95
|
-
type: "
|
|
128
|
+
type: "cancelByCloid";
|
|
96
129
|
/** Orders to cancel. */
|
|
97
130
|
cancels: {
|
|
98
131
|
/** Asset ID. */
|
|
99
|
-
|
|
100
|
-
/** Order ID. */
|
|
101
|
-
|
|
132
|
+
asset: number;
|
|
133
|
+
/** Client Order ID. */
|
|
134
|
+
cloid: Hex;
|
|
102
135
|
}[];
|
|
103
136
|
};
|
|
104
137
|
/** Vault address (for vault trading). */
|
|
105
138
|
vaultAddress?: Hex;
|
|
106
139
|
}
|
|
107
140
|
/**
|
|
108
|
-
* Cancel order(s)
|
|
141
|
+
* Cancel order(s).
|
|
109
142
|
* @returns {CancelResponse}
|
|
110
|
-
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s
|
|
143
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s
|
|
111
144
|
*/
|
|
112
|
-
export interface
|
|
145
|
+
export interface CancelRequest extends BaseExchangeRequest {
|
|
113
146
|
/** Action to be performed. */
|
|
114
147
|
action: {
|
|
115
148
|
/** Type of action. */
|
|
116
|
-
type: "
|
|
149
|
+
type: "cancel";
|
|
117
150
|
/** Orders to cancel. */
|
|
118
151
|
cancels: {
|
|
119
152
|
/** Asset ID. */
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
|
|
153
|
+
a: number;
|
|
154
|
+
/** Order ID. */
|
|
155
|
+
o: number;
|
|
123
156
|
}[];
|
|
124
157
|
};
|
|
125
158
|
/** Vault address (for vault trading). */
|
|
@@ -145,6 +178,18 @@ export interface CDepositRequest extends BaseExchangeRequest {
|
|
|
145
178
|
wei: number;
|
|
146
179
|
};
|
|
147
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Claim rewards from referral program.
|
|
183
|
+
* @returns {SuccessResponse}
|
|
184
|
+
* @see null - no documentation
|
|
185
|
+
*/
|
|
186
|
+
export interface ClaimRewardsRequest extends BaseExchangeRequest {
|
|
187
|
+
/** Action to be performed. */
|
|
188
|
+
action: {
|
|
189
|
+
/** Type of action. */
|
|
190
|
+
type: "claimRewards";
|
|
191
|
+
};
|
|
192
|
+
}
|
|
148
193
|
/**
|
|
149
194
|
* Create a sub-account.
|
|
150
195
|
* @returns {CreateSubAccountResponse}
|
|
@@ -179,6 +224,20 @@ export interface CWithdrawRequest extends BaseExchangeRequest {
|
|
|
179
224
|
wei: number;
|
|
180
225
|
};
|
|
181
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Configure block type for EVM transactions.
|
|
229
|
+
* @returns {SuccessResponse}
|
|
230
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/evm/dual-block-architecture
|
|
231
|
+
*/
|
|
232
|
+
export interface EvmUserModifyRequest extends BaseExchangeRequest {
|
|
233
|
+
/** Action to be performed. */
|
|
234
|
+
action: {
|
|
235
|
+
/** Type of action. */
|
|
236
|
+
type: "evmUserModify";
|
|
237
|
+
/** `true` for large blocks, `false` for small blocks. */
|
|
238
|
+
usingBigBlocks: boolean;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
182
241
|
/**
|
|
183
242
|
* Modify an order.
|
|
184
243
|
* @returns {SuccessResponse}
|
|
@@ -248,6 +307,24 @@ export interface ScheduleCancelRequest extends BaseExchangeRequest {
|
|
|
248
307
|
/** Vault address (for vault trading). */
|
|
249
308
|
vaultAddress?: Hex;
|
|
250
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* Set the display name in the leaderboard.
|
|
312
|
+
* @returns {SuccessResponse}
|
|
313
|
+
* @see null - no documentation
|
|
314
|
+
*/
|
|
315
|
+
export interface SetDisplayNameRequest extends BaseExchangeRequest {
|
|
316
|
+
/** Action to be performed. */
|
|
317
|
+
action: {
|
|
318
|
+
/** Type of action. */
|
|
319
|
+
type: "setDisplayName";
|
|
320
|
+
/**
|
|
321
|
+
* Display name.
|
|
322
|
+
*
|
|
323
|
+
* Set to an empty string to remove the display name.
|
|
324
|
+
*/
|
|
325
|
+
displayName: string;
|
|
326
|
+
};
|
|
327
|
+
}
|
|
251
328
|
/**
|
|
252
329
|
* Set a referral code.
|
|
253
330
|
* @returns {SuccessResponse}
|
|
@@ -278,7 +355,7 @@ export interface SpotSendRequest extends BaseExchangeRequest {
|
|
|
278
355
|
signatureChainId: Hex;
|
|
279
356
|
/** Unique request identifier (recommended current timestamp in ms). */
|
|
280
357
|
time: number;
|
|
281
|
-
/**
|
|
358
|
+
/** Destination address. */
|
|
282
359
|
destination: Hex;
|
|
283
360
|
/** Token identifier. */
|
|
284
361
|
token: `${string}:${Hex}`;
|
|
@@ -287,7 +364,44 @@ export interface SpotSendRequest extends BaseExchangeRequest {
|
|
|
287
364
|
};
|
|
288
365
|
}
|
|
289
366
|
/**
|
|
290
|
-
*
|
|
367
|
+
* Opt Out of Spot Dusting.
|
|
368
|
+
* @returns {SuccessResponse}
|
|
369
|
+
* @see null - no documentation
|
|
370
|
+
*/
|
|
371
|
+
export interface SpotUserRequest extends BaseExchangeRequest {
|
|
372
|
+
/** Action to be performed. */
|
|
373
|
+
action: {
|
|
374
|
+
/** Type of action. */
|
|
375
|
+
type: "spotUser";
|
|
376
|
+
/** Spot dusting options. */
|
|
377
|
+
toggleSpotDusting: {
|
|
378
|
+
/** Opt out of spot dusting. */
|
|
379
|
+
optOut: boolean;
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Transfer between sub-accounts (spot).
|
|
385
|
+
* @returns {SuccessResponse}
|
|
386
|
+
* @see null - no documentation
|
|
387
|
+
*/
|
|
388
|
+
export interface SubAccountSpotTransferRequest extends BaseExchangeRequest {
|
|
389
|
+
/** Action to be performed. */
|
|
390
|
+
action: {
|
|
391
|
+
/** Type of action. */
|
|
392
|
+
type: "subAccountSpotTransfer";
|
|
393
|
+
/** Sub-account address. */
|
|
394
|
+
subAccountUser: Hex;
|
|
395
|
+
/** `true` for deposit, `false` for withdrawal. */
|
|
396
|
+
isDeposit: boolean;
|
|
397
|
+
/** Token identifier. */
|
|
398
|
+
token: `${string}:${Hex}`;
|
|
399
|
+
/** Amount to send. */
|
|
400
|
+
amount: string;
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Transfer between sub-accounts (perpetual).
|
|
291
405
|
* @returns {SuccessResponse}
|
|
292
406
|
* @see null - no documentation
|
|
293
407
|
*/
|
|
@@ -453,12 +567,50 @@ export interface UsdSendRequest extends BaseExchangeRequest {
|
|
|
453
567
|
signatureChainId: Hex;
|
|
454
568
|
/** Unique request identifier (recommended current timestamp in ms). */
|
|
455
569
|
time: number;
|
|
456
|
-
/**
|
|
570
|
+
/** Destination address. */
|
|
457
571
|
destination: Hex;
|
|
458
572
|
/** Amount to send. */
|
|
459
573
|
amount: string;
|
|
460
574
|
};
|
|
461
575
|
}
|
|
576
|
+
/**
|
|
577
|
+
* Distribute funds from a vault between followers.
|
|
578
|
+
* @returns {SuccessResponse}
|
|
579
|
+
* @see null - no documentation
|
|
580
|
+
*/
|
|
581
|
+
export interface VaultDistributeRequest extends BaseExchangeRequest {
|
|
582
|
+
/** Action to be performed. */
|
|
583
|
+
action: {
|
|
584
|
+
/** Type of action. */
|
|
585
|
+
type: "vaultDistribute";
|
|
586
|
+
/** Vault address. */
|
|
587
|
+
vaultAddress: Hex;
|
|
588
|
+
/**
|
|
589
|
+
* Raw amount to distribute (float * 1e6).
|
|
590
|
+
*
|
|
591
|
+
* Set to 0 to close the vault.
|
|
592
|
+
*/
|
|
593
|
+
usd: number;
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Modify a vault's configuration.
|
|
598
|
+
* @returns {SuccessResponse}
|
|
599
|
+
* @see null - no documentation
|
|
600
|
+
*/
|
|
601
|
+
export interface VaultModifyRequest extends BaseExchangeRequest {
|
|
602
|
+
/** Action to be performed. */
|
|
603
|
+
action: {
|
|
604
|
+
/** Type of action. */
|
|
605
|
+
type: "vaultModify";
|
|
606
|
+
/** Vault address. */
|
|
607
|
+
vaultAddress: Hex;
|
|
608
|
+
/** Allow deposits from followers. */
|
|
609
|
+
allowDeposits: boolean | null;
|
|
610
|
+
/** Always close positions on withdrawal. */
|
|
611
|
+
alwaysCloseOnWithdraw: boolean | null;
|
|
612
|
+
};
|
|
613
|
+
}
|
|
462
614
|
/**
|
|
463
615
|
* Add or remove funds from a vault.
|
|
464
616
|
* @returns {SuccessResponse}
|
|
@@ -495,7 +647,7 @@ export interface Withdraw3Request extends BaseExchangeRequest {
|
|
|
495
647
|
time: number;
|
|
496
648
|
/** Amount to withdraw. */
|
|
497
649
|
amount: string;
|
|
498
|
-
/**
|
|
650
|
+
/** Destination address. */
|
|
499
651
|
destination: Hex;
|
|
500
652
|
};
|
|
501
653
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../../src/src/types/exchange/requests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../../src/src/types/exchange/requests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAE7C,wBAAwB;AACxB,MAAM,MAAM,WAAW,GAAG;IACtB,gBAAgB;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,0DAA0D;IAC1D,CAAC,EAAE,OAAO,CAAC;IACX,aAAa;IACb,CAAC,EAAE,MAAM,CAAC;IACV,qCAAqC;IACrC,CAAC,EAAE,MAAM,CAAC;IACV,sBAAsB;IACtB,CAAC,EAAE,OAAO,CAAC;IACX,kBAAkB;IAClB,CAAC,EACK;QACE,8BAA8B;QAC9B,KAAK,EAAE;YACH,qBAAqB;YACrB,GAAG,EAAE,GAAG,CAAC;SACZ,CAAC;KACL,GACC;QACE,gCAAgC;QAChC,OAAO,EAAE;YACL,uBAAuB;YACvB,QAAQ,EAAE,OAAO,CAAC;YAClB,qBAAqB;YACrB,SAAS,EAAE,MAAM,CAAC;YAClB,wDAAwD;YACxD,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;SACrB,CAAC;KACL,CAAC;IACN,uBAAuB;IACvB,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;CAClB,CAAC;AAEF,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IAChC,yBAAyB;IACzB,MAAM,EAAE;QACJ,sBAAsB;QACtB,IAAI,EAAE,MAAM,CAAC;QACb,oCAAoC;QACpC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KAC1B,CAAC;IACF,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,SAAS,EAAE;QAAE,CAAC,EAAE,GAAG,CAAC;QAAC,CAAC,EAAE,GAAG,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CA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AAqB;QACrB,YAAY,EAAE,GAAG,CAAC;QAClB;;;;WAIG;QACH,GAAG,EAAE,MAAM,CAAC;KACf,CAAC;CACL;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC3D,8BAA8B;IAC9B,MAAM,EAAE;QACJ,sBAAsB;QACtB,IAAI,EAAE,aAAa,CAAC;QACpB,qBAAqB;QACrB,YAAY,EAAE,GAAG,CAAC;QAClB,qCAAqC;QACrC,aAAa,EAAE,OAAO,GAAG,IAAI,CAAC;QAC9B,4CAA4C;QAC5C,qBAAqB,EAAE,OAAO,GAAG,IAAI,CAAC;KACzC,CAAC;CACL;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC7D,8BAA8B;IAC9B,MAAM,EAAE;QACJ,sBAAsB;QACtB,IAAI,EAAE,eAAe,CAAC;QACtB,qBAAqB;QACrB,YAAY,EAAE,GAAG,CAAC;QAClB,kDAAkD;QAClD,SAAS,EAAE,OAAO,CAAC;QACnB,4CAA4C;QAC5C,GAAG,EAAE,MAAM,CAAC;KACf,CAAC;CACL;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAiB,SAAQ,mBAAmB;IACzD,8BAA8B;IAC9B,MAAM,EAAE;QACJ,sBAAsB;QACtB,IAAI,EAAE,WAAW,CAAC;QAClB,2BAA2B;QAC3B,gBAAgB,EAAE,SAAS,GAAG,SAAS,CAAC;QACxC,iCAAiC;QACjC,gBAAgB,EAAE,GAAG,CAAC;QACtB,uEAAuE;QACvE,IAAI,EAAE,MAAM,CAAC;QACb,0BAA0B;QAC1B,MAAM,EAAE,MAAM,CAAC;QACf,2BAA2B;QAC3B,WAAW,EAAE,GAAG,CAAC;KACpB,CAAC;CACL"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Hex } from "
|
|
1
|
+
import type { Hex } from "../../base.js";
|
|
2
2
|
/** Base structure for exchange responses. */
|
|
3
3
|
export interface BaseExchangeResponse {
|
|
4
4
|
/** Response status */
|
|
@@ -11,23 +11,6 @@ export interface BaseExchangeResponse {
|
|
|
11
11
|
data?: unknown;
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
/** Successful response without specific data. */
|
|
15
|
-
export interface SuccessResponse extends BaseExchangeResponse {
|
|
16
|
-
/** Successful status. */
|
|
17
|
-
status: "ok";
|
|
18
|
-
/** Response details. */
|
|
19
|
-
response: {
|
|
20
|
-
/** Type of response. */
|
|
21
|
-
type: "default";
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/** Error response for failed operations. */
|
|
25
|
-
export interface ErrorResponse extends BaseExchangeResponse {
|
|
26
|
-
/** Error status. */
|
|
27
|
-
status: "err";
|
|
28
|
-
/** Error message. */
|
|
29
|
-
response: string;
|
|
30
|
-
}
|
|
31
14
|
/** Response for order cancellation. */
|
|
32
15
|
export interface CancelResponse extends BaseExchangeResponse {
|
|
33
16
|
/** Successful status. */
|
|
@@ -58,6 +41,13 @@ export interface CreateSubAccountResponse extends BaseExchangeResponse {
|
|
|
58
41
|
data: Hex;
|
|
59
42
|
};
|
|
60
43
|
}
|
|
44
|
+
/** Error response for failed operations. */
|
|
45
|
+
export interface ErrorResponse extends BaseExchangeResponse {
|
|
46
|
+
/** Error status. */
|
|
47
|
+
status: "err";
|
|
48
|
+
/** Error message. */
|
|
49
|
+
response: string;
|
|
50
|
+
}
|
|
61
51
|
/** Response for order placement and batch modifications. */
|
|
62
52
|
export interface OrderResponse extends BaseExchangeResponse {
|
|
63
53
|
/** Successful status. */
|
|
@@ -96,42 +86,52 @@ export interface OrderResponse extends BaseExchangeResponse {
|
|
|
96
86
|
};
|
|
97
87
|
};
|
|
98
88
|
}
|
|
99
|
-
/**
|
|
100
|
-
export interface
|
|
89
|
+
/** Successful response without specific data. */
|
|
90
|
+
export interface SuccessResponse extends BaseExchangeResponse {
|
|
101
91
|
/** Successful status. */
|
|
102
92
|
status: "ok";
|
|
103
93
|
/** Response details. */
|
|
104
94
|
response: {
|
|
105
95
|
/** Type of response. */
|
|
106
|
-
type: "
|
|
96
|
+
type: "default";
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** Response for canceling a TWAP order. */
|
|
100
|
+
export interface TwapCancelResponse extends BaseExchangeResponse {
|
|
101
|
+
/** Successful status. */
|
|
102
|
+
status: "ok";
|
|
103
|
+
/** Response details. */
|
|
104
|
+
response: {
|
|
105
|
+
/** Type of response. */
|
|
106
|
+
type: "twapCancel";
|
|
107
107
|
/** Specific data. */
|
|
108
108
|
data: {
|
|
109
109
|
/** Status of the operation. */
|
|
110
|
-
status: {
|
|
111
|
-
/** Running order status. */
|
|
112
|
-
running: {
|
|
113
|
-
/** TWAP ID. */
|
|
114
|
-
twapId: number;
|
|
115
|
-
};
|
|
116
|
-
} | {
|
|
110
|
+
status: string | {
|
|
117
111
|
/** Error message. */
|
|
118
112
|
error: string;
|
|
119
113
|
};
|
|
120
114
|
};
|
|
121
115
|
};
|
|
122
116
|
}
|
|
123
|
-
/** Response for
|
|
124
|
-
export interface
|
|
117
|
+
/** Response for creating a TWAP order. */
|
|
118
|
+
export interface TwapOrderResponse extends BaseExchangeResponse {
|
|
125
119
|
/** Successful status. */
|
|
126
120
|
status: "ok";
|
|
127
121
|
/** Response details. */
|
|
128
122
|
response: {
|
|
129
123
|
/** Type of response. */
|
|
130
|
-
type: "
|
|
124
|
+
type: "twapOrder";
|
|
131
125
|
/** Specific data. */
|
|
132
126
|
data: {
|
|
133
127
|
/** Status of the operation. */
|
|
134
|
-
status:
|
|
128
|
+
status: {
|
|
129
|
+
/** Running order status. */
|
|
130
|
+
running: {
|
|
131
|
+
/** TWAP ID. */
|
|
132
|
+
twapId: number;
|
|
133
|
+
};
|
|
134
|
+
} | {
|
|
135
135
|
/** Error message. */
|
|
136
136
|
error: string;
|
|
137
137
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../../../src/src/types/exchange/responses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../../../src/src/types/exchange/responses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEzC,6CAA6C;AAC7C,MAAM,WAAW,oBAAoB;IACjC,sBAAsB;IACtB,MAAM,EAAE,IAAI,GAAG,KAAK,CAAC;IACrB,oCAAoC;IACpC,QAAQ,EACF,MAAM,GACN;QACE,wBAAwB;QACxB,IAAI,EAAE,MAAM,CAAC;QACb,uCAAuC;QACvC,IAAI,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC;CACT;AAED,uCAAuC;AACvC,MAAM,WAAW,cAAe,SAAQ,oBAAoB;IACxD,yBAAyB;IACzB,MAAM,EAAE,IAAI,CAAC;IACb,wBAAwB;IACxB,QAAQ,EAAE;QACN,wBAAwB;QACxB,IAAI,EAAE,QAAQ,CAAC;QACf,qBAAqB;QACrB,IAAI,EAAE;YACF,2CAA2C;YAC3C,QAAQ,EAAE,CACJ,SAAS,GACT;gBACE,qBAAqB;gBACrB,KAAK,EAAE,MAAM,CAAC;aACjB,CACJ,EAAE,CAAC;SACP,CAAC;KACL,CAAC;CACL;AAED,2CAA2C;AAC3C,MAAM,WAAW,wBAAyB,SAAQ,oBAAoB;IAClE,yBAAyB;IACzB,MAAM,EAAE,IAAI,CAAC;IACb,wBAAwB;IACxB,QAAQ,EAAE;QACN,wBAAwB;QACxB,IAAI,EAAE,kBAAkB,CAAC;QACzB,2BAA2B;QAC3B,IAAI,EAAE,GAAG,CAAC;KACb,CAAC;CACL;AAED,4CAA4C;AAC5C,MAAM,WAAW,aAAc,SAAQ,oBAAoB;IACvD,oBAAoB;IACpB,MAAM,EAAE,KAAK,CAAC;IACd,qBAAqB;IACrB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,4DAA4D;AAC5D,MAAM,WAAW,aAA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