@nktkas/hyperliquid 0.13.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +302 -91
- 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} +10 -13
- 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 +836 -220
- 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 +1 -1
- package/esm/src/transports/http/http_transport.d.ts.map +1 -1
- package/esm/src/transports/http/http_transport.js +1 -1
- 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 +12 -15
- package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/esm/src/transports/websocket/websocket_transport.js +45 -48
- 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} +10 -13
- 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 +837 -221
- 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 +1 -1
- package/script/src/transports/http/http_transport.d.ts.map +1 -1
- package/script/src/transports/http/http_transport.js +2 -2
- 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 +12 -15
- package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/script/src/transports/websocket/websocket_transport.js +51 -54
- 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
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# Hyperliquid API TypeScript SDK
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@nktkas/hyperliquid)
|
|
4
|
+
[](https://jsr.io/@nktkas/hyperliquid)
|
|
5
|
+
[](https://coveralls.io/github/nktkas/hyperliquid)
|
|
6
|
+
[](https://bundlejs.com/?q=@nktkas/hyperliquid)
|
|
6
7
|
|
|
7
8
|
Unofficial [Hyperliquid API](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api) SDK for all major JS
|
|
8
9
|
runtimes, written in TypeScript and provided with tests.
|
|
@@ -10,12 +11,12 @@ runtimes, written in TypeScript and provided with tests.
|
|
|
10
11
|
## Features
|
|
11
12
|
|
|
12
13
|
- 🖋️ **Typed**: Source code is 100% TypeScript.
|
|
13
|
-
- 🧪 **Tested**: Good code coverage and type
|
|
14
|
+
- 🧪 **Tested**: Good code coverage and type testing.
|
|
14
15
|
- 📦 **Minimal dependencies**: Few small dependencies, standard JS is favored.
|
|
15
16
|
- 🌐 **Cross-Environment Support**: Compatible with all major JS runtimes, including Node.js, Deno, Bun, and browser
|
|
16
17
|
environments.
|
|
17
|
-
- 🔧 **
|
|
18
|
-
[ethers](https://github.com/ethers-io/ethers.js).
|
|
18
|
+
- 🔧 **Integratable**: Easy to use with [viem](https://github.com/wevm/viem),
|
|
19
|
+
[ethers](https://github.com/ethers-io/ethers.js) and web3 wallets.
|
|
19
20
|
- 📚 **Documented**: Comprehensive documentation and usage examples, provided directly in JSDoc annotations within the
|
|
20
21
|
source code.
|
|
21
22
|
|
|
@@ -51,21 +52,15 @@ First, choose and configure your transport layer (more details in the [API Refer
|
|
|
51
52
|
import * as hl from "@nktkas/hyperliquid";
|
|
52
53
|
|
|
53
54
|
// HTTP Transport
|
|
54
|
-
const httpTransport = new hl.HttpTransport(
|
|
55
|
-
url: "https://api.hyperliquid.xyz", // API base URL for /info, /exchange, /explorer
|
|
56
|
-
timeout: 10_000, // Request timeout in ms
|
|
57
|
-
});
|
|
55
|
+
const httpTransport = new hl.HttpTransport(); // Accepts optional parameters (e.g. url, timeout, fetchOptions)
|
|
58
56
|
|
|
59
|
-
//
|
|
60
|
-
const wsTransport = new hl.WebSocketTransport(
|
|
61
|
-
url: "wss://api.hyperliquid.xyz/ws", // WebSocket URL
|
|
62
|
-
timeout: 10_000, // Request timeout in ms
|
|
63
|
-
});
|
|
57
|
+
// or WebSocket Transport
|
|
58
|
+
const wsTransport = new hl.WebSocketTransport(); // Accepts optional parameters (e.g. url, timeout, keepAlive, reconnect)
|
|
64
59
|
```
|
|
65
60
|
|
|
66
61
|
### Initialize Client
|
|
67
62
|
|
|
68
|
-
Next, initialize
|
|
63
|
+
Next, initialize a client with the transport layer (more details in the [API Reference](#clients)):
|
|
69
64
|
|
|
70
65
|
#### Create PublicClient
|
|
71
66
|
|
|
@@ -97,7 +92,10 @@ const ethersClient = new hl.WalletClient({ wallet: ethersWallet, transport });
|
|
|
97
92
|
// 3. Using external wallet (e.g. MetaMask) via Viem
|
|
98
93
|
const [account] = await window.ethereum.request({ method: "eth_requestAccounts" });
|
|
99
94
|
const externalWallet = createWalletClient({ account, transport: custom(window.ethereum) });
|
|
100
|
-
const
|
|
95
|
+
const viemMetamaskClient = new hl.WalletClient({ wallet: externalWallet, transport });
|
|
96
|
+
|
|
97
|
+
// 4. Using external wallet (e.g. MetaMask) via `window.ethereum` directly
|
|
98
|
+
const windowMetamaskClient = new hl.WalletClient({ wallet: window.ethereum, transport });
|
|
101
99
|
```
|
|
102
100
|
|
|
103
101
|
#### Create EventClient
|
|
@@ -105,8 +103,99 @@ const metamaskClient = new hl.WalletClient({ wallet: externalWallet, transport }
|
|
|
105
103
|
```typescript
|
|
106
104
|
import * as hl from "@nktkas/hyperliquid";
|
|
107
105
|
|
|
106
|
+
const transport = new hl.WebSocketTransport(); // Only WebSocketTransport is supported
|
|
107
|
+
const client = new hl.EventClient({ transport });
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Use Client
|
|
111
|
+
|
|
112
|
+
Finally, use client methods to interact with the Hyperliquid API (more details in the [API Reference](#clients)):
|
|
113
|
+
|
|
114
|
+
#### Example of using a public client
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import * as hl from "@nktkas/hyperliquid";
|
|
118
|
+
|
|
119
|
+
const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
120
|
+
const client = new hl.PublicClient({ transport });
|
|
121
|
+
|
|
122
|
+
// L2 Book
|
|
123
|
+
const l2Book = await client.l2Book({ coin: "BTC" });
|
|
124
|
+
|
|
125
|
+
// Account clearinghouse state
|
|
126
|
+
const clearinghouseState = await client.clearinghouseState({ user: "0x..." });
|
|
127
|
+
|
|
128
|
+
// Open orders
|
|
129
|
+
const openOrders = await client.openOrders({ user: "0x..." });
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### Example of using a wallet client
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import * as hl from "@nktkas/hyperliquid";
|
|
136
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
137
|
+
|
|
138
|
+
const account = privateKeyToAccount("0x...");
|
|
139
|
+
const transport = new hl.HttpTransport();
|
|
140
|
+
const client = new hl.WalletClient({ wallet: account, transport });
|
|
141
|
+
|
|
142
|
+
// Place an orders
|
|
143
|
+
const result = await client.order({
|
|
144
|
+
orders: [{
|
|
145
|
+
a: 0, // Asset index
|
|
146
|
+
b: true, // Buy order
|
|
147
|
+
p: "30000", // Price
|
|
148
|
+
s: "0.1", // Size
|
|
149
|
+
r: false, // Not reduce-only
|
|
150
|
+
t: {
|
|
151
|
+
limit: {
|
|
152
|
+
tif: "Gtc", // Good-til-cancelled
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
}],
|
|
156
|
+
grouping: "na", // No grouping
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Approve an agent
|
|
160
|
+
const result = await client.approveAgent({
|
|
161
|
+
agentAddress: "0x...",
|
|
162
|
+
agentName: "agentName",
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Withdraw funds
|
|
166
|
+
const result = await client.withdraw3({
|
|
167
|
+
destination: account.address, // Withdraw funds to your address
|
|
168
|
+
amount: "100", // 100 USD
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
#### Example of using an event client
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
import * as hl from "@nktkas/hyperliquid";
|
|
176
|
+
|
|
108
177
|
const transport = new hl.WebSocketTransport();
|
|
109
178
|
const client = new hl.EventClient({ transport });
|
|
179
|
+
|
|
180
|
+
// L2 Book updates
|
|
181
|
+
// Promise is resolved when the subscription is set up
|
|
182
|
+
const sub = await client.l2Book({ coin: "BTC" }, (data) => {
|
|
183
|
+
console.log(data);
|
|
184
|
+
});
|
|
185
|
+
// Later, you can unsubscribe from receiving events
|
|
186
|
+
await sub.unsubscribe();
|
|
187
|
+
|
|
188
|
+
// User fills
|
|
189
|
+
const sub = await client.userFills({ user: "0x..." }, (data) => {
|
|
190
|
+
console.log(data);
|
|
191
|
+
});
|
|
192
|
+
await sub.unsubscribe();
|
|
193
|
+
|
|
194
|
+
// Explorer block updates
|
|
195
|
+
const sub = await client.explorerBlock((data) => {
|
|
196
|
+
console.log(data);
|
|
197
|
+
});
|
|
198
|
+
await sub.unsubscribe();
|
|
110
199
|
```
|
|
111
200
|
|
|
112
201
|
## API Reference
|
|
@@ -126,20 +215,18 @@ A Public Client which provides access to
|
|
|
126
215
|
The Public Client class sets up with a given [Transport](#transports).
|
|
127
216
|
|
|
128
217
|
```typescript
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
class PublicClient<T extends IRESTTransport> {
|
|
134
|
-
constructor(args: PublicClientParameters<T>);
|
|
218
|
+
class PublicClient {
|
|
219
|
+
constructor(args: {
|
|
220
|
+
transport: HttpTransport | WebSocketTransport;
|
|
221
|
+
});
|
|
135
222
|
|
|
136
223
|
// Market
|
|
137
224
|
allMids(): Promise<AllMids>;
|
|
138
|
-
candleSnapshot(args: CandleSnapshotParameters): Promise<
|
|
225
|
+
candleSnapshot(args: CandleSnapshotParameters): Promise<Candle[]>;
|
|
139
226
|
fundingHistory(args: FundingHistoryParameters): Promise<FundingHistory[]>;
|
|
140
|
-
l2Book(args: L2BookParameters): Promise<
|
|
141
|
-
meta(): Promise<
|
|
142
|
-
metaAndAssetCtxs(): Promise<
|
|
227
|
+
l2Book(args: L2BookParameters): Promise<Book>;
|
|
228
|
+
meta(): Promise<PerpsMeta>;
|
|
229
|
+
metaAndAssetCtxs(): Promise<PerpsMetaAndAssetCtxs>;
|
|
143
230
|
perpsAtOpenInterestCap(): Promise<string[]>;
|
|
144
231
|
predictedFundings(): Promise<PredictedFunding[]>;
|
|
145
232
|
spotDeployState(args: SpotDeployStateParameters): Promise<SpotDeployState>;
|
|
@@ -148,28 +235,30 @@ class PublicClient<T extends IRESTTransport> {
|
|
|
148
235
|
tokenDetails(args: TokenDetailsParameters): Promise<TokenDetails>;
|
|
149
236
|
|
|
150
237
|
// Account
|
|
151
|
-
clearinghouseState(args: ClearinghouseStateParameters): Promise<
|
|
238
|
+
clearinghouseState(args: ClearinghouseStateParameters): Promise<PerpsClearinghouseState>;
|
|
152
239
|
extraAgents(args: ExtraAgentsParameters): Promise<ExtraAgent[]>;
|
|
240
|
+
isVip(args: IsVipParameters): Promise<boolean>;
|
|
241
|
+
legalCheck(args: LegalCheckParameters): Promise<LegalCheck>;
|
|
153
242
|
maxBuilderFee(args: MaxBuilderFeeParameters): Promise<number>;
|
|
154
243
|
portfolio(args: PortfolioParameters): Promise<PortfolioPeriods>;
|
|
155
244
|
referral(args: ReferralParameters): Promise<Referral>;
|
|
156
245
|
spotClearinghouseState(args: SpotClearinghouseStateParameters): Promise<SpotClearinghouseState>;
|
|
157
|
-
subAccounts(args: SubAccountsParameters): Promise<SubAccount[]>;
|
|
246
|
+
subAccounts(args: SubAccountsParameters): Promise<SubAccount[] | null>;
|
|
158
247
|
userFees(args: UserFeesParameters): Promise<UserFees>;
|
|
159
|
-
userFunding(args: UserFundingParameters): Promise<
|
|
160
|
-
userNonFundingLedgerUpdates(args: UserNonFundingLedgerUpdatesParameters): Promise<
|
|
248
|
+
userFunding(args: UserFundingParameters): Promise<UserFundingUpdate[]>;
|
|
249
|
+
userNonFundingLedgerUpdates(args: UserNonFundingLedgerUpdatesParameters): Promise<UserNonFundingLedgerUpdate[]>;
|
|
161
250
|
userRateLimit(args: UserRateLimitParameters): Promise<UserRateLimit>;
|
|
162
251
|
userRole(args: UserRoleParameters): Promise<UserRole>;
|
|
163
252
|
|
|
164
253
|
// Order
|
|
165
|
-
frontendOpenOrders(args: FrontendOpenOrdersParameters): Promise<
|
|
166
|
-
historicalOrders(args: HistoricalOrdersParameters): Promise<OrderStatus[]>;
|
|
167
|
-
openOrders(args: OpenOrdersParameters): Promise<
|
|
168
|
-
orderStatus(args: OrderStatusParameters): Promise<
|
|
169
|
-
twapHistory(args: TwapHistoryParameters): Promise<TwapHistory>;
|
|
170
|
-
userFills(args: UserFillsParameters): Promise<
|
|
171
|
-
userFillsByTime(args: UserFillsByTimeParameters): Promise<
|
|
172
|
-
userTwapSliceFills(args: UserTwapSliceFillsParameters): Promise<
|
|
254
|
+
frontendOpenOrders(args: FrontendOpenOrdersParameters): Promise<FrontendOrder[]>;
|
|
255
|
+
historicalOrders(args: HistoricalOrdersParameters): Promise<OrderStatus<FrontendOrder>[]>;
|
|
256
|
+
openOrders(args: OpenOrdersParameters): Promise<Order[]>;
|
|
257
|
+
orderStatus(args: OrderStatusParameters): Promise<OrderLookup>;
|
|
258
|
+
twapHistory(args: TwapHistoryParameters): Promise<TwapHistory[]>;
|
|
259
|
+
userFills(args: UserFillsParameters): Promise<Fill[]>;
|
|
260
|
+
userFillsByTime(args: UserFillsByTimeParameters): Promise<Fill[]>;
|
|
261
|
+
userTwapSliceFills(args: UserTwapSliceFillsParameters): Promise<TwapSliceFill[]>;
|
|
173
262
|
|
|
174
263
|
// Staking
|
|
175
264
|
delegations(args: DelegationsParameters): Promise<Delegation[]>;
|
|
@@ -179,7 +268,7 @@ class PublicClient<T extends IRESTTransport> {
|
|
|
179
268
|
validatorSummaries(): Promise<ValidatorSummary[]>;
|
|
180
269
|
|
|
181
270
|
// Vault
|
|
182
|
-
userVaultEquities(args: UserVaultEquitiesParameters): Promise<
|
|
271
|
+
userVaultEquities(args: UserVaultEquitiesParameters): Promise<VaultEquity[]>;
|
|
183
272
|
vaultDetails(args: VaultDetailsParameters): Promise<VaultDetails | null>;
|
|
184
273
|
vaultSummaries(): Promise<VaultSummary[]>;
|
|
185
274
|
|
|
@@ -201,21 +290,18 @@ The Wallet Client class sets up with a given [Transport](#transports) and a wall
|
|
|
201
290
|
[Ethers Wallet](https://docs.ethers.org/v6/api/providers/#Signer).
|
|
202
291
|
|
|
203
292
|
```typescript
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
W extends AbstractViemWalletClient | AbstractEthersSigner | AbstractEthersV5Signer,
|
|
217
|
-
> {
|
|
218
|
-
constructor(args: WalletClientParameters<T, W>);
|
|
293
|
+
class WalletClient {
|
|
294
|
+
constructor(args: {
|
|
295
|
+
transport: HttpTransport | WebSocketTransport;
|
|
296
|
+
wallet:
|
|
297
|
+
| AbstractViemWalletClient // viem
|
|
298
|
+
| AbstractExtendedViemWalletClient // extended viem (e.g. privy)
|
|
299
|
+
| AbstractEthersSigner // ethers
|
|
300
|
+
| AbstractEthersV5Signer // ethers v5
|
|
301
|
+
| AbstractWindowEthereum; // window.ethereum (EIP-1193) directly
|
|
302
|
+
isTestnet?: boolean; // Whether to use testnet API (default: false)
|
|
303
|
+
defaultVaultAddress?: Hex; // Vault address used by default if not provided in method call
|
|
304
|
+
});
|
|
219
305
|
|
|
220
306
|
// Order
|
|
221
307
|
batchModify(args: BatchModifyParameters): Promise<OrderResponseSuccess>;
|
|
@@ -232,21 +318,30 @@ class WalletClient<
|
|
|
232
318
|
// Account
|
|
233
319
|
approveAgent(args: ApproveAgentParameters): Promise<SuccessResponse>;
|
|
234
320
|
approveBuilderFee(args: ApproveBuilderFeeParameters): Promise<SuccessResponse>;
|
|
321
|
+
claimRewards(args: ClaimRewardsParameters): Promise<SuccessResponse>;
|
|
235
322
|
createSubAccount(args: CreateSubAccountParameters): Promise<CreateSubAccountResponse>;
|
|
323
|
+
evmUserModify(args: EvmUserModifyParameters): Promise<SuccessResponse>;
|
|
324
|
+
setDisplayName(args: SetDisplayNameParameters): Promise<SuccessResponse>;
|
|
236
325
|
setReferrer(args: SetReferrerParameters): Promise<SuccessResponse>;
|
|
326
|
+
spotUser(args: SpotUserParameters): Promise<SuccessResponse>;
|
|
237
327
|
|
|
238
328
|
// Transfers & Withdrawals
|
|
239
329
|
spotSend(args: SpotSendParameters): Promise<SuccessResponse>;
|
|
330
|
+
subAccountSpotTransfer(args: SubAccountSpotTransferParameters): Promise<SuccessResponse>;
|
|
240
331
|
subAccountTransfer(args: SubAccountTransferParameters): Promise<SuccessResponse>;
|
|
241
332
|
usdClassTransfer(args: UsdClassTransferParameters): Promise<SuccessResponse>;
|
|
242
333
|
usdSend(args: UsdSendParameters): Promise<SuccessResponse>;
|
|
243
|
-
vaultTransfer(args: VaultTransferParameters): Promise<SuccessResponse>;
|
|
244
334
|
withdraw3(args: Withdraw3Parameters): Promise<SuccessResponse>;
|
|
245
335
|
|
|
246
336
|
// Staking
|
|
247
337
|
cDeposit(args: CDepositParameters): Promise<SuccessResponse>;
|
|
248
338
|
cWithdraw(args: CWithdrawParameters): Promise<SuccessResponse>;
|
|
249
339
|
tokenDelegate(args: TokenDelegateParameters): Promise<SuccessResponse>;
|
|
340
|
+
|
|
341
|
+
// Vault
|
|
342
|
+
vaultDistribute(args: VaultDistributeParameters): Promise<SuccessResponse>;
|
|
343
|
+
vaultModify(args: VaultModifyParameters): Promise<SuccessResponse>;
|
|
344
|
+
vaultTransfer(args: VaultTransferParameters): Promise<SuccessResponse>;
|
|
250
345
|
}
|
|
251
346
|
```
|
|
252
347
|
|
|
@@ -260,12 +355,10 @@ The Event Client class sets up with a given [WebSocket Transport](#websocket-tra
|
|
|
260
355
|
|
|
261
356
|
<!-- deno-fmt-ignore-start -->
|
|
262
357
|
```typescript
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
class EventClient<T extends ISubscriptionTransport> {
|
|
268
|
-
constructor(args: EventClientParameters<T>);
|
|
358
|
+
class EventClient {
|
|
359
|
+
constructor(args: {
|
|
360
|
+
transport: WebSocketTransport;
|
|
361
|
+
});
|
|
269
362
|
|
|
270
363
|
// Market
|
|
271
364
|
activeAssetCtx(args: EventActiveAssetCtxParameters, listener: (data: WsActiveAssetCtx | WsActiveSpotAssetCtx) => void): Promise<Subscription>;
|
|
@@ -308,19 +401,17 @@ A HTTP Transport that executes requests via a [fetch](https://developer.mozilla.
|
|
|
308
401
|
API.
|
|
309
402
|
|
|
310
403
|
```typescript
|
|
311
|
-
class HttpTransport
|
|
312
|
-
constructor(options?:
|
|
404
|
+
class HttpTransport {
|
|
405
|
+
constructor(options?: {
|
|
406
|
+
url?: string | URL; // Base URL for API endpoints (default: "https://api.hyperliquid.xyz")
|
|
407
|
+
timeout?: number; // Request timeout in ms (default: 10_000)
|
|
408
|
+
fetchOptions?: RequestInit; // A custom fetch options
|
|
409
|
+
onRequest?: (request: Request) => MaybePromise<Request | void | null | undefined>; // A callback before request is sent
|
|
410
|
+
onResponse?: (response: Response) => MaybePromise<Response | void | null | undefined>; // A callback after response is received
|
|
411
|
+
});
|
|
313
412
|
|
|
314
413
|
request(endpoint: "info" | "action" | "explorer", payload: unknown, signal?: AbortSignal): Promise<unknown>;
|
|
315
414
|
}
|
|
316
|
-
|
|
317
|
-
interface HttpTransportOptions {
|
|
318
|
-
url?: string | URL; // Base URL for API endpoints (default: "https://api.hyperliquid.xyz")
|
|
319
|
-
timeout?: number; // Request timeout in ms (default: 10_000)
|
|
320
|
-
fetchOptions?: RequestInit; // A custom fetch options
|
|
321
|
-
onRequest?: (request: Request) => MaybePromise<Request | void | null | undefined>; // A callback before request is sent
|
|
322
|
-
onResponse?: (response: Response) => MaybePromise<Response | void | null | undefined>; // A callback after response is received
|
|
323
|
-
}
|
|
324
415
|
```
|
|
325
416
|
|
|
326
417
|
#### WebSocket Transport
|
|
@@ -329,8 +420,21 @@ A WebSocket Transport that executes requests and subscribes to events via a
|
|
|
329
420
|
[WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) connection.
|
|
330
421
|
|
|
331
422
|
```typescript
|
|
332
|
-
class WebSocketTransport
|
|
333
|
-
constructor(options?:
|
|
423
|
+
class WebSocketTransport {
|
|
424
|
+
constructor(options?: {
|
|
425
|
+
url?: string | URL; // WebSocket URL (default: "wss://api.hyperliquid.xyz/ws")
|
|
426
|
+
timeout?: number; // Request timeout in ms (default: 10_000)
|
|
427
|
+
keepAlive?: { // Keep-alive configuration
|
|
428
|
+
interval?: number; // Ping interval in ms (default: 20_000)
|
|
429
|
+
};
|
|
430
|
+
reconnect?: { // Reconnection policy configuration for closed connections
|
|
431
|
+
maxRetries?: number; // Maximum number of reconnection attempts (default: 3)
|
|
432
|
+
connectionTimeout?: number; // Connection timeout in ms (default: 10_000)
|
|
433
|
+
connectionDelay?: number | ((attempt: number) => number | Promise<number>); // Delay between reconnection (default: Exponential backoff (max 10s))
|
|
434
|
+
shouldReconnect?: (event: CloseEvent) => boolean | Promise<boolean>; // Custom reconnection logic (default: Always reconnect)
|
|
435
|
+
messageBuffer?: MessageBufferStrategy; // Message buffering strategy between reconnection (default: FIFO buffer)
|
|
436
|
+
};
|
|
437
|
+
});
|
|
334
438
|
|
|
335
439
|
request(endpoint: "info" | "action" | "explorer", payload: unknown, signal?: AbortSignal): Promise<unknown>;
|
|
336
440
|
subscribe(
|
|
@@ -343,28 +447,135 @@ class WebSocketTransport implements IRESTTransport, ISubscriptionTransport {
|
|
|
343
447
|
ready(signal?: AbortSignal): Promise<void>;
|
|
344
448
|
close(signal?: AbortSignal): Promise<void>;
|
|
345
449
|
}
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
## Additional Import Points
|
|
453
|
+
|
|
454
|
+
The SDK exports additional import points to access internal functions.
|
|
455
|
+
|
|
456
|
+
### `/types`
|
|
457
|
+
|
|
458
|
+
The import point gives access to all Hyperliquid-related types, including the base types on which class methods are
|
|
459
|
+
based.
|
|
460
|
+
|
|
461
|
+
Useful if you want to get all Hyperliquid types.
|
|
462
|
+
|
|
463
|
+
### `/signing`
|
|
464
|
+
|
|
465
|
+
The import point gives access to functions that generate signatures for Hyperliquid transactions.
|
|
466
|
+
|
|
467
|
+
Useful if you want to sign a Hyperliquid transaction yourself.
|
|
468
|
+
|
|
469
|
+
### Examples
|
|
470
|
+
|
|
471
|
+
#### Cancel an order without a client
|
|
472
|
+
|
|
473
|
+
```typescript
|
|
474
|
+
import { signL1Action } from "@nktkas/hyperliquid/signing";
|
|
475
|
+
import type { CancelRequest, CancelResponse } from "@nktkas/hyperliquid/types";
|
|
476
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
477
|
+
|
|
478
|
+
// —————————— Prepare ——————————
|
|
479
|
+
|
|
480
|
+
const wallet = privateKeyToAccount("0x..."); // Change to your private key
|
|
481
|
+
|
|
482
|
+
// The CancelRequest["action"] type ensures that we collect the correct cancel request action
|
|
483
|
+
const action: CancelRequest["action"] = { type: "cancel", cancels: [{ a: 0, o: 12345 }] };
|
|
484
|
+
const nonce = Date.now();
|
|
485
|
+
|
|
486
|
+
// —————————— Signing ——————————
|
|
487
|
+
|
|
488
|
+
const signature = await signL1Action({
|
|
489
|
+
wallet,
|
|
490
|
+
action: sortedAction,
|
|
491
|
+
nonce,
|
|
492
|
+
isTestnet: true,
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
// —————————— Request ——————————
|
|
496
|
+
|
|
497
|
+
// The CancelRequest type guarantees us that the object we want to send is valid in terms of types
|
|
498
|
+
const request: CancelRequest = { action, signature, nonce };
|
|
499
|
+
|
|
500
|
+
const response = await fetch("https://api.hyperliquid-testnet.xyz/exchange", {
|
|
501
|
+
method: "POST",
|
|
502
|
+
headers: { "Content-Type": "application/json" },
|
|
503
|
+
body: JSON.stringify(request),
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
if (!response.ok) {
|
|
507
|
+
const body = await response.text();
|
|
508
|
+
throw new Error(`Failed to cancel order: ${response.statusText} ${body}`);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// If we sent a cancel request and received a successful response, then we got exactly the CancelResponse type
|
|
512
|
+
const body = await response.json() as CancelResponse;
|
|
513
|
+
console.log("Order cancel response:", body);
|
|
514
|
+
```
|
|
346
515
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
516
|
+
#### Approve an agent without a client
|
|
517
|
+
|
|
518
|
+
```typescript
|
|
519
|
+
import { signUserSignedAction } from "@nktkas/hyperliquid/signing";
|
|
520
|
+
import type { ApproveAgentRequest, ErrorResponse, SuccessResponse } from "@nktkas/hyperliquid/types";
|
|
521
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
522
|
+
|
|
523
|
+
// —————————— Prepare ——————————
|
|
524
|
+
|
|
525
|
+
const wallet = privateKeyToAccount("0x..."); // Change to your private key
|
|
526
|
+
|
|
527
|
+
// The ApproveAgentRequest["action"] type ensures that we collect the correct approve agent request action
|
|
528
|
+
const action: ApproveAgentRequest["action"] = {
|
|
529
|
+
type: "approveAgent",
|
|
530
|
+
hyperliquidChain: "Testnet",
|
|
531
|
+
signatureChainId: "0x66eee",
|
|
532
|
+
nonce: Date.now(),
|
|
533
|
+
agentAddress: "0x...", // Change to the agent address you want to approve
|
|
534
|
+
agentName: "TempAgent",
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
// —————————— Signing ——————————
|
|
538
|
+
|
|
539
|
+
const signature = await signUserSignedAction({
|
|
540
|
+
wallet,
|
|
541
|
+
action,
|
|
542
|
+
types: {
|
|
543
|
+
"HyperliquidTransaction:ApproveAgent": [
|
|
544
|
+
{ name: "hyperliquidChain", type: "string" },
|
|
545
|
+
{ name: "agentAddress", type: "address" },
|
|
546
|
+
{ name: "agentName", type: "string" },
|
|
547
|
+
{ name: "nonce", type: "uint64" },
|
|
548
|
+
],
|
|
549
|
+
},
|
|
550
|
+
chainId: parseInt(action.signatureChainId, 16),
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
// —————————— Request ——————————
|
|
554
|
+
|
|
555
|
+
// The ApproveAgentRequest type guarantees us that the object we want to send is valid in terms of types
|
|
556
|
+
const request: ApproveAgentRequest = { action, signature, nonce: action.nonce };
|
|
557
|
+
|
|
558
|
+
const response = await fetch("https://api.hyperliquid-testnet.xyz/exchange", {
|
|
559
|
+
method: "POST",
|
|
560
|
+
headers: { "Content-Type": "application/json" },
|
|
561
|
+
body: JSON.stringify(request),
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
if (!response.ok) {
|
|
565
|
+
const body = await response.text();
|
|
566
|
+
throw new Error(`Failed to approve agent: ${response.statusText} ${body}`);
|
|
361
567
|
}
|
|
568
|
+
|
|
569
|
+
// If we sent a request for agent approval and received a successful response,
|
|
570
|
+
// we will get either a SuccessResponse type or an ErrorResponse type
|
|
571
|
+
const body = await response.json() as SuccessResponse | ErrorResponse;
|
|
572
|
+
console.log("Agent approval response:", body);
|
|
362
573
|
```
|
|
363
574
|
|
|
364
|
-
##
|
|
575
|
+
## Versioning Policy
|
|
365
576
|
|
|
366
|
-
This library follows [
|
|
367
|
-
[
|
|
577
|
+
This library follows a [stricter version](https://github.com/semver/semver/pull/923) of
|
|
578
|
+
[Semantic Versioning](https://semver.org/) for its releases.
|
|
368
579
|
|
|
369
580
|
> [!IMPORTANT]
|
|
370
581
|
> To avoid rapid increase in the main version of the SDK due to changes in Hyperliquid API types, such changes are
|
package/esm/mod.d.ts
CHANGED
|
@@ -1,25 +1,16 @@
|
|
|
1
|
+
export * from "./src/base.js";
|
|
2
|
+
export type { AbstractEthersSigner, AbstractEthersV5Signer, AbstractExtendedViemWalletClient, AbstractViemWalletClient, AbstractWindowEthereum, } from "./src/signing.js";
|
|
1
3
|
export * from "./src/clients/event.js";
|
|
2
4
|
export * from "./src/clients/public.js";
|
|
3
5
|
export * from "./src/clients/wallet.js";
|
|
4
|
-
export * from "./src/transports/base.js";
|
|
5
6
|
export * from "./src/transports/http/http_transport.js";
|
|
6
7
|
export * from "./src/transports/websocket/websocket_transport.js";
|
|
7
|
-
export type { MessageBufferStrategy, ReconnectingWebSocketOptions, } from "./src/transports/websocket/reconnecting_websocket.js";
|
|
8
|
-
export { WebSocketRequestError } from "./src/transports/websocket/websocket_request_dispatcher.js";
|
|
9
|
-
export type * from "./src/types/common.js";
|
|
10
|
-
export type * from "./src/types/exchange/common.js";
|
|
11
|
-
export type * from "./src/types/exchange/requests.js";
|
|
12
8
|
export type * from "./src/types/exchange/responses.js";
|
|
13
|
-
export type * from "./src/types/explorer/common.js";
|
|
14
|
-
export type * from "./src/types/explorer/requests.js";
|
|
15
9
|
export type * from "./src/types/explorer/responses.js";
|
|
16
10
|
export type * from "./src/types/info/accounts.js";
|
|
17
11
|
export type * from "./src/types/info/assets.js";
|
|
18
12
|
export type * from "./src/types/info/delegations.js";
|
|
19
13
|
export type * from "./src/types/info/orders.js";
|
|
20
|
-
export type * from "./src/types/info/requests.js";
|
|
21
14
|
export type * from "./src/types/info/vaults.js";
|
|
22
|
-
export type * from "./src/types/subscriptions/
|
|
23
|
-
export type * from "./src/types/subscriptions/requests.js";
|
|
24
|
-
export type { AbstractEthersSigner, AbstractEthersV5Signer, AbstractViemWalletClient } from "./src/utils/signing.js";
|
|
15
|
+
export type * from "./src/types/subscriptions/responses.js";
|
|
25
16
|
//# sourceMappingURL=mod.d.ts.map
|
package/esm/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AACA,cAAc,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AACA,cAAc,eAAe,CAAC;AAG9B,YAAY,EACR,oBAAoB,EACpB,sBAAsB,EACtB,gCAAgC,EAChC,wBAAwB,EACxB,sBAAsB,GACzB,MAAM,kBAAkB,CAAC;AAG1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,yCAAyC,CAAC;AACxD,cAAc,mDAAmD,CAAC;AAGlE,mBAAmB,mCAAmC,CAAC;AACvD,mBAAmB,mCAAmC,CAAC;AACvD,mBAAmB,8BAA8B,CAAC;AAClD,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,iCAAiC,CAAC;AACrD,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,wCAAwC,CAAC"}
|
package/esm/mod.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
// Base interfaces
|
|
2
|
+
export * from "./src/base.js";
|
|
1
3
|
// Clients
|
|
2
4
|
export * from "./src/clients/event.js";
|
|
3
5
|
export * from "./src/clients/public.js";
|
|
4
6
|
export * from "./src/clients/wallet.js";
|
|
5
7
|
// Transports
|
|
6
|
-
export * from "./src/transports/base.js";
|
|
7
8
|
export * from "./src/transports/http/http_transport.js";
|
|
8
9
|
export * from "./src/transports/websocket/websocket_transport.js";
|
|
9
|
-
export { WebSocketRequestError } from "./src/transports/websocket/websocket_request_dispatcher.js";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Hexadecimal string starting with `0x`. */
|
|
2
|
+
export type Hex = `0x${string}`;
|
|
1
3
|
/**
|
|
2
4
|
* Interface representing a REST transport.
|
|
3
5
|
* Handles communication with Hyperliquid API endpoints.
|
|
@@ -31,9 +33,7 @@ export interface ISubscriptionTransport {
|
|
|
31
33
|
*/
|
|
32
34
|
subscribe(channel: string, payload: unknown, listener: (data: CustomEvent) => void, signal?: AbortSignal): Promise<Subscription>;
|
|
33
35
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Controls event subscription lifecycle.
|
|
36
|
-
*/
|
|
36
|
+
/** Controls event subscription lifecycle. */
|
|
37
37
|
export interface Subscription {
|
|
38
38
|
/**
|
|
39
39
|
* Unsubscribes from the event and sends an unsubscribe request to the server.
|
|
@@ -41,15 +41,12 @@ export interface Subscription {
|
|
|
41
41
|
*/
|
|
42
42
|
unsubscribe(signal?: AbortSignal): Promise<void>;
|
|
43
43
|
}
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
* @param options - Additional error options.
|
|
52
|
-
*/
|
|
53
|
-
constructor(message?: string, options?: ErrorOptions);
|
|
44
|
+
/** Base class for all Hyperliquid SDK errors. */
|
|
45
|
+
export declare class HyperliquidError extends Error {
|
|
46
|
+
constructor(message?: string);
|
|
47
|
+
}
|
|
48
|
+
/** Base class for all transport-related errors. */
|
|
49
|
+
export declare class TransportError extends HyperliquidError {
|
|
50
|
+
constructor(message?: string);
|
|
54
51
|
}
|
|
55
52
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/src/base.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,MAAM,MAAM,GAAG,GAAG,KAAK,MAAM,EAAE,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/G;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACnC;;;;;;;OAOG;IACH,SAAS,CACL,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,EACrC,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,YAAY,CAAC,CAAC;CAC5B;AAED,6CAA6C;AAC7C,MAAM,WAAW,YAAY;IACzB;;;OAGG;IACH,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED,iDAAiD;AACjD,qBAAa,gBAAiB,SAAQ,KAAK;gBAC3B,OAAO,CAAC,EAAE,MAAM;CAI/B;AAED,mDAAmD;AACnD,qBAAa,cAAe,SAAQ,gBAAgB;gBACpC,OAAO,CAAC,EAAE,MAAM;CAI/B"}
|
package/esm/src/base.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Base class for all Hyperliquid SDK errors. */
|
|
2
|
+
export class HyperliquidError extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "HyperliquidError";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/** Base class for all transport-related errors. */
|
|
9
|
+
export class TransportError extends HyperliquidError {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "TransportError";
|
|
13
|
+
}
|
|
14
|
+
}
|