@pear-protocol/hyperliquid-sdk 0.0.73-beta.2 → 0.0.73-beta.5
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/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 -40
- package/dist/index.js +1264 -199
- package/dist/provider.d.ts +1 -1
- package/dist/store/hyperliquidDataStore.d.ts +9 -3
- package/dist/store/userDataStore.d.ts +3 -1
- 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/provider.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActiveAssetData, CandleChartData, CandleData, ClearinghouseState, UniverseAsset, WebData3AssetCtx, WsAllMidsData } from
|
|
1
|
+
import { ActiveAssetData, CandleChartData, CandleData, ClearinghouseState, UniverseAsset, WebData3AssetCtx, WsAllMidsData } from '../types';
|
|
2
2
|
interface HyperliquidDataState {
|
|
3
3
|
allMids: WsAllMidsData | null;
|
|
4
4
|
activeAssetData: Record<string, ActiveAssetData> | null;
|
|
@@ -6,8 +6,11 @@ interface HyperliquidDataState {
|
|
|
6
6
|
finalAssetContexts: WebData3AssetCtx[] | null;
|
|
7
7
|
finalAtOICaps: string[] | null;
|
|
8
8
|
aggregatedClearingHouseState: ClearinghouseState | null;
|
|
9
|
+
rawClearinghouseStates: [string, ClearinghouseState][] | null;
|
|
9
10
|
perpMetaAssets: UniverseAsset[] | null;
|
|
10
|
-
|
|
11
|
+
allPerpMetaAssets: UniverseAsset[] | null;
|
|
12
|
+
hip3Assets: Map<string, string[]>;
|
|
13
|
+
hip3MarketPrefixes: Map<string, string>;
|
|
11
14
|
setAllMids: (value: WsAllMidsData | null) => void;
|
|
12
15
|
setActiveAssetData: (value: Record<string, ActiveAssetData> | null | ((prev: Record<string, ActiveAssetData> | null) => Record<string, ActiveAssetData> | null)) => void;
|
|
13
16
|
deleteActiveAssetData: (key: string) => void;
|
|
@@ -18,8 +21,11 @@ interface HyperliquidDataState {
|
|
|
18
21
|
setFinalAssetContexts: (value: WebData3AssetCtx[] | null) => void;
|
|
19
22
|
setFinalAtOICaps: (value: string[] | null) => void;
|
|
20
23
|
setAggregatedClearingHouseState: (value: ClearinghouseState | null) => void;
|
|
24
|
+
setRawClearinghouseStates: (value: [string, ClearinghouseState][] | null) => void;
|
|
21
25
|
setPerpMetaAssets: (value: UniverseAsset[] | null) => void;
|
|
22
|
-
|
|
26
|
+
setAllPerpMetaAssets: (value: UniverseAsset[] | null) => void;
|
|
27
|
+
setHip3Assets: (value: Map<string, string[]>) => void;
|
|
28
|
+
setHip3MarketPrefixes: (value: Map<string, string>) => void;
|
|
23
29
|
}
|
|
24
30
|
export declare const useHyperliquidData: import("zustand").UseBoundStore<import("zustand").StoreApi<HyperliquidDataState>>;
|
|
25
31
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlatformAccountSummaryResponseDto, OpenLimitOrderDto, RawPositionDto, TradeHistoryDataDto, TwapMonitoringDto, NotificationDto, ExtraAgent } from "../types";
|
|
1
|
+
import { PlatformAccountSummaryResponseDto, OpenLimitOrderDto, RawPositionDto, TradeHistoryDataDto, TwapMonitoringDto, NotificationDto, ExtraAgent, SpotState } from "../types";
|
|
2
2
|
interface UserDataState {
|
|
3
3
|
accessToken: string | null;
|
|
4
4
|
refreshToken: string | null;
|
|
@@ -12,6 +12,7 @@ interface UserDataState {
|
|
|
12
12
|
twapDetails: TwapMonitoringDto[] | null;
|
|
13
13
|
notifications: NotificationDto[] | null;
|
|
14
14
|
userExtraAgents: ExtraAgent[] | null;
|
|
15
|
+
spotState: SpotState | null;
|
|
15
16
|
setAccessToken: (token: string | null) => void;
|
|
16
17
|
setRefreshToken: (token: string | null) => void;
|
|
17
18
|
setIsAuthenticated: (value: boolean) => void;
|
|
@@ -24,6 +25,7 @@ interface UserDataState {
|
|
|
24
25
|
setUserExtraAgents: (value: ExtraAgent[] | null) => void;
|
|
25
26
|
setTwapDetails: (value: TwapMonitoringDto[] | null) => void;
|
|
26
27
|
setNotifications: (value: NotificationDto[] | null) => void;
|
|
28
|
+
setSpotState: (value: SpotState | null) => void;
|
|
27
29
|
clean: () => void;
|
|
28
30
|
}
|
|
29
31
|
export declare const useUserData: import("zustand").UseBoundStore<import("zustand").StoreApi<UserDataState>>;
|
package/dist/types.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface ExternalFillDto {
|
|
|
20
20
|
coin: string;
|
|
21
21
|
px: string;
|
|
22
22
|
sz: string;
|
|
23
|
-
side:
|
|
23
|
+
side: 'B' | 'A';
|
|
24
24
|
time: number;
|
|
25
25
|
dir: string;
|
|
26
26
|
fee: string;
|
|
@@ -52,7 +52,7 @@ export interface TwapSliceFillResponseItem {
|
|
|
52
52
|
/**
|
|
53
53
|
* WebSocket connection states
|
|
54
54
|
*/
|
|
55
|
-
export type WebSocketConnectionState =
|
|
55
|
+
export type WebSocketConnectionState = 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
56
56
|
export declare enum ReadyState {
|
|
57
57
|
CONNECTING = 0,
|
|
58
58
|
OPEN = 1,
|
|
@@ -62,12 +62,12 @@ export declare enum ReadyState {
|
|
|
62
62
|
/**
|
|
63
63
|
* WebSocket channels
|
|
64
64
|
*/
|
|
65
|
-
export type WebSocketChannel =
|
|
65
|
+
export type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'twap-details' | 'notifications' | 'market-data' | 'market-data-all' | 'webData3' | 'allMids' | 'activeAssetData';
|
|
66
66
|
/**
|
|
67
67
|
* WebSocket subscription message
|
|
68
68
|
*/
|
|
69
69
|
export interface WebSocketSubscribeMessage {
|
|
70
|
-
action?:
|
|
70
|
+
action?: 'subscribe' | 'unsubscribe';
|
|
71
71
|
address: string;
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
@@ -97,7 +97,7 @@ export interface WatchlistItemDto {
|
|
|
97
97
|
export interface ToggleWatchlistResponseDto {
|
|
98
98
|
items: WatchlistItemDto[];
|
|
99
99
|
}
|
|
100
|
-
export type NotificationCategory =
|
|
100
|
+
export 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';
|
|
101
101
|
export interface NotificationDto {
|
|
102
102
|
id: string;
|
|
103
103
|
address: string;
|
|
@@ -114,7 +114,7 @@ export interface ChunkFillDto {
|
|
|
114
114
|
size: number;
|
|
115
115
|
executedAt: string;
|
|
116
116
|
}
|
|
117
|
-
export type TwapChunkStatus =
|
|
117
|
+
export type TwapChunkStatus = 'PENDING' | 'SCHEDULED' | 'EXECUTING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';
|
|
118
118
|
export interface TwapChunkStatusDto {
|
|
119
119
|
chunkId: string;
|
|
120
120
|
chunkIndex: number;
|
|
@@ -125,7 +125,7 @@ export interface TwapChunkStatusDto {
|
|
|
125
125
|
fills: ChunkFillDto[];
|
|
126
126
|
errorMessage?: string;
|
|
127
127
|
}
|
|
128
|
-
export type TwapOrderOverallStatus =
|
|
128
|
+
export type TwapOrderOverallStatus = 'OPEN' | 'EXECUTING' | 'COMPLETED' | 'PARTIALLY_COMPLETED' | 'FAILED' | 'CANCELLED';
|
|
129
129
|
export interface TwapMonitoringDto {
|
|
130
130
|
orderId: string;
|
|
131
131
|
positionId?: string;
|
|
@@ -162,6 +162,8 @@ export interface TradeHistoryAssetDataDto {
|
|
|
162
162
|
externalFeePaid: number;
|
|
163
163
|
builderFeePaid: number;
|
|
164
164
|
realizedPnl: number;
|
|
165
|
+
marketPrefix?: string | null;
|
|
166
|
+
collateralToken?: CollateralToken;
|
|
165
167
|
}
|
|
166
168
|
/**
|
|
167
169
|
* Trade history data structure
|
|
@@ -210,9 +212,11 @@ export interface PositionAssetDetailDto {
|
|
|
210
212
|
liquidationPrice: number;
|
|
211
213
|
initialWeight: number;
|
|
212
214
|
fundingPaid?: number;
|
|
215
|
+
marketPrefix?: string | null;
|
|
216
|
+
collateralToken?: CollateralToken;
|
|
213
217
|
}
|
|
214
218
|
export interface TpSlThreshold {
|
|
215
|
-
type:
|
|
219
|
+
type: 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
|
|
216
220
|
value: number;
|
|
217
221
|
}
|
|
218
222
|
/**
|
|
@@ -243,20 +247,22 @@ export interface OpenPositionDto {
|
|
|
243
247
|
export interface OrderAssetDto {
|
|
244
248
|
asset: string;
|
|
245
249
|
weight: number;
|
|
250
|
+
marketPrefix?: string | null;
|
|
251
|
+
collateralToken?: CollateralToken;
|
|
246
252
|
}
|
|
247
253
|
/**
|
|
248
254
|
* Order status
|
|
249
255
|
*/
|
|
250
|
-
export type OrderStatus =
|
|
256
|
+
export type OrderStatus = 'OPEN' | 'PARTIALLY_FILLED' | 'PROCESSING';
|
|
251
257
|
/**
|
|
252
258
|
* Order type
|
|
253
259
|
*/
|
|
254
|
-
export type OrderType =
|
|
260
|
+
export type OrderType = 'TP' | 'SL' | 'LIMIT' | 'MARKET' | 'LIMIT_BTCDOM' | 'TWAP';
|
|
255
261
|
/**
|
|
256
262
|
* TP/SL trigger type
|
|
257
263
|
*/
|
|
258
|
-
export type TpSlTriggerType =
|
|
259
|
-
export type OrderDirection =
|
|
264
|
+
export type TpSlTriggerType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
|
|
265
|
+
export type OrderDirection = 'MORE_THAN' | 'LESS_THAN' | null;
|
|
260
266
|
/**
|
|
261
267
|
* Open limit order data structure
|
|
262
268
|
*/
|
|
@@ -370,7 +376,7 @@ export interface PrivyAuthDetails {
|
|
|
370
376
|
accessToken: string;
|
|
371
377
|
}
|
|
372
378
|
export interface AuthenticateRequest {
|
|
373
|
-
method:
|
|
379
|
+
method: 'eip712' | 'api_key' | 'privy_access_token';
|
|
374
380
|
address: string;
|
|
375
381
|
clientId: string;
|
|
376
382
|
details: {
|
|
@@ -403,7 +409,7 @@ export interface LogoutRequest {
|
|
|
403
409
|
export interface LogoutResponse {
|
|
404
410
|
message: string;
|
|
405
411
|
}
|
|
406
|
-
export type AgentWalletStatus =
|
|
412
|
+
export type AgentWalletStatus = 'ACTIVE' | 'EXPIRED' | 'NOT_FOUND';
|
|
407
413
|
export interface GetAgentWalletResponseDto {
|
|
408
414
|
agentWalletAddress?: string;
|
|
409
415
|
agentName: string;
|
|
@@ -421,14 +427,14 @@ export interface ExtraAgent {
|
|
|
421
427
|
export interface AgentWalletState {
|
|
422
428
|
address: string | null;
|
|
423
429
|
name: string | null;
|
|
424
|
-
status: AgentWalletStatus |
|
|
430
|
+
status: AgentWalletStatus | 'PENDING' | null;
|
|
425
431
|
isActive: boolean;
|
|
426
432
|
}
|
|
427
433
|
/**
|
|
428
434
|
* WebSocket message from HyperLiquid native API
|
|
429
435
|
*/
|
|
430
436
|
export interface WebSocketMessage {
|
|
431
|
-
method:
|
|
437
|
+
method: 'subscribe' | 'unsubscribe';
|
|
432
438
|
subscription: {
|
|
433
439
|
type: string;
|
|
434
440
|
dex?: string;
|
|
@@ -441,12 +447,16 @@ export interface WebSocketMessage {
|
|
|
441
447
|
/**
|
|
442
448
|
* WebSocket response from HyperLiquid native API
|
|
443
449
|
*/
|
|
444
|
-
export type HLChannel =
|
|
450
|
+
export type HLChannel = 'webData3' | 'allMids' | 'activeAssetData' | 'candle' | 'spotState' | 'allDexsClearinghouseState' | 'allDexsAssetCtxs';
|
|
445
451
|
export interface HLChannelDataMap {
|
|
446
452
|
webData3: WebData3Response;
|
|
447
453
|
allMids: WsAllMidsData;
|
|
448
454
|
activeAssetData: ActiveAssetData;
|
|
449
455
|
candle: CandleData;
|
|
456
|
+
spotState: {
|
|
457
|
+
user: string;
|
|
458
|
+
spotState: SpotState;
|
|
459
|
+
};
|
|
450
460
|
allDexsClearinghouseState: AllDexsClearinghouseStateData;
|
|
451
461
|
allDexsAssetCtxs: AllDexsAssetCtxsData;
|
|
452
462
|
}
|
|
@@ -511,6 +521,12 @@ export interface AssetCtx {
|
|
|
511
521
|
impactPxs?: string[];
|
|
512
522
|
oraclePx: string;
|
|
513
523
|
}
|
|
524
|
+
/**
|
|
525
|
+
* Collateral token type
|
|
526
|
+
* 0 = USDC
|
|
527
|
+
* 360 = USDH
|
|
528
|
+
*/
|
|
529
|
+
export type CollateralToken = 'USDC' | 'USDH';
|
|
514
530
|
/**
|
|
515
531
|
* Universe asset metadata
|
|
516
532
|
*/
|
|
@@ -520,6 +536,8 @@ export interface UniverseAsset {
|
|
|
520
536
|
maxLeverage: number;
|
|
521
537
|
onlyIsolated?: boolean;
|
|
522
538
|
isDelisted?: boolean;
|
|
539
|
+
marketPrefix?: string;
|
|
540
|
+
collateralToken?: CollateralToken;
|
|
523
541
|
}
|
|
524
542
|
export interface PerpMetaAsset extends UniverseAsset {
|
|
525
543
|
marginTableId: number;
|
|
@@ -608,6 +626,8 @@ export interface RawAssetDto {
|
|
|
608
626
|
size: number;
|
|
609
627
|
side: string;
|
|
610
628
|
fundingPaid?: number;
|
|
629
|
+
marketPrefix?: string | null;
|
|
630
|
+
collateralToken?: CollateralToken;
|
|
611
631
|
leverage: number;
|
|
612
632
|
}
|
|
613
633
|
/**
|
|
@@ -656,6 +676,7 @@ export interface TokenMetadata {
|
|
|
656
676
|
leverage?: LeverageInfo;
|
|
657
677
|
maxTradeSzs?: [string, string];
|
|
658
678
|
availableToTrade?: [string, string];
|
|
679
|
+
collateralToken?: CollateralToken;
|
|
659
680
|
}
|
|
660
681
|
/**
|
|
661
682
|
* Enhanced token selection with weight and metadata for basket trading
|
|
@@ -669,16 +690,37 @@ export interface TokenSelection {
|
|
|
669
690
|
*/
|
|
670
691
|
export interface TokenConflict {
|
|
671
692
|
symbol: string;
|
|
672
|
-
conflictType:
|
|
693
|
+
conflictType: 'long' | 'short';
|
|
673
694
|
conflictMessage: string;
|
|
674
695
|
}
|
|
675
696
|
export interface AssetMarketData {
|
|
676
697
|
asset: WebData3AssetCtx | AssetCtx;
|
|
677
698
|
universe: UniverseAsset;
|
|
678
699
|
}
|
|
700
|
+
/**
|
|
701
|
+
* Nested market data structure for multi-market assets.
|
|
702
|
+
* Each symbol maps to its market variants (keyed by prefix).
|
|
703
|
+
* For non-HIP3 assets, use "default" as the key.
|
|
704
|
+
*
|
|
705
|
+
* @example
|
|
706
|
+
* ```ts
|
|
707
|
+
* {
|
|
708
|
+
* "TSLA": {
|
|
709
|
+
* "xyz": { asset: {...}, universe: { collateralToken: "USDC", ... } },
|
|
710
|
+
* "flx": { asset: {...}, universe: { collateralToken: "USDH", ... } }
|
|
711
|
+
* },
|
|
712
|
+
* "BTC": {
|
|
713
|
+
* "default": { asset: {...}, universe: {...} }
|
|
714
|
+
* }
|
|
715
|
+
* }
|
|
716
|
+
* ```
|
|
717
|
+
*/
|
|
718
|
+
export type MarketDataBySymbol = Record<string, Record<string, AssetMarketData>>;
|
|
679
719
|
export interface PairAssetDto {
|
|
680
720
|
asset: string;
|
|
681
721
|
weight: number;
|
|
722
|
+
collateralToken: CollateralToken;
|
|
723
|
+
marketPrefix: string | null;
|
|
682
724
|
}
|
|
683
725
|
export interface ActiveAssetGroupItem {
|
|
684
726
|
longAssets: PairAssetDto[];
|
|
@@ -692,6 +734,7 @@ export interface ActiveAssetGroupItem {
|
|
|
692
734
|
weightedRatio?: string;
|
|
693
735
|
weightedPrevRatio?: string;
|
|
694
736
|
weightedChange24h?: string;
|
|
737
|
+
collateralType: 'USDC' | 'USDH' | 'MIXED';
|
|
695
738
|
}
|
|
696
739
|
export interface ActiveAssetsResponse {
|
|
697
740
|
active: ActiveAssetGroupItem[];
|
|
@@ -709,7 +752,7 @@ export interface ActiveAssetsAllResponse {
|
|
|
709
752
|
/**
|
|
710
753
|
* Candle interval options
|
|
711
754
|
*/
|
|
712
|
-
export type CandleInterval =
|
|
755
|
+
export type CandleInterval = '1m' | '3m' | '5m' | '15m' | '30m' | '1h' | '2h' | '4h' | '8h' | '12h' | '1d' | '3d' | '1w' | '1M';
|
|
713
756
|
/**
|
|
714
757
|
* Candle data structure from WebSocket
|
|
715
758
|
*/
|
|
@@ -737,9 +780,20 @@ export interface CandleSnapshotRequest {
|
|
|
737
780
|
endTime: number;
|
|
738
781
|
interval: CandleInterval;
|
|
739
782
|
};
|
|
740
|
-
type:
|
|
783
|
+
type: 'candleSnapshot';
|
|
741
784
|
}
|
|
742
785
|
export interface TokenSelectorConfig {
|
|
743
786
|
isLong: boolean;
|
|
744
787
|
index: number;
|
|
745
788
|
}
|
|
789
|
+
export interface SpotBalance {
|
|
790
|
+
coin: string;
|
|
791
|
+
token: number;
|
|
792
|
+
total: string;
|
|
793
|
+
hold: string;
|
|
794
|
+
entryNtl: string;
|
|
795
|
+
}
|
|
796
|
+
export interface SpotState {
|
|
797
|
+
user: string;
|
|
798
|
+
balances: SpotBalance[];
|
|
799
|
+
}
|
|
@@ -5,7 +5,36 @@ export declare function toDisplaySymbol(symbol: string): string;
|
|
|
5
5
|
/**
|
|
6
6
|
* Convert a display symbol back to backend form using a provided map.
|
|
7
7
|
* If mapping is missing, returns the original symbol.
|
|
8
|
-
*
|
|
9
|
-
* @param
|
|
8
|
+
* For multi-market assets, returns the first available market.
|
|
9
|
+
* @param displaySymbol e.g., "TSLA"
|
|
10
|
+
* @param hip3Assets map of display -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"])
|
|
10
11
|
*/
|
|
11
|
-
export declare function toBackendSymbol(displaySymbol: string,
|
|
12
|
+
export declare function toBackendSymbol(displaySymbol: string, hip3Assets: Map<string, string[]>): string;
|
|
13
|
+
/**
|
|
14
|
+
* Convert a display symbol to backend form for a specific market prefix.
|
|
15
|
+
* This is useful when an asset is available on multiple markets (e.g., xyz:TSLA and flx:TSLA).
|
|
16
|
+
* @param displaySymbol e.g., "TSLA"
|
|
17
|
+
* @param marketPrefix e.g., "xyz" or "flx"
|
|
18
|
+
* @param hip3Assets map of display -> all full market names
|
|
19
|
+
* @returns Full market name if found, null if prefix not specified for multi-market asset, otherwise displaySymbol with prefix
|
|
20
|
+
*/
|
|
21
|
+
export declare function toBackendSymbolWithMarket(displaySymbol: string, marketPrefix: string | undefined, hip3Assets: Map<string, string[]>): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Get all available markets for a display symbol.
|
|
24
|
+
* @param displaySymbol e.g., "TSLA"
|
|
25
|
+
* @param hip3Assets map of display -> all full market names
|
|
26
|
+
* @returns Array of full market names, e.g., ["xyz:TSLA", "flx:TSLA"]
|
|
27
|
+
*/
|
|
28
|
+
export declare function getAvailableMarkets(displaySymbol: string, hip3Assets: Map<string, string[]>): string[];
|
|
29
|
+
/**
|
|
30
|
+
* Extract the market prefix from a full market name.
|
|
31
|
+
* @param fullSymbol e.g., "xyz:TSLA"
|
|
32
|
+
* @returns The prefix (e.g., "xyz") or undefined if no prefix
|
|
33
|
+
*/
|
|
34
|
+
export declare function getMarketPrefix(fullSymbol: string): string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Check if a symbol is a HIP-3 market (has a prefix).
|
|
37
|
+
* @param symbol e.g., "xyz:TSLA" or "TSLA"
|
|
38
|
+
* @returns true if the symbol has a market prefix
|
|
39
|
+
*/
|
|
40
|
+
export declare function isHip3Market(symbol: string): boolean;
|
|
@@ -5,24 +5,28 @@ import type { WsAllMidsData, TokenMetadata, ActiveAssetData, UniverseAsset, WebD
|
|
|
5
5
|
export declare class TokenMetadataExtractor {
|
|
6
6
|
/**
|
|
7
7
|
* Extracts comprehensive token metadata
|
|
8
|
-
* @param symbol - Token symbol
|
|
8
|
+
* @param symbol - Token symbol (base symbol without prefix, e.g., "TSLA")
|
|
9
9
|
* @param perpMetaAssets - Aggregated universe assets (flattened across dexes)
|
|
10
10
|
* @param finalAssetContexts - Aggregated asset contexts (flattened across dexes)
|
|
11
11
|
* @param allMids - AllMids data containing current prices
|
|
12
12
|
* @param activeAssetData - Optional active asset data containing leverage information
|
|
13
|
+
* @param marketPrefix - Optional market prefix (e.g., "xyz", "flx") for HIP3 multi-market assets
|
|
13
14
|
* @returns TokenMetadata or null if token not found
|
|
14
15
|
*/
|
|
15
|
-
static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): TokenMetadata | null;
|
|
16
|
+
static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null, marketPrefix?: string | null): TokenMetadata | null;
|
|
16
17
|
/**
|
|
17
18
|
* Extracts metadata for multiple tokens
|
|
18
|
-
* @param
|
|
19
|
+
* @param tokens - Array of token objects with symbol and optional marketPrefix
|
|
19
20
|
* @param perpMetaAssets - Aggregated universe assets
|
|
20
21
|
* @param finalAssetContexts - Aggregated asset contexts
|
|
21
22
|
* @param allMids - AllMids data
|
|
22
23
|
* @param activeAssetData - Optional active asset data containing leverage information
|
|
23
|
-
* @returns Record of
|
|
24
|
+
* @returns Record of unique key to TokenMetadata. Key is "{prefix}:{symbol}" for HIP3 assets, or just "{symbol}" otherwise
|
|
24
25
|
*/
|
|
25
|
-
static extractMultipleTokensMetadata(
|
|
26
|
+
static extractMultipleTokensMetadata(tokens: Array<{
|
|
27
|
+
symbol: string;
|
|
28
|
+
marketPrefix?: string | null;
|
|
29
|
+
}>, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): Record<string, TokenMetadata | null>;
|
|
26
30
|
/**
|
|
27
31
|
* Checks if token data is available in aggregated universe assets
|
|
28
32
|
* @param symbol - Token symbol
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pear-protocol/hyperliquid-sdk",
|
|
3
|
-
"version": "0.0.73-beta.
|
|
3
|
+
"version": "0.0.73-beta.5",
|
|
4
4
|
"description": "React SDK for Pear Protocol Hyperliquid API integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"axios": "^1.6.0",
|
|
28
|
-
"zustand": "^5.0.
|
|
28
|
+
"zustand": "^5.0.9"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": "^18.0.0",
|