@pear-protocol/hyperliquid-sdk 0.0.5 → 0.0.7-3.beta
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/clients/agentWallet.d.ts +3 -0
- package/dist/clients/auth.d.ts +14 -0
- package/dist/clients/hyperliquid.d.ts +25 -0
- package/dist/clients/notifications.d.ts +13 -0
- package/dist/clients/orders.d.ts +24 -0
- package/dist/clients/portfolio.d.ts +39 -0
- package/dist/clients/positions.d.ts +135 -0
- package/dist/clients/sync.d.ts +9 -0
- package/dist/clients/watchlist.d.ts +2 -0
- package/dist/hooks/index.d.ts +18 -2
- package/dist/hooks/useAccountSummary.d.ts +5 -0
- package/dist/hooks/useAgentWallet.d.ts +5 -0
- package/dist/hooks/useAuth.d.ts +14 -0
- package/dist/hooks/useAutoSyncFills.d.ts +19 -0
- package/dist/hooks/useBasketCandles.d.ts +25 -0
- package/dist/hooks/useHistoricalPriceData.d.ts +11 -0
- package/dist/hooks/useMarketData.d.ts +10 -0
- package/dist/hooks/useNotifications.d.ts +16 -0
- package/dist/hooks/useOrders.d.ts +10 -0
- package/dist/hooks/usePerformanceOverlays.d.ts +14 -0
- package/dist/hooks/usePortfolio.d.ts +13 -0
- package/dist/hooks/usePosition.d.ts +13 -0
- package/dist/hooks/useTokenSelectionMetadata.d.ts +18 -0
- package/dist/hooks/useTrading.d.ts +7 -23
- package/dist/hooks/useTwap.d.ts +6 -0
- package/dist/hooks/useUserSelection.d.ts +3 -0
- package/dist/hooks/useWatchlist.d.ts +6 -0
- package/dist/hooks/useWebData.d.ts +12 -0
- package/dist/hyperliquid-websocket.d.ts +10 -0
- package/dist/index.d.ts +1130 -419
- package/dist/index.js +7207 -5551
- package/dist/provider.d.ts +12 -41
- package/dist/store/historicalPriceDataStore.d.ts +25 -0
- package/dist/store/hyperliquidDataStore.d.ts +25 -0
- package/dist/store/marketDataStore.d.ts +10 -0
- package/dist/store/tokenSelectionMetadataStore.d.ts +27 -0
- package/dist/store/userDataStore.d.ts +30 -0
- package/dist/store/userSelection.d.ts +27 -0
- package/dist/types.d.ts +566 -225
- package/dist/utils/account-summary-calculator.d.ts +17 -0
- package/dist/utils/basket-calculator.d.ts +24 -0
- package/dist/utils/chart-interval-mappers.d.ts +9 -0
- package/dist/utils/conflict-detector.d.ts +14 -0
- package/dist/utils/http.d.ts +26 -0
- package/dist/utils/position-processor.d.ts +2 -0
- package/dist/utils/position-validator.d.ts +61 -0
- package/dist/utils/symbol-translator.d.ts +11 -0
- package/dist/utils/token-metadata-extractor.d.ts +33 -0
- package/dist/websocket.d.ts +9 -0
- package/package.json +19 -6
- package/README.md +0 -230
- package/dist/client.d.ts +0 -43
- package/dist/hooks/useAddress.d.ts +0 -9
- package/dist/hyperliquid-service.d.ts +0 -75
- package/dist/index.esm.js +0 -5862
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js.map +0 -1
- 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, displayToFull: 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,24 @@
|
|
|
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>>;
|
|
@@ -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, displayToFull: 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[], displayToFull: 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[], displayToFull: Map<string, string>): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
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 './useTwap';
|
|
14
|
+
export * from './useNotifications';
|
|
15
|
+
export * from './useMarketData';
|
|
16
|
+
export * from './useWatchlist';
|
|
17
|
+
export * from './usePortfolio';
|
|
18
|
+
export * from './useAuth';
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
readonly setAddress: (address: string | null) => void;
|
|
13
|
+
readonly address: string | null;
|
|
14
|
+
};
|
|
@@ -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,10 @@
|
|
|
1
|
+
import type { ActiveAssetGroupItem, ActiveAssetsResponse, ActiveAssetsAllResponse } from '../types';
|
|
2
|
+
export declare const useMarketDataPayload: () => ActiveAssetsResponse | null;
|
|
3
|
+
export declare const useMarketDataAllPayload: () => ActiveAssetsAllResponse | null;
|
|
4
|
+
export declare const useActiveBaskets: () => ActiveAssetGroupItem[];
|
|
5
|
+
export declare const useTopGainers: (limit?: number) => ActiveAssetGroupItem[];
|
|
6
|
+
export declare const useTopLosers: (limit?: number) => ActiveAssetGroupItem[];
|
|
7
|
+
export declare const useHighlightedBaskets: () => ActiveAssetGroupItem[];
|
|
8
|
+
export declare const useWatchlistBaskets: () => ActiveAssetGroupItem[];
|
|
9
|
+
export declare const useAllBaskets: () => ActiveAssetGroupItem[];
|
|
10
|
+
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,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,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
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
7
|
/**
|
|
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
|
|
8
|
+
* Hook to access open orders with loading state
|
|
22
9
|
*/
|
|
23
|
-
export declare const
|
|
24
|
-
|
|
10
|
+
export declare const useOpenOrders: () => {
|
|
11
|
+
data: OpenLimitOrderDto[] | null;
|
|
25
12
|
isLoading: boolean;
|
|
26
|
-
lastSyncTime: Date | null;
|
|
27
|
-
rawWsSummary: AccountSummaryResponseDto | null;
|
|
28
|
-
resync: () => Promise<void>;
|
|
29
13
|
};
|
|
@@ -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,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,12 @@
|
|
|
1
|
+
import type { AssetMarketData, ClearinghouseState } 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
|
+
marketDataBySymbol: Record<string, AssetMarketData>;
|
|
9
|
+
hip3Assets: Map<string, string>;
|
|
10
|
+
isConnected: boolean;
|
|
11
|
+
error: string | null;
|
|
12
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface UseHyperliquidNativeWebSocketProps {
|
|
2
|
+
address: string | null;
|
|
3
|
+
tokens?: string[];
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface UseHyperliquidNativeWebSocketReturn {
|
|
7
|
+
isConnected: boolean;
|
|
8
|
+
lastError: string | null;
|
|
9
|
+
}
|
|
10
|
+
export declare const useHyperliquidNativeWebSocket: ({ address, enabled, }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|