@pear-protocol/hyperliquid-sdk 0.0.5 → 0.0.7-2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/clients/agentWallet.d.ts +3 -0
  2. package/dist/clients/auth.d.ts +14 -0
  3. package/dist/clients/hyperliquid.d.ts +25 -0
  4. package/dist/clients/notifications.d.ts +13 -0
  5. package/dist/clients/orders.d.ts +65 -0
  6. package/dist/clients/portfolio.d.ts +39 -0
  7. package/dist/clients/positions.d.ts +135 -0
  8. package/dist/clients/sync.d.ts +9 -0
  9. package/dist/clients/watchlist.d.ts +2 -0
  10. package/dist/hooks/index.d.ts +20 -2
  11. package/dist/hooks/useAccountSummary.d.ts +5 -0
  12. package/dist/hooks/useAgentWallet.d.ts +5 -0
  13. package/dist/hooks/useAllUserBalances.d.ts +9 -0
  14. package/dist/hooks/useAuth.d.ts +12 -0
  15. package/dist/hooks/useAutoSyncFills.d.ts +19 -0
  16. package/dist/hooks/useBasketCandles.d.ts +25 -0
  17. package/dist/hooks/useHistoricalPriceData.d.ts +11 -0
  18. package/dist/hooks/useMarketData.d.ts +12 -0
  19. package/dist/hooks/useNotifications.d.ts +16 -0
  20. package/dist/hooks/useOrders.d.ts +10 -0
  21. package/dist/hooks/usePerformanceOverlays.d.ts +14 -0
  22. package/dist/hooks/usePortfolio.d.ts +13 -0
  23. package/dist/hooks/usePosition.d.ts +13 -0
  24. package/dist/hooks/useSpotOrder.d.ts +13 -0
  25. package/dist/hooks/useTokenSelectionMetadata.d.ts +18 -0
  26. package/dist/hooks/useTrading.d.ts +6 -25
  27. package/dist/hooks/useTwap.d.ts +6 -0
  28. package/dist/hooks/useUserSelection.d.ts +3 -0
  29. package/dist/hooks/useWatchlist.d.ts +6 -0
  30. package/dist/hooks/useWebData.d.ts +30 -0
  31. package/dist/hyperliquid-websocket.d.ts +10 -0
  32. package/dist/index.d.ts +1301 -414
  33. package/dist/index.js +8290 -5579
  34. package/dist/provider.d.ts +11 -40
  35. package/dist/store/historicalPriceDataStore.d.ts +25 -0
  36. package/dist/store/hyperliquidDataStore.d.ts +31 -0
  37. package/dist/store/marketDataStore.d.ts +10 -0
  38. package/dist/store/tokenSelectionMetadataStore.d.ts +27 -0
  39. package/dist/store/userDataStore.d.ts +30 -0
  40. package/dist/store/userSelection.d.ts +27 -0
  41. package/dist/types.d.ts +617 -222
  42. package/dist/utils/account-summary-calculator.d.ts +17 -0
  43. package/dist/utils/basket-calculator.d.ts +24 -0
  44. package/dist/utils/chart-interval-mappers.d.ts +9 -0
  45. package/dist/utils/conflict-detector.d.ts +14 -0
  46. package/dist/utils/http.d.ts +26 -0
  47. package/dist/utils/position-processor.d.ts +2 -0
  48. package/dist/utils/position-validator.d.ts +61 -0
  49. package/dist/utils/symbol-translator.d.ts +40 -0
  50. package/dist/utils/token-metadata-extractor.d.ts +37 -0
  51. package/dist/websocket.d.ts +9 -0
  52. package/package.json +19 -6
  53. package/README.md +0 -230
  54. package/dist/client.d.ts +0 -43
  55. package/dist/hooks/useAddress.d.ts +0 -9
  56. package/dist/hyperliquid-service.d.ts +0 -75
  57. package/dist/index.esm.js +0 -5862
  58. package/dist/index.esm.js.map +0 -1
  59. package/dist/index.js.map +0 -1
  60. package/dist/migration-sdk.d.ts +0 -59
