opentool 0.7.13 → 0.8.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.
@@ -0,0 +1,414 @@
1
+ import { c as WalletFullContext } from '../../types-BVLpaY4O.js';
2
+ import { StoreOptions, StoreResponse } from '../../store/index.js';
3
+ import 'viem';
4
+ import 'viem/accounts';
5
+
6
+ type HyperliquidEnvironment = "mainnet" | "testnet";
7
+ type HyperliquidTimeInForce = "Gtc" | "Ioc" | "Alo" | "FrontendMarket" | "LiquidationMarket";
8
+ type HyperliquidGrouping = "na" | "normalTpsl" | "positionTpsl";
9
+ type HyperliquidTriggerType = "tp" | "sl";
10
+ interface HyperliquidTriggerOptions {
11
+ triggerPx: string | number | bigint;
12
+ isMarket?: boolean;
13
+ tpsl: HyperliquidTriggerType;
14
+ }
15
+ interface HyperliquidBuilderFee {
16
+ address: `0x${string}`;
17
+ /**
18
+ * Fee in tenths of basis points (10 = 1bp = 0.01%). Max defaults to 0.1% (100).
19
+ */
20
+ fee: number;
21
+ }
22
+ interface HyperliquidOrderIntent {
23
+ symbol: string;
24
+ side: "buy" | "sell";
25
+ price: string | number | bigint;
26
+ size: string | number | bigint;
27
+ tif?: HyperliquidTimeInForce;
28
+ reduceOnly?: boolean;
29
+ clientId?: `0x${string}`;
30
+ trigger?: HyperliquidTriggerOptions;
31
+ }
32
+ type ExchangeOrderAction = {
33
+ type: "order";
34
+ orders: Array<{
35
+ a: number;
36
+ b: boolean;
37
+ p: string;
38
+ s: string;
39
+ r: boolean;
40
+ t: {
41
+ limit: {
42
+ tif: HyperliquidTimeInForce;
43
+ };
44
+ } | {
45
+ trigger: {
46
+ isMarket: boolean;
47
+ triggerPx: string;
48
+ tpsl: HyperliquidTriggerType;
49
+ };
50
+ };
51
+ c?: `0x${string}`;
52
+ }>;
53
+ grouping: HyperliquidGrouping;
54
+ builder?: {
55
+ b: `0x${string}`;
56
+ f: number;
57
+ };
58
+ };
59
+ type ExchangeSignature = {
60
+ r: `0x${string}`;
61
+ s: `0x${string}`;
62
+ v: 27 | 28;
63
+ };
64
+ type HyperliquidExchangeResponse<T = unknown> = {
65
+ status: "ok";
66
+ response?: {
67
+ type: string;
68
+ data?: T;
69
+ };
70
+ error?: string;
71
+ };
72
+ type NonceSource = () => number;
73
+ declare class HyperliquidApiError extends Error {
74
+ readonly response: unknown;
75
+ constructor(message: string, response: unknown);
76
+ }
77
+ declare class HyperliquidGuardError extends Error {
78
+ constructor(message: string);
79
+ }
80
+ declare class HyperliquidTermsError extends HyperliquidGuardError {
81
+ constructor(message?: string);
82
+ }
83
+ declare class HyperliquidBuilderApprovalError extends HyperliquidGuardError {
84
+ constructor(message?: string);
85
+ }
86
+ declare function createMonotonicNonceFactory(start?: number): NonceSource;
87
+ declare function toApiDecimal(value: string | number | bigint): string;
88
+ declare function splitSignature(signature: `0x${string}`): ExchangeSignature;
89
+ declare function createL1ActionHash(args: {
90
+ action: ExchangeOrderAction | Record<string, unknown>;
91
+ nonce: number;
92
+ vaultAddress?: `0x${string}` | undefined;
93
+ expiresAfter?: number | undefined;
94
+ }): `0x${string}`;
95
+
96
+ type CommonActionOptions = {
97
+ environment?: HyperliquidEnvironment;
98
+ vaultAddress?: `0x${string}` | undefined;
99
+ expiresAfter?: number | undefined;
100
+ nonce?: number | undefined;
101
+ nonceSource?: NonceSource | undefined;
102
+ /**
103
+ * Optional per-wallet nonce provider (preferred if available).
104
+ */
105
+ walletNonceProvider?: NonceSource | undefined;
106
+ };
107
+ type CancelInput = {
108
+ symbol: string;
109
+ oid: number | string;
110
+ };
111
+ type CancelByCloidInput = {
112
+ symbol: string;
113
+ cloid: `0x${string}`;
114
+ };
115
+ type ModifyOrderInput = {
116
+ oid: number | `0x${string}`;
117
+ order: HyperliquidOrderIntent;
118
+ };
119
+ type TwapOrderInput = {
120
+ symbol: string;
121
+ side: "buy" | "sell";
122
+ size: string | number | bigint;
123
+ reduceOnly?: boolean;
124
+ minutes: number;
125
+ randomize?: boolean;
126
+ };
127
+ type TwapCancelInput = {
128
+ symbol: string;
129
+ twapId: number;
130
+ };
131
+ type UpdateLeverageInput = {
132
+ symbol: string;
133
+ leverageMode: "cross" | "isolated";
134
+ leverage: number;
135
+ };
136
+ type UpdateIsolatedMarginInput = {
137
+ symbol: string;
138
+ isBuy: boolean;
139
+ ntli: number;
140
+ };
141
+ declare class HyperliquidExchangeClient {
142
+ private readonly nonceSource;
143
+ private readonly environment;
144
+ private readonly vaultAddress;
145
+ private readonly expiresAfter;
146
+ private readonly wallet;
147
+ constructor(args: {
148
+ wallet: WalletFullContext;
149
+ environment?: HyperliquidEnvironment;
150
+ vaultAddress?: `0x${string}`;
151
+ expiresAfter?: number;
152
+ nonceSource?: NonceSource;
153
+ walletNonceProvider?: NonceSource;
154
+ });
155
+ cancel(cancels: CancelInput[]): Promise<HyperliquidExchangeResponse<unknown>>;
156
+ cancelByCloid(cancels: CancelByCloidInput[]): Promise<HyperliquidExchangeResponse<unknown>>;
157
+ cancelAll(): Promise<HyperliquidExchangeResponse<unknown>>;
158
+ scheduleCancel(time: number | null): Promise<HyperliquidExchangeResponse<unknown>>;
159
+ modify(modification: ModifyOrderInput): Promise<HyperliquidExchangeResponse<unknown>>;
160
+ batchModify(modifications: ModifyOrderInput[]): Promise<HyperliquidExchangeResponse<unknown>>;
161
+ twapOrder(twap: TwapOrderInput): Promise<HyperliquidExchangeResponse<unknown>>;
162
+ twapCancel(cancel: TwapCancelInput): Promise<HyperliquidExchangeResponse<unknown>>;
163
+ updateLeverage(input: UpdateLeverageInput): Promise<HyperliquidExchangeResponse<unknown>>;
164
+ updateIsolatedMargin(input: UpdateIsolatedMarginInput): Promise<HyperliquidExchangeResponse<unknown>>;
165
+ reserveRequestWeight(weight: number): Promise<HyperliquidExchangeResponse<unknown>>;
166
+ spotSend(params: {
167
+ destination: `0x${string}`;
168
+ token: string;
169
+ amount: string | number | bigint;
170
+ }): Promise<HyperliquidExchangeResponse<unknown>>;
171
+ }
172
+ declare function cancelHyperliquidOrders(options: {
173
+ wallet: WalletFullContext;
174
+ cancels: CancelInput[];
175
+ } & CommonActionOptions): Promise<HyperliquidExchangeResponse<unknown>>;
176
+ declare function cancelHyperliquidOrdersByCloid(options: {
177
+ wallet: WalletFullContext;
178
+ cancels: CancelByCloidInput[];
179
+ } & CommonActionOptions): Promise<HyperliquidExchangeResponse<unknown>>;
180
+ declare function cancelAllHyperliquidOrders(options: {
181
+ wallet: WalletFullContext;
182
+ } & CommonActionOptions): Promise<HyperliquidExchangeResponse<unknown>>;
183
+ declare function scheduleHyperliquidCancel(options: {
184
+ wallet: WalletFullContext;
185
+ time: number | null;
186
+ } & CommonActionOptions): Promise<HyperliquidExchangeResponse<unknown>>;
187
+ declare function modifyHyperliquidOrder(options: {
188
+ wallet: WalletFullContext;
189
+ modification: ModifyOrderInput;
190
+ grouping?: HyperliquidGrouping;
191
+ } & CommonActionOptions): Promise<HyperliquidExchangeResponse<unknown>>;
192
+ declare function batchModifyHyperliquidOrders(options: {
193
+ wallet: WalletFullContext;
194
+ modifications: ModifyOrderInput[];
195
+ } & CommonActionOptions): Promise<HyperliquidExchangeResponse<unknown>>;
196
+ declare function placeHyperliquidTwapOrder(options: {
197
+ wallet: WalletFullContext;
198
+ twap: TwapOrderInput;
199
+ } & CommonActionOptions): Promise<HyperliquidExchangeResponse<unknown>>;
200
+ declare function cancelHyperliquidTwapOrder(options: {
201
+ wallet: WalletFullContext;
202
+ cancel: TwapCancelInput;
203
+ } & CommonActionOptions): Promise<HyperliquidExchangeResponse<unknown>>;
204
+ declare function updateHyperliquidLeverage(options: {
205
+ wallet: WalletFullContext;
206
+ input: UpdateLeverageInput;
207
+ } & CommonActionOptions): Promise<HyperliquidExchangeResponse<unknown>>;
208
+ declare function updateHyperliquidIsolatedMargin(options: {
209
+ wallet: WalletFullContext;
210
+ input: UpdateIsolatedMarginInput;
211
+ } & CommonActionOptions): Promise<HyperliquidExchangeResponse<unknown>>;
212
+ declare function reserveHyperliquidRequestWeight(options: {
213
+ wallet: WalletFullContext;
214
+ weight: number;
215
+ } & CommonActionOptions): Promise<HyperliquidExchangeResponse<unknown>>;
216
+ declare function createHyperliquidSubAccount(options: {
217
+ wallet: WalletFullContext;
218
+ name: string;
219
+ } & CommonActionOptions): Promise<HyperliquidExchangeResponse<unknown>>;
220
+ declare function transferHyperliquidSubAccount(options: {
221
+ wallet: WalletFullContext;
222
+ subAccountUser: `0x${string}`;
223
+ isDeposit: boolean;
224
+ usd: string | number | bigint;
225
+ } & CommonActionOptions): Promise<HyperliquidExchangeResponse<unknown>>;
226
+ declare function sendHyperliquidSpot(options: {
227
+ wallet: WalletFullContext;
228
+ destination: `0x${string}`;
229
+ token: string;
230
+ amount: string | number | bigint;
231
+ environment?: HyperliquidEnvironment;
232
+ nonce?: number;
233
+ nonceSource?: NonceSource;
234
+ }): Promise<HyperliquidExchangeResponse<unknown>>;
235
+
236
+ declare class HyperliquidInfoClient {
237
+ private readonly environment;
238
+ constructor(environment?: HyperliquidEnvironment);
239
+ meta(): Promise<any>;
240
+ metaAndAssetCtxs(): Promise<any>;
241
+ spotMeta(): Promise<any>;
242
+ spotMetaAndAssetCtxs(): Promise<any>;
243
+ assetCtxs(): Promise<any>;
244
+ spotAssetCtxs(): Promise<any>;
245
+ openOrders(user: `0x${string}`): Promise<any>;
246
+ frontendOpenOrders(user: `0x${string}`): Promise<any>;
247
+ orderStatus(user: `0x${string}`, oid: number | string): Promise<any>;
248
+ historicalOrders(user: `0x${string}`): Promise<any>;
249
+ userFills(user: `0x${string}`): Promise<any>;
250
+ userFillsByTime(user: `0x${string}`, startTime: number, endTime: number): Promise<any>;
251
+ userRateLimit(user: `0x${string}`): Promise<any>;
252
+ preTransferCheck(user: `0x${string}`, source: `0x${string}`): Promise<any>;
253
+ spotClearinghouseState(user: `0x${string}`): Promise<any>;
254
+ }
255
+ declare function fetchHyperliquidMeta(environment?: HyperliquidEnvironment): Promise<any>;
256
+ declare function fetchHyperliquidMetaAndAssetCtxs(environment?: HyperliquidEnvironment): Promise<any>;
257
+ declare function fetchHyperliquidSpotMeta(environment?: HyperliquidEnvironment): Promise<any>;
258
+ declare function fetchHyperliquidSpotMetaAndAssetCtxs(environment?: HyperliquidEnvironment): Promise<any>;
259
+ declare function fetchHyperliquidAssetCtxs(environment?: HyperliquidEnvironment): Promise<any>;
260
+ declare function fetchHyperliquidSpotAssetCtxs(environment?: HyperliquidEnvironment): Promise<any>;
261
+ declare function fetchHyperliquidOpenOrders(params: {
262
+ environment?: HyperliquidEnvironment;
263
+ user: `0x${string}`;
264
+ }): Promise<any>;
265
+ declare function fetchHyperliquidFrontendOpenOrders(params: {
266
+ environment?: HyperliquidEnvironment;
267
+ user: `0x${string}`;
268
+ }): Promise<any>;
269
+ declare function fetchHyperliquidOrderStatus(params: {
270
+ environment?: HyperliquidEnvironment;
271
+ user: `0x${string}`;
272
+ oid: number | string;
273
+ }): Promise<any>;
274
+ declare function fetchHyperliquidHistoricalOrders(params: {
275
+ environment?: HyperliquidEnvironment;
276
+ user: `0x${string}`;
277
+ }): Promise<any>;
278
+ declare function fetchHyperliquidUserFills(params: {
279
+ environment?: HyperliquidEnvironment;
280
+ user: `0x${string}`;
281
+ }): Promise<any>;
282
+ declare function fetchHyperliquidUserFillsByTime(params: {
283
+ environment?: HyperliquidEnvironment;
284
+ user: `0x${string}`;
285
+ startTime: number;
286
+ endTime: number;
287
+ }): Promise<any>;
288
+ declare function fetchHyperliquidUserRateLimit(params: {
289
+ environment?: HyperliquidEnvironment;
290
+ user: `0x${string}`;
291
+ }): Promise<any>;
292
+ declare function fetchHyperliquidPreTransferCheck(params: {
293
+ environment?: HyperliquidEnvironment;
294
+ user: `0x${string}`;
295
+ source: `0x${string}`;
296
+ }): Promise<any>;
297
+ declare function fetchHyperliquidSpotClearinghouseState(params: {
298
+ environment?: HyperliquidEnvironment;
299
+ user: `0x${string}`;
300
+ }): Promise<any>;
301
+
302
+ interface HyperliquidOrderOptions {
303
+ wallet: WalletFullContext;
304
+ orders: HyperliquidOrderIntent[];
305
+ grouping?: HyperliquidGrouping;
306
+ environment?: HyperliquidEnvironment;
307
+ vaultAddress?: `0x${string}`;
308
+ expiresAfter?: number;
309
+ nonce?: number;
310
+ }
311
+ type HyperliquidOrderStatus = {
312
+ resting: {
313
+ oid: number;
314
+ cloid?: `0x${string}`;
315
+ };
316
+ } | {
317
+ filled: {
318
+ totalSz: string;
319
+ avgPx: string;
320
+ oid: number;
321
+ cloid?: `0x${string}`;
322
+ };
323
+ } | {
324
+ error: string;
325
+ };
326
+ interface HyperliquidOrderResponse {
327
+ status: "ok";
328
+ response: {
329
+ type: "order";
330
+ data: {
331
+ statuses: HyperliquidOrderStatus[];
332
+ };
333
+ };
334
+ }
335
+ interface HyperliquidDepositResult {
336
+ txHash: `0x${string}`;
337
+ amount: number;
338
+ amountUnits: string;
339
+ environment: HyperliquidEnvironment;
340
+ bridgeAddress: `0x${string}`;
341
+ }
342
+ interface HyperliquidWithdrawResult {
343
+ amount: number;
344
+ destination: `0x${string}`;
345
+ environment: HyperliquidEnvironment;
346
+ nonce: number;
347
+ status: string;
348
+ }
349
+ interface HyperliquidClearinghouseState {
350
+ ok: boolean;
351
+ data: Record<string, unknown> | null;
352
+ }
353
+ interface HyperliquidApproveBuilderFeeOptions {
354
+ environment: HyperliquidEnvironment;
355
+ wallet: WalletFullContext;
356
+ nonce?: number;
357
+ /** Override default signature chain id. */
358
+ signatureChainId?: string;
359
+ }
360
+ interface HyperliquidApproveBuilderFeeResponse {
361
+ status: string;
362
+ response?: unknown;
363
+ error?: string;
364
+ }
365
+ interface HyperliquidTermsRecordInput {
366
+ environment: HyperliquidEnvironment;
367
+ walletAddress: `0x${string}`;
368
+ storeOptions?: StoreOptions;
369
+ }
370
+ interface HyperliquidBuilderApprovalRecordInput {
371
+ environment: HyperliquidEnvironment;
372
+ walletAddress: `0x${string}`;
373
+ storeOptions?: StoreOptions;
374
+ }
375
+ /**
376
+ * Sign and submit one or more orders to the Hyperliquid exchange endpoint.
377
+ */
378
+ declare function placeHyperliquidOrder(options: HyperliquidOrderOptions): Promise<HyperliquidOrderResponse>;
379
+ declare function depositToHyperliquidBridge(options: {
380
+ environment: HyperliquidEnvironment;
381
+ amount: string;
382
+ wallet: WalletFullContext;
383
+ }): Promise<HyperliquidDepositResult>;
384
+ declare function withdrawFromHyperliquid(options: {
385
+ environment: HyperliquidEnvironment;
386
+ amount: string;
387
+ destination: `0x${string}`;
388
+ wallet: WalletFullContext;
389
+ }): Promise<HyperliquidWithdrawResult>;
390
+ declare function fetchHyperliquidClearinghouseState(params: {
391
+ environment: HyperliquidEnvironment;
392
+ walletAddress: `0x${string}`;
393
+ }): Promise<HyperliquidClearinghouseState>;
394
+ /**
395
+ * Approve a max builder fee for a specific builder address (user-signed action).
396
+ */
397
+ declare function approveHyperliquidBuilderFee(options: HyperliquidApproveBuilderFeeOptions): Promise<HyperliquidApproveBuilderFeeResponse>;
398
+ /**
399
+ * Query max builder fee for a user/builder pair.
400
+ */
401
+ declare function getHyperliquidMaxBuilderFee(params: {
402
+ environment: HyperliquidEnvironment;
403
+ user: `0x${string}`;
404
+ }): Promise<unknown>;
405
+ declare function recordHyperliquidTermsAcceptance(input: HyperliquidTermsRecordInput): Promise<StoreResponse>;
406
+ declare function recordHyperliquidBuilderApproval(input: HyperliquidBuilderApprovalRecordInput): Promise<StoreResponse>;
407
+
408
+ declare const __hyperliquidInternals: {
409
+ toApiDecimal: typeof toApiDecimal;
410
+ createL1ActionHash: typeof createL1ActionHash;
411
+ splitSignature: typeof splitSignature;
412
+ };
413
+
414
+ export { HyperliquidApiError, type HyperliquidApproveBuilderFeeOptions, type HyperliquidApproveBuilderFeeResponse, HyperliquidBuilderApprovalError, type HyperliquidBuilderApprovalRecordInput, type HyperliquidBuilderFee, type HyperliquidClearinghouseState, type HyperliquidDepositResult, type HyperliquidEnvironment, HyperliquidExchangeClient, type HyperliquidExchangeResponse, type HyperliquidGrouping, HyperliquidGuardError, HyperliquidInfoClient, type HyperliquidOrderIntent, type HyperliquidOrderOptions, type HyperliquidOrderResponse, type HyperliquidOrderStatus, HyperliquidTermsError, type HyperliquidTermsRecordInput, type HyperliquidTriggerOptions, type HyperliquidTriggerType, type HyperliquidWithdrawResult, type NonceSource, __hyperliquidInternals, approveHyperliquidBuilderFee, batchModifyHyperliquidOrders, cancelAllHyperliquidOrders, cancelHyperliquidOrders, cancelHyperliquidOrdersByCloid, cancelHyperliquidTwapOrder, createHyperliquidSubAccount, createMonotonicNonceFactory, depositToHyperliquidBridge, fetchHyperliquidAssetCtxs, fetchHyperliquidClearinghouseState, fetchHyperliquidFrontendOpenOrders, fetchHyperliquidHistoricalOrders, fetchHyperliquidMeta, fetchHyperliquidMetaAndAssetCtxs, fetchHyperliquidOpenOrders, fetchHyperliquidOrderStatus, fetchHyperliquidPreTransferCheck, fetchHyperliquidSpotAssetCtxs, fetchHyperliquidSpotClearinghouseState, fetchHyperliquidSpotMeta, fetchHyperliquidSpotMetaAndAssetCtxs, fetchHyperliquidUserFills, fetchHyperliquidUserFillsByTime, fetchHyperliquidUserRateLimit, getHyperliquidMaxBuilderFee, modifyHyperliquidOrder, placeHyperliquidOrder, placeHyperliquidTwapOrder, recordHyperliquidBuilderApproval, recordHyperliquidTermsAcceptance, reserveHyperliquidRequestWeight, scheduleHyperliquidCancel, sendHyperliquidSpot, transferHyperliquidSubAccount, updateHyperliquidIsolatedMargin, updateHyperliquidLeverage, withdrawFromHyperliquid };