@pear-protocol/hyperliquid-sdk 0.0.72 → 0.0.73-beta-2
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/kalshi.d.ts +87 -0
- 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/useOrders.d.ts +2 -3
- 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 +490 -95
- package/dist/index.js +1674 -354
- 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 +147 -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,26 @@ 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
|
+
}
|
|
813
|
+
interface EnrichedOpenLimitOrderDto extends OpenLimitOrderDto {
|
|
814
|
+
marketTitle?: string;
|
|
815
|
+
}
|
|
698
816
|
|
|
699
817
|
declare const useAccountSummary: () => {
|
|
700
818
|
data: AccountSummaryResponseDto | null;
|
|
@@ -705,9 +823,6 @@ declare const useTradeHistories: () => {
|
|
|
705
823
|
data: TradeHistoryDataDto[] | null;
|
|
706
824
|
isLoading: boolean;
|
|
707
825
|
};
|
|
708
|
-
/**
|
|
709
|
-
* Hook to access open orders with loading state
|
|
710
|
-
*/
|
|
711
826
|
declare const useOpenOrders: () => {
|
|
712
827
|
data: OpenLimitOrderDto[] | null;
|
|
713
828
|
isLoading: boolean;
|
|
@@ -746,8 +861,26 @@ declare const useUserSelection: () => UserSelectionState;
|
|
|
746
861
|
declare const useWebData: () => {
|
|
747
862
|
clearinghouseState: ClearinghouseState | null;
|
|
748
863
|
perpsAtOpenInterestCap: string[] | null;
|
|
749
|
-
|
|
750
|
-
|
|
864
|
+
/**
|
|
865
|
+
* Market data keyed by symbol, with nested market variants.
|
|
866
|
+
* Each symbol maps to its market variants (keyed by prefix).
|
|
867
|
+
* For non-HIP3 assets, use "default" as the key.
|
|
868
|
+
*
|
|
869
|
+
* @example
|
|
870
|
+
* ```ts
|
|
871
|
+
* // HIP-3 asset with multiple markets
|
|
872
|
+
* marketDataBySymbol["TSLA"]["xyz"] // { asset, universe: { collateralToken: "USDC" } }
|
|
873
|
+
* marketDataBySymbol["TSLA"]["flx"] // { asset, universe: { collateralToken: "USDH" } }
|
|
874
|
+
*
|
|
875
|
+
* // Regular asset
|
|
876
|
+
* marketDataBySymbol["BTC"]["default"] // { asset, universe }
|
|
877
|
+
* ```
|
|
878
|
+
*/
|
|
879
|
+
marketDataBySymbol: MarketDataBySymbol;
|
|
880
|
+
/** Map of display name -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"]) */
|
|
881
|
+
hip3Assets: Map<string, string[]>;
|
|
882
|
+
/** Map of full market name -> prefix (e.g., "xyz:TSLA" -> "xyz") */
|
|
883
|
+
hip3MarketPrefixes: Map<string, string>;
|
|
751
884
|
isConnected: boolean;
|
|
752
885
|
error: string | null;
|
|
753
886
|
};
|
|
@@ -781,7 +914,18 @@ interface TokenHistoricalPriceData {
|
|
|
781
914
|
oldestTime: number | null;
|
|
782
915
|
latestTime: number | null;
|
|
783
916
|
}
|
|
784
|
-
|
|
917
|
+
interface HistoricalPriceDataState {
|
|
918
|
+
historicalPriceData: Record<string, TokenHistoricalPriceData>;
|
|
919
|
+
loadingTokens: Set<string>;
|
|
920
|
+
addHistoricalPriceData: (symbol: string, interval: CandleInterval, candles: CandleData[], range: HistoricalRange) => void;
|
|
921
|
+
hasHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => boolean;
|
|
922
|
+
getHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => CandleData[];
|
|
923
|
+
setTokenLoading: (symbol: string, loading: boolean) => void;
|
|
924
|
+
isTokenLoading: (symbol: string) => boolean;
|
|
925
|
+
removeTokenPriceData: (symbol: string, interval: CandleInterval) => void;
|
|
926
|
+
clearData: () => void;
|
|
927
|
+
}
|
|
928
|
+
declare const useHistoricalPriceDataStore: zustand.UseBoundStore<zustand.StoreApi<HistoricalPriceDataState>>;
|
|
785
929
|
|
|
786
930
|
interface UseHistoricalPriceDataReturn {
|
|
787
931
|
fetchHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval, callback?: (data: Record<string, CandleData[]>) => void) => Promise<Record<string, CandleData[]>>;
|
|
@@ -839,25 +983,6 @@ declare function useAgentWallet(): {
|
|
|
839
983
|
readonly notifyAgentWalletApproved: () => Promise<void>;
|
|
840
984
|
};
|
|
841
985
|
|
|
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
986
|
interface AdjustOrderRequestInput {
|
|
862
987
|
limitRatio?: number;
|
|
863
988
|
usdValue?: number;
|
|
@@ -881,9 +1006,51 @@ interface CancelTwapResponseDto {
|
|
|
881
1006
|
cancelledAt: string;
|
|
882
1007
|
}
|
|
883
1008
|
declare function cancelTwapOrder(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
1009
|
+
interface SpotOrderRequestInput {
|
|
1010
|
+
/** Asset to buy/sell (e.g., "USDH") */
|
|
1011
|
+
asset: string;
|
|
1012
|
+
/** Whether to buy (true) or sell (false) the asset */
|
|
1013
|
+
isBuy: boolean;
|
|
1014
|
+
/** Amount of asset to buy/sell (minimum: 11) */
|
|
1015
|
+
amount: number;
|
|
1016
|
+
}
|
|
1017
|
+
/** Filled order status from Hyperliquid */
|
|
1018
|
+
interface SpotOrderFilledStatus {
|
|
1019
|
+
filled: {
|
|
1020
|
+
totalSz: string;
|
|
1021
|
+
avgPx: string;
|
|
1022
|
+
oid: number;
|
|
1023
|
+
cloid: string;
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
/** Hyperliquid order response data */
|
|
1027
|
+
interface SpotOrderHyperliquidData {
|
|
1028
|
+
statuses: SpotOrderFilledStatus[];
|
|
1029
|
+
}
|
|
1030
|
+
/** Hyperliquid result from spot order execution */
|
|
1031
|
+
interface SpotOrderHyperliquidResult {
|
|
1032
|
+
status: 'ok' | 'error';
|
|
1033
|
+
response: {
|
|
1034
|
+
type: 'order';
|
|
1035
|
+
data: SpotOrderHyperliquidData;
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
interface SpotOrderResponseDto {
|
|
1039
|
+
orderId: string;
|
|
1040
|
+
status: 'EXECUTED' | 'FAILED' | 'PENDING';
|
|
1041
|
+
asset: string;
|
|
1042
|
+
createdAt: string;
|
|
1043
|
+
hyperliquidResult?: SpotOrderHyperliquidResult;
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* Execute a spot order (swap) using Pear Hyperliquid service
|
|
1047
|
+
* POST /orders/spot
|
|
1048
|
+
*/
|
|
1049
|
+
declare function executeSpotOrder(baseUrl: string, payload: SpotOrderRequestInput): Promise<ApiResponse<SpotOrderResponseDto>>;
|
|
884
1050
|
|
|
885
|
-
type ExecutionType = "MARKET" | "
|
|
886
|
-
type
|
|
1051
|
+
type ExecutionType = "MARKET" | "TRIGGER" | "TWAP" | "LADDER" | "TP" | "SL" | "SPOT_MARKET" | "SPOT_LIMIT" | "SPOT_TWAP";
|
|
1052
|
+
type TriggerType = "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO" | "BTC_DOM" | "CROSS_ASSET_PRICE" | "PREDICTION_MARKET_OUTCOME";
|
|
1053
|
+
type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE" | "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO";
|
|
887
1054
|
interface PairAssetInput {
|
|
888
1055
|
asset: string;
|
|
889
1056
|
weight?: number;
|
|
@@ -891,6 +1058,9 @@ interface PairAssetInput {
|
|
|
891
1058
|
interface TpSlThresholdInput {
|
|
892
1059
|
type: TpSlThresholdType;
|
|
893
1060
|
value: number;
|
|
1061
|
+
isTrailing?: boolean;
|
|
1062
|
+
trailingDeltaValue?: number;
|
|
1063
|
+
trailingActivationValue?: number;
|
|
894
1064
|
}
|
|
895
1065
|
interface LadderConfigInput {
|
|
896
1066
|
ratioStart: number;
|
|
@@ -904,8 +1074,11 @@ interface CreatePositionRequestInput {
|
|
|
904
1074
|
usdValue: number;
|
|
905
1075
|
longAssets?: PairAssetInput[];
|
|
906
1076
|
shortAssets?: PairAssetInput[];
|
|
907
|
-
triggerValue?: number;
|
|
1077
|
+
triggerValue?: string | number;
|
|
1078
|
+
triggerType?: TriggerType;
|
|
908
1079
|
direction?: "MORE_THAN" | "LESS_THAN";
|
|
1080
|
+
assetName?: string;
|
|
1081
|
+
marketCode?: string;
|
|
909
1082
|
twapDuration?: number;
|
|
910
1083
|
twapIntervalSeconds?: number;
|
|
911
1084
|
randomizeExecution?: boolean;
|
|
@@ -914,24 +1087,9 @@ interface CreatePositionRequestInput {
|
|
|
914
1087
|
takeProfit?: TpSlThresholdInput | null;
|
|
915
1088
|
stopLoss?: TpSlThresholdInput | null;
|
|
916
1089
|
}
|
|
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
1090
|
interface CreatePositionResponseDto {
|
|
927
|
-
positionId: string | null;
|
|
928
1091
|
orderId: string;
|
|
929
|
-
|
|
930
|
-
createdAt: string;
|
|
931
|
-
assets?: PositionAssetSummaryDto[];
|
|
932
|
-
stopLoss?: TpSlThresholdInput | null;
|
|
933
|
-
takeProfit?: TpSlThresholdInput | null;
|
|
934
|
-
hyperliquidResult?: any;
|
|
1092
|
+
fills?: ExternalFillDto[];
|
|
935
1093
|
}
|
|
936
1094
|
/**
|
|
937
1095
|
* Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
|
|
@@ -939,7 +1097,7 @@ interface CreatePositionResponseDto {
|
|
|
939
1097
|
* @throws MinimumPositionSizeError if any asset has less than $11 USD value
|
|
940
1098
|
* @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets (15)
|
|
941
1099
|
*/
|
|
942
|
-
declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput,
|
|
1100
|
+
declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput, hip3Assets: Map<string, string[]>): Promise<ApiResponse<CreatePositionResponseDto>>;
|
|
943
1101
|
interface UpdateRiskParametersRequestInput {
|
|
944
1102
|
stopLoss?: TpSlThresholdInput | null;
|
|
945
1103
|
takeProfit?: TpSlThresholdInput | null;
|
|
@@ -1006,7 +1164,7 @@ interface AdjustAdvanceResponseDto {
|
|
|
1006
1164
|
status: string;
|
|
1007
1165
|
executedAt: string;
|
|
1008
1166
|
}
|
|
1009
|
-
declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[],
|
|
1167
|
+
declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[], hip3Assets: Map<string, string[]>): Promise<ApiResponse<AdjustAdvanceResponseDto>>;
|
|
1010
1168
|
declare function cancelTwap(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
1011
1169
|
interface UpdateLeverageRequestInput {
|
|
1012
1170
|
leverage: number;
|
|
@@ -1032,10 +1190,22 @@ declare function useOrders(): {
|
|
|
1032
1190
|
readonly adjustOrder: (orderId: string, payload: AdjustOrderRequestInput) => Promise<ApiResponse<AdjustOrderResponseDto>>;
|
|
1033
1191
|
readonly cancelOrder: (orderId: string) => Promise<ApiResponse<CancelOrderResponseDto>>;
|
|
1034
1192
|
readonly cancelTwapOrder: (orderId: string) => Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
1035
|
-
readonly openOrders:
|
|
1193
|
+
readonly openOrders: EnrichedOpenLimitOrderDto[] | null;
|
|
1036
1194
|
readonly isLoading: boolean;
|
|
1037
1195
|
};
|
|
1038
1196
|
|
|
1197
|
+
interface UseSpotOrderResult {
|
|
1198
|
+
executeSpotOrder: (payload: SpotOrderRequestInput) => Promise<ApiResponse<SpotOrderResponseDto>>;
|
|
1199
|
+
isLoading: boolean;
|
|
1200
|
+
error: ApiErrorResponse | null;
|
|
1201
|
+
resetError: () => void;
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Hook for executing spot orders (swaps) on Hyperliquid
|
|
1205
|
+
* Use this to swap between USDC and USDH or other spot assets
|
|
1206
|
+
*/
|
|
1207
|
+
declare function useSpotOrder(): UseSpotOrderResult;
|
|
1208
|
+
|
|
1039
1209
|
declare function useTwap(): {
|
|
1040
1210
|
readonly orders: TwapMonitoringDto[];
|
|
1041
1211
|
readonly cancelTwap: (orderId: string) => Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
@@ -1057,14 +1227,16 @@ interface UseNotificationsResult {
|
|
|
1057
1227
|
*/
|
|
1058
1228
|
declare function useNotifications(): UseNotificationsResult;
|
|
1059
1229
|
|
|
1230
|
+
type CollateralFilter = 'USDC' | 'USDH' | 'ALL';
|
|
1060
1231
|
declare const useMarketDataPayload: () => ActiveAssetsResponse | null;
|
|
1061
1232
|
declare const useMarketDataAllPayload: () => ActiveAssetsAllResponse | null;
|
|
1062
|
-
declare const
|
|
1063
|
-
declare const
|
|
1064
|
-
declare const
|
|
1065
|
-
declare const
|
|
1066
|
-
declare const
|
|
1067
|
-
declare const
|
|
1233
|
+
declare const usePerpMetaAssets: () => UniverseAsset[] | null;
|
|
1234
|
+
declare const useActiveBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1235
|
+
declare const useTopGainers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1236
|
+
declare const useTopLosers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1237
|
+
declare const useHighlightedBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1238
|
+
declare const useWatchlistBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1239
|
+
declare const useAllBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1068
1240
|
declare const useFindBasket: (longs: string[], shorts: string[]) => ActiveAssetGroupItem | undefined;
|
|
1069
1241
|
|
|
1070
1242
|
declare function useWatchlist(): {
|
|
@@ -1127,9 +1299,9 @@ declare function usePortfolio(): UsePortfolioResult;
|
|
|
1127
1299
|
|
|
1128
1300
|
declare function useAuth(): {
|
|
1129
1301
|
readonly isReady: boolean;
|
|
1130
|
-
readonly isAuthenticated:
|
|
1131
|
-
readonly accessToken:
|
|
1132
|
-
readonly refreshToken:
|
|
1302
|
+
readonly isAuthenticated: boolean;
|
|
1303
|
+
readonly accessToken: string | null;
|
|
1304
|
+
readonly refreshToken: string | null;
|
|
1133
1305
|
readonly getEip712: (address: string) => Promise<GetEIP712MessageResponse>;
|
|
1134
1306
|
readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
|
|
1135
1307
|
readonly loginWithPrivyToken: (address: string, appId: string, privyAccessToken: string) => Promise<void>;
|
|
@@ -1137,6 +1309,32 @@ declare function useAuth(): {
|
|
|
1137
1309
|
readonly logout: () => Promise<void>;
|
|
1138
1310
|
};
|
|
1139
1311
|
|
|
1312
|
+
interface AllUserBalances {
|
|
1313
|
+
spotUsdcBalance: number | undefined;
|
|
1314
|
+
availableToTradeUsdc: number | undefined;
|
|
1315
|
+
spotUsdhBalance: number | undefined;
|
|
1316
|
+
availableToTradeUsdh: number | undefined;
|
|
1317
|
+
isLoading: boolean;
|
|
1318
|
+
}
|
|
1319
|
+
declare const useAllUserBalances: () => AllUserBalances;
|
|
1320
|
+
|
|
1321
|
+
interface UseHyperliquidUserFillsOptions {
|
|
1322
|
+
baseUrl: string;
|
|
1323
|
+
address: string | null;
|
|
1324
|
+
aggregateByTime?: boolean;
|
|
1325
|
+
}
|
|
1326
|
+
interface UseHyperliquidUserFillsState {
|
|
1327
|
+
lastRunAt: number | null;
|
|
1328
|
+
lastResult: SyncFillsResponseDto | null;
|
|
1329
|
+
error: string | null;
|
|
1330
|
+
isSyncing: boolean;
|
|
1331
|
+
handleUserFillsEvent: () => Promise<void>;
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Provides a callback to sync user fills whenever the native WebSocket emits a userFills event.
|
|
1335
|
+
*/
|
|
1336
|
+
declare function useHyperliquidUserFills(options: UseHyperliquidUserFillsOptions): UseHyperliquidUserFillsState;
|
|
1337
|
+
|
|
1140
1338
|
interface UseHyperliquidWebSocketProps {
|
|
1141
1339
|
wsUrl: string;
|
|
1142
1340
|
address: string | null;
|
|
@@ -1151,12 +1349,13 @@ interface UseHyperliquidNativeWebSocketProps {
|
|
|
1151
1349
|
address: string | null;
|
|
1152
1350
|
tokens?: string[];
|
|
1153
1351
|
enabled?: boolean;
|
|
1352
|
+
onUserFills?: () => void | Promise<void>;
|
|
1154
1353
|
}
|
|
1155
1354
|
interface UseHyperliquidNativeWebSocketReturn {
|
|
1156
1355
|
isConnected: boolean;
|
|
1157
1356
|
lastError: string | null;
|
|
1158
1357
|
}
|
|
1159
|
-
declare const useHyperliquidNativeWebSocket: ({ address, enabled, }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
|
1358
|
+
declare const useHyperliquidNativeWebSocket: ({ address, enabled, onUserFills, }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
|
1160
1359
|
|
|
1161
1360
|
/**
|
|
1162
1361
|
* Mark notifications as read up to a given timestamp (ms)
|
|
@@ -1171,7 +1370,94 @@ declare function markNotificationReadById(baseUrl: string, id: string): Promise<
|
|
|
1171
1370
|
updated: number;
|
|
1172
1371
|
}>>;
|
|
1173
1372
|
|
|
1174
|
-
declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[],
|
|
1373
|
+
declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[], hip3Assets: Map<string, string[]>): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
|
|
1374
|
+
|
|
1375
|
+
interface KalshiPriceRange {
|
|
1376
|
+
start: string;
|
|
1377
|
+
end: string;
|
|
1378
|
+
step: string;
|
|
1379
|
+
}
|
|
1380
|
+
interface KalshiMveLeg {
|
|
1381
|
+
event_ticker: string;
|
|
1382
|
+
market_ticker: string;
|
|
1383
|
+
side: string;
|
|
1384
|
+
}
|
|
1385
|
+
interface KalshiMarket {
|
|
1386
|
+
ticker: string;
|
|
1387
|
+
event_ticker: string;
|
|
1388
|
+
market_type: 'binary' | string;
|
|
1389
|
+
title: string;
|
|
1390
|
+
subtitle: string;
|
|
1391
|
+
yes_sub_title: string;
|
|
1392
|
+
no_sub_title: string;
|
|
1393
|
+
created_time: string;
|
|
1394
|
+
open_time: string;
|
|
1395
|
+
close_time: string;
|
|
1396
|
+
expiration_time: string;
|
|
1397
|
+
latest_expiration_time: string;
|
|
1398
|
+
settlement_timer_seconds: number;
|
|
1399
|
+
status: 'initialized' | 'open' | 'closed' | 'settled' | string;
|
|
1400
|
+
response_price_units: 'usd_cent' | string;
|
|
1401
|
+
yes_bid: number;
|
|
1402
|
+
yes_bid_dollars: string;
|
|
1403
|
+
yes_ask: number;
|
|
1404
|
+
yes_ask_dollars: string;
|
|
1405
|
+
no_bid: number;
|
|
1406
|
+
no_bid_dollars: string;
|
|
1407
|
+
no_ask: number;
|
|
1408
|
+
no_ask_dollars: string;
|
|
1409
|
+
last_price: number;
|
|
1410
|
+
last_price_dollars: string;
|
|
1411
|
+
volume: number;
|
|
1412
|
+
volume_24h: number;
|
|
1413
|
+
result: 'yes' | 'no' | null;
|
|
1414
|
+
can_close_early: boolean;
|
|
1415
|
+
open_interest: number;
|
|
1416
|
+
notional_value: number;
|
|
1417
|
+
notional_value_dollars: string;
|
|
1418
|
+
previous_yes_bid: number;
|
|
1419
|
+
previous_yes_bid_dollars: string;
|
|
1420
|
+
previous_yes_ask: number;
|
|
1421
|
+
previous_yes_ask_dollars: string;
|
|
1422
|
+
previous_price: number;
|
|
1423
|
+
previous_price_dollars: string;
|
|
1424
|
+
liquidity: number;
|
|
1425
|
+
liquidity_dollars: string;
|
|
1426
|
+
expiration_value: string;
|
|
1427
|
+
tick_size: number;
|
|
1428
|
+
rules_primary: string;
|
|
1429
|
+
rules_secondary: string;
|
|
1430
|
+
price_level_structure: string;
|
|
1431
|
+
price_ranges: KalshiPriceRange[];
|
|
1432
|
+
expected_expiration_time: string;
|
|
1433
|
+
settlement_value: number;
|
|
1434
|
+
settlement_value_dollars: string;
|
|
1435
|
+
settlement_ts: string;
|
|
1436
|
+
fee_waiver_expiration_time: string;
|
|
1437
|
+
early_close_condition: string;
|
|
1438
|
+
strike_type: 'greater' | 'less' | 'between' | string;
|
|
1439
|
+
floor_strike: number;
|
|
1440
|
+
cap_strike: number;
|
|
1441
|
+
functional_strike: string;
|
|
1442
|
+
custom_strike: Record<string, unknown>;
|
|
1443
|
+
mve_collection_ticker: string;
|
|
1444
|
+
mve_selected_legs: KalshiMveLeg[];
|
|
1445
|
+
primary_participant_key: string;
|
|
1446
|
+
is_provisional: boolean;
|
|
1447
|
+
}
|
|
1448
|
+
interface KalshiMarketsResponse {
|
|
1449
|
+
markets: KalshiMarket[];
|
|
1450
|
+
cursor: string;
|
|
1451
|
+
}
|
|
1452
|
+
interface GetKalshiMarketsParams {
|
|
1453
|
+
limit?: number;
|
|
1454
|
+
cursor?: string;
|
|
1455
|
+
tickers?: string[];
|
|
1456
|
+
event_ticker?: string;
|
|
1457
|
+
series_ticker?: string;
|
|
1458
|
+
status?: string;
|
|
1459
|
+
}
|
|
1460
|
+
declare function getKalshiMarkets(params?: GetKalshiMarketsParams): Promise<ApiResponse<KalshiMarketsResponse>>;
|
|
1175
1461
|
|
|
1176
1462
|
/**
|
|
1177
1463
|
* Account summary calculation utility class
|
|
@@ -1210,24 +1496,28 @@ declare class ConflictDetector {
|
|
|
1210
1496
|
declare class TokenMetadataExtractor {
|
|
1211
1497
|
/**
|
|
1212
1498
|
* Extracts comprehensive token metadata
|
|
1213
|
-
* @param symbol - Token symbol
|
|
1499
|
+
* @param symbol - Token symbol (base symbol without prefix, e.g., "TSLA")
|
|
1214
1500
|
* @param perpMetaAssets - Aggregated universe assets (flattened across dexes)
|
|
1215
1501
|
* @param finalAssetContexts - Aggregated asset contexts (flattened across dexes)
|
|
1216
1502
|
* @param allMids - AllMids data containing current prices
|
|
1217
1503
|
* @param activeAssetData - Optional active asset data containing leverage information
|
|
1504
|
+
* @param marketPrefix - Optional market prefix (e.g., "xyz", "flx") for HIP3 multi-market assets
|
|
1218
1505
|
* @returns TokenMetadata or null if token not found
|
|
1219
1506
|
*/
|
|
1220
|
-
static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): TokenMetadata | null;
|
|
1507
|
+
static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null, marketPrefix?: string | null): TokenMetadata | null;
|
|
1221
1508
|
/**
|
|
1222
1509
|
* Extracts metadata for multiple tokens
|
|
1223
|
-
* @param
|
|
1510
|
+
* @param tokens - Array of token objects with symbol and optional marketPrefix
|
|
1224
1511
|
* @param perpMetaAssets - Aggregated universe assets
|
|
1225
1512
|
* @param finalAssetContexts - Aggregated asset contexts
|
|
1226
1513
|
* @param allMids - AllMids data
|
|
1227
1514
|
* @param activeAssetData - Optional active asset data containing leverage information
|
|
1228
|
-
* @returns Record of
|
|
1515
|
+
* @returns Record of unique key to TokenMetadata. Key is "{prefix}:{symbol}" for HIP3 assets, or just "{symbol}" otherwise
|
|
1229
1516
|
*/
|
|
1230
|
-
static extractMultipleTokensMetadata(
|
|
1517
|
+
static extractMultipleTokensMetadata(tokens: Array<{
|
|
1518
|
+
symbol: string;
|
|
1519
|
+
marketPrefix?: string | null;
|
|
1520
|
+
}>, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): Record<string, TokenMetadata | null>;
|
|
1231
1521
|
/**
|
|
1232
1522
|
* Checks if token data is available in aggregated universe assets
|
|
1233
1523
|
* @param symbol - Token symbol
|
|
@@ -1331,7 +1621,112 @@ declare function validatePositionSize(usdValue: number, longAssets?: PairAssetIn
|
|
|
1331
1621
|
minimumRequired?: number;
|
|
1332
1622
|
};
|
|
1333
1623
|
|
|
1334
|
-
|
|
1624
|
+
/**
|
|
1625
|
+
* Convert a full/prefixed symbol (e.g., "xyz:XYZ100") to a display symbol (e.g., "XYZ100").
|
|
1626
|
+
*/
|
|
1627
|
+
declare function toDisplaySymbol(symbol: string): string;
|
|
1628
|
+
/**
|
|
1629
|
+
* Convert a display symbol back to backend form using a provided map.
|
|
1630
|
+
* If mapping is missing, returns the original symbol.
|
|
1631
|
+
* For multi-market assets, returns the first available market.
|
|
1632
|
+
* @param displaySymbol e.g., "TSLA"
|
|
1633
|
+
* @param hip3Assets map of display -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"])
|
|
1634
|
+
*/
|
|
1635
|
+
declare function toBackendSymbol(displaySymbol: string, hip3Assets: Map<string, string[]>): string;
|
|
1636
|
+
/**
|
|
1637
|
+
* Convert a display symbol to backend form for a specific market prefix.
|
|
1638
|
+
* This is useful when an asset is available on multiple markets (e.g., xyz:TSLA and flx:TSLA).
|
|
1639
|
+
* @param displaySymbol e.g., "TSLA"
|
|
1640
|
+
* @param marketPrefix e.g., "xyz" or "flx"
|
|
1641
|
+
* @param hip3Assets map of display -> all full market names
|
|
1642
|
+
* @returns Full market name if found, null if prefix not specified for multi-market asset, otherwise displaySymbol with prefix
|
|
1643
|
+
*/
|
|
1644
|
+
declare function toBackendSymbolWithMarket(displaySymbol: string, marketPrefix: string | undefined, hip3Assets: Map<string, string[]>): string | null;
|
|
1645
|
+
/**
|
|
1646
|
+
* Get all available markets for a display symbol.
|
|
1647
|
+
* @param displaySymbol e.g., "TSLA"
|
|
1648
|
+
* @param hip3Assets map of display -> all full market names
|
|
1649
|
+
* @returns Array of full market names, e.g., ["xyz:TSLA", "flx:TSLA"]
|
|
1650
|
+
*/
|
|
1651
|
+
declare function getAvailableMarkets(displaySymbol: string, hip3Assets: Map<string, string[]>): string[];
|
|
1652
|
+
/**
|
|
1653
|
+
* Extract the market prefix from a full market name.
|
|
1654
|
+
* @param fullSymbol e.g., "xyz:TSLA"
|
|
1655
|
+
* @returns The prefix (e.g., "xyz") or undefined if no prefix
|
|
1656
|
+
*/
|
|
1657
|
+
declare function getMarketPrefix(fullSymbol: string): string | undefined;
|
|
1658
|
+
/**
|
|
1659
|
+
* Check if a symbol is a HIP-3 market (has a prefix).
|
|
1660
|
+
* @param symbol e.g., "xyz:TSLA" or "TSLA"
|
|
1661
|
+
* @returns true if the symbol has a market prefix
|
|
1662
|
+
*/
|
|
1663
|
+
declare function isHip3Market(symbol: string): boolean;
|
|
1664
|
+
|
|
1665
|
+
/**
|
|
1666
|
+
* Helper functions to safely extract values from order parameters
|
|
1667
|
+
* based on the order type and parameter structure.
|
|
1668
|
+
*/
|
|
1669
|
+
/**
|
|
1670
|
+
* Get leverage from order parameters (available for Market, Trigger, Twap, Ladder orders)
|
|
1671
|
+
*/
|
|
1672
|
+
declare function getOrderLeverage(order: OpenLimitOrderDto): number | undefined;
|
|
1673
|
+
/**
|
|
1674
|
+
* Get USD value from order parameters (available for Market, Trigger, Twap, Ladder orders)
|
|
1675
|
+
*/
|
|
1676
|
+
declare function getOrderUsdValue(order: OpenLimitOrderDto): number | undefined;
|
|
1677
|
+
/**
|
|
1678
|
+
* Get trigger value from order parameters (available for TP/SL and Trigger orders)
|
|
1679
|
+
*/
|
|
1680
|
+
declare function getOrderTriggerValue(order: OpenLimitOrderDto): number | undefined;
|
|
1681
|
+
/**
|
|
1682
|
+
* Get TP/SL trigger type from order parameters (only for TP/SL orders)
|
|
1683
|
+
*/
|
|
1684
|
+
declare function getOrderTpSlTriggerType(order: OpenLimitOrderDto): TpSlTriggerType | undefined;
|
|
1685
|
+
/**
|
|
1686
|
+
* Get trigger type from order parameters (for Trigger orders)
|
|
1687
|
+
*/
|
|
1688
|
+
declare function getOrderTriggerType(order: OpenLimitOrderDto): TriggerType$1 | undefined;
|
|
1689
|
+
/**
|
|
1690
|
+
* Get order direction from order parameters (for Trigger orders)
|
|
1691
|
+
*/
|
|
1692
|
+
declare function getOrderDirection(order: OpenLimitOrderDto): OrderDirection | undefined;
|
|
1693
|
+
/**
|
|
1694
|
+
* Get reduce only flag from order parameters (available for all order types)
|
|
1695
|
+
*/
|
|
1696
|
+
declare function getOrderReduceOnly(order: OpenLimitOrderDto): boolean;
|
|
1697
|
+
/**
|
|
1698
|
+
* Get TWAP duration from order parameters (only for TWAP orders)
|
|
1699
|
+
*/
|
|
1700
|
+
declare function getOrderTwapDuration(order: OpenLimitOrderDto): string | undefined;
|
|
1701
|
+
/**
|
|
1702
|
+
* Get ladder config from order parameters (only for Ladder orders)
|
|
1703
|
+
*/
|
|
1704
|
+
declare function getOrderLadderConfig(order: OpenLimitOrderDto): {
|
|
1705
|
+
ratioStart: number;
|
|
1706
|
+
ratioEnd: number;
|
|
1707
|
+
numberOfLevels: number;
|
|
1708
|
+
} | undefined;
|
|
1709
|
+
/**
|
|
1710
|
+
* Check if the order is a BTC Dominance trigger order
|
|
1711
|
+
*/
|
|
1712
|
+
declare function isBtcDomOrder(order: OpenLimitOrderDto): boolean;
|
|
1713
|
+
/**
|
|
1714
|
+
* Get trailing info from TP/SL order parameters
|
|
1715
|
+
*/
|
|
1716
|
+
declare function getOrderTrailingInfo(order: OpenLimitOrderDto): {
|
|
1717
|
+
isTrailing: boolean;
|
|
1718
|
+
trailingDeltaValue?: number;
|
|
1719
|
+
trailingActivationValue?: number;
|
|
1720
|
+
} | undefined;
|
|
1721
|
+
|
|
1722
|
+
interface MarketDataState {
|
|
1723
|
+
marketData: ActiveAssetsResponse | null;
|
|
1724
|
+
marketDataAll: ActiveAssetsAllResponse | null;
|
|
1725
|
+
setMarketData: (value: ActiveAssetsResponse | null) => void;
|
|
1726
|
+
setMarketDataAll: (value: ActiveAssetsAllResponse | null) => void;
|
|
1727
|
+
clean: () => void;
|
|
1728
|
+
}
|
|
1729
|
+
declare const useMarketData: zustand.UseBoundStore<zustand.StoreApi<MarketDataState>>;
|
|
1335
1730
|
|
|
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,
|
|
1731
|
+
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, getKalshiMarkets, 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 };
|
|
1732
|
+
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, GetKalshiMarketsParams, HLWebSocketResponse, HistoricalRange, KalshiMarket, KalshiMarketsResponse, KalshiMveLeg, KalshiPriceRange, 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 };
|