@pear-protocol/hyperliquid-sdk 0.0.61 → 0.0.63

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.
@@ -55,6 +55,7 @@ export interface CreatePositionResponseDto {
55
55
  * Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
56
56
  * Authorization is derived from headers (Axios defaults or browser localStorage fallback)
57
57
  * @throws MinimumPositionSizeError if any asset has less than $11 USD value
58
+ * @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets (15)
58
59
  */
59
60
  export declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput, displayToFull: Map<string, string>): Promise<ApiResponse<CreatePositionResponseDto>>;
60
61
  export interface UpdateRiskParametersRequestInput {
package/dist/index.d.ts CHANGED
@@ -720,7 +720,8 @@ interface UserSelectionState {
720
720
  setConflicts: (conflicts: TokenConflict[]) => void;
721
721
  setCandleInterval: (interval: CandleInterval) => void;
722
722
  updateTokenWeight: (isLong: boolean, index: number, newWeight: number) => void;
723
- addToken: (isLong: boolean) => void;
723
+ addToken: (isLong: boolean) => boolean;
724
+ canAddToken: (isLong: boolean) => boolean;
724
725
  removeToken: (isLong: boolean, index: number) => void;
725
726
  handleTokenSelect: (selectedToken: string) => void;
726
727
  setTokenSelections: (longTokens: TokenSelection[], shortTokens: TokenSelection[]) => void;
@@ -926,6 +927,7 @@ interface CreatePositionResponseDto {
926
927
  * Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
927
928
  * Authorization is derived from headers (Axios defaults or browser localStorage fallback)
928
929
  * @throws MinimumPositionSizeError if any asset has less than $11 USD value
930
+ * @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets (15)
929
931
  */
930
932
  declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput, displayToFull: Map<string, string>): Promise<ApiResponse<CreatePositionResponseDto>>;
931
933
  interface UpdateRiskParametersRequestInput {
@@ -1254,6 +1256,10 @@ declare function mapCandleIntervalToTradingViewInterval(interval: CandleInterval
1254
1256
  * Minimum USD value required per asset when creating a position
1255
1257
  */
1256
1258
  declare const MINIMUM_ASSET_USD_VALUE = 11;
1259
+ /**
1260
+ * Maximum number of assets allowed per leg (long or short) in a position
1261
+ */
1262
+ declare const MAX_ASSETS_PER_LEG = 15;
1257
1263
  /**
1258
1264
  * Validation error for minimum position size
1259
1265
  */
@@ -1263,6 +1269,22 @@ declare class MinimumPositionSizeError extends Error {
1263
1269
  minimumRequired: number;
1264
1270
  constructor(assetName: string, assetValue: number, minimumRequired: number);
1265
1271
  }
1272
+ /**
1273
+ * Validation error for exceeding maximum assets per leg
1274
+ */
1275
+ declare class MaxAssetsPerLegError extends Error {
1276
+ leg: "long" | "short";
1277
+ assetCount: number;
1278
+ maxAllowed: number;
1279
+ constructor(leg: "long" | "short", assetCount: number, maxAllowed: number);
1280
+ }
1281
+ /**
1282
+ * Validates that each leg doesn't exceed the maximum number of assets
1283
+ * @param longAssets Array of long assets
1284
+ * @param shortAssets Array of short assets
1285
+ * @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets
1286
+ */
1287
+ declare function validateMaxAssetsPerLeg(longAssets?: PairAssetInput[], shortAssets?: PairAssetInput[]): void;
1266
1288
  /**
1267
1289
  * Validates that each asset in a position has at least the minimum USD value
1268
1290
  * @param usdValue Total USD value for the position
@@ -1293,5 +1315,5 @@ declare function validatePositionSize(usdValue: number, longAssets?: PairAssetIn
1293
1315
 
1294
1316
  declare const useMarketData: any;
1295
1317
 
1296
- export { AccountSummaryCalculator, ConflictDetector, MINIMUM_ASSET_USD_VALUE, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, getPortfolio, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllBaskets, useAuth, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMarketData, useMarketDataAllPayload, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePortfolio, usePosition, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWatchlist, useWatchlistBaskets, useWebData, validateMinimumAssetSize, validatePositionSize };
1318
+ export { AccountSummaryCalculator, ConflictDetector, MAX_ASSETS_PER_LEG, MINIMUM_ASSET_USD_VALUE, MaxAssetsPerLegError, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, getPortfolio, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllBaskets, useAuth, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMarketData, useMarketDataAllPayload, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePortfolio, usePosition, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWatchlist, useWatchlistBaskets, useWebData, validateMaxAssetsPerLeg, validateMinimumAssetSize, validatePositionSize };
1297
1319
  export type { AccountSummaryResponseDto, ActiveAssetGroupItem, ActiveAssetsResponse, AdjustAdvanceAssetInput, AdjustAdvanceItemInput, AdjustAdvanceResponseDto, 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, ExtraAgent, HLWebSocketResponse, HistoricalRange, LadderConfigInput, MarginSummaryDto, NotificationCategory, NotificationDto, OpenLimitOrderDto, OpenPositionDto, OrderAssetDto, OrderStatus, PairAssetDto, PairAssetInput, PerformanceOverlay, PlatformAccountSummaryResponseDto, PortfolioBucketDto, PortfolioInterval, PortfolioIntervalsDto, PortfolioOverallDto, PortfolioResponseDto, PositionAdjustmentType, PositionAssetDetailDto, PositionAssetSummaryDto, PositionResponseStatus, RealtimeBar, RealtimeBarsCallback, ToggleWatchlistResponseDto, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlThresholdInput, TpSlThresholdType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TwapChunkStatusDto, TwapMonitoringDto, TwapSliceFillResponseItem, UniverseAsset, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseNotificationsResult, UsePerformanceOverlaysReturn, UsePortfolioResult, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WatchlistItemDto, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
package/dist/index.js CHANGED
@@ -365,6 +365,119 @@ const useHyperliquidData = create((set, get) => ({
365
365
  setHip3DisplayToFull: (value) => set({ hip3DisplayToFull: value })
366
366
  }));
367
367
 
368
+ /**
369
+ * Minimum USD value required per asset when creating a position
370
+ */
371
+ const MINIMUM_ASSET_USD_VALUE = 11;
372
+ /**
373
+ * Maximum number of assets allowed per leg (long or short) in a position
374
+ */
375
+ const MAX_ASSETS_PER_LEG = 15;
376
+ /**
377
+ * Validation error for minimum position size
378
+ */
379
+ class MinimumPositionSizeError extends Error {
380
+ constructor(assetName, assetValue, minimumRequired) {
381
+ super(`Asset "${assetName}" has a USD value of $${assetValue.toFixed(2)}, which is below the minimum required value of $${minimumRequired.toFixed(2)}`);
382
+ this.assetName = assetName;
383
+ this.assetValue = assetValue;
384
+ this.minimumRequired = minimumRequired;
385
+ this.name = "MinimumPositionSizeError";
386
+ }
387
+ }
388
+ /**
389
+ * Validation error for exceeding maximum assets per leg
390
+ */
391
+ class MaxAssetsPerLegError extends Error {
392
+ constructor(leg, assetCount, maxAllowed) {
393
+ super(`Maximum ${maxAllowed} assets allowed per leg. Your ${leg} leg has ${assetCount} assets. Please reduce the number of assets to continue.`);
394
+ this.leg = leg;
395
+ this.assetCount = assetCount;
396
+ this.maxAllowed = maxAllowed;
397
+ this.name = "MaxAssetsPerLegError";
398
+ }
399
+ }
400
+ /**
401
+ * Validates that each leg doesn't exceed the maximum number of assets
402
+ * @param longAssets Array of long assets
403
+ * @param shortAssets Array of short assets
404
+ * @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets
405
+ */
406
+ function validateMaxAssetsPerLeg(longAssets, shortAssets) {
407
+ const longCount = (longAssets === null || longAssets === void 0 ? void 0 : longAssets.length) || 0;
408
+ const shortCount = (shortAssets === null || shortAssets === void 0 ? void 0 : shortAssets.length) || 0;
409
+ if (longCount > MAX_ASSETS_PER_LEG) {
410
+ throw new MaxAssetsPerLegError("long", longCount, MAX_ASSETS_PER_LEG);
411
+ }
412
+ if (shortCount > MAX_ASSETS_PER_LEG) {
413
+ throw new MaxAssetsPerLegError("short", shortCount, MAX_ASSETS_PER_LEG);
414
+ }
415
+ }
416
+ /**
417
+ * Validates that each asset in a position has at least the minimum USD value
418
+ * @param usdValue Total USD value for the position
419
+ * @param longAssets Array of long assets with weights
420
+ * @param shortAssets Array of short assets with weights
421
+ * @throws MinimumPositionSizeError if any asset has less than the minimum USD value
422
+ */
423
+ function validateMinimumAssetSize(usdValue, longAssets, shortAssets) {
424
+ var _a;
425
+ const allAssets = [...(longAssets || []), ...(shortAssets || [])];
426
+ if (allAssets.length === 0) {
427
+ return; // No assets to validate
428
+ }
429
+ // Calculate total weight
430
+ const totalWeight = allAssets.reduce((sum, asset) => { var _a; return sum + ((_a = asset.weight) !== null && _a !== void 0 ? _a : 0); }, 0);
431
+ // If weights are not provided or sum to 0, assume equal distribution
432
+ const hasWeights = totalWeight > 0;
433
+ const equalWeight = hasWeights ? 0 : 1 / allAssets.length;
434
+ // Validate each asset
435
+ for (const asset of allAssets) {
436
+ const weight = hasWeights ? (_a = asset.weight) !== null && _a !== void 0 ? _a : 0 : equalWeight;
437
+ const assetUsdValue = usdValue * weight;
438
+ if (assetUsdValue < MINIMUM_ASSET_USD_VALUE) {
439
+ throw new MinimumPositionSizeError(asset.asset, assetUsdValue, MINIMUM_ASSET_USD_VALUE);
440
+ }
441
+ }
442
+ }
443
+ /**
444
+ * Calculates the minimum USD value required for a position based on the number of assets
445
+ * @param longAssets Array of long assets
446
+ * @param shortAssets Array of short assets
447
+ * @returns The minimum total USD value required
448
+ */
449
+ function calculateMinimumPositionValue(longAssets, shortAssets) {
450
+ const totalAssets = ((longAssets === null || longAssets === void 0 ? void 0 : longAssets.length) || 0) + ((shortAssets === null || shortAssets === void 0 ? void 0 : shortAssets.length) || 0);
451
+ if (totalAssets === 0) {
452
+ return 0;
453
+ }
454
+ return MINIMUM_ASSET_USD_VALUE * totalAssets;
455
+ }
456
+ /**
457
+ * Validates and provides a user-friendly error message with suggestions
458
+ * @param usdValue Total USD value for the position
459
+ * @param longAssets Array of long assets with weights
460
+ * @param shortAssets Array of short assets with weights
461
+ * @returns Validation result with success flag and optional error message
462
+ */
463
+ function validatePositionSize(usdValue, longAssets, shortAssets) {
464
+ try {
465
+ validateMinimumAssetSize(usdValue, longAssets, shortAssets);
466
+ return { valid: true };
467
+ }
468
+ catch (error) {
469
+ if (error instanceof MinimumPositionSizeError) {
470
+ const minimumRequired = calculateMinimumPositionValue(longAssets, shortAssets);
471
+ return {
472
+ valid: false,
473
+ error: error.message,
474
+ minimumRequired,
475
+ };
476
+ }
477
+ throw error;
478
+ }
479
+ }
480
+
368
481
  const DEFAULT_STATE = {
369
482
  longTokens: [
370
483
  { symbol: "HYPE", weight: 25 },
@@ -413,14 +526,23 @@ const useUserSelection$1 = create((set, get) => ({
413
526
  }
414
527
  });
415
528
  },
529
+ canAddToken: (isLong) => {
530
+ const currentTokens = isLong ? get().longTokens : get().shortTokens;
531
+ return currentTokens.length < MAX_ASSETS_PER_LEG;
532
+ },
416
533
  addToken: (isLong) => {
417
534
  const currentTokens = isLong ? get().longTokens : get().shortTokens;
535
+ // Check if we've reached the maximum number of assets per leg
536
+ if (currentTokens.length >= MAX_ASSETS_PER_LEG) {
537
+ return false;
538
+ }
418
539
  const newIndex = currentTokens.length;
419
540
  set((prev) => ({
420
541
  ...prev,
421
542
  selectorConfig: { isLong, index: newIndex },
422
543
  openTokenSelector: true,
423
544
  }));
545
+ return true;
424
546
  },
425
547
  removeToken: (isLong, index) => {
426
548
  set((prev) => {
@@ -579,7 +701,9 @@ const useHyperliquidNativeWebSocket = ({ address, enabled = true, }) => {
579
701
  {
580
702
  const data = response.data;
581
703
  const remapped = {
582
- mids: Object.fromEntries(Object.entries(data.mids || {}).map(([k, v]) => [toDisplaySymbol(k), v]))
704
+ mids: Object.fromEntries(
705
+ // only support non hip-3 and xyz market
706
+ Object.entries(data.mids || {}).filter(([k, v]) => !k.includes(':') || k.includes('xyz:')).map(([k, v]) => [toDisplaySymbol(k), v]))
583
707
  };
584
708
  setAllMids(remapped);
585
709
  }
@@ -6252,93 +6376,15 @@ function useAutoSyncFills(options) {
6252
6376
  };
6253
6377
  }
6254
6378
 
6255
- /**
6256
- * Minimum USD value required per asset when creating a position
6257
- */
6258
- const MINIMUM_ASSET_USD_VALUE = 11;
6259
- /**
6260
- * Validation error for minimum position size
6261
- */
6262
- class MinimumPositionSizeError extends Error {
6263
- constructor(assetName, assetValue, minimumRequired) {
6264
- super(`Asset "${assetName}" has a USD value of $${assetValue.toFixed(2)}, which is below the minimum required value of $${minimumRequired.toFixed(2)}`);
6265
- this.assetName = assetName;
6266
- this.assetValue = assetValue;
6267
- this.minimumRequired = minimumRequired;
6268
- this.name = "MinimumPositionSizeError";
6269
- }
6270
- }
6271
- /**
6272
- * Validates that each asset in a position has at least the minimum USD value
6273
- * @param usdValue Total USD value for the position
6274
- * @param longAssets Array of long assets with weights
6275
- * @param shortAssets Array of short assets with weights
6276
- * @throws MinimumPositionSizeError if any asset has less than the minimum USD value
6277
- */
6278
- function validateMinimumAssetSize(usdValue, longAssets, shortAssets) {
6279
- var _a;
6280
- const allAssets = [...(longAssets || []), ...(shortAssets || [])];
6281
- if (allAssets.length === 0) {
6282
- return; // No assets to validate
6283
- }
6284
- // Calculate total weight
6285
- const totalWeight = allAssets.reduce((sum, asset) => { var _a; return sum + ((_a = asset.weight) !== null && _a !== void 0 ? _a : 0); }, 0);
6286
- // If weights are not provided or sum to 0, assume equal distribution
6287
- const hasWeights = totalWeight > 0;
6288
- const equalWeight = hasWeights ? 0 : 1 / allAssets.length;
6289
- // Validate each asset
6290
- for (const asset of allAssets) {
6291
- const weight = hasWeights ? (_a = asset.weight) !== null && _a !== void 0 ? _a : 0 : equalWeight;
6292
- const assetUsdValue = usdValue * weight;
6293
- if (assetUsdValue < MINIMUM_ASSET_USD_VALUE) {
6294
- throw new MinimumPositionSizeError(asset.asset, assetUsdValue, MINIMUM_ASSET_USD_VALUE);
6295
- }
6296
- }
6297
- }
6298
- /**
6299
- * Calculates the minimum USD value required for a position based on the number of assets
6300
- * @param longAssets Array of long assets
6301
- * @param shortAssets Array of short assets
6302
- * @returns The minimum total USD value required
6303
- */
6304
- function calculateMinimumPositionValue(longAssets, shortAssets) {
6305
- const totalAssets = ((longAssets === null || longAssets === void 0 ? void 0 : longAssets.length) || 0) + ((shortAssets === null || shortAssets === void 0 ? void 0 : shortAssets.length) || 0);
6306
- if (totalAssets === 0) {
6307
- return 0;
6308
- }
6309
- return MINIMUM_ASSET_USD_VALUE * totalAssets;
6310
- }
6311
- /**
6312
- * Validates and provides a user-friendly error message with suggestions
6313
- * @param usdValue Total USD value for the position
6314
- * @param longAssets Array of long assets with weights
6315
- * @param shortAssets Array of short assets with weights
6316
- * @returns Validation result with success flag and optional error message
6317
- */
6318
- function validatePositionSize(usdValue, longAssets, shortAssets) {
6319
- try {
6320
- validateMinimumAssetSize(usdValue, longAssets, shortAssets);
6321
- return { valid: true };
6322
- }
6323
- catch (error) {
6324
- if (error instanceof MinimumPositionSizeError) {
6325
- const minimumRequired = calculateMinimumPositionValue(longAssets, shortAssets);
6326
- return {
6327
- valid: false,
6328
- error: error.message,
6329
- minimumRequired,
6330
- };
6331
- }
6332
- throw error;
6333
- }
6334
- }
6335
-
6336
6379
  /**
6337
6380
  * Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
6338
6381
  * Authorization is derived from headers (Axios defaults or browser localStorage fallback)
6339
6382
  * @throws MinimumPositionSizeError if any asset has less than $11 USD value
6383
+ * @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets (15)
6340
6384
  */
6341
6385
  async function createPosition(baseUrl, payload, displayToFull) {
6386
+ // Validate maximum assets per leg before creating position
6387
+ validateMaxAssetsPerLeg(payload.longAssets, payload.shortAssets);
6342
6388
  // Validate minimum asset size before creating position
6343
6389
  validateMinimumAssetSize(payload.usdValue, payload.longAssets, payload.shortAssets);
6344
6390
  const url = joinUrl(baseUrl, "/positions");
@@ -7308,4 +7354,4 @@ function mapCandleIntervalToTradingViewInterval(interval) {
7308
7354
  }
7309
7355
  }
7310
7356
 
7311
- export { AccountSummaryCalculator, ConflictDetector, MINIMUM_ASSET_USD_VALUE, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, getPortfolio, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllBaskets, useAuth, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMarketData, useMarketDataAllPayload, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePortfolio, usePosition, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWatchlist, useWatchlistBaskets, useWebData, validateMinimumAssetSize, validatePositionSize };
7357
+ export { AccountSummaryCalculator, ConflictDetector, MAX_ASSETS_PER_LEG, MINIMUM_ASSET_USD_VALUE, MaxAssetsPerLegError, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, getPortfolio, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllBaskets, useAuth, useAutoSyncFills, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMarketData, useMarketDataAllPayload, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePortfolio, usePosition, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWatchlist, useWatchlistBaskets, useWebData, validateMaxAssetsPerLeg, validateMinimumAssetSize, validatePositionSize };
@@ -16,7 +16,8 @@ interface UserSelectionState {
16
16
  setConflicts: (conflicts: TokenConflict[]) => void;
17
17
  setCandleInterval: (interval: CandleInterval) => void;
18
18
  updateTokenWeight: (isLong: boolean, index: number, newWeight: number) => void;
19
- addToken: (isLong: boolean) => void;
19
+ addToken: (isLong: boolean) => boolean;
20
+ canAddToken: (isLong: boolean) => boolean;
20
21
  removeToken: (isLong: boolean, index: number) => void;
21
22
  handleTokenSelect: (selectedToken: string) => void;
22
23
  setTokenSelections: (longTokens: TokenSelection[], shortTokens: TokenSelection[]) => void;
@@ -3,6 +3,10 @@ import type { PairAssetInput } from "../clients/positions";
3
3
  * Minimum USD value required per asset when creating a position
4
4
  */
5
5
  export declare const MINIMUM_ASSET_USD_VALUE = 11;
6
+ /**
7
+ * Maximum number of assets allowed per leg (long or short) in a position
8
+ */
9
+ export declare const MAX_ASSETS_PER_LEG = 15;
6
10
  /**
7
11
  * Validation error for minimum position size
8
12
  */
@@ -12,6 +16,22 @@ export declare class MinimumPositionSizeError extends Error {
12
16
  minimumRequired: number;
13
17
  constructor(assetName: string, assetValue: number, minimumRequired: number);
14
18
  }
19
+ /**
20
+ * Validation error for exceeding maximum assets per leg
21
+ */
22
+ export declare class MaxAssetsPerLegError extends Error {
23
+ leg: "long" | "short";
24
+ assetCount: number;
25
+ maxAllowed: number;
26
+ constructor(leg: "long" | "short", assetCount: number, maxAllowed: number);
27
+ }
28
+ /**
29
+ * Validates that each leg doesn't exceed the maximum number of assets
30
+ * @param longAssets Array of long assets
31
+ * @param shortAssets Array of short assets
32
+ * @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets
33
+ */
34
+ export declare function validateMaxAssetsPerLeg(longAssets?: PairAssetInput[], shortAssets?: PairAssetInput[]): void;
15
35
  /**
16
36
  * Validates that each asset in a position has at least the minimum USD value
17
37
  * @param usdValue Total USD value for the position
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.0.61",
3
+ "version": "0.0.63",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",