@pear-protocol/hyperliquid-sdk 0.0.5 → 0.0.7-3.beta

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.
Files changed (58) hide show
  1. package/dist/clients/agentWallet.d.ts +3 -0
  2. package/dist/clients/auth.d.ts +14 -0
  3. package/dist/clients/hyperliquid.d.ts +25 -0
  4. package/dist/clients/notifications.d.ts +13 -0
  5. package/dist/clients/orders.d.ts +24 -0
  6. package/dist/clients/portfolio.d.ts +39 -0
  7. package/dist/clients/positions.d.ts +135 -0
  8. package/dist/clients/sync.d.ts +9 -0
  9. package/dist/clients/watchlist.d.ts +2 -0
  10. package/dist/hooks/index.d.ts +18 -2
  11. package/dist/hooks/useAccountSummary.d.ts +5 -0
  12. package/dist/hooks/useAgentWallet.d.ts +5 -0
  13. package/dist/hooks/useAuth.d.ts +14 -0
  14. package/dist/hooks/useAutoSyncFills.d.ts +19 -0
  15. package/dist/hooks/useBasketCandles.d.ts +25 -0
  16. package/dist/hooks/useHistoricalPriceData.d.ts +11 -0
  17. package/dist/hooks/useMarketData.d.ts +10 -0
  18. package/dist/hooks/useNotifications.d.ts +16 -0
  19. package/dist/hooks/useOrders.d.ts +10 -0
  20. package/dist/hooks/usePerformanceOverlays.d.ts +14 -0
  21. package/dist/hooks/usePortfolio.d.ts +13 -0
  22. package/dist/hooks/usePosition.d.ts +13 -0
  23. package/dist/hooks/useTokenSelectionMetadata.d.ts +18 -0
  24. package/dist/hooks/useTrading.d.ts +7 -23
  25. package/dist/hooks/useTwap.d.ts +6 -0
  26. package/dist/hooks/useUserSelection.d.ts +3 -0
  27. package/dist/hooks/useWatchlist.d.ts +6 -0
  28. package/dist/hooks/useWebData.d.ts +12 -0
  29. package/dist/hyperliquid-websocket.d.ts +10 -0
  30. package/dist/index.d.ts +1130 -419
  31. package/dist/index.js +7207 -5551
  32. package/dist/provider.d.ts +12 -41
  33. package/dist/store/historicalPriceDataStore.d.ts +25 -0
  34. package/dist/store/hyperliquidDataStore.d.ts +25 -0
  35. package/dist/store/marketDataStore.d.ts +10 -0
  36. package/dist/store/tokenSelectionMetadataStore.d.ts +27 -0
  37. package/dist/store/userDataStore.d.ts +30 -0
  38. package/dist/store/userSelection.d.ts +27 -0
  39. package/dist/types.d.ts +566 -225
  40. package/dist/utils/account-summary-calculator.d.ts +17 -0
  41. package/dist/utils/basket-calculator.d.ts +24 -0
  42. package/dist/utils/chart-interval-mappers.d.ts +9 -0
  43. package/dist/utils/conflict-detector.d.ts +14 -0
  44. package/dist/utils/http.d.ts +26 -0
  45. package/dist/utils/position-processor.d.ts +2 -0
  46. package/dist/utils/position-validator.d.ts +61 -0
  47. package/dist/utils/symbol-translator.d.ts +11 -0
  48. package/dist/utils/token-metadata-extractor.d.ts +33 -0
  49. package/dist/websocket.d.ts +9 -0
  50. package/package.json +19 -6
  51. package/README.md +0 -230
  52. package/dist/client.d.ts +0 -43
  53. package/dist/hooks/useAddress.d.ts +0 -9
  54. package/dist/hyperliquid-service.d.ts +0 -75
  55. package/dist/index.esm.js +0 -5862
  56. package/dist/index.esm.js.map +0 -1
  57. package/dist/index.js.map +0 -1
  58. package/dist/migration-sdk.d.ts +0 -59
@@ -1,56 +1,27 @@
1
- import React, { ReactNode } from 'react';
2
- import { ReadyState } from 'react-use-websocket';
3
- import { PearHyperliquidClient } from './client';
4
- import { PearHyperliquidConfig } from './types';
5
- import { PearMigrationSDK } from './migration-sdk';
6
- import { HyperliquidService } from './hyperliquid-service';
7
- import type { PaginatedTradeHistoryResponseDto, OpenPositionDto, OpenLimitOrderDto, AccountSummaryResponseDto } from './types';
8
- interface WebSocketData {
9
- tradeHistories: PaginatedTradeHistoryResponseDto | null;
10
- openPositions: OpenPositionDto[] | null;
11
- openOrders: OpenLimitOrderDto[] | null;
12
- accountSummary: AccountSummaryResponseDto | null;
13
- }
1
+ import React, { ReactNode } from "react";
14
2
  export interface PearHyperliquidContextType {
15
- client: PearHyperliquidClient;
16
- migrationSDK: PearMigrationSDK;
17
- hyperliquidService: HyperliquidService;
18
- address: string | null;
19
- setAddress: (address: string | null) => void;
20
- connectionStatus: ReadyState;
3
+ clientId: string;
4
+ apiBaseUrl: string;
5
+ wsUrl: string;
21
6
  isConnected: boolean;
22
- data: WebSocketData;
23
7
  lastError: string | null;
8
+ nativeIsConnected: boolean;
9
+ nativeLastError: string | null;
24
10
  }
