@pear-protocol/hyperliquid-sdk 0.0.41 → 0.0.42

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.
@@ -13,3 +13,4 @@ export * from './usePosition';
13
13
  export * from './useOrders';
14
14
  export * from './useTwap';
15
15
  export * from './useNotifications';
16
+ export * from './useMarketData';
@@ -0,0 +1,7 @@
1
+ import type { ActiveAssetGroupItem, ActiveAssetsResponse } from '../types';
2
+ export declare const useMarketDataPayload: () => ActiveAssetsResponse | null;
3
+ export declare const useActiveBaskets: () => ActiveAssetGroupItem[];
4
+ export declare const useTopGainers: (limit?: number) => ActiveAssetGroupItem[];
5
+ export declare const useTopLosers: (limit?: number) => ActiveAssetGroupItem[];
6
+ export declare const useHighlightedBaskets: () => ActiveAssetGroupItem[];
7
+ export declare const useFindBasket: (longs: string[], shorts: string[]) => ActiveAssetGroupItem | undefined;
@@ -6,6 +6,10 @@ export interface UseTokenSelectionMetadataReturn {
6
6
  shortTokensMetadata: Record<string, TokenMetadata | null>;
7
7
  weightedRatio: number;
8
8
  weightedRatio24h: number;
9
+ priceRatio: number;
10
+ priceRatio24h: number;
11
+ openInterest: string;
12
+ volume: string;
9
13
  sumNetFunding: number;
10
14
  maxLeverage: number;
11
15
  minMargin: number;
package/dist/index.d.ts CHANGED
@@ -30,7 +30,7 @@ type WebSocketConnectionState = 'connecting' | 'connected' | 'disconnected' | 'e
30
30
  /**
31
31
  * WebSocket channels
32
32
  */
33
- type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'twap-details' | 'notifications' | 'webData2' | 'allMids' | 'activeAssetData';
33
+ type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'twap-details' | 'notifications' | 'market-data' | 'webData2' | 'allMids' | 'activeAssetData';
34
34
  /**
35
35
  * WebSocket subscription message
36
36
  */
@@ -132,6 +132,8 @@ interface TradeHistoryDataDto {
132
132
  totalValue: number;
133
133
  entryRatio: number;
134
134
  exitRatio: number;
135
+ entryPriceRatio?: number;
136
+ exitpPriceRatio?: number;
135
137
  longAssets: TradeHistoryAssetDataDto[];
136
138
  shortAssets: TradeHistoryAssetDataDto[];
137
139
  createdAt: string;
@@ -174,6 +176,8 @@ interface OpenPositionDto {
174
176
  takeProfit: TpSlThreshold | null;
175
177
  entryRatio: number;
176
178
  markRatio: number;
179
+ entryPriceRatio?: number;
180
+ markPriceRatio?: number;
177
181
  entryPositionValue: number;
178
182
  positionValue: number;
179
183
  marginUsed: number;
@@ -507,6 +511,28 @@ interface AssetMarketData {
507
511
  asset: AssetCtx;
508
512
  universe: UniverseAsset;
509
513
  }
514
+ interface PairAssetDto {
515
+ asset: string;
516
+ weight: number;
517
+ }
518
+ interface ActiveAssetGroupItem {
519
+ longAssets: PairAssetDto[];
520
+ shortAssets: PairAssetDto[];
521
+ openInterest: string;
522
+ volume: string;
523
+ ratio?: string;
524
+ prevRatio?: string;
525
+ change24h?: string;
526
+ weightedRatio?: string;
527
+ weightedPrevRatio?: string;
528
+ weightedChange24h?: string;
529
+ }
530
+ interface ActiveAssetsResponse {
531
+ active: ActiveAssetGroupItem[];
532
+ topGainers: ActiveAssetGroupItem[];
533
+ topLosers: ActiveAssetGroupItem[];
534
+ highlighted: ActiveAssetGroupItem[];
535
+ }
510
536
  /**
511
537
  * Candle interval options
512
538
  */
@@ -691,6 +717,10 @@ interface UseTokenSelectionMetadataReturn {
691
717
  shortTokensMetadata: Record<string, TokenMetadata | null>;
692
718
  weightedRatio: number;
693
719
  weightedRatio24h: number;
720
+ priceRatio: number;
721
+ priceRatio24h: number;
722
+ openInterest: string;
723
+ volume: string;
694
724
  sumNetFunding: number;
695
725
  maxLeverage: number;
696
726
  minMargin: number;
@@ -976,6 +1006,13 @@ interface UseNotificationsResult {
976
1006
  */
977
1007
  declare function useNotifications(): UseNotificationsResult;
978
1008
 
1009
+ declare const useMarketDataPayload: () => ActiveAssetsResponse | null;
1010
+ declare const useActiveBaskets: () => ActiveAssetGroupItem[];
1011
+ declare const useTopGainers: (limit?: number) => ActiveAssetGroupItem[];
1012
+ declare const useTopLosers: (limit?: number) => ActiveAssetGroupItem[];
1013
+ declare const useHighlightedBaskets: () => ActiveAssetGroupItem[];
1014
+ declare const useFindBasket: (longs: string[], shorts: string[]) => ActiveAssetGroupItem | undefined;
1015
+
979
1016
  interface UseHyperliquidWebSocketProps {
980
1017
  wsUrl: string;
981
1018
  address: string | null;
@@ -1112,5 +1149,7 @@ declare function mapTradingViewIntervalToCandleInterval(interval: string): Candl
1112
1149
  */
1113
1150
  declare function mapCandleIntervalToTradingViewInterval(interval: CandleInterval): string;
1114
1151
 
1115
- export { AccountSummaryCalculator, AuthStatus, ConflictDetector, PearHyperliquidProvider, TokenMetadataExtractor, adjustOrder, adjustPosition, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, updateRiskParameters, useAccountSummary, useAddress, useAgentWallet, useAuth, useAutoSyncFills, useBasketCandles, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useNotifications, useOpenOrders, useOrders, usePearAgentWallet, usePearAuth, usePearHyperliquid, usePerformanceOverlays, usePosition, useTokenSelectionMetadata, useTradeHistories, useTwap, useUserSelection, useWebData };
1116
- export type { AccountSummaryResponseDto, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, AutoSyncFillsOptions, AutoSyncFillsState, BalanceSummaryDto, CancelOrderResponseDto, CancelTwapResponseDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ClearinghouseState, CloseAllPositionsResponseDto, CloseAllPositionsResultDto, CloseExecutionType, ClosePositionRequestInput, ClosePositionResponseDto, CreatePositionRequestInput, CreatePositionResponseDto, CrossMarginSummaryDto, CumFundingDto, ExecutionType, HLWebSocketResponse, HistoricalRange, LadderConfigInput, MarginSummaryDto, NotificationCategory, NotificationDto, OpenLimitOrderDto, OpenPositionDto, OrderAssetDto, OrderStatus, PairAssetInput, PerformanceOverlay, PositionAdjustmentType, PositionAssetDetailDto, PositionAssetSummaryDto, PositionResponseStatus, RealtimeBar, RealtimeBarsCallback, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlThresholdInput, TpSlThresholdType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TwapChunkStatusDto, TwapMonitoringDto, UniverseAsset, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAgentWalletOptions, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseNotificationsResult, UsePerformanceOverlaysReturn, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WebData2Response, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
1152
+ declare const useMarketData: any;
1153
+
1154
+ export { AccountSummaryCalculator, AuthStatus, ConflictDetector, PearHyperliquidProvider, TokenMetadataExtractor, adjustOrder, adjustPosition, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, updateRiskParameters, useAccountSummary, useActiveBaskets, useAddress, useAgentWallet, useAuth, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMarketData, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearAgentWallet, usePearAuth, usePearHyperliquid, usePerformanceOverlays, usePosition, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWebData };
1155
+ export type { AccountSummaryResponseDto, ActiveAssetGroupItem, ActiveAssetsResponse, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, AutoSyncFillsOptions, AutoSyncFillsState, BalanceSummaryDto, CancelOrderResponseDto, CancelTwapResponseDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ClearinghouseState, CloseAllPositionsResponseDto, CloseAllPositionsResultDto, CloseExecutionType, ClosePositionRequestInput, ClosePositionResponseDto, CreatePositionRequestInput, CreatePositionResponseDto, CrossMarginSummaryDto, CumFundingDto, ExecutionType, HLWebSocketResponse, HistoricalRange, LadderConfigInput, MarginSummaryDto, NotificationCategory, NotificationDto, OpenLimitOrderDto, OpenPositionDto, OrderAssetDto, OrderStatus, PairAssetDto, PairAssetInput, PerformanceOverlay, PositionAdjustmentType, PositionAssetDetailDto, PositionAssetSummaryDto, PositionResponseStatus, RealtimeBar, RealtimeBarsCallback, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlThresholdInput, TpSlThresholdType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TwapChunkStatusDto, TwapMonitoringDto, UniverseAsset, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAgentWalletOptions, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseNotificationsResult, UsePerformanceOverlaysReturn, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WebData2Response, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
package/dist/index.js CHANGED
@@ -2451,8 +2451,15 @@ const useUserData = create((set) => ({
2451
2451
  }),
2452
2452
  }));
2453
2453
 
2454
+ const useMarketData = create((set) => ({
2455
+ marketData: null,
2456
+ setMarketData: (value) => set({ marketData: value }),
2457
+ clean: () => set({ marketData: null }),
2458
+ }));
2459
+
2454
2460
  const useHyperliquidWebSocket = ({ wsUrl, address }) => {
2455
2461
  const { setTradeHistories, setRawOpenPositions, setOpenOrders, setAccountSummary, setTwapDetails, setNotifications, clean, } = useUserData();
2462
+ const { setMarketData, clean: cleanMarketData } = useMarketData();
2456
2463
  const [lastError, setLastError] = useState(null);
2457
2464
  const [lastSubscribedAddress, setLastSubscribedAddress] = useState(null);
2458
2465
  // WebSocket connection
@@ -2499,6 +2506,9 @@ const useHyperliquidWebSocket = ({ wsUrl, address }) => {
2499
2506
  case 'notifications':
2500
2507
  setNotifications(dataMessage.data);
2501
2508
  break;
2509
+ case 'market-data':
2510
+ setMarketData(dataMessage.data);
2511
+ break;
2502
2512
  // 'fills-checkpoint' is intentionally ignored here
2503
2513
  }
2504
2514
  }
@@ -2540,6 +2550,7 @@ const useHyperliquidWebSocket = ({ wsUrl, address }) => {
2540
2550
  useEffect(() => {
2541
2551
  if (address !== lastSubscribedAddress) {
2542
2552
  clean();
2553
+ cleanMarketData();
2543
2554
  setLastError(null);
2544
2555
  }
2545
2556
  }, [address, lastSubscribedAddress]);
@@ -7251,11 +7262,15 @@ const useTokenSelectionMetadataStore = create((set) => ({
7251
7262
  shortTokensMetadata: {},
7252
7263
  weightedRatio: 1,
7253
7264
  weightedRatio24h: 1,
7265
+ priceRatio: 1,
7266
+ priceRatio24h: 1,
7267
+ openInterest: "0",
7268
+ volume: "0",
7254
7269
  sumNetFunding: 0,
7255
7270
  maxLeverage: 0,
7256
7271
  minMargin: 0,
7257
7272
  leverageMatched: true,
7258
- recompute: ({ webData2, allMids, activeAssetData, longTokens, shortTokens }) => {
7273
+ recompute: ({ webData2, allMids, activeAssetData, marketData, longTokens, shortTokens }) => {
7259
7274
  const isPriceDataReady = !!(webData2 && allMids);
7260
7275
  // Compute metadata when ready
7261
7276
  const longSymbols = longTokens.map((t) => t.symbol);
@@ -7276,6 +7291,42 @@ const useTokenSelectionMetadataStore = create((set) => ({
7276
7291
  const allMetadata = { ...longTokensMetadata, ...shortTokensMetadata };
7277
7292
  return allTokens.some((token) => !allMetadata[token.symbol]);
7278
7293
  })();
7294
+ // Open interest and volume (from market data for matching asset basket)
7295
+ const { openInterest, volume } = (() => {
7296
+ const empty = { openInterest: "0", volume: "0" };
7297
+ if (!(marketData === null || marketData === void 0 ? void 0 : marketData.active) || (!longTokens.length && !shortTokens.length))
7298
+ return empty;
7299
+ const selectedLong = longTokens.map((t) => t.symbol).sort();
7300
+ const selectedShort = shortTokens.map((t) => t.symbol).sort();
7301
+ const match = marketData.active.find((item) => {
7302
+ const longs = [...item.longAssets].sort();
7303
+ const shorts = [...item.shortAssets].sort();
7304
+ if (longs.length !== selectedLong.length || shorts.length !== selectedShort.length)
7305
+ return false;
7306
+ const longsEqual = longs.every((s, i) => s.asset === selectedLong[i]);
7307
+ const shortsEqual = shorts.every((s, i) => s.asset === selectedShort[i]);
7308
+ return longsEqual && shortsEqual;
7309
+ });
7310
+ return match ? { openInterest: match.openInterest, volume: match.volume } : empty;
7311
+ })();
7312
+ // Price ratio (only when exactly one long and one short)
7313
+ const { priceRatio, priceRatio24h } = (() => {
7314
+ var _a, _b, _c, _d;
7315
+ if (longTokens.length !== 1 || shortTokens.length !== 1) {
7316
+ return { priceRatio: 1, priceRatio24h: 1 };
7317
+ }
7318
+ const longSymbol = longTokens[0].symbol;
7319
+ const shortSymbol = shortTokens[0].symbol;
7320
+ const longMeta = longTokensMetadata[longSymbol];
7321
+ const shortMeta = shortTokensMetadata[shortSymbol];
7322
+ const currentLong = (_a = longMeta === null || longMeta === void 0 ? void 0 : longMeta.currentPrice) !== null && _a !== void 0 ? _a : 0;
7323
+ const currentShort = (_b = shortMeta === null || shortMeta === void 0 ? void 0 : shortMeta.currentPrice) !== null && _b !== void 0 ? _b : 0;
7324
+ const prevLong = (_c = longMeta === null || longMeta === void 0 ? void 0 : longMeta.prevDayPrice) !== null && _c !== void 0 ? _c : 0;
7325
+ const prevShort = (_d = shortMeta === null || shortMeta === void 0 ? void 0 : shortMeta.prevDayPrice) !== null && _d !== void 0 ? _d : 0;
7326
+ const ratio = currentShort !== 0 ? currentLong / currentShort : 1;
7327
+ const ratio24h = prevShort !== 0 ? prevLong / prevShort : 1;
7328
+ return { priceRatio: ratio, priceRatio24h: ratio24h };
7329
+ })();
7279
7330
  // Weighted ratio (current)
7280
7331
  const weightedRatio = (() => {
7281
7332
  let longProduct = 1;
@@ -7380,6 +7431,10 @@ const useTokenSelectionMetadataStore = create((set) => ({
7380
7431
  shortTokensMetadata,
7381
7432
  weightedRatio,
7382
7433
  weightedRatio24h,
7434
+ priceRatio,
7435
+ priceRatio24h,
7436
+ openInterest,
7437
+ volume,
7383
7438
  sumNetFunding,
7384
7439
  maxLeverage,
7385
7440
  minMargin,
@@ -7396,14 +7451,16 @@ const useTokenSelectionMetadata = () => {
7396
7451
  const webData2 = useHyperliquidData((state) => state.webData2);
7397
7452
  const allMids = useHyperliquidData((state) => state.allMids);
7398
7453
  const activeAssetData = useHyperliquidData((state) => state.activeAssetData);
7454
+ const marketData = useMarketData((state) => state.marketData);
7399
7455
  const { longTokens, shortTokens } = useUserSelection$1();
7400
- const { isLoading, isPriceDataReady, longTokensMetadata, shortTokensMetadata, weightedRatio, weightedRatio24h, sumNetFunding, maxLeverage, minMargin, leverageMatched, recompute, } = useTokenSelectionMetadataStore();
7456
+ const { isLoading, isPriceDataReady, longTokensMetadata, shortTokensMetadata, weightedRatio, weightedRatio24h, priceRatio, priceRatio24h, openInterest, volume, sumNetFunding, maxLeverage, minMargin, leverageMatched, recompute, } = useTokenSelectionMetadataStore();
7401
7457
  // Recompute derived metadata when inputs change
7402
7458
  useEffect(() => {
7403
7459
  recompute({
7404
7460
  webData2,
7405
7461
  allMids,
7406
7462
  activeAssetData: activeAssetData || null,
7463
+ marketData: marketData || null,
7407
7464
  longTokens,
7408
7465
  shortTokens,
7409
7466
  });
@@ -7419,6 +7476,10 @@ const useTokenSelectionMetadata = () => {
7419
7476
  // Calculated values
7420
7477
  weightedRatio,
7421
7478
  weightedRatio24h,
7479
+ priceRatio,
7480
+ priceRatio24h,
7481
+ openInterest,
7482
+ volume,
7422
7483
  sumNetFunding,
7423
7484
  maxLeverage,
7424
7485
  minMargin,
@@ -8412,6 +8473,17 @@ const buildPositionValue = (rawPositions, webData2, allMids) => {
8412
8473
  return mappedPositionAssets;
8413
8474
  });
8414
8475
  mappedPosition.positionValue = mappedPosition.entryPositionValue + mappedPosition.unrealizedPnl;
8476
+ // If exactly one long and one short asset, include simple price ratios
8477
+ if (position.longAssets.length === 1 && position.shortAssets.length === 1) {
8478
+ const long = position.longAssets[0];
8479
+ const short = position.shortAssets[0];
8480
+ const longMark = parseFloat(allMids.mids[long.coin]);
8481
+ const shortMark = parseFloat(allMids.mids[short.coin]);
8482
+ // entryPriceRatio = long entry price / short entry price
8483
+ mappedPosition.entryPriceRatio = long.entryPrice / short.entryPrice;
8484
+ // markPriceRatio = long current price / short current price
8485
+ mappedPosition.markPriceRatio = longMark / shortMark;
8486
+ }
8415
8487
  return mappedPosition;
8416
8488
  });
8417
8489
  };
@@ -8643,6 +8715,61 @@ function useNotifications() {
8643
8715
  };
8644
8716
  }
8645
8717
 
8718
+ // Base selector for the full market-data payload
8719
+ const useMarketDataPayload = () => {
8720
+ return useMarketData((s) => s.marketData);
8721
+ };
8722
+ // Active baskets
8723
+ const useActiveBaskets = () => {
8724
+ var _a;
8725
+ const data = useMarketDataPayload();
8726
+ return (_a = data === null || data === void 0 ? void 0 : data.active) !== null && _a !== void 0 ? _a : [];
8727
+ };
8728
+ // Top gainers (optional limit override)
8729
+ const useTopGainers = (limit) => {
8730
+ const data = useMarketDataPayload();
8731
+ return useMemo(() => {
8732
+ var _a;
8733
+ const list = (_a = data === null || data === void 0 ? void 0 : data.topGainers) !== null && _a !== void 0 ? _a : [];
8734
+ return typeof limit === 'number' ? list.slice(0, Math.max(0, limit)) : list;
8735
+ }, [data, limit]);
8736
+ };
8737
+ // Top losers (optional limit override)
8738
+ const useTopLosers = (limit) => {
8739
+ const data = useMarketDataPayload();
8740
+ return useMemo(() => {
8741
+ var _a;
8742
+ const list = (_a = data === null || data === void 0 ? void 0 : data.topLosers) !== null && _a !== void 0 ? _a : [];
8743
+ return typeof limit === 'number' ? list.slice(0, Math.max(0, limit)) : list;
8744
+ }, [data, limit]);
8745
+ };
8746
+ // Highlighted baskets
8747
+ const useHighlightedBaskets = () => {
8748
+ var _a;
8749
+ const data = useMarketDataPayload();
8750
+ return (_a = data === null || data === void 0 ? void 0 : data.highlighted) !== null && _a !== void 0 ? _a : [];
8751
+ };
8752
+ // Find a basket by its exact asset composition (order-insensitive)
8753
+ const useFindBasket = (longs, shorts) => {
8754
+ const data = useMarketDataPayload();
8755
+ return useMemo(() => {
8756
+ if (!data)
8757
+ return undefined;
8758
+ const normalize = (arr) => Array.isArray(arr)
8759
+ ? arr
8760
+ .map((v) => (typeof v === 'string' ? v : v === null || v === void 0 ? void 0 : v.asset))
8761
+ .filter(Boolean)
8762
+ .map((s) => s.toUpperCase())
8763
+ .sort()
8764
+ .join(',')
8765
+ : '';
8766
+ const lKey = normalize(longs);
8767
+ const sKey = normalize(shorts);
8768
+ const match = (item) => normalize(item.longAssets) === lKey && normalize(item.shortAssets) === sKey;
8769
+ return data.active.find(match) || data.highlighted.find(match);
8770
+ }, [data, longs, shorts]);
8771
+ };
8772
+
8646
8773
  const PearHyperliquidContext = createContext(undefined);
8647
8774
  /**
8648
8775
  * React Provider for PearHyperliquidClient
@@ -8941,4 +9068,4 @@ function mapCandleIntervalToTradingViewInterval(interval) {
8941
9068
  }
8942
9069
  }
8943
9070
 
8944
- export { AccountSummaryCalculator, AuthStatus, ConflictDetector, PearHyperliquidProvider, TokenMetadataExtractor, adjustOrder, adjustPosition, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, updateRiskParameters, useAccountSummary, useAddress, useAgentWallet, useAuth, useAutoSyncFills, useBasketCandles, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useNotifications, useOpenOrders, useOrders, usePearAgentWallet, usePearAuth, usePearHyperliquid, usePerformanceOverlays, usePosition, useTokenSelectionMetadata, useTradeHistories, useTwap, useUserSelection, useWebData };
9071
+ export { AccountSummaryCalculator, AuthStatus, ConflictDetector, PearHyperliquidProvider, TokenMetadataExtractor, adjustOrder, adjustPosition, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, updateRiskParameters, useAccountSummary, useActiveBaskets, useAddress, useAgentWallet, useAuth, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMarketData, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearAgentWallet, usePearAuth, usePearHyperliquid, usePerformanceOverlays, usePosition, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWebData };
@@ -0,0 +1 @@
1
+ export declare const useMarketData: any;
@@ -1,4 +1,4 @@
1
- import type { ActiveAssetData, TokenSelection, TokenMetadata, WebData2Response, WsAllMidsData } from "../types";
1
+ import type { ActiveAssetData, TokenSelection, TokenMetadata, WebData2Response, WsAllMidsData, ActiveAssetsResponse } from "../types";
2
2
  export interface TokenSelectionMetadataState {
3
3
  isPriceDataReady: boolean;
4
4
  isLoading: boolean;
@@ -6,6 +6,10 @@ export interface TokenSelectionMetadataState {
6
6
  shortTokensMetadata: Record<string, TokenMetadata | null>;
7
7
  weightedRatio: number;
8
8
  weightedRatio24h: number;
9
+ priceRatio: number;
10
+ priceRatio24h: number;
11
+ openInterest: string;
12
+ volume: string;
9
13
  sumNetFunding: number;
10
14
  maxLeverage: number;
11
15
  minMargin: number;
@@ -14,6 +18,7 @@ export interface TokenSelectionMetadataState {
14
18
  webData2: WebData2Response | null;
15
19
  allMids: WsAllMidsData | null;
16
20
  activeAssetData: Record<string, ActiveAssetData> | null;
21
+ marketData: ActiveAssetsResponse | null;
17
22
  longTokens: TokenSelection[];
18
23
  shortTokens: TokenSelection[];
19
24
  }) => void;
package/dist/types.d.ts CHANGED
@@ -51,7 +51,7 @@ export type WebSocketConnectionState = 'connecting' | 'connected' | 'disconnecte
51
51
  /**
52
52
  * WebSocket channels
53
53
  */
54
- export type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'twap-details' | 'notifications' | 'webData2' | 'allMids' | 'activeAssetData';
54
+ export type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'twap-details' | 'notifications' | 'market-data' | 'webData2' | 'allMids' | 'activeAssetData';
55
55
  /**
56
56
  * WebSocket subscription message
57
57
  */
@@ -153,6 +153,8 @@ export interface TradeHistoryDataDto {
153
153
  totalValue: number;
154
154
  entryRatio: number;
155
155
  exitRatio: number;
156
+ entryPriceRatio?: number;
157
+ exitpPriceRatio?: number;
156
158
  longAssets: TradeHistoryAssetDataDto[];
157
159
  shortAssets: TradeHistoryAssetDataDto[];
158
160
  createdAt: string;
@@ -195,6 +197,8 @@ export interface OpenPositionDto {
195
197
  takeProfit: TpSlThreshold | null;
196
198
  entryRatio: number;
197
199
  markRatio: number;
200
+ entryPriceRatio?: number;
201
+ markPriceRatio?: number;
198
202
  entryPositionValue: number;
199
203
  positionValue: number;
200
204
  marginUsed: number;
@@ -592,6 +596,28 @@ export interface AssetMarketData {
592
596
  asset: AssetCtx;
593
597
  universe: UniverseAsset;
594
598
  }
599
+ export interface PairAssetDto {
600
+ asset: string;
601
+ weight: number;
602
+ }
603
+ export interface ActiveAssetGroupItem {
604
+ longAssets: PairAssetDto[];
605
+ shortAssets: PairAssetDto[];
606
+ openInterest: string;
607
+ volume: string;
608
+ ratio?: string;
609
+ prevRatio?: string;
610
+ change24h?: string;
611
+ weightedRatio?: string;
612
+ weightedPrevRatio?: string;
613
+ weightedChange24h?: string;
614
+ }
615
+ export interface ActiveAssetsResponse {
616
+ active: ActiveAssetGroupItem[];
617
+ topGainers: ActiveAssetGroupItem[];
618
+ topLosers: ActiveAssetGroupItem[];
619
+ highlighted: ActiveAssetGroupItem[];
620
+ }
595
621
  /**
596
622
  * Candle interval options
597
623
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",