@pear-protocol/hyperliquid-sdk 0.0.11 → 0.0.13
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/use-webdata2.d.ts +10 -0
- package/dist/hooks/useTokenSelection.d.ts +1 -0
- package/dist/hyperliquid-websocket.d.ts +4 -2
- package/dist/index.d.ts +43 -5
- package/dist/index.js +11 -3919
- package/dist/provider.d.ts +3 -1
- package/dist/types.d.ts +22 -1
- package/dist/utils/token-metadata-extractor.d.ts +5 -3
- package/package.json +17 -7
- package/dist/index.esm.js +0 -3908
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/hooks/index.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export { useCalculatedOpenPositions } from './useCalculatedPositions';
|
|
|
4
4
|
export { useCalculatedAccountSummary } from './useCalculatedAccountSummary';
|
|
5
5
|
export { useTokenSelection } from './useTokenSelection';
|
|
6
6
|
export type { TokenSelectorConfig, UseTokenSelectionReturn } from './useTokenSelection';
|
|
7
|
+
export { useWebData2 } from './use-webdata2';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to access webData2 and native WebSocket state
|
|
3
|
+
*/
|
|
4
|
+
export declare const useWebData2: () => {
|
|
5
|
+
webData2: import("..").WebData2Response | null;
|
|
6
|
+
allMids: import("..").WsAllMidsData | null;
|
|
7
|
+
isConnected: boolean;
|
|
8
|
+
connectionStatus: import("react-use-websocket").ReadyState;
|
|
9
|
+
error: string | null;
|
|
10
|
+
};
|
|
@@ -15,6 +15,7 @@ export interface UseTokenSelectionReturn {
|
|
|
15
15
|
sumNetFunding: number;
|
|
16
16
|
maxLeverage: number;
|
|
17
17
|
minMargin: number;
|
|
18
|
+
leverageMatched: boolean;
|
|
18
19
|
setLongTokens: (tokens: TokenSelection[]) => void;
|
|
19
20
|
setShortTokens: (tokens: TokenSelection[]) => void;
|
|
20
21
|
updateTokenWeight: (isLong: boolean, index: number, newWeight: number) => void;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { ReadyState } from 'react-use-websocket';
|
|
2
|
-
import type { WebData2Response, WsAllMidsData } from './types';
|
|
2
|
+
import type { WebData2Response, WsAllMidsData, ActiveAssetData } from './types';
|
|
3
3
|
export interface UseHyperliquidNativeWebSocketProps {
|
|
4
4
|
address: string | null;
|
|
5
|
+
tokens?: string[];
|
|
5
6
|
}
|
|
6
7
|
export interface UseHyperliquidNativeWebSocketReturn {
|
|
7
8
|
webData2: WebData2Response | null;
|
|
8
9
|
allMids: WsAllMidsData | null;
|
|
10
|
+
activeAssetData: Record<string, ActiveAssetData> | null;
|
|
9
11
|
connectionStatus: ReadyState;
|
|
10
12
|
isConnected: boolean;
|
|
11
13
|
lastError: string | null;
|
|
12
14
|
}
|
|
13
|
-
export declare const useHyperliquidNativeWebSocket: ({ address }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
|
15
|
+
export declare const useHyperliquidNativeWebSocket: ({ address, tokens }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
+
import * as react_use_websocket from 'react-use-websocket';
|
|
2
3
|
import { ReadyState } from 'react-use-websocket';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -215,7 +216,7 @@ type WebSocketConnectionState = 'connecting' | 'connected' | 'disconnected' | 'e
|
|
|
215
216
|
/**
|
|
216
217
|
* WebSocket channels
|
|
217
218
|
*/
|
|
218
|
-
type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'webData2' | 'allMids';
|
|
219
|
+
type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'webData2' | 'allMids' | 'activeAssetData';
|
|
219
220
|
/**
|
|
220
221
|
* WebSocket subscription message
|
|
221
222
|
*/
|
|
@@ -542,6 +543,24 @@ interface RawPositionDto {
|
|
|
542
543
|
longAssets: RawAssetDto[];
|
|
543
544
|
shortAssets: RawAssetDto[];
|
|
544
545
|
}
|
|
546
|
+
/**
|
|
547
|
+
* Leverage information from activeAssetData
|
|
548
|
+
*/
|
|
549
|
+
interface LeverageInfo {
|
|
550
|
+
type: string;
|
|
551
|
+
value: number;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Active asset data from WebSocket
|
|
555
|
+
*/
|
|
556
|
+
interface ActiveAssetData {
|
|
557
|
+
user: string;
|
|
558
|
+
coin: string;
|
|
559
|
+
leverage: LeverageInfo;
|
|
560
|
+
maxTradeSzs: [string, string];
|
|
561
|
+
availableToTrade: [string, string];
|
|
562
|
+
markPx: string;
|
|
563
|
+
}
|
|
545
564
|
/**
|
|
546
565
|
* Token metadata from WebData2 and AllMids
|
|
547
566
|
*/
|
|
@@ -556,6 +575,9 @@ interface TokenMetadata {
|
|
|
556
575
|
oraclePrice: number;
|
|
557
576
|
openInterest: string;
|
|
558
577
|
dayVolume: string;
|
|
578
|
+
leverage?: LeverageInfo;
|
|
579
|
+
maxTradeSzs?: [string, string];
|
|
580
|
+
availableToTrade?: [string, string];
|
|
559
581
|
}
|
|
560
582
|
/**
|
|
561
583
|
* Enhanced token selection with weight and metadata for basket trading
|
|
@@ -764,6 +786,7 @@ interface UseTokenSelectionReturn {
|
|
|
764
786
|
sumNetFunding: number;
|
|
765
787
|
maxLeverage: number;
|
|
766
788
|
minMargin: number;
|
|
789
|
+
leverageMatched: boolean;
|
|
767
790
|
setLongTokens: (tokens: TokenSelection[]) => void;
|
|
768
791
|
setShortTokens: (tokens: TokenSelection[]) => void;
|
|
769
792
|
updateTokenWeight: (isLong: boolean, index: number, newWeight: number) => void;
|
|
@@ -781,6 +804,17 @@ interface UseTokenSelectionReturn {
|
|
|
781
804
|
*/
|
|
782
805
|
declare const useTokenSelection: () => UseTokenSelectionReturn;
|
|
783
806
|
|
|
807
|
+
/**
|
|
808
|
+
* Hook to access webData2 and native WebSocket state
|
|
809
|
+
*/
|
|
810
|
+
declare const useWebData2: () => {
|
|
811
|
+
webData2: WebData2Response | null;
|
|
812
|
+
allMids: WsAllMidsData | null;
|
|
813
|
+
isConnected: boolean;
|
|
814
|
+
connectionStatus: react_use_websocket.ReadyState;
|
|
815
|
+
error: string | null;
|
|
816
|
+
};
|
|
817
|
+
|
|
784
818
|
interface WebSocketData {
|
|
785
819
|
tradeHistories: TradeHistoryDataDto[] | null;
|
|
786
820
|
openPositions: RawPositionDto[] | null;
|
|
@@ -801,15 +835,17 @@ declare const useHyperliquidWebSocket: ({ wsUrl, address }: UseHyperliquidWebSoc
|
|
|
801
835
|
|
|
802
836
|
interface UseHyperliquidNativeWebSocketProps {
|
|
803
837
|
address: string | null;
|
|
838
|
+
tokens?: string[];
|
|
804
839
|
}
|
|
805
840
|
interface UseHyperliquidNativeWebSocketReturn {
|
|
806
841
|
webData2: WebData2Response | null;
|
|
807
842
|
allMids: WsAllMidsData | null;
|
|
843
|
+
activeAssetData: Record<string, ActiveAssetData> | null;
|
|
808
844
|
connectionStatus: ReadyState;
|
|
809
845
|
isConnected: boolean;
|
|
810
846
|
lastError: string | null;
|
|
811
847
|
}
|
|
812
|
-
declare const useHyperliquidNativeWebSocket: ({ address }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
|
848
|
+
declare const useHyperliquidNativeWebSocket: ({ address, tokens }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
|
813
849
|
|
|
814
850
|
/**
|
|
815
851
|
* Account summary calculation utility class
|
|
@@ -875,17 +911,19 @@ declare class TokenMetadataExtractor {
|
|
|
875
911
|
* @param symbol - Token symbol
|
|
876
912
|
* @param webData2 - WebData2 response containing asset context and universe data
|
|
877
913
|
* @param allMids - AllMids data containing current prices
|
|
914
|
+
* @param activeAssetData - Optional active asset data containing leverage information
|
|
878
915
|
* @returns TokenMetadata or null if token not found
|
|
879
916
|
*/
|
|
880
|
-
static extractTokenMetadata(symbol: string, webData2: WebData2Response | null, allMids: WsAllMidsData | null): TokenMetadata | null;
|
|
917
|
+
static extractTokenMetadata(symbol: string, webData2: WebData2Response | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): TokenMetadata | null;
|
|
881
918
|
/**
|
|
882
919
|
* Extracts metadata for multiple tokens
|
|
883
920
|
* @param symbols - Array of token symbols
|
|
884
921
|
* @param webData2 - WebData2 response
|
|
885
922
|
* @param allMids - AllMids data
|
|
923
|
+
* @param activeAssetData - Optional active asset data containing leverage information
|
|
886
924
|
* @returns Record of symbol to TokenMetadata
|
|
887
925
|
*/
|
|
888
|
-
static extractMultipleTokensMetadata(symbols: string[], webData2: WebData2Response | null, allMids: WsAllMidsData | null): Record<string, TokenMetadata | null>;
|
|
926
|
+
static extractMultipleTokensMetadata(symbols: string[], webData2: WebData2Response | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): Record<string, TokenMetadata | null>;
|
|
889
927
|
/**
|
|
890
928
|
* Checks if token data is available in WebData2
|
|
891
929
|
* @param symbol - Token symbol
|
|
@@ -895,5 +933,5 @@ declare class TokenMetadataExtractor {
|
|
|
895
933
|
static isTokenAvailable(symbol: string, webData2: WebData2Response | null): boolean;
|
|
896
934
|
}
|
|
897
935
|
|
|
898
|
-
export { AccountSummaryCalculator, ConflictDetector, PearHyperliquidClient, PearHyperliquidProvider, PearMigrationSDK, TokenMetadataExtractor, PearHyperliquidClient as default, useAccountSummary, useAddress, useCalculatedAccountSummary, useCalculatedOpenPositions, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMigrationSDK, useOpenOrders, useOpenPositions, usePearHyperliquidClient, useTokenSelection, useTradeHistories };
|
|
936
|
+
export { AccountSummaryCalculator, ConflictDetector, PearHyperliquidClient, PearHyperliquidProvider, PearMigrationSDK, TokenMetadataExtractor, PearHyperliquidClient as default, useAccountSummary, useAddress, useCalculatedAccountSummary, useCalculatedOpenPositions, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMigrationSDK, useOpenOrders, useOpenPositions, usePearHyperliquidClient, useTokenSelection, useTradeHistories, useWebData2 };
|
|
899
937
|
export type { AccountSummaryResponseDto, AgentWalletDto, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetPosition, BalanceSummaryDto, CrossMarginSummaryDto, CumFundingDto, MarginSummaryDto, MigrationHookState, MigrationHooks, OpenLimitOrderDto, OpenOrderV1Dto, OpenPositionDto, OpenPositionV1Dto, OrderAssetDto, OrderStatus, PearHyperliquidConfig, PnlDto, PositionAssetDetailDto, PositionSideDto, PositionSyncStatus, RawValueDto, SyncOpenOrderDto, SyncOpenOrderResponseDto, SyncOpenPositionDto, SyncOpenPositionResponseDto, SyncTradeHistoryDto, SyncTradeHistoryResponseDto, TokenConflict, TokenMetadata, TokenSelection, TokenSelectorConfig, TpSlDto, TradeHistoryAssetDataDto, TradeHistoryDataDto, TradeHistoryV1Dto, UniverseAsset, UseTokenSelectionReturn, WebData2Response, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketResponse, WebSocketSubscribeMessage, WsAllMidsData };
|