@pear-protocol/hyperliquid-sdk 0.0.44 → 0.0.45

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.
package/README.md CHANGED
@@ -37,7 +37,7 @@ yarn add react react-dom
37
37
  ### 1. Wrap your application with the Provider
38
38
 
39
39
  ```tsx
40
- import { PearHyperliquidProvider } from '@pear-protocol/hyperliquid-sdk';
40
+ import { PearHyperliquidProvider } from "@pear-protocol/hyperliquid-sdk";
41
41
 
42
42
  function App() {
43
43
  return (
@@ -59,8 +59,8 @@ import {
59
59
  usePearAuth,
60
60
  usePearHyperliquid,
61
61
  usePosition,
62
- useOrders
63
- } from '@pear-protocol/hyperliquid-sdk';
62
+ useOrders,
63
+ } from "@pear-protocol/hyperliquid-sdk";
64
64
 
65
65
  function TradingComponent() {
66
66
  const { address, setAddress } = usePearHyperliquid();
@@ -78,11 +78,11 @@ function TradingComponent() {
78
78
 
79
79
  The `PearHyperliquidProvider` accepts the following props:
80
80
 
81
- | Prop | Type | Default | Description |
82
- |------|------|---------|-------------|
83
- | `apiBaseUrl` | `string` | `https://hl-v2.pearprotocol.io` | Pear API base URL |
84
- | `wsUrl` | `string` | `wss://hl-v2.pearprotocol.io/ws` | Pear WebSocket URL |
85
- | `clientId` | `string` | `PEARPROTOCOLUI` | Client identifier for authentication |
81
+ | Prop | Type | Default | Description |
82
+ | ------------ | -------- | -------------------------------- | ------------------------------------ |
83
+ | `apiBaseUrl` | `string` | `https://hl-v2.pearprotocol.io` | Pear API base URL |
84
+ | `wsUrl` | `string` | `wss://hl-v2.pearprotocol.io/ws` | Pear WebSocket URL |
85
+ | `clientId` | `string` | `PEARPROTOCOLUI` | Client identifier for authentication |
86
86
 
87
87
  ### Authentication
88
88
 
@@ -91,7 +91,7 @@ The SDK supports two authentication methods:
91
91
  #### EIP-712 Signature Authentication
92
92
 
93
93
  ```tsx
94
- import { usePearAuth } from '@pear-protocol/hyperliquid-sdk';
94
+ import { usePearAuth } from "@pear-protocol/hyperliquid-sdk";
95
95
 
96
96
  function LoginComponent() {
97
97
  const { getEip712, loginWithSignedMessage, isAuthenticated } = usePearAuth();
@@ -111,23 +111,23 @@ function LoginComponent() {
111
111
  await loginWithSignedMessage(address, signature, eip712Data.timestamp);
112
112
  };
113
113
 
114
- return (
115
- <div>
116
- {isAuthenticated ? 'Logged In' : 'Logged Out'}
117
- </div>
118
- );
114
+ return <div>{isAuthenticated ? "Logged In" : "Logged Out"}</div>;
119
115
  }
120
116
  ```
121
117
 
122
118
  #### Privy Token Authentication
123
119
 
124
120
  ```tsx
125
- import { usePearAuth } from '@pear-protocol/hyperliquid-sdk';
121
+ import { usePearAuth } from "@pear-protocol/hyperliquid-sdk";
126
122
 
127
123
  function PrivyLoginComponent() {
128
124
  const { loginWithPrivyToken, isAuthenticated } = usePearAuth();
129
125
 
130
- const handlePrivyLogin = async (address: string, appId: string, accessToken: string) => {
126
+ const handlePrivyLogin = async (
127
+ address: string,
128
+ appId: string,
129
+ accessToken: string
130
+ ) => {
131
131
  await loginWithPrivyToken(address, appId, accessToken);
132
132
  };
133
133
  }
@@ -167,15 +167,15 @@ Authentication state and actions.
167
167
 
168
168
  ```tsx
169
169
  const {
170
- status, // AuthStatus enum
171
- isAuthenticated, // boolean
172
- user, // UserProfile | null
173
- error, // string | null
174
- getEip712, // (address: string) => Promise<EIP712MessageResponse>
170
+ status, // AuthStatus enum
171
+ isAuthenticated, // boolean
172
+ user, // UserProfile | null
173
+ error, // string | null
174
+ getEip712, // (address: string) => Promise<EIP712MessageResponse>
175
175
  loginWithSignedMessage, // (address, signature, timestamp) => Promise<void>
176
- loginWithPrivyToken, // (address, appId, accessToken) => Promise<void>
177
- refreshTokens, // () => Promise<any>
178
- logout, // () => Promise<void>
176
+ loginWithPrivyToken, // (address, appId, accessToken) => Promise<void>
177
+ refreshTokens, // () => Promise<any>
178
+ logout, // () => Promise<void>
179
179
  } = usePearAuth();
180
180
  ```
181
181
 
@@ -185,12 +185,12 @@ Agent wallet management.
185
185
 
186
186
  ```tsx
187
187
  const {
188
- agentWallet, // AgentWalletState
189
- isReady, // boolean
190
- loading, // boolean
191
- error, // string | null
188
+ agentWallet, // AgentWalletState
189
+ isReady, // boolean
190
+ loading, // boolean
191
+ error, // string | null
192
192
  refreshAgentWalletStatus, // () => Promise<any>
193
- createAgentWallet, // () => Promise<any>
193
+ createAgentWallet, // () => Promise<any>
194
194
  notifyAgentWalletApproved, // () => Promise<any>
195
195
  } = usePearAgentWallet();
196
196
  ```
@@ -203,13 +203,13 @@ Manage trading positions.
203
203
 
204
204
  ```tsx
