@pear-protocol/hyperliquid-sdk 0.0.79 → 0.1.1-9.1-pnl
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/README.md +1141 -0
- package/dist/clients/auth.d.ts +1 -1
- package/dist/clients/hyperliquid.d.ts +9 -2
- package/dist/clients/positions.d.ts +3 -46
- package/dist/clients/watchlist.d.ts +1 -1
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/useAgentWallet.d.ts +1 -1
- package/dist/hooks/useAllUserBalances.d.ts +21 -6
- package/dist/hooks/useAuth.d.ts +4 -1
- package/dist/hooks/useBasketCandles.d.ts +1 -0
- package/dist/hooks/useHistoricalPriceData.d.ts +1 -0
- package/dist/hooks/useMarket.d.ts +8 -0
- package/dist/hooks/useMarketData.d.ts +15 -12
- package/dist/hooks/usePnlCalendar.d.ts +38 -0
- package/dist/hooks/usePosition.d.ts +23 -2
- package/dist/hooks/useTokenSelectionMetadata.d.ts +1 -1
- package/dist/hooks/useTrading.d.ts +1 -2
- package/dist/hooks/useUserSelection.d.ts +16 -1
- package/dist/index.d.ts +285 -245
- package/dist/index.js +1675 -1476
- package/dist/provider.d.ts +1 -1
- package/dist/store/historicalPriceDataStore.d.ts +3 -0
- package/dist/store/hyperliquidDataStore.d.ts +10 -7
- package/dist/store/marketDataStore.d.ts +1 -3
- package/dist/store/tokenSelectionMetadataStore.d.ts +3 -6
- package/dist/store/userDataStore.d.ts +5 -1
- package/dist/types.d.ts +83 -33
- package/dist/utils/http.d.ts +2 -2
- package/dist/utils/market-symbol.d.ts +5 -0
- package/dist/utils/position-processor.d.ts +2 -2
- package/dist/utils/position-validator.d.ts +1 -1
- package/dist/utils/token-metadata-extractor.d.ts +35 -24
- package/dist/utils/token-metadata-selectors.d.ts +4 -0
- package/package.json +1 -1
- package/dist/hooks/useWebData.d.ts +0 -30
- package/dist/utils/symbol-translator.d.ts +0 -40
package/dist/index.d.ts
CHANGED
|
@@ -60,6 +60,11 @@ interface ExternalFillDto {
|
|
|
60
60
|
feeToken?: string | null;
|
|
61
61
|
liquidation?: ExternalLiquidationDto | null;
|
|
62
62
|
}
|
|
63
|
+
interface SyncFillsRequestDto {
|
|
64
|
+
user: string;
|
|
65
|
+
fills: ExternalFillDto[];
|
|
66
|
+
assetPositions?: AssetPosition[];
|
|
67
|
+
}
|
|
63
68
|
interface SyncFillsResponseDto {
|
|
64
69
|
insertedFills: number;
|
|
65
70
|
skippedDuplicates: number;
|
|
@@ -76,6 +81,12 @@ interface TwapSliceFillResponseItem {
|
|
|
76
81
|
* WebSocket connection states
|
|
77
82
|
*/
|
|
78
83
|
type WebSocketConnectionState = 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
84
|
+
declare enum ReadyState {
|
|
85
|
+
CONNECTING = 0,
|
|
86
|
+
OPEN = 1,
|
|
87
|
+
CLOSING = 2,
|
|
88
|
+
CLOSED = 3
|
|
89
|
+
}
|
|
79
90
|
/**
|
|
80
91
|
* WebSocket channels
|
|
81
92
|
*/
|
|
@@ -217,6 +228,7 @@ interface TwapMonitoringDto {
|
|
|
217
228
|
interface TradeHistoryAssetDataDto {
|
|
218
229
|
coin: string;
|
|
219
230
|
entryWeight: number;
|
|
231
|
+
closeWeight: number;
|
|
220
232
|
entryPrice: number;
|
|
221
233
|
limitPrice: number;
|
|
222
234
|
leverage: number;
|
|
@@ -224,8 +236,7 @@ interface TradeHistoryAssetDataDto {
|
|
|
224
236
|
externalFeePaid: number;
|
|
225
237
|
builderFeePaid: number;
|
|
226
238
|
realizedPnl: number;
|
|
227
|
-
|
|
228
|
-
collateralToken?: CollateralToken;
|
|
239
|
+
metadata?: TokenMetadata | null;
|
|
229
240
|
}
|
|
230
241
|
/**
|
|
231
242
|
* Trade history data structure
|
|
@@ -273,9 +284,10 @@ interface PositionAssetDetailDto {
|
|
|
273
284
|
unrealizedPnl: number;
|
|
274
285
|
liquidationPrice: number;
|
|
275
286
|
initialWeight: number;
|
|
287
|
+
currentWeight: number;
|
|
276
288
|
fundingPaid?: number;
|
|
277
|
-
|
|
278
|
-
|
|
289
|
+
targetWeight?: number;
|
|
290
|
+
metadata?: TokenMetadata | null;
|
|
279
291
|
}
|
|
280
292
|
interface TpSlThreshold {
|
|
281
293
|
type: 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE' | 'PRICE' | 'PRICE_RATIO' | 'WEIGHTED_RATIO';
|
|
@@ -312,8 +324,7 @@ interface OpenPositionDto {
|
|
|
312
324
|
interface OrderAssetDto {
|
|
313
325
|
asset: string;
|
|
314
326
|
weight: number;
|
|
315
|
-
|
|
316
|
-
collateralToken?: CollateralToken;
|
|
327
|
+
metadata?: TokenMetadata | null;
|
|
317
328
|
}
|
|
318
329
|
/**
|
|
319
330
|
* Order status
|
|
@@ -330,7 +341,7 @@ type TpSlTriggerType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE' | 'PRICE' | 'P
|
|
|
330
341
|
/**
|
|
331
342
|
* Trigger type for trigger orders
|
|
332
343
|
*/
|
|
333
|
-
type TriggerType
|
|
344
|
+
type TriggerType = 'PRICE' | 'PRICE_RATIO' | 'WEIGHTED_RATIO' | 'BTC_DOM' | 'CROSS_ASSET_PRICE' | 'PREDICTION_MARKET_OUTCOME';
|
|
334
345
|
type OrderDirection = 'MORE_THAN' | 'LESS_THAN';
|
|
335
346
|
/**
|
|
336
347
|
* Market order parameters
|
|
@@ -346,7 +357,7 @@ interface MarketOrderParameters {
|
|
|
346
357
|
interface TriggerOrderParameters {
|
|
347
358
|
leverage: number;
|
|
348
359
|
usdValue: number;
|
|
349
|
-
triggerType: TriggerType
|
|
360
|
+
triggerType: TriggerType;
|
|
350
361
|
triggerValue: number;
|
|
351
362
|
direction: OrderDirection;
|
|
352
363
|
reduceOnly?: boolean;
|
|
@@ -458,6 +469,15 @@ interface AccountSummaryResponseDto {
|
|
|
458
469
|
platformAccountSummary: PlatformAccountSummaryResponseDto | null;
|
|
459
470
|
agentWallet?: AgentWalletDto;
|
|
460
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* Address management state
|
|
474
|
+
*/
|
|
475
|
+
interface AddressState {
|
|
476
|
+
currentAddress: string | null;
|
|
477
|
+
isLoggedIn: boolean;
|
|
478
|
+
autoConnect: boolean;
|
|
479
|
+
previousAddresses: string[];
|
|
480
|
+
}
|
|
461
481
|
interface UseAuthOptions {
|
|
462
482
|
baseUrl: string;
|
|
463
483
|
clientId: string;
|
|
@@ -484,13 +504,50 @@ interface EIP712AuthDetails {
|
|
|
484
504
|
}
|
|
485
505
|
interface GetEIP712MessageResponse extends EIP712AuthDetails {
|
|
486
506
|
}
|
|
507
|
+
interface PrivyAuthDetails {
|
|
508
|
+
appId: string;
|
|
509
|
+
accessToken: string;
|
|
510
|
+
}
|
|
511
|
+
interface AuthenticateRequest {
|
|
512
|
+
method: 'eip712' | 'api_key' | 'privy_access_token';
|
|
513
|
+
address: string;
|
|
514
|
+
clientId: string;
|
|
515
|
+
details: {
|
|
516
|
+
signature: string;
|
|
517
|
+
timestamp: number;
|
|
518
|
+
} | {
|
|
519
|
+
apiKey: string;
|
|
520
|
+
} | PrivyAuthDetails;
|
|
521
|
+
}
|
|
522
|
+
interface AuthenticateResponse {
|
|
523
|
+
accessToken: string;
|
|
524
|
+
refreshToken: string;
|
|
525
|
+
tokenType: string;
|
|
526
|
+
expiresIn: number;
|
|
527
|
+
address: string;
|
|
528
|
+
clientId: string;
|
|
529
|
+
}
|
|
530
|
+
interface RefreshTokenRequest {
|
|
531
|
+
refreshToken: string;
|
|
532
|
+
}
|
|
487
533
|
interface RefreshTokenResponse {
|
|
488
534
|
accessToken: string;
|
|
489
535
|
refreshToken: string;
|
|
490
536
|
tokenType: string;
|
|
491
537
|
expiresIn: number;
|
|
492
538
|
}
|
|
539
|
+
interface LogoutRequest {
|
|
540
|
+
refreshToken: string;
|
|
541
|
+
}
|
|
542
|
+
interface LogoutResponse {
|
|
543
|
+
message: string;
|
|
544
|
+
}
|
|
493
545
|
type AgentWalletStatus = 'ACTIVE' | 'EXPIRED' | 'NOT_FOUND';
|
|
546
|
+
interface GetAgentWalletResponseDto {
|
|
547
|
+
agentWalletAddress?: string;
|
|
548
|
+
agentName: string;
|
|
549
|
+
status: AgentWalletStatus;
|
|
550
|
+
}
|
|
494
551
|
interface CreateAgentWalletResponseDto {
|
|
495
552
|
agentWalletAddress: string;
|
|
496
553
|
message: string;
|
|
@@ -537,6 +594,7 @@ interface HLChannelDataMap {
|
|
|
537
594
|
allDexsAssetCtxs: AllDexsAssetCtxsData;
|
|
538
595
|
userFills: any;
|
|
539
596
|
}
|
|
597
|
+
type UserAbstraction = 'dexAbstraction' | 'disabled' | 'unifiedAccount' | 'portfolioMargin';
|
|
540
598
|
interface WebData3UserState {
|
|
541
599
|
agentAddress?: string;
|
|
542
600
|
agentValidUntil?: number;
|
|
@@ -545,6 +603,7 @@ interface WebData3UserState {
|
|
|
545
603
|
isVault: boolean;
|
|
546
604
|
user: string;
|
|
547
605
|
dexAbstractionEnabled?: boolean;
|
|
606
|
+
abstraction: UserAbstraction;
|
|
548
607
|
}
|
|
549
608
|
interface WebData3AssetCtx {
|
|
550
609
|
funding: string;
|
|
@@ -602,8 +661,10 @@ interface AssetCtx {
|
|
|
602
661
|
* Collateral token type
|
|
603
662
|
* 0 = USDC
|
|
604
663
|
* 360 = USDH
|
|
664
|
+
* 235 = USDE
|
|
665
|
+
* 268 = USDT0
|
|
605
666
|
*/
|
|
606
|
-
type CollateralToken = 'USDC' | 'USDH';
|
|
667
|
+
type CollateralToken = 'USDC' | 'USDH' | 'USDE' | 'USDT0';
|
|
607
668
|
/**
|
|
608
669
|
* Universe asset metadata
|
|
609
670
|
*/
|
|
@@ -613,9 +674,26 @@ interface UniverseAsset {
|
|
|
613
674
|
maxLeverage: number;
|
|
614
675
|
onlyIsolated?: boolean;
|
|
615
676
|
isDelisted?: boolean;
|
|
616
|
-
|
|
617
|
-
|
|
677
|
+
collateralToken: CollateralToken;
|
|
678
|
+
}
|
|
679
|
+
interface PerpMetaAsset extends UniverseAsset {
|
|
680
|
+
marginTableId: number;
|
|
681
|
+
}
|
|
682
|
+
interface MarginTier {
|
|
683
|
+
lowerBound: string;
|
|
684
|
+
maxLeverage: number;
|
|
618
685
|
}
|
|
686
|
+
interface MarginTableDef {
|
|
687
|
+
description: string;
|
|
688
|
+
marginTiers: MarginTier[];
|
|
689
|
+
}
|
|
690
|
+
type MarginTablesEntry = [number, MarginTableDef];
|
|
691
|
+
interface AllPerpMetasItem {
|
|
692
|
+
universe: PerpMetaAsset[];
|
|
693
|
+
marginTables: MarginTablesEntry[];
|
|
694
|
+
collateralToken: number;
|
|
695
|
+
}
|
|
696
|
+
type AllPerpMetasResponse = AllPerpMetasItem[];
|
|
619
697
|
interface ClearinghouseState {
|
|
620
698
|
assetPositions: AssetPosition[];
|
|
621
699
|
crossMaintenanceMarginUsed: string;
|
|
@@ -685,9 +763,8 @@ interface RawAssetDto {
|
|
|
685
763
|
size: number;
|
|
686
764
|
side: string;
|
|
687
765
|
fundingPaid?: number;
|
|
688
|
-
marketPrefix?: string | null;
|
|
689
|
-
collateralToken?: CollateralToken;
|
|
690
766
|
leverage: number;
|
|
767
|
+
targetWeight?: number;
|
|
691
768
|
}
|
|
692
769
|
/**
|
|
693
770
|
* Raw position data from open-positions channel
|
|
@@ -722,6 +799,10 @@ interface ActiveAssetData {
|
|
|
722
799
|
markPx: string;
|
|
723
800
|
}
|
|
724
801
|
interface TokenMetadata {
|
|
802
|
+
assetName: string;
|
|
803
|
+
symbolName: string;
|
|
804
|
+
marketName: string;
|
|
805
|
+
isAtOiCaps: boolean;
|
|
725
806
|
currentPrice: number;
|
|
726
807
|
prevDayPrice: number;
|
|
727
808
|
priceChange24h: number;
|
|
@@ -756,30 +837,10 @@ interface AssetMarketData {
|
|
|
756
837
|
asset: WebData3AssetCtx | AssetCtx;
|
|
757
838
|
universe: UniverseAsset;
|
|
758
839
|
}
|
|
759
|
-
/**
|
|
760
|
-
* Nested market data structure for multi-market assets.
|
|
761
|
-
* Each symbol maps to its market variants (keyed by prefix).
|
|
762
|
-
* For non-HIP3 assets, use "default" as the key.
|
|
763
|
-
*
|
|
764
|
-
* @example
|
|
765
|
-
* ```ts
|
|
766
|
-
* {
|
|
767
|
-
* "TSLA": {
|
|
768
|
-
* "xyz": { asset: {...}, universe: { collateralToken: "USDC", ... } },
|
|
769
|
-
* "flx": { asset: {...}, universe: { collateralToken: "USDH", ... } }
|
|
770
|
-
* },
|
|
771
|
-
* "BTC": {
|
|
772
|
-
* "default": { asset: {...}, universe: {...} }
|
|
773
|
-
* }
|
|
774
|
-
* }
|
|
775
|
-
* ```
|
|
776
|
-
*/
|
|
777
|
-
type MarketDataBySymbol = Record<string, Record<string, AssetMarketData>>;
|
|
778
840
|
interface PairAssetDto {
|
|
779
841
|
asset: string;
|
|
780
842
|
weight: number;
|
|
781
|
-
|
|
782
|
-
marketPrefix: string | null;
|
|
843
|
+
metadata?: TokenMetadata | null;
|
|
783
844
|
}
|
|
784
845
|
interface ActiveAssetGroupItem {
|
|
785
846
|
longAssets: PairAssetDto[];
|
|
@@ -793,7 +854,6 @@ interface ActiveAssetGroupItem {
|
|
|
793
854
|
weightedRatio?: string;
|
|
794
855
|
weightedPrevRatio?: string;
|
|
795
856
|
weightedChange24h?: string;
|
|
796
|
-
collateralType: 'USDC' | 'USDH' | 'MIXED';
|
|
797
857
|
}
|
|
798
858
|
interface ActiveAssetsResponse {
|
|
799
859
|
active: ActiveAssetGroupItem[];
|
|
@@ -856,6 +916,71 @@ interface SpotState {
|
|
|
856
916
|
user: string;
|
|
857
917
|
balances: SpotBalance[];
|
|
858
918
|
}
|
|
919
|
+
interface TokenEntry {
|
|
920
|
+
symbol: string;
|
|
921
|
+
data: AssetMarketData;
|
|
922
|
+
}
|
|
923
|
+
interface PerpDex {
|
|
924
|
+
name: string;
|
|
925
|
+
fullName: string;
|
|
926
|
+
deployer: string;
|
|
927
|
+
oracleUpdater: string | null;
|
|
928
|
+
feeRecipient: string | null;
|
|
929
|
+
deployerFeeScale: string;
|
|
930
|
+
assetToStreamingOiCap: [string, string][];
|
|
931
|
+
assetToFundingMultiplier: [string, string][];
|
|
932
|
+
subDeployers: [string, string[]][];
|
|
933
|
+
lastDeployerFeeScaleChangeTime: string;
|
|
934
|
+
}
|
|
935
|
+
type PerpDexsResponse = (PerpDex | null)[];
|
|
936
|
+
interface SpotBalances {
|
|
937
|
+
[coin: string]: number;
|
|
938
|
+
}
|
|
939
|
+
interface AvailableToTrades {
|
|
940
|
+
[collateralCoin: string]: number;
|
|
941
|
+
}
|
|
942
|
+
type ExecutionType = "MARKET" | "TRIGGER" | "TWAP" | "LADDER" | "TP" | "SL" | "SPOT_MARKET" | "SPOT_LIMIT" | "SPOT_TWAP";
|
|
943
|
+
type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE" | "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO";
|
|
944
|
+
interface PairAssetInput {
|
|
945
|
+
asset: string;
|
|
946
|
+
weight?: number;
|
|
947
|
+
}
|
|
948
|
+
interface TpSlThresholdInput {
|
|
949
|
+
type: TpSlThresholdType;
|
|
950
|
+
value?: number;
|
|
951
|
+
isTrailing?: boolean;
|
|
952
|
+
trailingDeltaValue?: number;
|
|
953
|
+
trailingActivationValue?: number;
|
|
954
|
+
}
|
|
955
|
+
interface LadderConfigInput {
|
|
956
|
+
ratioStart: number;
|
|
957
|
+
ratioEnd: number;
|
|
958
|
+
numberOfLevels: number;
|
|
959
|
+
}
|
|
960
|
+
interface CreatePositionRequestInput {
|
|
961
|
+
slippage: number;
|
|
962
|
+
executionType: ExecutionType;
|
|
963
|
+
leverage: number;
|
|
964
|
+
usdValue: number;
|
|
965
|
+
longAssets?: PairAssetInput[];
|
|
966
|
+
shortAssets?: PairAssetInput[];
|
|
967
|
+
triggerValue?: string | number;
|
|
968
|
+
triggerType?: TriggerType;
|
|
969
|
+
direction?: "MORE_THAN" | "LESS_THAN";
|
|
970
|
+
assetName?: string;
|
|
971
|
+
marketCode?: string;
|
|
972
|
+
twapDuration?: number;
|
|
973
|
+
twapIntervalSeconds?: number;
|
|
974
|
+
randomizeExecution?: boolean;
|
|
975
|
+
referralCode?: string;
|
|
976
|
+
ladderConfig?: LadderConfigInput;
|
|
977
|
+
takeProfit?: TpSlThresholdInput | null;
|
|
978
|
+
stopLoss?: TpSlThresholdInput | null;
|
|
979
|
+
}
|
|
980
|
+
interface CreatePositionResponseDto {
|
|
981
|
+
orderId: string;
|
|
982
|
+
fills?: ExternalFillDto[];
|
|
983
|
+
}
|
|
859
984
|
|
|
860
985
|
declare const useAccountSummary: () => {
|
|
861
986
|
data: AccountSummaryResponseDto | null;
|
|
@@ -896,36 +1021,29 @@ interface UserSelectionState {
|
|
|
896
1021
|
resetToDefaults: () => void;
|
|
897
1022
|
}
|
|
898
1023
|
|
|
899
|
-
declare const useUserSelection: () =>
|
|
1024
|
+
declare const useUserSelection: () => {
|
|
1025
|
+
longTokens: TokenSelection[];
|
|
1026
|
+
shortTokens: TokenSelection[];
|
|
1027
|
+
candleInterval: CandleInterval;
|
|
1028
|
+
openTokenSelector: boolean;
|
|
1029
|
+
selectorConfig: TokenSelectorConfig | null;
|
|
1030
|
+
openConflictModal: boolean;
|
|
1031
|
+
setLongTokens: (tokens: TokenSelection[]) => void;
|
|
1032
|
+
setShortTokens: (tokens: TokenSelection[]) => void;
|
|
1033
|
+
setCandleInterval: (interval: CandleInterval) => void;
|
|
1034
|
+
setTokenSelections: (longTokens: TokenSelection[], shortTokens: TokenSelection[]) => void;
|
|
1035
|
+
setOpenTokenSelector: (open: boolean) => void;
|
|
1036
|
+
setSelectorConfig: (config: TokenSelectorConfig | null) => void;
|
|
1037
|
+
setOpenConflictModal: (open: boolean) => void;
|
|
1038
|
+
addToken: (isLong: boolean) => boolean;
|
|
1039
|
+
};
|
|
900
1040
|
|
|
901
1041
|
/**
|
|
902
|
-
* Hook to access webData
|
|
1042
|
+
* Hook to access webData
|
|
903
1043
|
*/
|
|
904
|
-
declare const
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
/**
|
|
908
|
-
* Market data keyed by symbol, with nested market variants.
|
|
909
|
-
* Each symbol maps to its market variants (keyed by prefix).
|
|
910
|
-
* For non-HIP3 assets, use "default" as the key.
|
|
911
|
-
*
|
|
912
|
-
* @example
|
|
913
|
-
* ```ts
|
|
914
|
-
* // HIP-3 asset with multiple markets
|
|
915
|
-
* marketDataBySymbol["TSLA"]["xyz"] // { asset, universe: { collateralToken: "USDC" } }
|
|
916
|
-
* marketDataBySymbol["TSLA"]["flx"] // { asset, universe: { collateralToken: "USDH" } }
|
|
917
|
-
*
|
|
918
|
-
* // Regular asset
|
|
919
|
-
* marketDataBySymbol["BTC"]["default"] // { asset, universe }
|
|
920
|
-
* ```
|
|
921
|
-
*/
|
|
922
|
-
marketDataBySymbol: MarketDataBySymbol;
|
|
923
|
-
/** Map of display name -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"]) */
|
|
924
|
-
hip3Assets: Map<string, string[]>;
|
|
925
|
-
/** Map of full market name -> prefix (e.g., "xyz:TSLA" -> "xyz") */
|
|
926
|
-
hip3MarketPrefixes: Map<string, string>;
|
|
927
|
-
isConnected: boolean;
|
|
928
|
-
error: string | null;
|
|
1044
|
+
declare const useMarket: () => {
|
|
1045
|
+
allTokenMetadata: TokenMetadata[];
|
|
1046
|
+
getAssetByName: (symbol: string) => TokenMetadata | null;
|
|
929
1047
|
};
|
|
930
1048
|
|
|
931
1049
|
interface UseTokenSelectionMetadataReturn {
|
|
@@ -941,8 +1059,8 @@ interface UseTokenSelectionMetadataReturn {
|
|
|
941
1059
|
volume: string;
|
|
942
1060
|
sumNetFunding: number;
|
|
943
1061
|
maxLeverage: number;
|
|
944
|
-
minMargin: number;
|
|
945
1062
|
leverageMatched: boolean;
|
|
1063
|
+
minSize: Record<string, number>;
|
|
946
1064
|
}
|
|
947
1065
|
declare const useTokenSelectionMetadata: () => UseTokenSelectionMetadataReturn;
|
|
948
1066
|
|
|
@@ -956,6 +1074,8 @@ interface TokenHistoricalPriceData {
|
|
|
956
1074
|
candles: CandleData[];
|
|
957
1075
|
oldestTime: number | null;
|
|
958
1076
|
latestTime: number | null;
|
|
1077
|
+
requestedRanges: HistoricalRange[];
|
|
1078
|
+
noDataBefore: number | null;
|
|
959
1079
|
}
|
|
960
1080
|
interface HistoricalPriceDataState {
|
|
961
1081
|
historicalPriceData: Record<string, TokenHistoricalPriceData>;
|
|
@@ -963,6 +1083,7 @@ interface HistoricalPriceDataState {
|
|
|
963
1083
|
addHistoricalPriceData: (symbol: string, interval: CandleInterval, candles: CandleData[], range: HistoricalRange) => void;
|
|
964
1084
|
hasHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => boolean;
|
|
965
1085
|
getHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => CandleData[];
|
|
1086
|
+
getEffectiveDataBoundary: (symbols: string[], interval: CandleInterval) => number | null;
|
|
966
1087
|
setTokenLoading: (symbol: string, loading: boolean) => void;
|
|
967
1088
|
isTokenLoading: (symbol: string) => boolean;
|
|
968
1089
|
removeTokenPriceData: (symbol: string, interval: CandleInterval) => void;
|
|
@@ -974,6 +1095,7 @@ interface UseHistoricalPriceDataReturn {
|
|
|
974
1095
|
fetchHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval, callback?: (data: Record<string, CandleData[]>) => void) => Promise<Record<string, CandleData[]>>;
|
|
975
1096
|
hasHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval) => boolean;
|
|
976
1097
|
getHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval) => Record<string, CandleData[]>;
|
|
1098
|
+
getEffectiveDataBoundary: (interval: CandleInterval) => number | null;
|
|
977
1099
|
getAllHistoricalPriceData(): Promise<Record<string, TokenHistoricalPriceData>>;
|
|
978
1100
|
isLoading: (symbol?: string) => boolean;
|
|
979
1101
|
clearCache: () => void;
|
|
@@ -984,6 +1106,7 @@ interface UseBasketCandlesReturn {
|
|
|
984
1106
|
fetchBasketCandles: (startTime: number, endTime: number, interval: CandleInterval) => Promise<CandleData[]>;
|
|
985
1107
|
fetchPerformanceCandles: (startTime: number, endTime: number, interval: CandleInterval, symbol: string) => Promise<CandleData[]>;
|
|
986
1108
|
fetchOverallPerformanceCandles: (startTime: number, endTime: number, interval: CandleInterval) => Promise<CandleData[]>;
|
|
1109
|
+
getEffectiveDataBoundary: (interval: CandleInterval) => number | null;
|
|
987
1110
|
isLoading: boolean;
|
|
988
1111
|
addRealtimeListener: (cb: RealtimeBarsCallback) => string;
|
|
989
1112
|
removeRealtimeListener: (id: string) => void;
|
|
@@ -1091,56 +1214,13 @@ interface SpotOrderResponseDto {
|
|
|
1091
1214
|
*/
|
|
1092
1215
|
declare function executeSpotOrder(baseUrl: string, payload: SpotOrderRequestInput): Promise<ApiResponse<SpotOrderResponseDto>>;
|
|
1093
1216
|
|
|
1094
|
-
type ExecutionType = "MARKET" | "TRIGGER" | "TWAP" | "LADDER" | "TP" | "SL" | "SPOT_MARKET" | "SPOT_LIMIT" | "SPOT_TWAP";
|
|
1095
|
-
type TriggerType = "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO" | "BTC_DOM" | "CROSS_ASSET_PRICE" | "PREDICTION_MARKET_OUTCOME";
|
|
1096
|
-
type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE" | "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO";
|
|
1097
|
-
interface PairAssetInput {
|
|
1098
|
-
asset: string;
|
|
1099
|
-
weight?: number;
|
|
1100
|
-
}
|
|
1101
|
-
interface TpSlThresholdInput {
|
|
1102
|
-
type: TpSlThresholdType;
|
|
1103
|
-
value?: number;
|
|
1104
|
-
isTrailing?: boolean;
|
|
1105
|
-
trailingDeltaValue?: number;
|
|
1106
|
-
trailingActivationValue?: number;
|
|
1107
|
-
}
|
|
1108
|
-
interface LadderConfigInput {
|
|
1109
|
-
ratioStart: number;
|
|
1110
|
-
ratioEnd: number;
|
|
1111
|
-
numberOfLevels: number;
|
|
1112
|
-
}
|
|
1113
|
-
interface CreatePositionRequestInput {
|
|
1114
|
-
slippage: number;
|
|
1115
|
-
executionType: ExecutionType;
|
|
1116
|
-
leverage: number;
|
|
1117
|
-
usdValue: number;
|
|
1118
|
-
longAssets?: PairAssetInput[];
|
|
1119
|
-
shortAssets?: PairAssetInput[];
|
|
1120
|
-
triggerValue?: string | number;
|
|
1121
|
-
triggerType?: TriggerType;
|
|
1122
|
-
direction?: "MORE_THAN" | "LESS_THAN";
|
|
1123
|
-
assetName?: string;
|
|
1124
|
-
marketCode?: string;
|
|
1125
|
-
twapDuration?: number;
|
|
1126
|
-
twapIntervalSeconds?: number;
|
|
1127
|
-
randomizeExecution?: boolean;
|
|
1128
|
-
referralCode?: string;
|
|
1129
|
-
ladderConfig?: LadderConfigInput;
|
|
1130
|
-
takeProfit?: TpSlThresholdInput | null;
|
|
1131
|
-
stopLoss?: TpSlThresholdInput | null;
|
|
1132
|
-
}
|
|
1133
|
-
interface CreatePositionResponseDto {
|
|
1134
|
-
orderId: string;
|
|
1135
|
-
fills?: ExternalFillDto[];
|
|
1136
|
-
}
|
|
1137
1217
|
/**
|
|
1138
1218
|
* Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
|
|
1139
1219
|
* Authorization is derived from headers (Axios defaults or browser localStorage fallback)
|
|
1140
1220
|
* @throws MinimumPositionSizeError if any asset has less than $11 USD value
|
|
1141
1221
|
* @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets (15)
|
|
1142
1222
|
*/
|
|
1143
|
-
declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput
|
|
1223
|
+
declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput): Promise<ApiResponse<CreatePositionResponseDto>>;
|
|
1144
1224
|
interface UpdateRiskParametersRequestInput {
|
|
1145
1225
|
stopLoss?: TpSlThresholdInput | null;
|
|
1146
1226
|
takeProfit?: TpSlThresholdInput | null;
|
|
@@ -1207,7 +1287,7 @@ interface AdjustAdvanceResponseDto {
|
|
|
1207
1287
|
status: string;
|
|
1208
1288
|
executedAt: string;
|
|
1209
1289
|
}
|
|
1210
|
-
declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[]
|
|
1290
|
+
declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[]): Promise<ApiResponse<AdjustAdvanceResponseDto>>;
|
|
1211
1291
|
declare function cancelTwap(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
1212
1292
|
interface UpdateLeverageRequestInput {
|
|
1213
1293
|
leverage: number;
|
|
@@ -1217,6 +1297,25 @@ interface UpdateLeverageResponseDto {
|
|
|
1217
1297
|
}
|
|
1218
1298
|
declare function updateLeverage(baseUrl: string, positionId: string, payload: UpdateLeverageRequestInput): Promise<ApiResponse<UpdateLeverageResponseDto | null>>;
|
|
1219
1299
|
|
|
1300
|
+
interface RebalanceAssetPlan {
|
|
1301
|
+
coin: string;
|
|
1302
|
+
side: 'long' | 'short';
|
|
1303
|
+
currentWeight: number;
|
|
1304
|
+
targetWeight: number;
|
|
1305
|
+
currentValue: number;
|
|
1306
|
+
targetValue: number;
|
|
1307
|
+
deltaValue: number;
|
|
1308
|
+
currentSize: number;
|
|
1309
|
+
newSize: number;
|
|
1310
|
+
deltaSize: number;
|
|
1311
|
+
skipped: boolean;
|
|
1312
|
+
skipReason?: string;
|
|
1313
|
+
}
|
|
1314
|
+
interface RebalancePlan {
|
|
1315
|
+
positionId: string;
|
|
1316
|
+
assets: RebalanceAssetPlan[];
|
|
1317
|
+
canExecute: boolean;
|
|
1318
|
+
}
|
|
1220
1319
|
declare function usePosition(): {
|
|
1221
1320
|
readonly createPosition: (payload: CreatePositionRequestInput) => Promise<ApiResponse<CreatePositionResponseDto>>;
|
|
1222
1321
|
readonly updateRiskParameters: (positionId: string, payload: UpdateRiskParametersRequestInput) => Promise<ApiResponse<UpdateRiskParametersResponseDto>>;
|
|
@@ -1227,6 +1326,8 @@ declare function usePosition(): {
|
|
|
1227
1326
|
readonly updateLeverage: (positionId: string, leverage: number) => Promise<ApiResponse<UpdateLeverageResponseDto | null>>;
|
|
1228
1327
|
readonly openPositions: OpenPositionDto[] | null;
|
|
1229
1328
|
readonly isLoading: boolean;
|
|
1329
|
+
readonly planRebalance: (positionId: string, targetWeights?: Record<string, number>) => RebalancePlan;
|
|
1330
|
+
readonly executeRebalance: (positionId: string, targetWeights?: Record<string, number>) => Promise<ApiResponse<AdjustAdvanceResponseDto>>;
|
|
1230
1331
|
};
|
|
1231
1332
|
|
|
1232
1333
|
declare function useOrders(): {
|
|
@@ -1270,17 +1371,19 @@ interface UseNotificationsResult {
|
|
|
1270
1371
|
*/
|
|
1271
1372
|
declare function useNotifications(): UseNotificationsResult;
|
|
1272
1373
|
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1374
|
+
interface UseMarketDataHookOptions {
|
|
1375
|
+
topGainersLimit?: number;
|
|
1376
|
+
topLosersLimit?: number;
|
|
1377
|
+
}
|
|
1378
|
+
interface UseMarketDataHookResult {
|
|
1379
|
+
marketData: ActiveAssetsResponse | null;
|
|
1380
|
+
activeBaskets: ActiveAssetGroupItem[];
|
|
1381
|
+
topGainers: ActiveAssetGroupItem[];
|
|
1382
|
+
topLosers: ActiveAssetGroupItem[];
|
|
1383
|
+
highlightedBaskets: ActiveAssetGroupItem[];
|
|
1384
|
+
watchlistBaskets: ActiveAssetGroupItem[];
|
|
1385
|
+
}
|
|
1386
|
+
declare const useMarketDataHook: (options?: UseMarketDataHookOptions) => UseMarketDataHookResult;
|
|
1284
1387
|
|
|
1285
1388
|
declare function useWatchlist(): {
|
|
1286
1389
|
readonly watchlists: ActiveAssetGroupItem[] | null;
|
|
@@ -1343,6 +1446,7 @@ declare function usePortfolio(): UsePortfolioResult;
|
|
|
1343
1446
|
declare function useAuth(): {
|
|
1344
1447
|
readonly isReady: boolean;
|
|
1345
1448
|
readonly isAuthenticated: boolean;
|
|
1449
|
+
readonly address: string | null;
|
|
1346
1450
|
readonly accessToken: string | null;
|
|
1347
1451
|
readonly refreshToken: string | null;
|
|
1348
1452
|
readonly getEip712: (address: string) => Promise<GetEIP712MessageResponse>;
|
|
@@ -1350,16 +1454,32 @@ declare function useAuth(): {
|
|
|
1350
1454
|
readonly loginWithPrivyToken: (address: string, appId: string, privyAccessToken: string) => Promise<void>;
|
|
1351
1455
|
readonly refreshTokens: () => Promise<RefreshTokenResponse>;
|
|
1352
1456
|
readonly logout: () => Promise<void>;
|
|
1457
|
+
readonly clearSession: () => void;
|
|
1458
|
+
readonly setAddress: (address: string | null) => void;
|
|
1353
1459
|
};
|
|
1354
1460
|
|
|
1355
|
-
interface
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1461
|
+
interface MarginRequiredPerCollateral {
|
|
1462
|
+
collateral: CollateralToken;
|
|
1463
|
+
marginRequired: number;
|
|
1464
|
+
availableBalance: number;
|
|
1465
|
+
hasEnough: boolean;
|
|
1466
|
+
shortfall: number;
|
|
1467
|
+
}
|
|
1468
|
+
interface MarginRequiredResult {
|
|
1469
|
+
totalMarginRequired: number;
|
|
1470
|
+
orderValue: number;
|
|
1471
|
+
perCollateral: MarginRequiredPerCollateral[];
|
|
1472
|
+
hasEnoughTotal: boolean;
|
|
1473
|
+
}
|
|
1474
|
+
interface AllUserBalancesResult {
|
|
1475
|
+
spotBalances: SpotBalances;
|
|
1476
|
+
availableToTrades: AvailableToTrades;
|
|
1360
1477
|
isLoading: boolean;
|
|
1478
|
+
abstractionMode: UserAbstraction | null;
|
|
1479
|
+
getMarginRequired: (assetsLeverage: Record<string, number>, size: number) => MarginRequiredResult;
|
|
1480
|
+
getMaxSize: (assetsLeverage: Record<string, number>) => number;
|
|
1361
1481
|
}
|
|
1362
|
-
declare const useAllUserBalances: () =>
|
|
1482
|
+
declare const useAllUserBalances: () => AllUserBalancesResult;
|
|
1363
1483
|
|
|
1364
1484
|
interface UseHyperliquidUserFillsOptions {
|
|
1365
1485
|
baseUrl: string;
|
|
@@ -1378,27 +1498,44 @@ interface UseHyperliquidUserFillsState {
|
|
|
1378
1498
|
*/
|
|
1379
1499
|
declare function useHyperliquidUserFills(options: UseHyperliquidUserFillsOptions): UseHyperliquidUserFillsState;
|
|
1380
1500
|
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
};
|
|
1390
|
-
|
|
1391
|
-
interface UseHyperliquidNativeWebSocketProps {
|
|
1392
|
-
address: string | null;
|
|
1393
|
-
tokens?: string[];
|
|
1394
|
-
enabled?: boolean;
|
|
1395
|
-
onUserFills?: () => void | Promise<void>;
|
|
1501
|
+
type PnlCalendarTimeframe = '2W' | '3W' | '2M' | '3M';
|
|
1502
|
+
interface PnlCalendarDay {
|
|
1503
|
+
date: string;
|
|
1504
|
+
totalPnl: number;
|
|
1505
|
+
volume: number;
|
|
1506
|
+
positionsClosed: number;
|
|
1507
|
+
result: 'profit' | 'loss' | 'breakeven';
|
|
1508
|
+
tokens: string[];
|
|
1396
1509
|
}
|
|
1397
|
-
interface
|
|
1398
|
-
|
|
1399
|
-
|
|
1510
|
+
interface PeriodSummary {
|
|
1511
|
+
pnl: number;
|
|
1512
|
+
volume: number;
|
|
1513
|
+
winRate: number;
|
|
1514
|
+
wins: number;
|
|
1515
|
+
losses: number;
|
|
1516
|
+
totalProfit: number;
|
|
1517
|
+
totalLoss: number;
|
|
1518
|
+
}
|
|
1519
|
+
interface PnlCalendarWeek {
|
|
1520
|
+
weekStart: string;
|
|
1521
|
+
weekEnd: string;
|
|
1522
|
+
days: PnlCalendarDay[];
|
|
1523
|
+
summary: PeriodSummary;
|
|
1524
|
+
}
|
|
1525
|
+
interface PnlCalendarMonth {
|
|
1526
|
+
month: string;
|
|
1527
|
+
label: string;
|
|
1528
|
+
days: PnlCalendarDay[];
|
|
1529
|
+
summary: PeriodSummary;
|
|
1530
|
+
}
|
|
1531
|
+
interface UsePnlCalendarResult {
|
|
1532
|
+
timeframe: PnlCalendarTimeframe;
|
|
1533
|
+
weeks: PnlCalendarWeek[];
|
|
1534
|
+
months: PnlCalendarMonth[];
|
|
1535
|
+
overall: PeriodSummary;
|
|
1536
|
+
isLoading: boolean;
|
|
1400
1537
|
}
|
|
1401
|
-
declare
|
|
1538
|
+
declare function usePnlCalendar(timeframe?: PnlCalendarTimeframe): UsePnlCalendarResult;
|
|
1402
1539
|
|
|
1403
1540
|
/**
|
|
1404
1541
|
* Mark notifications as read up to a given timestamp (ms)
|
|
@@ -1413,7 +1550,7 @@ declare function markNotificationReadById(baseUrl: string, id: string): Promise<
|
|
|
1413
1550
|
updated: number;
|
|
1414
1551
|
}>>;
|
|
1415
1552
|
|
|
1416
|
-
declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[]
|
|
1553
|
+
declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[]): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
|
|
1417
1554
|
|
|
1418
1555
|
interface KalshiPriceRange {
|
|
1419
1556
|
start: string;
|
|
@@ -1502,23 +1639,6 @@ interface GetKalshiMarketsParams {
|
|
|
1502
1639
|
}
|
|
1503
1640
|
declare function getKalshiMarkets(params?: GetKalshiMarketsParams): Promise<ApiResponse<KalshiMarketsResponse>>;
|
|
1504
1641
|
|
|
1505
|
-
/**
|
|
1506
|
-
* Account summary calculation utility class
|
|
1507
|
-
*/
|
|
1508
|
-
declare class AccountSummaryCalculator {
|
|
1509
|
-
private clearinghouseState;
|
|
1510
|
-
constructor(clearinghouseState: ClearinghouseState | null);
|
|
1511
|
-
/**
|
|
1512
|
-
* Calculate account summary from real-time clearinghouse state and platform orders
|
|
1513
|
-
*/
|
|
1514
|
-
calculateAccountSummary(platformAccountSummary: PlatformAccountSummaryResponseDto | null, registeredAgentWallets: ExtraAgent[]): AccountSummaryResponseDto | null;
|
|
1515
|
-
getClearinghouseState(): ClearinghouseState | null;
|
|
1516
|
-
/**
|
|
1517
|
-
* Check if real-time data is available
|
|
1518
|
-
*/
|
|
1519
|
-
hasRealTimeData(): boolean;
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
1642
|
/**
|
|
1523
1643
|
* Detects conflicts between selected tokens and existing positions
|
|
1524
1644
|
*/
|
|
@@ -1533,43 +1653,6 @@ declare class ConflictDetector {
|
|
|
1533
1653
|
static detectConflicts(longTokens: TokenSelection[], shortTokens: TokenSelection[], openPositions: RawPositionDto[] | null): TokenConflict[];
|
|
1534
1654
|
}
|
|
1535
1655
|
|
|
1536
|
-
/**
|
|
1537
|
-
* Extracts token metadata from aggregated WebData3 contexts and AllMids data
|
|
1538
|
-
*/
|
|
1539
|
-
declare class TokenMetadataExtractor {
|
|
1540
|
-
/**
|
|
1541
|
-
* Extracts comprehensive token metadata
|
|
1542
|
-
* @param symbol - Token symbol (base symbol without prefix, e.g., "TSLA")
|
|
1543
|
-
* @param perpMetaAssets - Aggregated universe assets (flattened across dexes)
|
|
1544
|
-
* @param finalAssetContexts - Aggregated asset contexts (flattened across dexes)
|
|
1545
|
-
* @param allMids - AllMids data containing current prices
|
|
1546
|
-
* @param activeAssetData - Optional active asset data containing leverage information
|
|
1547
|
-
* @param marketPrefix - Optional market prefix (e.g., "xyz", "flx") for HIP3 multi-market assets
|
|
1548
|
-
* @returns TokenMetadata or null if token not found
|
|
1549
|
-
*/
|
|
1550
|
-
static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null, marketPrefix?: string | null): TokenMetadata | null;
|
|
1551
|
-
/**
|
|
1552
|
-
* Extracts metadata for multiple tokens
|
|
1553
|
-
* @param tokens - Array of token objects with symbol and optional marketPrefix
|
|
1554
|
-
* @param perpMetaAssets - Aggregated universe assets
|
|
1555
|
-
* @param finalAssetContexts - Aggregated asset contexts
|
|
1556
|
-
* @param allMids - AllMids data
|
|
1557
|
-
* @param activeAssetData - Optional active asset data containing leverage information
|
|
1558
|
-
* @returns Record of unique key to TokenMetadata. Key is "{prefix}:{symbol}" for HIP3 assets, or just "{symbol}" otherwise
|
|
1559
|
-
*/
|
|
1560
|
-
static extractMultipleTokensMetadata(tokens: Array<{
|
|
1561
|
-
symbol: string;
|
|
1562
|
-
marketPrefix?: string | null;
|
|
1563
|
-
}>, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): Record<string, TokenMetadata | null>;
|
|
1564
|
-
/**
|
|
1565
|
-
* Checks if token data is available in aggregated universe assets
|
|
1566
|
-
* @param symbol - Token symbol
|
|
1567
|
-
* @param perpMetaAssets - Aggregated universe assets
|
|
1568
|
-
* @returns boolean indicating if token exists in universe
|
|
1569
|
-
*/
|
|
1570
|
-
static isTokenAvailable(symbol: string, perpMetaAssets: UniverseAsset[] | null): boolean;
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1573
1656
|
/**
|
|
1574
1657
|
* Create efficient timestamp-based lookup maps for candle data
|
|
1575
1658
|
*/
|
|
@@ -1664,47 +1747,6 @@ declare function validatePositionSize(usdValue: number, longAssets?: PairAssetIn
|
|
|
1664
1747
|
minimumRequired?: number;
|
|
1665
1748
|
};
|
|
1666
1749
|
|
|
1667
|
-
/**
|
|
1668
|
-
* Convert a full/prefixed symbol (e.g., "xyz:XYZ100") to a display symbol (e.g., "XYZ100").
|
|
1669
|
-
*/
|
|
1670
|
-
declare function toDisplaySymbol(symbol: string): string;
|
|
1671
|
-
/**
|
|
1672
|
-
* Convert a display symbol back to backend form using a provided map.
|
|
1673
|
-
* If mapping is missing, returns the original symbol.
|
|
1674
|
-
* For multi-market assets, returns the first available market.
|
|
1675
|
-
* @param displaySymbol e.g., "TSLA"
|
|
1676
|
-
* @param hip3Assets map of display -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"])
|
|
1677
|
-
*/
|
|
1678
|
-
declare function toBackendSymbol(displaySymbol: string, hip3Assets: Map<string, string[]>): string;
|
|
1679
|
-
/**
|
|
1680
|
-
* Convert a display symbol to backend form for a specific market prefix.
|
|
1681
|
-
* This is useful when an asset is available on multiple markets (e.g., xyz:TSLA and flx:TSLA).
|
|
1682
|
-
* @param displaySymbol e.g., "TSLA"
|
|
1683
|
-
* @param marketPrefix e.g., "xyz" or "flx"
|
|
1684
|
-
* @param hip3Assets map of display -> all full market names
|
|
1685
|
-
* @returns Full market name if found, null if prefix not specified for multi-market asset, otherwise displaySymbol with prefix
|
|
1686
|
-
*/
|
|
1687
|
-
declare function toBackendSymbolWithMarket(displaySymbol: string, marketPrefix: string | undefined, hip3Assets: Map<string, string[]>): string | null;
|
|
1688
|
-
/**
|
|
1689
|
-
* Get all available markets for a display symbol.
|
|
1690
|
-
* @param displaySymbol e.g., "TSLA"
|
|
1691
|
-
* @param hip3Assets map of display -> all full market names
|
|
1692
|
-
* @returns Array of full market names, e.g., ["xyz:TSLA", "flx:TSLA"]
|
|
1693
|
-
*/
|
|
1694
|
-
declare function getAvailableMarkets(displaySymbol: string, hip3Assets: Map<string, string[]>): string[];
|
|
1695
|
-
/**
|
|
1696
|
-
* Extract the market prefix from a full market name.
|
|
1697
|
-
* @param fullSymbol e.g., "xyz:TSLA"
|
|
1698
|
-
* @returns The prefix (e.g., "xyz") or undefined if no prefix
|
|
1699
|
-
*/
|
|
1700
|
-
declare function getMarketPrefix(fullSymbol: string): string | undefined;
|
|
1701
|
-
/**
|
|
1702
|
-
* Check if a symbol is a HIP-3 market (has a prefix).
|
|
1703
|
-
* @param symbol e.g., "xyz:TSLA" or "TSLA"
|
|
1704
|
-
* @returns true if the symbol has a market prefix
|
|
1705
|
-
*/
|
|
1706
|
-
declare function isHip3Market(symbol: string): boolean;
|
|
1707
|
-
|
|
1708
1750
|
/**
|
|
1709
1751
|
* Helper functions to safely extract values from order parameters
|
|
1710
1752
|
* based on the order type and parameter structure.
|
|
@@ -1728,7 +1770,7 @@ declare function getOrderTpSlTriggerType(order: OpenLimitOrderDto): TpSlTriggerT
|
|
|
1728
1770
|
/**
|
|
1729
1771
|
* Get trigger type from order parameters (for Trigger orders)
|
|
1730
1772
|
*/
|
|
1731
|
-
declare function getOrderTriggerType(order: OpenLimitOrderDto): TriggerType
|
|
1773
|
+
declare function getOrderTriggerType(order: OpenLimitOrderDto): TriggerType | undefined;
|
|
1732
1774
|
/**
|
|
1733
1775
|
* Get order direction from order parameters (for Trigger orders)
|
|
1734
1776
|
*/
|
|
@@ -1764,12 +1806,10 @@ declare function getOrderTrailingInfo(order: OpenLimitOrderDto): {
|
|
|
1764
1806
|
|
|
1765
1807
|
interface MarketDataState {
|
|
1766
1808
|
marketData: ActiveAssetsResponse | null;
|
|
1767
|
-
marketDataAll: ActiveAssetsAllResponse | null;
|
|
1768
1809
|
setMarketData: (value: ActiveAssetsResponse | null) => void;
|
|
1769
|
-
setMarketDataAll: (value: ActiveAssetsAllResponse | null) => void;
|
|
1770
1810
|
clean: () => void;
|
|
1771
1811
|
}
|
|
1772
1812
|
declare const useMarketData: zustand.UseBoundStore<zustand.StoreApi<MarketDataState>>;
|
|
1773
1813
|
|
|
1774
|
-
export {
|
|
1775
|
-
export type { AccountSummaryResponseDto, ActiveAssetGroupItem, ActiveAssetsResponse, AdjustAdvanceAssetInput, AdjustAdvanceItemInput, AdjustAdvanceResponseDto, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, BalanceSummaryDto, BaseTriggerOrderNotificationParams, BtcDomTriggerParams, CancelOrderResponseDto, CancelTwapResponseDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ClearinghouseState, CloseAllPositionsResponseDto, CloseAllPositionsResultDto, CloseExecutionType, ClosePositionRequestInput, ClosePositionResponseDto,
|
|
1814
|
+
export { ConflictDetector, MAX_ASSETS_PER_LEG, MINIMUM_ASSET_USD_VALUE, MaxAssetsPerLegError, MinimumPositionSizeError, PearHyperliquidProvider, ReadyState, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, executeSpotOrder, getCompleteTimestamps, getKalshiMarkets, getOrderDirection, getOrderLadderConfig, getOrderLeverage, getOrderReduceOnly, getOrderTpSlTriggerType, getOrderTrailingInfo, getOrderTriggerType, getOrderTriggerValue, getOrderTwapDuration, getOrderUsdValue, getPortfolio, isBtcDomOrder, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, updateLeverage, updateRiskParameters, useAccountSummary, useAgentWallet, useAllUserBalances, useAuth, useBasketCandles, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidUserFills, useMarket, useMarketData, useMarketDataHook, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePnlCalendar, usePortfolio, usePosition, useSpotOrder, useTokenSelectionMetadata, useTradeHistories, useTwap, useUserSelection, useWatchlist, validateMaxAssetsPerLeg, validateMinimumAssetSize, validatePositionSize };
|
|
1815
|
+
export type { AccountSummaryResponseDto, ActiveAssetData, ActiveAssetGroupItem, ActiveAssetsAllResponse, ActiveAssetsResponse, AddressState, AdjustAdvanceAssetInput, AdjustAdvanceItemInput, AdjustAdvanceResponseDto, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, AgentWalletStatus, AllDexsAssetCtxsData, AllDexsClearinghouseStateData, AllPerpMetasItem, AllPerpMetasResponse, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, AuthenticateRequest, AuthenticateResponse, AvailableToTrades, BalanceSummaryDto, BaseTriggerOrderNotificationParams, BtcDomTriggerParams, CancelOrderResponseDto, CancelTwapResponseDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ChunkFillDto, ClearinghouseState, CloseAllPositionsResponseDto, CloseAllPositionsResultDto, CloseExecutionType, ClosePositionRequestInput, ClosePositionResponseDto, CollateralToken, CreateAgentWalletResponseDto, CreatePositionRequestInput, CreatePositionResponseDto, CrossAssetPriceTriggerParams, CrossMarginSummaryDto, CumFundingDto, EIP712AuthDetails, ExecutionType, ExternalFillDto, ExternalLiquidationDto, ExtraAgent, GetAgentWalletResponseDto, GetEIP712MessageResponse, GetKalshiMarketsParams, HLChannel, HLChannelDataMap, HLWebSocketResponse, HistoricalRange, KalshiMarket, KalshiMarketsResponse, KalshiMveLeg, KalshiPriceRange, LadderConfigInput, LadderOrderParameters, LeverageInfo, LogoutRequest, LogoutResponse, MarginRequiredPerCollateral, MarginRequiredResult, MarginSummaryDto, MarginTableDef, MarginTablesEntry, MarginTier, MarketOrderParameters, NotificationCategory, NotificationDto, OpenLimitOrderDto, OpenPositionDto, OrderAssetDto, OrderDirection, OrderParameters, OrderStatus, OrderType, PairAssetDto, PairAssetInput, PerformanceOverlay, PeriodSummary, PerpDex, PerpDexsResponse, PerpMetaAsset, PlatformAccountSummaryResponseDto, PnlCalendarDay, PnlCalendarMonth, PnlCalendarTimeframe, PnlCalendarWeek, PortfolioBucketDto, PortfolioInterval, PortfolioIntervalsDto, PortfolioOverallDto, PortfolioResponseDto, PositionAdjustmentType, PositionAssetDetailDto, PredictionMarketOutcomeTriggerParams, PriceRatioTriggerParams, PriceTriggerParams, PrivyAuthDetails, RawAssetDto, RawPositionDto, RealtimeBar, RealtimeBarsCallback, RebalanceAssetPlan, RebalancePlan, RefreshTokenRequest, RefreshTokenResponse, SpotBalance, SpotBalances, SpotOrderFilledStatus, SpotOrderHyperliquidData, SpotOrderHyperliquidResult, SpotOrderRequestInput, SpotOrderResponseDto, SpotState, SyncFillsRequestDto, SyncFillsResponseDto, ToggleWatchlistResponseDto, TokenConflict, TokenEntry, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TokenSelectorConfig, TpSlOrderParameters, TpSlThreshold, TpSlThresholdInput, TpSlThresholdType, TpSlTriggerType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TriggerOrderNotificationAsset, TriggerOrderNotificationParams, TriggerOrderNotificationType, TriggerOrderParameters, TriggerType, TwapChunkStatus, TwapChunkStatusDto, TwapMonitoringDto, TwapOrderOverallStatus, TwapOrderParameters, TwapSliceFillResponseItem, UniverseAsset, UpdateLeverageRequestInput, UpdateLeverageResponseDto, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseHyperliquidUserFillsOptions, UseHyperliquidUserFillsState, UseNotificationsResult, UsePerformanceOverlaysReturn, UsePnlCalendarResult, UsePortfolioResult, UseSpotOrderResult, UseTokenSelectionMetadataReturn, UserAbstraction, UserProfile, UserSelectionState, WatchlistAssetDto, WatchlistItemDto, WebData3AssetCtx, WebData3PerpDexState, WebData3Response, WebData3UserState, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
|