@pear-protocol/hyperliquid-sdk 0.0.4 → 0.0.7-2.1
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 +65 -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 +20 -2
- package/dist/hooks/useAccountSummary.d.ts +5 -0
- package/dist/hooks/useAgentWallet.d.ts +5 -0
- package/dist/hooks/useAllUserBalances.d.ts +9 -0
- package/dist/hooks/useAuth.d.ts +12 -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 +12 -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/useSpotOrder.d.ts +13 -0
- package/dist/hooks/useTokenSelectionMetadata.d.ts +18 -0
- package/dist/hooks/useTrading.d.ts +10 -16
- 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 +30 -0
- package/dist/hyperliquid-websocket.d.ts +10 -0
- package/dist/index.d.ts +1289 -324
- package/dist/index.js +8432 -2727
- package/dist/provider.d.ts +11 -29
- package/dist/store/historicalPriceDataStore.d.ts +14 -0
- package/dist/store/hyperliquidDataStore.d.ts +1 -0
- package/dist/store/marketDataStore.d.ts +1 -0
- package/dist/store/tokenSelectionMetadataStore.d.ts +27 -0
- package/dist/store/userDataStore.d.ts +1 -0
- package/dist/store/userSelection.d.ts +27 -0
- package/dist/types.d.ts +617 -222
- 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 +40 -0
- package/dist/utils/token-metadata-extractor.d.ts +37 -0
- package/dist/websocket.d.ts +9 -0
- package/package.json +28 -8
- package/README.md +0 -230
- package/dist/client.d.ts +0 -43
- package/dist/hooks/useAddress.d.ts +0 -9
- package/dist/index.esm.js +0 -2830
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/migration-sdk.d.ts +0 -59
package/dist/index.d.ts
CHANGED
|
@@ -1,73 +1,35 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
closePx: string;
|
|
12
|
-
marginUsed: string;
|
|
13
|
-
positionValue: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Trade history data structure from V1 API
|
|
17
|
-
*/
|
|
18
|
-
interface TradeHistoryV1Dto {
|
|
19
|
-
pearId: string;
|
|
20
|
-
openedDate: string;
|
|
21
|
-
closedDate: string;
|
|
22
|
-
time: string;
|
|
23
|
-
pair: string;
|
|
24
|
-
direction: Record<string, string>;
|
|
25
|
-
closedPrice: number;
|
|
26
|
-
openedPrice: number;
|
|
27
|
-
size: string;
|
|
28
|
-
longPositionValue: number;
|
|
29
|
-
shortPositionValue: number;
|
|
30
|
-
positionValue: number;
|
|
31
|
-
fee: number;
|
|
32
|
-
builderFee: number;
|
|
33
|
-
closedPNL: number;
|
|
34
|
-
closedPnlPercentage: number;
|
|
35
|
-
leverage: number;
|
|
36
|
-
rawLongValue: RawValueDto;
|
|
37
|
-
rawShortValue: RawValueDto;
|
|
3
|
+
interface PearHyperliquidContextType {
|
|
4
|
+
clientId: string;
|
|
5
|
+
apiBaseUrl: string;
|
|
6
|
+
wsUrl: string;
|
|
7
|
+
isConnected: boolean;
|
|
8
|
+
lastError: string | null;
|
|
9
|
+
nativeIsConnected: boolean;
|
|
10
|
+
nativeLastError: string | null;
|
|
38
11
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
data: TradeHistoryV1Dto[];
|
|
12
|
+
interface PearHyperliquidProviderProps {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
apiBaseUrl?: string;
|
|
15
|
+
clientId?: string;
|
|
16
|
+
wsUrl?: string;
|
|
45
17
|
}
|
|
46
18
|
/**
|
|
47
|
-
*
|
|
19
|
+
* React Provider for PearHyperliquidClient
|
|
48
20
|
*/
|
|
49
|
-
|
|
50
|
-
success: boolean;
|
|
51
|
-
positionId: string;
|
|
52
|
-
tradeHistoryId: string;
|
|
53
|
-
message: string;
|
|
54
|
-
}
|
|
21
|
+
declare const PearHyperliquidProvider: React.FC<PearHyperliquidProviderProps>;
|
|
55
22
|
/**
|
|
56
|
-
*
|
|
23
|
+
* Hook to access the entire Pear Hyperliquid context.
|
|
24
|
+
* Prefer using the more specific hooks below when possible.
|
|
57
25
|
*/
|
|
26
|
+
declare function usePearHyperliquid(): PearHyperliquidContextType;
|
|
27
|
+
|
|
58
28
|
interface ApiErrorResponse {
|
|
59
29
|
statusCode: number;
|
|
60
30
|
message: string;
|
|
61
31
|
error?: string;
|
|
62
32
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Configuration options for the SDK
|
|
65
|
-
*/
|
|
66
|
-
interface PearHyperliquidConfig {
|
|
67
|
-
baseUrl: string;
|
|
68
|
-
timeout?: number;
|
|
69
|
-
headers?: Record<string, string>;
|
|
70
|
-
}
|
|
71
33
|
/**
|
|
72
34
|
* HTTP client response wrapper
|
|
73
35
|
*/
|
|
@@ -76,136 +38,38 @@ interface ApiResponse<T> {
|
|
|
76
38
|
status: number;
|
|
77
39
|
headers: Record<string, string>;
|
|
78
40
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
loading: boolean;
|
|
84
|
-
error: ApiErrorResponse | null;
|
|
85
|
-
data: T | null;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* PnL data structure for open positions
|
|
89
|
-
*/
|
|
90
|
-
interface PnlDto {
|
|
91
|
-
value: number;
|
|
92
|
-
percentage: number;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Take profit and stop loss data structure
|
|
96
|
-
*/
|
|
97
|
-
interface TpSlDto {
|
|
98
|
-
takeProfit?: number;
|
|
99
|
-
stopLoss?: number;
|
|
41
|
+
interface ExternalLiquidationDto {
|
|
42
|
+
liquidatedUser: string;
|
|
43
|
+
markPx: string;
|
|
44
|
+
method: string;
|
|
100
45
|
}
|
|
101
|
-
|
|
102
|
-
* Position side data structure for open positions
|
|
103
|
-
*/
|
|
104
|
-
interface PositionSideDto {
|
|
46
|
+
interface ExternalFillDto {
|
|
105
47
|
coin: string;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
interface OpenPositionV1Dto {
|
|
120
|
-
pair: string;
|
|
121
|
-
leverage: number;
|
|
122
|
-
size: number;
|
|
123
|
-
longPositionValue?: number;
|
|
124
|
-
shortPositionValue?: number;
|
|
125
|
-
positionValue: number;
|
|
126
|
-
entryPrice: number;
|
|
127
|
-
markPrice: number;
|
|
128
|
-
pnl: PnlDto;
|
|
129
|
-
liqPrice: string | number;
|
|
130
|
-
margin: number;
|
|
131
|
-
funding: number;
|
|
132
|
-
pearId: string;
|
|
133
|
-
openedDate: string;
|
|
134
|
-
tpsl: TpSlDto;
|
|
135
|
-
long: PositionSideDto;
|
|
136
|
-
short: PositionSideDto;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Request payload for syncing open positions
|
|
140
|
-
*/
|
|
141
|
-
interface SyncOpenPositionDto {
|
|
142
|
-
address: string;
|
|
143
|
-
data: OpenPositionV1Dto[];
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Response from sync open positions endpoint
|
|
147
|
-
*/
|
|
148
|
-
interface SyncOpenPositionResponseDto {
|
|
149
|
-
success: boolean;
|
|
150
|
-
positionIds: string[];
|
|
151
|
-
count: number;
|
|
152
|
-
message: string;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Open order data structure from V1 API
|
|
156
|
-
*/
|
|
157
|
-
interface OpenOrderV1Dto {
|
|
158
|
-
id: string;
|
|
159
|
-
time: string;
|
|
160
|
-
pair: string;
|
|
161
|
-
type: string;
|
|
162
|
-
orderValue: number;
|
|
163
|
-
price: number;
|
|
164
|
-
triggerConditions: string;
|
|
165
|
-
status: string;
|
|
166
|
-
leverage?: string;
|
|
48
|
+
px: string;
|
|
49
|
+
sz: string;
|
|
50
|
+
side: 'B' | 'A';
|
|
51
|
+
time: number;
|
|
52
|
+
dir: string;
|
|
53
|
+
fee: string;
|
|
54
|
+
builderFee?: string;
|
|
55
|
+
oid?: string | number;
|
|
56
|
+
tid?: string | number;
|
|
57
|
+
cloid?: string | null;
|
|
58
|
+
hash?: string | null;
|
|
59
|
+
feeToken?: string | null;
|
|
60
|
+
liquidation?: ExternalLiquidationDto | null;
|
|
167
61
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
62
|
+
interface SyncFillsResponseDto {
|
|
63
|
+
insertedFills: number;
|
|
64
|
+
skippedDuplicates: number;
|
|
65
|
+
createdOrders: number;
|
|
66
|
+
updatedPositions: number;
|
|
67
|
+
createdPositions: number;
|
|
68
|
+
closedPositions: number;
|
|
174
69
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
interface SyncOpenOrderResponseDto {
|
|
179
|
-
success: boolean;
|
|
180
|
-
orderIds: string[];
|
|
181
|
-
count: number;
|
|
182
|
-
message: string;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Migration hooks interface
|
|
186
|
-
*/
|
|
187
|
-
interface MigrationHooks {
|
|
188
|
-
tradeHistory: {
|
|
189
|
-
sync: (payload: SyncTradeHistoryDto) => Promise<ApiResponse<SyncTradeHistoryResponseDto>>;
|
|
190
|
-
loading: boolean;
|
|
191
|
-
error: ApiErrorResponse | null;
|
|
192
|
-
data: SyncTradeHistoryResponseDto | null;
|
|
193
|
-
reset: () => void;
|
|
194
|
-
};
|
|
195
|
-
openPositions: {
|
|
196
|
-
sync: (payload: SyncOpenPositionDto) => Promise<ApiResponse<SyncOpenPositionResponseDto>>;
|
|
197
|
-
loading: boolean;
|
|
198
|
-
error: ApiErrorResponse | null;
|
|
199
|
-
data: SyncOpenPositionResponseDto | null;
|
|
200
|
-
reset: () => void;
|
|
201
|
-
};
|
|
202
|
-
openOrders: {
|
|
203
|
-
sync: (payload: SyncOpenOrderDto) => Promise<ApiResponse<SyncOpenOrderResponseDto>>;
|
|
204
|
-
loading: boolean;
|
|
205
|
-
error: ApiErrorResponse | null;
|
|
206
|
-
data: SyncOpenOrderResponseDto | null;
|
|
207
|
-
reset: () => void;
|
|
208
|
-
};
|
|
70
|
+
interface TwapSliceFillResponseItem {
|
|
71
|
+
fill: ExternalFillDto;
|
|
72
|
+
twapId: number;
|
|
209
73
|
}
|
|
210
74
|
/**
|
|
211
75
|
* WebSocket connection states
|
|
@@ -214,7 +78,7 @@ type WebSocketConnectionState = 'connecting' | 'connected' | 'disconnected' | 'e
|
|
|
214
78
|
/**
|
|
215
79
|
* WebSocket channels
|
|
216
80
|
*/
|
|
217
|
-
type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary';
|
|
81
|
+
type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'twap-details' | 'notifications' | 'market-data' | 'market-data-all' | 'webData3' | 'allMids' | 'activeAssetData';
|
|
218
82
|
/**
|
|
219
83
|
* WebSocket subscription message
|
|
220
84
|
*/
|
|
@@ -225,7 +89,7 @@ interface WebSocketSubscribeMessage {
|
|
|
225
89
|
/**
|
|
226
90
|
* WebSocket response message
|
|
227
91
|
*/
|
|
228
|
-
interface
|
|
92
|
+
interface WebSocketAckResponse {
|
|
229
93
|
success?: boolean;
|
|
230
94
|
message?: string;
|
|
231
95
|
error?: string;
|
|
@@ -237,17 +101,85 @@ interface WebSocketDataMessage<T = unknown> {
|
|
|
237
101
|
channel: WebSocketChannel;
|
|
238
102
|
data: T;
|
|
239
103
|
}
|
|
104
|
+
interface WatchlistAssetDto {
|
|
105
|
+
asset: string;
|
|
106
|
+
weight: number;
|
|
107
|
+
}
|
|
108
|
+
interface WatchlistItemDto {
|
|
109
|
+
id: string;
|
|
110
|
+
longAssets: WatchlistAssetDto[];
|
|
111
|
+
shortAssets: WatchlistAssetDto[];
|
|
112
|
+
}
|
|
113
|
+
interface ToggleWatchlistResponseDto {
|
|
114
|
+
items: WatchlistItemDto[];
|
|
115
|
+
}
|
|
116
|
+
type NotificationCategory = 'TRADE_OPENED_OUTSIDE_PEAR' | 'TRADE_CLOSED_OUTSIDE_PEAR' | 'POSITION_LIQUIDATED' | 'LIMIT_ORDER_FILLED' | 'LIMIT_ORDER_FAILED' | 'TP_ORDER_FILLED' | 'TP_ORDER_FAILED' | 'SL_ORDER_FILLED' | 'SL_ORDER_FAILED';
|
|
117
|
+
interface NotificationDto {
|
|
118
|
+
id: string;
|
|
119
|
+
address: string;
|
|
120
|
+
category: NotificationCategory;
|
|
121
|
+
parameters: Record<string, any>;
|
|
122
|
+
is_read: boolean;
|
|
123
|
+
created_at: string;
|
|
124
|
+
updated_at: string;
|
|
125
|
+
}
|
|
126
|
+
interface ChunkFillDto {
|
|
127
|
+
fillId: string;
|
|
128
|
+
assetName: string;
|
|
129
|
+
price: number;
|
|
130
|
+
size: number;
|
|
131
|
+
executedAt: string;
|
|
132
|
+
}
|
|
133
|
+
type TwapChunkStatus = 'PENDING' | 'SCHEDULED' | 'EXECUTING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';
|
|
134
|
+
interface TwapChunkStatusDto {
|
|
135
|
+
chunkId: string;
|
|
136
|
+
chunkIndex: number;
|
|
137
|
+
scheduledTime: string;
|
|
138
|
+
executedTime?: string;
|
|
139
|
+
status: TwapChunkStatus;
|
|
140
|
+
chunkSize: number;
|
|
141
|
+
fills: ChunkFillDto[];
|
|
142
|
+
errorMessage?: string;
|
|
143
|
+
}
|
|
144
|
+
type TwapOrderOverallStatus = 'OPEN' | 'EXECUTING' | 'COMPLETED' | 'PARTIALLY_COMPLETED' | 'FAILED' | 'CANCELLED';
|
|
145
|
+
interface TwapMonitoringDto {
|
|
146
|
+
orderId: string;
|
|
147
|
+
positionId?: string;
|
|
148
|
+
address: string;
|
|
149
|
+
orderType: string;
|
|
150
|
+
status: TwapOrderOverallStatus;
|
|
151
|
+
totalUsdValue: number;
|
|
152
|
+
filledUsdValue: number;
|
|
153
|
+
remainingUsdValue: number;
|
|
154
|
+
twapDuration: string;
|
|
155
|
+
twapIntervalSeconds?: number | null;
|
|
156
|
+
twapChunkUsdValue?: number | null;
|
|
157
|
+
randomizeExecution: boolean;
|
|
158
|
+
reduceOnly: boolean;
|
|
159
|
+
chunks: TwapChunkStatusDto[];
|
|
160
|
+
estimatedCompletionTime?: string;
|
|
161
|
+
actualCompletionTime?: string;
|
|
162
|
+
remainingChunks: number;
|
|
163
|
+
longAssets: OrderAssetDto[];
|
|
164
|
+
shortAssets: OrderAssetDto[];
|
|
165
|
+
createdAt: string;
|
|
166
|
+
updatedAt: string;
|
|
167
|
+
}
|
|
240
168
|
/**
|
|
241
169
|
* Trade history asset data
|
|
242
170
|
*/
|
|
243
171
|
interface TradeHistoryAssetDataDto {
|
|
244
172
|
coin: string;
|
|
173
|
+
entryWeight: number;
|
|
245
174
|
entryPrice: number;
|
|
246
175
|
limitPrice: number;
|
|
176
|
+
leverage: number;
|
|
247
177
|
size: number;
|
|
248
178
|
externalFeePaid: number;
|
|
249
179
|
builderFeePaid: number;
|
|
250
180
|
realizedPnl: number;
|
|
181
|
+
marketPrefix?: string | null;
|
|
182
|
+
collateralToken?: CollateralToken;
|
|
251
183
|
}
|
|
252
184
|
/**
|
|
253
185
|
* Trade history data structure
|
|
@@ -259,23 +191,19 @@ interface TradeHistoryDataDto {
|
|
|
259
191
|
externalFeePaid: number;
|
|
260
192
|
builderFeePaid: number;
|
|
261
193
|
realizedPnl: number;
|
|
194
|
+
realizedPnlPercentage: number;
|
|
195
|
+
totalEntryValue: number;
|
|
262
196
|
totalValue: number;
|
|
263
197
|
entryRatio: number;
|
|
264
198
|
exitRatio: number;
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
199
|
+
entryPriceRatio?: number;
|
|
200
|
+
exitpPriceRatio?: number;
|
|
201
|
+
closedLongAssets: TradeHistoryAssetDataDto[];
|
|
202
|
+
closedShortAssets: TradeHistoryAssetDataDto[];
|
|
203
|
+
positionLongAssets?: string[];
|
|
204
|
+
positionShortAssets?: string[];
|
|
268
205
|
createdAt: string;
|
|
269
206
|
}
|
|
270
|
-
/**
|
|
271
|
-
* Paginated trade history response
|
|
272
|
-
*/
|
|
273
|
-
interface PaginatedTradeHistoryResponseDto {
|
|
274
|
-
data: TradeHistoryDataDto[];
|
|
275
|
-
hasMore: boolean;
|
|
276
|
-
nextCursor?: string;
|
|
277
|
-
count: number;
|
|
278
|
-
}
|
|
279
207
|
/**
|
|
280
208
|
* Cumulative funding information
|
|
281
209
|
*/
|
|
@@ -292,36 +220,40 @@ interface PositionAssetDetailDto {
|
|
|
292
220
|
entryPrice: number;
|
|
293
221
|
platformSize: number;
|
|
294
222
|
actualSize: number;
|
|
295
|
-
|
|
223
|
+
leverage: number;
|
|
296
224
|
marginUsed: number;
|
|
225
|
+
entryPositionValue: number;
|
|
297
226
|
positionValue: number;
|
|
298
227
|
unrealizedPnl: number;
|
|
299
228
|
liquidationPrice: number;
|
|
300
|
-
|
|
229
|
+
initialWeight: number;
|
|
230
|
+
fundingPaid?: number;
|
|
231
|
+
marketPrefix?: string | null;
|
|
232
|
+
collateralToken?: CollateralToken;
|
|
233
|
+
}
|
|
234
|
+
interface TpSlThreshold {
|
|
235
|
+
type: 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
|
|
236
|
+
value: number;
|
|
301
237
|
}
|
|
302
|
-
/**
|
|
303
|
-
* Position sync status
|
|
304
|
-
*/
|
|
305
|
-
type PositionSyncStatus = 'SYNCED' | 'EXTERNALLY_MODIFIED' | 'EXTERNALLY_CLOSED' | 'PAIR_BROKEN';
|
|
306
238
|
/**
|
|
307
239
|
* Open position data structure
|
|
308
240
|
*/
|
|
309
241
|
interface OpenPositionDto {
|
|
310
242
|
positionId: string;
|
|
311
243
|
address: string;
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
takeProfit: number | null;
|
|
244
|
+
stopLoss: TpSlThreshold | null;
|
|
245
|
+
takeProfit: TpSlThreshold | null;
|
|
315
246
|
entryRatio: number;
|
|
316
247
|
markRatio: number;
|
|
317
|
-
|
|
248
|
+
entryPriceRatio?: number;
|
|
249
|
+
markPriceRatio?: number;
|
|
250
|
+
entryPositionValue: number;
|
|
318
251
|
positionValue: number;
|
|
319
252
|
marginUsed: number;
|
|
320
253
|
unrealizedPnl: number;
|
|
254
|
+
unrealizedPnlPercentage: number;
|
|
321
255
|
longAssets: PositionAssetDetailDto[];
|
|
322
256
|
shortAssets: PositionAssetDetailDto[];
|
|
323
|
-
syncStatus: PositionSyncStatus;
|
|
324
|
-
lastSyncAt: string;
|
|
325
257
|
createdAt: string;
|
|
326
258
|
updatedAt: string;
|
|
327
259
|
}
|
|
@@ -331,23 +263,40 @@ interface OpenPositionDto {
|
|
|
331
263
|
interface OrderAssetDto {
|
|
332
264
|
asset: string;
|
|
333
265
|
weight: number;
|
|
266
|
+
marketPrefix?: string | null;
|
|
267
|
+
collateralToken?: CollateralToken;
|
|
334
268
|
}
|
|
335
269
|
/**
|
|
336
270
|
* Order status
|
|
337
271
|
*/
|
|
338
272
|
type OrderStatus = 'OPEN' | 'PARTIALLY_FILLED' | 'PROCESSING';
|
|
273
|
+
/**
|
|
274
|
+
* Order type
|
|
275
|
+
*/
|
|
276
|
+
type OrderType = 'TP' | 'SL' | 'LIMIT' | 'MARKET' | 'LIMIT_BTCDOM' | 'TWAP';
|
|
277
|
+
/**
|
|
278
|
+
* TP/SL trigger type
|
|
279
|
+
*/
|
|
280
|
+
type TpSlTriggerType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
|
|
281
|
+
type OrderDirection = 'MORE_THAN' | 'LESS_THAN' | null;
|
|
339
282
|
/**
|
|
340
283
|
* Open limit order data structure
|
|
341
284
|
*/
|
|
342
285
|
interface OpenLimitOrderDto {
|
|
343
286
|
orderId: string;
|
|
344
287
|
address: string;
|
|
288
|
+
clientId: string | null;
|
|
289
|
+
positionId?: string | null;
|
|
345
290
|
leverage: number;
|
|
346
291
|
usdValue: number;
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
292
|
+
triggerValue?: number | null;
|
|
293
|
+
twapDuration?: string | null;
|
|
294
|
+
tpSlTriggerType?: TpSlTriggerType | null;
|
|
295
|
+
randomizeFlag: boolean;
|
|
296
|
+
reduceOnlyFlag: boolean;
|
|
350
297
|
status: OrderStatus;
|
|
298
|
+
orderType: OrderType;
|
|
299
|
+
direction?: OrderDirection | null;
|
|
351
300
|
longAssets: OrderAssetDto[];
|
|
352
301
|
shortAssets: OrderAssetDto[];
|
|
353
302
|
createdAt: string;
|
|
@@ -385,166 +334,1182 @@ interface BalanceSummaryDto {
|
|
|
385
334
|
* Agent wallet information
|
|
386
335
|
*/
|
|
387
336
|
interface AgentWalletDto {
|
|
388
|
-
address
|
|
337
|
+
address?: string;
|
|
389
338
|
status: string;
|
|
390
339
|
}
|
|
340
|
+
interface PlatformAccountSummaryResponseDto {
|
|
341
|
+
agentWalletAddress: string | null;
|
|
342
|
+
totalClosedTrades: number;
|
|
343
|
+
totalLimitOrderUsdValue?: number;
|
|
344
|
+
totalTwapChunkUsdValue?: number;
|
|
345
|
+
lastSyncedAt?: number;
|
|
346
|
+
}
|
|
391
347
|
/**
|
|
392
348
|
* Account balance response (renamed to AccountSummaryResponseDto for consistency)
|
|
393
349
|
*/
|
|
394
350
|
interface AccountSummaryResponseDto {
|
|
395
351
|
balanceSummary: BalanceSummaryDto;
|
|
396
|
-
|
|
352
|
+
platformAccountSummary: PlatformAccountSummaryResponseDto | null;
|
|
353
|
+
agentWallet?: AgentWalletDto;
|
|
354
|
+
}
|
|
355
|
+
interface UseAuthOptions {
|
|
356
|
+
baseUrl: string;
|
|
357
|
+
clientId: string;
|
|
358
|
+
}
|
|
359
|
+
interface UserProfile {
|
|
360
|
+
userId: string;
|
|
361
|
+
address: string;
|
|
362
|
+
appId: string;
|
|
363
|
+
}
|
|
364
|
+
interface EIP712AuthDetails {
|
|
365
|
+
primaryType: string;
|
|
366
|
+
domain: {
|
|
367
|
+
name: string;
|
|
368
|
+
version: string;
|
|
369
|
+
chainId: number;
|
|
370
|
+
verifyingContract: `0x${string}`;
|
|
371
|
+
};
|
|
372
|
+
types: Record<string, Array<{
|
|
373
|
+
name: string;
|
|
374
|
+
type: string;
|
|
375
|
+
}>>;
|
|
376
|
+
message: Record<string, unknown>;
|
|
377
|
+
timestamp: number;
|
|
378
|
+
}
|
|
379
|
+
interface GetEIP712MessageResponse extends EIP712AuthDetails {
|
|
380
|
+
}
|
|
381
|
+
interface RefreshTokenResponse {
|
|
382
|
+
accessToken: string;
|
|
383
|
+
refreshToken: string;
|
|
384
|
+
tokenType: string;
|
|
385
|
+
expiresIn: number;
|
|
386
|
+
}
|
|
387
|
+
type AgentWalletStatus = 'ACTIVE' | 'EXPIRED' | 'NOT_FOUND';
|
|
388
|
+
interface CreateAgentWalletResponseDto {
|
|
389
|
+
agentWalletAddress: string;
|
|
390
|
+
message: string;
|
|
391
|
+
}
|
|
392
|
+
interface ExtraAgent {
|
|
393
|
+
name: string;
|
|
394
|
+
address: string;
|
|
395
|
+
validUntil: number;
|
|
396
|
+
}
|
|
397
|
+
interface AgentWalletState {
|
|
398
|
+
address: string | null;
|
|
399
|
+
name: string | null;
|
|
400
|
+
status: AgentWalletStatus | 'PENDING' | null;
|
|
401
|
+
isActive: boolean;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* WebSocket message from HyperLiquid native API
|
|
405
|
+
*/
|
|
406
|
+
interface WebSocketMessage {
|
|
407
|
+
method: 'subscribe' | 'unsubscribe';
|
|
408
|
+
subscription: {
|
|
409
|
+
type: string;
|
|
410
|
+
dex?: string;
|
|
411
|
+
coin?: string;
|
|
412
|
+
interval?: string;
|
|
413
|
+
user?: string;
|
|
414
|
+
aggregateByTime?: boolean;
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* WebSocket response from HyperLiquid native API
|
|
419
|
+
*/
|
|
420
|
+
type HLChannel = 'webData3' | 'allMids' | 'activeAssetData' | 'candle' | 'spotState' | 'allDexsClearinghouseState' | 'allDexsAssetCtxs';
|
|
421
|
+
interface HLChannelDataMap {
|
|
422
|
+
webData3: WebData3Response;
|
|
423
|
+
allMids: WsAllMidsData;
|
|
424
|
+
activeAssetData: ActiveAssetData;
|
|
425
|
+
candle: CandleData;
|
|
426
|
+
spotState: {
|
|
427
|
+
user: string;
|
|
428
|
+
spotState: SpotState;
|
|
429
|
+
};
|
|
430
|
+
allDexsClearinghouseState: AllDexsClearinghouseStateData;
|
|
431
|
+
allDexsAssetCtxs: AllDexsAssetCtxsData;
|
|
432
|
+
}
|
|
433
|
+
interface WebData3UserState {
|
|
434
|
+
agentAddress?: string;
|
|
435
|
+
agentValidUntil?: number;
|
|
436
|
+
cumLedger: string;
|
|
437
|
+
serverTime: number;
|
|
438
|
+
isVault: boolean;
|
|
439
|
+
user: string;
|
|
440
|
+
dexAbstractionEnabled?: boolean;
|
|
441
|
+
}
|
|
442
|
+
interface WebData3AssetCtx {
|
|
443
|
+
funding: string;
|
|
444
|
+
openInterest: string;
|
|
445
|
+
prevDayPx: string;
|
|
446
|
+
dayNtlVlm: string;
|
|
447
|
+
premium: string | null;
|
|
448
|
+
oraclePx: string;
|
|
449
|
+
markPx: string;
|
|
450
|
+
midPx: string | null;
|
|
451
|
+
impactPxs: string[] | null;
|
|
452
|
+
dayBaseVlm: string;
|
|
397
453
|
}
|
|
454
|
+
interface WebData3PerpDexState {
|
|
455
|
+
clearinghouseState: ClearinghouseState;
|
|
456
|
+
totalVaultEquity: string;
|
|
457
|
+
assetCtxs: WebData3AssetCtx[];
|
|
458
|
+
perpsAtOpenInterestCap: string[];
|
|
459
|
+
}
|
|
460
|
+
interface WebData3Response {
|
|
461
|
+
userState: WebData3UserState;
|
|
462
|
+
perpDexStates: WebData3PerpDexState[];
|
|
463
|
+
}
|
|
464
|
+
interface AllDexsClearinghouseStateData {
|
|
465
|
+
user: string;
|
|
466
|
+
clearinghouseStates: [string, ClearinghouseState][];
|
|
467
|
+
}
|
|
468
|
+
interface AllDexsAssetCtxsData {
|
|
469
|
+
ctxs: [string, WebData3AssetCtx[]][];
|
|
470
|
+
}
|
|
471
|
+
interface HLWebSocketResponse<T extends HLChannel = HLChannel> {
|
|
472
|
+
channel: T;
|
|
473
|
+
data: HLChannelDataMap[T];
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* All mids data structure
|
|
477
|
+
*/
|
|
478
|
+
interface WsAllMidsData {
|
|
479
|
+
mids: Record<string, string>;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Asset context data
|
|
483
|
+
*/
|
|
484
|
+
interface AssetCtx {
|
|
485
|
+
funding: string;
|
|
486
|
+
openInterest: string;
|
|
487
|
+
prevDayPx: string;
|
|
488
|
+
dayNtlVlm: string;
|
|
489
|
+
markPx: string;
|
|
490
|
+
midPx?: string;
|
|
491
|
+
impactPxs?: string[];
|
|
492
|
+
oraclePx: string;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Collateral token type
|
|
496
|
+
* 0 = USDC
|
|
497
|
+
* 360 = USDH
|
|
498
|
+
*/
|
|
499
|
+
type CollateralToken = 'USDC' | 'USDH';
|
|
500
|
+
/**
|
|
501
|
+
* Universe asset metadata
|
|
502
|
+
*/
|
|
503
|
+
interface UniverseAsset {
|
|
504
|
+
name: string;
|
|
505
|
+
szDecimals: number;
|
|
506
|
+
maxLeverage: number;
|
|
507
|
+
onlyIsolated?: boolean;
|
|
508
|
+
isDelisted?: boolean;
|
|
509
|
+
marketPrefix?: string;
|
|
510
|
+
collateralToken?: CollateralToken;
|
|
511
|
+
}
|
|
512
|
+
interface ClearinghouseState {
|
|
513
|
+
assetPositions: AssetPosition[];
|
|
514
|
+
crossMaintenanceMarginUsed: string;
|
|
515
|
+
crossMarginSummary: {
|
|
516
|
+
accountValue: string;
|
|
517
|
+
totalMarginUsed: string;
|
|
518
|
+
totalNtlPos: string;
|
|
519
|
+
totalRawUsd: string;
|
|
520
|
+
};
|
|
521
|
+
marginSummary: {
|
|
522
|
+
accountValue: string;
|
|
523
|
+
totalMarginUsed: string;
|
|
524
|
+
totalNtlPos: string;
|
|
525
|
+
totalRawUsd: string;
|
|
526
|
+
};
|
|
527
|
+
time: number;
|
|
528
|
+
withdrawable: string;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Asset position data
|
|
532
|
+
*/
|
|
533
|
+
interface AssetPosition {
|
|
534
|
+
position: {
|
|
535
|
+
coin: string;
|
|
536
|
+
entryPx?: string;
|
|
537
|
+
leverage: {
|
|
538
|
+
type: string;
|
|
539
|
+
value: number;
|
|
540
|
+
};
|
|
541
|
+
liquidationPx?: string;
|
|
542
|
+
marginUsed: string;
|
|
543
|
+
maxLeverage: number;
|
|
544
|
+
positionValue: string;
|
|
545
|
+
returnOnEquity: string;
|
|
546
|
+
szi: string;
|
|
547
|
+
unrealizedPnl: string;
|
|
548
|
+
cumFunding: {
|
|
549
|
+
allTime: string;
|
|
550
|
+
sinceChange: string;
|
|
551
|
+
sinceOpen: string;
|
|
552
|
+
};
|
|
553
|
+
};
|
|
554
|
+
type: string;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Asset information detail
|
|
558
|
+
*/
|
|
559
|
+
interface AssetInformationDetail {
|
|
560
|
+
name: string;
|
|
561
|
+
funding: string;
|
|
562
|
+
openInterest: string;
|
|
563
|
+
prevDayPx: string;
|
|
564
|
+
dayNtlVlm: string;
|
|
565
|
+
oraclePx: string;
|
|
566
|
+
markPx: string;
|
|
567
|
+
midPx?: string;
|
|
568
|
+
dayBaseVlm: string;
|
|
569
|
+
priceChange: number;
|
|
570
|
+
assetIndex: number;
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Raw asset data from open-positions channel
|
|
574
|
+
*/
|
|
575
|
+
interface RawAssetDto {
|
|
576
|
+
coin: string;
|
|
577
|
+
entryPrice: number;
|
|
578
|
+
size: number;
|
|
579
|
+
side: string;
|
|
580
|
+
fundingPaid?: number;
|
|
581
|
+
marketPrefix?: string | null;
|
|
582
|
+
collateralToken?: CollateralToken;
|
|
583
|
+
leverage: number;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Raw position data from open-positions channel
|
|
587
|
+
*/
|
|
588
|
+
interface RawPositionDto {
|
|
589
|
+
positionId: string;
|
|
590
|
+
address: string;
|
|
591
|
+
stopLoss: number | null;
|
|
592
|
+
takeProfit: number | null;
|
|
593
|
+
status: string;
|
|
594
|
+
createdAt: string;
|
|
595
|
+
updatedAt: string;
|
|
596
|
+
longAssets: RawAssetDto[];
|
|
597
|
+
shortAssets: RawAssetDto[];
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Leverage information from activeAssetData
|
|
601
|
+
*/
|
|
602
|
+
interface LeverageInfo {
|
|
603
|
+
type: string;
|
|
604
|
+
value: number;
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* Active asset data from WebSocket
|
|
608
|
+
*/
|
|
609
|
+
interface ActiveAssetData {
|
|
610
|
+
user: string;
|
|
611
|
+
coin: string;
|
|
612
|
+
leverage: LeverageInfo;
|
|
613
|
+
maxTradeSzs: [string, string];
|
|
614
|
+
availableToTrade: [string, string];
|
|
615
|
+
markPx: string;
|
|
616
|
+
}
|
|
617
|
+
interface TokenMetadata {
|
|
618
|
+
currentPrice: number;
|
|
619
|
+
prevDayPrice: number;
|
|
620
|
+
priceChange24h: number;
|
|
621
|
+
priceChange24hPercent: number;
|
|
622
|
+
netFunding: number;
|
|
623
|
+
maxLeverage: number;
|
|
624
|
+
markPrice: number;
|
|
625
|
+
oraclePrice: number;
|
|
626
|
+
openInterest: string;
|
|
627
|
+
dayVolume: string;
|
|
628
|
+
leverage?: LeverageInfo;
|
|
629
|
+
maxTradeSzs?: [string, string];
|
|
630
|
+
availableToTrade?: [string, string];
|
|
631
|
+
collateralToken?: CollateralToken;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Enhanced token selection with weight and metadata for basket trading
|
|
635
|
+
*/
|
|
636
|
+
interface TokenSelection {
|
|
637
|
+
symbol: string;
|
|
638
|
+
weight: number;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Token conflict information for position conflicts
|
|
642
|
+
*/
|
|
643
|
+
interface TokenConflict {
|
|
644
|
+
symbol: string;
|
|
645
|
+
conflictType: 'long' | 'short';
|
|
646
|
+
conflictMessage: string;
|
|
647
|
+
}
|
|
648
|
+
interface AssetMarketData {
|
|
649
|
+
asset: WebData3AssetCtx | AssetCtx;
|
|
650
|
+
universe: UniverseAsset;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Nested market data structure for multi-market assets.
|
|
654
|
+
* Each symbol maps to its market variants (keyed by prefix).
|
|
655
|
+
* For non-HIP3 assets, use "default" as the key.
|
|
656
|
+
*
|
|
657
|
+
* @example
|
|
658
|
+
* ```ts
|
|
659
|
+
* {
|
|
660
|
+
* "TSLA": {
|
|
661
|
+
* "xyz": { asset: {...}, universe: { collateralToken: "USDC", ... } },
|
|
662
|
+
* "flx": { asset: {...}, universe: { collateralToken: "USDH", ... } }
|
|
663
|
+
* },
|
|
664
|
+
* "BTC": {
|
|
665
|
+
* "default": { asset: {...}, universe: {...} }
|
|
666
|
+
* }
|
|
667
|
+
* }
|
|
668
|
+
* ```
|
|
669
|
+
*/
|
|
670
|
+
type MarketDataBySymbol = Record<string, Record<string, AssetMarketData>>;
|
|
671
|
+
interface PairAssetDto {
|
|
672
|
+
asset: string;
|
|
673
|
+
weight: number;
|
|
674
|
+
collateralToken: CollateralToken;
|
|
675
|
+
marketPrefix: string | null;
|
|
676
|
+
}
|
|
677
|
+
interface ActiveAssetGroupItem {
|
|
678
|
+
longAssets: PairAssetDto[];
|
|
679
|
+
shortAssets: PairAssetDto[];
|
|
680
|
+
openInterest: string;
|
|
681
|
+
volume: string;
|
|
682
|
+
netFunding?: string;
|
|
683
|
+
ratio?: string;
|
|
684
|
+
prevRatio?: string;
|
|
685
|
+
change24h?: string;
|
|
686
|
+
weightedRatio?: string;
|
|
687
|
+
weightedPrevRatio?: string;
|
|
688
|
+
weightedChange24h?: string;
|
|
689
|
+
collateralType: 'USDC' | 'USDH' | 'MIXED';
|
|
690
|
+
}
|
|
691
|
+
interface ActiveAssetsResponse {
|
|
692
|
+
active: ActiveAssetGroupItem[];
|
|
693
|
+
topGainers: ActiveAssetGroupItem[];
|
|
694
|
+
topLosers: ActiveAssetGroupItem[];
|
|
695
|
+
highlighted: ActiveAssetGroupItem[];
|
|
696
|
+
watchlist: ActiveAssetGroupItem[];
|
|
697
|
+
}
|
|
698
|
+
interface ActiveAssetsAllResponse {
|
|
699
|
+
active: ActiveAssetGroupItem[];
|
|
700
|
+
all: ActiveAssetGroupItem[];
|
|
701
|
+
highlighted: ActiveAssetGroupItem[];
|
|
702
|
+
watchlist: ActiveAssetGroupItem[];
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Candle interval options
|
|
706
|
+
*/
|
|
707
|
+
type CandleInterval = '1m' | '3m' | '5m' | '15m' | '30m' | '1h' | '2h' | '4h' | '8h' | '12h' | '1d' | '3d' | '1w' | '1M';
|
|
708
|
+
/**
|
|
709
|
+
* Candle data structure from WebSocket
|
|
710
|
+
*/
|
|
711
|
+
interface CandleData {
|
|
712
|
+
s?: string;
|
|
713
|
+
t: number;
|
|
714
|
+
T: number;
|
|
715
|
+
o: number;
|
|
716
|
+
c: number;
|
|
717
|
+
h: number;
|
|
718
|
+
l: number;
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Candle chart data organized by symbol only
|
|
722
|
+
* Since new candles always have latest timestamp, no need to store per interval
|
|
723
|
+
*/
|
|
724
|
+
type CandleChartData = Map<string, CandleData>;
|
|
725
|
+
/**
|
|
726
|
+
* Historical candle data request
|
|
727
|
+
*/
|
|
728
|
+
interface CandleSnapshotRequest {
|
|
729
|
+
req: {
|
|
730
|
+
coin: string;
|
|
731
|
+
startTime: number;
|
|
732
|
+
endTime: number;
|
|
733
|
+
interval: CandleInterval;
|
|
734
|
+
};
|
|
735
|
+
type: 'candleSnapshot';
|
|
736
|
+
}
|
|
737
|
+
interface TokenSelectorConfig {
|
|
738
|
+
isLong: boolean;
|
|
739
|
+
index: number;
|
|
740
|
+
}
|
|
741
|
+
interface SpotBalance {
|
|
742
|
+
coin: string;
|
|
743
|
+
token: number;
|
|
744
|
+
total: string;
|
|
745
|
+
hold: string;
|
|
746
|
+
entryNtl: string;
|
|
747
|
+
}
|
|
748
|
+
interface SpotState {
|
|
749
|
+
user: string;
|
|
750
|
+
balances: SpotBalance[];
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
declare const useAccountSummary: () => {
|
|
754
|
+
data: AccountSummaryResponseDto | null;
|
|
755
|
+
isLoading: boolean;
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
declare const useTradeHistories: () => {
|
|
759
|
+
data: TradeHistoryDataDto[] | null;
|
|
760
|
+
isLoading: boolean;
|
|
761
|
+
};
|
|
762
|
+
declare const useOpenOrders: () => {
|
|
763
|
+
data: OpenLimitOrderDto[] | null;
|
|
764
|
+
isLoading: boolean;
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
interface UserSelectionState {
|
|
768
|
+
longTokens: TokenSelection[];
|
|
769
|
+
shortTokens: TokenSelection[];
|
|
770
|
+
openTokenSelector: boolean;
|
|
771
|
+
selectorConfig: TokenSelectorConfig | null;
|
|
772
|
+
openConflictModal: boolean;
|
|
773
|
+
conflicts: TokenConflict[];
|
|
774
|
+
candleInterval: CandleInterval;
|
|
775
|
+
isWeightBalanced: boolean;
|
|
776
|
+
setLongTokens: (tokens: TokenSelection[]) => void;
|
|
777
|
+
setShortTokens: (tokens: TokenSelection[]) => void;
|
|
778
|
+
setOpenTokenSelector: (open: boolean) => void;
|
|
779
|
+
setSelectorConfig: (config: TokenSelectorConfig | null) => void;
|
|
780
|
+
setOpenConflictModal: (open: boolean) => void;
|
|
781
|
+
setConflicts: (conflicts: TokenConflict[]) => void;
|
|
782
|
+
setCandleInterval: (interval: CandleInterval) => void;
|
|
783
|
+
updateTokenWeight: (isLong: boolean, index: number, newWeight: number) => void;
|
|
784
|
+
addToken: (isLong: boolean) => boolean;
|
|
785
|
+
canAddToken: (isLong: boolean) => boolean;
|
|
786
|
+
removeToken: (isLong: boolean, index: number) => void;
|
|
787
|
+
handleTokenSelect: (selectedToken: string) => void;
|
|
788
|
+
setTokenSelections: (longTokens: TokenSelection[], shortTokens: TokenSelection[]) => void;
|
|
789
|
+
resetToDefaults: () => void;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
declare const useUserSelection: () => UserSelectionState;
|
|
398
793
|
|
|
399
794
|
/**
|
|
400
|
-
*
|
|
795
|
+
* Hook to access webData and native WebSocket state
|
|
401
796
|
*/
|
|
402
|
-
declare
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
constructor(config: PearHyperliquidConfig);
|
|
797
|
+
declare const useWebData: () => {
|
|
798
|
+
clearinghouseState: ClearinghouseState | null;
|
|
799
|
+
perpsAtOpenInterestCap: string[] | null;
|
|
406
800
|
/**
|
|
407
|
-
*
|
|
801
|
+
* Market data keyed by symbol, with nested market variants.
|
|
802
|
+
* Each symbol maps to its market variants (keyed by prefix).
|
|
803
|
+
* For non-HIP3 assets, use "default" as the key.
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* ```ts
|
|
807
|
+
* // HIP-3 asset with multiple markets
|
|
808
|
+
* marketDataBySymbol["TSLA"]["xyz"] // { asset, universe: { collateralToken: "USDC" } }
|
|
809
|
+
* marketDataBySymbol["TSLA"]["flx"] // { asset, universe: { collateralToken: "USDH" } }
|
|
810
|
+
*
|
|
811
|
+
* // Regular asset
|
|
812
|
+
* marketDataBySymbol["BTC"]["default"] // { asset, universe }
|
|
813
|
+
* ```
|
|
408
814
|
*/
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
815
|
+
marketDataBySymbol: MarketDataBySymbol;
|
|
816
|
+
/** Map of display name -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"]) */
|
|
817
|
+
hip3Assets: Map<string, string[]>;
|
|
818
|
+
/** Map of full market name -> prefix (e.g., "xyz:TSLA" -> "xyz") */
|
|
819
|
+
hip3MarketPrefixes: Map<string, string>;
|
|
820
|
+
isConnected: boolean;
|
|
821
|
+
error: string | null;
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
interface UseTokenSelectionMetadataReturn {
|
|
825
|
+
isLoading: boolean;
|
|
826
|
+
isPriceDataReady: boolean;
|
|
827
|
+
longTokensMetadata: Record<string, TokenMetadata | null>;
|
|
828
|
+
shortTokensMetadata: Record<string, TokenMetadata | null>;
|
|
829
|
+
weightedRatio: number;
|
|
830
|
+
weightedRatio24h: number;
|
|
831
|
+
priceRatio: number;
|
|
832
|
+
priceRatio24h: number;
|
|
833
|
+
openInterest: string;
|
|
834
|
+
volume: string;
|
|
835
|
+
sumNetFunding: number;
|
|
836
|
+
maxLeverage: number;
|
|
837
|
+
minMargin: number;
|
|
838
|
+
leverageMatched: boolean;
|
|
839
|
+
}
|
|
840
|
+
declare const useTokenSelectionMetadata: () => UseTokenSelectionMetadataReturn;
|
|
841
|
+
|
|
842
|
+
interface HistoricalRange {
|
|
843
|
+
start: number;
|
|
844
|
+
end: number;
|
|
845
|
+
}
|
|
846
|
+
interface TokenHistoricalPriceData {
|
|
847
|
+
symbol: string;
|
|
848
|
+
interval: CandleInterval;
|
|
849
|
+
candles: CandleData[];
|
|
850
|
+
oldestTime: number | null;
|
|
851
|
+
latestTime: number | null;
|
|
852
|
+
}
|
|
853
|
+
declare const useHistoricalPriceDataStore: any;
|
|
854
|
+
|
|
855
|
+
interface UseHistoricalPriceDataReturn {
|
|
856
|
+
fetchHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval, callback?: (data: Record<string, CandleData[]>) => void) => Promise<Record<string, CandleData[]>>;
|
|
857
|
+
hasHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval) => boolean;
|
|
858
|
+
getHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval) => Record<string, CandleData[]>;
|
|
859
|
+
getAllHistoricalPriceData(): Promise<Record<string, TokenHistoricalPriceData>>;
|
|
860
|
+
isLoading: (symbol?: string) => boolean;
|
|
861
|
+
clearCache: () => void;
|
|
440
862
|
}
|
|
863
|
+
declare const useHistoricalPriceData: () => UseHistoricalPriceDataReturn;
|
|
441
864
|
|
|
865
|
+
interface UseBasketCandlesReturn {
|
|
866
|
+
fetchBasketCandles: (startTime: number, endTime: number, interval: CandleInterval) => Promise<CandleData[]>;
|
|
867
|
+
fetchPerformanceCandles: (startTime: number, endTime: number, interval: CandleInterval, symbol: string) => Promise<CandleData[]>;
|
|
868
|
+
fetchOverallPerformanceCandles: (startTime: number, endTime: number, interval: CandleInterval) => Promise<CandleData[]>;
|
|
869
|
+
isLoading: boolean;
|
|
870
|
+
addRealtimeListener: (cb: RealtimeBarsCallback) => string;
|
|
871
|
+
removeRealtimeListener: (id: string) => void;
|
|
872
|
+
}
|
|
873
|
+
type RealtimeBar = {
|
|
874
|
+
time: number;
|
|
875
|
+
open: number;
|
|
876
|
+
high: number;
|
|
877
|
+
low: number;
|
|
878
|
+
close: number;
|
|
879
|
+
volume?: number;
|
|
880
|
+
};
|
|
881
|
+
type RealtimeBarsCallback = (bar: RealtimeBar) => void;
|
|
442
882
|
/**
|
|
443
|
-
*
|
|
883
|
+
* Composes historical price fetching with basket candle computation.
|
|
884
|
+
* - Listens to `longTokens` and `shortTokens` from user selection.
|
|
885
|
+
* - Uses `fetchHistoricalPriceData` to retrieve token candles for the range.
|
|
886
|
+
* - Computes and returns weighted basket candles via `computeBasketCandles`.
|
|
444
887
|
*/
|
|
445
|
-
declare
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
888
|
+
declare const useBasketCandles: () => UseBasketCandlesReturn;
|
|
889
|
+
|
|
890
|
+
interface PerformanceOverlay {
|
|
891
|
+
id: string;
|
|
892
|
+
symbol: string;
|
|
893
|
+
label: string;
|
|
894
|
+
color: string;
|
|
895
|
+
enabled: boolean;
|
|
896
|
+
type: 'asset' | 'portfolio';
|
|
897
|
+
weight?: number;
|
|
898
|
+
}
|
|
899
|
+
interface UsePerformanceOverlaysReturn {
|
|
900
|
+
overlays: PerformanceOverlay[];
|
|
901
|
+
generateOverlaySymbols: () => string[];
|
|
902
|
+
}
|
|
903
|
+
declare const usePerformanceOverlays: () => UsePerformanceOverlaysReturn;
|
|
904
|
+
|
|
905
|
+
declare function useAgentWallet(): {
|
|
906
|
+
readonly refreshAgentWalletStatus: () => Promise<void>;
|
|
907
|
+
readonly createAgentWallet: () => Promise<CreateAgentWalletResponseDto>;
|
|
908
|
+
readonly notifyAgentWalletApproved: () => Promise<void>;
|
|
909
|
+
};
|
|
910
|
+
|
|
911
|
+
interface AutoSyncFillsOptions {
|
|
912
|
+
baseUrl: string;
|
|
913
|
+
address: string | null;
|
|
914
|
+
intervalMs?: number;
|
|
915
|
+
aggregateByTime?: boolean;
|
|
916
|
+
}
|
|
917
|
+
interface AutoSyncFillsState {
|
|
918
|
+
lastRunAt: number | null;
|
|
919
|
+
lastResult: SyncFillsResponseDto | null;
|
|
920
|
+
error: string | null;
|
|
921
|
+
isSyncing: boolean;
|
|
922
|
+
triggerSync: () => Promise<void>;
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Listens to address changes and periodically syncs user fills
|
|
926
|
+
* Defaults: aggregate=true, interval=60s
|
|
927
|
+
*/
|
|
928
|
+
declare function useAutoSyncFills(options: AutoSyncFillsOptions): AutoSyncFillsState;
|
|
929
|
+
|
|
930
|
+
interface AdjustOrderRequestInput {
|
|
931
|
+
limitRatio?: number;
|
|
932
|
+
usdValue?: number;
|
|
933
|
+
}
|
|
934
|
+
interface AdjustOrderResponseDto {
|
|
935
|
+
orderId: string;
|
|
936
|
+
limitRatio: number;
|
|
937
|
+
usdValue: number;
|
|
938
|
+
updatedAt: string;
|
|
939
|
+
}
|
|
940
|
+
declare function adjustOrder(baseUrl: string, orderId: string, payload: AdjustOrderRequestInput): Promise<ApiResponse<AdjustOrderResponseDto>>;
|
|
941
|
+
interface CancelOrderResponseDto {
|
|
942
|
+
orderId: string;
|
|
943
|
+
status: string;
|
|
944
|
+
cancelledAt: string;
|
|
945
|
+
}
|
|
946
|
+
declare function cancelOrder(baseUrl: string, orderId: string): Promise<ApiResponse<CancelOrderResponseDto>>;
|
|
947
|
+
interface CancelTwapResponseDto {
|
|
948
|
+
orderId: string;
|
|
949
|
+
status: string;
|
|
950
|
+
cancelledAt: string;
|
|
951
|
+
}
|
|
952
|
+
declare function cancelTwapOrder(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
953
|
+
interface SpotOrderRequestInput {
|
|
954
|
+
/** Asset to buy/sell (e.g., "USDH") */
|
|
955
|
+
asset: string;
|
|
956
|
+
/** Whether to buy (true) or sell (false) the asset */
|
|
957
|
+
isBuy: boolean;
|
|
958
|
+
/** Amount of asset to buy/sell (minimum: 11) */
|
|
959
|
+
amount: number;
|
|
960
|
+
}
|
|
961
|
+
/** Filled order status from Hyperliquid */
|
|
962
|
+
interface SpotOrderFilledStatus {
|
|
963
|
+
filled: {
|
|
964
|
+
totalSz: string;
|
|
965
|
+
avgPx: string;
|
|
966
|
+
oid: number;
|
|
967
|
+
cloid: string;
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
/** Hyperliquid order response data */
|
|
971
|
+
interface SpotOrderHyperliquidData {
|
|
972
|
+
statuses: SpotOrderFilledStatus[];
|
|
973
|
+
}
|
|
974
|
+
/** Hyperliquid result from spot order execution */
|
|
975
|
+
interface SpotOrderHyperliquidResult {
|
|
976
|
+
status: 'ok' | 'error';
|
|
977
|
+
response: {
|
|
978
|
+
type: 'order';
|
|
979
|
+
data: SpotOrderHyperliquidData;
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
interface SpotOrderResponseDto {
|
|
983
|
+
orderId: string;
|
|
984
|
+
status: 'EXECUTED' | 'FAILED' | 'PENDING';
|
|
985
|
+
asset: string;
|
|
986
|
+
createdAt: string;
|
|
987
|
+
hyperliquidResult?: SpotOrderHyperliquidResult;
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* Execute a spot order (swap) using Pear Hyperliquid service
|
|
991
|
+
* POST /orders/spot
|
|
992
|
+
*/
|
|
993
|
+
declare function executeSpotOrder(baseUrl: string, payload: SpotOrderRequestInput): Promise<ApiResponse<SpotOrderResponseDto>>;
|
|
994
|
+
|
|
995
|
+
type ExecutionType = "MARKET" | "LIMIT" | "TWAP" | "LADDER" | "LIMIT_BTCDOM";
|
|
996
|
+
type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
|
|
997
|
+
interface PairAssetInput {
|
|
998
|
+
asset: string;
|
|
999
|
+
weight?: number;
|
|
1000
|
+
}
|
|
1001
|
+
interface TpSlThresholdInput {
|
|
1002
|
+
type: TpSlThresholdType;
|
|
1003
|
+
value: number;
|
|
1004
|
+
}
|
|
1005
|
+
interface LadderConfigInput {
|
|
1006
|
+
ratioStart: number;
|
|
1007
|
+
ratioEnd: number;
|
|
1008
|
+
numberOfLevels: number;
|
|
1009
|
+
}
|
|
1010
|
+
interface CreatePositionRequestInput {
|
|
1011
|
+
slippage: number;
|
|
1012
|
+
executionType: ExecutionType;
|
|
1013
|
+
leverage: number;
|
|
1014
|
+
usdValue: number;
|
|
1015
|
+
longAssets?: PairAssetInput[];
|
|
1016
|
+
shortAssets?: PairAssetInput[];
|
|
1017
|
+
triggerValue?: number;
|
|
1018
|
+
direction?: "MORE_THAN" | "LESS_THAN";
|
|
1019
|
+
twapDuration?: number;
|
|
1020
|
+
twapIntervalSeconds?: number;
|
|
1021
|
+
randomizeExecution?: boolean;
|
|
1022
|
+
referralCode?: string;
|
|
1023
|
+
ladderConfig?: LadderConfigInput;
|
|
1024
|
+
takeProfit?: TpSlThresholdInput | null;
|
|
1025
|
+
stopLoss?: TpSlThresholdInput | null;
|
|
1026
|
+
}
|
|
1027
|
+
type PositionResponseStatus = "SUCCESS" | "FAILED" | "PENDING" | "PARTIALLY_FILLED" | "OPEN";
|
|
1028
|
+
interface PositionAssetSummaryDto {
|
|
1029
|
+
asset: string;
|
|
1030
|
+
side: "LONG" | "SHORT";
|
|
1031
|
+
size: number;
|
|
1032
|
+
entryRatio: number;
|
|
1033
|
+
usdValue: number;
|
|
1034
|
+
orderId: string;
|
|
1035
|
+
}
|
|
1036
|
+
interface CreatePositionResponseDto {
|
|
1037
|
+
positionId: string | null;
|
|
1038
|
+
orderId: string;
|
|
1039
|
+
status: PositionResponseStatus;
|
|
1040
|
+
createdAt: string;
|
|
1041
|
+
assets?: PositionAssetSummaryDto[];
|
|
1042
|
+
stopLoss?: TpSlThresholdInput | null;
|
|
1043
|
+
takeProfit?: TpSlThresholdInput | null;
|
|
1044
|
+
hyperliquidResult?: any;
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
|
|
1048
|
+
* Authorization is derived from headers (Axios defaults or browser localStorage fallback)
|
|
1049
|
+
* @throws MinimumPositionSizeError if any asset has less than $11 USD value
|
|
1050
|
+
* @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets (15)
|
|
1051
|
+
*/
|
|
1052
|
+
declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput, hip3Assets: Map<string, string[]>): Promise<ApiResponse<CreatePositionResponseDto>>;
|
|
1053
|
+
interface UpdateRiskParametersRequestInput {
|
|
1054
|
+
stopLoss?: TpSlThresholdInput | null;
|
|
1055
|
+
takeProfit?: TpSlThresholdInput | null;
|
|
1056
|
+
}
|
|
1057
|
+
interface UpdateRiskParametersResponseDto {
|
|
1058
|
+
positionId: string;
|
|
1059
|
+
stopLoss: TpSlThresholdInput | null;
|
|
1060
|
+
takeProfit: TpSlThresholdInput | null;
|
|
1061
|
+
updatedAt: string;
|
|
1062
|
+
}
|
|
1063
|
+
declare function updateRiskParameters(baseUrl: string, positionId: string, payload: UpdateRiskParametersRequestInput): Promise<ApiResponse<UpdateRiskParametersResponseDto>>;
|
|
1064
|
+
type CloseExecutionType = "MARKET" | "TWAP";
|
|
1065
|
+
interface ClosePositionRequestInput {
|
|
1066
|
+
executionType: CloseExecutionType;
|
|
1067
|
+
twapDuration?: number;
|
|
1068
|
+
twapIntervalSeconds?: number;
|
|
1069
|
+
randomizeExecution?: boolean;
|
|
1070
|
+
referralCode?: string;
|
|
1071
|
+
}
|
|
1072
|
+
interface ClosePositionResponseDto {
|
|
1073
|
+
orderId: string;
|
|
1074
|
+
executionTime?: string;
|
|
1075
|
+
chunksScheduled?: number;
|
|
1076
|
+
}
|
|
1077
|
+
declare function closePosition(baseUrl: string, positionId: string, payload: ClosePositionRequestInput): Promise<ApiResponse<ClosePositionResponseDto>>;
|
|
1078
|
+
interface CloseAllPositionsResultDto {
|
|
1079
|
+
positionId: string;
|
|
1080
|
+
success: boolean;
|
|
1081
|
+
orderId?: string;
|
|
1082
|
+
error?: string;
|
|
1083
|
+
}
|
|
1084
|
+
interface CloseAllPositionsResponseDto {
|
|
1085
|
+
results: CloseAllPositionsResultDto[];
|
|
1086
|
+
}
|
|
1087
|
+
declare function closeAllPositions(baseUrl: string, payload: ClosePositionRequestInput): Promise<ApiResponse<CloseAllPositionsResponseDto>>;
|
|
1088
|
+
type AdjustExecutionType = "MARKET" | "LIMIT";
|
|
1089
|
+
type PositionAdjustmentType = "REDUCE" | "INCREASE";
|
|
1090
|
+
interface AdjustPositionRequestInput {
|
|
1091
|
+
adjustmentType: PositionAdjustmentType;
|
|
1092
|
+
adjustmentSize: number;
|
|
1093
|
+
executionType: AdjustExecutionType;
|
|
1094
|
+
limitRatio?: number;
|
|
1095
|
+
referralCode?: string;
|
|
1096
|
+
}
|
|
1097
|
+
interface AdjustPositionResponseDto {
|
|
1098
|
+
orderId: string;
|
|
1099
|
+
status: string;
|
|
1100
|
+
adjustmentType: PositionAdjustmentType;
|
|
1101
|
+
adjustmentSize: number;
|
|
1102
|
+
newSize: number;
|
|
1103
|
+
executedAt: string;
|
|
1104
|
+
}
|
|
1105
|
+
declare function adjustPosition(baseUrl: string, positionId: string, payload: AdjustPositionRequestInput): Promise<ApiResponse<AdjustPositionResponseDto>>;
|
|
1106
|
+
interface AdjustAdvanceAssetInput {
|
|
1107
|
+
asset: string;
|
|
1108
|
+
size: number;
|
|
1109
|
+
}
|
|
1110
|
+
interface AdjustAdvanceItemInput {
|
|
1111
|
+
longAssets?: AdjustAdvanceAssetInput[];
|
|
1112
|
+
shortAssets?: AdjustAdvanceAssetInput[];
|
|
1113
|
+
}
|
|
1114
|
+
interface AdjustAdvanceResponseDto {
|
|
1115
|
+
orderId: string;
|
|
1116
|
+
status: string;
|
|
1117
|
+
executedAt: string;
|
|
1118
|
+
}
|
|
1119
|
+
declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[], hip3Assets: Map<string, string[]>): Promise<ApiResponse<AdjustAdvanceResponseDto>>;
|
|
1120
|
+
declare function cancelTwap(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
1121
|
+
interface UpdateLeverageRequestInput {
|
|
1122
|
+
leverage: number;
|
|
1123
|
+
}
|
|
1124
|
+
interface UpdateLeverageResponseDto {
|
|
1125
|
+
message?: string;
|
|
1126
|
+
}
|
|
1127
|
+
declare function updateLeverage(baseUrl: string, positionId: string, payload: UpdateLeverageRequestInput): Promise<ApiResponse<UpdateLeverageResponseDto | null>>;
|
|
1128
|
+
|
|
1129
|
+
declare function usePosition(): {
|
|
1130
|
+
readonly createPosition: (payload: CreatePositionRequestInput) => Promise<ApiResponse<CreatePositionResponseDto>>;
|
|
1131
|
+
readonly updateRiskParameters: (positionId: string, payload: UpdateRiskParametersRequestInput) => Promise<ApiResponse<UpdateRiskParametersResponseDto>>;
|
|
1132
|
+
readonly closePosition: (positionId: string, payload: ClosePositionRequestInput) => Promise<ApiResponse<ClosePositionResponseDto>>;
|
|
1133
|
+
readonly closeAllPositions: (payload: ClosePositionRequestInput) => Promise<ApiResponse<CloseAllPositionsResponseDto>>;
|
|
1134
|
+
readonly adjustPosition: (positionId: string, payload: AdjustPositionRequestInput) => Promise<ApiResponse<AdjustPositionResponseDto>>;
|
|
1135
|
+
readonly adjustAdvancePosition: (positionId: string, payload: AdjustAdvanceItemInput[]) => Promise<ApiResponse<AdjustAdvanceResponseDto>>;
|
|
1136
|
+
readonly updateLeverage: (positionId: string, leverage: number) => Promise<ApiResponse<UpdateLeverageResponseDto | null>>;
|
|
1137
|
+
readonly openPositions: OpenPositionDto[] | null;
|
|
1138
|
+
readonly isLoading: boolean;
|
|
1139
|
+
};
|
|
1140
|
+
|
|
1141
|
+
declare function useOrders(): {
|
|
1142
|
+
readonly adjustOrder: (orderId: string, payload: AdjustOrderRequestInput) => Promise<ApiResponse<AdjustOrderResponseDto>>;
|
|
1143
|
+
readonly cancelOrder: (orderId: string) => Promise<ApiResponse<CancelOrderResponseDto>>;
|
|
1144
|
+
readonly cancelTwapOrder: (orderId: string) => Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
1145
|
+
readonly openOrders: OpenLimitOrderDto[] | null;
|
|
1146
|
+
readonly isLoading: boolean;
|
|
1147
|
+
};
|
|
1148
|
+
|
|
1149
|
+
interface UseSpotOrderResult {
|
|
1150
|
+
executeSpotOrder: (payload: SpotOrderRequestInput) => Promise<ApiResponse<SpotOrderResponseDto>>;
|
|
1151
|
+
isLoading: boolean;
|
|
1152
|
+
error: ApiErrorResponse | null;
|
|
1153
|
+
resetError: () => void;
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Hook for executing spot orders (swaps) on Hyperliquid
|
|
1157
|
+
* Use this to swap between USDC and USDH or other spot assets
|
|
1158
|
+
*/
|
|
1159
|
+
declare function useSpotOrder(): UseSpotOrderResult;
|
|
1160
|
+
|
|
1161
|
+
declare function useTwap(): {
|
|
1162
|
+
readonly orders: TwapMonitoringDto[];
|
|
1163
|
+
readonly cancelTwap: (orderId: string) => Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
1164
|
+
};
|
|
1165
|
+
|
|
1166
|
+
interface UseNotificationsResult {
|
|
1167
|
+
notifications: NotificationDto[] | null;
|
|
1168
|
+
unreadCount: number;
|
|
1169
|
+
markReadUntil: (timestampMs: number) => Promise<{
|
|
1170
|
+
updated: number;
|
|
1171
|
+
}>;
|
|
1172
|
+
markReadById: (id: string) => Promise<{
|
|
1173
|
+
updated: number;
|
|
1174
|
+
}>;
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* Provides notifications and fills checkpoint data sourced from the SDK WebSocket.
|
|
1178
|
+
* Data is persisted in the SDK's Zustand store.
|
|
1179
|
+
*/
|
|
1180
|
+
declare function useNotifications(): UseNotificationsResult;
|
|
1181
|
+
|
|
1182
|
+
type CollateralFilter = 'USDC' | 'USDH' | 'ALL';
|
|
1183
|
+
declare const useMarketDataPayload: () => ActiveAssetsResponse | null;
|
|
1184
|
+
declare const useMarketDataAllPayload: () => ActiveAssetsAllResponse | null;
|
|
1185
|
+
declare const usePerpMetaAssets: () => UniverseAsset[] | null;
|
|
1186
|
+
declare const useActiveBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1187
|
+
declare const useTopGainers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1188
|
+
declare const useTopLosers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1189
|
+
declare const useHighlightedBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1190
|
+
declare const useWatchlistBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1191
|
+
declare const useAllBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1192
|
+
declare const useFindBasket: (longs: string[], shorts: string[]) => ActiveAssetGroupItem | undefined;
|
|
1193
|
+
|
|
1194
|
+
declare function useWatchlist(): {
|
|
1195
|
+
readonly watchlists: ActiveAssetGroupItem[] | null;
|
|
1196
|
+
readonly isLoading: boolean;
|
|
1197
|
+
readonly toggle: (longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[]) => Promise<ApiResponse<ToggleWatchlistResponseDto>>;
|
|
1198
|
+
};
|
|
1199
|
+
|
|
1200
|
+
type PortfolioInterval = '1d' | '1w' | '1m' | '1y' | 'all';
|
|
1201
|
+
interface PortfolioBucketDto {
|
|
1202
|
+
periodStart: string;
|
|
1203
|
+
periodEnd: string;
|
|
1204
|
+
volume: number;
|
|
1205
|
+
openInterest: number;
|
|
1206
|
+
winningTradesCount: number;
|
|
1207
|
+
winningTradesUsd: number;
|
|
1208
|
+
losingTradesCount: number;
|
|
1209
|
+
losingTradesUsd: number;
|
|
1210
|
+
}
|
|
1211
|
+
interface PortfolioOverallDto {
|
|
1212
|
+
totalWinningTradesCount: number;
|
|
1213
|
+
totalLosingTradesCount: number;
|
|
1214
|
+
totalWinningUsd: number;
|
|
1215
|
+
totalLosingUsd: number;
|
|
1216
|
+
currentOpenInterest: number;
|
|
1217
|
+
currentTotalVolume: number;
|
|
1218
|
+
unrealizedPnl: number;
|
|
1219
|
+
totalTrades: number;
|
|
1220
|
+
}
|
|
1221
|
+
interface PortfolioIntervalsDto {
|
|
1222
|
+
oneDay: PortfolioBucketDto[];
|
|
1223
|
+
oneWeek: PortfolioBucketDto[];
|
|
1224
|
+
oneMonth: PortfolioBucketDto[];
|
|
1225
|
+
oneYear: PortfolioBucketDto[];
|
|
1226
|
+
all: PortfolioBucketDto[];
|
|
1227
|
+
}
|
|
1228
|
+
interface PortfolioResponseDto {
|
|
1229
|
+
intervals: PortfolioIntervalsDto;
|
|
1230
|
+
overall: PortfolioOverallDto;
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Get portfolio summary buckets and overall metrics
|
|
1234
|
+
* Returns bucketed volume, open interest snapshot, win/loss trade counts, and overall metrics filtered to PEAR fills (cloid LIKE 0x50454152%)
|
|
1235
|
+
* Authorization is derived from headers (Axios defaults or browser localStorage fallback)
|
|
1236
|
+
*/
|
|
1237
|
+
declare function getPortfolio(baseUrl: string): Promise<ApiResponse<PortfolioResponseDto>>;
|
|
1238
|
+
|
|
1239
|
+
interface UsePortfolioResult {
|
|
1240
|
+
data: PortfolioResponseDto | null;
|
|
1241
|
+
isLoading: boolean;
|
|
1242
|
+
error: Error | null;
|
|
1243
|
+
refetch: () => Promise<void>;
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1246
|
+
* Hook to fetch and manage portfolio data
|
|
1247
|
+
* Returns bucketed volume, open interest snapshot, win/loss trade counts,
|
|
1248
|
+
* and overall metrics
|
|
1249
|
+
*/
|
|
1250
|
+
declare function usePortfolio(): UsePortfolioResult;
|
|
1251
|
+
|
|
1252
|
+
declare function useAuth(): {
|
|
1253
|
+
readonly isReady: boolean;
|
|
1254
|
+
readonly isAuthenticated: any;
|
|
1255
|
+
readonly accessToken: any;
|
|
1256
|
+
readonly refreshToken: any;
|
|
1257
|
+
readonly getEip712: (address: string) => Promise<GetEIP712MessageResponse>;
|
|
1258
|
+
readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
|
|
1259
|
+
readonly loginWithPrivyToken: (address: string, appId: string, privyAccessToken: string) => Promise<void>;
|
|
1260
|
+
readonly refreshTokens: () => Promise<RefreshTokenResponse>;
|
|
1261
|
+
readonly logout: () => Promise<void>;
|
|
1262
|
+
};
|
|
1263
|
+
|
|
1264
|
+
interface AllUserBalances {
|
|
1265
|
+
spotUsdcBalance: number | undefined;
|
|
1266
|
+
availableToTradeUsdc: number | undefined;
|
|
1267
|
+
spotUsdhBalance: number | undefined;
|
|
1268
|
+
availableToTradeUsdh: number | undefined;
|
|
1269
|
+
isLoading: boolean;
|
|
1270
|
+
}
|
|
1271
|
+
declare const useAllUserBalances: () => AllUserBalances;
|
|
1272
|
+
|
|
1273
|
+
interface UseHyperliquidWebSocketProps {
|
|
1274
|
+
wsUrl: string;
|
|
1275
|
+
address: string | null;
|
|
1276
|
+
enabled?: boolean;
|
|
1277
|
+
}
|
|
1278
|
+
declare const useHyperliquidWebSocket: ({ wsUrl, address, enabled, }: UseHyperliquidWebSocketProps) => {
|
|
1279
|
+
isConnected: boolean;
|
|
1280
|
+
lastError: string | null;
|
|
1281
|
+
};
|
|
1282
|
+
|
|
1283
|
+
interface UseHyperliquidNativeWebSocketProps {
|
|
1284
|
+
address: string | null;
|
|
1285
|
+
tokens?: string[];
|
|
1286
|
+
enabled?: boolean;
|
|
1287
|
+
}
|
|
1288
|
+
interface UseHyperliquidNativeWebSocketReturn {
|
|
1289
|
+
isConnected: boolean;
|
|
1290
|
+
lastError: string | null;
|
|
1291
|
+
}
|
|
1292
|
+
declare const useHyperliquidNativeWebSocket: ({ address, enabled, }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
|
1293
|
+
|
|
1294
|
+
/**
|
|
1295
|
+
* Mark notifications as read up to a given timestamp (ms)
|
|
1296
|
+
*/
|
|
1297
|
+
declare function markNotificationsRead(baseUrl: string, timestampMs: number): Promise<ApiResponse<{
|
|
1298
|
+
updated: number;
|
|
1299
|
+
}>>;
|
|
1300
|
+
/**
|
|
1301
|
+
* Mark a single notification as read by id
|
|
1302
|
+
*/
|
|
1303
|
+
declare function markNotificationReadById(baseUrl: string, id: string): Promise<ApiResponse<{
|
|
1304
|
+
updated: number;
|
|
1305
|
+
}>>;
|
|
1306
|
+
|
|
1307
|
+
declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[], hip3Assets: Map<string, string[]>): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
|
|
1308
|
+
|
|
1309
|
+
/**
|
|
1310
|
+
* Account summary calculation utility class
|
|
1311
|
+
*/
|
|
1312
|
+
declare class AccountSummaryCalculator {
|
|
1313
|
+
private clearinghouseState;
|
|
1314
|
+
constructor(clearinghouseState: ClearinghouseState | null);
|
|
474
1315
|
/**
|
|
475
|
-
*
|
|
1316
|
+
* Calculate account summary from real-time clearinghouse state and platform orders
|
|
476
1317
|
*/
|
|
477
|
-
|
|
1318
|
+
calculateAccountSummary(platformAccountSummary: PlatformAccountSummaryResponseDto | null, registeredAgentWallets: ExtraAgent[]): AccountSummaryResponseDto | null;
|
|
1319
|
+
getClearinghouseState(): ClearinghouseState | null;
|
|
478
1320
|
/**
|
|
479
|
-
* Check if
|
|
1321
|
+
* Check if real-time data is available
|
|
480
1322
|
*/
|
|
481
|
-
|
|
1323
|
+
hasRealTimeData(): boolean;
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
/**
|
|
1327
|
+
* Detects conflicts between selected tokens and existing positions
|
|
1328
|
+
*/
|
|
1329
|
+
declare class ConflictDetector {
|
|
482
1330
|
/**
|
|
483
|
-
*
|
|
1331
|
+
* Detects conflicts between token selections and open positions
|
|
1332
|
+
* @param longTokens - Selected long tokens
|
|
1333
|
+
* @param shortTokens - Selected short tokens
|
|
1334
|
+
* @param openPositions - Current open positions from API
|
|
1335
|
+
* @returns Array of detected conflicts
|
|
484
1336
|
*/
|
|
485
|
-
|
|
1337
|
+
static detectConflicts(longTokens: TokenSelection[], shortTokens: TokenSelection[], openPositions: RawPositionDto[] | null): TokenConflict[];
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* Extracts token metadata from aggregated WebData3 contexts and AllMids data
|
|
1342
|
+
*/
|
|
1343
|
+
declare class TokenMetadataExtractor {
|
|
486
1344
|
/**
|
|
487
|
-
*
|
|
1345
|
+
* Extracts comprehensive token metadata
|
|
1346
|
+
* @param symbol - Token symbol (base symbol without prefix, e.g., "TSLA")
|
|
1347
|
+
* @param perpMetaAssets - Aggregated universe assets (flattened across dexes)
|
|
1348
|
+
* @param finalAssetContexts - Aggregated asset contexts (flattened across dexes)
|
|
1349
|
+
* @param allMids - AllMids data containing current prices
|
|
1350
|
+
* @param activeAssetData - Optional active asset data containing leverage information
|
|
1351
|
+
* @param marketPrefix - Optional market prefix (e.g., "xyz", "flx") for HIP3 multi-market assets
|
|
1352
|
+
* @returns TokenMetadata or null if token not found
|
|
488
1353
|
*/
|
|
489
|
-
|
|
1354
|
+
static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null, marketPrefix?: string | null): TokenMetadata | null;
|
|
490
1355
|
/**
|
|
491
|
-
*
|
|
1356
|
+
* Extracts metadata for multiple tokens
|
|
1357
|
+
* @param tokens - Array of token objects with symbol and optional marketPrefix
|
|
1358
|
+
* @param perpMetaAssets - Aggregated universe assets
|
|
1359
|
+
* @param finalAssetContexts - Aggregated asset contexts
|
|
1360
|
+
* @param allMids - AllMids data
|
|
1361
|
+
* @param activeAssetData - Optional active asset data containing leverage information
|
|
1362
|
+
* @returns Record of unique key to TokenMetadata. Key is "{prefix}:{symbol}" for HIP3 assets, or just "{symbol}" otherwise
|
|
492
1363
|
*/
|
|
493
|
-
|
|
1364
|
+
static extractMultipleTokensMetadata(tokens: Array<{
|
|
1365
|
+
symbol: string;
|
|
1366
|
+
marketPrefix?: string | null;
|
|
1367
|
+
}>, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): Record<string, TokenMetadata | null>;
|
|
494
1368
|
/**
|
|
495
|
-
*
|
|
1369
|
+
* Checks if token data is available in aggregated universe assets
|
|
1370
|
+
* @param symbol - Token symbol
|
|
1371
|
+
* @param perpMetaAssets - Aggregated universe assets
|
|
1372
|
+
* @returns boolean indicating if token exists in universe
|
|
496
1373
|
*/
|
|
497
|
-
|
|
1374
|
+
static isTokenAvailable(symbol: string, perpMetaAssets: UniverseAsset[] | null): boolean;
|
|
498
1375
|
}
|
|
499
1376
|
|
|
500
|
-
interface PearHyperliquidProviderProps {
|
|
501
|
-
config: PearHyperliquidConfig;
|
|
502
|
-
/**
|
|
503
|
-
* WebSocket server URL
|
|
504
|
-
* @default 'wss://hl-v2.pearprotocol.io/ws'
|
|
505
|
-
*/
|
|
506
|
-
wsUrl?: string;
|
|
507
|
-
children: ReactNode;
|
|
508
|
-
}
|
|
509
1377
|
/**
|
|
510
|
-
*
|
|
1378
|
+
* Create efficient timestamp-based lookup maps for candle data
|
|
511
1379
|
*/
|
|
512
|
-
declare const
|
|
1380
|
+
declare const createCandleLookups: (tokenCandles: Record<string, CandleData[]>) => Record<string, Map<number, CandleData>>;
|
|
1381
|
+
/**
|
|
1382
|
+
* Calculate weighted ratio for a specific price type (open, high, low, close)
|
|
1383
|
+
* Uses the formula: LONG_PRODUCT * SHORT_PRODUCT
|
|
1384
|
+
* Where LONG_PRODUCT = ∏(PRICE^(WEIGHT/100)) for long tokens
|
|
1385
|
+
* And SHORT_PRODUCT = ∏(PRICE^-(WEIGHT/100)) for short tokens
|
|
1386
|
+
*
|
|
1387
|
+
* Optimized version that uses Map lookups instead of Array.find()
|
|
1388
|
+
*/
|
|
1389
|
+
declare const calculateWeightedRatio: (longTokens: TokenSelection[], shortTokens: TokenSelection[], candleLookups: Record<string, Map<number, CandleData>>, timestamp: number, priceType: "o" | "h" | "l" | "c") => number;
|
|
513
1390
|
/**
|
|
514
|
-
*
|
|
1391
|
+
* Get all unique timestamps where ALL required symbols have data
|
|
1392
|
+
* Optimized version that uses Map lookups
|
|
515
1393
|
*/
|
|
516
|
-
declare const
|
|
1394
|
+
declare const getCompleteTimestamps: (candleLookups: Record<string, Map<number, CandleData>>, requiredSymbols: string[]) => number[];
|
|
517
1395
|
/**
|
|
518
|
-
*
|
|
1396
|
+
* Compute basket candles from individual token candles using weighted ratios
|
|
1397
|
+
* Optimized version that creates lookup maps once and reuses them
|
|
519
1398
|
*/
|
|
520
|
-
declare const
|
|
1399
|
+
declare const computeBasketCandles: (longTokens: TokenSelection[], shortTokens: TokenSelection[], tokenCandles: Record<string, CandleData[]>) => CandleData[];
|
|
521
1400
|
|
|
522
1401
|
/**
|
|
523
|
-
*
|
|
1402
|
+
* Maps TradingView ResolutionString to CandleInterval
|
|
524
1403
|
*/
|
|
525
|
-
declare
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
1404
|
+
declare function mapTradingViewIntervalToCandleInterval(interval: string): CandleInterval;
|
|
1405
|
+
/**
|
|
1406
|
+
* Maps CandleInterval to TradingView ResolutionString
|
|
1407
|
+
*/
|
|
1408
|
+
declare function mapCandleIntervalToTradingViewInterval(interval: CandleInterval): string;
|
|
1409
|
+
|
|
1410
|
+
/**
|
|
1411
|
+
* Minimum USD value required per asset when creating a position
|
|
1412
|
+
*/
|
|
1413
|
+
declare const MINIMUM_ASSET_USD_VALUE = 11;
|
|
1414
|
+
/**
|
|
1415
|
+
* Maximum number of assets allowed per leg (long or short) in a position
|
|
1416
|
+
*/
|
|
1417
|
+
declare const MAX_ASSETS_PER_LEG = 15;
|
|
1418
|
+
/**
|
|
1419
|
+
* Validation error for minimum position size
|
|
1420
|
+
*/
|
|
1421
|
+
declare class MinimumPositionSizeError extends Error {
|
|
1422
|
+
assetName: string;
|
|
1423
|
+
assetValue: number;
|
|
1424
|
+
minimumRequired: number;
|
|
1425
|
+
constructor(assetName: string, assetValue: number, minimumRequired: number);
|
|
1426
|
+
}
|
|
1427
|
+
/**
|
|
1428
|
+
* Validation error for exceeding maximum assets per leg
|
|
1429
|
+
*/
|
|
1430
|
+
declare class MaxAssetsPerLegError extends Error {
|
|
1431
|
+
leg: "long" | "short";
|
|
1432
|
+
assetCount: number;
|
|
1433
|
+
maxAllowed: number;
|
|
1434
|
+
constructor(leg: "long" | "short", assetCount: number, maxAllowed: number);
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* Validates that each leg doesn't exceed the maximum number of assets
|
|
1438
|
+
* @param longAssets Array of long assets
|
|
1439
|
+
* @param shortAssets Array of short assets
|
|
1440
|
+
* @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets
|
|
1441
|
+
*/
|
|
1442
|
+
declare function validateMaxAssetsPerLeg(longAssets?: PairAssetInput[], shortAssets?: PairAssetInput[]): void;
|
|
1443
|
+
/**
|
|
1444
|
+
* Validates that each asset in a position has at least the minimum USD value
|
|
1445
|
+
* @param usdValue Total USD value for the position
|
|
1446
|
+
* @param longAssets Array of long assets with weights
|
|
1447
|
+
* @param shortAssets Array of short assets with weights
|
|
1448
|
+
* @throws MinimumPositionSizeError if any asset has less than the minimum USD value
|
|
1449
|
+
*/
|
|
1450
|
+
declare function validateMinimumAssetSize(usdValue: number, longAssets?: PairAssetInput[], shortAssets?: PairAssetInput[]): void;
|
|
1451
|
+
/**
|
|
1452
|
+
* Calculates the minimum USD value required for a position based on the number of assets
|
|
1453
|
+
* @param longAssets Array of long assets
|
|
1454
|
+
* @param shortAssets Array of short assets
|
|
1455
|
+
* @returns The minimum total USD value required
|
|
1456
|
+
*/
|
|
1457
|
+
declare function calculateMinimumPositionValue(longAssets?: PairAssetInput[], shortAssets?: PairAssetInput[]): number;
|
|
1458
|
+
/**
|
|
1459
|
+
* Validates and provides a user-friendly error message with suggestions
|
|
1460
|
+
* @param usdValue Total USD value for the position
|
|
1461
|
+
* @param longAssets Array of long assets with weights
|
|
1462
|
+
* @param shortAssets Array of short assets with weights
|
|
1463
|
+
* @returns Validation result with success flag and optional error message
|
|
1464
|
+
*/
|
|
1465
|
+
declare function validatePositionSize(usdValue: number, longAssets?: PairAssetInput[], shortAssets?: PairAssetInput[]): {
|
|
1466
|
+
valid: boolean;
|
|
1467
|
+
error?: string;
|
|
1468
|
+
minimumRequired?: number;
|
|
530
1469
|
};
|
|
531
1470
|
|
|
532
1471
|
/**
|
|
533
|
-
*
|
|
1472
|
+
* Convert a full/prefixed symbol (e.g., "xyz:XYZ100") to a display symbol (e.g., "XYZ100").
|
|
1473
|
+
*/
|
|
1474
|
+
declare function toDisplaySymbol(symbol: string): string;
|
|
1475
|
+
/**
|
|
1476
|
+
* Convert a display symbol back to backend form using a provided map.
|
|
1477
|
+
* If mapping is missing, returns the original symbol.
|
|
1478
|
+
* For multi-market assets, returns the first available market.
|
|
1479
|
+
* @param displaySymbol e.g., "TSLA"
|
|
1480
|
+
* @param hip3Assets map of display -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"])
|
|
534
1481
|
*/
|
|
535
|
-
declare
|
|
1482
|
+
declare function toBackendSymbol(displaySymbol: string, hip3Assets: Map<string, string[]>): string;
|
|
536
1483
|
/**
|
|
537
|
-
*
|
|
1484
|
+
* Convert a display symbol to backend form for a specific market prefix.
|
|
1485
|
+
* This is useful when an asset is available on multiple markets (e.g., xyz:TSLA and flx:TSLA).
|
|
1486
|
+
* @param displaySymbol e.g., "TSLA"
|
|
1487
|
+
* @param marketPrefix e.g., "xyz" or "flx"
|
|
1488
|
+
* @param hip3Assets map of display -> all full market names
|
|
1489
|
+
* @returns Full market name if found, null if prefix not specified for multi-market asset, otherwise displaySymbol with prefix
|
|
538
1490
|
*/
|
|
539
|
-
declare
|
|
1491
|
+
declare function toBackendSymbolWithMarket(displaySymbol: string, marketPrefix: string | undefined, hip3Assets: Map<string, string[]>): string | null;
|
|
540
1492
|
/**
|
|
541
|
-
*
|
|
1493
|
+
* Get all available markets for a display symbol.
|
|
1494
|
+
* @param displaySymbol e.g., "TSLA"
|
|
1495
|
+
* @param hip3Assets map of display -> all full market names
|
|
1496
|
+
* @returns Array of full market names, e.g., ["xyz:TSLA", "flx:TSLA"]
|
|
542
1497
|
*/
|
|
543
|
-
declare
|
|
1498
|
+
declare function getAvailableMarkets(displaySymbol: string, hip3Assets: Map<string, string[]>): string[];
|
|
544
1499
|
/**
|
|
545
|
-
*
|
|
1500
|
+
* Extract the market prefix from a full market name.
|
|
1501
|
+
* @param fullSymbol e.g., "xyz:TSLA"
|
|
1502
|
+
* @returns The prefix (e.g., "xyz") or undefined if no prefix
|
|
546
1503
|
*/
|
|
547
|
-
declare
|
|
1504
|
+
declare function getMarketPrefix(fullSymbol: string): string | undefined;
|
|
1505
|
+
/**
|
|
1506
|
+
* Check if a symbol is a HIP-3 market (has a prefix).
|
|
1507
|
+
* @param symbol e.g., "xyz:TSLA" or "TSLA"
|
|
1508
|
+
* @returns true if the symbol has a market prefix
|
|
1509
|
+
*/
|
|
1510
|
+
declare function isHip3Market(symbol: string): boolean;
|
|
1511
|
+
|
|
1512
|
+
declare const useMarketData: any;
|
|
548
1513
|
|
|
549
|
-
export {
|
|
550
|
-
export type { AccountSummaryResponseDto, AgentWalletDto, ApiErrorResponse, ApiResponse, BalanceSummaryDto, CrossMarginSummaryDto, CumFundingDto, MarginSummaryDto,
|
|
1514
|
+
export { AccountSummaryCalculator, ConflictDetector, MAX_ASSETS_PER_LEG, MINIMUM_ASSET_USD_VALUE, MaxAssetsPerLegError, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, executeSpotOrder, getAvailableMarkets, getCompleteTimestamps, getMarketPrefix, getPortfolio, isHip3Market, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toBackendSymbol, toBackendSymbolWithMarket, toDisplaySymbol, toggleWatchlist, updateLeverage, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllBaskets, useAllUserBalances, useAuth, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMarketData, useMarketDataAllPayload, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePerpMetaAssets, usePortfolio, usePosition, useSpotOrder, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWatchlist, useWatchlistBaskets, useWebData, validateMaxAssetsPerLeg, validateMinimumAssetSize, validatePositionSize };
|
|
1515
|
+
export type { AccountSummaryResponseDto, ActiveAssetGroupItem, ActiveAssetsResponse, AdjustAdvanceAssetInput, AdjustAdvanceItemInput, AdjustAdvanceResponseDto, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, AutoSyncFillsOptions, AutoSyncFillsState, BalanceSummaryDto, CancelOrderResponseDto, CancelTwapResponseDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ClearinghouseState, CloseAllPositionsResponseDto, CloseAllPositionsResultDto, CloseExecutionType, ClosePositionRequestInput, ClosePositionResponseDto, CollateralFilter, CollateralToken, CreatePositionRequestInput, CreatePositionResponseDto, CrossMarginSummaryDto, CumFundingDto, ExecutionType, ExtraAgent, HLWebSocketResponse, HistoricalRange, LadderConfigInput, MarginSummaryDto, MarketDataBySymbol, NotificationCategory, NotificationDto, OpenLimitOrderDto, OpenPositionDto, OrderAssetDto, OrderStatus, PairAssetDto, PairAssetInput, PerformanceOverlay, PlatformAccountSummaryResponseDto, PortfolioBucketDto, PortfolioInterval, PortfolioIntervalsDto, PortfolioOverallDto, PortfolioResponseDto, PositionAdjustmentType, PositionAssetDetailDto, PositionAssetSummaryDto, PositionResponseStatus, RealtimeBar, RealtimeBarsCallback, SpotBalance, SpotOrderFilledStatus, SpotOrderHyperliquidData, SpotOrderHyperliquidResult, SpotOrderRequestInput, SpotOrderResponseDto, SpotState, ToggleWatchlistResponseDto, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlThresholdInput, TpSlThresholdType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TwapChunkStatusDto, TwapMonitoringDto, TwapSliceFillResponseItem, UniverseAsset, UpdateLeverageRequestInput, UpdateLeverageResponseDto, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseNotificationsResult, UsePerformanceOverlaysReturn, UsePortfolioResult, UseSpotOrderResult, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WatchlistItemDto, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
|