@pear-protocol/hyperliquid-sdk 0.0.64 → 0.0.66

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
@@ -729,7 +729,8 @@ interface UserSelectionState {
729
729
  setConflicts: (conflicts: TokenConflict[]) => void;
730
730
  setCandleInterval: (interval: CandleInterval) => void;
731
731
  updateTokenWeight: (isLong: boolean, index: number, newWeight: number) => void;
732
- addToken: (isLong: boolean) => void;
732
+ addToken: (isLong: boolean) => boolean;
733
+ canAddToken: (isLong: boolean) => boolean;
733
734
  removeToken: (isLong: boolean, index: number) => void;
734
735
  handleTokenSelect: (selectedToken: string) => void;
735
736
  setTokenSelections: (longTokens: TokenSelection[], shortTokens: TokenSelection[]) => void;
@@ -935,6 +936,7 @@ interface CreatePositionResponseDto {
935
936
  * Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
936
937
  * Authorization is derived from headers (Axios defaults or browser localStorage fallback)
937
938
  * @throws MinimumPositionSizeError if any asset has less than $11 USD value
939
+ * @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets (15)
938
940
  */
939
941
  declare function createPosition(baseUrl: string, payload: CreatePositionRequestInput, displayToFull: Map<string, string>): Promise<ApiResponse<CreatePositionResponseDto>>;
940
942
  interface UpdateRiskParametersRequestInput {
@@ -1263,6 +1265,10 @@ declare function mapCandleIntervalToTradingViewInterval(interval: CandleInterval
1263
1265
  * Minimum USD value required per asset when creating a position
1264
1266
  */
1265
1267
  declare const MINIMUM_ASSET_USD_VALUE = 11;
1268
+ /**
1269
+ * Maximum number of assets allowed per leg (long or short) in a position
1270
+ */
1271
+ declare const MAX_ASSETS_PER_LEG = 15;
1266
1272
  /**
1267
1273
  * Validation error for minimum position size
1268
1274
  */
@@ -1272,6 +1278,22 @@ declare class MinimumPositionSizeError extends Error {
1272
1278
  minimumRequired: number;
1273
1279
  constructor(assetName: string, assetValue: number, minimumRequired: number);
1274
1280
  }
1281
+ /**
1282
+ * Validation error for exceeding maximum assets per leg
1283
+ */
1284
+ declare class MaxAssetsPerLegError extends Error {
1285
+ leg: "long" | "short";
1286
+ assetCount: number;
1287
+ maxAllowed: number;
1288
+ constructor(leg: "long" | "short", assetCount: number, maxAllowed: number);
1289
+ }
1290
+ /**
1291
+ * Validates that each leg doesn't exceed the maximum number of assets
1292
+ * @param longAssets Array of long assets
1293
+ * @param shortAssets Array of short assets
1294
+ * @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets
1295
+ */
1296
+ declare function validateMaxAssetsPerLeg(longAssets?: PairAssetInput[], shortAssets?: PairAssetInput[]): void;
1275
1297
  /**
1276
1298
  * Validates that each asset in a position has at least the minimum USD value
1277
1299
  * @param usdValue Total USD value for the position
@@ -1302,5 +1324,5 @@ declare function validatePositionSize(usdValue: number, longAssets?: PairAssetIn
1302
1324
 
1303
1325
  declare const useMarketData: any;
1304
1326
 
1305
- 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 };
1327
+ 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 };
1306
1328
  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) => {
@@ -6287,93 +6409,15 @@ function useAutoSyncFills(options) {
6287
6409
  };
6288
6410
  }
6289
6411
 
6290
- /**
6291
- * Minimum USD value required per asset when creating a position
6292
- */
6293
- const MINIMUM_ASSET_USD_VALUE = 11;
6294
- /**
6295
- * Validation error for minimum position size
6296
- */
6297
- class MinimumPositionSizeError extends Error {
6298
- constructor(assetName, assetValue, minimumRequired) {
6299
- super(`Asset "${assetName}" has a USD value of $${assetValue.toFixed(2)}, which is below the minimum required value of $${minimumRequired.toFixed(2)}`);
6300
- this.assetName = assetName;
6301
- this.assetValue = assetValue;
6302
- this.minimumRequired = minimumRequired;
6303
- this.name = "MinimumPositionSizeError";
6304
- }
6305
- }
6306
- /**
6307
- * Validates that each asset in a position has at least the minimum USD value
6308
- * @param usdValue Total USD value for the position
6309
- * @param longAssets Array of long assets with weights
6310
- * @param shortAssets Array of short assets with weights
6311
- * @throws MinimumPositionSizeError if any asset has less than the minimum USD value
6312
- */
6313
- function validateMinimumAssetSize(usdValue, longAssets, shortAssets) {
6314
- var _a;
6315
- const allAssets = [...(longAssets || []), ...(shortAssets || [])];
6316
- if (allAssets.length === 0) {
6317
- return; // No assets to validate
6318
- }
6319
- // Calculate total weight
6320
- const totalWeight = allAssets.reduce((sum, asset) => { var _a; return sum + ((_a = asset.weight) !== null && _a !== void 0 ? _a : 0); }, 0);
6321
- // If weights are not provided or sum to 0, assume equal distribution
6322
- const hasWeights = totalWeight > 0;
6323
- const equalWeight = hasWeights ? 0 : 1 / allAssets.length;
6324
- // Validate each asset
6325
- for (const asset of allAssets) {
6326
- const weight = hasWeights ? (_a = asset.weight) !== null && _a !== void 0 ? _a : 0 : equalWeight;
6327
- const assetUsdValue = usdValue * weight;
6328
- if (assetUsdValue < MINIMUM_ASSET_USD_VALUE) {
6329
- throw new MinimumPositionSizeError(asset.asset, assetUsdValue, MINIMUM_ASSET_USD_VALUE);
6330
- }
6331
- }
6332
- }
6333
- /**
6334
- * Calculates the minimum USD value required for a position based on the number of assets
6335
- * @param longAssets Array of long assets
6336
- * @param shortAssets Array of short assets
6337
- * @returns The minimum total USD value required
6338
- */
6339
- function calculateMinimumPositionValue(longAssets, shortAssets) {
6340
- const totalAssets = ((longAssets === null || longAssets === void 0 ? void 0 : longAssets.length) || 0) + ((shortAssets === null || shortAssets === void 0 ? void 0 : shortAssets.length) || 0);
6341
- if (totalAssets === 0) {
6342
- return 0;
6343
- }
6344
- return MINIMUM_ASSET_USD_VALUE * totalAssets;
6345
- }
6346
- /**
6347
- * Validates and provides a user-friendly error message with suggestions
6348
- * @param usdValue Total USD value for the position
6349
- * @param longAssets Array of long assets with weights
6350
- * @param shortAssets Array of short assets with weights
6351
- * @returns Validation result with success flag and optional error message
6352
- */
6353
- function validatePositionSize(usdValue, longAssets, shortAssets) {
6354
- try {
6355
- validateMinimumAssetSize(usdValue, longAssets, shortAssets);
6356
- return { valid: true };
6357
- }
6358
- catch (error) {
6359
- if (error instanceof MinimumPositionSizeError) {
6360
- const minimumRequired = calculateMinimumPositionValue(longAssets, shortAssets);
6361
- return {
6362
- valid: false,
6363
- error: error.message,
6364
- minimumRequired,
6365
- };
6366
- }
6367
- throw error;
6368
- }
6369
- }
6370
-
6371
6412
  /**
6372
6413
  * Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
6373
6414
  * Authorization is derived from headers (Axios defaults or browser localStorage fallback)
6374
6415
  * @throws MinimumPositionSizeError if any asset has less than $11 USD value
6416
+ * @throws MaxAssetsPerLegError if any leg exceeds the maximum allowed assets (15)
6375
6417
  */
6376
6418
  async function createPosition(baseUrl, payload, displayToFull) {
6419
+ // Validate maximum assets per leg before creating position
6420
+ validateMaxAssetsPerLeg(payload.longAssets, payload.shortAssets);
6377
6421
  // Validate minimum asset size before creating position
6378
6422
  validateMinimumAssetSize(payload.usdValue, payload.longAssets, payload.shortAssets);
6379
6423
  const url = joinUrl(baseUrl, "/positions");
@@ -7169,7 +7213,7 @@ const PearHyperliquidContext = createContext(undefined);
7169
7213
  /**
7170
7214
  * React Provider for PearHyperliquidClient
7171
7215
  */
7172
- const PearHyperliquidProvider = ({ children, apiBaseUrl = "https://hl-v2.pearprotocol.io", clientId = "PEARPROTOCOLUI", wsUrl = "wss://hl-v2.pearprotocol.io/ws", }) => {
7216
+ const PearHyperliquidProvider = ({ children, apiBaseUrl = "https://hl-ui.pearprotocol.io", clientId = "PEARPROTOCOLUI", wsUrl = "wss://hl-ui.pearprotocol.io/ws", }) => {
7173
7217
  const address = useUserData((s) => s.address);
7174
7218
  const setAddress = useUserData((s) => s.setAddress);
7175
7219
  const perpsMetaAssets = useHyperliquidData((state) => state.perpMetaAssets);
@@ -7343,4 +7387,4 @@ function mapCandleIntervalToTradingViewInterval(interval) {
7343
7387
  }
7344
7388
  }
7345
7389
 
7346
- 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 };
7390
+ 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.64",
3
+ "version": "0.0.66",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",