@pear-protocol/hyperliquid-sdk 0.0.64 → 0.0.66-usdh-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/index.d.ts CHANGED
@@ -47,7 +47,7 @@ interface ExternalFillDto {
47
47
  coin: string;
48
48
  px: string;
49
49
  sz: string;
50
- side: "B" | "A";
50
+ side: 'B' | 'A';
51
51
  time: number;
52
52
  dir: string;
53
53
  fee: string;
@@ -74,16 +74,16 @@ interface TwapSliceFillResponseItem {
74
74
  /**
75
75
  * WebSocket connection states
76
76
  */
77
- type WebSocketConnectionState = "connecting" | "connected" | "disconnected" | "error";
77
+ type WebSocketConnectionState = 'connecting' | 'connected' | 'disconnected' | 'error';
78
78
  /**
79
79
  * WebSocket channels
80
80
  */
81
- type WebSocketChannel = "trade-histories" | "open-positions" | "open-orders" | "account-summary" | "twap-details" | "notifications" | "market-data" | "market-data-all" | "webData3" | "allMids" | "activeAssetData";
81
+ type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'twap-details' | 'notifications' | 'market-data' | 'market-data-all' | 'webData3' | 'allMids' | 'activeAssetData';
82
82
  /**
83
83
  * WebSocket subscription message
84
84
  */
85
85
  interface WebSocketSubscribeMessage {
86
- action?: "subscribe" | "unsubscribe";
86
+ action?: 'subscribe' | 'unsubscribe';
87
87
  address: string;
88
88
  }
89
89
  /**
@@ -113,7 +113,7 @@ interface WatchlistItemDto {
113
113
  interface ToggleWatchlistResponseDto {
114
114
  items: WatchlistItemDto[];
115
115
  }
116
- 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";
116
+ 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
117
  interface NotificationDto {
118
118
  id: string;
119
119
  address: string;
@@ -130,7 +130,7 @@ interface ChunkFillDto {
130
130
  size: number;
131
131
  executedAt: string;
132
132
  }
133
- type TwapChunkStatus = "PENDING" | "SCHEDULED" | "EXECUTING" | "COMPLETED" | "FAILED" | "CANCELLED";
133
+ type TwapChunkStatus = 'PENDING' | 'SCHEDULED' | 'EXECUTING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';
134
134
  interface TwapChunkStatusDto {
135
135
  chunkId: string;
136
136
  chunkIndex: number;
@@ -141,7 +141,7 @@ interface TwapChunkStatusDto {
141
141
  fills: ChunkFillDto[];
142
142
  errorMessage?: string;
143
143
  }
144
- type TwapOrderOverallStatus = "OPEN" | "EXECUTING" | "COMPLETED" | "PARTIALLY_COMPLETED" | "FAILED" | "CANCELLED";
144
+ type TwapOrderOverallStatus = 'OPEN' | 'EXECUTING' | 'COMPLETED' | 'PARTIALLY_COMPLETED' | 'FAILED' | 'CANCELLED';
145
145
  interface TwapMonitoringDto {
146
146
  orderId: string;
147
147
  positionId?: string;
@@ -178,6 +178,8 @@ interface TradeHistoryAssetDataDto {
178
178
  externalFeePaid: number;
179
179
  builderFeePaid: number;
180
180
  realizedPnl: number;
181
+ marketPrefix?: string | null;
182
+ collateralToken?: CollateralToken;
181
183
  }
182
184
  /**
183
185
  * Trade history data structure
@@ -226,9 +228,11 @@ interface PositionAssetDetailDto {
226
228
  liquidationPrice: number;
227
229
  initialWeight: number;
228
230
  fundingPaid?: number;
231
+ marketPrefix?: string | null;
232
+ collateralToken?: CollateralToken;
229
233
  }
230
234
  interface TpSlThreshold {
231
- type: "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
235
+ type: 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
232
236
  value: number;
233
237
  }
234
238
  /**
@@ -259,20 +263,22 @@ interface OpenPositionDto {
259
263
  interface OrderAssetDto {
260
264
  asset: string;
261
265
  weight: number;
266
+ marketPrefix?: string | null;
267
+ collateralToken?: CollateralToken;
262
268
  }
263
269
  /**
264
270
  * Order status
265
271
  */
266
- type OrderStatus = "OPEN" | "PARTIALLY_FILLED" | "PROCESSING";
272
+ type OrderStatus = 'OPEN' | 'PARTIALLY_FILLED' | 'PROCESSING';
267
273
  /**
268
274
  * Order type
269
275
  */
270
- type OrderType = "TP" | "SL" | "LIMIT" | "MARKET" | "LIMIT_BTCDOM" | "TWAP";
276
+ type OrderType = 'TP' | 'SL' | 'LIMIT' | 'MARKET' | 'LIMIT_BTCDOM' | 'TWAP';
271
277
  /**
272
278
  * TP/SL trigger type
273
279
  */
274
- type TpSlTriggerType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
275
- type OrderDirection = "MORE_THAN" | "LESS_THAN" | null;
280
+ type TpSlTriggerType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
281
+ type OrderDirection = 'MORE_THAN' | 'LESS_THAN' | null;
276
282
  /**
277
283
  * Open limit order data structure
278
284
  */
@@ -378,7 +384,7 @@ interface RefreshTokenResponse {
378
384
  tokenType: string;
379
385
  expiresIn: number;
380
386
  }
381
- type AgentWalletStatus = "ACTIVE" | "EXPIRED" | "NOT_FOUND";
387
+ type AgentWalletStatus = 'ACTIVE' | 'EXPIRED' | 'NOT_FOUND';
382
388
  interface CreateAgentWalletResponseDto {
383
389
  agentWalletAddress: string;
384
390
  message: string;
@@ -391,14 +397,14 @@ interface ExtraAgent {
391
397
  interface AgentWalletState {
392
398
  address: string | null;
393
399
  name: string | null;
394
- status: AgentWalletStatus | "PENDING" | null;
400
+ status: AgentWalletStatus | 'PENDING' | null;
395
401
  isActive: boolean;
396
402
  }
397
403
  /**
398
404
  * WebSocket message from HyperLiquid native API
399
405
  */
400
406
  interface WebSocketMessage {
401
- method: "subscribe" | "unsubscribe";
407
+ method: 'subscribe' | 'unsubscribe';
402
408
  subscription: {
403
409
  type: string;
404
410
  dex?: string;
@@ -411,12 +417,16 @@ interface WebSocketMessage {
411
417
  /**
412
418
  * WebSocket response from HyperLiquid native API
413
419
  */
414
- type HLChannel = "webData3" | "allMids" | "activeAssetData" | "candle" | "allDexsClearinghouseState" | "allDexsAssetCtxs";
420
+ type HLChannel = 'webData3' | 'allMids' | 'activeAssetData' | 'candle' | 'spotState' | 'allDexsClearinghouseState' | 'allDexsAssetCtxs';
415
421
  interface HLChannelDataMap {
416
422
  webData3: WebData3Response;
417
423
  allMids: WsAllMidsData;
418
424
  activeAssetData: ActiveAssetData;
419
425
  candle: CandleData;
426
+ spotState: {
427
+ user: string;
428
+ spotState: SpotState;
429
+ };
420
430
  allDexsClearinghouseState: AllDexsClearinghouseStateData;
421
431
  allDexsAssetCtxs: AllDexsAssetCtxsData;
422
432
  }
@@ -481,6 +491,12 @@ interface AssetCtx {
481
491
  impactPxs?: string[];
482
492
  oraclePx: string;
483
493
  }
494
+ /**
495
+ * Collateral token type
496
+ * 0 = USDC
497
+ * 360 = USDH
498
+ */
499
+ type CollateralToken = 'USDC' | 'USDH';
484
500
  /**
485
501
  * Universe asset metadata
486
502
  */
@@ -490,6 +506,8 @@ interface UniverseAsset {
490
506
  maxLeverage: number;
491
507
  onlyIsolated?: boolean;
492
508
  isDelisted?: boolean;
509
+ marketPrefix?: string;
510
+ collateralToken?: CollateralToken;
493
511
  }
494
512
  interface ClearinghouseState {
495
513
  assetPositions: AssetPosition[];
@@ -560,6 +578,8 @@ interface RawAssetDto {
560
578
  size: number;
561
579
  side: string;
562
580
  fundingPaid?: number;
581
+ marketPrefix?: string | null;
582
+ collateralToken?: CollateralToken;
563
583
  }
564
584
  /**
565
585
  * Raw position data from open-positions channel
@@ -607,6 +627,7 @@ interface TokenMetadata {
607
627
  leverage?: LeverageInfo;
608
628
  maxTradeSzs?: [string, string];
609
629
  availableToTrade?: [string, string];
630
+ collateralToken?: CollateralToken;
610
631
  }
611
632
  /**
612
633
  * Enhanced token selection with weight and metadata for basket trading
@@ -620,16 +641,37 @@ interface TokenSelection {
620
641
  */
621
642
  interface TokenConflict {
622
643
  symbol: string;
623
- conflictType: "long" | "short";
644
+ conflictType: 'long' | 'short';
624
645
  conflictMessage: string;
625
646
  }
626
647
  interface AssetMarketData {
627
648
  asset: WebData3AssetCtx | AssetCtx;
628
649
  universe: UniverseAsset;
629
650
  }
651
+ /**
652
+ * Nested market data structure for multi-market assets.
653
+ * Each symbol maps to its market variants (keyed by prefix).
654
+ * For non-HIP3 assets, use "default" as the key.
655
+ *
656
+ * @example
657
+ * ```ts
658
+ * {
659
+ * "TSLA": {
660
+ * "xyz": { asset: {...}, universe: { collateralToken: "USDC", ... } },
661
+ * "flx": { asset: {...}, universe: { collateralToken: "USDH", ... } }
662
+ * },
663
+ * "BTC": {
664
+ * "default": { asset: {...}, universe: {...} }
665
+ * }
666
+ * }
667
+ * ```
668
+ */
669
+ type MarketDataBySymbol = Record<string, Record<string, AssetMarketData>>;
630
670
  interface PairAssetDto {
631
671
  asset: string;
632
672
  weight: number;
673
+ collateralToken: CollateralToken;
674
+ marketPrefix: string | null;
633
675
  }
634
676
  interface ActiveAssetGroupItem {
635
677
  longAssets: PairAssetDto[];
@@ -643,6 +685,7 @@ interface ActiveAssetGroupItem {
643
685
  weightedRatio?: string;
644
686
  weightedPrevRatio?: string;
645
687
  weightedChange24h?: string;
688
+ collateralType: 'USDC' | 'USDH' | 'MIXED';
646
689
  }
647
690
  interface ActiveAssetsResponse {
648
691
  active: ActiveAssetGroupItem[];
@@ -660,7 +703,7 @@ interface ActiveAssetsAllResponse {
660
703
  /**
661
704
  * Candle interval options
662
705
  */
663
- type CandleInterval = "1m" | "3m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" | "8h" | "12h" | "1d" | "3d" | "1w" | "1M";
706
+ type CandleInterval = '1m' | '3m' | '5m' | '15m' | '30m' | '1h' | '2h' | '4h' | '8h' | '12h' | '1d' | '3d' | '1w' | '1M';
664
707
  /**
665
708
  * Candle data structure from WebSocket
666
709
  */
@@ -688,12 +731,23 @@ interface CandleSnapshotRequest {
688
731
  endTime: number;
689
732
  interval: CandleInterval;
690
733
  };
691
- type: "candleSnapshot";
734
+ type: 'candleSnapshot';
692
735
  }
693
736
  interface TokenSelectorConfig {
694
737
  isLong: boolean;
695
738
  index: number;
696
739
  }
740
+ interface SpotBalance {
741
+ coin: string;
742
+ token: number;
743
+ total: string;
744
+ hold: string;
745
+ entryNtl: string;
746
+ }
747
+ interface SpotState {
748
+ user: string;
749
+ balances: SpotBalance[];
750
+ }
697
751
 
698
752
  declare const useAccountSummary: () => {
699
753
  data: AccountSummaryResponseDto | null;
@@ -704,9 +758,6 @@ declare const useTradeHistories: () => {
704
758
  data: TradeHistoryDataDto[] | null;
705
759
  isLoading: boolean;
706
760
  };
707
- /**
708
- * Hook to access open orders with loading state
709
- */
710
761
  declare const useOpenOrders: () => {
711
762
  data: OpenLimitOrderDto[] | null;
712
763
  isLoading: boolean;
@@ -729,7 +780,8 @@ interface UserSelectionState {
729
780
  setConflicts: (conflicts: TokenConflict[]) => void;
730
781
  setCandleInterval: (interval: CandleInterval) => void;
731
782
  updateTokenWeight: (isLong: boolean, index: number, newWeight: number) => void;
732
- addToken: (isLong: boolean) => void;
783
+ addToken: (isLong: boolean) => boolean;
784
+ canAddToken: (isLong: boolean) => boolean;
733
785
  removeToken: (isLong: boolean, index: number) => void;
734
786
  handleTokenSelect: (selectedToken: string) => void;
735
787
  setTokenSelections: (longTokens: TokenSelection[], shortTokens: TokenSelection[]) => void;
@@ -744,8 +796,26 @@ declare const useUserSelection: () => UserSelectionState;
744
796
  declare const useWebData: () => {
745
797
  clearinghouseState: ClearinghouseState | null;
746
798
  perpsAtOpenInterestCap: string[] | null;
747
- marketDataBySymbol: Record<string, AssetMarketData>;
748
- hip3Assets: Map<string, string>;
799
+ /**
800
+ * Market data keyed by symbol, with nested market variants.
801
+ * Each symbol maps to its market variants (keyed by prefix).
802
+ * For non-HIP3 assets, use "default" as the key.
803
+ *
804
+ * @example
805
+ * ```ts
806
+ * // HIP-3 asset with multiple markets
807
+ * marketDataBySymbol["TSLA"]["xyz"] // { asset, universe: { collateralToken: "USDC" } }
808
+ * marketDataBySymbol["TSLA"]["flx"] // { asset, universe: { collateralToken: "USDH" } }
809
+ *
810
+ * // Regular asset
811
+ * marketDataBySymbol["BTC"]["default"] // { asset, universe }
812
+ * ```
813
+ */
814
+ marketDataBySymbol: MarketDataBySymbol;
815
+ /** Map of display name -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"]) */
816
+ hip3Assets: Map<string, string[]>;
817
+ /** Map of full market name -> prefix (e.g., "xyz:TSLA" -> "xyz") */
818
+ hip3MarketPrefixes: Map<string, string>;
749
819
  isConnected: boolean;
750
820
  error: string | null;
751
821
  };
@@ -879,6 +949,47 @@ interface CancelTwapResponseDto {
879
949
  cancelledAt: string;
880
950
  }
881
951
  declare function cancelTwapOrder(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
952
+ interface SpotOrderRequestInput {
953
+ /** Asset to buy/sell (e.g., "USDH") */
954
+ asset: string;
955
+ /** Whether to buy (true) or sell (false) the asset */
956
+ isBuy: boolean;
957
+ /** Amount of asset to buy/sell (minimum: 11) */
958
+ amount: number;
959
+ }
960
+ /** Filled order status from Hyperliquid */
961
+ interface SpotOrderFilledStatus {
962
+ filled: {
963
+ totalSz: string;
964
+ avgPx: string;
965
+ oid: number;
966
+ cloid: string;
967
+ };
968
+ }
969
+ /** Hyperliquid order response data */
970
+ interface SpotOrderHyperliquidData {
971
+ statuses: SpotOrderFilledStatus[];
972
+ }
973
+ /** Hyperliquid result from spot order execution */
974
+ interface SpotOrderHyperliquidResult {
975
+ status: 'ok' | 'error';
976
+ response: {
977
+ type: 'order';
978
+ data: SpotOrderHyperliquidData;
979
+ };
980
+ }
981
+ interface SpotOrderResponseDto {
982
+ orderId: string;
983
+ status: 'EXECUTED' | 'FAILED' | 'PENDING';
984
+ asset: string;
985
+ createdAt: string;
986
+ hyperliquidResult?: SpotOrderHyperliquidResult;
987
+ }
988
+ /**
989
+ * Execute a spot order (swap) using Pear Hyperliquid service
990
+ * POST /orders/spot
991
+ */
992
+ declare function executeSpotOrder(baseUrl: string, payload: SpotOrderRequestInput): Promise<ApiResponse<SpotOrderResponseDto>>;
882
993
 
883
994
  type ExecutionType = "MARKET" | "LIMIT" | "TWAP" | "LADDER" | "LIMIT_BTCDOM";
884
995
  type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
@@ -935,8 +1046,9 @@ interface CreatePositionResponseDto {
935
1046
  * Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
936
1047
  * Authorization is derived from headers (Axios defaults or browser localStorage fallback)
937
1048
  * @throws MinimumPositionSizeError if any asset has less than $11 USD value
1049
+ * @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets (15)
938
1050
  */
939
- declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput, displayToFull: Map<string, string>): Promise<ApiResponse<CreatePositionResponseDto>>;
1051
+ declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput, hip3Assets: Map<string, string[]>): Promise<ApiResponse<CreatePositionResponseDto>>;
940
1052
  interface UpdateRiskParametersRequestInput {
941
1053
  stopLoss?: TpSlThresholdInput | null;
942
1054
  takeProfit?: TpSlThresholdInput | null;
@@ -1003,7 +1115,7 @@ interface AdjustAdvanceResponseDto {
1003
1115
  status: string;
1004
1116
  executedAt: string;
1005
1117
  }
1006
- declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[], displayToFull: Map<string, string>): Promise<ApiResponse<AdjustAdvanceResponseDto>>;
1118
+ declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[], hip3Assets: Map<string, string[]>): Promise<ApiResponse<AdjustAdvanceResponseDto>>;
1007
1119
  declare function cancelTwap(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
1008
1120
 
1009
1121
  declare function usePosition(): {
@@ -1025,6 +1137,18 @@ declare function useOrders(): {
1025
1137
  readonly isLoading: boolean;
1026
1138
  };
1027
1139
 
1140
+ interface UseSpotOrderResult {
1141
+ executeSpotOrder: (payload: SpotOrderRequestInput) => Promise<ApiResponse<SpotOrderResponseDto>>;
1142
+ isLoading: boolean;
1143
+ error: ApiErrorResponse | null;
1144
+ resetError: () => void;
1145
+ }
1146
+ /**
1147
+ * Hook for executing spot orders (swaps) on Hyperliquid
1148
+ * Use this to swap between USDC and USDH or other spot assets
1149
+ */
1150
+ declare function useSpotOrder(): UseSpotOrderResult;
1151
+
1028
1152
  declare function useTwap(): {
1029
1153
  readonly orders: TwapMonitoringDto[];
1030
1154
  readonly cancelTwap: (orderId: string) => Promise<ApiResponse<CancelTwapResponseDto>>;
@@ -1046,14 +1170,16 @@ interface UseNotificationsResult {
1046
1170
  */
1047
1171
  declare function useNotifications(): UseNotificationsResult;
1048
1172
 
1173
+ type CollateralFilter = 'USDC' | 'USDH' | 'ALL';
1049
1174
  declare const useMarketDataPayload: () => ActiveAssetsResponse | null;
1050
1175
  declare const useMarketDataAllPayload: () => ActiveAssetsAllResponse | null;
1051
- declare const useActiveBaskets: () => ActiveAssetGroupItem[];
1052
- declare const useTopGainers: (limit?: number) => ActiveAssetGroupItem[];
1053
- declare const useTopLosers: (limit?: number) => ActiveAssetGroupItem[];
1054
- declare const useHighlightedBaskets: () => ActiveAssetGroupItem[];
1055
- declare const useWatchlistBaskets: () => ActiveAssetGroupItem[];
1056
- declare const useAllBaskets: () => ActiveAssetGroupItem[];
1176
+ declare const usePerpMetaAssets: () => UniverseAsset[] | null;
1177
+ declare const useActiveBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
1178
+ declare const useTopGainers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
1179
+ declare const useTopLosers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
1180
+ declare const useHighlightedBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
1181
+ declare const useWatchlistBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
1182
+ declare const useAllBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
1057
1183
  declare const useFindBasket: (longs: string[], shorts: string[]) => ActiveAssetGroupItem | undefined;
1058
1184
 
1059
1185
  declare function useWatchlist(): {
@@ -1126,6 +1252,13 @@ declare function useAuth(): {
1126
1252
  readonly logout: () => Promise<void>;
1127
1253
  };
1128
1254
 
1255
+ interface SpotBalances {
1256
+ usdhBalance: number | undefined;
1257
+ spotUsdcBalance: number | undefined;
1258
+ isLoading: boolean;
1259
+ }
1260
+ declare const useSpotBalances: () => SpotBalances;
1261
+
1129
1262
  interface UseHyperliquidWebSocketProps {
1130
1263
  wsUrl: string;
1131
1264
  address: string | null;
@@ -1160,7 +1293,7 @@ declare function markNotificationReadById(baseUrl: string, id: string): Promise<
1160
1293
  updated: number;
1161
1294
  }>>;
1162
1295
 
1163
- declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[], displayToFull: Map<string, string>): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
1296
+ declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[], hip3Assets: Map<string, string[]>): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
1164
1297
 
1165
1298
  /**
1166
1299
  * Account summary calculation utility class
@@ -1199,24 +1332,28 @@ declare class ConflictDetector {
1199
1332
  declare class TokenMetadataExtractor {
1200
1333
  /**
1201
1334
  * Extracts comprehensive token metadata
1202
- * @param symbol - Token symbol
1335
+ * @param symbol - Token symbol (base symbol without prefix, e.g., "TSLA")
1203
1336
  * @param perpMetaAssets - Aggregated universe assets (flattened across dexes)
1204
1337
  * @param finalAssetContexts - Aggregated asset contexts (flattened across dexes)
1205
1338
  * @param allMids - AllMids data containing current prices
1206
1339
  * @param activeAssetData - Optional active asset data containing leverage information
1340
+ * @param marketPrefix - Optional market prefix (e.g., "xyz", "flx") for HIP3 multi-market assets
1207
1341
  * @returns TokenMetadata or null if token not found
1208
1342
  */
1209
- static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): TokenMetadata | null;
1343
+ static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null, marketPrefix?: string | null): TokenMetadata | null;
1210
1344
  /**
1211
1345
  * Extracts metadata for multiple tokens
1212
- * @param symbols - Array of token symbols
1346
+ * @param tokens - Array of token objects with symbol and optional marketPrefix
1213
1347
  * @param perpMetaAssets - Aggregated universe assets
1214
1348
  * @param finalAssetContexts - Aggregated asset contexts
1215
1349
  * @param allMids - AllMids data
1216
1350
  * @param activeAssetData - Optional active asset data containing leverage information
1217
- * @returns Record of symbol to TokenMetadata
1351
+ * @returns Record of unique key to TokenMetadata. Key is "{prefix}:{symbol}" for HIP3 assets, or just "{symbol}" otherwise
1218
1352
  */
1219
- static extractMultipleTokensMetadata(symbols: string[], perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): Record<string, TokenMetadata | null>;
1353
+ static extractMultipleTokensMetadata(tokens: Array<{
1354
+ symbol: string;
1355
+ marketPrefix?: string | null;
1356
+ }>, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): Record<string, TokenMetadata | null>;
1220
1357
  /**
1221
1358
  * Checks if token data is available in aggregated universe assets
1222
1359
  * @param symbol - Token symbol
@@ -1263,6 +1400,10 @@ declare function mapCandleIntervalToTradingViewInterval(interval: CandleInterval
1263
1400
  * Minimum USD value required per asset when creating a position
1264
1401
  */
1265
1402
  declare const MINIMUM_ASSET_USD_VALUE = 11;
1403
+ /**
1404
+ * Maximum number of assets allowed per leg (long or short) in a position
1405
+ */
1406
+ declare const MAX_ASSETS_PER_LEG = 15;
1266
1407
  /**
1267
1408
  * Validation error for minimum position size
1268
1409
  */
@@ -1272,6 +1413,22 @@ declare class MinimumPositionSizeError extends Error {
1272
1413
  minimumRequired: number;
1273
1414
  constructor(assetName: string, assetValue: number, minimumRequired: number);
1274
1415
  }
1416
+ /**
1417
+ * Validation error for exceeding maximum assets per leg
1418
+ */
1419
+ declare class MaxAssetsPerLegError extends Error {
1420
+ leg: "long" | "short";
1421
+ assetCount: number;
1422
+ maxAllowed: number;
1423
+ constructor(leg: "long" | "short", assetCount: number, maxAllowed: number);
1424
+ }
1425
+ /**
1426
+ * Validates that each leg doesn't exceed the maximum number of assets
1427
+ * @param longAssets Array of long assets
1428
+ * @param shortAssets Array of short assets
1429
+ * @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets
1430
+ */
1431
+ declare function validateMaxAssetsPerLeg(longAssets?: PairAssetInput[], shortAssets?: PairAssetInput[]): void;
1275
1432
  /**
1276
1433
  * Validates that each asset in a position has at least the minimum USD value
1277
1434
  * @param usdValue Total USD value for the position
@@ -1300,7 +1457,48 @@ declare function validatePositionSize(usdValue: number, longAssets?: PairAssetIn
1300
1457
  minimumRequired?: number;
1301
1458
  };
1302
1459
 
1460
+ /**
1461
+ * Convert a full/prefixed symbol (e.g., "xyz:XYZ100") to a display symbol (e.g., "XYZ100").
1462
+ */
1463
+ declare function toDisplaySymbol(symbol: string): string;
1464
+ /**
1465
+ * Convert a display symbol back to backend form using a provided map.
1466
+ * If mapping is missing, returns the original symbol.
1467
+ * For multi-market assets, returns the first available market.
1468
+ * @param displaySymbol e.g., "TSLA"
1469
+ * @param hip3Assets map of display -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"])
1470
+ */
1471
+ declare function toBackendSymbol(displaySymbol: string, hip3Assets: Map<string, string[]>): string;
1472
+ /**
1473
+ * Convert a display symbol to backend form for a specific market prefix.
1474
+ * This is useful when an asset is available on multiple markets (e.g., xyz:TSLA and flx:TSLA).
1475
+ * @param displaySymbol e.g., "TSLA"
1476
+ * @param marketPrefix e.g., "xyz" or "flx"
1477
+ * @param hip3Assets map of display -> all full market names
1478
+ * @returns Full market name if found, null if prefix not specified for multi-market asset, otherwise displaySymbol with prefix
1479
+ */
1480
+ declare function toBackendSymbolWithMarket(displaySymbol: string, marketPrefix: string | undefined, hip3Assets: Map<string, string[]>): string | null;
1481
+ /**
1482
+ * Get all available markets for a display symbol.
1483
+ * @param displaySymbol e.g., "TSLA"
1484
+ * @param hip3Assets map of display -> all full market names
1485
+ * @returns Array of full market names, e.g., ["xyz:TSLA", "flx:TSLA"]
1486
+ */
1487
+ declare function getAvailableMarkets(displaySymbol: string, hip3Assets: Map<string, string[]>): string[];
1488
+ /**
1489
+ * Extract the market prefix from a full market name.
1490
+ * @param fullSymbol e.g., "xyz:TSLA"
1491
+ * @returns The prefix (e.g., "xyz") or undefined if no prefix
1492
+ */
1493
+ declare function getMarketPrefix(fullSymbol: string): string | undefined;
1494
+ /**
1495
+ * Check if a symbol is a HIP-3 market (has a prefix).
1496
+ * @param symbol e.g., "xyz:TSLA" or "TSLA"
1497
+ * @returns true if the symbol has a market prefix
1498
+ */
1499
+ declare function isHip3Market(symbol: string): boolean;
1500
+
1303
1501
  declare const useMarketData: any;
1304
1502
 
1305
- export { AccountSummaryCalculator, ConflictDetector, MINIMUM_ASSET_USD_VALUE, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, getPortfolio, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, 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, validateMinimumAssetSize, validatePositionSize };
1306
- 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, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseNotificationsResult, UsePerformanceOverlaysReturn, UsePortfolioResult, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WatchlistItemDto, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
1503
+ 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, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllBaskets, useAuth, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMarketData, useMarketDataAllPayload, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePerpMetaAssets, usePortfolio, usePosition, useSpotBalances, useSpotOrder, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWatchlist, useWatchlistBaskets, useWebData, validateMaxAssetsPerLeg, validateMinimumAssetSize, validatePositionSize };
1504
+ 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, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseNotificationsResult, UsePerformanceOverlaysReturn, UsePortfolioResult, UseSpotOrderResult, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WatchlistItemDto, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };