@pear-protocol/hyperliquid-sdk 0.0.73-beta.2 → 0.0.73-beta.4

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.
@@ -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, displayToFull: Map<string, string>) => Promise<ApiResponse<CandleData[]>>;
5
+ export declare const fetchHistoricalCandles: (coin: string, startTime: number, endTime: number, interval: CandleInterval, hip3Assets: Map<string, string[]>) => Promise<ApiResponse<CandleData[]>>;
6
6
  /**
7
7
  * Retrieve recent user fills from HyperLiquid and map to ExternalFillDto[]
8
8
  */
@@ -22,3 +22,44 @@ 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>>;
@@ -57,7 +57,7 @@ export interface CreatePositionResponseDto {
57
57
  * @throws MinimumPositionSizeError if any asset has less than $11 USD value
58
58
  * @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets (15)
59
59
  */
60
- export declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput, displayToFull: Map<string, string>): Promise<ApiResponse<CreatePositionResponseDto>>;
60
+ export declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput, hip3Assets: Map<string, string[]>): Promise<ApiResponse<CreatePositionResponseDto>>;
61
61
  export interface UpdateRiskParametersRequestInput {
62
62
  stopLoss?: TpSlThresholdInput | null;
63
63
  takeProfit?: TpSlThresholdInput | null;
@@ -124,7 +124,7 @@ export interface AdjustAdvanceResponseDto {
124
124
  status: string;
125
125
  executedAt: string;
126
126
  }
127
- export declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[], displayToFull: Map<string, string>): Promise<ApiResponse<AdjustAdvanceResponseDto>>;
127
+ export declare function adjustAdvancePosition(baseUrl: string, positionId: string, payload: AdjustAdvanceItemInput[], hip3Assets: Map<string, string[]>): Promise<ApiResponse<AdjustAdvanceResponseDto>>;
128
128
  export declare function cancelTwap(baseUrl: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
129
129
  export interface UpdateLeverageRequestInput {
130
130
  leverage: number;
@@ -1,2 +1,2 @@
1
1
  import type { ApiResponse, ToggleWatchlistResponseDto, WatchlistAssetDto } from '../types';
2
- export declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[], displayToFull: Map<string, string>): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
2
+ export declare function toggleWatchlist(baseUrl: string, longAssets: WatchlistAssetDto[], shortAssets: WatchlistAssetDto[], hip3Assets: Map<string, string[]>): Promise<ApiResponse<ToggleWatchlistResponseDto>>;
@@ -10,9 +10,11 @@ export * from './useAgentWallet';
10
10
  export * from './useAutoSyncFills';
11
11
  export * from './usePosition';
12
12
  export * from './useOrders';
13
+ export * from './useSpotOrder';
13
14
  export * from './useTwap';
14
15
  export * from './useNotifications';
15
16
  export * from './useMarketData';
16
17
  export * from './useWatchlist';
17
18
  export * from './usePortfolio';
18
19
  export * from './useAuth';
20
+ export * from './useAllUserBalances';
@@ -0,0 +1,9 @@
1
+ interface AllUserBalances {
2
+ spotUsdcBalance: number | undefined;
3
+ availableToTradeUsdc: number | undefined;
4
+ spotUsdhBalance: number | undefined;
5
+ availableToTradeUsdh: number | undefined;
6
+ isLoading: boolean;
7
+ }
8
+ export declare const useAllUserBalances: () => AllUserBalances;
9
+ export {};
@@ -1,10 +1,12 @@
1
- import type { ActiveAssetGroupItem, ActiveAssetsResponse, ActiveAssetsAllResponse } from '../types';
1
+ import type { ActiveAssetGroupItem, ActiveAssetsResponse, ActiveAssetsAllResponse, UniverseAsset } from '../types';
2
+ export type CollateralFilter = 'USDC' | 'USDH' | 'ALL';
2
3
  export declare const useMarketDataPayload: () => ActiveAssetsResponse | null;
3
4
  export declare const useMarketDataAllPayload: () => ActiveAssetsAllResponse | null;
4
- export declare const useActiveBaskets: () => ActiveAssetGroupItem[];
5
- export declare const useTopGainers: (limit?: number) => ActiveAssetGroupItem[];
6
- export declare const useTopLosers: (limit?: number) => ActiveAssetGroupItem[];
7
- export declare const useHighlightedBaskets: () => ActiveAssetGroupItem[];
8
- export declare const useWatchlistBaskets: () => ActiveAssetGroupItem[];
9
- export declare const useAllBaskets: () => ActiveAssetGroupItem[];
5
+ export declare const usePerpMetaAssets: () => UniverseAsset[] | null;
6
+ export declare const useActiveBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
7
+ export declare const useTopGainers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
8
+ export declare const useTopLosers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
9
+ export declare const useHighlightedBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
10
+ export declare const useWatchlistBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
11
+ export declare const useAllBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
10
12
  export declare const useFindBasket: (longs: string[], shorts: string[]) => ActiveAssetGroupItem | undefined;
@@ -0,0 +1,13 @@
1
+ import type { ApiResponse, ApiErrorResponse } from '../types';
2
+ import { type SpotOrderRequestInput, type SpotOrderResponseDto } from '../clients/orders';
3
+ export interface UseSpotOrderResult {
4
+ executeSpotOrder: (payload: SpotOrderRequestInput) => Promise<ApiResponse<SpotOrderResponseDto>>;
5
+ isLoading: boolean;
6
+ error: ApiErrorResponse | null;
7
+ resetError: () => void;
8
+ }
9
+ /**
10
+ * Hook for executing spot orders (swaps) on Hyperliquid
11
+ * Use this to swap between USDC and USDH or other spot assets
12
+ */
13
+ export declare function useSpotOrder(): UseSpotOrderResult;
@@ -4,9 +4,6 @@ export declare const useTradeHistories: () => {
4
4
  data: TradeHistoryDataDto[] | null;
5
5
  isLoading: boolean;
6
6
  };
7
- /**
8
- * Hook to access open orders with loading state
9
- */
10
7
  export declare const useOpenOrders: () => {
11
8
  data: OpenLimitOrderDto[] | null;
12
9
  isLoading: boolean;
@@ -1,12 +1,30 @@
1
- import type { AssetMarketData, ClearinghouseState } from '../types';
1
+ import type { ClearinghouseState, MarketDataBySymbol } 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
- marketDataBySymbol: Record<string, AssetMarketData>;
9
- hip3Assets: Map<string, string>;
8
+ /**
9
+ * Market data keyed by symbol, with nested market variants.
10
+ * Each symbol maps to its market variants (keyed by prefix).
11
+ * For non-HIP3 assets, use "default" as the key.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * // HIP-3 asset with multiple markets
16
+ * marketDataBySymbol["TSLA"]["xyz"] // { asset, universe: { collateralToken: "USDC" } }
17
+ * marketDataBySymbol["TSLA"]["flx"] // { asset, universe: { collateralToken: "USDH" } }
18
+ *
19
+ * // Regular asset
20
+ * marketDataBySymbol["BTC"]["default"] // { asset, universe }
21
+ * ```
22
+ */
23
+ marketDataBySymbol: MarketDataBySymbol;
24
+ /** Map of display name -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"]) */
25
+ hip3Assets: Map<string, string[]>;
26
+ /** Map of full market name -> prefix (e.g., "xyz:TSLA" -> "xyz") */
27
+ hip3MarketPrefixes: Map<string, string>;
10
28
  isConnected: boolean;
11
29
  error: string | null;
12
30
  };