@pear-protocol/hyperliquid-sdk 0.0.60-beta-usdh-2 → 0.0.60-beta.10
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 +1 -1
- package/dist/clients/orders.d.ts +0 -41
- package/dist/clients/positions.d.ts +2 -2
- package/dist/clients/watchlist.d.ts +1 -1
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/useAuth.d.ts +6 -4
- package/dist/hooks/useMarketData.d.ts +7 -9
- package/dist/hooks/useWebData.d.ts +3 -21
- package/dist/index.d.ts +47 -179
- package/dist/index.js +269 -806
- package/dist/provider.d.ts +1 -1
- package/dist/store/historicalPriceDataStore.d.ts +12 -1
- package/dist/store/hyperliquidDataStore.d.ts +25 -1
- package/dist/store/marketDataStore.d.ts +10 -1
- package/dist/store/tokenSelectionMetadataStore.d.ts +2 -2
- package/dist/store/userDataStore.d.ts +30 -1
- package/dist/store/userSelection.d.ts +1 -1
- package/dist/types.d.ts +3 -38
- package/dist/utils/symbol-translator.d.ts +3 -32
- package/dist/utils/token-metadata-extractor.d.ts +5 -9
- package/package.json +3 -2
- package/dist/hooks/useSpotOrder.d.ts +0 -13
|
@@ -2,7 +2,7 @@ import type { ApiResponse, CandleInterval, CandleData, ExternalFillDto, AllPerpM
|
|
|
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,
|
|
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
|
*/
|
package/dist/clients/orders.d.ts
CHANGED
|
@@ -22,44 +22,3 @@ export interface CancelTwapResponseDto {
|
|
|
22
22
|
cancelledAt: string;
|
|
23
23
|
}
|
|
24
24
|
export declare function cancelTwapOrder(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
25
|
-
export interface SpotOrderRequestInput {
|
|
26
|
-
/** Asset to buy/sell (e.g., "USDH") */
|
|
27
|
-
asset: string;
|
|
28
|
-
/** Whether to buy (true) or sell (false) the asset */
|
|
29
|
-
isBuy: boolean;
|
|
30
|
-
/** Amount of asset to buy/sell (minimum: 11) */
|
|
31
|
-
amount: number;
|
|
32
|
-
}
|
|
33
|
-
/** Filled order status from Hyperliquid */
|
|
34
|
-
export interface SpotOrderFilledStatus {
|
|
35
|
-
filled: {
|
|
36
|
-
totalSz: string;
|
|
37
|
-
avgPx: string;
|
|
38
|
-
oid: number;
|
|
39
|
-
cloid: string;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
/** Hyperliquid order response data */
|
|
43
|
-
export interface SpotOrderHyperliquidData {
|
|
44
|
-
statuses: SpotOrderFilledStatus[];
|
|
45
|
-
}
|
|
46
|
-
/** Hyperliquid result from spot order execution */
|
|
47
|
-
export interface SpotOrderHyperliquidResult {
|
|
48
|
-
status: 'ok' | 'error';
|
|
49
|
-
response: {
|
|
50
|
-
type: 'order';
|
|
51
|
-
data: SpotOrderHyperliquidData;
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
export interface SpotOrderResponseDto {
|
|
55
|
-
orderId: string;
|
|
56
|
-
status: 'EXECUTED' | 'FAILED' | 'PENDING';
|
|
57
|
-
asset: string;
|
|
58
|
-
createdAt: string;
|
|
59
|
-
hyperliquidResult?: SpotOrderHyperliquidResult;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Execute a spot order (swap) using Pear Hyperliquid service
|
|
63
|
-
* POST /orders/spot
|
|
64
|
-
*/
|
|
65
|
-
export declare function executeSpotOrder(baseUrl: string, payload: SpotOrderRequestInput): Promise<ApiResponse<SpotOrderResponseDto>>;
|
|
@@ -56,7 +56,7 @@ export interface CreatePositionResponseDto {
|
|
|
56
56
|
* Authorization is derived from headers (Axios defaults or browser localStorage fallback)
|
|
57
57
|
* @throws MinimumPositionSizeError if any asset has less than $11 USD value
|
|
58
58
|
*/
|
|
59
|
-
export declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput,
|
|
59
|
+
export declare function createPosition(baseUrl: 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;
|
|
@@ -123,5 +123,5 @@ export interface AdjustAdvanceResponseDto {
|
|
|
123
123
|
status: string;
|
|
124
124
|
executedAt: string;
|
|
125
125
|
}
|
|
126
|
-
export declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[],
|
|
126
|
+
export declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[], displayToFull: Map<string, string>): Promise<ApiResponse<AdjustAdvanceResponseDto>>;
|
|
127
127
|
export declare function cancelTwap(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ApiResponse, ToggleWatchlistResponseDto, WatchlistAssetDto } from '../types';
|
|
2
|
-
export declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[],
|
|
2
|
+
export declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[], displayToFull: Map<string, string>): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export * from './useAgentWallet';
|
|
|
10
10
|
export * from './useAutoSyncFills';
|
|
11
11
|
export * from './usePosition';
|
|
12
12
|
export * from './useOrders';
|
|
13
|
-
export * from './useSpotOrder';
|
|
14
13
|
export * from './useTwap';
|
|
15
14
|
export * from './useNotifications';
|
|
16
15
|
export * from './useMarketData';
|
package/dist/hooks/useAuth.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import type { GetEIP712MessageResponse } from
|
|
1
|
+
import type { GetEIP712MessageResponse } from "../types";
|
|
2
2
|
export declare function useAuth(): {
|
|
3
3
|
readonly isReady: boolean;
|
|
4
|
-
readonly isAuthenticated:
|
|
5
|
-
readonly accessToken:
|
|
6
|
-
readonly refreshToken:
|
|
4
|
+
readonly isAuthenticated: boolean;
|
|
5
|
+
readonly accessToken: string | null;
|
|
6
|
+
readonly refreshToken: string | null;
|
|
7
7
|
readonly getEip712: (address: string) => Promise<GetEIP712MessageResponse>;
|
|
8
8
|
readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
|
|
9
9
|
readonly loginWithPrivyToken: (address: string, appId: string, privyAccessToken: string) => Promise<void>;
|
|
10
10
|
readonly refreshTokens: () => Promise<import("../types").RefreshTokenResponse>;
|
|
11
11
|
readonly logout: () => Promise<void>;
|
|
12
|
+
readonly setAddress: (address: string | null) => void;
|
|
13
|
+
readonly address: string | null;
|
|
12
14
|
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import type { ActiveAssetGroupItem, ActiveAssetsResponse, ActiveAssetsAllResponse
|
|
2
|
-
export type CollateralFilter = 'USDC' | 'USDH' | 'ALL';
|
|
1
|
+
import type { ActiveAssetGroupItem, ActiveAssetsResponse, ActiveAssetsAllResponse } from '../types';
|
|
3
2
|
export declare const useMarketDataPayload: () => ActiveAssetsResponse | null;
|
|
4
3
|
export declare const useMarketDataAllPayload: () => ActiveAssetsAllResponse | null;
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const useAllBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
4
|
+
export declare const useActiveBaskets: () => ActiveAssetGroupItem[];
|
|
5
|
+
export declare const useTopGainers: (limit?: number) => ActiveAssetGroupItem[];
|
|
6
|
+
export declare const useTopLosers: (limit?: number) => ActiveAssetGroupItem[];
|
|
7
|
+
export declare const useHighlightedBaskets: () => ActiveAssetGroupItem[];
|
|
8
|
+
export declare const useWatchlistBaskets: () => ActiveAssetGroupItem[];
|
|
9
|
+
export declare const useAllBaskets: () => ActiveAssetGroupItem[];
|
|
12
10
|
export declare const useFindBasket: (longs: string[], shorts: string[]) => ActiveAssetGroupItem | undefined;
|
|
@@ -1,30 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AssetMarketData, ClearinghouseState } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Hook to access webData and native WebSocket state
|
|
4
4
|
*/
|
|
5
5
|
export declare const useWebData: () => {
|
|
6
6
|
clearinghouseState: ClearinghouseState | null;
|
|
7
7
|
perpsAtOpenInterestCap: string[] | null;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Each symbol maps to its market variants (keyed by prefix).
|
|
11
|
-
* For non-HIP3 assets, use "default" as the key.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* // HIP-3 asset with multiple markets
|
|
16
|
-
* marketDataBySymbol["TSLA"]["xyz"] // { asset, universe: { collateralToken: "USDC" } }
|
|
17
|
-
* marketDataBySymbol["TSLA"]["flx"] // { asset, universe: { collateralToken: "USDH" } }
|
|
18
|
-
*
|
|
19
|
-
* // Regular asset
|
|
20
|
-
* marketDataBySymbol["BTC"]["default"] // { asset, universe }
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
marketDataBySymbol: MarketDataBySymbol;
|
|
24
|
-
/** Map of display name -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"]) */
|
|
25
|
-
hip3Assets: Map<string, string[]>;
|
|
26
|
-
/** Map of full market name -> prefix (e.g., "xyz:TSLA" -> "xyz") */
|
|
27
|
-
hip3MarketPrefixes: Map<string, string>;
|
|
8
|
+
marketDataBySymbol: Record<string, AssetMarketData>;
|
|
9
|
+
hip3Assets: Map<string, string>;
|
|
28
10
|
isConnected: boolean;
|
|
29
11
|
error: string | null;
|
|
30
12
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
+
import * as zustand from 'zustand';
|
|
2
3
|
|
|
3
4
|
interface PearHyperliquidContextType {
|
|
4
5
|
clientId: string;
|
|
@@ -178,8 +179,6 @@ interface TradeHistoryAssetDataDto {
|
|
|
178
179
|
externalFeePaid: number;
|
|
179
180
|
builderFeePaid: number;
|
|
180
181
|
realizedPnl: number;
|
|
181
|
-
marketPrefix?: string | null;
|
|
182
|
-
collateralToken?: CollateralToken;
|
|
183
182
|
}
|
|
184
183
|
/**
|
|
185
184
|
* Trade history data structure
|
|
@@ -228,8 +227,6 @@ interface PositionAssetDetailDto {
|
|
|
228
227
|
liquidationPrice: number;
|
|
229
228
|
initialWeight: number;
|
|
230
229
|
fundingPaid?: number;
|
|
231
|
-
marketPrefix?: string | null;
|
|
232
|
-
collateralToken?: CollateralToken;
|
|
233
230
|
}
|
|
234
231
|
interface TpSlThreshold {
|
|
235
232
|
type: 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
|
|
@@ -401,7 +398,7 @@ interface AgentWalletState {
|
|
|
401
398
|
* WebSocket message from HyperLiquid native API
|
|
402
399
|
*/
|
|
403
400
|
interface WebSocketMessage {
|
|
404
|
-
method:
|
|
401
|
+
method: "subscribe" | "unsubscribe";
|
|
405
402
|
subscription: {
|
|
406
403
|
type: string;
|
|
407
404
|
dex?: string;
|
|
@@ -475,12 +472,6 @@ interface AssetCtx {
|
|
|
475
472
|
impactPxs?: string[];
|
|
476
473
|
oraclePx: string;
|
|
477
474
|
}
|
|
478
|
-
/**
|
|
479
|
-
* Collateral token type
|
|
480
|
-
* 0 = USDC
|
|
481
|
-
* 360 = USDH
|
|
482
|
-
*/
|
|
483
|
-
type CollateralToken = 'USDC' | 'USDH';
|
|
484
475
|
/**
|
|
485
476
|
* Universe asset metadata
|
|
486
477
|
*/
|
|
@@ -490,8 +481,6 @@ interface UniverseAsset {
|
|
|
490
481
|
maxLeverage: number;
|
|
491
482
|
onlyIsolated?: boolean;
|
|
492
483
|
isDelisted?: boolean;
|
|
493
|
-
marketPrefix?: string;
|
|
494
|
-
collateralToken?: CollateralToken;
|
|
495
484
|
}
|
|
496
485
|
interface ClearinghouseState {
|
|
497
486
|
assetPositions: AssetPosition[];
|
|
@@ -609,7 +598,6 @@ interface TokenMetadata {
|
|
|
609
598
|
leverage?: LeverageInfo;
|
|
610
599
|
maxTradeSzs?: [string, string];
|
|
611
600
|
availableToTrade?: [string, string];
|
|
612
|
-
collateralToken?: CollateralToken;
|
|
613
601
|
}
|
|
614
602
|
/**
|
|
615
603
|
* Enhanced token selection with weight and metadata for basket trading
|
|
@@ -630,30 +618,9 @@ interface AssetMarketData {
|
|
|
630
618
|
asset: WebData3AssetCtx | AssetCtx;
|
|
631
619
|
universe: UniverseAsset;
|
|
632
620
|
}
|
|
633
|
-
/**
|
|
634
|
-
* Nested market data structure for multi-market assets.
|
|
635
|
-
* Each symbol maps to its market variants (keyed by prefix).
|
|
636
|
-
* For non-HIP3 assets, use "default" as the key.
|
|
637
|
-
*
|
|
638
|
-
* @example
|
|
639
|
-
* ```ts
|
|
640
|
-
* {
|
|
641
|
-
* "TSLA": {
|
|
642
|
-
* "xyz": { asset: {...}, universe: { collateralToken: "USDC", ... } },
|
|
643
|
-
* "flx": { asset: {...}, universe: { collateralToken: "USDH", ... } }
|
|
644
|
-
* },
|
|
645
|
-
* "BTC": {
|
|
646
|
-
* "default": { asset: {...}, universe: {...} }
|
|
647
|
-
* }
|
|
648
|
-
* }
|
|
649
|
-
* ```
|
|
650
|
-
*/
|
|
651
|
-
type MarketDataBySymbol = Record<string, Record<string, AssetMarketData>>;
|
|
652
621
|
interface PairAssetDto {
|
|
653
622
|
asset: string;
|
|
654
623
|
weight: number;
|
|
655
|
-
collateralToken: CollateralToken;
|
|
656
|
-
marketPrefix: string | null;
|
|
657
624
|
}
|
|
658
625
|
interface ActiveAssetGroupItem {
|
|
659
626
|
longAssets: PairAssetDto[];
|
|
@@ -667,7 +634,6 @@ interface ActiveAssetGroupItem {
|
|
|
667
634
|
weightedRatio?: string;
|
|
668
635
|
weightedPrevRatio?: string;
|
|
669
636
|
weightedChange24h?: string;
|
|
670
|
-
collateralType: 'USDC' | 'USDH' | 'MIXED';
|
|
671
637
|
}
|
|
672
638
|
interface ActiveAssetsResponse {
|
|
673
639
|
active: ActiveAssetGroupItem[];
|
|
@@ -685,7 +651,7 @@ interface ActiveAssetsAllResponse {
|
|
|
685
651
|
/**
|
|
686
652
|
* Candle interval options
|
|
687
653
|
*/
|
|
688
|
-
type CandleInterval =
|
|
654
|
+
type CandleInterval = "1m" | "3m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" | "8h" | "12h" | "1d" | "3d" | "1w" | "1M";
|
|
689
655
|
/**
|
|
690
656
|
* Candle data structure from WebSocket
|
|
691
657
|
*/
|
|
@@ -713,7 +679,7 @@ interface CandleSnapshotRequest {
|
|
|
713
679
|
endTime: number;
|
|
714
680
|
interval: CandleInterval;
|
|
715
681
|
};
|
|
716
|
-
type:
|
|
682
|
+
type: "candleSnapshot";
|
|
717
683
|
}
|
|
718
684
|
interface TokenSelectorConfig {
|
|
719
685
|
isLong: boolean;
|
|
@@ -769,26 +735,8 @@ declare const useUserSelection: () => UserSelectionState;
|
|
|
769
735
|
declare const useWebData: () => {
|
|
770
736
|
clearinghouseState: ClearinghouseState | null;
|
|
771
737
|
perpsAtOpenInterestCap: string[] | null;
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
* Each symbol maps to its market variants (keyed by prefix).
|
|
775
|
-
* For non-HIP3 assets, use "default" as the key.
|
|
776
|
-
*
|
|
777
|
-
* @example
|
|
778
|
-
* ```ts
|
|
779
|
-
* // HIP-3 asset with multiple markets
|
|
780
|
-
* marketDataBySymbol["TSLA"]["xyz"] // { asset, universe: { collateralToken: "USDC" } }
|
|
781
|
-
* marketDataBySymbol["TSLA"]["flx"] // { asset, universe: { collateralToken: "USDH" } }
|
|
782
|
-
*
|
|
783
|
-
* // Regular asset
|
|
784
|
-
* marketDataBySymbol["BTC"]["default"] // { asset, universe }
|
|
785
|
-
* ```
|
|
786
|
-
*/
|
|
787
|
-
marketDataBySymbol: MarketDataBySymbol;
|
|
788
|
-
/** Map of display name -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"]) */
|
|
789
|
-
hip3Assets: Map<string, string[]>;
|
|
790
|
-
/** Map of full market name -> prefix (e.g., "xyz:TSLA" -> "xyz") */
|
|
791
|
-
hip3MarketPrefixes: Map<string, string>;
|
|
738
|
+
marketDataBySymbol: Record<string, AssetMarketData>;
|
|
739
|
+
hip3Assets: Map<string, string>;
|
|
792
740
|
isConnected: boolean;
|
|
793
741
|
error: string | null;
|
|
794
742
|
};
|
|
@@ -822,7 +770,18 @@ interface TokenHistoricalPriceData {
|
|
|
822
770
|
oldestTime: number | null;
|
|
823
771
|
latestTime: number | null;
|
|
824
772
|
}
|
|
825
|
-
|
|
773
|
+
interface HistoricalPriceDataState {
|
|
774
|
+
historicalPriceData: Record<string, TokenHistoricalPriceData>;
|
|
775
|
+
loadingTokens: Set<string>;
|
|
776
|
+
addHistoricalPriceData: (symbol: string, interval: CandleInterval, candles: CandleData[], range: HistoricalRange) => void;
|
|
777
|
+
hasHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => boolean;
|
|
778
|
+
getHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => CandleData[];
|
|
779
|
+
setTokenLoading: (symbol: string, loading: boolean) => void;
|
|
780
|
+
isTokenLoading: (symbol: string) => boolean;
|
|
781
|
+
removeTokenPriceData: (symbol: string, interval: CandleInterval) => void;
|
|
782
|
+
clearData: () => void;
|
|
783
|
+
}
|
|
784
|
+
declare const useHistoricalPriceDataStore: zustand.UseBoundStore<zustand.StoreApi<HistoricalPriceDataState>>;
|
|
826
785
|
|
|
827
786
|
interface UseHistoricalPriceDataReturn {
|
|
828
787
|
fetchHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval, callback?: (data: Record<string, CandleData[]>) => void) => Promise<Record<string, CandleData[]>>;
|
|
@@ -922,47 +881,6 @@ interface CancelTwapResponseDto {
|
|
|
922
881
|
cancelledAt: string;
|
|
923
882
|
}
|
|
924
883
|
declare function cancelTwapOrder(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
925
|
-
interface SpotOrderRequestInput {
|
|
926
|
-
/** Asset to buy/sell (e.g., "USDH") */
|
|
927
|
-
asset: string;
|
|
928
|
-
/** Whether to buy (true) or sell (false) the asset */
|
|
929
|
-
isBuy: boolean;
|
|
930
|
-
/** Amount of asset to buy/sell (minimum: 11) */
|
|
931
|
-
amount: number;
|
|
932
|
-
}
|
|
933
|
-
/** Filled order status from Hyperliquid */
|
|
934
|
-
interface SpotOrderFilledStatus {
|
|
935
|
-
filled: {
|
|
936
|
-
totalSz: string;
|
|
937
|
-
avgPx: string;
|
|
938
|
-
oid: number;
|
|
939
|
-
cloid: string;
|
|
940
|
-
};
|
|
941
|
-
}
|
|
942
|
-
/** Hyperliquid order response data */
|
|
943
|
-
interface SpotOrderHyperliquidData {
|
|
944
|
-
statuses: SpotOrderFilledStatus[];
|
|
945
|
-
}
|
|
946
|
-
/** Hyperliquid result from spot order execution */
|
|
947
|
-
interface SpotOrderHyperliquidResult {
|
|
948
|
-
status: 'ok' | 'error';
|
|
949
|
-
response: {
|
|
950
|
-
type: 'order';
|
|
951
|
-
data: SpotOrderHyperliquidData;
|
|
952
|
-
};
|
|
953
|
-
}
|
|
954
|
-
interface SpotOrderResponseDto {
|
|
955
|
-
orderId: string;
|
|
956
|
-
status: 'EXECUTED' | 'FAILED' | 'PENDING';
|
|
957
|
-
asset: string;
|
|
958
|
-
createdAt: string;
|
|
959
|
-
hyperliquidResult?: SpotOrderHyperliquidResult;
|
|
960
|
-
}
|
|
961
|
-
/**
|
|
962
|
-
* Execute a spot order (swap) using Pear Hyperliquid service
|
|
963
|
-
* POST /orders/spot
|
|
964
|
-
*/
|
|
965
|
-
declare function executeSpotOrder(baseUrl: string, payload: SpotOrderRequestInput): Promise<ApiResponse<SpotOrderResponseDto>>;
|
|
966
884
|
|
|
967
885
|
type ExecutionType = "MARKET" | "LIMIT" | "TWAP" | "LADDER" | "LIMIT_BTCDOM";
|
|
968
886
|
type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
|
|
@@ -1020,7 +938,7 @@ interface CreatePositionResponseDto {
|
|
|
1020
938
|
* Authorization is derived from headers (Axios defaults or browser localStorage fallback)
|
|
1021
939
|
* @throws MinimumPositionSizeError if any asset has less than $11 USD value
|
|
1022
940
|
*/
|
|
1023
|
-
declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput,
|
|
941
|
+
declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput, displayToFull: Map<string, string>): Promise<ApiResponse<CreatePositionResponseDto>>;
|
|
1024
942
|
interface UpdateRiskParametersRequestInput {
|
|
1025
943
|
stopLoss?: TpSlThresholdInput | null;
|
|
1026
944
|
takeProfit?: TpSlThresholdInput | null;
|
|
@@ -1087,7 +1005,7 @@ interface AdjustAdvanceResponseDto {
|
|
|
1087
1005
|
status: string;
|
|
1088
1006
|
executedAt: string;
|
|
1089
1007
|
}
|
|
1090
|
-
declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[],
|
|
1008
|
+
declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[], displayToFull: Map<string, string>): Promise<ApiResponse<AdjustAdvanceResponseDto>>;
|
|
1091
1009
|
declare function cancelTwap(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
1092
1010
|
|
|
1093
1011
|
declare function usePosition(): {
|
|
@@ -1109,18 +1027,6 @@ declare function useOrders(): {
|
|
|
1109
1027
|
readonly isLoading: boolean;
|
|
1110
1028
|
};
|
|
1111
1029
|
|
|
1112
|
-
interface UseSpotOrderResult {
|
|
1113
|
-
executeSpotOrder: (payload: SpotOrderRequestInput) => Promise<ApiResponse<SpotOrderResponseDto>>;
|
|
1114
|
-
isLoading: boolean;
|
|
1115
|
-
error: ApiErrorResponse | null;
|
|
1116
|
-
resetError: () => void;
|
|
1117
|
-
}
|
|
1118
|
-
/**
|
|
1119
|
-
* Hook for executing spot orders (swaps) on Hyperliquid
|
|
1120
|
-
* Use this to swap between USDC and USDH or other spot assets
|
|
1121
|
-
*/
|
|
1122
|
-
declare function useSpotOrder(): UseSpotOrderResult;
|
|
1123
|
-
|
|
1124
1030
|
declare function useTwap(): {
|
|
1125
1031
|
readonly orders: TwapMonitoringDto[];
|
|
1126
1032
|
readonly cancelTwap: (orderId: string) => Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
@@ -1142,16 +1048,14 @@ interface UseNotificationsResult {
|
|
|
1142
1048
|
*/
|
|
1143
1049
|
declare function useNotifications(): UseNotificationsResult;
|
|
1144
1050
|
|
|
1145
|
-
type CollateralFilter = 'USDC' | 'USDH' | 'ALL';
|
|
1146
1051
|
declare const useMarketDataPayload: () => ActiveAssetsResponse | null;
|
|
1147
1052
|
declare const useMarketDataAllPayload: () => ActiveAssetsAllResponse | null;
|
|
1148
|
-
declare const
|
|
1149
|
-
declare const
|
|
1150
|
-
declare const
|
|
1151
|
-
declare const
|
|
1152
|
-
declare const
|
|
1153
|
-
declare const
|
|
1154
|
-
declare const useAllBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
|
|
1053
|
+
declare const useActiveBaskets: () => ActiveAssetGroupItem[];
|
|
1054
|
+
declare const useTopGainers: (limit?: number) => ActiveAssetGroupItem[];
|
|
1055
|
+
declare const useTopLosers: (limit?: number) => ActiveAssetGroupItem[];
|
|
1056
|
+
declare const useHighlightedBaskets: () => ActiveAssetGroupItem[];
|
|
1057
|
+
declare const useWatchlistBaskets: () => ActiveAssetGroupItem[];
|
|
1058
|
+
declare const useAllBaskets: () => ActiveAssetGroupItem[];
|
|
1155
1059
|
declare const useFindBasket: (longs: string[], shorts: string[]) => ActiveAssetGroupItem | undefined;
|
|
1156
1060
|
|
|
1157
1061
|
declare function useWatchlist(): {
|
|
@@ -1214,14 +1118,16 @@ declare function usePortfolio(): UsePortfolioResult;
|
|
|
1214
1118
|
|
|
1215
1119
|
declare function useAuth(): {
|
|
1216
1120
|
readonly isReady: boolean;
|
|
1217
|
-
readonly isAuthenticated:
|
|
1218
|
-
readonly accessToken:
|
|
1219
|
-
readonly refreshToken:
|
|
1121
|
+
readonly isAuthenticated: boolean;
|
|
1122
|
+
readonly accessToken: string | null;
|
|
1123
|
+
readonly refreshToken: string | null;
|
|
1220
1124
|
readonly getEip712: (address: string) => Promise<GetEIP712MessageResponse>;
|
|
1221
1125
|
readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
|
|
1222
1126
|
readonly loginWithPrivyToken: (address: string, appId: string, privyAccessToken: string) => Promise<void>;
|
|
1223
1127
|
readonly refreshTokens: () => Promise<RefreshTokenResponse>;
|
|
1224
1128
|
readonly logout: () => Promise<void>;
|
|
1129
|
+
readonly setAddress: (address: string | null) => void;
|
|
1130
|
+
readonly address: string | null;
|
|
1225
1131
|
};
|
|
1226
1132
|
|
|
1227
1133
|
interface UseHyperliquidWebSocketProps {
|
|
@@ -1258,7 +1164,7 @@ declare function markNotificationReadById(baseUrl: string, id: string): Promise<
|
|
|
1258
1164
|
updated: number;
|
|
1259
1165
|
}>>;
|
|
1260
1166
|
|
|
1261
|
-
declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[],
|
|
1167
|
+
declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[], displayToFull: Map<string, string>): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
|
|
1262
1168
|
|
|
1263
1169
|
/**
|
|
1264
1170
|
* Account summary calculation utility class
|
|
@@ -1297,28 +1203,24 @@ declare class ConflictDetector {
|
|
|
1297
1203
|
declare class TokenMetadataExtractor {
|
|
1298
1204
|
/**
|
|
1299
1205
|
* Extracts comprehensive token metadata
|
|
1300
|
-
* @param symbol - Token symbol
|
|
1206
|
+
* @param symbol - Token symbol
|
|
1301
1207
|
* @param perpMetaAssets - Aggregated universe assets (flattened across dexes)
|
|
1302
1208
|
* @param finalAssetContexts - Aggregated asset contexts (flattened across dexes)
|
|
1303
1209
|
* @param allMids - AllMids data containing current prices
|
|
1304
1210
|
* @param activeAssetData - Optional active asset data containing leverage information
|
|
1305
|
-
* @param marketPrefix - Optional market prefix (e.g., "xyz", "flx") for HIP3 multi-market assets
|
|
1306
1211
|
* @returns TokenMetadata or null if token not found
|
|
1307
1212
|
*/
|
|
1308
|
-
static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null
|
|
1213
|
+
static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): TokenMetadata | null;
|
|
1309
1214
|
/**
|
|
1310
1215
|
* Extracts metadata for multiple tokens
|
|
1311
|
-
* @param
|
|
1216
|
+
* @param symbols - Array of token symbols
|
|
1312
1217
|
* @param perpMetaAssets - Aggregated universe assets
|
|
1313
1218
|
* @param finalAssetContexts - Aggregated asset contexts
|
|
1314
1219
|
* @param allMids - AllMids data
|
|
1315
1220
|
* @param activeAssetData - Optional active asset data containing leverage information
|
|
1316
|
-
* @returns Record of
|
|
1221
|
+
* @returns Record of symbol to TokenMetadata
|
|
1317
1222
|
*/
|
|
1318
|
-
static extractMultipleTokensMetadata(
|
|
1319
|
-
symbol: string;
|
|
1320
|
-
marketPrefix?: string | null;
|
|
1321
|
-
}>, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): Record<string, TokenMetadata | null>;
|
|
1223
|
+
static extractMultipleTokensMetadata(symbols: string[], perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): Record<string, TokenMetadata | null>;
|
|
1322
1224
|
/**
|
|
1323
1225
|
* Checks if token data is available in aggregated universe assets
|
|
1324
1226
|
* @param symbol - Token symbol
|
|
@@ -1402,48 +1304,14 @@ declare function validatePositionSize(usdValue: number, longAssets?: PairAssetIn
|
|
|
1402
1304
|
minimumRequired?: number;
|
|
1403
1305
|
};
|
|
1404
1306
|
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
* @param displaySymbol e.g., "TSLA"
|
|
1414
|
-
* @param hip3Assets map of display -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"])
|
|
1415
|
-
*/
|
|
1416
|
-
declare function toBackendSymbol(displaySymbol: string, hip3Assets: Map<string, string[]>): string;
|
|
1417
|
-
/**
|
|
1418
|
-
* Convert a display symbol to backend form for a specific market prefix.
|
|
1419
|
-
* This is useful when an asset is available on multiple markets (e.g., xyz:TSLA and flx:TSLA).
|
|
1420
|
-
* @param displaySymbol e.g., "TSLA"
|
|
1421
|
-
* @param marketPrefix e.g., "xyz" or "flx"
|
|
1422
|
-
* @param hip3Assets map of display -> all full market names
|
|
1423
|
-
* @returns Full market name if found, null if prefix not specified for multi-market asset, otherwise displaySymbol with prefix
|
|
1424
|
-
*/
|
|
1425
|
-
declare function toBackendSymbolWithMarket(displaySymbol: string, marketPrefix: string | undefined, hip3Assets: Map<string, string[]>): string | null;
|
|
1426
|
-
/**
|
|
1427
|
-
* Get all available markets for a display symbol.
|
|
1428
|
-
* @param displaySymbol e.g., "TSLA"
|
|
1429
|
-
* @param hip3Assets map of display -> all full market names
|
|
1430
|
-
* @returns Array of full market names, e.g., ["xyz:TSLA", "flx:TSLA"]
|
|
1431
|
-
*/
|
|
1432
|
-
declare function getAvailableMarkets(displaySymbol: string, hip3Assets: Map<string, string[]>): string[];
|
|
1433
|
-
/**
|
|
1434
|
-
* Extract the market prefix from a full market name.
|
|
1435
|
-
* @param fullSymbol e.g., "xyz:TSLA"
|
|
1436
|
-
* @returns The prefix (e.g., "xyz") or undefined if no prefix
|
|
1437
|
-
*/
|
|
1438
|
-
declare function getMarketPrefix(fullSymbol: string): string | undefined;
|
|
1439
|
-
/**
|
|
1440
|
-
* Check if a symbol is a HIP-3 market (has a prefix).
|
|
1441
|
-
* @param symbol e.g., "xyz:TSLA" or "TSLA"
|
|
1442
|
-
* @returns true if the symbol has a market prefix
|
|
1443
|
-
*/
|
|
1444
|
-
declare function isHip3Market(symbol: string): boolean;
|
|
1445
|
-
|
|
1446
|
-
declare const useMarketData: any;
|
|
1307
|
+
interface MarketDataState {
|
|
1308
|
+
marketData: ActiveAssetsResponse | null;
|
|
1309
|
+
marketDataAll: ActiveAssetsAllResponse | null;
|
|
1310
|
+
setMarketData: (value: ActiveAssetsResponse | null) => void;
|
|
1311
|
+
setMarketDataAll: (value: ActiveAssetsAllResponse | null) => void;
|
|
1312
|
+
clean: () => void;
|
|
1313
|
+
}
|
|
1314
|
+
declare const useMarketData: zustand.UseBoundStore<zustand.StoreApi<MarketDataState>>;
|
|
1447
1315
|
|
|
1448
|
-
export { AccountSummaryCalculator, ConflictDetector, MINIMUM_ASSET_USD_VALUE, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition,
|
|
1449
|
-
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,
|
|
1316
|
+
export { AccountSummaryCalculator, ConflictDetector, MINIMUM_ASSET_USD_VALUE, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, getPortfolio, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllBaskets, useAuth, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMarketData, useMarketDataAllPayload, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePortfolio, usePosition, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWatchlist, useWatchlistBaskets, useWebData, validateMinimumAssetSize, validatePositionSize };
|
|
1317
|
+
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, 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, TwapSliceFillResponseItem, UniverseAsset, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseNotificationsResult, UsePerformanceOverlaysReturn, UsePortfolioResult, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WatchlistItemDto, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
|