@pear-protocol/hyperliquid-sdk 0.0.49 → 0.0.51
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/hyperliquid.d.ts +14 -2
- package/dist/clients/positions.d.ts +1 -1
- package/dist/clients/sync.d.ts +1 -1
- package/dist/clients/watchlist.d.ts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/useAccountSummary.d.ts +5 -0
- package/dist/hooks/useAgentWallet.d.ts +4 -9
- package/dist/hooks/usePortfolio.d.ts +1 -1
- package/dist/hooks/useTrading.d.ts +1 -8
- package/dist/hooks/useWebData.d.ts +3 -2
- package/dist/hyperliquid-websocket.d.ts +2 -1
- package/dist/index.d.ts +84 -96
- package/dist/index.js +400 -310
- package/dist/provider.d.ts +0 -20
- package/dist/store/tokenSelectionMetadataStore.d.ts +3 -2
- package/dist/types.d.ts +69 -21
- package/dist/utils/account-summary-calculator.d.ts +6 -13
- package/dist/utils/position-processor.d.ts +2 -2
- package/dist/utils/symbol-translator.d.ts +11 -0
- package/dist/utils/token-metadata-extractor.d.ts +11 -9
- package/dist/websocket.d.ts +2 -1
- package/package.json +1 -1
- package/README.md +0 -735
- package/dist/hooks/useAddress.d.ts +0 -9
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
import type { ApiResponse, CandleInterval, CandleData, ExternalFillDto } from '../types';
|
|
1
|
+
import type { ApiResponse, CandleInterval, CandleData, ExternalFillDto, AllPerpMetasResponse, ExtraAgent } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Fetch historical candle data from HyperLiquid API
|
|
4
4
|
*/
|
|
5
|
-
export declare const fetchHistoricalCandles: (coin: string, startTime: number, endTime: number, interval: CandleInterval) => Promise<ApiResponse<CandleData[]>>;
|
|
5
|
+
export declare const fetchHistoricalCandles: (coin: string, startTime: number, endTime: number, interval: CandleInterval, displayToFull: Map<string, string>) => Promise<ApiResponse<CandleData[]>>;
|
|
6
6
|
/**
|
|
7
7
|
* Retrieve recent user fills from HyperLiquid and map to ExternalFillDto[]
|
|
8
8
|
*/
|
|
9
9
|
export declare const fetchUserFillsFromHyperliquid: (user: string, startTime: number, aggregateByTime?: boolean) => Promise<ApiResponse<ExternalFillDto[]>>;
|
|
10
|
+
/**
|
|
11
|
+
* Fetch all perp metas from HyperLiquid API
|
|
12
|
+
* Endpoint: https://api.hyperliquid.xyz/info
|
|
13
|
+
* Payload: { "type": "allPerpMetas" }
|
|
14
|
+
*/
|
|
15
|
+
export declare const fetchAllPerpMetas: () => Promise<ApiResponse<AllPerpMetasResponse>>;
|
|
16
|
+
/**
|
|
17
|
+
* Fetch extra agent approvals for a given user from HyperLiquid API
|
|
18
|
+
* Endpoint: https://api.hyperliquid.xyz/info
|
|
19
|
+
* Payload: { "type": "extraAgents", "user": "0x..." }
|
|
20
|
+
*/
|
|
21
|
+
export declare const fetchExtraAgents: (user: string) => Promise<ApiResponse<ExtraAgent[]>>;
|
|
@@ -56,7 +56,7 @@ export interface CreatePositionResponseDto {
|
|
|
56
56
|
* Caller should supply an accessToken from localStorage.getItem('accessToken')
|
|
57
57
|
* @throws MinimumPositionSizeError if any asset has less than $11 USD value
|
|
58
58
|
*/
|
|
59
|
-
export declare function createPosition(baseUrl: string, accessToken: string, payload: CreatePositionRequestInput): Promise<ApiResponse<CreatePositionResponseDto>>;
|
|
59
|
+
export declare function createPosition(baseUrl: string, accessToken: string, payload: CreatePositionRequestInput, displayToFull: Map<string, string>): Promise<ApiResponse<CreatePositionResponseDto>>;
|
|
60
60
|
export interface UpdateRiskParametersRequestInput {
|
|
61
61
|
stopLoss?: TpSlThresholdInput | null;
|
|
62
62
|
takeProfit?: TpSlThresholdInput | null;
|
package/dist/clients/sync.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export declare const syncFills: (baseUrl: string, accessToken: string, payload:
|
|
|
6
6
|
/**
|
|
7
7
|
* Convenience: fetch user fills from HyperLiquid, then sync them to Pear backend
|
|
8
8
|
*/
|
|
9
|
-
export declare const syncUserFillsFromHyperliquid: (baseUrl: string, accessToken: string, user: string, aggregateByTime?: boolean) => Promise<ApiResponse<SyncFillsResponseDto>>;
|
|
9
|
+
export declare const syncUserFillsFromHyperliquid: (baseUrl: string, accessToken: string, user: string, aggregateByTime?: boolean, lastSyncAt?: number | null) => Promise<ApiResponse<SyncFillsResponseDto>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ApiResponse, ToggleWatchlistResponseDto, WatchlistAssetDto } from '../types';
|
|
2
|
-
export declare function toggleWatchlist(baseUrl: string, accessToken: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[]): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
|
|
2
|
+
export declare function toggleWatchlist(baseUrl: string, accessToken: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[], displayToFull: Map<string, string>): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
readonly
|
|
4
|
-
readonly
|
|
5
|
-
readonly loading: false;
|
|
6
|
-
readonly error: null;
|
|
7
|
-
readonly refreshAgentWalletStatus: () => Promise<GetAgentWalletResponseDto>;
|
|
8
|
-
readonly createAgentWallet: () => Promise<CreateAgentWalletResponseDto>;
|
|
9
|
-
readonly notifyAgentWalletApproved: () => Promise<GetAgentWalletResponseDto>;
|
|
1
|
+
export declare function useAgentWallet(): {
|
|
2
|
+
readonly refreshAgentWalletStatus: () => Promise<void>;
|
|
3
|
+
readonly createAgentWallet: () => Promise<import("../types").CreateAgentWalletResponseDto>;
|
|
4
|
+
readonly notifyAgentWalletApproved: () => Promise<void>;
|
|
10
5
|
};
|
|
@@ -8,6 +8,6 @@ export interface UsePortfolioResult {
|
|
|
8
8
|
/**
|
|
9
9
|
* Hook to fetch and manage portfolio data
|
|
10
10
|
* Returns bucketed volume, open interest snapshot, win/loss trade counts,
|
|
11
|
-
* and overall metrics
|
|
11
|
+
* and overall metrics
|
|
12
12
|
*/
|
|
13
13
|
export declare function usePortfolio(): UsePortfolioResult;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OpenLimitOrderDto } from '../types';
|
|
2
2
|
import type { TradeHistoryDataDto } from '../types';
|
|
3
3
|
export declare const useTradeHistories: () => {
|
|
4
4
|
data: TradeHistoryDataDto[] | null;
|
|
@@ -11,10 +11,3 @@ export declare const useOpenOrders: () => {
|
|
|
11
11
|
data: OpenLimitOrderDto[] | null;
|
|
12
12
|
isLoading: boolean;
|
|
13
13
|
};
|
|
14
|
-
/**
|
|
15
|
-
* Hook to access account summary with real-time calculations and loading state
|
|
16
|
-
*/
|
|
17
|
-
export declare const useAccountSummary: () => {
|
|
18
|
-
data: AccountSummaryResponseDto | null;
|
|
19
|
-
isLoading: boolean;
|
|
20
|
-
};
|
|
@@ -3,9 +3,10 @@ import type { AssetMarketData, ClearinghouseState } from '../types';
|
|
|
3
3
|
* Hook to access webData and native WebSocket state
|
|
4
4
|
*/
|
|
5
5
|
export declare const useWebData: () => {
|
|
6
|
-
clearinghouseState: ClearinghouseState |
|
|
7
|
-
perpsAtOpenInterestCap: string[] |
|
|
6
|
+
clearinghouseState: ClearinghouseState | null;
|
|
7
|
+
perpsAtOpenInterestCap: string[] | null;
|
|
8
8
|
marketDataBySymbol: Record<string, AssetMarketData>;
|
|
9
|
+
hip3Assets: Map<string, string>;
|
|
9
10
|
isConnected: boolean;
|
|
10
11
|
error: string | null;
|
|
11
12
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export interface UseHyperliquidNativeWebSocketProps {
|
|
2
2
|
address: string | null;
|
|
3
3
|
tokens?: string[];
|
|
4
|
+
enabled?: boolean;
|
|
4
5
|
}
|
|
5
6
|
export interface UseHyperliquidNativeWebSocketReturn {
|
|
6
7
|
isConnected: boolean;
|
|
7
8
|
lastError: string | null;
|
|
8
9
|
}
|
|
9
|
-
export declare const useHyperliquidNativeWebSocket: ({ address, }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
|
10
|
+
export declare const useHyperliquidNativeWebSocket: ({ address, enabled, }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ type WebSocketConnectionState = 'connecting' | 'connected' | 'disconnected' | 'e
|
|
|
28
28
|
/**
|
|
29
29
|
* WebSocket channels
|
|
30
30
|
*/
|
|
31
|
-
type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'twap-details' | 'notifications' | 'market-data' | 'market-data-all' | '
|
|
31
|
+
type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'twap-details' | 'notifications' | 'market-data' | 'market-data-all' | 'webData3' | 'allMids' | 'activeAssetData';
|
|
32
32
|
/**
|
|
33
33
|
* WebSocket subscription message
|
|
34
34
|
*/
|
|
@@ -123,6 +123,7 @@ interface TradeHistoryAssetDataDto {
|
|
|
123
123
|
entryWeight: number;
|
|
124
124
|
entryPrice: number;
|
|
125
125
|
limitPrice: number;
|
|
126
|
+
leverage: number;
|
|
126
127
|
size: number;
|
|
127
128
|
externalFeePaid: number;
|
|
128
129
|
builderFeePaid: number;
|
|
@@ -138,6 +139,7 @@ interface TradeHistoryDataDto {
|
|
|
138
139
|
externalFeePaid: number;
|
|
139
140
|
builderFeePaid: number;
|
|
140
141
|
realizedPnl: number;
|
|
142
|
+
realizedPnlPercentage: number;
|
|
141
143
|
totalEntryValue: number;
|
|
142
144
|
totalValue: number;
|
|
143
145
|
entryRatio: number;
|
|
@@ -192,6 +194,7 @@ interface OpenPositionDto {
|
|
|
192
194
|
positionValue: number;
|
|
193
195
|
marginUsed: number;
|
|
194
196
|
unrealizedPnl: number;
|
|
197
|
+
unrealizedPnlPercentage: number;
|
|
195
198
|
longAssets: PositionAssetDetailDto[];
|
|
196
199
|
shortAssets: PositionAssetDetailDto[];
|
|
197
200
|
createdAt: string;
|
|
@@ -272,15 +275,22 @@ interface BalanceSummaryDto {
|
|
|
272
275
|
* Agent wallet information
|
|
273
276
|
*/
|
|
274
277
|
interface AgentWalletDto {
|
|
275
|
-
address
|
|
278
|
+
address?: string;
|
|
276
279
|
status: string;
|
|
277
280
|
}
|
|
281
|
+
interface PlatformAccountSummaryResponseDto {
|
|
282
|
+
agentWalletAddress: string | null;
|
|
283
|
+
totalClosedTrades: number;
|
|
284
|
+
totalLimitOrderUsdValue?: number;
|
|
285
|
+
totalTwapChunkUsdValue?: number;
|
|
286
|
+
lastSyncedAt?: number;
|
|
287
|
+
}
|
|
278
288
|
/**
|
|
279
289
|
* Account balance response (renamed to AccountSummaryResponseDto for consistency)
|
|
280
290
|
*/
|
|
281
291
|
interface AccountSummaryResponseDto {
|
|
282
292
|
balanceSummary: BalanceSummaryDto;
|
|
283
|
-
agentWallet
|
|
293
|
+
agentWallet?: AgentWalletDto;
|
|
284
294
|
}
|
|
285
295
|
declare enum AuthStatus {
|
|
286
296
|
Idle = "idle",
|
|
@@ -298,17 +308,14 @@ interface UserProfile {
|
|
|
298
308
|
appId: string;
|
|
299
309
|
}
|
|
300
310
|
type AgentWalletStatus = 'ACTIVE' | 'EXPIRED' | 'NOT_FOUND';
|
|
301
|
-
interface GetAgentWalletResponseDto {
|
|
302
|
-
agentWalletAddress?: string;
|
|
303
|
-
agentName: string;
|
|
304
|
-
status: AgentWalletStatus;
|
|
305
|
-
}
|
|
306
311
|
interface CreateAgentWalletResponseDto {
|
|
307
312
|
agentWalletAddress: string;
|
|
308
313
|
message: string;
|
|
309
314
|
}
|
|
310
|
-
interface
|
|
311
|
-
|
|
315
|
+
interface ExtraAgent {
|
|
316
|
+
name: string;
|
|
317
|
+
address: string;
|
|
318
|
+
validUntil: number;
|
|
312
319
|
}
|
|
313
320
|
interface AgentWalletState {
|
|
314
321
|
address: string | null;
|
|
@@ -323,6 +330,7 @@ interface WebSocketMessage {
|
|
|
323
330
|
method: "subscribe" | "unsubscribe";
|
|
324
331
|
subscription: {
|
|
325
332
|
type: string;
|
|
333
|
+
dex?: string;
|
|
326
334
|
coin?: string;
|
|
327
335
|
interval?: string;
|
|
328
336
|
user?: string;
|
|
@@ -332,13 +340,44 @@ interface WebSocketMessage {
|
|
|
332
340
|
/**
|
|
333
341
|
* WebSocket response from HyperLiquid native API
|
|
334
342
|
*/
|
|
335
|
-
type HLChannel = '
|
|
343
|
+
type HLChannel = 'webData3' | 'allMids' | 'activeAssetData' | 'candle';
|
|
336
344
|
interface HLChannelDataMap {
|
|
337
|
-
|
|
345
|
+
webData3: WebData3Response;
|
|
338
346
|
allMids: WsAllMidsData;
|
|
339
347
|
activeAssetData: ActiveAssetData;
|
|
340
348
|
candle: CandleData;
|
|
341
349
|
}
|
|
350
|
+
interface WebData3UserState {
|
|
351
|
+
agentAddress?: string;
|
|
352
|
+
agentValidUntil?: number;
|
|
353
|
+
cumLedger: string;
|
|
354
|
+
serverTime: number;
|
|
355
|
+
isVault: boolean;
|
|
356
|
+
user: string;
|
|
357
|
+
dexAbstractionEnabled?: boolean;
|
|
358
|
+
}
|
|
359
|
+
interface WebData3AssetCtx {
|
|
360
|
+
funding: string;
|
|
361
|
+
openInterest: string;
|
|
362
|
+
prevDayPx: string;
|
|
363
|
+
dayNtlVlm: string;
|
|
364
|
+
premium: string | null;
|
|
365
|
+
oraclePx: string;
|
|
366
|
+
markPx: string;
|
|
367
|
+
midPx: string | null;
|
|
368
|
+
impactPxs: string[] | null;
|
|
369
|
+
dayBaseVlm: string;
|
|
370
|
+
}
|
|
371
|
+
interface WebData3PerpDexState {
|
|
372
|
+
clearinghouseState: ClearinghouseState;
|
|
373
|
+
totalVaultEquity: string;
|
|
374
|
+
assetCtxs: WebData3AssetCtx[];
|
|
375
|
+
perpsAtOpenInterestCap: string[];
|
|
376
|
+
}
|
|
377
|
+
interface WebData3Response {
|
|
378
|
+
userState: WebData3UserState;
|
|
379
|
+
perpDexStates: WebData3PerpDexState[];
|
|
380
|
+
}
|
|
342
381
|
interface HLWebSocketResponse<T extends HLChannel = HLChannel> {
|
|
343
382
|
channel: T;
|
|
344
383
|
data: HLChannelDataMap[T];
|
|
@@ -372,17 +411,6 @@ interface UniverseAsset {
|
|
|
372
411
|
onlyIsolated?: boolean;
|
|
373
412
|
isDelisted?: boolean;
|
|
374
413
|
}
|
|
375
|
-
/**
|
|
376
|
-
* WebData2 response structure
|
|
377
|
-
*/
|
|
378
|
-
interface WebData2Response {
|
|
379
|
-
assetCtxs: AssetCtx[];
|
|
380
|
-
meta: {
|
|
381
|
-
universe: UniverseAsset[];
|
|
382
|
-
};
|
|
383
|
-
clearinghouseState: ClearinghouseState;
|
|
384
|
-
perpsAtOpenInterestCap?: string[];
|
|
385
|
-
}
|
|
386
414
|
interface ClearinghouseState {
|
|
387
415
|
assetPositions: AssetPosition[];
|
|
388
416
|
crossMaintenanceMarginUsed: string;
|
|
@@ -484,9 +512,6 @@ interface ActiveAssetData {
|
|
|
484
512
|
availableToTrade: [string, string];
|
|
485
513
|
markPx: string;
|
|
486
514
|
}
|
|
487
|
-
/**
|
|
488
|
-
* Token metadata from WebData2 and AllMids
|
|
489
|
-
*/
|
|
490
515
|
interface TokenMetadata {
|
|
491
516
|
currentPrice: number;
|
|
492
517
|
prevDayPrice: number;
|
|
@@ -518,7 +543,7 @@ interface TokenConflict {
|
|
|
518
543
|
conflictMessage: string;
|
|
519
544
|
}
|
|
520
545
|
interface AssetMarketData {
|
|
521
|
-
asset: AssetCtx;
|
|
546
|
+
asset: WebData3AssetCtx | AssetCtx;
|
|
522
547
|
universe: UniverseAsset;
|
|
523
548
|
}
|
|
524
549
|
interface PairAssetDto {
|
|
@@ -608,13 +633,6 @@ interface PearHyperliquidContextType {
|
|
|
608
633
|
loginWithPrivyToken: (address: string, appId: string, accessToken: string) => Promise<void>;
|
|
609
634
|
refreshTokens: () => Promise<any>;
|
|
610
635
|
logout: () => Promise<void>;
|
|
611
|
-
agentWallet: AgentWalletState;
|
|
612
|
-
isAgentWalletReady: boolean;
|
|
613
|
-
agentWalletError: string | null;
|
|
614
|
-
agentWalletLoading: boolean;
|
|
615
|
-
refreshAgentWalletStatus: () => Promise<any>;
|
|
616
|
-
createAgentWallet: () => Promise<any>;
|
|
617
|
-
notifyAgentWalletApproved: () => Promise<any>;
|
|
618
636
|
}
|
|
619
637
|
interface PearHyperliquidProviderProps {
|
|
620
638
|
children: ReactNode;
|
|
@@ -646,27 +664,10 @@ declare function usePearAuth(): {
|
|
|
646
664
|
readonly refreshTokens: () => Promise<any>;
|
|
647
665
|
readonly logout: () => Promise<void>;
|
|
648
666
|
};
|
|
649
|
-
/**
|
|
650
|
-
* Provider-aware Agent Wallet hook. Uses agent wallet state/actions provided by PearHyperliquidProvider.
|
|
651
|
-
*/
|
|
652
|
-
declare function usePearAgentWallet(): {
|
|
653
|
-
readonly agentWallet: AgentWalletState;
|
|
654
|
-
readonly isReady: boolean;
|
|
655
|
-
readonly loading: boolean;
|
|
656
|
-
readonly error: string | null;
|
|
657
|
-
readonly refreshAgentWalletStatus: () => Promise<any>;
|
|
658
|
-
readonly createAgentWallet: () => Promise<any>;
|
|
659
|
-
readonly notifyAgentWalletApproved: () => Promise<any>;
|
|
660
|
-
};
|
|
661
667
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
declare const useAddress: () => {
|
|
666
|
-
address: string | null;
|
|
667
|
-
setAddress: (address: string | null) => void;
|
|
668
|
-
clearAddress: () => void;
|
|
669
|
-
isLoggedIn: boolean;
|
|
668
|
+
declare const useAccountSummary: () => {
|
|
669
|
+
data: AccountSummaryResponseDto | null;
|
|
670
|
+
isLoading: boolean;
|
|
670
671
|
};
|
|
671
672
|
|
|
672
673
|
declare const useTradeHistories: () => {
|
|
@@ -680,13 +681,6 @@ declare const useOpenOrders: () => {
|
|
|
680
681
|
data: OpenLimitOrderDto[] | null;
|
|
681
682
|
isLoading: boolean;
|
|
682
683
|
};
|
|
683
|
-
/**
|
|
684
|
-
* Hook to access account summary with real-time calculations and loading state
|
|
685
|
-
*/
|
|
686
|
-
declare const useAccountSummary: () => {
|
|
687
|
-
data: AccountSummaryResponseDto | null;
|
|
688
|
-
isLoading: boolean;
|
|
689
|
-
};
|
|
690
684
|
|
|
691
685
|
interface UserSelectionState {
|
|
692
686
|
longTokens: TokenSelection[];
|
|
@@ -718,9 +712,10 @@ declare const useUserSelection: () => UserSelectionState;
|
|
|
718
712
|
* Hook to access webData and native WebSocket state
|
|
719
713
|
*/
|
|
720
714
|
declare const useWebData: () => {
|
|
721
|
-
clearinghouseState: ClearinghouseState |
|
|
722
|
-
perpsAtOpenInterestCap: string[] |
|
|
715
|
+
clearinghouseState: ClearinghouseState | null;
|
|
716
|
+
perpsAtOpenInterestCap: string[] | null;
|
|
723
717
|
marketDataBySymbol: Record<string, AssetMarketData>;
|
|
718
|
+
hip3Assets: Map<string, string>;
|
|
724
719
|
isConnected: boolean;
|
|
725
720
|
error: string | null;
|
|
726
721
|
};
|
|
@@ -806,14 +801,10 @@ interface UsePerformanceOverlaysReturn {
|
|
|
806
801
|
}
|
|
807
802
|
declare const usePerformanceOverlays: () => UsePerformanceOverlaysReturn;
|
|
808
803
|
|
|
809
|
-
declare function useAgentWallet(
|
|
810
|
-
readonly
|
|
811
|
-
readonly isReady: boolean;
|
|
812
|
-
readonly loading: false;
|
|
813
|
-
readonly error: null;
|
|
814
|
-
readonly refreshAgentWalletStatus: () => Promise<GetAgentWalletResponseDto>;
|
|
804
|
+
declare function useAgentWallet(): {
|
|
805
|
+
readonly refreshAgentWalletStatus: () => Promise<void>;
|
|
815
806
|
readonly createAgentWallet: () => Promise<CreateAgentWalletResponseDto>;
|
|
816
|
-
readonly notifyAgentWalletApproved: () => Promise<
|
|
807
|
+
readonly notifyAgentWalletApproved: () => Promise<void>;
|
|
817
808
|
};
|
|
818
809
|
|
|
819
810
|
interface AutoSyncFillsOptions {
|
|
@@ -917,7 +908,7 @@ interface CreatePositionResponseDto {
|
|
|
917
908
|
* Caller should supply an accessToken from localStorage.getItem('accessToken')
|
|
918
909
|
* @throws MinimumPositionSizeError if any asset has less than $11 USD value
|
|
919
910
|
*/
|
|
920
|
-
declare function createPosition(baseUrl: string, accessToken: string, payload: CreatePositionRequestInput): Promise<ApiResponse<CreatePositionResponseDto>>;
|
|
911
|
+
declare function createPosition(baseUrl: string, accessToken: string, payload: CreatePositionRequestInput, displayToFull: Map<string, string>): Promise<ApiResponse<CreatePositionResponseDto>>;
|
|
921
912
|
interface UpdateRiskParametersRequestInput {
|
|
922
913
|
stopLoss?: TpSlThresholdInput | null;
|
|
923
914
|
takeProfit?: TpSlThresholdInput | null;
|
|
@@ -1076,15 +1067,16 @@ interface UsePortfolioResult {
|
|
|
1076
1067
|
/**
|
|
1077
1068
|
* Hook to fetch and manage portfolio data
|
|
1078
1069
|
* Returns bucketed volume, open interest snapshot, win/loss trade counts,
|
|
1079
|
-
* and overall metrics
|
|
1070
|
+
* and overall metrics
|
|
1080
1071
|
*/
|
|
1081
1072
|
declare function usePortfolio(): UsePortfolioResult;
|
|
1082
1073
|
|
|
1083
1074
|
interface UseHyperliquidWebSocketProps {
|
|
1084
1075
|
wsUrl: string;
|
|
1085
1076
|
address: string | null;
|
|
1077
|
+
enabled?: boolean;
|
|
1086
1078
|
}
|
|
1087
|
-
declare const useHyperliquidWebSocket: ({ wsUrl, address }: UseHyperliquidWebSocketProps) => {
|
|
1079
|
+
declare const useHyperliquidWebSocket: ({ wsUrl, address, enabled, }: UseHyperliquidWebSocketProps) => {
|
|
1088
1080
|
isConnected: boolean;
|
|
1089
1081
|
lastError: string | null;
|
|
1090
1082
|
};
|
|
@@ -1092,12 +1084,13 @@ declare const useHyperliquidWebSocket: ({ wsUrl, address }: UseHyperliquidWebSoc
|
|
|
1092
1084
|
interface UseHyperliquidNativeWebSocketProps {
|
|
1093
1085
|
address: string | null;
|
|
1094
1086
|
tokens?: string[];
|
|
1087
|
+
enabled?: boolean;
|
|
1095
1088
|
}
|
|
1096
1089
|
interface UseHyperliquidNativeWebSocketReturn {
|
|
1097
1090
|
isConnected: boolean;
|
|
1098
1091
|
lastError: string | null;
|
|
1099
1092
|
}
|
|
1100
|
-
declare const useHyperliquidNativeWebSocket: ({ address, }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
|
1093
|
+
declare const useHyperliquidNativeWebSocket: ({ address, enabled, }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
|
1101
1094
|
|
|
1102
1095
|
/**
|
|
1103
1096
|
* Mark notifications as read up to a given timestamp (ms)
|
|
@@ -1112,25 +1105,18 @@ declare function markNotificationReadById(baseUrl: string, accessToken: string,
|
|
|
1112
1105
|
updated: number;
|
|
1113
1106
|
}>>;
|
|
1114
1107
|
|
|
1115
|
-
declare function toggleWatchlist(baseUrl: string, accessToken: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[]): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
|
|
1108
|
+
declare function toggleWatchlist(baseUrl: string, accessToken: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[], displayToFull: Map<string, string>): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
|
|
1116
1109
|
|
|
1117
1110
|
/**
|
|
1118
1111
|
* Account summary calculation utility class
|
|
1119
1112
|
*/
|
|
1120
1113
|
declare class AccountSummaryCalculator {
|
|
1121
|
-
private
|
|
1122
|
-
constructor(
|
|
1123
|
-
/**
|
|
1124
|
-
* Calculate account summary from webData2 and platform orders
|
|
1125
|
-
*/
|
|
1126
|
-
calculateAccountSummary(platformAccountSummary: AccountSummaryResponseDto | null, platformOpenOrders: OpenLimitOrderDto[] | null, agentWalletAddress?: string, agentWalletStatus?: string): AccountSummaryResponseDto | null;
|
|
1127
|
-
/**
|
|
1128
|
-
* Calculate total USD value of open limit orders
|
|
1129
|
-
*/
|
|
1130
|
-
private calculateTotalLimitOrderValue;
|
|
1114
|
+
private clearinghouseState;
|
|
1115
|
+
constructor(clearinghouseState: ClearinghouseState | null);
|
|
1131
1116
|
/**
|
|
1132
|
-
*
|
|
1117
|
+
* Calculate account summary from real-time clearinghouse state and platform orders
|
|
1133
1118
|
*/
|
|
1119
|
+
calculateAccountSummary(platformAccountSummary: PlatformAccountSummaryResponseDto | null, registeredAgentWallets: ExtraAgent[]): AccountSummaryResponseDto | null;
|
|
1134
1120
|
getClearinghouseState(): ClearinghouseState | null;
|
|
1135
1121
|
/**
|
|
1136
1122
|
* Check if real-time data is available
|
|
@@ -1153,34 +1139,36 @@ declare class ConflictDetector {
|
|
|
1153
1139
|
}
|
|
1154
1140
|
|
|
1155
1141
|
/**
|
|
1156
|
-
* Extracts token metadata from
|
|
1142
|
+
* Extracts token metadata from aggregated WebData3 contexts and AllMids data
|
|
1157
1143
|
*/
|
|
1158
1144
|
declare class TokenMetadataExtractor {
|
|
1159
1145
|
/**
|
|
1160
1146
|
* Extracts comprehensive token metadata
|
|
1161
1147
|
* @param symbol - Token symbol
|
|
1162
|
-
* @param
|
|
1148
|
+
* @param perpMetaAssets - Aggregated universe assets (flattened across dexes)
|
|
1149
|
+
* @param finalAssetContexts - Aggregated asset contexts (flattened across dexes)
|
|
1163
1150
|
* @param allMids - AllMids data containing current prices
|
|
1164
1151
|
* @param activeAssetData - Optional active asset data containing leverage information
|
|
1165
1152
|
* @returns TokenMetadata or null if token not found
|
|
1166
1153
|
*/
|
|
1167
|
-
static extractTokenMetadata(symbol: string,
|
|
1154
|
+
static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): TokenMetadata | null;
|
|
1168
1155
|
/**
|
|
1169
1156
|
* Extracts metadata for multiple tokens
|
|
1170
1157
|
* @param symbols - Array of token symbols
|
|
1171
|
-
* @param
|
|
1158
|
+
* @param perpMetaAssets - Aggregated universe assets
|
|
1159
|
+
* @param finalAssetContexts - Aggregated asset contexts
|
|
1172
1160
|
* @param allMids - AllMids data
|
|
1173
1161
|
* @param activeAssetData - Optional active asset data containing leverage information
|
|
1174
1162
|
* @returns Record of symbol to TokenMetadata
|
|
1175
1163
|
*/
|
|
1176
|
-
static extractMultipleTokensMetadata(symbols: string[],
|
|
1164
|
+
static extractMultipleTokensMetadata(symbols: string[], perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): Record<string, TokenMetadata | null>;
|
|
1177
1165
|
/**
|
|
1178
|
-
* Checks if token data is available in
|
|
1166
|
+
* Checks if token data is available in aggregated universe assets
|
|
1179
1167
|
* @param symbol - Token symbol
|
|
1180
|
-
* @param
|
|
1168
|
+
* @param perpMetaAssets - Aggregated universe assets
|
|
1181
1169
|
* @returns boolean indicating if token exists in universe
|
|
1182
1170
|
*/
|
|
1183
|
-
static isTokenAvailable(symbol: string,
|
|
1171
|
+
static isTokenAvailable(symbol: string, perpMetaAssets: UniverseAsset[] | null): boolean;
|
|
1184
1172
|
}
|
|
1185
1173
|
|
|
1186
1174
|
/**
|
|
@@ -1259,5 +1247,5 @@ declare function validatePositionSize(usdValue: number, longAssets?: PairAssetIn
|
|
|
1259
1247
|
|
|
1260
1248
|
declare const useMarketData: any;
|
|
1261
1249
|
|
|
1262
|
-
export { AccountSummaryCalculator, AuthStatus, ConflictDetector, MINIMUM_ASSET_USD_VALUE, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, getPortfolio, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, updateRiskParameters, useAccountSummary, useActiveBaskets,
|
|
1263
|
-
export type { AccountSummaryResponseDto, ActiveAssetGroupItem, ActiveAssetsResponse, 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, CreatePositionRequestInput, CreatePositionResponseDto, CrossMarginSummaryDto, CumFundingDto, ExecutionType, HLWebSocketResponse, HistoricalRange, LadderConfigInput, MarginSummaryDto, NotificationCategory, NotificationDto, OpenLimitOrderDto, OpenPositionDto, OrderAssetDto, OrderStatus, PairAssetDto, PairAssetInput, PerformanceOverlay, PortfolioBucketDto, PortfolioInterval, PortfolioIntervalsDto, PortfolioOverallDto, PortfolioResponseDto, PositionAdjustmentType, PositionAssetDetailDto, PositionAssetSummaryDto, PositionResponseStatus, RealtimeBar, RealtimeBarsCallback, ToggleWatchlistResponseDto, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlThresholdInput, TpSlThresholdType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TwapChunkStatusDto, TwapMonitoringDto, UniverseAsset, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto,
|
|
1250
|
+
export { AccountSummaryCalculator, AuthStatus, ConflictDetector, MINIMUM_ASSET_USD_VALUE, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, getPortfolio, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllBaskets, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMarketData, useMarketDataAllPayload, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearAuth, usePearHyperliquid, usePerformanceOverlays, usePortfolio, usePosition, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWatchlist, useWatchlistBaskets, useWebData, validateMinimumAssetSize, validatePositionSize };
|
|
1251
|
+
export type { AccountSummaryResponseDto, ActiveAssetGroupItem, ActiveAssetsResponse, 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, CreatePositionRequestInput, CreatePositionResponseDto, CrossMarginSummaryDto, CumFundingDto, ExecutionType, ExtraAgent, HLWebSocketResponse, HistoricalRange, LadderConfigInput, MarginSummaryDto, NotificationCategory, NotificationDto, OpenLimitOrderDto, OpenPositionDto, OrderAssetDto, OrderStatus, PairAssetDto, PairAssetInput, PerformanceOverlay, PlatformAccountSummaryResponseDto, PortfolioBucketDto, PortfolioInterval, PortfolioIntervalsDto, PortfolioOverallDto, PortfolioResponseDto, PositionAdjustmentType, PositionAssetDetailDto, PositionAssetSummaryDto, PositionResponseStatus, RealtimeBar, RealtimeBarsCallback, ToggleWatchlistResponseDto, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlThresholdInput, TpSlThresholdType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TwapChunkStatusDto, TwapMonitoringDto, UniverseAsset, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseNotificationsResult, UsePerformanceOverlaysReturn, UsePortfolioResult, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WatchlistItemDto, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
|