@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.
@@ -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;
@@ -10,5 +10,16 @@ interface TokenHistoricalPriceData {
10
10
  oldestTime: number | null;
11
11
  latestTime: number | null;
12
12
  }
13
- export declare const useHistoricalPriceDataStore: any;
13
+ interface HistoricalPriceDataState {
14
+ historicalPriceData: Record<string, TokenHistoricalPriceData>;
15
+ loadingTokens: Set<string>;
16
+ addHistoricalPriceData: (symbol: string, interval: CandleInterval, candles: CandleData[], range: HistoricalRange) => void;
17
+ hasHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => boolean;
18
+ getHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => CandleData[];
19
+ setTokenLoading: (symbol: string, loading: boolean) => void;
20
+ isTokenLoading: (symbol: string) => boolean;
21
+ removeTokenPriceData: (symbol: string, interval: CandleInterval) => void;
22
+ clearData: () => void;
23
+ }
24
+ export declare const useHistoricalPriceDataStore: import("zustand").UseBoundStore<import("zustand").StoreApi<HistoricalPriceDataState>>;
14
25
  export type { HistoricalRange, TokenHistoricalPriceData };
@@ -1 +1,25 @@
1
- export declare const useHyperliquidData: any;
1
+ import { ActiveAssetData, CandleChartData, CandleData, ClearinghouseState, UniverseAsset, WebData3AssetCtx, WsAllMidsData } from "../types";
2
+ interface HyperliquidDataState {
3
+ allMids: WsAllMidsData | null;
4
+ activeAssetData: Record<string, ActiveAssetData> | null;
5
+ candleData: CandleChartData | null;
6
+ finalAssetContexts: WebData3AssetCtx[] | null;
7
+ finalAtOICaps: string[] | null;
8
+ aggregatedClearingHouseState: ClearinghouseState | null;
9
+ perpMetaAssets: UniverseAsset[] | null;
10
+ hip3DisplayToFull: Map<string, string>;
11
+ setAllMids: (value: WsAllMidsData | null) => void;
12
+ setActiveAssetData: (value: Record<string, ActiveAssetData> | null | ((prev: Record<string, ActiveAssetData> | null) => Record<string, ActiveAssetData> | null)) => void;
13
+ deleteActiveAssetData: (key: string) => void;
14
+ addCandleData: (symbol: string, candle: CandleData) => void;
15
+ deleteCandleSymbol: (symbol: string) => void;
16
+ setCandleData: (value: CandleChartData | null) => void;
17
+ upsertActiveAssetData: (key: string, value: ActiveAssetData) => void;
18
+ setFinalAssetContexts: (value: WebData3AssetCtx[] | null) => void;
19
+ setFinalAtOICaps: (value: string[] | null) => void;
20
+ setAggregatedClearingHouseState: (value: ClearinghouseState | null) => void;
21
+ setPerpMetaAssets: (value: UniverseAsset[] | null) => void;
22
+ setHip3DisplayToFull: (value: Map<string, string>) => void;
23
+ }
24
+ export declare const useHyperliquidData: import("zustand").UseBoundStore<import("zustand").StoreApi<HyperliquidDataState>>;
25
+ export {};
@@ -1 +1,10 @@
1
- export declare const useMarketData: any;
1
+ import type { ActiveAssetsAllResponse, ActiveAssetsResponse } from '../types';
2
+ interface MarketDataState {
3
+ marketData: ActiveAssetsResponse | null;
4
+ marketDataAll: ActiveAssetsAllResponse | null;
5
+ setMarketData: (value: ActiveAssetsResponse | null) => void;
6
+ setMarketDataAll: (value: ActiveAssetsAllResponse | null) => void;
7
+ clean: () => void;
8
+ }
9
+ export declare const useMarketData: import("zustand").UseBoundStore<import("zustand").StoreApi<MarketDataState>>;
10
+ export {};
@@ -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;
@@ -24,4 +24,4 @@ export interface TokenSelectionMetadataState {
24
24
  shortTokens: TokenSelection[];
25
25
  }) => void;
26
26
  }
27
- export declare const useTokenSelectionMetadataStore: any;
27
+ export declare const useTokenSelectionMetadataStore: import("zustand").UseBoundStore<import("zustand").StoreApi<TokenSelectionMetadataState>>;
@@ -1 +1,30 @@
1
- export declare const useUserData: any;
1
+ import { PlatformAccountSummaryResponseDto, OpenLimitOrderDto, RawPositionDto, TradeHistoryDataDto, TwapMonitoringDto, NotificationDto, ExtraAgent } from "../types";
2
+ interface UserDataState {
3
+ accessToken: string | null;
4
+ refreshToken: string | null;
5
+ isAuthenticated: boolean;
6
+ isReady: boolean;
7
+ address: string | null;
8
+ tradeHistories: TradeHistoryDataDto[] | null;
9
+ rawOpenPositions: RawPositionDto[] | null;
10
+ openOrders: OpenLimitOrderDto[] | null;
11
+ accountSummary: PlatformAccountSummaryResponseDto | null;
12
+ twapDetails: TwapMonitoringDto[] | null;
13
+ notifications: NotificationDto[] | null;
14
+ userExtraAgents: ExtraAgent[] | null;
15
+ setAccessToken: (token: string | null) => void;
16
+ setRefreshToken: (token: string | null) => void;
17
+ setIsAuthenticated: (value: boolean) => void;
18
+ setIsReady: (value: boolean) => void;
19
+ setAddress: (address: string | null) => void;
20
+ setTradeHistories: (value: TradeHistoryDataDto[] | null) => void;
21
+ setRawOpenPositions: (value: RawPositionDto[] | null) => void;
22
+ setOpenOrders: (value: OpenLimitOrderDto[] | null) => void;
23
+ setAccountSummary: (value: PlatformAccountSummaryResponseDto | null) => void;
24
+ setUserExtraAgents: (value: ExtraAgent[] | null) => void;
25
+ setTwapDetails: (value: TwapMonitoringDto[] | null) => void;
26
+ setNotifications: (value: NotificationDto[] | null) => void;
27
+ clean: () => void;
28
+ }
29
+ export declare const useUserData: import("zustand").UseBoundStore<import("zustand").StoreApi<UserDataState>>;
30
+ export {};
@@ -22,5 +22,5 @@ interface UserSelectionState {
22
22
  setTokenSelections: (longTokens: TokenSelection[], shortTokens: TokenSelection[]) => void;
23
23
  resetToDefaults: () => void;
24
24
  }
