@pear-protocol/hyperliquid-sdk 0.0.72 → 0.0.73-beta-1
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/dist/clients/hyperliquid.d.ts +1 -1
- package/dist/clients/orders.d.ts +41 -0
- package/dist/clients/positions.d.ts +14 -22
- package/dist/clients/watchlist.d.ts +1 -1
- package/dist/hooks/index.d.ts +3 -1
- package/dist/hooks/useAllUserBalances.d.ts +9 -0
- package/dist/hooks/useAuth.d.ts +3 -3
- package/dist/hooks/useHyperliquidUserFills.d.ts +17 -0
- package/dist/hooks/useMarketData.d.ts +9 -7
- package/dist/hooks/useSpotOrder.d.ts +13 -0
- package/dist/hooks/useTrading.d.ts +0 -3
- package/dist/hooks/useWebData.d.ts +21 -3
- package/dist/hyperliquid-websocket.d.ts +2 -1
- package/dist/index.d.ts +399 -94
- package/dist/index.js +1609 -353
- package/dist/provider.d.ts +1 -1
- package/dist/store/historicalPriceDataStore.d.ts +12 -1
- package/dist/store/hyperliquidDataStore.d.ts +31 -1
- package/dist/store/marketDataStore.d.ts +10 -1
- package/dist/store/tokenSelectionMetadataStore.d.ts +1 -1
- package/dist/store/userDataStore.d.ts +30 -1
- package/dist/store/userSelection.d.ts +1 -1
- package/dist/types.d.ts +144 -30
- package/dist/utils/order-helpers.d.ts +57 -0
- package/dist/utils/symbol-translator.d.ts +32 -3
- package/dist/utils/token-metadata-extractor.d.ts +9 -5
- package/package.json +3 -2
- package/dist/hooks/useAutoSyncFills.d.ts +0 -19
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
+
import * as zustand from 'zustand';
|
|
2
3
|
|
|
3
4
|
interface PearHyperliquidContextType {
|
|
4
5
|
clientId: string;
|
|
@@ -47,7 +48,7 @@ interface ExternalFillDto {
|
|
|
47
48
|
coin: string;
|
|
48
49
|
px: string;
|
|
49
50
|
sz: string;
|
|
50
|
-
side:
|
|
51
|
+
side: 'B' | 'A';
|
|
51
52
|
time: number;
|
|
52
53
|
dir: string;
|
|
53
54
|
fee: string;
|
|
@@ -74,16 +75,16 @@ interface TwapSliceFillResponseItem {
|
|
|
74
75
|
/**
|
|
75
76
|
* WebSocket connection states
|
|
76
77
|
*/
|
|
77
|
-
type WebSocketConnectionState =
|
|
78
|
+
type WebSocketConnectionState = 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
78
79
|
/**
|
|
79
80
|
* WebSocket channels
|
|
80
81
|
*/
|
|
81
|
-
type WebSocketChannel =
|
|
82
|
+
type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'twap-details' | 'notifications' | 'market-data' | 'market-data-all' | 'webData3' | 'allMids' | 'activeAssetData';
|
|
82
83
|
/**
|
|
83
84
|
* WebSocket subscription message
|
|
84
85
|
*/
|
|
85
86
|
interface WebSocketSubscribeMessage {
|
|
86
|
-
action?:
|
|
87
|
+
action?: 'subscribe' | 'unsubscribe';
|
|
87
88
|
address: string;
|
|
88
89
|
}
|
|
89
90
|
/**
|
|
@@ -113,7 +114,7 @@ interface WatchlistItemDto {
|
|
|
113
114
|
interface ToggleWatchlistResponseDto {
|
|
114
115
|
items: WatchlistItemDto[];
|
|
115
116
|
}
|
|
116
|
-
type NotificationCategory =
|
|
117
|
+
type NotificationCategory = 'TRADE_OPENED_OUTSIDE_PEAR' | 'TRADE_CLOSED_OUTSIDE_PEAR' | 'POSITION_LIQUIDATED' | 'LIMIT_ORDER_FILLED' | 'LIMIT_ORDER_FAILED' | 'TP_ORDER_FILLED' | 'TP_ORDER_FAILED' | 'SL_ORDER_FILLED' | 'SL_ORDER_FAILED';
|
|
117
118
|
interface NotificationDto {
|
|
118
119
|
id: string;
|
|
119
120
|
address: string;
|
|
@@ -130,7 +131,7 @@ interface ChunkFillDto {
|
|
|
130
131
|
size: number;
|
|
131
132
|
executedAt: string;
|
|
132
133
|
}
|
|
133
|
-
type TwapChunkStatus =
|
|
134
|
+
type TwapChunkStatus = 'PENDING' | 'SCHEDULED' | 'EXECUTING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';
|
|
134
135
|
interface TwapChunkStatusDto {
|
|
135
136
|
chunkId: string;
|
|
136
137
|
chunkIndex: number;
|
|
@@ -141,7 +142,7 @@ interface TwapChunkStatusDto {
|
|
|
141
142
|
fills: ChunkFillDto[];
|
|
142
143
|
errorMessage?: string;
|
|
143
144
|
}
|
|
144
|
-
type TwapOrderOverallStatus =
|
|
145
|
+
type TwapOrderOverallStatus = 'OPEN' | 'EXECUTING' | 'COMPLETED' | 'PARTIALLY_COMPLETED' | 'FAILED' | 'CANCELLED';
|
|
145
146
|
interface TwapMonitoringDto {
|
|
146
147
|
orderId: string;
|
|
147
148
|
positionId?: string;
|
|
@@ -178,6 +179,8 @@ interface TradeHistoryAssetDataDto {
|
|
|
178
179
|
externalFeePaid: number;
|
|
179
180
|
builderFeePaid: number;
|
|
180
181
|
realizedPnl: number;
|
|
182
|
+
marketPrefix?: string | null;
|
|
183
|
+
collateralToken?: CollateralToken;
|
|
181
184
|
}
|
|
182
185
|
/**
|
|
183
186
|
* Trade history data structure
|
|
@@ -226,10 +229,15 @@ interface PositionAssetDetailDto {
|
|
|
226
229
|
liquidationPrice: number;
|
|
227
230
|
initialWeight: number;
|
|
228
231
|
fundingPaid?: number;
|
|
232
|
+
marketPrefix?: string | null;
|
|
233
|
+
collateralToken?: CollateralToken;
|
|
229
234
|
}
|
|
230
235
|
interface TpSlThreshold {
|
|
231
|
-
type:
|
|
236
|
+
type: 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE' | 'PRICE' | 'PRICE_RATIO' | 'WEIGHTED_RATIO';
|
|
232
237
|
value: number;
|
|
238
|
+
isTrailing?: boolean;
|
|
239
|
+
trailingDeltaValue?: number;
|
|
240
|
+
trailingActivationValue?: number;
|
|
233
241
|
}
|
|
234
242
|
/**
|
|
235
243
|
* Open position data structure
|
|
@@ -259,38 +267,96 @@ interface OpenPositionDto {
|
|
|
259
267
|
interface OrderAssetDto {
|
|
260
268
|
asset: string;
|
|
261
269
|
weight: number;
|
|
270
|
+
marketPrefix?: string | null;
|
|
271
|
+
collateralToken?: CollateralToken;
|
|
262
272
|
}
|
|
263
273
|
/**
|
|
264
274
|
* Order status
|
|
265
275
|
*/
|
|
266
|
-
type OrderStatus =
|
|
276
|
+
type OrderStatus = 'OPEN' | 'PROCESSING' | 'EXECUTED' | 'CANCELLED' | 'FAILED' | 'PARTIALLY_FILLED';
|
|
267
277
|
/**
|
|
268
278
|
* Order type
|
|
269
279
|
*/
|
|
270
|
-
type OrderType =
|
|
280
|
+
type OrderType = 'SYNC' | 'MARKET' | 'TRIGGER' | 'TWAP' | 'LADDER' | 'TP' | 'SL' | 'SPOT_MARKET' | 'SPOT_LIMIT' | 'SPOT_TWAP';
|
|
271
281
|
/**
|
|
272
282
|
* TP/SL trigger type
|
|
273
283
|
*/
|
|
274
|
-
type TpSlTriggerType =
|
|
275
|
-
|
|
284
|
+
type TpSlTriggerType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE' | 'PRICE' | 'PRICE_RATIO' | 'WEIGHTED_RATIO';
|
|
285
|
+
/**
|
|
286
|
+
* Trigger type for trigger orders
|
|
287
|
+
*/
|
|
288
|
+
type TriggerType$1 = 'PRICE' | 'PRICE_RATIO' | 'WEIGHTED_RATIO' | 'BTC_DOM' | 'CROSS_ASSET_PRICE' | 'PREDICTION_MARKET_OUTCOME';
|
|
289
|
+
type OrderDirection = 'MORE_THAN' | 'LESS_THAN';
|
|
290
|
+
/**
|
|
291
|
+
* Market order parameters
|
|
292
|
+
*/
|
|
293
|
+
interface MarketOrderParameters {
|
|
294
|
+
leverage?: number;
|
|
295
|
+
usdValue: number;
|
|
296
|
+
reduceOnly?: boolean;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Trigger order parameters
|
|
300
|
+
*/
|
|
301
|
+
interface TriggerOrderParameters {
|
|
302
|
+
leverage: number;
|
|
303
|
+
usdValue: number;
|
|
304
|
+
triggerType: TriggerType$1;
|
|
305
|
+
triggerValue: number;
|
|
306
|
+
direction: OrderDirection;
|
|
307
|
+
reduceOnly?: boolean;
|
|
308
|
+
assetName?: string;
|
|
309
|
+
marketCode?: string;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* TWAP order parameters
|
|
313
|
+
*/
|
|
314
|
+
interface TwapOrderParameters {
|
|
315
|
+
leverage: number;
|
|
316
|
+
usdValue: number;
|
|
317
|
+
duration: string;
|
|
318
|
+
intervalSeconds?: number;
|
|
319
|
+
chunkUsdValue: number;
|
|
320
|
+
randomizeExecution?: boolean;
|
|
321
|
+
reduceOnly?: boolean;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* TP/SL order parameters
|
|
325
|
+
*/
|
|
326
|
+
interface TpSlOrderParameters {
|
|
327
|
+
triggerType: TpSlTriggerType;
|
|
328
|
+
triggerValue: number;
|
|
329
|
+
isTrailing?: boolean;
|
|
330
|
+
trailingDeltaValue?: number;
|
|
331
|
+
trailingActivationValue?: number;
|
|
332
|
+
reduceOnly?: boolean;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Ladder order parameters
|
|
336
|
+
*/
|
|
337
|
+
interface LadderOrderParameters {
|
|
338
|
+
leverage: number;
|
|
339
|
+
usdValue: number;
|
|
340
|
+
ratioStart: number;
|
|
341
|
+
ratioEnd: number;
|
|
342
|
+
numberOfLevels: number;
|
|
343
|
+
reduceOnly?: boolean;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Union type for all order parameters
|
|
347
|
+
*/
|
|
348
|
+
type OrderParameters = MarketOrderParameters | TriggerOrderParameters | TwapOrderParameters | TpSlOrderParameters | LadderOrderParameters;
|
|
276
349
|
/**
|
|
277
350
|
* Open limit order data structure
|
|
278
351
|
*/
|
|
279
352
|
interface OpenLimitOrderDto {
|
|
280
353
|
orderId: string;
|
|
281
354
|
address: string;
|
|
282
|
-
clientId
|
|
355
|
+
clientId?: string | null;
|
|
283
356
|
positionId?: string | null;
|
|
284
|
-
|
|
285
|
-
usdValue: number;
|
|
286
|
-
triggerValue?: number | null;
|
|
287
|
-
twapDuration?: string | null;
|
|
288
|
-
tpSlTriggerType?: TpSlTriggerType | null;
|
|
289
|
-
randomizeFlag: boolean;
|
|
290
|
-
reduceOnlyFlag: boolean;
|
|
291
|
-
status: OrderStatus;
|
|
357
|
+
parameters: OrderParameters;
|
|
292
358
|
orderType: OrderType;
|
|
293
|
-
|
|
359
|
+
status: OrderStatus;
|
|
294
360
|
longAssets: OrderAssetDto[];
|
|
295
361
|
shortAssets: OrderAssetDto[];
|
|
296
362
|
createdAt: string;
|
|
@@ -378,7 +444,7 @@ interface RefreshTokenResponse {
|
|
|
378
444
|
tokenType: string;
|
|
379
445
|
expiresIn: number;
|
|
380
446
|
}
|
|
381
|
-
type AgentWalletStatus =
|
|
447
|
+
type AgentWalletStatus = 'ACTIVE' | 'EXPIRED' | 'NOT_FOUND';
|
|
382
448
|
interface CreateAgentWalletResponseDto {
|
|
383
449
|
agentWalletAddress: string;
|
|
384
450
|
message: string;
|
|
@@ -391,14 +457,14 @@ interface ExtraAgent {
|
|
|
391
457
|
interface AgentWalletState {
|
|
392
458
|
address: string | null;
|
|
393
459
|
name: string | null;
|
|
394
|
-
status: AgentWalletStatus |
|
|
460
|
+
status: AgentWalletStatus | 'PENDING' | null;
|
|
395
461
|
isActive: boolean;
|
|
396
462
|
}
|
|
397
463
|
/**
|
|
398
464
|
* WebSocket message from HyperLiquid native API
|
|
399
465
|
*/
|
|
400
466
|
interface WebSocketMessage {
|
|
401
|
-
method:
|
|
467
|
+
method: 'subscribe' | 'unsubscribe';
|
|
402
468
|
subscription: {
|
|
403
469
|
type: string;
|
|
404
470
|
dex?: string;
|
|
@@ -411,14 +477,19 @@ interface WebSocketMessage {
|
|
|
411
477
|
/**
|
|
412
478
|
* WebSocket response from HyperLiquid native API
|
|
413
479
|
*/
|
|
414
|
-
type HLChannel =
|
|
480
|
+
type HLChannel = 'webData3' | 'allMids' | 'activeAssetData' | 'candle' | 'spotState' | 'allDexsClearinghouseState' | 'allDexsAssetCtxs' | 'userFills';
|
|
415
481
|
interface HLChannelDataMap {
|
|
416
482
|
webData3: WebData3Response;
|
|
417
483
|
allMids: WsAllMidsData;
|
|
418
484
|
activeAssetData: ActiveAssetData;
|
|
419
485
|
candle: CandleData;
|
|
486
|
+
spotState: {
|
|
487
|
+
user: string;
|
|
488
|
+
spotState: SpotState;
|
|
489
|
+
};
|
|
420
490
|
allDexsClearinghouseState: AllDexsClearinghouseStateData;
|
|
421
491
|
allDexsAssetCtxs: AllDexsAssetCtxsData;
|
|
492
|
+
userFills: any;
|
|
422
493
|
}
|
|
423
494
|
interface WebData3UserState {
|
|
424
495
|
agentAddress?: string;
|
|
@@ -481,6 +552,12 @@ interface AssetCtx {
|
|
|
481
552
|
impactPxs?: string[];
|
|
482
553
|
oraclePx: string;
|
|
483
554
|
}
|
|
555
|
+
/**
|
|
556
|
+
* Collateral token type
|
|
557
|
+
* 0 = USDC
|
|
558
|
+
* 360 = USDH
|
|
559
|
+
*/
|
|
560
|
+
type CollateralToken = 'USDC' | 'USDH';
|
|
484
561
|
/**
|
|
485
562
|
* Universe asset metadata
|
|
486
563
|
*/
|
|
@@ -490,6 +567,8 @@ interface UniverseAsset {
|
|
|
490
567
|
maxLeverage: number;
|
|
491
568
|
onlyIsolated?: boolean;
|
|
492
569
|
isDelisted?: boolean;
|
|
570
|
+
marketPrefix?: string;
|
|
571
|
+
collateralToken?: CollateralToken;
|
|
493
572
|
}
|
|
494
573
|
interface ClearinghouseState {
|
|
495
574
|
assetPositions: AssetPosition[];
|
|
@@ -560,6 +639,8 @@ interface RawAssetDto {
|
|
|
560
639
|
size: number;
|
|
561
640
|
side: string;
|
|
562
641
|
fundingPaid?: number;
|
|
642
|
+
marketPrefix?: string | null;
|
|
643
|
+
collateralToken?: CollateralToken;
|
|
563
644
|
leverage: number;
|
|
564
645
|
}
|
|
565
646
|
/**
|
|
@@ -608,6 +689,7 @@ interface TokenMetadata {
|
|
|
608
689
|
leverage?: LeverageInfo;
|
|
609
690
|
maxTradeSzs?: [string, string];
|
|
610
691
|
availableToTrade?: [string, string];
|
|
692
|
+
collateralToken?: CollateralToken;
|
|
611
693
|
}
|
|
612
694
|
/**
|
|
613
695
|
* Enhanced token selection with weight and metadata for basket trading
|
|
@@ -621,16 +703,37 @@ interface TokenSelection {
|
|
|
621
703
|
*/
|
|
622
704
|
interface TokenConflict {
|
|
623
705
|
symbol: string;
|
|
624
|
-
conflictType:
|
|
706
|
+
conflictType: 'long' | 'short';
|
|
625
707
|
conflictMessage: string;
|
|
626
708
|
}
|
|
627
709
|
interface AssetMarketData {
|
|
628
710
|
asset: WebData3AssetCtx | AssetCtx;
|
|
629
711
|
universe: UniverseAsset;
|
|
630
712
|
}
|
|
713
|
+
/**
|
|
714
|
+
* Nested market data structure for multi-market assets.
|
|
715
|
+
* Each symbol maps to its market variants (keyed by prefix).
|
|
716
|
+
* For non-HIP3 assets, use "default" as the key.
|
|
717
|
+
*
|
|
718
|
+
* @example
|
|
719
|
+
* ```ts
|
|
720
|
+
* {
|
|
721
|
+
* "TSLA": {
|
|
722
|
+
* "xyz": { asset: {...}, universe: { collateralToken: "USDC", ... } },
|
|
723
|
+
* "flx": { asset: {...}, universe: { collateralToken: "USDH", ... } }
|
|
724
|
+
* },
|
|
725
|
+
* "BTC": {
|
|
726
|
+
* "default": { asset: {...}, universe: {...} }
|
|
727
|
+
* }
|
|
728
|
+
* }
|
|
729
|
+
* ```
|
|
730
|
+
*/
|
|
731
|
+
type MarketDataBySymbol = Record<string, Record<string, AssetMarketData>>;
|
|
631
732
|
interface PairAssetDto {
|
|
632
733
|
asset: string;
|
|
633
734
|
weight: number;
|
|
735
|
+
collateralToken: CollateralToken;
|
|
736
|
+
marketPrefix: string | null;
|
|
634
737
|
}
|
|
635
738
|
interface ActiveAssetGroupItem {
|
|
636
739
|
longAssets: PairAssetDto[];
|
|
@@ -644,6 +747,7 @@ interface ActiveAssetGroupItem {
|
|
|
644
747
|
weightedRatio?: string;
|
|
645
748
|
weightedPrevRatio?: string;
|
|
646
749
|
weightedChange24h?: string;
|
|
750
|
+
collateralType: 'USDC' | 'USDH' | 'MIXED';
|
|
647
751
|
}
|
|
648
752
|
interface ActiveAssetsResponse {
|
|
649
753
|
active: ActiveAssetGroupItem[];
|
|
@@ -661,7 +765,7 @@ interface ActiveAssetsAllResponse {
|
|
|
661
765
|
/**
|
|
662
766
|
* Candle interval options
|
|
663
767
|
*/
|
|
664
|
-
type CandleInterval =
|
|
768
|
+
type CandleInterval = '1m' | '3m' | '5m' | '15m' | '30m' | '1h' | '2h' | '4h' | '8h' | '12h' | '1d' | '3d' | '1w' | '1M';
|
|
665
769
|
/**
|
|
666
770
|
* Candle data structure from WebSocket
|
|
667
771
|
*/
|
|
@@ -689,12 +793,23 @@ interface CandleSnapshotRequest {
|
|
|
689
793
|
endTime: number;
|
|
690
794
|
interval: CandleInterval;
|
|
691
795
|
};
|
|
692
|
-
type:
|
|
796
|
+
type: 'candleSnapshot';
|
|
693
797
|
}
|
|
694
798
|
interface TokenSelectorConfig {
|
|
695
799
|
isLong: boolean;
|
|
696
800
|
index: number;
|
|
697
801
|
}
|
|
802
|
+
interface SpotBalance {
|
|
803
|
+
coin: string;
|
|
804
|
+
token: number;
|
|
805
|
+
total: string;
|
|
806
|
+
hold: string;
|
|
807
|
+
entryNtl: string;
|
|
808
|
+
}
|
|
809
|
+
interface SpotState {
|
|
810
|
+
user: string;
|
|
811
|
+
balances: SpotBalance[];
|
|
812
|
+
}
|
|
698
813
|
|
|
699
814
|
declare const useAccountSummary: () => {
|
|
700
815
|
data: AccountSummaryResponseDto | null;
|
|
@@ -705,9 +820,6 @@ declare const useTradeHistories: () => {
|
|
|
705
820
|
data: TradeHistoryDataDto[] | null;
|
|
706
821
|
isLoading: boolean;
|
|
707
822
|
};
|
|
708
|
-
/**
|
|
709
|
-
* Hook to access open orders with loading state
|
|
710
|
-
*/
|
|
711
823
|
declare const useOpenOrders: () => {
|
|
712
824
|
data: OpenLimitOrderDto[] | null;
|
|
713
825
|
isLoading: boolean;
|
|
@@ -746,8 +858,26 @@ declare const useUserSelection: () => UserSelectionState;
|
|
|
746
858
|
declare const useWebData: () => {
|
|
747
859
|
clearinghouseState: ClearinghouseState | null;
|
|
748
860
|
perpsAtOpenInterestCap: string[] | null;
|
|
749
|
-
|
|
750
|
-
|
|
861
|
+
/**
|
|
862
|
+
* Market data keyed by symbol, with nested market variants.
|
|
863
|
+
* Each symbol maps to its market variants (keyed by prefix).
|
|
864
|
+
* For non-HIP3 assets, use "default" as the key.
|
|
865
|
+
*
|
|
866
|
+
* @example
|
|
867
|
+
* ```ts
|
|
868
|
+
* // HIP-3 asset with multiple markets
|
|
869
|
+
* marketDataBySymbol["TSLA"]["xyz"] // { asset, universe: { collateralToken: "USDC" } }
|
|
870
|
+
* marketDataBySymbol["TSLA"]["flx"] // { asset, universe: { collateralToken: "USDH" } }
|
|
871
|
+
*
|
|
872
|
+
* // Regular asset
|
|
873
|
+
* marketDataBySymbol["BTC"]["default"] // { asset, universe }
|
|
874
|
+
* ```
|
|
875
|
+
*/
|
|
876
|
+
marketDataBySymbol: MarketDataBySymbol;
|
|
877
|
+
/** Map of display name -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"]) */
|
|
878
|
+
hip3Assets: Map<string, string[]>;
|
|
879
|
+
/** Map of full market name -> prefix (e.g., "xyz:TSLA" -> "xyz") */
|
|
880
|
+
hip3MarketPrefixes: Map<string, string>;
|
|
751
881
|
isConnected: boolean;
|
|
752
882
|
error: string | null;
|
|
753
883
|
};
|
|
@@ -781,7 +911,18 @@ interface TokenHistoricalPriceData {
|
|
|
781
911
|
oldestTime: number | null;
|
|
782
912
|
latestTime: number | null;
|
|
783
913
|
}
|
|
784
|
-
|
|
914
|
+
interface HistoricalPriceDataState {
|
|
915
|
+
historicalPriceData: Record<string, TokenHistoricalPriceData>;
|
|
916
|
+
loadingTokens: Set<string>;
|
|
917
|
+
addHistoricalPriceData: (symbol: string, interval: CandleInterval, candles: CandleData[], range: HistoricalRange) => void;
|
|
918
|
+
hasHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => boolean;
|
|
919
|
+
getHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => CandleData[];
|
|
920
|
+
setTokenLoading: (symbol: string, loading: boolean) => void;
|
|
921
|
+
isTokenLoading: (symbol: string) => boolean;
|
|
922
|
+
removeTokenPriceData: (symbol: string, interval: CandleInterval) => void;
|
|
923
|
+
clearData: () => void;
|
|
924
|
+
}
|
|
925
|
+
declare const useHistoricalPriceDataStore: zustand.UseBoundStore<zustand.StoreApi<HistoricalPriceDataState>>;
|
|
785
926
|
|
|
786
927
|
interface UseHistoricalPriceDataReturn {
|
|
787
928
|
fetchHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval, callback?: (data: Record<string, CandleData[]>) => void) => Promise<Record<string, CandleData[]>>;
|
|
@@ -839,25 +980,6 @@ declare function useAgentWallet(): {
|
|
|
839
980
|
readonly notifyAgentWalletApproved: () => Promise<void>;
|
|
840
981
|
};
|
|
841
982
|
|
|
842
|
-
interface AutoSyncFillsOptions {
|
|
843
|
-
baseUrl: string;
|
|
844
|
-
address: string | null;
|
|
845
|
-
intervalMs?: number;
|
|
846
|
-
aggregateByTime?: boolean;
|
|
847
|
-
}
|
|
848
|
-
interface AutoSyncFillsState {
|
|
849
|
-
lastRunAt: number | null;
|
|
850
|
-
lastResult: SyncFillsResponseDto | null;
|
|
851
|
-
error: string | null;
|
|
852
|
-
isSyncing: boolean;
|
|
853
|
-
triggerSync: () => Promise<void>;
|
|
854
|
-
}
|
|
855
|
-
/**
|
|
856
|
-
* Listens to address changes and periodically syncs user fills
|
|
857
|
-
* Defaults: aggregate=true, interval=60s
|
|
858
|
-
*/
|
|
859
|
-
declare function useAutoSyncFills(options: AutoSyncFillsOptions): AutoSyncFillsState;
|
|
860
|
-
|
|
861
983
|
interface AdjustOrderRequestInput {
|
|
862
984
|
limitRatio?: number;
|
|
863
985
|
usdValue?: number;
|
|
@@ -881,9 +1003,51 @@ interface CancelTwapResponseDto {
|
|
|
881
1003
|
cancelledAt: string;
|
|
882
1004
|
}
|
|
883
1005
|
declare function cancelTwapOrder(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
1006
|
+
interface SpotOrderRequestInput {
|
|
1007
|
+
/** Asset to buy/sell (e.g., "USDH") */
|
|
1008
|
+
asset: string;
|
|
1009
|
+
/** Whether to buy (true) or sell (false) the asset */
|
|
1010
|
+
isBuy: boolean;
|
|
1011
|
+
/** Amount of asset to buy/sell (minimum: 11) */
|
|
1012
|
+
amount: number;
|
|
1013
|
+
}
|
|
1014
|
+
/** Filled order status from Hyperliquid */
|
|
1015
|
+
interface SpotOrderFilledStatus {
|
|
1016
|
+
filled: {
|
|
1017
|
+
totalSz: string;
|
|
1018
|
+
avgPx: string;
|
|
1019
|
+
oid: number;
|
|
1020
|
+
cloid: string;
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
/** Hyperliquid order response data */
|
|
1024
|
+
interface SpotOrderHyperliquidData {
|
|
1025
|
+
statuses: SpotOrderFilledStatus[];
|
|
1026
|
+
}
|
|
1027
|
+
/** Hyperliquid result from spot order execution */
|
|
1028
|
+
interface SpotOrderHyperliquidResult {
|
|
1029
|
+
status: 'ok' | 'error';
|
|
1030
|
+
response: {
|
|
1031
|
+
type: 'order';
|
|
1032
|
+
data: SpotOrderHyperliquidData;
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
interface SpotOrderResponseDto {
|
|
1036
|
+
orderId: string;
|
|
1037
|
+
status: 'EXECUTED' | 'FAILED' | 'PENDING';
|
|
1038
|
+
asset: string;
|
|
1039
|
+
createdAt: string;
|
|
1040
|
+
hyperliquidResult?: SpotOrderHyperliquidResult;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Execute a spot order (swap) using Pear Hyperliquid service
|
|
1044
|
+
* POST /orders/spot
|
|
1045
|
+
*/
|
|
1046
|
+
declare function executeSpotOrder(baseUrl: string, payload: SpotOrderRequestInput): Promise<ApiResponse<SpotOrderResponseDto>>;
|
|
884
1047
|
|
|
885
|
-
type ExecutionType = "MARKET" | "
|
|
886
|
-
type
|
|
1048
|
+
type ExecutionType = "MARKET" | "TRIGGER" | "TWAP" | "LADDER" | "TP" | "SL" | "SPOT_MARKET" | "SPOT_LIMIT" | "SPOT_TWAP";
|
|
1049
|
+
type TriggerType = "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO" | "BTC_DOM" | "CROSS_ASSET_PRICE" | "PREDICTION_MARKET_OUTCOME";
|
|
1050
|
+
type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE" | "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO";
|
|
887
1051
|
interface PairAssetInput {
|
|
888
1052
|
asset: string;
|
|
889
1053
|
weight?: number;
|
|
@@ -891,6 +1055,9 @@ interface PairAssetInput {
|
|
|
891
1055
|
interface TpSlThresholdInput {
|
|
892
1056
|
type: TpSlThresholdType;
|
|
893
1057
|
value: number;
|
|
1058
|
+
isTrailing?: boolean;
|
|
1059
|
+
trailingDeltaValue?: number;
|
|
1060
|
+
trailingActivationValue?: number;
|
|
894
1061
|
}
|
|
895
1062
|
interface LadderConfigInput {
|
|
896
1063
|
ratioStart: number;
|
|
@@ -904,8 +1071,11 @@ interface CreatePositionRequestInput {
|
|
|
904
1071
|
usdValue: number;
|
|
905
1072
|
longAssets?: PairAssetInput[];
|
|
906
1073
|
shortAssets?: PairAssetInput[];
|
|
907
|
-
triggerValue?: number;
|
|
1074
|
+
triggerValue?: string | number;
|
|
1075
|
+
triggerType?: TriggerType;
|
|
908
1076
|
direction?: "MORE_THAN" | "LESS_THAN";
|
|
1077
|
+
assetName?: string;
|
|
1078
|
+
marketCode?: string;
|
|
909
1079
|
twapDuration?: number;
|
|
910
1080
|
twapIntervalSeconds?: number;
|
|
911
1081
|
randomizeExecution?: boolean;
|
|
@@ -914,24 +1084,9 @@ interface CreatePositionRequestInput {
|
|
|
914
1084
|
takeProfit?: TpSlThresholdInput | null;
|
|
915
1085
|
stopLoss?: TpSlThresholdInput | null;
|
|
916
1086
|
}
|
|
917
|
-
type PositionResponseStatus = "SUCCESS" | "FAILED" | "PENDING" | "PARTIALLY_FILLED" | "OPEN";
|
|
918
|
-
interface PositionAssetSummaryDto {
|
|
919
|
-
asset: string;
|
|
920
|
-
side: "LONG" | "SHORT";
|
|
921
|
-
size: number;
|
|
922
|
-
entryRatio: number;
|
|
923
|
-
usdValue: number;
|
|
924
|
-
orderId: string;
|
|
925
|
-
}
|
|
926
1087
|
interface CreatePositionResponseDto {
|
|
927
|
-
positionId: string | null;
|
|
928
1088
|
orderId: string;
|
|
929
|
-
|
|
930
|
-
createdAt: string;
|
|
931
|
-
assets?: PositionAssetSummaryDto[];
|
|
932
|
-
stopLoss?: TpSlThresholdInput | null;
|
|
933
|
-
takeProfit?: TpSlThresholdInput | null;
|
|
934
|
-
hyperliquidResult?: any;
|
|
1089
|
+
fills?: ExternalFillDto[];
|
|
935
1090
|
}
|
|
936
1091
|
/**
|
|
937
1092
|
* Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
|
|
@@ -939,7 +1094,7 @@ interface CreatePositionResponseDto {
|
|
|
939
1094
|
* @throws MinimumPositionSizeError if any asset has less than $11 USD value
|
|
940
1095
|
* @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets (15)
|
|
941
1096
|
*/
|
|
942
|
-
declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput,
|
|
1097
|
+
declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput, hip3Assets: Map<string, string[]>): Promise<ApiResponse<CreatePositionResponseDto>>;
|
|
943
1098
|
interface UpdateRiskParametersRequestInput {
|
|
944
1099
|
stopLoss?: TpSlThresholdInput | null;
|
|
945
1100
|
takeProfit?: TpSlThresholdInput | null;
|
|
@@ -1006,7 +1161,7 @@ interface AdjustAdvanceResponseDto {
|
|
|
1006
1161
|
status: string;
|
|
1007
1162
|
executedAt: string;
|
|
1008
1163
|
}
|
|
1009
|
-
declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[],
|
|
1164
|
+
declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[], hip3Assets: Map<string, string[]>): Promise<ApiResponse<AdjustAdvanceResponseDto>>;
|
|
1010
1165
|
declare function cancelTwap(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
1011
1166
|
interface UpdateLeverageRequestInput {
|
|
1012
1167
|
leverage: number;
|
|
@@ -1036,6 +1191,18 @@ declare function useOrders(): {
|
|
|
1036
1191
|
readonly isLoading: boolean;
|
|
1037
1192
|
};
|
|
1038
1193
|
|
|
1194
|
+
interface UseSpotOrderResult {
|
|
1195
|
+
executeSpotOrder: (payload: SpotOrderRequestInput) => Promise<ApiResponse<SpotOrderResponseDto>>;
|
|
1196
|
+
isLoading: boolean;
|
|
1197
|
+
error: ApiErrorResponse | null;
|
|
1198
|
+
resetError: () => void;
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Hook for executing spot orders (swaps) on Hyperliquid
|
|
1202
|
+
* Use this to swap between USDC and USDH or other spot assets
|
|
1203
|
+
*/
|
|
1204
|
+
declare function useSpotOrder(): UseSpotOrderResult;
|
|
1205
|
+
|
|
1039
1206
|
declare function useTwap(): {
|
|
1040
1207
|
readonly orders: TwapMonitoringDto[];
|
|
1041
1208
|
readonly cancelTwap: (orderId: string) => Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
@@ -1057,14 +1224,16 @@ interface UseNotificationsResult {
|
|
|
1057
1224
|
*/
|
|
1058
1225
|
declare function useNotifications(): UseNotificationsResult;
|
|
1059
1226
|
|
|
1227
|
+
type CollateralFilter = 'USDC' | 'USDH' | 'ALL';
|
|
1060
1228
|
declare const useMarketDataPayload: () => ActiveAssetsResponse | null;
|
|
1061
1229
|
declare const useMarketDataAllPayload: () => ActiveAssetsAllResponse | null;
|
|
1062
|
-
declare const
|
|
1063
|
-
declare const
|
|
1064
|
-
declare const
|
|
1065
|
-
declare const
|
|
1066
|
-
declare const
|
|
1067
|
-
declare const
|
|
1230
|
+
declare const usePerpMetaAssets: () => UniverseAsset[] | null;
|
|
1231
|
+
declare const useActiveBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1232
|
+
declare const useTopGainers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1233
|
+
declare const useTopLosers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1234
|
+
declare const useHighlightedBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1235
|
+
declare const useWatchlistBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1236
|
+
declare const useAllBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1068
1237
|
declare const useFindBasket: (longs: string[], shorts: string[]) => ActiveAssetGroupItem | undefined;
|
|
1069
1238
|
|
|
1070
1239
|
declare function useWatchlist(): {
|
|
@@ -1127,9 +1296,9 @@ declare function usePortfolio(): UsePortfolioResult;
|
|
|
1127
1296
|
|
|
1128
1297
|
declare function useAuth(): {
|
|
1129
1298
|
readonly isReady: boolean;
|
|
1130
|
-
readonly isAuthenticated:
|
|
1131
|
-
readonly accessToken:
|
|
1132
|
-
readonly refreshToken:
|
|
1299
|
+
readonly isAuthenticated: boolean;
|
|
1300
|
+
readonly accessToken: string | null;
|
|
1301
|
+
readonly refreshToken: string | null;
|
|
1133
1302
|
readonly getEip712: (address: string) => Promise<GetEIP712MessageResponse>;
|
|
1134
1303
|
readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
|
|
1135
1304
|
readonly loginWithPrivyToken: (address: string, appId: string, privyAccessToken: string) => Promise<void>;
|
|
@@ -1137,6 +1306,32 @@ declare function useAuth(): {
|
|
|
1137
1306
|
readonly logout: () => Promise<void>;
|
|
1138
1307
|
};
|
|
1139
1308
|
|
|
1309
|
+
interface AllUserBalances {
|
|
1310
|
+
spotUsdcBalance: number | undefined;
|
|
1311
|
+
availableToTradeUsdc: number | undefined;
|
|
1312
|
+
spotUsdhBalance: number | undefined;
|
|
1313
|
+
availableToTradeUsdh: number | undefined;
|
|
1314
|
+
isLoading: boolean;
|
|
1315
|
+
}
|
|
1316
|
+
declare const useAllUserBalances: () => AllUserBalances;
|
|
1317
|
+
|
|
1318
|
+
interface UseHyperliquidUserFillsOptions {
|
|
1319
|
+
baseUrl: string;
|
|
1320
|
+
address: string | null;
|
|
1321
|
+
aggregateByTime?: boolean;
|
|
1322
|
+
}
|
|
1323
|
+
interface UseHyperliquidUserFillsState {
|
|
1324
|
+
lastRunAt: number | null;
|
|
1325
|
+
lastResult: SyncFillsResponseDto | null;
|
|
1326
|
+
error: string | null;
|
|
1327
|
+
isSyncing: boolean;
|
|
1328
|
+
handleUserFillsEvent: () => Promise<void>;
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Provides a callback to sync user fills whenever the native WebSocket emits a userFills event.
|
|
1332
|
+
*/
|
|
1333
|
+
declare function useHyperliquidUserFills(options: UseHyperliquidUserFillsOptions): UseHyperliquidUserFillsState;
|
|
1334
|
+
|
|
1140
1335
|
interface UseHyperliquidWebSocketProps {
|
|
1141
1336
|
wsUrl: string;
|
|
1142
1337
|
address: string | null;
|
|
@@ -1151,12 +1346,13 @@ interface UseHyperliquidNativeWebSocketProps {
|
|
|
1151
1346
|
address: string | null;
|
|
1152
1347
|
tokens?: string[];
|
|
1153
1348
|
enabled?: boolean;
|
|
1349
|
+
onUserFills?: () => void | Promise<void>;
|
|
1154
1350
|
}
|
|
1155
1351
|
interface UseHyperliquidNativeWebSocketReturn {
|
|
1156
1352
|
isConnected: boolean;
|
|
1157
1353
|
lastError: string | null;
|
|
1158
1354
|
}
|
|
1159
|
-
declare const useHyperliquidNativeWebSocket: ({ address, enabled, }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
|
1355
|
+
declare const useHyperliquidNativeWebSocket: ({ address, enabled, onUserFills, }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
|
1160
1356
|
|
|
1161
1357
|
/**
|
|
1162
1358
|
* Mark notifications as read up to a given timestamp (ms)
|
|
@@ -1171,7 +1367,7 @@ declare function markNotificationReadById(baseUrl: string, id: string): Promise<
|
|
|
1171
1367
|
updated: number;
|
|
1172
1368
|
}>>;
|
|
1173
1369
|
|
|
1174
|
-
declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[],
|
|
1370
|
+
declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[], hip3Assets: Map<string, string[]>): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
|
|
1175
1371
|
|
|
1176
1372
|
/**
|
|
1177
1373
|
* Account summary calculation utility class
|
|
@@ -1210,24 +1406,28 @@ declare class ConflictDetector {
|
|
|
1210
1406
|
declare class TokenMetadataExtractor {
|
|
1211
1407
|
/**
|
|
1212
1408
|
* Extracts comprehensive token metadata
|
|
1213
|
-
* @param symbol - Token symbol
|
|
1409
|
+
* @param symbol - Token symbol (base symbol without prefix, e.g., "TSLA")
|
|
1214
1410
|
* @param perpMetaAssets - Aggregated universe assets (flattened across dexes)
|
|
1215
1411
|
* @param finalAssetContexts - Aggregated asset contexts (flattened across dexes)
|
|
1216
1412
|
* @param allMids - AllMids data containing current prices
|
|
1217
1413
|
* @param activeAssetData - Optional active asset data containing leverage information
|
|
1414
|
+
* @param marketPrefix - Optional market prefix (e.g., "xyz", "flx") for HIP3 multi-market assets
|
|
1218
1415
|
* @returns TokenMetadata or null if token not found
|
|
1219
1416
|
*/
|
|
1220
|
-
static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): TokenMetadata | null;
|
|
1417
|
+
static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null, marketPrefix?: string | null): TokenMetadata | null;
|
|
1221
1418
|
/**
|
|
1222
1419
|
* Extracts metadata for multiple tokens
|
|
1223
|
-
* @param
|
|
1420
|
+
* @param tokens - Array of token objects with symbol and optional marketPrefix
|
|
1224
1421
|
* @param perpMetaAssets - Aggregated universe assets
|
|
1225
1422
|
* @param finalAssetContexts - Aggregated asset contexts
|
|
1226
1423
|
* @param allMids - AllMids data
|
|
1227
1424
|
* @param activeAssetData - Optional active asset data containing leverage information
|
|
1228
|
-
* @returns Record of
|
|
1425
|
+
* @returns Record of unique key to TokenMetadata. Key is "{prefix}:{symbol}" for HIP3 assets, or just "{symbol}" otherwise
|
|
1229
1426
|
*/
|
|
1230
|
-
static extractMultipleTokensMetadata(
|
|
1427
|
+
static extractMultipleTokensMetadata(tokens: Array<{
|
|
1428
|
+
symbol: string;
|
|
1429
|
+
marketPrefix?: string | null;
|
|
1430
|
+
}>, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): Record<string, TokenMetadata | null>;
|
|
1231
1431
|
/**
|
|
1232
1432
|
* Checks if token data is available in aggregated universe assets
|
|
1233
1433
|
* @param symbol - Token symbol
|
|
@@ -1331,7 +1531,112 @@ declare function validatePositionSize(usdValue: number, longAssets?: PairAssetIn
|
|
|
1331
1531
|
minimumRequired?: number;
|
|
1332
1532
|
};
|
|
1333
1533
|
|
|
1334
|
-
|
|
1534
|
+
/**
|
|
1535
|
+
* Convert a full/prefixed symbol (e.g., "xyz:XYZ100") to a display symbol (e.g., "XYZ100").
|
|
1536
|
+
*/
|
|
1537
|
+
declare function toDisplaySymbol(symbol: string): string;
|
|
1538
|
+
/**
|
|
1539
|
+
* Convert a display symbol back to backend form using a provided map.
|
|
1540
|
+
* If mapping is missing, returns the original symbol.
|
|
1541
|
+
* For multi-market assets, returns the first available market.
|
|
1542
|
+
* @param displaySymbol e.g., "TSLA"
|
|
1543
|
+
* @param hip3Assets map of display -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"])
|
|
1544
|
+
*/
|
|
1545
|
+
declare function toBackendSymbol(displaySymbol: string, hip3Assets: Map<string, string[]>): string;
|
|
1546
|
+
/**
|
|
1547
|
+
* Convert a display symbol to backend form for a specific market prefix.
|
|
1548
|
+
* This is useful when an asset is available on multiple markets (e.g., xyz:TSLA and flx:TSLA).
|
|
1549
|
+
* @param displaySymbol e.g., "TSLA"
|
|
1550
|
+
* @param marketPrefix e.g., "xyz" or "flx"
|
|
1551
|
+
* @param hip3Assets map of display -> all full market names
|
|
1552
|
+
* @returns Full market name if found, null if prefix not specified for multi-market asset, otherwise displaySymbol with prefix
|
|
1553
|
+
*/
|
|
1554
|
+
declare function toBackendSymbolWithMarket(displaySymbol: string, marketPrefix: string | undefined, hip3Assets: Map<string, string[]>): string | null;
|
|
1555
|
+
/**
|
|
1556
|
+
* Get all available markets for a display symbol.
|
|
1557
|
+
* @param displaySymbol e.g., "TSLA"
|
|
1558
|
+
* @param hip3Assets map of display -> all full market names
|
|
1559
|
+
* @returns Array of full market names, e.g., ["xyz:TSLA", "flx:TSLA"]
|
|
1560
|
+
*/
|
|
1561
|
+
declare function getAvailableMarkets(displaySymbol: string, hip3Assets: Map<string, string[]>): string[];
|
|
1562
|
+
/**
|
|
1563
|
+
* Extract the market prefix from a full market name.
|
|
1564
|
+
* @param fullSymbol e.g., "xyz:TSLA"
|
|
1565
|
+
* @returns The prefix (e.g., "xyz") or undefined if no prefix
|
|
1566
|
+
*/
|
|
1567
|
+
declare function getMarketPrefix(fullSymbol: string): string | undefined;
|
|
1568
|
+
/**
|
|
1569
|
+
* Check if a symbol is a HIP-3 market (has a prefix).
|
|
1570
|
+
* @param symbol e.g., "xyz:TSLA" or "TSLA"
|
|
1571
|
+
* @returns true if the symbol has a market prefix
|
|
1572
|
+
*/
|
|
1573
|
+
declare function isHip3Market(symbol: string): boolean;
|
|
1574
|
+
|
|
1575
|
+
/**
|
|
1576
|
+
* Helper functions to safely extract values from order parameters
|
|
1577
|
+
* based on the order type and parameter structure.
|
|
1578
|
+
*/
|
|
1579
|
+
/**
|
|
1580
|
+
* Get leverage from order parameters (available for Market, Trigger, Twap, Ladder orders)
|
|
1581
|
+
*/
|
|
1582
|
+
declare function getOrderLeverage(order: OpenLimitOrderDto): number | undefined;
|
|
1583
|
+
/**
|
|
1584
|
+
* Get USD value from order parameters (available for Market, Trigger, Twap, Ladder orders)
|
|
1585
|
+
*/
|
|
1586
|
+
declare function getOrderUsdValue(order: OpenLimitOrderDto): number | undefined;
|
|
1587
|
+
/**
|
|
1588
|
+
* Get trigger value from order parameters (available for TP/SL and Trigger orders)
|
|
1589
|
+
*/
|
|
1590
|
+
declare function getOrderTriggerValue(order: OpenLimitOrderDto): number | undefined;
|
|
1591
|
+
/**
|
|
1592
|
+
* Get TP/SL trigger type from order parameters (only for TP/SL orders)
|
|
1593
|
+
*/
|
|
1594
|
+
declare function getOrderTpSlTriggerType(order: OpenLimitOrderDto): TpSlTriggerType | undefined;
|
|
1595
|
+
/**
|
|
1596
|
+
* Get trigger type from order parameters (for Trigger orders)
|
|
1597
|
+
*/
|
|
1598
|
+
declare function getOrderTriggerType(order: OpenLimitOrderDto): TriggerType$1 | undefined;
|
|
1599
|
+
/**
|
|
1600
|
+
* Get order direction from order parameters (for Trigger orders)
|
|
1601
|
+
*/
|
|
1602
|
+
declare function getOrderDirection(order: OpenLimitOrderDto): OrderDirection | undefined;
|
|
1603
|
+
/**
|
|
1604
|
+
* Get reduce only flag from order parameters (available for all order types)
|
|
1605
|
+
*/
|
|
1606
|
+
declare function getOrderReduceOnly(order: OpenLimitOrderDto): boolean;
|
|
1607
|
+
/**
|
|
1608
|
+
* Get TWAP duration from order parameters (only for TWAP orders)
|
|
1609
|
+
*/
|
|
1610
|
+
declare function getOrderTwapDuration(order: OpenLimitOrderDto): string | undefined;
|
|
1611
|
+
/**
|
|
1612
|
+
* Get ladder config from order parameters (only for Ladder orders)
|
|
1613
|
+
*/
|
|
1614
|
+
declare function getOrderLadderConfig(order: OpenLimitOrderDto): {
|
|
1615
|
+
ratioStart: number;
|
|
1616
|
+
ratioEnd: number;
|
|
1617
|
+
numberOfLevels: number;
|
|
1618
|
+
} | undefined;
|
|
1619
|
+
/**
|
|
1620
|
+
* Check if the order is a BTC Dominance trigger order
|
|
1621
|
+
*/
|
|
1622
|
+
declare function isBtcDomOrder(order: OpenLimitOrderDto): boolean;
|
|
1623
|
+
/**
|
|
1624
|
+
* Get trailing info from TP/SL order parameters
|
|
1625
|
+
*/
|
|
1626
|
+
declare function getOrderTrailingInfo(order: OpenLimitOrderDto): {
|
|
1627
|
+
isTrailing: boolean;
|
|
1628
|
+
trailingDeltaValue?: number;
|
|
1629
|
+
trailingActivationValue?: number;
|
|
1630
|
+
} | undefined;
|
|
1631
|
+
|
|
1632
|
+
interface MarketDataState {
|
|
1633
|
+
marketData: ActiveAssetsResponse | null;
|
|
1634
|
+
marketDataAll: ActiveAssetsAllResponse | null;
|
|
1635
|
+
setMarketData: (value: ActiveAssetsResponse | null) => void;
|
|
1636
|
+
setMarketDataAll: (value: ActiveAssetsAllResponse | null) => void;
|
|
1637
|
+
clean: () => void;
|
|
1638
|
+
}
|
|
1639
|
+
declare const useMarketData: zustand.UseBoundStore<zustand.StoreApi<MarketDataState>>;
|
|
1335
1640
|
|
|
1336
|
-
export { AccountSummaryCalculator, ConflictDetector, MAX_ASSETS_PER_LEG, MINIMUM_ASSET_USD_VALUE, MaxAssetsPerLegError, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, getPortfolio, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, updateLeverage, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllBaskets,
|
|
1337
|
-
export type { AccountSummaryResponseDto, ActiveAssetGroupItem, ActiveAssetsResponse, AdjustAdvanceAssetInput, AdjustAdvanceItemInput, AdjustAdvanceResponseDto, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition,
|
|
1641
|
+
export { AccountSummaryCalculator, ConflictDetector, MAX_ASSETS_PER_LEG, MINIMUM_ASSET_USD_VALUE, MaxAssetsPerLegError, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, executeSpotOrder, getAvailableMarkets, getCompleteTimestamps, getMarketPrefix, getOrderDirection, getOrderLadderConfig, getOrderLeverage, getOrderReduceOnly, getOrderTpSlTriggerType, getOrderTrailingInfo, getOrderTriggerType, getOrderTriggerValue, getOrderTwapDuration, getOrderUsdValue, getPortfolio, isBtcDomOrder, isHip3Market, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toBackendSymbol, toBackendSymbolWithMarket, toDisplaySymbol, toggleWatchlist, updateLeverage, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllBaskets, useAllUserBalances, useAuth, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidUserFills, useHyperliquidWebSocket, useMarketData, useMarketDataAllPayload, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePerpMetaAssets, usePortfolio, usePosition, useSpotOrder, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWatchlist, useWatchlistBaskets, useWebData, validateMaxAssetsPerLeg, validateMinimumAssetSize, validatePositionSize };
|
|
1642
|
+
export type { AccountSummaryResponseDto, ActiveAssetGroupItem, ActiveAssetsResponse, AdjustAdvanceAssetInput, AdjustAdvanceItemInput, AdjustAdvanceResponseDto, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, BalanceSummaryDto, CancelOrderResponseDto, CancelTwapResponseDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ClearinghouseState, CloseAllPositionsResponseDto, CloseAllPositionsResultDto, CloseExecutionType, ClosePositionRequestInput, ClosePositionResponseDto, CollateralFilter, CollateralToken, CreatePositionRequestInput, CreatePositionResponseDto, CrossMarginSummaryDto, CumFundingDto, ExecutionType, ExtraAgent, HLWebSocketResponse, HistoricalRange, LadderConfigInput, MarginSummaryDto, MarketDataBySymbol, NotificationCategory, NotificationDto, OpenLimitOrderDto, OpenPositionDto, OrderAssetDto, OrderStatus, PairAssetDto, PairAssetInput, PerformanceOverlay, PlatformAccountSummaryResponseDto, PortfolioBucketDto, PortfolioInterval, PortfolioIntervalsDto, PortfolioOverallDto, PortfolioResponseDto, PositionAdjustmentType, PositionAssetDetailDto, RealtimeBar, RealtimeBarsCallback, SpotBalance, SpotOrderFilledStatus, SpotOrderHyperliquidData, SpotOrderHyperliquidResult, SpotOrderRequestInput, SpotOrderResponseDto, SpotState, ToggleWatchlistResponseDto, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlOrderParameters, TpSlThresholdInput, TpSlThresholdType, TpSlTriggerType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TriggerOrderParameters, TriggerType, TwapChunkStatusDto, TwapMonitoringDto, TwapSliceFillResponseItem, UniverseAsset, UpdateLeverageRequestInput, UpdateLeverageResponseDto, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseHyperliquidUserFillsOptions, UseHyperliquidUserFillsState, UseNotificationsResult, UsePerformanceOverlaysReturn, UsePortfolioResult, UseSpotOrderResult, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WatchlistItemDto, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
|