@@ -0,0 +1,3 @@
1
+ import type { ApiResponse, GetAgentWalletResponseDto, CreateAgentWalletResponseDto } from '../types';
2
+ export declare function getAgentWallet(baseUrl: string): Promise<ApiResponse<GetAgentWalletResponseDto>>;
3
+ export declare function createAgentWallet(baseUrl: string): Promise<ApiResponse<CreateAgentWalletResponseDto>>;
@@ -0,0 +1,14 @@
1
+ import type { ApiResponse, GetEIP712MessageResponse, AuthenticateRequest, AuthenticateResponse, RefreshTokenResponse, LogoutResponse } from '../types';
2
+ export declare function getEIP712Message(baseUrl: string, address: string, clientId: string): Promise<ApiResponse<GetEIP712MessageResponse>>;
3
+ export declare function authenticate(baseUrl: string, body: AuthenticateRequest): Promise<ApiResponse<AuthenticateResponse>>;
4
+ /**
5
+ * Convenience wrapper for Privy access token authentication
6
+ */
7
+ export declare function authenticateWithPrivy(baseUrl: string, params: {
8
+ address: string;
9
+ clientId: string;
10
+ appId: string;
11
+ accessToken: string;
12
+ }): Promise<ApiResponse<AuthenticateResponse>>;
13
+ export declare function refreshToken(baseUrl: string, refreshTokenVal: string): Promise<ApiResponse<RefreshTokenResponse>>;
14
+ export declare function logout(baseUrl: string, refreshTokenVal: string): Promise<ApiResponse<LogoutResponse>>;
@@ -0,0 +1,25 @@
1
+ import type { ApiResponse, CandleInterval, CandleData, ExternalFillDto, AllPerpMetasResponse, ExtraAgent, TwapSliceFillResponseItem } from '../types';
2
+ /**
3
+ * Fetch historical candle data from HyperLiquid API
4
+ */
5
+ export declare const fetchHistoricalCandles: (coin: string, startTime: number, endTime: number, interval: CandleInterval, hip3Assets: Map<string, string[]>) => Promise<ApiResponse<CandleData[]>>;
6
+ /**
7
+ * Retrieve recent user fills from HyperLiquid and map to ExternalFillDto[]
8
+ */
9
+ export declare const fetchUserFillsFromHyperliquid: (user: string, startTime: number, aggregateByTime?: boolean) => Promise<ApiResponse<ExternalFillDto[]>>;
10
+ /**
11
+ * Retrieve user TWAP slice fills from HyperLiquid and map to ExternalFillDto within items
12
+ */
13
+ export declare const fetchUserTwapSliceFillsByTime: (user: string, startTime: number, aggregateByTime?: boolean) => Promise<ApiResponse<TwapSliceFillResponseItem[]>>;
14
+ /**
15
+ * Fetch all perp metas from HyperLiquid API
16
+ * Endpoint: https://api.hyperliquid.xyz/info
17
+ * Payload: { "type": "allPerpMetas" }
18
+ */
19
+ export declare const fetchAllPerpMetas: () => Promise<ApiResponse<AllPerpMetasResponse>>;
20
+ /**
21
+ * Fetch extra agent approvals for a given user from HyperLiquid API
22
+ * Endpoint: https://api.hyperliquid.xyz/info
23
+ * Payload: { "type": "extraAgents", "user": "0x..." }
24
+ */
25
+ export declare const fetchExtraAgents: (user: string) => Promise<ApiResponse<ExtraAgent[]>>;
@@ -0,0 +1,13 @@
1
+ import type { ApiResponse } from '../types';
2
+ /**
3
+ * Mark notifications as read up to a given timestamp (ms)
4
+ */
5
+ export declare function markNotificationsRead(baseUrl: string, timestampMs: number): Promise<ApiResponse<{
6
+ updated: number;
7
+ }>>;
8
+ /**
9
+ * Mark a single notification as read by id
10
+ */
11
+ export declare function markNotificationReadById(baseUrl: string, id: string): Promise<ApiResponse<{
12
+ updated: number;
13
+ }>>;
@@ -0,0 +1,65 @@
1
+ import type { ApiResponse } from '../types';
2
+ export interface AdjustOrderRequestInput {
3
+ limitRatio?: number;
4
+ usdValue?: number;
5
+ }
6
+ export interface AdjustOrderResponseDto {
7
+ orderId: string;
8
+ limitRatio: number;
9
+ usdValue: number;
10
+ updatedAt: string;
11
+ }
12
+ export declare function adjustOrder(baseUrl: string, orderId: string, payload: AdjustOrderRequestInput): Promise<ApiResponse<AdjustOrderResponseDto>>;
13
+ export interface CancelOrderResponseDto {
14
+ orderId: string;
15
+ status: string;
16
+ cancelledAt: string;
17
+ }
18
+ export declare function cancelOrder(baseUrl: string, orderId: string): Promise<ApiResponse<CancelOrderResponseDto>>;
19
+ export interface CancelTwapResponseDto {
20
+ orderId: string;
21
+ status: string;
22
+ cancelledAt: string;
23
+ }
24
+ export declare function cancelTwapOrder(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
25
+ export interface SpotOrderRequestInput {
26
+ /** Asset to buy/sell (e.g., "USDH") */
27
+ asset: string;
28
+ /** Whether to buy (true) or sell (false) the asset */
29
+ isBuy: boolean;
30
+ /** Amount of asset to buy/sell (minimum: 11) */
31
+ amount: number;
32
+ }
33
+ /** Filled order status from Hyperliquid */
34
+ export interface SpotOrderFilledStatus {
35
+ filled: {
36
+ totalSz: string;
37
+ avgPx: string;
38
+ oid: number;
39
+ cloid: string;
40
+ };
41
+ }
42
+ /** Hyperliquid order response data */
43
+ export interface SpotOrderHyperliquidData {
44
+ statuses: SpotOrderFilledStatus[];
45
+ }
46
+ /** Hyperliquid result from spot order execution */
47
+ export interface SpotOrderHyperliquidResult {
48
+ status: 'ok' | 'error';
49
+ response: {
50
+ type: 'order';
51
+ data: SpotOrderHyperliquidData;
52
+ };
53
+ }
54
+ export interface SpotOrderResponseDto {
55
+ orderId: string;
56
+ status: 'EXECUTED' | 'FAILED' | 'PENDING';
57
+ asset: string;
58
+ createdAt: string;
59
+ hyperliquidResult?: SpotOrderHyperliquidResult;
60
+ }
61
+ /**
62
+ * Execute a spot order (swap) using Pear Hyperliquid service
63
+ * POST /orders/spot
64
+ */
65
+ export declare function executeSpotOrder(baseUrl: string, payload: SpotOrderRequestInput): Promise<ApiResponse<SpotOrderResponseDto>>;
@@ -0,0 +1,39 @@
1
+ import type { ApiResponse } from '../types';
2
+ export type PortfolioInterval = '1d' | '1w' | '1m' | '1y' | 'all';
3
+ export interface PortfolioBucketDto {
4
+ periodStart: string;
5
+ periodEnd: string;
6
+ volume: number;
7
+ openInterest: number;
8
+ winningTradesCount: number;
9
+ winningTradesUsd: number;
10
+ losingTradesCount: number;
11
+ losingTradesUsd: number;
12
+ }
13
+ export interface PortfolioOverallDto {
14
+ totalWinningTradesCount: number;
15
+ totalLosingTradesCount: number;
16
+ totalWinningUsd: number;
17
+ totalLosingUsd: number;
18
+ currentOpenInterest: number;
19
+ currentTotalVolume: number;
20
+ unrealizedPnl: number;
21
+ totalTrades: number;
22
+ }
23
+ export interface PortfolioIntervalsDto {
24
+ oneDay: PortfolioBucketDto[];
25
+ oneWeek: PortfolioBucketDto[];
26
+ oneMonth: PortfolioBucketDto[];
27
+ oneYear: PortfolioBucketDto[];
28
+ all: PortfolioBucketDto[];
29
+ }
30
+ export interface PortfolioResponseDto {
31
+ intervals: PortfolioIntervalsDto;
32
+ overall: PortfolioOverallDto;
33
+ }
34
+ /**
35
+ * Get portfolio summary buckets and overall metrics
36
+ * Returns bucketed volume, open interest snapshot, win/loss trade counts, and overall metrics filtered to PEAR fills (cloid LIKE 0x50454152%)
37
+ * Authorization is derived from headers (Axios defaults or browser localStorage fallback)
38
+ */
39
+ export declare function getPortfolio(baseUrl: string): Promise<ApiResponse<PortfolioResponseDto>>;
@@ -0,0 +1,135 @@
1
+ import type { ApiResponse } from "../types";
2
+ import type { CancelTwapResponseDto } from "./orders";
3
+ export type ExecutionType = "MARKET" | "LIMIT" | "TWAP" | "LADDER" | "LIMIT_BTCDOM";
4
+ export type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
5
+ export interface PairAssetInput {
6
+ asset: string;
7
+ weight?: number;
8
+ }
9
+ export interface TpSlThresholdInput {
10
+ type: TpSlThresholdType;
11
+ value: number;
12
+ }
13
+ export interface LadderConfigInput {
14
+ ratioStart: number;
15
+ ratioEnd: number;
16
+ numberOfLevels: number;
17
+ }
18
+ export interface CreatePositionRequestInput {
19
+ slippage: number;
20
+ executionType: ExecutionType;
21
+ leverage: number;
22
+ usdValue: number;
23
+ longAssets?: PairAssetInput[];
24
+ shortAssets?: PairAssetInput[];
25
+ triggerValue?: number;
26
+ direction?: "MORE_THAN" | "LESS_THAN";
27
+ twapDuration?: number;
28
+ twapIntervalSeconds?: number;
29
+ randomizeExecution?: boolean;
30
+ referralCode?: string;
31
+ ladderConfig?: LadderConfigInput;
32
+ takeProfit?: TpSlThresholdInput | null;
33
+ stopLoss?: TpSlThresholdInput | null;
34
+ }
35
+ export type PositionResponseStatus = "SUCCESS" | "FAILED" | "PENDING" | "PARTIALLY_FILLED" | "OPEN";
36
+ export interface PositionAssetSummaryDto {
37
+ asset: string;
38
+ side: "LONG" | "SHORT";
39
+ size: number;
40
+ entryRatio: number;
41
+ usdValue: number;
42
+ orderId: string;
43
+ }
44
+ export interface CreatePositionResponseDto {
45
+ positionId: string | null;
46
+ orderId: string;
47
+ status: PositionResponseStatus;
48
+ createdAt: string;
49
+ assets?: PositionAssetSummaryDto[];
50
+ stopLoss?: TpSlThresholdInput | null;
51
+ takeProfit?: TpSlThresholdInput | null;
52
+ hyperliquidResult?: any;
53
+ }
54
+ /**
55
+ * Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
56
+ * Authorization is derived from headers (Axios defaults or browser localStorage fallback)
57
+ * @throws MinimumPositionSizeError if any asset has less than $11 USD value
58
+ * @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets (15)
59
+ */
60
+ export declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput, hip3Assets: Map<string, string[]>): Promise<ApiResponse<CreatePositionResponseDto>>;
61
+ export interface UpdateRiskParametersRequestInput {
62
+ stopLoss?: TpSlThresholdInput | null;
63
+ takeProfit?: TpSlThresholdInput | null;
64
+ }
65
+ export interface UpdateRiskParametersResponseDto {
66
+ positionId: string;
67
+ stopLoss: TpSlThresholdInput | null;
68
+ takeProfit: TpSlThresholdInput | null;
69
+ updatedAt: string;
70
+ }
71
+ export declare function updateRiskParameters(baseUrl: string, positionId: string, payload: UpdateRiskParametersRequestInput): Promise<ApiResponse<UpdateRiskParametersResponseDto>>;
72
+ export type CloseExecutionType = "MARKET" | "TWAP";
73
+ export interface ClosePositionRequestInput {
74
+ executionType: CloseExecutionType;
75
+ twapDuration?: number;
76
+ twapIntervalSeconds?: number;
77
+ randomizeExecution?: boolean;
78
+ referralCode?: string;
79
+ }
80
+ export interface ClosePositionResponseDto {
81
+ orderId: string;
82
+ executionTime?: string;
83
+ chunksScheduled?: number;
84
+ }
85
+ export declare function closePosition(baseUrl: string, positionId: string, payload: ClosePositionRequestInput): Promise<ApiResponse<ClosePositionResponseDto>>;
86
+ export interface CloseAllPositionsResultDto {
87
+ positionId: string;
88
+ success: boolean;
89
+ orderId?: string;
90
+ error?: string;
91
+ }
92
+ export interface CloseAllPositionsResponseDto {
93
+ results: CloseAllPositionsResultDto[];
94
+ }
95
+ export declare function closeAllPositions(baseUrl: string, payload: ClosePositionRequestInput): Promise<ApiResponse<CloseAllPositionsResponseDto>>;
96
+ export type AdjustExecutionType = "MARKET" | "LIMIT";
97
+ export type PositionAdjustmentType = "REDUCE" | "INCREASE";
98
+ export interface AdjustPositionRequestInput {
99
+ adjustmentType: PositionAdjustmentType;
100
+ adjustmentSize: number;
101
+ executionType: AdjustExecutionType;
102
+ limitRatio?: number;
103
+ referralCode?: string;
104
+ }
105
+ export interface AdjustPositionResponseDto {
106
+ orderId: string;
107
+ status: string;
108
+ adjustmentType: PositionAdjustmentType;
109
+ adjustmentSize: number;
110
+ newSize: number;
111
+ executedAt: string;
112
+ }
113
+ export declare function adjustPosition(baseUrl: string, positionId: string, payload: AdjustPositionRequestInput): Promise<ApiResponse<AdjustPositionResponseDto>>;
114
+ export interface AdjustAdvanceAssetInput {
115
+ asset: string;
116
+ size: number;
117
+ }
118
+ export interface AdjustAdvanceItemInput {
119
+ longAssets?: AdjustAdvanceAssetInput[];
120
+ shortAssets?: AdjustAdvanceAssetInput[];
121
+ }
122
+ export interface AdjustAdvanceResponseDto {
123
+ orderId: string;
124
+ status: string;
125
+ executedAt: string;
126
+ }
127
+ export declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[], hip3Assets: Map<string, string[]>): Promise<ApiResponse<AdjustAdvanceResponseDto>>;
128
+ export declare function cancelTwap(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
129
+ export interface UpdateLeverageRequestInput {
130
+ leverage: number;
131
+ }
132
+ export interface UpdateLeverageResponseDto {
133
+ message?: string;
134
+ }
135
+ export declare function updateLeverage(baseUrl: string, positionId: string, payload: UpdateLeverageRequestInput): Promise<ApiResponse<UpdateLeverageResponseDto | null>>;
@@ -0,0 +1,9 @@
1
+ import type { ApiResponse, AssetPosition, SyncFillsRequestDto, SyncFillsResponseDto } from '../types';
2
+ /**
3
+ * Sync external fills into Pear Hyperliquid service (POST /sync/fills)
4
+ */
5
+ export declare const syncFills: (baseUrl: string, payload: SyncFillsRequestDto) => Promise<ApiResponse<SyncFillsResponseDto>>;
6
+ /**
7
+ * Convenience: fetch user fills from HyperLiquid, then sync them to Pear backend
8
+ */
9
+ export declare const syncUserFillsFromHyperliquid: (baseUrl: string, user: string, aggregateByTime: boolean | undefined, lastSyncAt: number | null | undefined, assetPositions: AssetPosition[]) => Promise<ApiResponse<SyncFillsResponseDto>>;
@@ -0,0 +1,2 @@
1
+ import type { ApiResponse, ToggleWatchlistResponseDto, WatchlistAssetDto } from '../types';
2
+ export declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[], hip3Assets: Map<string, string[]>): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
@@ -1,2 +1,20 @@
1
- export { useAddress } from './useAddress';
2
- export { useTradeHistories, useOpenPositions, useOpenOrders, useAccountSummary } from './useTrading';
1
+ export * from './useAccountSummary';
2
+ export * from './useTrading';
3
+ export * from './useUserSelection';
4
+ export * from './useWebData';
5
+ export * from './useTokenSelectionMetadata';
6
+ export * from './useHistoricalPriceData';
7
+ export * from './useBasketCandles';
8
+ export * from './usePerformanceOverlays';
9
+ export * from './useAgentWallet';
10
+ export * from './useAutoSyncFills';
11
+ export * from './usePosition';
12
+ export * from './useOrders';
13
+ export * from './useSpotOrder';
14
+ export * from './useTwap';
15
+ export * from './useNotifications';
16
+ export * from './useMarketData';
17
+ export * from './useWatchlist';
18
+ export * from './usePortfolio';
19
+ export * from './useAuth';
20
+ export * from './useAllUserBalances';
@@ -0,0 +1,5 @@
1
+ import { AccountSummaryResponseDto } from "../types";
2
+ export declare const useAccountSummary: () => {
3
+ data: AccountSummaryResponseDto | null;
4
+ isLoading: boolean;
5
+ };
@@ -0,0 +1,5 @@
1
+ export declare function useAgentWallet(): {
2
+ readonly refreshAgentWalletStatus: () => Promise<void>;
3
+ readonly createAgentWallet: () => Promise<import("../types").CreateAgentWalletResponseDto>;
4
+ readonly notifyAgentWalletApproved: () => Promise<void>;
5
+ };
@@ -0,0 +1,9 @@
1
+ interface AllUserBalances {
2
+ spotUsdcBalance: number | undefined;
3
+ availableToTradeUsdc: number | undefined;
4
+ spotUsdhBalance: number | undefined;
5
+ availableToTradeUsdh: number | undefined;
6
+ isLoading: boolean;
7
+ }
8
+ export declare const useAllUserBalances: () => AllUserBalances;
9
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { GetEIP712MessageResponse } from "../types";
2
+ export declare function useAuth(): {
3
+ readonly isReady: boolean;
4
+ readonly isAuthenticated: boolean;
5
+ readonly accessToken: string | null;
6
+ readonly refreshToken: string | null;
7
+ readonly getEip712: (address: string) => Promise<GetEIP712MessageResponse>;
8
+ readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
9
+ readonly loginWithPrivyToken: (address: string, appId: string, privyAccessToken: string) => Promise<void>;
10
+ readonly refreshTokens: () => Promise<import("../types").RefreshTokenResponse>;
11
+ readonly logout: () => Promise<void>;
12
+ };
@@ -0,0 +1,19 @@
1
+ import type { SyncFillsResponseDto } from '../types';
2
+ export interface AutoSyncFillsOptions {
3
+ baseUrl: string;
4
+ address: string | null;
5
+ intervalMs?: number;
6
+ aggregateByTime?: boolean;
7
+ }
8
+ export interface AutoSyncFillsState {
9
+ lastRunAt: number | null;
10
+ lastResult: SyncFillsResponseDto | null;
11
+ error: string | null;
12
+ isSyncing: boolean;
13
+ triggerSync: () => Promise<void>;
14
+ }
15
+ /**
16
+ * Listens to address changes and periodically syncs user fills
17
+ * Defaults: aggregate=true, interval=60s
18
+ */
19
+ export declare function useAutoSyncFills(options: AutoSyncFillsOptions): AutoSyncFillsState;
@@ -0,0 +1,25 @@
1
+ import type { CandleData, CandleInterval } from '../types';
2
+ export interface UseBasketCandlesReturn {
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[]>;
6
+ isLoading: boolean;
7
+ addRealtimeListener: (cb: RealtimeBarsCallback) => string;
8
+ removeRealtimeListener: (id: string) => void;
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;
19
+ /**
20
+ * Composes historical price fetching with basket candle computation.
21
+ * - Listens to `longTokens` and `shortTokens` from user selection.
22
+ * - Uses `fetchHistoricalPriceData` to retrieve token candles for the range.
23
+ * - Computes and returns weighted basket candles via `computeBasketCandles`.
24
+ */
25
+ export declare const useBasketCandles: () => UseBasketCandlesReturn;
@@ -0,0 +1,11 @@
1
+ import { TokenHistoricalPriceData } from '../store/historicalPriceDataStore';
2
+ import type { CandleData, CandleInterval } from '../types';
3
+ export interface UseHistoricalPriceDataReturn {
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
+ isLoading: (symbol?: string) => boolean;
9
+ clearCache: () => void;
10
+ }
11
+ export declare const useHistoricalPriceData: () => UseHistoricalPriceDataReturn;
@@ -0,0 +1,12 @@
1
+ import type { ActiveAssetGroupItem, ActiveAssetsResponse, ActiveAssetsAllResponse, UniverseAsset } from '../types';
2
+ export type CollateralFilter = 'USDC' | 'USDH' | 'ALL';
3
+ export declare const useMarketDataPayload: () => ActiveAssetsResponse | null;
4
+ export declare const useMarketDataAllPayload: () => ActiveAssetsAllResponse | null;
5
+ export declare const usePerpMetaAssets: () => UniverseAsset[] | null;
6
+ export declare const useActiveBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
7
+ export declare const useTopGainers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
8
+ export declare const useTopLosers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
9
+ export declare const useHighlightedBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
10
+ export declare const useWatchlistBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
11
+ export declare const useAllBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
12
+ export declare const useFindBasket: (longs: string[], shorts: string[]) => ActiveAssetGroupItem | undefined;
@@ -0,0 +1,16 @@
1
+ import type { NotificationDto } from '../types';
2
+ export interface UseNotificationsResult {
3
+ notifications: NotificationDto[] | null;
4
+ unreadCount: number;
5
+ markReadUntil: (timestampMs: number) => Promise<{
6
+ updated: number;
7
+ }>;
8
+ markReadById: (id: string) => Promise<{
9
+ updated: number;
10
+ }>;
11
+ }
12
+ /**
13
+ * Provides notifications and fills checkpoint data sourced from the SDK WebSocket.
14
+ * Data is persisted in the SDK's Zustand store.
15
+ */
16
+ export declare function useNotifications(): UseNotificationsResult;
@@ -0,0 +1,10 @@
1
+ import type { ApiResponse } from '../types';
2
+ import type { OpenLimitOrderDto } from '../types';
3
+ import { type AdjustOrderRequestInput, type AdjustOrderResponseDto, type CancelOrderResponseDto, type CancelTwapResponseDto } from '../clients/orders';
4
+ export declare function useOrders(): {
5
+ readonly adjustOrder: (orderId: string, payload: AdjustOrderRequestInput) => Promise<ApiResponse<AdjustOrderResponseDto>>;
6
+ readonly cancelOrder: (orderId: string) => Promise<ApiResponse<CancelOrderResponseDto>>;
7
+ readonly cancelTwapOrder: (orderId: string) => Promise<ApiResponse<CancelTwapResponseDto>>;
8
+ readonly openOrders: OpenLimitOrderDto[] | null;
9
+ readonly isLoading: boolean;
10
+ };
@@ -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;
@@ -0,0 +1,13 @@
1
+ import { type PortfolioResponseDto } from '../clients/portfolio';
2
+ export interface UsePortfolioResult {
3
+ data: PortfolioResponseDto | null;
4
+ isLoading: boolean;
5
+ error: Error | null;
6
+ refetch: () => Promise<void>;
7
+ }
8
+ /**
9
+ * Hook to fetch and manage portfolio data
10
+ * Returns bucketed volume, open interest snapshot, win/loss trade counts,
11
+ * and overall metrics
12
+ */
13
+ export declare function usePortfolio(): UsePortfolioResult;
@@ -0,0 +1,13 @@
1
+ import { type CreatePositionRequestInput, type CreatePositionResponseDto, type UpdateRiskParametersRequestInput, type UpdateRiskParametersResponseDto, type ClosePositionRequestInput, type ClosePositionResponseDto, type CloseAllPositionsResponseDto, type AdjustPositionRequestInput, type AdjustPositionResponseDto, type AdjustAdvanceItemInput, type AdjustAdvanceResponseDto, type UpdateLeverageResponseDto } from '../clients/positions';
2
+ import type { ApiResponse, OpenPositionDto } from '../types';
3
+ export declare function usePosition(): {
4
+ readonly createPosition: (payload: CreatePositionRequestInput) => Promise<ApiResponse<CreatePositionResponseDto>>;
5
+ readonly updateRiskParameters: (positionId: string, payload: UpdateRiskParametersRequestInput) => Promise<ApiResponse<UpdateRiskParametersResponseDto>>;
6
+ readonly closePosition: (positionId: string, payload: ClosePositionRequestInput) => Promise<ApiResponse<ClosePositionResponseDto>>;
7
+ readonly closeAllPositions: (payload: ClosePositionRequestInput) => Promise<ApiResponse<CloseAllPositionsResponseDto>>;
8
+ readonly adjustPosition: (positionId: string, payload: AdjustPositionRequestInput) => Promise<ApiResponse<AdjustPositionResponseDto>>;
9
+ readonly adjustAdvancePosition: (positionId: string, payload: AdjustAdvanceItemInput[]) => Promise<ApiResponse<AdjustAdvanceResponseDto>>;
10
+ readonly updateLeverage: (positionId: string, leverage: number) => Promise<ApiResponse<UpdateLeverageResponseDto | null>>;
11
+ readonly openPositions: OpenPositionDto[] | null;
12
+ readonly isLoading: boolean;
13
+ };
@@ -0,0 +1,13 @@
1
+ import type { ApiResponse, ApiErrorResponse } from '../types';
2
+ import { type SpotOrderRequestInput, type SpotOrderResponseDto } from '../clients/orders';
3
+ export interface UseSpotOrderResult {
4
+ executeSpotOrder: (payload: SpotOrderRequestInput) => Promise<ApiResponse<SpotOrderResponseDto>>;
5
+ isLoading: boolean;
6
+ error: ApiErrorResponse | null;
7
+ resetError: () => void;
8
+ }
9
+ /**
10
+ * Hook for executing spot orders (swaps) on Hyperliquid
11
+ * Use this to swap between USDC and USDH or other spot assets
12
+ */
13
+ export declare function useSpotOrder(): UseSpotOrderResult;
@@ -0,0 +1,18 @@
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
+ priceRatio: number;
10
+ priceRatio24h: number;
11
+ openInterest: string;
12
+ volume: string;
13
+ sumNetFunding: number;
14
+ maxLeverage: number;
15
+ minMargin: number;
16
+ leverageMatched: boolean;
17
+ }
18
+ export declare const useTokenSelectionMetadata: () => UseTokenSelectionMetadataReturn;
@@ -1,29 +1,10 @@
1
- import { OpenPositionDto, AccountSummaryResponseDto } from '../types';
2
- /**
3
- * Hook to access trade histories
4
- */
5
- export declare const useTradeHistories: () => import("../types").PaginatedTradeHistoryResponseDto | null;
6
- /**
7
- * Hook to access open positions with enhanced real-time synchronization
8
- */
9
- export declare const useOpenPositions: () => {
10
- positions: OpenPositionDto[];
1
+ import type { OpenLimitOrderDto } from '../types';
2
+ import type { TradeHistoryDataDto } from '../types';
3
+ export declare const useTradeHistories: () => {
4
+ data: TradeHistoryDataDto[] | null;
11
5
  isLoading: boolean;
12
- lastSyncTime: Date | null;
13
- rawWsPositions: OpenPositionDto[] | null;
14
- resync: () => Promise<void>;
15
6
  };
16
- /**
17
- * Hook to access open orders
18
- */
19
- export declare const useOpenOrders: () => import("../types").OpenLimitOrderDto[] | null;
20
- /**
21
- * Hook to access account summary with enhanced real-time data from Hyperliquid
22
- */
23
- export declare const useAccountSummary: () => {
24
- summary: AccountSummaryResponseDto | null;
7
+ export declare const useOpenOrders: () => {
8
+ data: OpenLimitOrderDto[] | null;
25
9
  isLoading: boolean;
26
- lastSyncTime: Date | null;
27
- rawWsSummary: AccountSummaryResponseDto | null;
28
- resync: () => Promise<void>;
29
10
  };
@@ -0,0 +1,6 @@
1
+ import type { ApiResponse, TwapMonitoringDto } from '../types';
2
+ import type { CancelTwapResponseDto } from '../clients/orders';
3
+ export declare function useTwap(): {
4
+ readonly orders: TwapMonitoringDto[];
5
+ readonly cancelTwap: (orderId: string) => Promise<ApiResponse<CancelTwapResponseDto>>;
6
+ };
@@ -0,0 +1,3 @@
1
+ import type { UserSelectionState } from "../store/userSelection";
2
+ export declare const useUserSelection: () => UserSelectionState;
3
+ export type { UserSelectionState };
@@ -0,0 +1,6 @@
1
+ import type { ApiResponse, ToggleWatchlistResponseDto, WatchlistAssetDto, ActiveAssetGroupItem } from '../types';
2
+ export declare function useWatchlist(): {
3
+ readonly watchlists: ActiveAssetGroupItem[] | null;
4
+ readonly isLoading: boolean;
5
+ readonly toggle: (longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[]) => Promise<ApiResponse<ToggleWatchlistResponseDto>>;
6
+ };
@@ -0,0 +1,30 @@
1
+ import type { ClearinghouseState, MarketDataBySymbol } from '../types';
2
+ /**
3
+ * Hook to access webData and native WebSocket state
4
+ */
5
+ export declare const useWebData: () => {
6
+ clearinghouseState: ClearinghouseState | null;
7
+ perpsAtOpenInterestCap: string[] | null;
8
+ /**
9
+ * Market data keyed by symbol, with nested market variants.
10
+ * Each symbol maps to its market variants (keyed by prefix).
11
+ * For non-HIP3 assets, use "default" as the key.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * // HIP-3 asset with multiple markets
16
+ * marketDataBySymbol["TSLA"]["xyz"] // { asset, universe: { collateralToken: "USDC" } }
17
+ * marketDataBySymbol["TSLA"]["flx"] // { asset, universe: { collateralToken: "USDH" } }
18
+ *
19
+ * // Regular asset
20
+ * marketDataBySymbol["BTC"]["default"] // { asset, universe }
21
+ * ```
22
+ */
23
+ marketDataBySymbol: MarketDataBySymbol;
24
+ /** Map of display name -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"]) */
25
+ hip3Assets: Map<string, string[]>;
26
+ /** Map of full market name -> prefix (e.g., "xyz:TSLA" -> "xyz") */
27
+ hip3MarketPrefixes: Map<string, string>;
28
+ isConnected: boolean;
29
+ error: string | null;
30
+ };