@pear-protocol/hyperliquid-sdk 0.0.73-beta.1 → 0.0.73
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 +2 -2
- package/dist/clients/watchlist.d.ts +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useAllUserBalances.d.ts +9 -0
- package/dist/hooks/useAuth.d.ts +0 -2
- 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/index.d.ts +218 -42
- package/dist/index.js +1316 -261
- package/dist/provider.d.ts +1 -1
- package/dist/store/hyperliquidDataStore.d.ts +9 -3
- package/dist/store/userDataStore.d.ts +3 -3
- package/dist/types.d.ts +74 -20
- package/dist/utils/symbol-translator.d.ts +32 -3
- package/dist/utils/token-metadata-extractor.d.ts +9 -5
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ interface ExternalFillDto {
|
|
|
48
48
|
coin: string;
|
|
49
49
|
px: string;
|
|
50
50
|
sz: string;
|
|
51
|
-
side:
|
|
51
|
+
side: 'B' | 'A';
|
|
52
52
|
time: number;
|
|
53
53
|
dir: string;
|
|
54
54
|
fee: string;
|
|
@@ -75,16 +75,16 @@ interface TwapSliceFillResponseItem {
|
|
|
75
75
|
/**
|
|
76
76
|
* WebSocket connection states
|
|
77
77
|
*/
|
|
78
|
-
type WebSocketConnectionState =
|
|
78
|
+
type WebSocketConnectionState = 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
79
79
|
/**
|
|
80
80
|
* WebSocket channels
|
|
81
81
|
*/
|
|
82
|
-
type WebSocketChannel =
|
|
82
|
+
type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'twap-details' | 'notifications' | 'market-data' | 'market-data-all' | 'webData3' | 'allMids' | 'activeAssetData';
|
|
83
83
|
/**
|
|
84
84
|
* WebSocket subscription message
|
|
85
85
|
*/
|
|
86
86
|
interface WebSocketSubscribeMessage {
|
|
87
|
-
action?:
|
|
87
|
+
action?: 'subscribe' | 'unsubscribe';
|
|
88
88
|
address: string;
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
@@ -114,7 +114,7 @@ interface WatchlistItemDto {
|
|
|
114
114
|
interface ToggleWatchlistResponseDto {
|
|
115
115
|
items: WatchlistItemDto[];
|
|
116
116
|
}
|
|
117
|
-
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';
|
|
118
118
|
interface NotificationDto {
|
|
119
119
|
id: string;
|
|
120
120
|
address: string;
|
|
@@ -131,7 +131,7 @@ interface ChunkFillDto {
|
|
|
131
131
|
size: number;
|
|
132
132
|
executedAt: string;
|
|
133
133
|
}
|
|
134
|
-
type TwapChunkStatus =
|
|
134
|
+
type TwapChunkStatus = 'PENDING' | 'SCHEDULED' | 'EXECUTING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';
|
|
135
135
|
interface TwapChunkStatusDto {
|
|
136
136
|
chunkId: string;
|
|
137
137
|
chunkIndex: number;
|
|
@@ -142,7 +142,7 @@ interface TwapChunkStatusDto {
|
|
|
142
142
|
fills: ChunkFillDto[];
|
|
143
143
|
errorMessage?: string;
|
|
144
144
|
}
|
|
145
|
-
type TwapOrderOverallStatus =
|
|
145
|
+
type TwapOrderOverallStatus = 'OPEN' | 'EXECUTING' | 'COMPLETED' | 'PARTIALLY_COMPLETED' | 'FAILED' | 'CANCELLED';
|
|
146
146
|
interface TwapMonitoringDto {
|
|
147
147
|
orderId: string;
|
|
148
148
|
positionId?: string;
|
|
@@ -179,6 +179,8 @@ interface TradeHistoryAssetDataDto {
|
|
|
179
179
|
externalFeePaid: number;
|
|
180
180
|
builderFeePaid: number;
|
|
181
181
|
realizedPnl: number;
|
|
182
|
+
marketPrefix?: string | null;
|
|
183
|
+
collateralToken?: CollateralToken;
|
|
182
184
|
}
|
|
183
185
|
/**
|
|
184
186
|
* Trade history data structure
|
|
@@ -227,9 +229,11 @@ interface PositionAssetDetailDto {
|
|
|
227
229
|
liquidationPrice: number;
|
|
228
230
|
initialWeight: number;
|
|
229
231
|
fundingPaid?: number;
|
|
232
|
+
marketPrefix?: string | null;
|
|
233
|
+
collateralToken?: CollateralToken;
|
|
230
234
|
}
|
|
231
235
|
interface TpSlThreshold {
|
|
232
|
-
type:
|
|
236
|
+
type: 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
|
|
233
237
|
value: number;
|
|
234
238
|
}
|
|
235
239
|
/**
|
|
@@ -260,20 +264,22 @@ interface OpenPositionDto {
|
|
|
260
264
|
interface OrderAssetDto {
|
|
261
265
|
asset: string;
|
|
262
266
|
weight: number;
|
|
267
|
+
marketPrefix?: string | null;
|
|
268
|
+
collateralToken?: CollateralToken;
|
|
263
269
|
}
|
|
264
270
|
/**
|
|
265
271
|
* Order status
|
|
266
272
|
*/
|
|
267
|
-
type OrderStatus =
|
|
273
|
+
type OrderStatus = 'OPEN' | 'PARTIALLY_FILLED' | 'PROCESSING';
|
|
268
274
|
/**
|
|
269
275
|
* Order type
|
|
270
276
|
*/
|
|
271
|
-
type OrderType =
|
|
277
|
+
type OrderType = 'TP' | 'SL' | 'LIMIT' | 'MARKET' | 'LIMIT_BTCDOM' | 'TWAP';
|
|
272
278
|
/**
|
|
273
279
|
* TP/SL trigger type
|
|
274
280
|
*/
|
|
275
|
-
type TpSlTriggerType =
|
|
276
|
-
type OrderDirection =
|
|
281
|
+
type TpSlTriggerType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
|
|
282
|
+
type OrderDirection = 'MORE_THAN' | 'LESS_THAN' | null;
|
|
277
283
|
/**
|
|
278
284
|
* Open limit order data structure
|
|
279
285
|
*/
|
|
@@ -379,7 +385,7 @@ interface RefreshTokenResponse {
|
|
|
379
385
|
tokenType: string;
|
|
380
386
|
expiresIn: number;
|
|
381
387
|
}
|
|
382
|
-
type AgentWalletStatus =
|
|
388
|
+
type AgentWalletStatus = 'ACTIVE' | 'EXPIRED' | 'NOT_FOUND';
|
|
383
389
|
interface CreateAgentWalletResponseDto {
|
|
384
390
|
agentWalletAddress: string;
|
|
385
391
|
message: string;
|
|
@@ -392,14 +398,14 @@ interface ExtraAgent {
|
|
|
392
398
|
interface AgentWalletState {
|
|
393
399
|
address: string | null;
|
|
394
400
|
name: string | null;
|
|
395
|
-
status: AgentWalletStatus |
|
|
401
|
+
status: AgentWalletStatus | 'PENDING' | null;
|
|
396
402
|
isActive: boolean;
|
|
397
403
|
}
|
|
398
404
|
/**
|
|
399
405
|
* WebSocket message from HyperLiquid native API
|
|
400
406
|
*/
|
|
401
407
|
interface WebSocketMessage {
|
|
402
|
-
method:
|
|
408
|
+
method: 'subscribe' | 'unsubscribe';
|
|
403
409
|
subscription: {
|
|
404
410
|
type: string;
|
|
405
411
|
dex?: string;
|
|
@@ -412,12 +418,16 @@ interface WebSocketMessage {
|
|
|
412
418
|
/**
|
|
413
419
|
* WebSocket response from HyperLiquid native API
|
|
414
420
|
*/
|
|
415
|
-
type HLChannel =
|
|
421
|
+
type HLChannel = 'webData3' | 'allMids' | 'activeAssetData' | 'candle' | 'spotState' | 'allDexsClearinghouseState' | 'allDexsAssetCtxs';
|
|
416
422
|
interface HLChannelDataMap {
|
|
417
423
|
webData3: WebData3Response;
|
|
418
424
|
allMids: WsAllMidsData;
|
|
419
425
|
activeAssetData: ActiveAssetData;
|
|
420
426
|
candle: CandleData;
|
|
427
|
+
spotState: {
|
|
428
|
+
user: string;
|
|
429
|
+
spotState: SpotState;
|
|
430
|
+
};
|
|
421
431
|
allDexsClearinghouseState: AllDexsClearinghouseStateData;
|
|
422
432
|
allDexsAssetCtxs: AllDexsAssetCtxsData;
|
|
423
433
|
}
|
|
@@ -482,6 +492,12 @@ interface AssetCtx {
|
|
|
482
492
|
impactPxs?: string[];
|
|
483
493
|
oraclePx: string;
|
|
484
494
|
}
|
|
495
|
+
/**
|
|
496
|
+
* Collateral token type
|
|
497
|
+
* 0 = USDC
|
|
498
|
+
* 360 = USDH
|
|
499
|
+
*/
|
|
500
|
+
type CollateralToken = 'USDC' | 'USDH';
|
|
485
501
|
/**
|
|
486
502
|
* Universe asset metadata
|
|
487
503
|
*/
|
|
@@ -491,6 +507,8 @@ interface UniverseAsset {
|
|
|
491
507
|
maxLeverage: number;
|
|
492
508
|
onlyIsolated?: boolean;
|
|
493
509
|
isDelisted?: boolean;
|
|
510
|
+
marketPrefix?: string;
|
|
511
|
+
collateralToken?: CollateralToken;
|
|
494
512
|
}
|
|
495
513
|
interface ClearinghouseState {
|
|
496
514
|
assetPositions: AssetPosition[];
|
|
@@ -561,6 +579,8 @@ interface RawAssetDto {
|
|
|
561
579
|
size: number;
|
|
562
580
|
side: string;
|
|
563
581
|
fundingPaid?: number;
|
|
582
|
+
marketPrefix?: string | null;
|
|
583
|
+
collateralToken?: CollateralToken;
|
|
564
584
|
leverage: number;
|
|
565
585
|
}
|
|
566
586
|
/**
|
|
@@ -609,6 +629,7 @@ interface TokenMetadata {
|
|
|
609
629
|
leverage?: LeverageInfo;
|
|
610
630
|
maxTradeSzs?: [string, string];
|
|
611
631
|
availableToTrade?: [string, string];
|
|
632
|
+
collateralToken?: CollateralToken;
|
|
612
633
|
}
|
|
613
634
|
/**
|
|
614
635
|
* Enhanced token selection with weight and metadata for basket trading
|
|
@@ -622,16 +643,37 @@ interface TokenSelection {
|
|
|
622
643
|
*/
|
|
623
644
|
interface TokenConflict {
|
|
624
645
|
symbol: string;
|
|
625
|
-
conflictType:
|
|
646
|
+
conflictType: 'long' | 'short';
|
|
626
647
|
conflictMessage: string;
|
|
627
648
|
}
|
|
628
649
|
interface AssetMarketData {
|
|
629
650
|
asset: WebData3AssetCtx | AssetCtx;
|
|
630
651
|
universe: UniverseAsset;
|
|
631
652
|
}
|
|
653
|
+
/**
|
|
654
|
+
* Nested market data structure for multi-market assets.
|
|
655
|
+
* Each symbol maps to its market variants (keyed by prefix).
|
|
656
|
+
* For non-HIP3 assets, use "default" as the key.
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* ```ts
|
|
660
|
+
* {
|
|
661
|
+
* "TSLA": {
|
|
662
|
+
* "xyz": { asset: {...}, universe: { collateralToken: "USDC", ... } },
|
|
663
|
+
* "flx": { asset: {...}, universe: { collateralToken: "USDH", ... } }
|
|
664
|
+
* },
|
|
665
|
+
* "BTC": {
|
|
666
|
+
* "default": { asset: {...}, universe: {...} }
|
|
667
|
+
* }
|
|
668
|
+
* }
|
|
669
|
+
* ```
|
|
670
|
+
*/
|
|
671
|
+
type MarketDataBySymbol = Record<string, Record<string, AssetMarketData>>;
|
|
632
672
|
interface PairAssetDto {
|
|
633
673
|
asset: string;
|
|
634
674
|
weight: number;
|
|
675
|
+
collateralToken: CollateralToken;
|
|
676
|
+
marketPrefix: string | null;
|
|
635
677
|
}
|
|
636
678
|
interface ActiveAssetGroupItem {
|
|
637
679
|
longAssets: PairAssetDto[];
|
|
@@ -645,6 +687,7 @@ interface ActiveAssetGroupItem {
|
|
|
645
687
|
weightedRatio?: string;
|
|
646
688
|
weightedPrevRatio?: string;
|
|
647
689
|
weightedChange24h?: string;
|
|
690
|
+
collateralType: 'USDC' | 'USDH' | 'MIXED';
|
|
648
691
|
}
|
|
649
692
|
interface ActiveAssetsResponse {
|
|
650
693
|
active: ActiveAssetGroupItem[];
|
|
@@ -662,7 +705,7 @@ interface ActiveAssetsAllResponse {
|
|
|
662
705
|
/**
|
|
663
706
|
* Candle interval options
|
|
664
707
|
*/
|
|
665
|
-
type CandleInterval =
|
|
708
|
+
type CandleInterval = '1m' | '3m' | '5m' | '15m' | '30m' | '1h' | '2h' | '4h' | '8h' | '12h' | '1d' | '3d' | '1w' | '1M';
|
|
666
709
|
/**
|
|
667
710
|
* Candle data structure from WebSocket
|
|
668
711
|
*/
|
|
@@ -690,12 +733,23 @@ interface CandleSnapshotRequest {
|
|
|
690
733
|
endTime: number;
|
|
691
734
|
interval: CandleInterval;
|
|
692
735
|
};
|
|
693
|
-
type:
|
|
736
|
+
type: 'candleSnapshot';
|
|
694
737
|
}
|
|
695
738
|
interface TokenSelectorConfig {
|
|
696
739
|
isLong: boolean;
|
|
697
740
|
index: number;
|
|
698
741
|
}
|
|
742
|
+
interface SpotBalance {
|
|
743
|
+
coin: string;
|
|
744
|
+
token: number;
|
|
745
|
+
total: string;
|
|
746
|
+
hold: string;
|
|
747
|
+
entryNtl: string;
|
|
748
|
+
}
|
|
749
|
+
interface SpotState {
|
|
750
|
+
user: string;
|
|
751
|
+
balances: SpotBalance[];
|
|
752
|
+
}
|
|
699
753
|
|
|
700
754
|
declare const useAccountSummary: () => {
|
|
701
755
|
data: AccountSummaryResponseDto | null;
|
|
@@ -706,9 +760,6 @@ declare const useTradeHistories: () => {
|
|
|
706
760
|
data: TradeHistoryDataDto[] | null;
|
|
707
761
|
isLoading: boolean;
|
|
708
762
|
};
|
|
709
|
-
/**
|
|
710
|
-
* Hook to access open orders with loading state
|
|
711
|
-
*/
|
|
712
763
|
declare const useOpenOrders: () => {
|
|
713
764
|
data: OpenLimitOrderDto[] | null;
|
|
714
765
|
isLoading: boolean;
|
|
@@ -747,8 +798,26 @@ declare const useUserSelection: () => UserSelectionState;
|
|
|
747
798
|
declare const useWebData: () => {
|
|
748
799
|
clearinghouseState: ClearinghouseState | null;
|
|
749
800
|
perpsAtOpenInterestCap: string[] | null;
|
|
750
|
-
|
|
751
|
-
|
|
801
|
+
/**
|
|
802
|
+
* Market data keyed by symbol, with nested market variants.
|
|
803
|
+
* Each symbol maps to its market variants (keyed by prefix).
|
|
804
|
+
* For non-HIP3 assets, use "default" as the key.
|
|
805
|
+
*
|
|
806
|
+
* @example
|
|
807
|
+
* ```ts
|
|
808
|
+
* // HIP-3 asset with multiple markets
|
|
809
|
+
* marketDataBySymbol["TSLA"]["xyz"] // { asset, universe: { collateralToken: "USDC" } }
|
|
810
|
+
* marketDataBySymbol["TSLA"]["flx"] // { asset, universe: { collateralToken: "USDH" } }
|
|
811
|
+
*
|
|
812
|
+
* // Regular asset
|
|
813
|
+
* marketDataBySymbol["BTC"]["default"] // { asset, universe }
|
|
814
|
+
* ```
|
|
815
|
+
*/
|
|
816
|
+
marketDataBySymbol: MarketDataBySymbol;
|
|
817
|
+
/** Map of display name -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"]) */
|
|
818
|
+
hip3Assets: Map<string, string[]>;
|
|
819
|
+
/** Map of full market name -> prefix (e.g., "xyz:TSLA" -> "xyz") */
|
|
820
|
+
hip3MarketPrefixes: Map<string, string>;
|
|
752
821
|
isConnected: boolean;
|
|
753
822
|
error: string | null;
|
|
754
823
|
};
|
|
@@ -893,6 +962,47 @@ interface CancelTwapResponseDto {
|
|
|
893
962
|
cancelledAt: string;
|
|
894
963
|
}
|
|
895
964
|
declare function cancelTwapOrder(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
965
|
+
interface SpotOrderRequestInput {
|
|
966
|
+
/** Asset to buy/sell (e.g., "USDH") */
|
|
967
|
+
asset: string;
|
|
968
|
+
/** Whether to buy (true) or sell (false) the asset */
|
|
969
|
+
isBuy: boolean;
|
|
970
|
+
/** Amount of asset to buy/sell (minimum: 11) */
|
|
971
|
+
amount: number;
|
|
972
|
+
}
|
|
973
|
+
/** Filled order status from Hyperliquid */
|
|
974
|
+
interface SpotOrderFilledStatus {
|
|
975
|
+
filled: {
|
|
976
|
+
totalSz: string;
|
|
977
|
+
avgPx: string;
|
|
978
|
+
oid: number;
|
|
979
|
+
cloid: string;
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
/** Hyperliquid order response data */
|
|
983
|
+
interface SpotOrderHyperliquidData {
|
|
984
|
+
statuses: SpotOrderFilledStatus[];
|
|
985
|
+
}
|
|
986
|
+
/** Hyperliquid result from spot order execution */
|
|
987
|
+
interface SpotOrderHyperliquidResult {
|
|
988
|
+
status: 'ok' | 'error';
|
|
989
|
+
response: {
|
|
990
|
+
type: 'order';
|
|
991
|
+
data: SpotOrderHyperliquidData;
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
interface SpotOrderResponseDto {
|
|
995
|
+
orderId: string;
|
|
996
|
+
status: 'EXECUTED' | 'FAILED' | 'PENDING';
|
|
997
|
+
asset: string;
|
|
998
|
+
createdAt: string;
|
|
999
|
+
hyperliquidResult?: SpotOrderHyperliquidResult;
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* Execute a spot order (swap) using Pear Hyperliquid service
|
|
1003
|
+
* POST /orders/spot
|
|
1004
|
+
*/
|
|
1005
|
+
declare function executeSpotOrder(baseUrl: string, payload: SpotOrderRequestInput): Promise<ApiResponse<SpotOrderResponseDto>>;
|
|
896
1006
|
|
|
897
1007
|
type ExecutionType = "MARKET" | "LIMIT" | "TWAP" | "LADDER" | "LIMIT_BTCDOM";
|
|
898
1008
|
type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
|
|
@@ -951,7 +1061,7 @@ interface CreatePositionResponseDto {
|
|
|
951
1061
|
* @throws MinimumPositionSizeError if any asset has less than $11 USD value
|
|
952
1062
|
* @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets (15)
|
|
953
1063
|
*/
|
|
954
|
-
declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput,
|
|
1064
|
+
declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput, hip3Assets: Map<string, string[]>): Promise<ApiResponse<CreatePositionResponseDto>>;
|
|
955
1065
|
interface UpdateRiskParametersRequestInput {
|
|
956
1066
|
stopLoss?: TpSlThresholdInput | null;
|
|
957
1067
|
takeProfit?: TpSlThresholdInput | null;
|
|
@@ -1018,7 +1128,7 @@ interface AdjustAdvanceResponseDto {
|
|
|
1018
1128
|
status: string;
|
|
1019
1129
|
executedAt: string;
|
|
1020
1130
|
}
|
|
1021
|
-
declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[],
|
|
1131
|
+
declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[], hip3Assets: Map<string, string[]>): Promise<ApiResponse<AdjustAdvanceResponseDto>>;
|
|
1022
1132
|
declare function cancelTwap(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
1023
1133
|
interface UpdateLeverageRequestInput {
|
|
1024
1134
|
leverage: number;
|
|
@@ -1048,6 +1158,18 @@ declare function useOrders(): {
|
|
|
1048
1158
|
readonly isLoading: boolean;
|
|
1049
1159
|
};
|
|
1050
1160
|
|
|
1161
|
+
interface UseSpotOrderResult {
|
|
1162
|
+
executeSpotOrder: (payload: SpotOrderRequestInput) => Promise<ApiResponse<SpotOrderResponseDto>>;
|
|
1163
|
+
isLoading: boolean;
|
|
1164
|
+
error: ApiErrorResponse | null;
|
|
1165
|
+
resetError: () => void;
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Hook for executing spot orders (swaps) on Hyperliquid
|
|
1169
|
+
* Use this to swap between USDC and USDH or other spot assets
|
|
1170
|
+
*/
|
|
1171
|
+
declare function useSpotOrder(): UseSpotOrderResult;
|
|
1172
|
+
|
|
1051
1173
|
declare function useTwap(): {
|
|
1052
1174
|
readonly orders: TwapMonitoringDto[];
|
|
1053
1175
|
readonly cancelTwap: (orderId: string) => Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
@@ -1069,14 +1191,16 @@ interface UseNotificationsResult {
|
|
|
1069
1191
|
*/
|
|
1070
1192
|
declare function useNotifications(): UseNotificationsResult;
|
|
1071
1193
|
|
|
1194
|
+
type CollateralFilter = 'USDC' | 'USDH' | 'ALL';
|
|
1072
1195
|
declare const useMarketDataPayload: () => ActiveAssetsResponse | null;
|
|
1073
1196
|
declare const useMarketDataAllPayload: () => ActiveAssetsAllResponse | null;
|
|
1074
|
-
declare const
|
|
1075
|
-
declare const
|
|
1076
|
-
declare const
|
|
1077
|
-
declare const
|
|
1078
|
-
declare const
|
|
1079
|
-
declare const
|
|
1197
|
+
declare const usePerpMetaAssets: () => UniverseAsset[] | null;
|
|
1198
|
+
declare const useActiveBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1199
|
+
declare const useTopGainers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1200
|
+
declare const useTopLosers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1201
|
+
declare const useHighlightedBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1202
|
+
declare const useWatchlistBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1203
|
+
declare const useAllBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1080
1204
|
declare const useFindBasket: (longs: string[], shorts: string[]) => ActiveAssetGroupItem | undefined;
|
|
1081
1205
|
|
|
1082
1206
|
declare function useWatchlist(): {
|
|
@@ -1147,10 +1271,17 @@ declare function useAuth(): {
|
|
|
1147
1271
|
readonly loginWithPrivyToken: (address: string, appId: string, privyAccessToken: string) => Promise<void>;
|
|
1148
1272
|
readonly refreshTokens: () => Promise<RefreshTokenResponse>;
|
|
1149
1273
|
readonly logout: () => Promise<void>;
|
|
1150
|
-
readonly setAddress: (address: string | null) => void;
|
|
1151
|
-
readonly address: string | null;
|
|
1152
1274
|
};
|
|
1153
1275
|
|
|
1276
|
+
interface AllUserBalances {
|
|
1277
|
+
spotUsdcBalance: number | undefined;
|
|
1278
|
+
availableToTradeUsdc: number | undefined;
|
|
1279
|
+
spotUsdhBalance: number | undefined;
|
|
1280
|
+
availableToTradeUsdh: number | undefined;
|
|
1281
|
+
isLoading: boolean;
|
|
1282
|
+
}
|
|
1283
|
+
declare const useAllUserBalances: () => AllUserBalances;
|
|
1284
|
+
|
|
1154
1285
|
interface UseHyperliquidWebSocketProps {
|
|
1155
1286
|
wsUrl: string;
|
|
1156
1287
|
address: string | null;
|
|
@@ -1185,7 +1316,7 @@ declare function markNotificationReadById(baseUrl: string, id: string): Promise<
|
|
|
1185
1316
|
updated: number;
|
|
1186
1317
|
}>>;
|
|
1187
1318
|
|
|
1188
|
-
declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[],
|
|
1319
|
+
declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[], hip3Assets: Map<string, string[]>): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
|
|
1189
1320
|
|
|
1190
1321
|
/**
|
|
1191
1322
|
* Account summary calculation utility class
|
|
@@ -1224,24 +1355,28 @@ declare class ConflictDetector {
|
|
|
1224
1355
|
declare class TokenMetadataExtractor {
|
|
1225
1356
|
/**
|
|
1226
1357
|
* Extracts comprehensive token metadata
|
|
1227
|
-
* @param symbol - Token symbol
|
|
1358
|
+
* @param symbol - Token symbol (base symbol without prefix, e.g., "TSLA")
|
|
1228
1359
|
* @param perpMetaAssets - Aggregated universe assets (flattened across dexes)
|
|
1229
1360
|
* @param finalAssetContexts - Aggregated asset contexts (flattened across dexes)
|
|
1230
1361
|
* @param allMids - AllMids data containing current prices
|
|
1231
1362
|
* @param activeAssetData - Optional active asset data containing leverage information
|
|
1363
|
+
* @param marketPrefix - Optional market prefix (e.g., "xyz", "flx") for HIP3 multi-market assets
|
|
1232
1364
|
* @returns TokenMetadata or null if token not found
|
|
1233
1365
|
*/
|
|
1234
|
-
static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): TokenMetadata | null;
|
|
1366
|
+
static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null, marketPrefix?: string | null): TokenMetadata | null;
|
|
1235
1367
|
/**
|
|
1236
1368
|
* Extracts metadata for multiple tokens
|
|
1237
|
-
* @param
|
|
1369
|
+
* @param tokens - Array of token objects with symbol and optional marketPrefix
|
|
1238
1370
|
* @param perpMetaAssets - Aggregated universe assets
|
|
1239
1371
|
* @param finalAssetContexts - Aggregated asset contexts
|
|
1240
1372
|
* @param allMids - AllMids data
|
|
1241
1373
|
* @param activeAssetData - Optional active asset data containing leverage information
|
|
1242
|
-
* @returns Record of
|
|
1374
|
+
* @returns Record of unique key to TokenMetadata. Key is "{prefix}:{symbol}" for HIP3 assets, or just "{symbol}" otherwise
|
|
1243
1375
|
*/
|
|
1244
|
-
static extractMultipleTokensMetadata(
|
|
1376
|
+
static extractMultipleTokensMetadata(tokens: Array<{
|
|
1377
|
+
symbol: string;
|
|
1378
|
+
marketPrefix?: string | null;
|
|
1379
|
+
}>, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): Record<string, TokenMetadata | null>;
|
|
1245
1380
|
/**
|
|
1246
1381
|
* Checks if token data is available in aggregated universe assets
|
|
1247
1382
|
* @param symbol - Token symbol
|
|
@@ -1345,6 +1480,47 @@ declare function validatePositionSize(usdValue: number, longAssets?: PairAssetIn
|
|
|
1345
1480
|
minimumRequired?: number;
|
|
1346
1481
|
};
|
|
1347
1482
|
|
|
1483
|
+
/**
|
|
1484
|
+
* Convert a full/prefixed symbol (e.g., "xyz:XYZ100") to a display symbol (e.g., "XYZ100").
|
|
1485
|
+
*/
|
|
1486
|
+
declare function toDisplaySymbol(symbol: string): string;
|
|
1487
|
+
/**
|
|
1488
|
+
* Convert a display symbol back to backend form using a provided map.
|
|
1489
|
+
* If mapping is missing, returns the original symbol.
|
|
1490
|
+
* For multi-market assets, returns the first available market.
|
|
1491
|
+
* @param displaySymbol e.g., "TSLA"
|
|
1492
|
+
* @param hip3Assets map of display -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"])
|
|
1493
|
+
*/
|
|
1494
|
+
declare function toBackendSymbol(displaySymbol: string, hip3Assets: Map<string, string[]>): string;
|
|
1495
|
+
/**
|
|
1496
|
+
* Convert a display symbol to backend form for a specific market prefix.
|
|
1497
|
+
* This is useful when an asset is available on multiple markets (e.g., xyz:TSLA and flx:TSLA).
|
|
1498
|
+
* @param displaySymbol e.g., "TSLA"
|
|
1499
|
+
* @param marketPrefix e.g., "xyz" or "flx"
|
|
1500
|
+
* @param hip3Assets map of display -> all full market names
|
|
1501
|
+
* @returns Full market name if found, null if prefix not specified for multi-market asset, otherwise displaySymbol with prefix
|
|
1502
|
+
*/
|
|
1503
|
+
declare function toBackendSymbolWithMarket(displaySymbol: string, marketPrefix: string | undefined, hip3Assets: Map<string, string[]>): string | null;
|
|
1504
|
+
/**
|
|
1505
|
+
* Get all available markets for a display symbol.
|
|
1506
|
+
* @param displaySymbol e.g., "TSLA"
|
|
1507
|
+
* @param hip3Assets map of display -> all full market names
|
|
1508
|
+
* @returns Array of full market names, e.g., ["xyz:TSLA", "flx:TSLA"]
|
|
1509
|
+
*/
|
|
1510
|
+
declare function getAvailableMarkets(displaySymbol: string, hip3Assets: Map<string, string[]>): string[];
|
|
1511
|
+
/**
|
|
1512
|
+
* Extract the market prefix from a full market name.
|
|
1513
|
+
* @param fullSymbol e.g., "xyz:TSLA"
|
|
1514
|
+
* @returns The prefix (e.g., "xyz") or undefined if no prefix
|
|
1515
|
+
*/
|
|
1516
|
+
declare function getMarketPrefix(fullSymbol: string): string | undefined;
|
|
1517
|
+
/**
|
|
1518
|
+
* Check if a symbol is a HIP-3 market (has a prefix).
|
|
1519
|
+
* @param symbol e.g., "xyz:TSLA" or "TSLA"
|
|
1520
|
+
* @returns true if the symbol has a market prefix
|
|
1521
|
+
*/
|
|
1522
|
+
declare function isHip3Market(symbol: string): boolean;
|
|
1523
|
+
|
|
1348
1524
|
interface MarketDataState {
|
|
1349
1525
|
marketData: ActiveAssetsResponse | null;
|
|
1350
1526
|
marketDataAll: ActiveAssetsAllResponse | null;
|
|
@@ -1354,5 +1530,5 @@ interface MarketDataState {
|
|
|
1354
1530
|
}
|
|
1355
1531
|
declare const useMarketData: zustand.UseBoundStore<zustand.StoreApi<MarketDataState>>;
|
|
1356
1532
|
|
|
1357
|
-
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, useAuth, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMarketData, useMarketDataAllPayload, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePortfolio, usePosition, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWatchlist, useWatchlistBaskets, useWebData, validateMaxAssetsPerLeg, validateMinimumAssetSize, validatePositionSize };
|
|
1358
|
-
export type { AccountSummaryResponseDto, ActiveAssetGroupItem, ActiveAssetsResponse, AdjustAdvanceAssetInput, AdjustAdvanceItemInput, AdjustAdvanceResponseDto, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, AutoSyncFillsOptions, AutoSyncFillsState, BalanceSummaryDto, CancelOrderResponseDto, CancelTwapResponseDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ClearinghouseState, CloseAllPositionsResponseDto, CloseAllPositionsResultDto, CloseExecutionType, ClosePositionRequestInput, ClosePositionResponseDto, CreatePositionRequestInput, CreatePositionResponseDto, CrossMarginSummaryDto, CumFundingDto, ExecutionType, ExtraAgent, HLWebSocketResponse, HistoricalRange, LadderConfigInput, MarginSummaryDto, NotificationCategory, NotificationDto, OpenLimitOrderDto, OpenPositionDto, OrderAssetDto, OrderStatus, PairAssetDto, PairAssetInput, PerformanceOverlay, PlatformAccountSummaryResponseDto, PortfolioBucketDto, PortfolioInterval, PortfolioIntervalsDto, PortfolioOverallDto, PortfolioResponseDto, PositionAdjustmentType, PositionAssetDetailDto, PositionAssetSummaryDto, PositionResponseStatus, RealtimeBar, RealtimeBarsCallback, ToggleWatchlistResponseDto, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlThresholdInput, TpSlThresholdType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TwapChunkStatusDto, TwapMonitoringDto, TwapSliceFillResponseItem, UniverseAsset, UpdateLeverageRequestInput, UpdateLeverageResponseDto, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseNotificationsResult, UsePerformanceOverlaysReturn, UsePortfolioResult, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WatchlistItemDto, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
|
|
1533
|
+
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, getPortfolio, isHip3Market, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toBackendSymbol, toBackendSymbolWithMarket, toDisplaySymbol, toggleWatchlist, updateLeverage, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllBaskets, useAllUserBalances, useAuth, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, 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 };
|
|
1534
|
+
export type { AccountSummaryResponseDto, ActiveAssetGroupItem, ActiveAssetsResponse, AdjustAdvanceAssetInput, AdjustAdvanceItemInput, AdjustAdvanceResponseDto, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, AutoSyncFillsOptions, AutoSyncFillsState, 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, PositionAssetSummaryDto, PositionResponseStatus, RealtimeBar, RealtimeBarsCallback, SpotBalance, SpotOrderFilledStatus, SpotOrderHyperliquidData, SpotOrderHyperliquidResult, SpotOrderRequestInput, SpotOrderResponseDto, SpotState, ToggleWatchlistResponseDto, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlThresholdInput, TpSlThresholdType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TwapChunkStatusDto, TwapMonitoringDto, TwapSliceFillResponseItem, UniverseAsset, UpdateLeverageRequestInput, UpdateLeverageResponseDto, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseNotificationsResult, UsePerformanceOverlaysReturn, UsePortfolioResult, UseSpotOrderResult, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WatchlistItemDto, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
|