@pear-protocol/hyperliquid-sdk 0.0.5 → 0.0.7-2.1

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 (60) 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 +65 -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 +20 -2
  11. package/dist/hooks/useAccountSummary.d.ts +5 -0
  12. package/dist/hooks/useAgentWallet.d.ts +5 -0
  13. package/dist/hooks/useAllUserBalances.d.ts +9 -0
  14. package/dist/hooks/useAuth.d.ts +12 -0
  15. package/dist/hooks/useAutoSyncFills.d.ts +19 -0
  16. package/dist/hooks/useBasketCandles.d.ts +25 -0
  17. package/dist/hooks/useHistoricalPriceData.d.ts +11 -0
  18. package/dist/hooks/useMarketData.d.ts +12 -0
  19. package/dist/hooks/useNotifications.d.ts +16 -0
  20. package/dist/hooks/useOrders.d.ts +10 -0
  21. package/dist/hooks/usePerformanceOverlays.d.ts +14 -0
  22. package/dist/hooks/usePortfolio.d.ts +13 -0
  23. package/dist/hooks/usePosition.d.ts +13 -0
  24. package/dist/hooks/useSpotOrder.d.ts +13 -0
  25. package/dist/hooks/useTokenSelectionMetadata.d.ts +18 -0
  26. package/dist/hooks/useTrading.d.ts +6 -25
  27. package/dist/hooks/useTwap.d.ts +6 -0
  28. package/dist/hooks/useUserSelection.d.ts +3 -0
  29. package/dist/hooks/useWatchlist.d.ts +6 -0
  30. package/dist/hooks/useWebData.d.ts +30 -0
  31. package/dist/hyperliquid-websocket.d.ts +10 -0
  32. package/dist/index.d.ts +1282 -414
  33. package/dist/index.js +8243 -5572
  34. package/dist/provider.d.ts +11 -40
  35. package/dist/store/historicalPriceDataStore.d.ts +14 -0
  36. package/dist/store/hyperliquidDataStore.d.ts +1 -0
  37. package/dist/store/marketDataStore.d.ts +1 -0
  38. package/dist/store/tokenSelectionMetadataStore.d.ts +27 -0
  39. package/dist/store/userDataStore.d.ts +1 -0
  40. package/dist/store/userSelection.d.ts +27 -0
  41. package/dist/types.d.ts +617 -222
  42. package/dist/utils/account-summary-calculator.d.ts +17 -0
  43. package/dist/utils/basket-calculator.d.ts +24 -0
  44. package/dist/utils/chart-interval-mappers.d.ts +9 -0
  45. package/dist/utils/conflict-detector.d.ts +14 -0
  46. package/dist/utils/http.d.ts +26 -0
  47. package/dist/utils/position-processor.d.ts +2 -0
  48. package/dist/utils/position-validator.d.ts +61 -0
  49. package/dist/utils/symbol-translator.d.ts +40 -0
  50. package/dist/utils/token-metadata-extractor.d.ts +37 -0
  51. package/dist/websocket.d.ts +9 -0
  52. package/package.json +19 -7
  53. package/README.md +0 -230
  54. package/dist/client.d.ts +0 -43
  55. package/dist/hooks/useAddress.d.ts +0 -9
  56. package/dist/hyperliquid-service.d.ts +0 -75
  57. package/dist/index.esm.js +0 -5862
  58. package/dist/index.esm.js.map +0 -1
  59. package/dist/index.js.map +0 -1
  60. package/dist/migration-sdk.d.ts +0 -59
@@ -1,56 +1,27 @@
1
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
- }
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,14 @@
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
+ export declare const useHistoricalPriceDataStore: any;
14
+ export type { HistoricalRange, TokenHistoricalPriceData };
@@ -0,0 +1 @@
1
+ export declare const useHyperliquidData: any;
@@ -0,0 +1 @@
1
+ export declare const useMarketData: any;
@@ -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: any;
@@ -0,0 +1 @@
1
+ export declare const useUserData: any;
@@ -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: any;
27
+ export type { UserSelectionState };