25
11
  export declare const PearHyperliquidContext: React.Context<PearHyperliquidContextType | undefined>;
26
12
  interface PearHyperliquidProviderProps {
27
- config: PearHyperliquidConfig;
28
- /**
29
- * WebSocket server URL
30
- * @default 'wss://hl-v2.pearprotocol.io/ws'
31
- */
32
- wsUrl?: string;
33
- /**
34
- * Hyperliquid WebSocket URL
35
- * @default 'wss://api.hyperliquid.xyz/ws'
36
- */
37
- hyperliquidWsUrl?: string;
38
13
  children: ReactNode;
14
+ apiBaseUrl?: string;
15
+ clientId?: string;
16
+ wsUrl?: string;
39
17
  }
40
18
  /**
41
19
  * React Provider for PearHyperliquidClient
42
20
  */
43
21
  export declare const PearHyperliquidProvider: React.FC<PearHyperliquidProviderProps>;
44
22
  /**
45
- * Hook to use PearHyperliquidClient from context
46
- */
47
- export declare const usePearHyperliquidClient: () => PearHyperliquidClient;
48
- /**
49
- * Hook to use migration SDK from context
50
- */
51
- export declare const useMigrationSDK: () => PearMigrationSDK;
52
- /**
53
- * Hook to use Hyperliquid service from context
23
+ * Hook to access the entire Pear Hyperliquid context.
24
+ * Prefer using the more specific hooks below when possible.
54
25
  */
55
- export declare const useHyperliquidService: () => HyperliquidService;
26
+ export declare function usePearHyperliquid(): PearHyperliquidContextType;
56
27
  export {};
@@ -0,0 +1,25 @@
1
+ import type { CandleData, CandleInterval } from "../types";
2
+ interface HistoricalRange {
3
+ start: number;
4
+ end: number;
5
+ }
6
+ interface TokenHistoricalPriceData {
7
+ symbol: string;
8
+ interval: CandleInterval;
9
+ candles: CandleData[];
10
+ oldestTime: number | null;
11
+ latestTime: number | null;
12
+ }
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>>;
25
+ export type { HistoricalRange, TokenHistoricalPriceData };
@@ -0,0 +1,25 @@
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 {};
@@ -0,0 +1,10 @@
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 {};
@@ -0,0 +1,27 @@
1
+ import type { ActiveAssetData, TokenSelection, TokenMetadata, WsAllMidsData, ActiveAssetsResponse, UniverseAsset, WebData3AssetCtx } from "../types";
2
+ export interface TokenSelectionMetadataState {
3
+ isPriceDataReady: boolean;
4
+ isLoading: boolean;
5
+ longTokensMetadata: Record<string, TokenMetadata | null>;
6
+ shortTokensMetadata: Record<string, TokenMetadata | null>;
7
+ weightedRatio: number;
8
+ weightedRatio24h: number;
9
+ priceRatio: number;
10
+ priceRatio24h: number;
11
+ openInterest: string;
12
+ volume: string;
13
+ sumNetFunding: number;
14
+ maxLeverage: number;
15
+ minMargin: number;
16
+ leverageMatched: boolean;
17
+ recompute: (args: {
18
+ perpMetaAssets: UniverseAsset[] | null;
19
+ finalAssetContexts: WebData3AssetCtx[] | null;
20
+ allMids: WsAllMidsData | null;
21
+ activeAssetData: Record<string, ActiveAssetData> | null;
22
+ marketData: ActiveAssetsResponse | null;
23
+ longTokens: TokenSelection[];
24
+ shortTokens: TokenSelection[];
25
+ }) => void;
26
+ }
27
+ export declare const useTokenSelectionMetadataStore: import("zustand").UseBoundStore<import("zustand").StoreApi<TokenSelectionMetadataState>>;
@@ -0,0 +1,30 @@
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 {};
@@ -0,0 +1,27 @@
1
+ import type { CandleInterval, TokenConflict, TokenSelection, TokenSelectorConfig } from "../types";
2
+ interface UserSelectionState {
3
+ longTokens: TokenSelection[];
4
+ shortTokens: TokenSelection[];
5
+ openTokenSelector: boolean;
6
+ selectorConfig: TokenSelectorConfig | null;
7
+ openConflictModal: boolean;
8
+ conflicts: TokenConflict[];
9
+ candleInterval: CandleInterval;
10
+ isWeightBalanced: boolean;
11
+ setLongTokens: (tokens: TokenSelection[]) => void;
12
+ setShortTokens: (tokens: TokenSelection[]) => void;
13
+ setOpenTokenSelector: (open: boolean) => void;
14
+ setSelectorConfig: (config: TokenSelectorConfig | null) => void;
15
+ setOpenConflictModal: (open: boolean) => void;
16
+ setConflicts: (conflicts: TokenConflict[]) => void;
17
+ setCandleInterval: (interval: CandleInterval) => void;
18
+ updateTokenWeight: (isLong: boolean, index: number, newWeight: number) => void;
19
+ addToken: (isLong: boolean) => boolean;
20
+ canAddToken: (isLong: boolean) => boolean;
21
+ removeToken: (isLong: boolean, index: number) => void;
22
+ handleTokenSelect: (selectedToken: string) => void;
23
+ setTokenSelections: (longTokens: TokenSelection[], shortTokens: TokenSelection[]) => void;
24
+ resetToDefaults: () => void;
25
+ }
26
+ export declare const useUserSelection: import("zustand").UseBoundStore<import("zustand").StoreApi<UserSelectionState>>;
27
+ export type { UserSelectionState };