@pear-protocol/hyperliquid-sdk 0.0.13 → 0.0.16
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/client.d.ts +10 -1
- package/dist/hooks/index.d.ts +7 -7
- package/dist/hooks/useBasketCandles.d.ts +12 -0
- package/dist/hooks/useHistoricalPriceData.d.ts +9 -0
- package/dist/hooks/useTokenSelectionMetadata.d.ts +14 -0
- package/dist/hooks/useTrading.d.ts +6 -6
- package/dist/hooks/useUserSelection.d.ts +2 -0
- package/dist/hooks/useWebData.d.ts +12 -0
- package/dist/hyperliquid-websocket.d.ts +3 -5
- package/dist/index.d.ts +161 -78
- package/dist/index.js +9886 -8
- package/dist/provider.d.ts +0 -22
- package/dist/store/historicalPriceDataStore.d.ts +14 -0
- package/dist/store/hyperliquidDataStore.d.ts +1 -0
- package/dist/store/tokenSelectionMetadataStore.d.ts +21 -0
- package/dist/store/userDataStore.d.ts +1 -0
- package/dist/{hooks/useTokenSelection.d.ts → store/userSelection.d.ts} +11 -20
- package/dist/types.d.ts +55 -2
- package/dist/utils/basket-calculator.d.ts +24 -0
- package/dist/websocket.d.ts +2 -12
- package/package.json +2 -4
- package/dist/hooks/use-webdata2.d.ts +0 -10
- package/dist/hooks/useCalculatedAccountSummary.d.ts +0 -5
- package/dist/hooks/useCalculatedPositions.d.ts +0 -5
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PearHyperliquidConfig, ApiResponse, SyncTradeHistoryDto, SyncTradeHistoryResponseDto, SyncOpenPositionDto, SyncOpenPositionResponseDto, SyncOpenOrderDto, SyncOpenOrderResponseDto } from './types';
|
|
1
|
+
import { PearHyperliquidConfig, ApiResponse, SyncTradeHistoryDto, SyncTradeHistoryResponseDto, SyncOpenPositionDto, SyncOpenPositionResponseDto, SyncOpenOrderDto, SyncOpenOrderResponseDto, CandleData } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Main SDK client for Pear Protocol Hyperliquid API integration
|
|
4
4
|
*/
|
|
@@ -40,4 +40,13 @@ export declare class PearHyperliquidClient {
|
|
|
40
40
|
* @returns Promise with sync result
|
|
41
41
|
*/
|
|
42
42
|
syncOpenOrders(payload: SyncOpenOrderDto): Promise<ApiResponse<SyncOpenOrderResponseDto>>;
|
|
43
|
+
/**
|
|
44
|
+
* Fetch historical candle data from HyperLiquid API
|
|
45
|
+
* @param coin - Token symbol (e.g., 'BTC', 'ETH')
|
|
46
|
+
* @param startTime - Start time in milliseconds
|
|
47
|
+
* @param endTime - End time in milliseconds
|
|
48
|
+
* @param interval - Candle interval
|
|
49
|
+
* @returns Promise with historical candle data
|
|
50
|
+
*/
|
|
51
|
+
fetchHistoricalCandles(coin: string, startTime: number, endTime: number, interval: string): Promise<ApiResponse<CandleData[]>>;
|
|
43
52
|
}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
1
|
+
export * from './useAddress';
|
|
2
|
+
export * from './useTrading';
|
|
3
|
+
export * from './useUserSelection';
|
|
4
|
+
export * from './useWebData';
|
|
5
|
+
export * from './useTokenSelectionMetadata';
|
|
6
|
+
export * from './useHistoricalPriceData';
|
|
7
|
+
export * from './useBasketCandles';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WeightedCandleData } from '../types';
|
|
2
|
+
export interface UseBasketCandlesReturn {
|
|
3
|
+
fetchBasketCandles: (startTime: number, endTime: number) => Promise<WeightedCandleData[]>;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Composes historical price fetching with basket candle computation.
|
|
8
|
+
* - Listens to `longTokens` and `shortTokens` from user selection.
|
|
9
|
+
* - Uses `fetchHistoricalPriceData` to retrieve token candles for the range.
|
|
10
|
+
* - Computes and returns weighted basket candles via `computeBasketCandles`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const useBasketCandles: () => UseBasketCandlesReturn;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CandleData } from '../types';
|
|
2
|
+
export interface UseHistoricalPriceDataReturn {
|
|
3
|
+
fetchHistoricalPriceData: (startTime: number, endTime: number, callback?: (data: Record<string, CandleData[]>) => void) => Promise<Record<string, CandleData[]>>;
|
|
4
|
+
hasHistoricalPriceData: (startTime: number, endTime: number) => boolean;
|
|
5
|
+
getHistoricalPriceData: (startTime: number, endTime: number) => Record<string, CandleData[]>;
|
|
6
|
+
isLoading: (symbol?: string) => boolean;
|
|
7
|
+
clearCache: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const useHistoricalPriceData: () => UseHistoricalPriceDataReturn;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TokenMetadata } from "../types";
|
|
2
|
+
export interface UseTokenSelectionMetadataReturn {
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
isPriceDataReady: boolean;
|
|
5
|
+
longTokensMetadata: Record<string, TokenMetadata | null>;
|
|
6
|
+
shortTokensMetadata: Record<string, TokenMetadata | null>;
|
|
7
|
+
weightedRatio: number;
|
|
8
|
+
weightedRatio24h: number;
|
|
9
|
+
sumNetFunding: number;
|
|
10
|
+
maxLeverage: number;
|
|
11
|
+
minMargin: number;
|
|
12
|
+
leverageMatched: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const useTokenSelectionMetadata: () => UseTokenSelectionMetadataReturn;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook to access trade histories with loading state
|
|
3
|
-
*/
|
|
4
1
|
export declare const useTradeHistories: () => {
|
|
5
|
-
data:
|
|
2
|
+
data: any;
|
|
6
3
|
isLoading: boolean;
|
|
7
4
|
};
|
|
8
5
|
/**
|
|
9
6
|
* Hook to access open positions with real-time calculations and loading state
|
|
10
7
|
*/
|
|
11
8
|
export declare const useOpenPositions: () => {
|
|
12
|
-
data:
|
|
9
|
+
data: null;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
} | {
|
|
12
|
+
data: import("..").OpenPositionDto[];
|
|
13
13
|
isLoading: boolean;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
16
|
* Hook to access open orders with loading state
|
|
17
17
|
*/
|
|
18
18
|
export declare const useOpenOrders: () => {
|
|
19
|
-
data:
|
|
19
|
+
data: any;
|
|
20
20
|
isLoading: boolean;
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AssetMarketData } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to access webData and native WebSocket state
|
|
4
|
+
*/
|
|
5
|
+
export declare const useWebData: () => {
|
|
6
|
+
clearinghouseState: any;
|
|
7
|
+
perpsAtOpenInterestCap: any;
|
|
8
|
+
marketDataBySymbol: Record<string, AssetMarketData>;
|
|
9
|
+
isConnected: boolean;
|
|
10
|
+
connectionStatus: import("react-use-websocket").ReadyState;
|
|
11
|
+
error: string | null;
|
|
12
|
+
};
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { ReadyState } from 'react-use-websocket';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CandleInterval } from './types';
|
|
3
3
|
export interface UseHyperliquidNativeWebSocketProps {
|
|
4
4
|
address: string | null;
|
|
5
5
|
tokens?: string[];
|
|
6
|
+
candleInterval?: CandleInterval;
|
|
6
7
|
}
|
|
7
8
|
export interface UseHyperliquidNativeWebSocketReturn {
|
|
8
|
-
webData2: WebData2Response | null;
|
|
9
|
-
allMids: WsAllMidsData | null;
|
|
10
|
-
activeAssetData: Record<string, ActiveAssetData> | null;
|
|
11
9
|
connectionStatus: ReadyState;
|
|
12
10
|
isConnected: boolean;
|
|
13
11
|
lastError: string | null;
|
|
14
12
|
}
|
|
15
|
-
export declare const useHyperliquidNativeWebSocket: ({ address, tokens }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
|
13
|
+
export declare const useHyperliquidNativeWebSocket: ({ address, tokens, candleInterval }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
package/dist/index.d.ts
CHANGED
|
@@ -447,7 +447,8 @@ interface UniverseAsset {
|
|
|
447
447
|
name: string;
|
|
448
448
|
szDecimals: number;
|
|
449
449
|
maxLeverage: number;
|
|
450
|
-
onlyIsolated
|
|
450
|
+
onlyIsolated?: boolean;
|
|
451
|
+
isDelisted?: boolean;
|
|
451
452
|
}
|
|
452
453
|
/**
|
|
453
454
|
* WebData2 response structure
|
|
@@ -519,30 +520,6 @@ interface AssetInformationDetail {
|
|
|
519
520
|
priceChange: number;
|
|
520
521
|
assetIndex: number;
|
|
521
522
|
}
|
|
522
|
-
/**
|
|
523
|
-
* Raw asset data from open-positions channel
|
|
524
|
-
*/
|
|
525
|
-
interface RawAssetDto {
|
|
526
|
-
coin: string;
|
|
527
|
-
entryPrice: number;
|
|
528
|
-
size: number;
|
|
529
|
-
side: string;
|
|
530
|
-
}
|
|
531
|
-
/**
|
|
532
|
-
* Raw position data from open-positions channel
|
|
533
|
-
*/
|
|
534
|
-
interface RawPositionDto {
|
|
535
|
-
positionId: string;
|
|
536
|
-
address: string;
|
|
537
|
-
leverage: number;
|
|
538
|
-
stopLoss: number | null;
|
|
539
|
-
takeProfit: number | null;
|
|
540
|
-
status: string;
|
|
541
|
-
createdAt: string;
|
|
542
|
-
updatedAt: string;
|
|
543
|
-
longAssets: RawAssetDto[];
|
|
544
|
-
shortAssets: RawAssetDto[];
|
|
545
|
-
}
|
|
546
523
|
/**
|
|
547
524
|
* Leverage information from activeAssetData
|
|
548
525
|
*/
|
|
@@ -585,7 +562,6 @@ interface TokenMetadata {
|
|
|
585
562
|
interface TokenSelection {
|
|
586
563
|
symbol: string;
|
|
587
564
|
weight: number;
|
|
588
|
-
metadata?: TokenMetadata;
|
|
589
565
|
}
|
|
590
566
|
/**
|
|
591
567
|
* Token conflict information for position conflicts
|
|
@@ -595,6 +571,59 @@ interface TokenConflict {
|
|
|
595
571
|
conflictType: 'long' | 'short';
|
|
596
572
|
conflictMessage: string;
|
|
597
573
|
}
|
|
574
|
+
interface AssetMarketData {
|
|
575
|
+
asset: AssetCtx;
|
|
576
|
+
universe: UniverseAsset;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Candle interval options
|
|
580
|
+
*/
|
|
581
|
+
type CandleInterval = "1m" | "3m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" | "8h" | "12h" | "1d" | "3d" | "1w" | "1M";
|
|
582
|
+
/**
|
|
583
|
+
* Candle data structure from WebSocket
|
|
584
|
+
*/
|
|
585
|
+
interface CandleData {
|
|
586
|
+
t: number;
|
|
587
|
+
T: number;
|
|
588
|
+
s: string;
|
|
589
|
+
i: string;
|
|
590
|
+
o: string;
|
|
591
|
+
c: string;
|
|
592
|
+
h: string;
|
|
593
|
+
l: string;
|
|
594
|
+
v: string;
|
|
595
|
+
n: number;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Candle chart data organized by symbol only
|
|
599
|
+
* Since new candles always have latest timestamp, no need to store per interval
|
|
600
|
+
*/
|
|
601
|
+
type CandleChartData = Record<string, CandleData>;
|
|
602
|
+
/**
|
|
603
|
+
* Historical candle data request
|
|
604
|
+
*/
|
|
605
|
+
interface CandleSnapshotRequest {
|
|
606
|
+
req: {
|
|
607
|
+
coin: string;
|
|
608
|
+
startTime: number;
|
|
609
|
+
endTime: number;
|
|
610
|
+
interval: CandleInterval;
|
|
611
|
+
};
|
|
612
|
+
type: "candleSnapshot";
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Weighted candle data for chart visualization
|
|
616
|
+
*/
|
|
617
|
+
interface WeightedCandleData {
|
|
618
|
+
t: number;
|
|
619
|
+
T: number;
|
|
620
|
+
o: number;
|
|
621
|
+
c: number;
|
|
622
|
+
h: number;
|
|
623
|
+
l: number;
|
|
624
|
+
v: number;
|
|
625
|
+
n: number;
|
|
626
|
+
}
|
|
598
627
|
|
|
599
628
|
/**
|
|
600
629
|
* Main SDK client for Pear Protocol Hyperliquid API integration
|
|
@@ -637,6 +666,15 @@ declare class PearHyperliquidClient {
|
|
|
637
666
|
* @returns Promise with sync result
|
|
638
667
|
*/
|
|
639
668
|
syncOpenOrders(payload: SyncOpenOrderDto): Promise<ApiResponse<SyncOpenOrderResponseDto>>;
|
|
669
|
+
/**
|
|
670
|
+
* Fetch historical candle data from HyperLiquid API
|
|
671
|
+
* @param coin - Token symbol (e.g., 'BTC', 'ETH')
|
|
672
|
+
* @param startTime - Start time in milliseconds
|
|
673
|
+
* @param endTime - End time in milliseconds
|
|
674
|
+
* @param interval - Candle interval
|
|
675
|
+
* @returns Promise with historical candle data
|
|
676
|
+
*/
|
|
677
|
+
fetchHistoricalCandles(coin: string, startTime: number, endTime: number, interval: string): Promise<ApiResponse<CandleData[]>>;
|
|
640
678
|
}
|
|
641
679
|
|
|
642
680
|
/**
|
|
@@ -733,25 +771,25 @@ declare const useAddress: () => {
|
|
|
733
771
|
isLoggedIn: boolean;
|
|
734
772
|
};
|
|
735
773
|
|
|
736
|
-
/**
|
|
737
|
-
* Hook to access trade histories with loading state
|
|
738
|
-
*/
|
|
739
774
|
declare const useTradeHistories: () => {
|
|
740
|
-
data:
|
|
775
|
+
data: any;
|
|
741
776
|
isLoading: boolean;
|
|
742
777
|
};
|
|
743
778
|
/**
|
|
744
779
|
* Hook to access open positions with real-time calculations and loading state
|
|
745
780
|
*/
|
|
746
781
|
declare const useOpenPositions: () => {
|
|
747
|
-
data:
|
|
782
|
+
data: null;
|
|
783
|
+
isLoading: boolean;
|
|
784
|
+
} | {
|
|
785
|
+
data: OpenPositionDto[];
|
|
748
786
|
isLoading: boolean;
|
|
749
787
|
};
|
|
750
788
|
/**
|
|
751
789
|
* Hook to access open orders with loading state
|
|
752
790
|
*/
|
|
753
791
|
declare const useOpenOrders: () => {
|
|
754
|
-
data:
|
|
792
|
+
data: any;
|
|
755
793
|
isLoading: boolean;
|
|
756
794
|
};
|
|
757
795
|
/**
|
|
@@ -762,90 +800,98 @@ declare const useAccountSummary: () => {
|
|
|
762
800
|
isLoading: boolean;
|
|
763
801
|
};
|
|
764
802
|
|
|
765
|
-
|
|
766
|
-
* Hook that calculates open positions by syncing platform positions with HyperLiquid real-time data
|
|
767
|
-
*/
|
|
768
|
-
declare const useCalculatedOpenPositions: (platformPositions: RawPositionDto[] | null, webData2: WebData2Response | null, allMids: WsAllMidsData | null) => OpenPositionDto[] | null;
|
|
769
|
-
|
|
770
|
-
/**
|
|
771
|
-
* Hook that calculates account summary by syncing platform data with HyperLiquid real-time data
|
|
772
|
-
*/
|
|
773
|
-
declare const useCalculatedAccountSummary: (platformAccountSummary: AccountSummaryResponseDto | null, platformOpenOrders: OpenLimitOrderDto[] | null, webData2: WebData2Response | null, agentWalletAddress?: string, agentWalletStatus?: string) => AccountSummaryResponseDto | null;
|
|
774
|
-
|
|
775
|
-
interface UseTokenSelectionReturn {
|
|
803
|
+
interface UserSelectionState {
|
|
776
804
|
longTokens: TokenSelection[];
|
|
777
805
|
shortTokens: TokenSelection[];
|
|
778
806
|
openTokenSelector: boolean;
|
|
779
807
|
selectorConfig: TokenSelectorConfig | null;
|
|
780
808
|
openConflictModal: boolean;
|
|
781
809
|
conflicts: TokenConflict[];
|
|
782
|
-
|
|
783
|
-
isPriceDataReady: boolean;
|
|
784
|
-
weightedRatio: number;
|
|
785
|
-
weightedRatio24h: number;
|
|
786
|
-
sumNetFunding: number;
|
|
787
|
-
maxLeverage: number;
|
|
788
|
-
minMargin: number;
|
|
789
|
-
leverageMatched: boolean;
|
|
810
|
+
candleInterval: CandleInterval;
|
|
790
811
|
setLongTokens: (tokens: TokenSelection[]) => void;
|
|
791
812
|
setShortTokens: (tokens: TokenSelection[]) => void;
|
|
792
|
-
updateTokenWeight: (isLong: boolean, index: number, newWeight: number) => void;
|
|
793
|
-
addToken: (isLong: boolean) => void;
|
|
794
|
-
removeToken: (isLong: boolean, index: number) => void;
|
|
795
|
-
handleTokenSelect: (selectedToken: string) => void;
|
|
796
813
|
setOpenTokenSelector: (open: boolean) => void;
|
|
797
814
|
setSelectorConfig: (config: TokenSelectorConfig | null) => void;
|
|
798
815
|
setOpenConflictModal: (open: boolean) => void;
|
|
799
816
|
setConflicts: (conflicts: TokenConflict[]) => void;
|
|
817
|
+
setCandleInterval: (interval: CandleInterval) => void;
|
|
818
|
+
updateTokenWeight: (isLong: boolean, index: number, newWeight: number) => void;
|
|
819
|
+
addToken: (isLong: boolean) => void;
|
|
820
|
+
removeToken: (isLong: boolean, index: number) => void;
|
|
821
|
+
handleTokenSelect: (selectedToken: string) => void;
|
|
800
822
|
resetToDefaults: () => void;
|
|
801
823
|
}
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
*/
|
|
805
|
-
declare const useTokenSelection: () => UseTokenSelectionReturn;
|
|
824
|
+
|
|
825
|
+
declare const useUserSelection: any;
|
|
806
826
|
|
|
807
827
|
/**
|
|
808
|
-
* Hook to access
|
|
828
|
+
* Hook to access webData and native WebSocket state
|
|
809
829
|
*/
|
|
810
|
-
declare const
|
|
811
|
-
|
|
812
|
-
|
|
830
|
+
declare const useWebData: () => {
|
|
831
|
+
clearinghouseState: any;
|
|
832
|
+
perpsAtOpenInterestCap: any;
|
|
833
|
+
marketDataBySymbol: Record<string, AssetMarketData>;
|
|
813
834
|
isConnected: boolean;
|
|
814
835
|
connectionStatus: react_use_websocket.ReadyState;
|
|
815
836
|
error: string | null;
|
|
816
837
|
};
|
|
817
838
|
|
|
818
|
-
interface
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
839
|
+
interface UseTokenSelectionMetadataReturn {
|
|
840
|
+
isLoading: boolean;
|
|
841
|
+
isPriceDataReady: boolean;
|
|
842
|
+
longTokensMetadata: Record<string, TokenMetadata | null>;
|
|
843
|
+
shortTokensMetadata: Record<string, TokenMetadata | null>;
|
|
844
|
+
weightedRatio: number;
|
|
845
|
+
weightedRatio24h: number;
|
|
846
|
+
sumNetFunding: number;
|
|
847
|
+
maxLeverage: number;
|
|
848
|
+
minMargin: number;
|
|
849
|
+
leverageMatched: boolean;
|
|
850
|
+
}
|
|
851
|
+
declare const useTokenSelectionMetadata: () => UseTokenSelectionMetadataReturn;
|
|
852
|
+
|
|
853
|
+
interface UseHistoricalPriceDataReturn {
|
|
854
|
+
fetchHistoricalPriceData: (startTime: number, endTime: number, callback?: (data: Record<string, CandleData[]>) => void) => Promise<Record<string, CandleData[]>>;
|
|
855
|
+
hasHistoricalPriceData: (startTime: number, endTime: number) => boolean;
|
|
856
|
+
getHistoricalPriceData: (startTime: number, endTime: number) => Record<string, CandleData[]>;
|
|
857
|
+
isLoading: (symbol?: string) => boolean;
|
|
858
|
+
clearCache: () => void;
|
|
859
|
+
}
|
|
860
|
+
declare const useHistoricalPriceData: () => UseHistoricalPriceDataReturn;
|
|
861
|
+
|
|
862
|
+
interface UseBasketCandlesReturn {
|
|
863
|
+
fetchBasketCandles: (startTime: number, endTime: number) => Promise<WeightedCandleData[]>;
|
|
864
|
+
isLoading: boolean;
|
|
823
865
|
}
|
|
866
|
+
/**
|
|
867
|
+
* Composes historical price fetching with basket candle computation.
|
|
868
|
+
* - Listens to `longTokens` and `shortTokens` from user selection.
|
|
869
|
+
* - Uses `fetchHistoricalPriceData` to retrieve token candles for the range.
|
|
870
|
+
* - Computes and returns weighted basket candles via `computeBasketCandles`.
|
|
871
|
+
*/
|
|
872
|
+
declare const useBasketCandles: () => UseBasketCandlesReturn;
|
|
873
|
+
|
|
824
874
|
interface UseHyperliquidWebSocketProps {
|
|
825
875
|
wsUrl: string;
|
|
826
876
|
address: string | null;
|
|
827
877
|
}
|
|
828
|
-
|
|
829
|
-
data: WebSocketData;
|
|
878
|
+
declare const useHyperliquidWebSocket: ({ wsUrl, address }: UseHyperliquidWebSocketProps) => {
|
|
830
879
|
connectionStatus: ReadyState;
|
|
831
880
|
isConnected: boolean;
|
|
832
881
|
lastError: string | null;
|
|
833
|
-
}
|
|
834
|
-
declare const useHyperliquidWebSocket: ({ wsUrl, address }: UseHyperliquidWebSocketProps) => UseHyperliquidWebSocketReturn;
|
|
882
|
+
};
|
|
835
883
|
|
|
836
884
|
interface UseHyperliquidNativeWebSocketProps {
|
|
837
885
|
address: string | null;
|
|
838
886
|
tokens?: string[];
|
|
887
|
+
candleInterval?: CandleInterval;
|
|
839
888
|
}
|
|
840
889
|
interface UseHyperliquidNativeWebSocketReturn {
|
|
841
|
-
webData2: WebData2Response | null;
|
|
842
|
-
allMids: WsAllMidsData | null;
|
|
843
|
-
activeAssetData: Record<string, ActiveAssetData> | null;
|
|
844
890
|
connectionStatus: ReadyState;
|
|
845
891
|
isConnected: boolean;
|
|
846
892
|
lastError: string | null;
|
|
847
893
|
}
|
|
848
|
-
declare const useHyperliquidNativeWebSocket: ({ address, tokens }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
|
894
|
+
declare const useHyperliquidNativeWebSocket: ({ address, tokens, candleInterval }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
|
849
895
|
|
|
850
896
|
/**
|
|
851
897
|
* Account summary calculation utility class
|
|
@@ -933,5 +979,42 @@ declare class TokenMetadataExtractor {
|
|
|
933
979
|
static isTokenAvailable(symbol: string, webData2: WebData2Response | null): boolean;
|
|
934
980
|
}
|
|
935
981
|
|
|
936
|
-
|
|
937
|
-
|
|
982
|
+
/**
|
|
983
|
+
* Create efficient timestamp-based lookup maps for candle data
|
|
984
|
+
*/
|
|
985
|
+
declare const createCandleLookups: (tokenCandles: Record<string, CandleData[]>) => Record<string, Map<number, CandleData>>;
|
|
986
|
+
/**
|
|
987
|
+
* Calculate weighted ratio for a specific price type (open, high, low, close)
|
|
988
|
+
* Uses the formula: LONG_PRODUCT * SHORT_PRODUCT
|
|
989
|
+
* Where LONG_PRODUCT = ∏(PRICE^(WEIGHT/100)) for long tokens
|
|
990
|
+
* And SHORT_PRODUCT = ∏(PRICE^-(WEIGHT/100)) for short tokens
|
|
991
|
+
*
|
|
992
|
+
* Optimized version that uses Map lookups instead of Array.find()
|
|
993
|
+
*/
|
|
994
|
+
declare const calculateWeightedRatio: (longTokens: TokenSelection[], shortTokens: TokenSelection[], candleLookups: Record<string, Map<number, CandleData>>, timestamp: number, priceType: "o" | "h" | "l" | "c") => number;
|
|
995
|
+
/**
|
|
996
|
+
* Get all unique timestamps where ALL required symbols have data
|
|
997
|
+
* Optimized version that uses Map lookups
|
|
998
|
+
*/
|
|
999
|
+
declare const getCompleteTimestamps: (candleLookups: Record<string, Map<number, CandleData>>, requiredSymbols: string[]) => number[];
|
|
1000
|
+
/**
|
|
1001
|
+
* Compute basket candles from individual token candles using weighted ratios
|
|
1002
|
+
* Optimized version that creates lookup maps once and reuses them
|
|
1003
|
+
*/
|
|
1004
|
+
declare const computeBasketCandles: (longTokens: TokenSelection[], shortTokens: TokenSelection[], tokenCandles: Record<string, CandleData[]>) => WeightedCandleData[];
|
|
1005
|
+
|
|
1006
|
+
interface HistoricalRange {
|
|
1007
|
+
start: number;
|
|
1008
|
+
end: number;
|
|
1009
|
+
}
|
|
1010
|
+
interface TokenHistoricalPriceData {
|
|
1011
|
+
symbol: string;
|
|
1012
|
+
interval: CandleInterval;
|
|
1013
|
+
candles: CandleData[];
|
|
1014
|
+
oldestTime: number | null;
|
|
1015
|
+
latestTime: number | null;
|
|
1016
|
+
}
|
|
1017
|
+
declare const useHistoricalPriceDataStore: any;
|
|
1018
|
+
|
|
1019
|
+
export { AccountSummaryCalculator, ConflictDetector, PearHyperliquidClient, PearHyperliquidProvider, PearMigrationSDK, TokenMetadataExtractor, calculateWeightedRatio, computeBasketCandles, createCandleLookups, PearHyperliquidClient as default, getCompleteTimestamps, useAccountSummary, useAddress, useBasketCandles, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMigrationSDK, useOpenOrders, useOpenPositions, usePearHyperliquidClient, useTokenSelectionMetadata, useTradeHistories, useUserSelection, useWebData };
|
|
1020
|
+
export type { AccountSummaryResponseDto, AgentWalletDto, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetPosition, BalanceSummaryDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, CrossMarginSummaryDto, CumFundingDto, HistoricalRange, MarginSummaryDto, MigrationHookState, MigrationHooks, OpenLimitOrderDto, OpenOrderV1Dto, OpenPositionDto, OpenPositionV1Dto, OrderAssetDto, OrderStatus, PearHyperliquidConfig, PnlDto, PositionAssetDetailDto, PositionSideDto, PositionSyncStatus, RawValueDto, SyncOpenOrderDto, SyncOpenOrderResponseDto, SyncOpenPositionDto, SyncOpenPositionResponseDto, SyncTradeHistoryDto, SyncTradeHistoryResponseDto, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlDto, TradeHistoryAssetDataDto, TradeHistoryDataDto, TradeHistoryV1Dto, UniverseAsset, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseTokenSelectionMetadataReturn, UserSelectionState, WebData2Response, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketResponse, WebSocketSubscribeMessage, WeightedCandleData, WsAllMidsData };
|