@pear-protocol/hyperliquid-sdk 0.0.66-usdh-1 → 0.0.67

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.
@@ -1,4 +1,4 @@
1
- import React, { ReactNode } from 'react';
1
+ import React, { ReactNode } from "react";
2
2
  export interface PearHyperliquidContextType {
3
3
  clientId: string;
4
4
  apiBaseUrl: string;
@@ -1,4 +1,4 @@
1
- import type { ActiveAssetData, TokenSelection, TokenMetadata, WsAllMidsData, ActiveAssetsResponse, UniverseAsset, WebData3AssetCtx } from '../types';
1
+ import type { ActiveAssetData, TokenSelection, TokenMetadata, WsAllMidsData, ActiveAssetsResponse, UniverseAsset, WebData3AssetCtx } from "../types";
2
2
  export interface TokenSelectionMetadataState {
3
3
  isPriceDataReady: boolean;
4
4
  isLoading: boolean;
package/dist/types.d.ts CHANGED
@@ -20,7 +20,7 @@ export interface ExternalFillDto {
20
20
  coin: string;
21
21
  px: string;
22
22
  sz: string;
23
- side: 'B' | 'A';
23
+ side: "B" | "A";
24
24
  time: number;
25
25
  dir: string;
26
26
  fee: string;
@@ -52,7 +52,7 @@ export interface TwapSliceFillResponseItem {
52
52
  /**
53
53
  * WebSocket connection states
54
54
  */
55
- export type WebSocketConnectionState = 'connecting' | 'connected' | 'disconnected' | 'error';
55
+ export type WebSocketConnectionState = "connecting" | "connected" | "disconnected" | "error";
56
56
  export declare enum ReadyState {
57
57
  CONNECTING = 0,
58
58
  OPEN = 1,
@@ -62,12 +62,12 @@ export declare enum ReadyState {
62
62
  /**
63
63
  * WebSocket channels
64
64
  */
65
- export type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'twap-details' | 'notifications' | 'market-data' | 'market-data-all' | 'webData3' | 'allMids' | 'activeAssetData';
65
+ export type WebSocketChannel = "trade-histories" | "open-positions" | "open-orders" | "account-summary" | "twap-details" | "notifications" | "market-data" | "market-data-all" | "webData3" | "allMids" | "activeAssetData";
66
66
  /**
67
67
  * WebSocket subscription message
68
68
  */
69
69
  export interface WebSocketSubscribeMessage {
70
- action?: 'subscribe' | 'unsubscribe';
70
+ action?: "subscribe" | "unsubscribe";
71
71
  address: string;
72
72
  }
73
73
  /**
@@ -97,7 +97,7 @@ export interface WatchlistItemDto {
97
97
  export interface ToggleWatchlistResponseDto {
98
98
  items: WatchlistItemDto[];
99
99
  }
100
- export 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';
100
+ export 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";
101
101
  export interface NotificationDto {
102
102
  id: string;
103
103
  address: string;
@@ -114,7 +114,7 @@ export interface ChunkFillDto {
114
114
  size: number;
115
115
  executedAt: string;
116
116
  }
117
- export type TwapChunkStatus = 'PENDING' | 'SCHEDULED' | 'EXECUTING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';
117
+ export type TwapChunkStatus = "PENDING" | "SCHEDULED" | "EXECUTING" | "COMPLETED" | "FAILED" | "CANCELLED";
118
118
  export interface TwapChunkStatusDto {
119
119
  chunkId: string;
120
120
  chunkIndex: number;
@@ -125,7 +125,7 @@ export interface TwapChunkStatusDto {
125
125
  fills: ChunkFillDto[];
126
126
  errorMessage?: string;
127
127
  }
128
- export type TwapOrderOverallStatus = 'OPEN' | 'EXECUTING' | 'COMPLETED' | 'PARTIALLY_COMPLETED' | 'FAILED' | 'CANCELLED';
128
+ export type TwapOrderOverallStatus = "OPEN" | "EXECUTING" | "COMPLETED" | "PARTIALLY_COMPLETED" | "FAILED" | "CANCELLED";
129
129
  export interface TwapMonitoringDto {
130
130
  orderId: string;
131
131
  positionId?: string;
@@ -162,8 +162,6 @@ export interface TradeHistoryAssetDataDto {
162
162
  externalFeePaid: number;
163
163
  builderFeePaid: number;
164
164
  realizedPnl: number;
165
- marketPrefix?: string | null;
166
- collateralToken?: CollateralToken;
167
165
  }
168
166
  /**
169
167
  * Trade history data structure
@@ -212,11 +210,9 @@ export interface PositionAssetDetailDto {
212
210
  liquidationPrice: number;
213
211
  initialWeight: number;
214
212
  fundingPaid?: number;
215
- marketPrefix?: string | null;
216
- collateralToken?: CollateralToken;
217
213
  }
218
214
  export interface TpSlThreshold {
219
- type: 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
215
+ type: "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
220
216
  value: number;
221
217
  }
222
218
  /**
@@ -247,22 +243,20 @@ export interface OpenPositionDto {
247
243
  export interface OrderAssetDto {
248
244
  asset: string;
249
245
  weight: number;
250
- marketPrefix?: string | null;
251
- collateralToken?: CollateralToken;
252
246
  }
253
247
  /**
254
248
  * Order status
255
249
  */
256
- export type OrderStatus = 'OPEN' | 'PARTIALLY_FILLED' | 'PROCESSING';
250
+ export type OrderStatus = "OPEN" | "PARTIALLY_FILLED" | "PROCESSING";
257
251
  /**
258
252
  * Order type
259
253
  */
260
- export type OrderType = 'TP' | 'SL' | 'LIMIT' | 'MARKET' | 'LIMIT_BTCDOM' | 'TWAP';
254
+ export type OrderType = "TP" | "SL" | "LIMIT" | "MARKET" | "LIMIT_BTCDOM" | "TWAP";
261
255
  /**
262
256
  * TP/SL trigger type
263
257
  */
264
- export type TpSlTriggerType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
265
- export type OrderDirection = 'MORE_THAN' | 'LESS_THAN' | null;
258
+ export type TpSlTriggerType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
259
+ export type OrderDirection = "MORE_THAN" | "LESS_THAN" | null;
266
260
  /**
267
261
  * Open limit order data structure
268
262
  */
@@ -376,7 +370,7 @@ export interface PrivyAuthDetails {
376
370
  accessToken: string;
377
371
  }
378
372
  export interface AuthenticateRequest {
379
- method: 'eip712' | 'api_key' | 'privy_access_token';
373
+ method: "eip712" | "api_key" | "privy_access_token";
380
374
  address: string;
381
375
  clientId: string;
382
376
  details: {
@@ -409,7 +403,7 @@ export interface LogoutRequest {
409
403
  export interface LogoutResponse {
410
404
  message: string;
411
405
  }
412
- export type AgentWalletStatus = 'ACTIVE' | 'EXPIRED' | 'NOT_FOUND';
406
+ export type AgentWalletStatus = "ACTIVE" | "EXPIRED" | "NOT_FOUND";
413
407
  export interface GetAgentWalletResponseDto {
414
408
  agentWalletAddress?: string;
415
409
  agentName: string;
@@ -427,14 +421,14 @@ export interface ExtraAgent {
427
421
  export interface AgentWalletState {
428
422
  address: string | null;
429
423
  name: string | null;
430
- status: AgentWalletStatus | 'PENDING' | null;
424
+ status: AgentWalletStatus | "PENDING" | null;
431
425
  isActive: boolean;
432
426
  }
433
427
  /**
434
428
  * WebSocket message from HyperLiquid native API
435
429
  */
436
430
  export interface WebSocketMessage {
437
- method: 'subscribe' | 'unsubscribe';
431
+ method: "subscribe" | "unsubscribe";
438
432
  subscription: {
439
433
  type: string;
440
434
  dex?: string;
@@ -447,16 +441,12 @@ export interface WebSocketMessage {
447
441
  /**
448
442
  * WebSocket response from HyperLiquid native API
449
443
  */
450
- export type HLChannel = 'webData3' | 'allMids' | 'activeAssetData' | 'candle' | 'spotState' | 'allDexsClearinghouseState' | 'allDexsAssetCtxs';
444
+ export type HLChannel = "webData3" | "allMids" | "activeAssetData" | "candle" | "allDexsClearinghouseState" | "allDexsAssetCtxs";
451
445
  export interface HLChannelDataMap {
452
446
  webData3: WebData3Response;
453
447
  allMids: WsAllMidsData;
454
448
  activeAssetData: ActiveAssetData;
455
449
  candle: CandleData;
456
- spotState: {
457
- user: string;
458
- spotState: SpotState;
459
- };
460
450
  allDexsClearinghouseState: AllDexsClearinghouseStateData;
461
451
  allDexsAssetCtxs: AllDexsAssetCtxsData;
462
452
  }
@@ -521,12 +511,6 @@ export interface AssetCtx {
521
511
  impactPxs?: string[];
522
512
  oraclePx: string;
523
513
  }
524
- /**
525
- * Collateral token type
526
- * 0 = USDC
527
- * 360 = USDH
528
- */
529
- export type CollateralToken = 'USDC' | 'USDH';
530
514
  /**
531
515
  * Universe asset metadata
532
516
  */
@@ -536,8 +520,6 @@ export interface UniverseAsset {
536
520
  maxLeverage: number;
537
521
  onlyIsolated?: boolean;
538
522
  isDelisted?: boolean;
539
- marketPrefix?: string;
540
- collateralToken?: CollateralToken;
541
523
  }
542
524
  export interface PerpMetaAsset extends UniverseAsset {
543
525
  marginTableId: number;
@@ -626,8 +608,7 @@ export interface RawAssetDto {
626
608
  size: number;
627
609
  side: string;
628
610
  fundingPaid?: number;
629
- marketPrefix?: string | null;
630
- collateralToken?: CollateralToken;
611
+ leverage: number;
631
612
  }
632
613
  /**
633
614
  * Raw position data from open-positions channel
@@ -675,7 +656,6 @@ export interface TokenMetadata {
675
656
  leverage?: LeverageInfo;
676
657
  maxTradeSzs?: [string, string];
677
658
  availableToTrade?: [string, string];
678
- collateralToken?: CollateralToken;
679
659
  }
680
660
  /**
681
661
  * Enhanced token selection with weight and metadata for basket trading
@@ -689,37 +669,16 @@ export interface TokenSelection {
689
669
  */
690
670
  export interface TokenConflict {
691
671
  symbol: string;
692
- conflictType: 'long' | 'short';
672
+ conflictType: "long" | "short";
693
673
  conflictMessage: string;
694
674
  }
695
675
  export interface AssetMarketData {
696
676
  asset: WebData3AssetCtx | AssetCtx;
697
677
  universe: UniverseAsset;
698
678
  }
699
- /**
700
- * Nested market data structure for multi-market assets.
701
- * Each symbol maps to its market variants (keyed by prefix).
702
- * For non-HIP3 assets, use "default" as the key.
703
- *
704
- * @example
705
- * ```ts
706
- * {
707
- * "TSLA": {
708
- * "xyz": { asset: {...}, universe: { collateralToken: "USDC", ... } },
709
- * "flx": { asset: {...}, universe: { collateralToken: "USDH", ... } }
710
- * },
711
- * "BTC": {
712
- * "default": { asset: {...}, universe: {...} }
713
- * }
714
- * }
715
- * ```
716
- */
717
- export type MarketDataBySymbol = Record<string, Record<string, AssetMarketData>>;
718
679
  export interface PairAssetDto {
719
680
  asset: string;
720
681
  weight: number;
721
- collateralToken: CollateralToken;
722
- marketPrefix: string | null;
723
682
  }
724
683
  export interface ActiveAssetGroupItem {
725
684
  longAssets: PairAssetDto[];
@@ -733,7 +692,6 @@ export interface ActiveAssetGroupItem {
733
692
  weightedRatio?: string;
734
693
  weightedPrevRatio?: string;
735
694
  weightedChange24h?: string;
736
- collateralType: 'USDC' | 'USDH' | 'MIXED';
737
695
  }
738
696
  export interface ActiveAssetsResponse {
739
697
  active: ActiveAssetGroupItem[];
@@ -751,7 +709,7 @@ export interface ActiveAssetsAllResponse {
751
709
  /**
752
710
  * Candle interval options
753
711
  */
754
- export type CandleInterval = '1m' | '3m' | '5m' | '15m' | '30m' | '1h' | '2h' | '4h' | '8h' | '12h' | '1d' | '3d' | '1w' | '1M';
712
+ export type CandleInterval = "1m" | "3m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" | "8h" | "12h" | "1d" | "3d" | "1w" | "1M";
755
713
  /**
756
714
  * Candle data structure from WebSocket
757
715
  */
@@ -779,20 +737,9 @@ export interface CandleSnapshotRequest {
779
737
  endTime: number;
780
738
  interval: CandleInterval;
781
739
  };
782
- type: 'candleSnapshot';
740
+ type: "candleSnapshot";
783
741
  }
784
742
  export interface TokenSelectorConfig {
785
743
  isLong: boolean;
786
744
  index: number;
787
745
  }
788
- export interface SpotBalance {
789
- coin: string;
790
- token: number;
791
- total: string;
792
- hold: string;
793
- entryNtl: string;
794
- }
795
- export interface SpotState {
796
- user: string;
797
- balances: SpotBalance[];
798
- }
@@ -5,36 +5,7 @@ export declare function toDisplaySymbol(symbol: string): string;
5
5
  /**
6
6
  * Convert a display symbol back to backend form using a provided map.
7
7
  * If mapping is missing, returns the original symbol.
8
- * For multi-market assets, returns the first available market.
9
- * @param displaySymbol e.g., "TSLA"
10
- * @param hip3Assets map of display -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"])
8
+ * @param displaySymbol e.g., "XYZ100"
9
+ * @param displayToFull map of display -> full (e.g., "XYZ100" -> "xyz:XYZ100")
11
10
  */
12
- export declare function toBackendSymbol(displaySymbol: string, hip3Assets: Map<string, string[]>): string;
13
- /**
14
- * Convert a display symbol to backend form for a specific market prefix.
15
- * This is useful when an asset is available on multiple markets (e.g., xyz:TSLA and flx:TSLA).
16
- * @param displaySymbol e.g., "TSLA"
17
- * @param marketPrefix e.g., "xyz" or "flx"
18
- * @param hip3Assets map of display -> all full market names
19
- * @returns Full market name if found, null if prefix not specified for multi-market asset, otherwise displaySymbol with prefix
20
- */
21
- export declare function toBackendSymbolWithMarket(displaySymbol: string, marketPrefix: string | undefined, hip3Assets: Map<string, string[]>): string | null;
22
- /**
23
- * Get all available markets for a display symbol.
24
- * @param displaySymbol e.g., "TSLA"
25
- * @param hip3Assets map of display -> all full market names
26
- * @returns Array of full market names, e.g., ["xyz:TSLA", "flx:TSLA"]
27
- */
28
- export declare function getAvailableMarkets(displaySymbol: string, hip3Assets: Map<string, string[]>): string[];
29
- /**
30
- * Extract the market prefix from a full market name.
31
- * @param fullSymbol e.g., "xyz:TSLA"
32
- * @returns The prefix (e.g., "xyz") or undefined if no prefix
33
- */
34
- export declare function getMarketPrefix(fullSymbol: string): string | undefined;
35
- /**
36
- * Check if a symbol is a HIP-3 market (has a prefix).
37
- * @param symbol e.g., "xyz:TSLA" or "TSLA"
38
- * @returns true if the symbol has a market prefix
39
- */
40
- export declare function isHip3Market(symbol: string): boolean;
11
+ export declare function toBackendSymbol(displaySymbol: string, displayToFull: Map<string, string>): string;
@@ -5,28 +5,24 @@ import type { WsAllMidsData, TokenMetadata, ActiveAssetData, UniverseAsset, WebD
5
5
  export declare class TokenMetadataExtractor {
6
6
  /**
7
7
  * Extracts comprehensive token metadata
8
- * @param symbol - Token symbol (base symbol without prefix, e.g., "TSLA")
8
+ * @param symbol - Token symbol
9
9
  * @param perpMetaAssets - Aggregated universe assets (flattened across dexes)
10
10
  * @param finalAssetContexts - Aggregated asset contexts (flattened across dexes)
11
11
  * @param allMids - AllMids data containing current prices
12
12
  * @param activeAssetData - Optional active asset data containing leverage information
13
- * @param marketPrefix - Optional market prefix (e.g., "xyz", "flx") for HIP3 multi-market assets
14
13
  * @returns TokenMetadata or null if token not found
15
14
  */
16
- static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null, marketPrefix?: string | null): TokenMetadata | null;
15
+ static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): TokenMetadata | null;
17
16
  /**
18
17
  * Extracts metadata for multiple tokens
19
- * @param tokens - Array of token objects with symbol and optional marketPrefix
18
+ * @param symbols - Array of token symbols
20
19
  * @param perpMetaAssets - Aggregated universe assets
21
20
  * @param finalAssetContexts - Aggregated asset contexts
22
21
  * @param allMids - AllMids data
23
22
  * @param activeAssetData - Optional active asset data containing leverage information
24
- * @returns Record of unique key to TokenMetadata. Key is "{prefix}:{symbol}" for HIP3 assets, or just "{symbol}" otherwise
23
+ * @returns Record of symbol to TokenMetadata
25
24
  */
26
- static extractMultipleTokensMetadata(tokens: Array<{
27
- symbol: string;
28
- marketPrefix?: string | null;
29
- }>, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): Record<string, TokenMetadata | null>;
25
+ static extractMultipleTokensMetadata(symbols: string[], perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): Record<string, TokenMetadata | null>;
30
26
  /**
31
27
  * Checks if token data is available in aggregated universe assets
32
28
  * @param symbol - Token symbol
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.0.66-usdh-1",
3
+ "version": "0.0.67",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,7 +0,0 @@
1
- interface SpotBalances {
2
- usdhBalance: number | undefined;
3
- spotUsdcBalance: number | undefined;
4
- isLoading: boolean;
5
- }
6
- export declare const useSpotBalances: () => SpotBalances;
7
- export {};
@@ -1,13 +0,0 @@
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;