205
205
  const {
206
- createPosition, // (payload) => Promise<ApiResponse<CreatePositionResponseDto>>
207
- updateRiskParameters, // (positionId, payload) => Promise<ApiResponse<UpdateRiskParametersResponseDto>>
208
- closePosition, // (positionId, payload) => Promise<ApiResponse<ClosePositionResponseDto>>
209
- closeAllPositions, // (payload) => Promise<ApiResponse<CloseAllPositionsResponseDto>>
210
- adjustPosition, // (positionId, payload) => Promise<ApiResponse<AdjustPositionResponseDto>>
211
- openPositions, // OpenPositionDto[] | null
212
- isLoading, // boolean
206
+ createPosition, // (payload) => Promise<ApiResponse<CreatePositionResponseDto>>
207
+ updateRiskParameters, // (positionId, payload) => Promise<ApiResponse<UpdateRiskParametersResponseDto>>
208
+ closePosition, // (positionId, payload) => Promise<ApiResponse<ClosePositionResponseDto>>
209
+ closeAllPositions, // (payload) => Promise<ApiResponse<CloseAllPositionsResponseDto>>
210
+ adjustPosition, // (positionId, payload) => Promise<ApiResponse<AdjustPositionResponseDto>>
211
+ openPositions, // OpenPositionDto[] | null
212
+ isLoading, // boolean
213
213
  } = usePosition();
214
214
  ```
215
215
 
@@ -223,13 +223,13 @@ const handleCreatePosition = async () => {
223
223
  const response = await createPosition({
224
224
  leverage: 5,
225
225
  usdValue: 1000,
226
- longAssets: [{ asset: 'ETH', weight: 1 }],
227
- shortAssets: [{ asset: 'BTC', weight: 1 }],
228
- orderType: 'MARKET',
226
+ longAssets: [{ asset: "ETH", weight: 1 }],
227
+ shortAssets: [{ asset: "BTC", weight: 1 }],
228
+ orderType: "MARKET",
229
229
  });
230
- console.log('Position created:', response.data);
230
+ console.log("Position created:", response.data);
231
231
  } catch (error) {
232
- console.error('Failed to create position:', error);
232
+ console.error("Failed to create position:", error);
233
233
  }
234
234
  };
235
235
  ```
@@ -242,11 +242,11 @@ const { closePosition } = usePosition();
242
242
  const handleClosePosition = async (positionId: string) => {
243
243
  try {
244
244
  const response = await closePosition(positionId, {
245
- orderType: 'MARKET',
245
+ orderType: "MARKET",
246
246
  });
247
- console.log('Position closed:', response.data);
247
+ console.log("Position closed:", response.data);
248
248
  } catch (error) {
249
- console.error('Failed to close position:', error);
249
+ console.error("Failed to close position:", error);
250
250
  }
251
251
  };
252
252
  ```
@@ -259,11 +259,11 @@ Manage orders (LIMIT, TP/SL, TWAP).
259
259
 
260
260
  ```tsx
261
261
  const {
262
- adjustOrder, // (orderId, payload) => Promise<ApiResponse<AdjustOrderResponseDto>>
263
- cancelOrder, // (orderId) => Promise<ApiResponse<CancelOrderResponseDto>>
264
- cancelTwapOrder, // (orderId) => Promise<ApiResponse<CancelTwapResponseDto>>
265
- openOrders, // OpenLimitOrderDto[] | null
266
- isLoading, // boolean
262
+ adjustOrder, // (orderId, payload) => Promise<ApiResponse<AdjustOrderResponseDto>>
263
+ cancelOrder, // (orderId) => Promise<ApiResponse<CancelOrderResponseDto>>
264
+ cancelTwapOrder, // (orderId) => Promise<ApiResponse<CancelTwapResponseDto>>
265
+ openOrders, // OpenLimitOrderDto[] | null
266
+ isLoading, // boolean
267
267
  } = useOrders();
268
268
  ```
269
269
 
@@ -275,9 +275,9 @@ const { cancelOrder } = useOrders();
275
275
  const handleCancelOrder = async (orderId: string) => {
276
276
  try {
277
277
  await cancelOrder(orderId);
278
- console.log('Order cancelled successfully');
278
+ console.log("Order cancelled successfully");
279
279
  } catch (error) {
280
- console.error('Failed to cancel order:', error);
280
+ console.error("Failed to cancel order:", error);
281
281
  }
282
282
  };
283
283
  ```
@@ -316,7 +316,7 @@ const { data, isLoading } = useAccountSummary();
316
316
  Access real-time market data from Zustand store.
317
317
 
318
318
  ```tsx
319
- import { useMarketData } from '@pear-protocol/hyperliquid-sdk';
319
+ import { useMarketData } from "@pear-protocol/hyperliquid-sdk";
320
320
 
321
321
  function MarketDataComponent() {
322
322
  const activeAssets = useMarketData((state) => state.activeAssets);
@@ -325,8 +325,8 @@ function MarketDataComponent() {
325
325
  <div>
326
326
  {activeAssets?.active.map((asset, idx) => (
327
327
  <div key={idx}>
328
- Long: {asset.longAssets.map(a => a.asset).join(', ')} vs
329
- Short: {asset.shortAssets.map(a => a.asset).join(', ')}
328
+ Long: {asset.longAssets.map((a) => a.asset).join(", ")} vs Short:{" "}
329
+ {asset.shortAssets.map((a) => a.asset).join(", ")}
330
330
  </div>
331
331
  ))}
332
332
  </div>
@@ -339,16 +339,16 @@ function MarketDataComponent() {
339
339
  Fetch and manage historical price data for tokens.
340
340
 
341
341
  ```tsx
342
- import { useHistoricalPriceData } from '@pear-protocol/hyperliquid-sdk';
342
+ import { useHistoricalPriceData } from "@pear-protocol/hyperliquid-sdk";
343
343
 
344
344
  function ChartComponent() {
345
345
  const { fetchHistoricalData, getTokenData } = useHistoricalPriceData();
346
346
 
347
347
  useEffect(() => {
348
- fetchHistoricalData('ETH', '1d'); // 1 day range
348
+ fetchHistoricalData("ETH", "1d"); // 1 day range
349
349
  }, []);
350
350
 
351
- const ethData = getTokenData('ETH');
351
+ const ethData = getTokenData("ETH");
352
352
  }
353
353
  ```
354
354
 
@@ -357,13 +357,16 @@ function ChartComponent() {
357
357
  Get candle data for basket (multi-asset) positions.
358
358
 
359
359
  ```tsx
