@pear-protocol/hyperliquid-sdk 0.0.20 → 0.0.24
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/hooks/index.d.ts +1 -0
- package/dist/hooks/useBasketCandles.d.ts +15 -2
- package/dist/hooks/useHistoricalPriceData.d.ts +7 -4
- package/dist/hooks/usePerformanceOverlays.d.ts +14 -0
- package/dist/hyperliquid-websocket.d.ts +1 -3
- package/dist/index.d.ts +67 -43
- package/dist/index.js +576 -499
- package/dist/store/userSelection.d.ts +1 -0
- package/dist/types.d.ts +7 -22
- package/dist/utils/basket-calculator.d.ts +2 -2
- package/dist/utils/chart-interval-mappers.d.ts +9 -0
- package/dist/utils/position-processor.d.ts +2 -22
- package/package.json +5 -2
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CandleData, CandleInterval } from '../types';
|
|
2
2
|
export interface UseBasketCandlesReturn {
|
|
3
|
-
fetchBasketCandles: (startTime: number, endTime: number) => Promise<
|
|
3
|
+
fetchBasketCandles: (startTime: number, endTime: number, interval: CandleInterval) => Promise<CandleData[]>;
|
|
4
|
+
fetchPerformanceCandles: (startTime: number, endTime: number, interval: CandleInterval, symbol: string) => Promise<CandleData[]>;
|
|
5
|
+
fetchOverallPerformanceCandles: (startTime: number, endTime: number, interval: CandleInterval) => Promise<CandleData[]>;
|
|
4
6
|
isLoading: boolean;
|
|
7
|
+
addRealtimeListener: (cb: RealtimeBarsCallback) => string;
|
|
8
|
+
removeRealtimeListener: (id: string) => void;
|
|
5
9
|
}
|
|
10
|
+
export type RealtimeBar = {
|
|
11
|
+
time: number;
|
|
12
|
+
open: number;
|
|
13
|
+
high: number;
|
|
14
|
+
low: number;
|
|
15
|
+
close: number;
|
|
16
|
+
volume?: number;
|
|
17
|
+
};
|
|
18
|
+
export type RealtimeBarsCallback = (bar: RealtimeBar) => void;
|
|
6
19
|
/**
|
|
7
20
|
* Composes historical price fetching with basket candle computation.
|
|
8
21
|
* - Listens to `longTokens` and `shortTokens` from user selection.
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TokenHistoricalPriceData } from '../store/historicalPriceDataStore';
|
|
2
|
+
import type { CandleData, CandleInterval } from '../types';
|
|
2
3
|
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[]>;
|
|
4
|
+
fetchHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval, callback?: (data: Record<string, CandleData[]>) => void) => Promise<Record<string, CandleData[]>>;
|
|
5
|
+
hasHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval) => boolean;
|
|
6
|
+
getHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval) => Record<string, CandleData[]>;
|
|
7
|
+
getAllHistoricalPriceData(): Promise<Record<string, TokenHistoricalPriceData>>;
|
|
8
|
+
fetchFirstCandle: (symbol: string, interval: CandleInterval) => Promise<CandleData | null>;
|
|
6
9
|
isLoading: (symbol?: string) => boolean;
|
|
7
10
|
clearCache: () => void;
|
|
8
11
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PerformanceOverlay {
|
|
2
|
+
id: string;
|
|
3
|
+
symbol: string;
|
|
4
|
+
label: string;
|
|
5
|
+
color: string;
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
type: 'asset' | 'portfolio';
|
|
8
|
+
weight?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface UsePerformanceOverlaysReturn {
|
|
11
|
+
overlays: PerformanceOverlay[];
|
|
12
|
+
generateOverlaySymbols: () => string[];
|
|
13
|
+
}
|
|
14
|
+
export declare const usePerformanceOverlays: () => UsePerformanceOverlaysReturn;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { ReadyState } from 'react-use-websocket';
|
|
2
|
-
import type { CandleInterval } from './types';
|
|
3
2
|
export interface UseHyperliquidNativeWebSocketProps {
|
|
4
3
|
address: string | null;
|
|
5
4
|
tokens?: string[];
|
|
6
|
-
candleInterval?: CandleInterval;
|
|
7
5
|
}
|
|
8
6
|
export interface UseHyperliquidNativeWebSocketReturn {
|
|
9
7
|
connectionStatus: ReadyState;
|
|
10
8
|
isConnected: boolean;
|
|
11
9
|
lastError: string | null;
|
|
12
10
|
}
|
|
13
|
-
export declare const useHyperliquidNativeWebSocket: ({ address,
|
|
11
|
+
export declare const useHyperliquidNativeWebSocket: ({ address, }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
package/dist/index.d.ts
CHANGED
|
@@ -291,6 +291,7 @@ interface PositionAssetDetailDto {
|
|
|
291
291
|
unrealizedPnl: number;
|
|
292
292
|
liquidationPrice: number;
|
|
293
293
|
isExternallyModified: boolean;
|
|
294
|
+
initialWeight: number;
|
|
294
295
|
}
|
|
295
296
|
/**
|
|
296
297
|
* Position sync status
|
|
@@ -615,22 +616,19 @@ type CandleInterval = "1m" | "3m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" |
|
|
|
615
616
|
* Candle data structure from WebSocket
|
|
616
617
|
*/
|
|
617
618
|
interface CandleData {
|
|
619
|
+
s?: string;
|
|
618
620
|
t: number;
|
|
619
621
|
T: number;
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
h: string;
|
|
625
|
-
l: string;
|
|
626
|
-
v: string;
|
|
627
|
-
n: number;
|
|
622
|
+
o: number;
|
|
623
|
+
c: number;
|
|
624
|
+
h: number;
|
|
625
|
+
l: number;
|
|
628
626
|
}
|
|
629
627
|
/**
|
|
630
628
|
* Candle chart data organized by symbol only
|
|
631
629
|
* Since new candles always have latest timestamp, no need to store per interval
|
|
632
630
|
*/
|
|
633
|
-
type CandleChartData =
|
|
631
|
+
type CandleChartData = Map<string, CandleData>;
|
|
634
632
|
/**
|
|
635
633
|
* Historical candle data request
|
|
636
634
|
*/
|
|
@@ -643,19 +641,6 @@ interface CandleSnapshotRequest {
|
|
|
643
641
|
};
|
|
644
642
|
type: "candleSnapshot";
|
|
645
643
|
}
|
|
646
|
-
/**
|
|
647
|
-
* Weighted candle data for chart visualization
|
|
648
|
-
*/
|
|
649
|
-
interface WeightedCandleData {
|
|
650
|
-
t: number;
|
|
651
|
-
T: number;
|
|
652
|
-
o: number;
|
|
653
|
-
c: number;
|
|
654
|
-
h: number;
|
|
655
|
-
l: number;
|
|
656
|
-
v: number;
|
|
657
|
-
n: number;
|
|
658
|
-
}
|
|
659
644
|
|
|
660
645
|
/**
|
|
661
646
|
* Main SDK client for Pear Protocol Hyperliquid API integration
|
|
@@ -840,6 +825,7 @@ interface UserSelectionState {
|
|
|
840
825
|
openConflictModal: boolean;
|
|
841
826
|
conflicts: TokenConflict[];
|
|
842
827
|
candleInterval: CandleInterval;
|
|
828
|
+
isWeightBalanced: boolean;
|
|
843
829
|
setLongTokens: (tokens: TokenSelection[]) => void;
|
|
844
830
|
setShortTokens: (tokens: TokenSelection[]) => void;
|
|
845
831
|
setOpenTokenSelector: (open: boolean) => void;
|
|
@@ -882,19 +868,47 @@ interface UseTokenSelectionMetadataReturn {
|
|
|
882
868
|
}
|
|
883
869
|
declare const useTokenSelectionMetadata: () => UseTokenSelectionMetadataReturn;
|
|
884
870
|
|
|
871
|
+
interface HistoricalRange {
|
|
872
|
+
start: number;
|
|
873
|
+
end: number;
|
|
874
|
+
}
|
|
875
|
+
interface TokenHistoricalPriceData {
|
|
876
|
+
symbol: string;
|
|
877
|
+
interval: CandleInterval;
|
|
878
|
+
candles: CandleData[];
|
|
879
|
+
oldestTime: number | null;
|
|
880
|
+
latestTime: number | null;
|
|
881
|
+
}
|
|
882
|
+
declare const useHistoricalPriceDataStore: any;
|
|
883
|
+
|
|
885
884
|
interface UseHistoricalPriceDataReturn {
|
|
886
|
-
fetchHistoricalPriceData: (startTime: number, endTime: number, callback?: (data: Record<string, CandleData[]>) => void) => Promise<Record<string, CandleData[]>>;
|
|
887
|
-
hasHistoricalPriceData: (startTime: number, endTime: number) => boolean;
|
|
888
|
-
getHistoricalPriceData: (startTime: number, endTime: number) => Record<string, CandleData[]>;
|
|
885
|
+
fetchHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval, callback?: (data: Record<string, CandleData[]>) => void) => Promise<Record<string, CandleData[]>>;
|
|
886
|
+
hasHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval) => boolean;
|
|
887
|
+
getHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval) => Record<string, CandleData[]>;
|
|
888
|
+
getAllHistoricalPriceData(): Promise<Record<string, TokenHistoricalPriceData>>;
|
|
889
|
+
fetchFirstCandle: (symbol: string, interval: CandleInterval) => Promise<CandleData | null>;
|
|
889
890
|
isLoading: (symbol?: string) => boolean;
|
|
890
891
|
clearCache: () => void;
|
|
891
892
|
}
|
|
892
893
|
declare const useHistoricalPriceData: () => UseHistoricalPriceDataReturn;
|
|
893
894
|
|
|
894
895
|
interface UseBasketCandlesReturn {
|
|
895
|
-
fetchBasketCandles: (startTime: number, endTime: number) => Promise<
|
|
896
|
+
fetchBasketCandles: (startTime: number, endTime: number, interval: CandleInterval) => Promise<CandleData[]>;
|
|
897
|
+
fetchPerformanceCandles: (startTime: number, endTime: number, interval: CandleInterval, symbol: string) => Promise<CandleData[]>;
|
|
898
|
+
fetchOverallPerformanceCandles: (startTime: number, endTime: number, interval: CandleInterval) => Promise<CandleData[]>;
|
|
896
899
|
isLoading: boolean;
|
|
900
|
+
addRealtimeListener: (cb: RealtimeBarsCallback) => string;
|
|
901
|
+
removeRealtimeListener: (id: string) => void;
|
|
897
902
|
}
|
|
903
|
+
type RealtimeBar = {
|
|
904
|
+
time: number;
|
|
905
|
+
open: number;
|
|
906
|
+
high: number;
|
|
907
|
+
low: number;
|
|
908
|
+
close: number;
|
|
909
|
+
volume?: number;
|
|
910
|
+
};
|
|
911
|
+
type RealtimeBarsCallback = (bar: RealtimeBar) => void;
|
|
898
912
|
/**
|
|
899
913
|
* Composes historical price fetching with basket candle computation.
|
|
900
914
|
* - Listens to `longTokens` and `shortTokens` from user selection.
|
|
@@ -903,6 +917,21 @@ interface UseBasketCandlesReturn {
|
|
|
903
917
|
*/
|
|
904
918
|
declare const useBasketCandles: () => UseBasketCandlesReturn;
|
|
905
919
|
|
|
920
|
+
interface PerformanceOverlay {
|
|
921
|
+
id: string;
|
|
922
|
+
symbol: string;
|
|
923
|
+
label: string;
|
|
924
|
+
color: string;
|
|
925
|
+
enabled: boolean;
|
|
926
|
+
type: 'asset' | 'portfolio';
|
|
927
|
+
weight?: number;
|
|
928
|
+
}
|
|
929
|
+
interface UsePerformanceOverlaysReturn {
|
|
930
|
+
overlays: PerformanceOverlay[];
|
|
931
|
+
generateOverlaySymbols: () => string[];
|
|
932
|
+
}
|
|
933
|
+
declare const usePerformanceOverlays: () => UsePerformanceOverlaysReturn;
|
|
934
|
+
|
|
906
935
|
interface UseHyperliquidWebSocketProps {
|
|
907
936
|
wsUrl: string;
|
|
908
937
|
address: string | null;
|
|
@@ -916,14 +945,13 @@ declare const useHyperliquidWebSocket: ({ wsUrl, address }: UseHyperliquidWebSoc
|
|
|
916
945
|
interface UseHyperliquidNativeWebSocketProps {
|
|
917
946
|
address: string | null;
|
|
918
947
|
tokens?: string[];
|
|
919
|
-
candleInterval?: CandleInterval;
|
|
920
948
|
}
|
|
921
949
|
interface UseHyperliquidNativeWebSocketReturn {
|
|
922
950
|
connectionStatus: ReadyState;
|
|
923
951
|
isConnected: boolean;
|
|
924
952
|
lastError: string | null;
|
|
925
953
|
}
|
|
926
|
-
declare const useHyperliquidNativeWebSocket: ({ address,
|
|
954
|
+
declare const useHyperliquidNativeWebSocket: ({ address, }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
|
927
955
|
|
|
928
956
|
/**
|
|
929
957
|
* Account summary calculation utility class
|
|
@@ -1016,20 +1044,16 @@ declare const getCompleteTimestamps: (candleLookups: Record<string, Map<number,
|
|
|
1016
1044
|
* Compute basket candles from individual token candles using weighted ratios
|
|
1017
1045
|
* Optimized version that creates lookup maps once and reuses them
|
|
1018
1046
|
*/
|
|
1019
|
-
declare const computeBasketCandles: (longTokens: TokenSelection[], shortTokens: TokenSelection[], tokenCandles: Record<string, CandleData[]>) =>
|
|
1047
|
+
declare const computeBasketCandles: (longTokens: TokenSelection[], shortTokens: TokenSelection[], tokenCandles: Record<string, CandleData[]>) => CandleData[];
|
|
1020
1048
|
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
oldestTime: number | null;
|
|
1030
|
-
latestTime: number | null;
|
|
1031
|
-
}
|
|
1032
|
-
declare const useHistoricalPriceDataStore: any;
|
|
1049
|
+
/**
|
|
1050
|
+
* Maps TradingView ResolutionString to CandleInterval
|
|
1051
|
+
*/
|
|
1052
|
+
declare function mapTradingViewIntervalToCandleInterval(interval: string): CandleInterval;
|
|
1053
|
+
/**
|
|
1054
|
+
* Maps CandleInterval to TradingView ResolutionString
|
|
1055
|
+
*/
|
|
1056
|
+
declare function mapCandleIntervalToTradingViewInterval(interval: CandleInterval): string;
|
|
1033
1057
|
|
|
1034
|
-
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 };
|
|
1035
|
-
export type { AccountSummaryResponseDto, AgentWalletDto, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, BalanceSummaryDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ClearinghouseState, CrossMarginSummaryDto, CumFundingDto, HLWebSocketResponse, 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, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage,
|
|
1058
|
+
export { AccountSummaryCalculator, ConflictDetector, PearHyperliquidClient, PearHyperliquidProvider, PearMigrationSDK, TokenMetadataExtractor, calculateWeightedRatio, computeBasketCandles, createCandleLookups, PearHyperliquidClient as default, getCompleteTimestamps, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, useAccountSummary, useAddress, useBasketCandles, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMigrationSDK, useOpenOrders, useOpenPositions, usePearHyperliquidClient, usePerformanceOverlays, useTokenSelectionMetadata, useTradeHistories, useUserSelection, useWebData };
|
|
1059
|
+
export type { AccountSummaryResponseDto, AgentWalletDto, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, BalanceSummaryDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ClearinghouseState, CrossMarginSummaryDto, CumFundingDto, HLWebSocketResponse, HistoricalRange, MarginSummaryDto, MigrationHookState, MigrationHooks, OpenLimitOrderDto, OpenOrderV1Dto, OpenPositionDto, OpenPositionV1Dto, OrderAssetDto, OrderStatus, PearHyperliquidConfig, PerformanceOverlay, PnlDto, PositionAssetDetailDto, PositionSideDto, PositionSyncStatus, RawValueDto, RealtimeBar, RealtimeBarsCallback, SyncOpenOrderDto, SyncOpenOrderResponseDto, SyncOpenPositionDto, SyncOpenPositionResponseDto, SyncTradeHistoryDto, SyncTradeHistoryResponseDto, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlDto, TradeHistoryAssetDataDto, TradeHistoryDataDto, TradeHistoryV1Dto, UniverseAsset, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UsePerformanceOverlaysReturn, UseTokenSelectionMetadataReturn, UserSelectionState, WebData2Response, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
|