25
- export declare const useUserSelection: any;
25
+ export declare const useUserSelection: import("zustand").UseBoundStore<import("zustand").StoreApi<UserSelectionState>>;
26
26
  export type { UserSelectionState };
package/dist/types.d.ts CHANGED
@@ -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,8 +210,6 @@ 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
215
  type: 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
@@ -431,7 +427,7 @@ export interface AgentWalletState {
431
427
  * WebSocket message from HyperLiquid native API
432
428
  */
433
429
  export interface WebSocketMessage {
434
- method: 'subscribe' | 'unsubscribe';
430
+ method: "subscribe" | "unsubscribe";
435
431
  subscription: {
436
432
  type: string;
437
433
  dex?: string;
@@ -505,12 +501,6 @@ export interface AssetCtx {
505
501
  impactPxs?: string[];
506
502
  oraclePx: string;
507
503
  }
508
- /**
509
- * Collateral token type
510
- * 0 = USDC
511
- * 360 = USDH
512
- */
513
- export type CollateralToken = 'USDC' | 'USDH';
514
504
  /**
515
505
  * Universe asset metadata
516
506
  */
@@ -520,8 +510,6 @@ export interface UniverseAsset {
520
510
  maxLeverage: number;
521
511
  onlyIsolated?: boolean;
522
512
  isDelisted?: boolean;
523
- marketPrefix?: string;
524
- collateralToken?: CollateralToken;
525
513
  }
526
514
  export interface PerpMetaAsset extends UniverseAsset {
527
515
  marginTableId: number;
@@ -657,7 +645,6 @@ export interface TokenMetadata {
657
645
  leverage?: LeverageInfo;
658
646
  maxTradeSzs?: [string, string];
659
647
  availableToTrade?: [string, string];
660
- collateralToken?: CollateralToken;
661
648
  }
662
649
  /**
663
650
  * Enhanced token selection with weight and metadata for basket trading
@@ -678,30 +665,9 @@ export interface AssetMarketData {
678
665
  asset: WebData3AssetCtx | AssetCtx;
679
666
  universe: UniverseAsset;
680
667
  }
681
- /**
682
- * Nested market data structure for multi-market assets.
683
- * Each symbol maps to its market variants (keyed by prefix).
684
- * For non-HIP3 assets, use "default" as the key.
685
- *
686
- * @example
687
- * ```ts
688
- * {
689
- * "TSLA": {
690
- * "xyz": { asset: {...}, universe: { collateralToken: "USDC", ... } },
691
- * "flx": { asset: {...}, universe: { collateralToken: "USDH", ... } }
692
- * },
693
- * "BTC": {
694
- * "default": { asset: {...}, universe: {...} }
695
- * }
696
- * }
697
- * ```
698
- */
699
- export type MarketDataBySymbol = Record<string, Record<string, AssetMarketData>>;
700
668
  export interface PairAssetDto {
701
669
  asset: string;
702
670
  weight: number;
703
- collateralToken: CollateralToken;
704
- marketPrefix: string | null;
705
671
  }
706
672
  export interface ActiveAssetGroupItem {
707
673
  longAssets: PairAssetDto[];
@@ -715,7 +681,6 @@ export interface ActiveAssetGroupItem {
715
681
  weightedRatio?: string;
716
682
  weightedPrevRatio?: string;
717
683
  weightedChange24h?: string;
718
- collateralType: 'USDC' | 'USDH' | 'MIXED';
719
684
  }
720
685
  export interface ActiveAssetsResponse {
721
686
  active: ActiveAssetGroupItem[];
@@ -733,7 +698,7 @@ export interface ActiveAssetsAllResponse {
733
698
  /**
734
699
  * Candle interval options
735
700
  */
736
- export type CandleInterval = '1m' | '3m' | '5m' | '15m' | '30m' | '1h' | '2h' | '4h' | '8h' | '12h' | '1d' | '3d' | '1w' | '1M';
701
+ export type CandleInterval = "1m" | "3m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" | "8h" | "12h" | "1d" | "3d" | "1w" | "1M";
737
702
  /**
738
703
  * Candle data structure from WebSocket
739
704
  */
@@ -761,7 +726,7 @@ export interface CandleSnapshotRequest {
761
726
  endTime: number;
762
727
  interval: CandleInterval;
763
728
  };
764
- type: 'candleSnapshot';
729
+ type: "candleSnapshot";
765
730
  }
766
731
  export interface TokenSelectorConfig {
767
732
  isLong: boolean;
@@ -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.60-beta-usdh-2",
3
+ "version": "0.0.60-beta.10",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -24,7 +24,8 @@
24
24
  "clean": "rimraf dist"
25
25
  },
26
26
  "dependencies": {
27
- "axios": "^1.6.0"
27
+ "axios": "^1.6.0",
28
+ "zustand": "^5.0.8"
28
29
  },
29
30
  "peerDependencies": {
30
31
  "react": "^18.0.0",
@@ -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;