360
- import { useBasketCandles } from '@pear-protocol/hyperliquid-sdk';
360
+ import { useBasketCandles } from "@pear-protocol/hyperliquid-sdk";
361
361
 
362
362
  function BasketChartComponent() {
363
363
  const { candles, isLoading, error } = useBasketCandles({
364
- longAssets: [{ symbol: 'ETH', weight: 0.5 }, { symbol: 'BTC', weight: 0.5 }],
365
- shortAssets: [{ symbol: 'SOL', weight: 1 }],
366
- interval: '1h',
364
+ longAssets: [
365
+ { symbol: "ETH", weight: 0.5 },
366
+ { symbol: "BTC", weight: 0.5 },
367
+ ],
368
+ shortAssets: [{ symbol: "SOL", weight: 1 }],
369
+ interval: "1h",
367
370
  lookbackHours: 24,
368
371
  });
369
372
  }
@@ -374,12 +377,12 @@ function BasketChartComponent() {
374
377
  Get metadata for selected tokens including prices, funding, and leverage info.
375
378
 
376
379
  ```tsx
377
- import { useTokenSelectionMetadata } from '@pear-protocol/hyperliquid-sdk';
380
+ import { useTokenSelectionMetadata } from "@pear-protocol/hyperliquid-sdk";
378
381
 
379
382
  function TokenSelector() {
380
383
  const { getMetadata, isLoading } = useTokenSelectionMetadata();
381
384
 
382
- const ethMetadata = getMetadata('ETH');
385
+ const ethMetadata = getMetadata("ETH");
383
386
  // ethMetadata: { currentPrice, priceChange24hPercent, maxLeverage, ... }
384
387
  }
385
388
  ```
@@ -401,17 +404,17 @@ Access HyperLiquid native WebSocket connection (managed by provider).
401
404
  Access TWAP (Time-Weighted Average Price) order monitoring.
402
405
 
403
406
  ```tsx
404
- import { useTwap } from '@pear-protocol/hyperliquid-sdk';
407
+ import { useTwap } from "@pear-protocol/hyperliquid-sdk";
405
408
 
406
409
  function TwapMonitor() {
407
410
  const { twapOrders, isLoading } = useTwap();
408
411
 
409
412
  return (
410
413
  <div>
411
- {twapOrders?.map(order => (
414
+ {twapOrders?.map((order) => (
412
415
  <div key={order.orderId}>
413
416
  Status: {order.status}
414
- Progress: {order.filledUsdValue / order.totalUsdValue * 100}%
417
+ Progress: {(order.filledUsdValue / order.totalUsdValue) * 100}%
415
418
  </div>
416
419
  ))}
417
420
  </div>
@@ -426,14 +429,15 @@ function TwapMonitor() {
426
429
  Access user notifications.
427
430
 
428
431
  ```tsx
429
- import { useNotifications } from '@pear-protocol/hyperliquid-sdk';
432
+ import { useNotifications } from "@pear-protocol/hyperliquid-sdk";
430
433
 
431
434
  function NotificationCenter() {
432
- const { notifications, isLoading, markAsRead, markAllAsRead } = useNotifications();
435
+ const { notifications, isLoading, markAsRead, markAllAsRead } =
436
+ useNotifications();
433
437
 
434
438
  return (
435
439
  <div>
436
- {notifications?.map(notif => (
440
+ {notifications?.map((notif) => (
437
441
  <div key={notif.id} onClick={() => markAsRead(notif.id)}>
438
442
  {notif.category}: {JSON.stringify(notif.parameters)}
439
443
  </div>
@@ -450,7 +454,7 @@ function NotificationCenter() {
450
454
  Calculate account summary with real-time data.
451
455
 
452
456
  ```tsx
453
- import { AccountSummaryCalculator } from '@pear-protocol/hyperliquid-sdk';
457
+ import { AccountSummaryCalculator } from "@pear-protocol/hyperliquid-sdk";
454
458
 
455
459
  const calculator = new AccountSummaryCalculator(webData2);
456
460
  const summary = calculator.calculateAccountSummary(
@@ -466,7 +470,7 @@ const summary = calculator.calculateAccountSummary(
466
470
  Detect position conflicts for new trades.
467
471
 
468
472
  ```tsx
469
- import { ConflictDetector } from '@pear-protocol/hyperliquid-sdk';
473
+ import { ConflictDetector } from "@pear-protocol/hyperliquid-sdk";
470
474
 
471
475
  const conflicts = ConflictDetector.detectConflicts(
472
476
  longTokens,
@@ -480,10 +484,10 @@ const conflicts = ConflictDetector.detectConflicts(
480
484
  Extract token metadata from WebSocket data.
481
485
 
482
486
  ```tsx
483
- import { TokenMetadataExtractor } from '@pear-protocol/hyperliquid-sdk';
487
+ import { TokenMetadataExtractor } from "@pear-protocol/hyperliquid-sdk";
484
488
 
485
489
  const metadata = TokenMetadataExtractor.extractMetadata(
486
- 'ETH',
490
+ "ETH",
487
491
  webData2,
488
492
  allMids,
489
493
  activeAssetData
@@ -501,15 +505,15 @@ import {
501
505
  closePosition,
502
506
  adjustOrder,
503
507
  cancelOrder,
504
- } from '@pear-protocol/hyperliquid-sdk';
508
+ } from "@pear-protocol/hyperliquid-sdk";
505
509
 
506
510
  // All client functions require baseUrl and accessToken
507
511
  const response = await createPosition(baseUrl, accessToken, {
508
512
  leverage: 5,
509
513
  usdValue: 1000,
510
- longAssets: [{ asset: 'ETH', weight: 1 }],
511
- shortAssets: [{ asset: 'BTC', weight: 1 }],
512
- orderType: 'MARKET',
514
+ longAssets: [{ asset: "ETH", weight: 1 }],
515
+ shortAssets: [{ asset: "BTC", weight: 1 }],
516
+ orderType: "MARKET",
513
517
  });
514
518
  ```
515
519
 
@@ -527,7 +531,7 @@ import type {
527
531
  CandleInterval,
528
532
  TokenMetadata,
529
533
  // ... and many more
530
- } from '@pear-protocol/hyperliquid-sdk';
534
+ } from "@pear-protocol/hyperliquid-sdk";
531
535
  ```
532
536
 
533
537
  ## WebSocket Data Flow
@@ -553,7 +557,7 @@ try {
553
557
  await createPosition(payload);
554
558
  } catch (error) {
555
559
  if (error instanceof Error) {
556
- console.error('Error:', error.message);
560
+ console.error("Error:", error.message);
557
561
  }
558
562
  }
559
563
  ```
@@ -581,14 +585,14 @@ When using the SDK, you may want to configure different environments:
581
585
  ### Complete Trading Component
582
586
 
583
587
  ```tsx
584
- import { useState } from 'react';
588
+ import { useState } from "react";
585
589
  import {
586
590
  usePearAuth,
587
591
  usePearHyperliquid,
588
592
  usePosition,
589
593
  useOrders,
590
594
  useAccountSummary,
591
- } from '@pear-protocol/hyperliquid-sdk';
595
+ } from "@pear-protocol/hyperliquid-sdk";
592
596
 
593
597
  function TradingDashboard() {
594
598
  const { address, setAddress, isConnected } = usePearHyperliquid();
@@ -602,12 +606,12 @@ function TradingDashboard() {
602
606
  await createPosition({
603
607
  leverage: 3,
604
608
  usdValue: 500,
605
- longAssets: [{ asset: 'ETH', weight: 1 }],
606
- shortAssets: [{ asset: 'BTC', weight: 1 }],
607
- orderType: 'MARKET',
609
+ longAssets: [{ asset: "ETH", weight: 1 }],
610
+ shortAssets: [{ asset: "BTC", weight: 1 }],
611
+ orderType: "MARKET",
608
612
  });
609
613
  } catch (error) {
610
- console.error('Failed to create position:', error);
614
+ console.error("Failed to create position:", error);
611
615
  }
612
616
  };
613
617
 
@@ -617,24 +621,31 @@ function TradingDashboard() {
617
621
 
618
622
  <div>
619
623
  <h2>Account</h2>
620
- <p>Address: {address || 'Not connected'}</p>
621
- <p>Status: {isAuthenticated ? 'Authenticated' : 'Not authenticated'}</p>
622
- <p>WebSocket: {isConnected ? 'Connected' : 'Disconnected'}</p>
624
+ <p>Address: {address || "Not connected"}</p>
625
+ <p>Status: {isAuthenticated ? "Authenticated" : "Not authenticated"}</p>
626
+ <p>WebSocket: {isConnected ? "Connected" : "Disconnected"}</p>
623
627
  </div>
624
628
 
625
629
  <div>
626
630
  <h2>Account Summary</h2>
627
- <p>Account Value: ${accountSummary?.balanceSummary.marginSummary.accountValue}</p>
631
+ <p>
632
+ Account Value: $
633
+ {accountSummary?.balanceSummary.marginSummary.accountValue}
634
+ </p>
628
635
  <p>Withdrawable: ${accountSummary?.balanceSummary.withdrawable}</p>
629
636
  </div>
630
637
 
631
638
  <div>
632
639
  <h2>Open Positions</h2>
633
- {openPositions?.map(pos => (
640
+ {openPositions?.map((pos) => (
634
641
  <div key={pos.positionId}>
635
642
  <p>PNL: ${pos.unrealizedPnl.toFixed(2)}</p>
636
643
  <p>Value: ${pos.positionValue.toFixed(2)}</p>
637
- <button onClick={() => closePosition(pos.positionId, { orderType: 'MARKET' })}>
644
+ <button
645
+ onClick={() =>
646
+ closePosition(pos.positionId, { orderType: "MARKET" })
647
+ }
648
+ >
638
649
  Close
639
650
  </button>
640
651
  </div>
@@ -643,7 +654,7 @@ function TradingDashboard() {
643
654
 
644
655
  <div>
645
656
  <h2>Open Orders</h2>
646
- {openOrders?.map(order => (
657
+ {openOrders?.map((order) => (
647
658
  <div key={order.orderId}>
648
659
  <p>Type: {order.orderType}</p>
649
660
  <p>Value: ${order.usdValue}</p>
@@ -652,9 +663,7 @@ function TradingDashboard() {
652
663
  ))}
653
664
  </div>
654
665
 
655
- <button onClick={handleCreatePosition}>
656
- Create New Position
657
- </button>
666
+ <button onClick={handleCreatePosition}>Create New Position</button>
658
667
  </div>
659
668
  );
660
669
  }
@@ -669,7 +678,7 @@ import {
669
678
  useMarketData,
670
679
  useTokenSelectionMetadata,
671
680
  useHyperliquidWebSocket,
672
- } from '@pear-protocol/hyperliquid-sdk';
681
+ } from "@pear-protocol/hyperliquid-sdk";
673
682
 
674
683
  function MarketOverview() {
675
684
  const activeAssets = useMarketData((state) => state.activeAssets);
@@ -684,7 +693,9 @@ function MarketOverview() {
684
693
 
685
694
  return (
686
695
  <div key={idx}>
687
- <p>{longAsset}: {metadata?.priceChange24hPercent.toFixed(2)}%</p>
696
+ <p>
697
+ {longAsset}: {metadata?.priceChange24hPercent.toFixed(2)}%
698
+ </p>
688
699
  </div>
689
700
  );
690
701
  })}
@@ -696,7 +707,9 @@ function MarketOverview() {
696
707
 
697
708
  return (
698
709
  <div key={idx}>
699
- <p>{shortAsset}: {metadata?.priceChange24hPercent.toFixed(2)}%</p>
710
+ <p>
711
+ {shortAsset}: {metadata?.priceChange24hPercent.toFixed(2)}%
712
+ </p>
700
713
  </div>
701
714
  );
702
715
  })}
@@ -1,7 +1,7 @@
1
- import type { ApiResponse } from '../types';
2
- import type { CancelTwapResponseDto } from './orders';
3
- export type ExecutionType = 'MARKET' | 'LIMIT' | 'TWAP' | 'LADDER' | 'LIMIT_BTCDOM';
4
- export type TpSlThresholdType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
1
+ import type { ApiResponse } from "../types";
2
+ import type { CancelTwapResponseDto } from "./orders";
3
+ export type ExecutionType = "MARKET" | "LIMIT" | "TWAP" | "LADDER" | "LIMIT_BTCDOM";
4
+ export type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
5
5
  export interface PairAssetInput {
6
6
  asset: string;
7
7
  weight?: number;
@@ -23,7 +23,7 @@ export interface CreatePositionRequestInput {
23
23
  longAssets?: PairAssetInput[];
24
24
  shortAssets?: PairAssetInput[];
25
25
  triggerValue?: number;
26
- direction?: 'MORE_THAN' | 'LESS_THAN';
26
+ direction?: "MORE_THAN" | "LESS_THAN";
27
27
  twapDuration?: number;
28
28
  twapIntervalSeconds?: number;
29
29
  randomizeExecution?: boolean;
@@ -31,10 +31,10 @@ export interface CreatePositionRequestInput {
31
31
  takeProfit?: TpSlThresholdInput | null;
32
32
  stopLoss?: TpSlThresholdInput | null;
33
33
  }
34
- export type PositionResponseStatus = 'SUCCESS' | 'FAILED' | 'PENDING' | 'PARTIALLY_FILLED' | 'OPEN';
34
+ export type PositionResponseStatus = "SUCCESS" | "FAILED" | "PENDING" | "PARTIALLY_FILLED" | "OPEN";
35
35
  export interface PositionAssetSummaryDto {
36
36
  asset: string;
37
- side: 'LONG' | 'SHORT';
37
+ side: "LONG" | "SHORT";
38
38
  size: number;
39
39
  entryRatio: number;
40
40
  usdValue: number;
@@ -53,6 +53,7 @@ export interface CreatePositionResponseDto {
53
53
  /**
54
54
  * Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
55
55
  * Caller should supply an accessToken from localStorage.getItem('accessToken')
56
+ * @throws MinimumPositionSizeError if any asset has less than $11 USD value
56
57
  */
57
58
  export declare function createPosition(baseUrl: string, accessToken: string, payload: CreatePositionRequestInput): Promise<ApiResponse<CreatePositionResponseDto>>;
58
59
  export interface UpdateRiskParametersRequestInput {
@@ -66,7 +67,7 @@ export interface UpdateRiskParametersResponseDto {
66
67
  updatedAt: string;
67
68
  }
68
69
  export declare function updateRiskParameters(baseUrl: string, accessToken: string, positionId: string, payload: UpdateRiskParametersRequestInput): Promise<ApiResponse<UpdateRiskParametersResponseDto>>;
69
- export type CloseExecutionType = 'MARKET' | 'TWAP';
70
+ export type CloseExecutionType = "MARKET" | "TWAP";
70
71
  export interface ClosePositionRequestInput {
71
72
  executionType: CloseExecutionType;
72
73
  twapDuration?: number;
@@ -89,8 +90,8 @@ export interface CloseAllPositionsResponseDto {
89
90
  results: CloseAllPositionsResultDto[];
90
91
  }
91
92
  export declare function closeAllPositions(baseUrl: string, accessToken: string, payload: ClosePositionRequestInput): Promise<ApiResponse<CloseAllPositionsResponseDto>>;
92
- export type AdjustExecutionType = 'MARKET' | 'LIMIT';
93
- export type PositionAdjustmentType = 'REDUCE' | 'INCREASE';
93
+ export type AdjustExecutionType = "MARKET" | "LIMIT";
94
+ export type PositionAdjustmentType = "REDUCE" | "INCREASE";
94
95
  export interface AdjustPositionRequestInput {
95
96
  adjustmentType: PositionAdjustmentType;
96
97
  adjustmentSize: number;
package/dist/index.d.ts CHANGED
@@ -872,8 +872,8 @@ interface CancelTwapResponseDto {
872
872
  }
873
873
  declare function cancelTwapOrder(baseUrl: string, accessToken: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
874
874
 
875
- type ExecutionType = 'MARKET' | 'LIMIT' | 'TWAP' | 'LADDER' | 'LIMIT_BTCDOM';
876
- type TpSlThresholdType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
875
+ type ExecutionType = "MARKET" | "LIMIT" | "TWAP" | "LADDER" | "LIMIT_BTCDOM";
876
+ type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE";
877
877
  interface PairAssetInput {
878
878
  asset: string;
879
879
  weight?: number;
@@ -895,7 +895,7 @@ interface CreatePositionRequestInput {
895
895
  longAssets?: PairAssetInput[];
896
896
  shortAssets?: PairAssetInput[];
897
897
  triggerValue?: number;
898
- direction?: 'MORE_THAN' | 'LESS_THAN';
898
+ direction?: "MORE_THAN" | "LESS_THAN";
899
899
  twapDuration?: number;
900
900
  twapIntervalSeconds?: number;
901
901
  randomizeExecution?: boolean;
@@ -903,10 +903,10 @@ interface CreatePositionRequestInput {
903
903
  takeProfit?: TpSlThresholdInput | null;
904
904
  stopLoss?: TpSlThresholdInput | null;
905
905
  }
906
- type PositionResponseStatus = 'SUCCESS' | 'FAILED' | 'PENDING' | 'PARTIALLY_FILLED' | 'OPEN';
906
+ type PositionResponseStatus = "SUCCESS" | "FAILED" | "PENDING" | "PARTIALLY_FILLED" | "OPEN";
907
907
  interface PositionAssetSummaryDto {
908
908
  asset: string;
909
- side: 'LONG' | 'SHORT';
909
+ side: "LONG" | "SHORT";
910
910
  size: number;
911
911
  entryRatio: number;
912
912
  usdValue: number;
@@ -925,6 +925,7 @@ interface CreatePositionResponseDto {
925
925
  /**
926
926
  * Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
927
927
  * Caller should supply an accessToken from localStorage.getItem('accessToken')
928
+ * @throws MinimumPositionSizeError if any asset has less than $11 USD value
928
929
  */
929
930
  declare function createPosition(baseUrl: string, accessToken: string, payload: CreatePositionRequestInput): Promise<ApiResponse<CreatePositionResponseDto>>;
930
931
  interface UpdateRiskParametersRequestInput {
@@ -938,7 +939,7 @@ interface UpdateRiskParametersResponseDto {
938
939
  updatedAt: string;
939
940
  }
940
941
  declare function updateRiskParameters(baseUrl: string, accessToken: string, positionId: string, payload: UpdateRiskParametersRequestInput): Promise<ApiResponse<UpdateRiskParametersResponseDto>>;
941
- type CloseExecutionType = 'MARKET' | 'TWAP';
942
+ type CloseExecutionType = "MARKET" | "TWAP";
942
943
  interface ClosePositionRequestInput {
943
944
  executionType: CloseExecutionType;
944
945
  twapDuration?: number;
@@ -961,8 +962,8 @@ interface CloseAllPositionsResponseDto {
961
962
  results: CloseAllPositionsResultDto[];
962
963
  }
963
964
  declare function closeAllPositions(baseUrl: string, accessToken: string, payload: ClosePositionRequestInput): Promise<ApiResponse<CloseAllPositionsResponseDto>>;
964
- type AdjustExecutionType = 'MARKET' | 'LIMIT';
965
- type PositionAdjustmentType = 'REDUCE' | 'INCREASE';
965
+ type AdjustExecutionType = "MARKET" | "LIMIT";
966
+ type PositionAdjustmentType = "REDUCE" | "INCREASE";
966
967
  interface AdjustPositionRequestInput {
967
968
  adjustmentType: PositionAdjustmentType;
968
969
  adjustmentSize: number;
@@ -1171,7 +1172,48 @@ declare function mapTradingViewIntervalToCandleInterval(interval: string): Candl
1171
1172
  */
1172
1173
  declare function mapCandleIntervalToTradingViewInterval(interval: CandleInterval): string;
1173
1174
 
1175
+ /**
1176
+ * Minimum USD value required per asset when creating a position
1177
+ */
1178
+ declare const MINIMUM_ASSET_USD_VALUE = 11;
1179
+ /**
1180
+ * Validation error for minimum position size
1181
+ */
1182
+ declare class MinimumPositionSizeError extends Error {
1183
+ assetName: string;
1184
+ assetValue: number;
1185
+ minimumRequired: number;
1186
+ constructor(assetName: string, assetValue: number, minimumRequired: number);
1187
+ }
1188
+ /**
1189
+ * Validates that each asset in a position has at least the minimum USD value
1190
+ * @param usdValue Total USD value for the position
1191
+ * @param longAssets Array of long assets with weights
1192
+ * @param shortAssets Array of short assets with weights
1193
+ * @throws MinimumPositionSizeError if any asset has less than the minimum USD value
1194
+ */
1195
+ declare function validateMinimumAssetSize(usdValue: number, longAssets?: PairAssetInput[], shortAssets?: PairAssetInput[]): void;
1196
+ /**
1197
+ * Calculates the minimum USD value required for a position based on the number of assets
1198
+ * @param longAssets Array of long assets
1199
+ * @param shortAssets Array of short assets
1200
+ * @returns The minimum total USD value required
1201
+ */
1202
+ declare function calculateMinimumPositionValue(longAssets?: PairAssetInput[], shortAssets?: PairAssetInput[]): number;
1203
+ /**
1204
+ * Validates and provides a user-friendly error message with suggestions
1205
+ * @param usdValue Total USD value for the position
1206
+ * @param longAssets Array of long assets with weights
1207
+ * @param shortAssets Array of short assets with weights
1208
+ * @returns Validation result with success flag and optional error message
1209
+ */
1210
+ declare function validatePositionSize(usdValue: number, longAssets?: PairAssetInput[], shortAssets?: PairAssetInput[]): {
1211
+ valid: boolean;
1212
+ error?: string;
1213
+ minimumRequired?: number;
1214
+ };
1215
+
1174
1216
  declare const useMarketData: any;
1175
1217
 
1176
- export { AccountSummaryCalculator, AuthStatus, ConflictDetector, PearHyperliquidProvider, TokenMetadataExtractor, adjustOrder, adjustPosition, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, 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, useWatchlist, useWatchlistBaskets, useWebData };
1218
+ export { AccountSummaryCalculator, AuthStatus, ConflictDetector, MINIMUM_ASSET_USD_VALUE, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, 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, useWatchlist, useWatchlistBaskets, useWebData, validateMinimumAssetSize, validatePositionSize };
1177
1219
  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, ToggleWatchlistResponseDto, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlThresholdInput, TpSlThresholdType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TwapChunkStatusDto, TwapMonitoringDto, UniverseAsset, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAgentWalletOptions, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseNotificationsResult, UsePerformanceOverlaysReturn, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WatchlistItemDto, WebData2Response, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
package/dist/index.js CHANGED
@@ -8364,15 +8364,109 @@ function useAutoSyncFills(options) {
8364
8364
  };
8365
8365
  }
8366
8366
 
8367
+ /**
8368
+ * Minimum USD value required per asset when creating a position
8369
+ */
8370
+ const MINIMUM_ASSET_USD_VALUE = 11;
8371
+ /**
8372
+ * Validation error for minimum position size
8373
+ */
8374
+ class MinimumPositionSizeError extends Error {
8375
+ constructor(assetName, assetValue, minimumRequired) {
8376
+ super(`Asset "${assetName}" has a USD value of $${assetValue.toFixed(2)}, which is below the minimum required value of $${minimumRequired.toFixed(2)}`);
8377
+ this.assetName = assetName;
8378
+ this.assetValue = assetValue;
8379
+ this.minimumRequired = minimumRequired;
8380
+ this.name = "MinimumPositionSizeError";
8381
+ }
8382
+ }
8383
+ /**
8384
+ * Validates that each asset in a position has at least the minimum USD value
8385
+ * @param usdValue Total USD value for the position
8386
+ * @param longAssets Array of long assets with weights
8387
+ * @param shortAssets Array of short assets with weights
8388
+ * @throws MinimumPositionSizeError if any asset has less than the minimum USD value
8389
+ */
8390
+ function validateMinimumAssetSize(usdValue, longAssets, shortAssets) {
8391
+ var _a;
8392
+ const allAssets = [...(longAssets || []), ...(shortAssets || [])];
8393
+ if (allAssets.length === 0) {
8394
+ return; // No assets to validate
8395
+ }
8396
+ // Calculate total weight
8397
+ const totalWeight = allAssets.reduce((sum, asset) => { var _a; return sum + ((_a = asset.weight) !== null && _a !== void 0 ? _a : 0); }, 0);
8398
+ // If weights are not provided or sum to 0, assume equal distribution
8399
+ const hasWeights = totalWeight > 0;
8400
+ const equalWeight = hasWeights ? 0 : 1 / allAssets.length;
8401
+ // Validate each asset
8402
+ for (const asset of allAssets) {
8403
+ const weight = hasWeights ? (_a = asset.weight) !== null && _a !== void 0 ? _a : 0 : equalWeight;
8404
+ const assetUsdValue = usdValue * weight;
8405
+ if (assetUsdValue < MINIMUM_ASSET_USD_VALUE) {
8406
+ throw new MinimumPositionSizeError(asset.asset, assetUsdValue, MINIMUM_ASSET_USD_VALUE);
8407
+ }
8408
+ }
8409
+ }
8410
+ /**
8411
+ * Calculates the minimum USD value required for a position based on the number of assets
8412
+ * @param longAssets Array of long assets
8413
+ * @param shortAssets Array of short assets
8414
+ * @returns The minimum total USD value required
8415
+ */
8416
+ function calculateMinimumPositionValue(longAssets, shortAssets) {
8417
+ const totalAssets = ((longAssets === null || longAssets === void 0 ? void 0 : longAssets.length) || 0) + ((shortAssets === null || shortAssets === void 0 ? void 0 : shortAssets.length) || 0);
8418
+ if (totalAssets === 0) {
8419
+ return 0;
8420
+ }
8421
+ return MINIMUM_ASSET_USD_VALUE * totalAssets;
8422
+ }
8423
+ /**
8424
+ * Validates and provides a user-friendly error message with suggestions
8425
+ * @param usdValue Total USD value for the position
8426
+ * @param longAssets Array of long assets with weights
8427
+ * @param shortAssets Array of short assets with weights
8428
+ * @returns Validation result with success flag and optional error message
8429
+ */
8430
+ function validatePositionSize(usdValue, longAssets, shortAssets) {
8431
+ try {
8432
+ validateMinimumAssetSize(usdValue, longAssets, shortAssets);
8433
+ return { valid: true };
8434
+ }
8435
+ catch (error) {
8436
+ if (error instanceof MinimumPositionSizeError) {
8437
+ const minimumRequired = calculateMinimumPositionValue(longAssets, shortAssets);
8438
+ return {
8439
+ valid: false,
8440
+ error: error.message,
8441
+ minimumRequired,
8442
+ };
8443
+ }
8444
+ throw error;
8445
+ }
8446
+ }
8447
+
8367
8448
  /**
8368
8449
  * Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
8369
8450
  * Caller should supply an accessToken from localStorage.getItem('accessToken')
8451
+ * @throws MinimumPositionSizeError if any asset has less than $11 USD value
8370
8452
  */
8371
8453
  async function createPosition(baseUrl, accessToken, payload) {
8372
- const url = joinUrl(baseUrl, '/positions');
8454
+ // Validate minimum asset size before creating position
8455
+ validateMinimumAssetSize(payload.usdValue, payload.longAssets, payload.shortAssets);
8456
+ const url = joinUrl(baseUrl, "/positions");
8373
8457
  try {
8374
- const resp = await axios$1.post(url, payload, { headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}` }, timeout: 60000 });
8375
- return { data: resp.data, status: resp.status, headers: resp.headers };
8458
+ const resp = await axios$1.post(url, payload, {
8459
+ headers: {
8460
+ "Content-Type": "application/json",
8461
+ Authorization: `Bearer ${accessToken}`,
8462
+ },
8463
+ timeout: 60000,
8464
+ });
8465
+ return {
8466
+ data: resp.data,
8467
+ status: resp.status,
8468
+ headers: resp.headers,
8469
+ };
8376
8470
  }
8377
8471
  catch (error) {
8378
8472
  throw toApiError(error);
@@ -8381,8 +8475,18 @@ async function createPosition(baseUrl, accessToken, payload) {
8381
8475
  async function updateRiskParameters(baseUrl, accessToken, positionId, payload) {
8382
8476
  const url = joinUrl(baseUrl, `/positions/${positionId}/riskParameters`);
8383
8477
  try {
8384
- const resp = await axios$1.put(url, payload, { headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}` }, timeout: 60000 });
8385
- return { data: resp.data, status: resp.status, headers: resp.headers };
8478
+ const resp = await axios$1.put(url, payload, {
8479
+ headers: {
8480
+ "Content-Type": "application/json",
8481
+ Authorization: `Bearer ${accessToken}`,
8482
+ },
8483
+ timeout: 60000,
8484
+ });
8485
+ return {
8486
+ data: resp.data,
8487
+ status: resp.status,
8488
+ headers: resp.headers,
8489
+ };
8386
8490
  }
8387
8491
  catch (error) {
8388
8492
  throw toApiError(error);
@@ -8391,8 +8495,18 @@ async function updateRiskParameters(baseUrl, accessToken, positionId, payload) {
8391
8495
  async function closePosition(baseUrl, accessToken, positionId, payload) {
8392
8496
  const url = joinUrl(baseUrl, `/positions/${positionId}/close`);
8393
8497
  try {
8394
- const resp = await axios$1.post(url, payload, { headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}` }, timeout: 60000 });
8395
- return { data: resp.data, status: resp.status, headers: resp.headers };
8498
+ const resp = await axios$1.post(url, payload, {
8499
+ headers: {
8500
+ "Content-Type": "application/json",
8501
+ Authorization: `Bearer ${accessToken}`,
8502
+ },
8503
+ timeout: 60000,
8504
+ });
8505
+ return {
8506
+ data: resp.data,
8507
+ status: resp.status,
8508
+ headers: resp.headers,
8509
+ };
8396
8510
  }
8397
8511
  catch (error) {
8398
8512
  throw toApiError(error);
@@ -8401,8 +8515,18 @@ async function closePosition(baseUrl, accessToken, positionId, payload) {
8401
8515
  async function closeAllPositions(baseUrl, accessToken, payload) {
8402
8516
  const url = joinUrl(baseUrl, `/positions/close-all`);
8403
8517
  try {
8404
- const resp = await axios$1.post(url, payload, { headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}` }, timeout: 60000 });
8405
- return { data: resp.data, status: resp.status, headers: resp.headers };
8518
+ const resp = await axios$1.post(url, payload, {
8519
+ headers: {
8520
+ "Content-Type": "application/json",
8521
+ Authorization: `Bearer ${accessToken}`,
8522
+ },
8523
+ timeout: 60000,
8524
+ });
8525
+ return {
8526
+ data: resp.data,
8527
+ status: resp.status,
8528
+ headers: resp.headers,
8529
+ };
8406
8530
  }
8407
8531
  catch (error) {
8408
8532
  throw toApiError(error);
@@ -8411,8 +8535,18 @@ async function closeAllPositions(baseUrl, accessToken, payload) {
8411
8535
  async function adjustPosition(baseUrl, accessToken, positionId, payload) {
8412
8536
  const url = joinUrl(baseUrl, `/positions/${positionId}/adjust`);
8413
8537
  try {
8414
- const resp = await axios$1.post(url, payload, { headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}` }, timeout: 60000 });
8415
- return { data: resp.data, status: resp.status, headers: resp.headers };
8538
+ const resp = await axios$1.post(url, payload, {
8539
+ headers: {
8540
+ "Content-Type": "application/json",
8541
+ Authorization: `Bearer ${accessToken}`,
8542
+ },
8543
+ timeout: 60000,
8544
+ });
8545
+ return {
8546
+ data: resp.data,
8547
+ status: resp.status,
8548
+ headers: resp.headers,
8549
+ };
8416
8550
  }
8417
8551
  catch (error) {
8418
8552
  throw toApiError(error);
@@ -8423,8 +8557,18 @@ async function adjustPosition(baseUrl, accessToken, positionId, payload) {
8423
8557
  async function cancelTwap(baseUrl, accessToken, orderId) {
8424
8558
  const url = joinUrl(baseUrl, `/orders/${orderId}/twap/cancel`);
8425
8559
  try {
8426
- const resp = await axios$1.post(url, {}, { headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}` }, timeout: 60000 });
8427
- return { data: resp.data, status: resp.status, headers: resp.headers };
8560
+ const resp = await axios$1.post(url, {}, {
8561
+ headers: {
8562
+ "Content-Type": "application/json",
8563
+ Authorization: `Bearer ${accessToken}`,
8564
+ },
8565
+ timeout: 60000,
8566
+ });
8567
+ return {
8568
+ data: resp.data,
8569
+ status: resp.status,
8570
+ headers: resp.headers,
8571
+ };
8428
8572
  }
8429
8573
  catch (error) {
8430
8574
  throw toApiError(error);
@@ -9125,4 +9269,4 @@ function mapCandleIntervalToTradingViewInterval(interval) {
9125
9269
  }
9126
9270
  }
9127
9271
 
9128
- export { AccountSummaryCalculator, AuthStatus, ConflictDetector, PearHyperliquidProvider, TokenMetadataExtractor, adjustOrder, adjustPosition, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, 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, useWatchlist, useWatchlistBaskets, useWebData };
9272
+ export { AccountSummaryCalculator, AuthStatus, ConflictDetector, MINIMUM_ASSET_USD_VALUE, MinimumPositionSizeError, PearHyperliquidProvider, TokenMetadataExtractor, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, 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, useWatchlist, useWatchlistBaskets, useWebData, validateMinimumAssetSize, validatePositionSize };
@@ -0,0 +1,41 @@
1
+ import type { PairAssetInput } from "../clients/positions";
2
+ /**
3
+ * Minimum USD value required per asset when creating a position
4
+ */
5
+ export declare const MINIMUM_ASSET_USD_VALUE = 11;
6
+ /**
7
+ * Validation error for minimum position size
8
+ */
9
+ export declare class MinimumPositionSizeError extends Error {
10
+ assetName: string;
11
+ assetValue: number;
12
+ minimumRequired: number;
13
+ constructor(assetName: string, assetValue: number, minimumRequired: number);
14
+ }
15
+ /**
16
+ * Validates that each asset in a position has at least the minimum USD value
17
+ * @param usdValue Total USD value for the position
18
+ * @param longAssets Array of long assets with weights
19
+ * @param shortAssets Array of short assets with weights
20
+ * @throws MinimumPositionSizeError if any asset has less than the minimum USD value
21
+ */
22
+ export declare function validateMinimumAssetSize(usdValue: number, longAssets?: PairAssetInput[], shortAssets?: PairAssetInput[]): void;
23
+ /**
24
+ * Calculates the minimum USD value required for a position based on the number of assets
25
+ * @param longAssets Array of long assets
26
+ * @param shortAssets Array of short assets
27
+ * @returns The minimum total USD value required
28
+ */
29
+ export declare function calculateMinimumPositionValue(longAssets?: PairAssetInput[], shortAssets?: PairAssetInput[]): number;
30
+ /**
31
+ * Validates and provides a user-friendly error message with suggestions
32
+ * @param usdValue Total USD value for the position
33
+ * @param longAssets Array of long assets with weights
34
+ * @param shortAssets Array of short assets with weights
35
+ * @returns Validation result with success flag and optional error message
36
+ */
37
+ export declare function validatePositionSize(usdValue: number, longAssets?: PairAssetInput[], shortAssets?: PairAssetInput[]): {
38
+ valid: boolean;
39
+ error?: string;
40
+ minimumRequired?: number;
41
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.0.44",
3
+ "version": "0.0.45",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",