@pear-protocol/hyperliquid-sdk 0.1.0 → 0.1.1-9.2-pnl

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/dist/index.d.ts CHANGED
@@ -60,6 +60,11 @@ interface ExternalFillDto {
60
60
  feeToken?: string | null;
61
61
  liquidation?: ExternalLiquidationDto | null;
62
62
  }
63
+ interface SyncFillsRequestDto {
64
+ user: string;
65
+ fills: ExternalFillDto[];
66
+ assetPositions?: AssetPosition[];
67
+ }
63
68
  interface SyncFillsResponseDto {
64
69
  insertedFills: number;
65
70
  skippedDuplicates: number;
@@ -76,6 +81,12 @@ interface TwapSliceFillResponseItem {
76
81
  * WebSocket connection states
77
82
  */
78
83
  type WebSocketConnectionState = 'connecting' | 'connected' | 'disconnected' | 'error';
84
+ declare enum ReadyState {
85
+ CONNECTING = 0,
86
+ OPEN = 1,
87
+ CLOSING = 2,
88
+ CLOSED = 3
89
+ }
79
90
  /**
80
91
  * WebSocket channels
81
92
  */
@@ -217,6 +228,7 @@ interface TwapMonitoringDto {
217
228
  interface TradeHistoryAssetDataDto {
218
229
  coin: string;
219
230
  entryWeight: number;
231
+ closeWeight: number;
220
232
  entryPrice: number;
221
233
  limitPrice: number;
222
234
  leverage: number;
@@ -272,7 +284,9 @@ interface PositionAssetDetailDto {
272
284
  unrealizedPnl: number;
273
285
  liquidationPrice: number;
274
286
  initialWeight: number;
287
+ currentWeight: number;
275
288
  fundingPaid?: number;
289
+ targetWeight?: number;
276
290
  metadata?: TokenMetadata | null;
277
291
  }
278
292
  interface TpSlThreshold {
@@ -327,7 +341,7 @@ type TpSlTriggerType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE' | 'PRICE' | 'P
327
341
  /**
328
342
  * Trigger type for trigger orders
329
343
  */
330
- type TriggerType$1 = 'PRICE' | 'PRICE_RATIO' | 'WEIGHTED_RATIO' | 'BTC_DOM' | 'CROSS_ASSET_PRICE' | 'PREDICTION_MARKET_OUTCOME';
344
+ type TriggerType = 'PRICE' | 'PRICE_RATIO' | 'WEIGHTED_RATIO' | 'BTC_DOM' | 'CROSS_ASSET_PRICE' | 'PREDICTION_MARKET_OUTCOME';
331
345
  type OrderDirection = 'MORE_THAN' | 'LESS_THAN';
332
346
  /**
333
347
  * Market order parameters
@@ -343,7 +357,7 @@ interface MarketOrderParameters {
343
357
  interface TriggerOrderParameters {
344
358
  leverage: number;
345
359
  usdValue: number;
346
- triggerType: TriggerType$1;
360
+ triggerType: TriggerType;
347
361
  triggerValue: number;
348
362
  direction: OrderDirection;
349
363
  reduceOnly?: boolean;
@@ -455,6 +469,15 @@ interface AccountSummaryResponseDto {
455
469
  platformAccountSummary: PlatformAccountSummaryResponseDto | null;
456
470
  agentWallet?: AgentWalletDto;
457
471
  }
472
+ /**
473
+ * Address management state
474
+ */
475
+ interface AddressState {
476
+ currentAddress: string | null;
477
+ isLoggedIn: boolean;
478
+ autoConnect: boolean;
479
+ previousAddresses: string[];
480
+ }
458
481
  interface UseAuthOptions {
459
482
  baseUrl: string;
460
483
  clientId: string;
@@ -481,13 +504,50 @@ interface EIP712AuthDetails {
481
504
  }
482
505
  interface GetEIP712MessageResponse extends EIP712AuthDetails {
483
506
  }
507
+ interface PrivyAuthDetails {
508
+ appId: string;
509
+ accessToken: string;
510
+ }
511
+ interface AuthenticateRequest {
512
+ method: 'eip712' | 'api_key' | 'privy_access_token';
513
+ address: string;
514
+ clientId: string;
515
+ details: {
516
+ signature: string;
517
+ timestamp: number;
518
+ } | {
519
+ apiKey: string;
520
+ } | PrivyAuthDetails;
521
+ }
522
+ interface AuthenticateResponse {
523
+ accessToken: string;
524
+ refreshToken: string;
525
+ tokenType: string;
526
+ expiresIn: number;
527
+ address: string;
528
+ clientId: string;
529
+ }
530
+ interface RefreshTokenRequest {
531
+ refreshToken: string;
532
+ }
484
533
  interface RefreshTokenResponse {
485
534
  accessToken: string;
486
535
  refreshToken: string;
487
536
  tokenType: string;
488
537
  expiresIn: number;
489
538
  }
539
+ interface LogoutRequest {
540
+ refreshToken: string;
541
+ }
542
+ interface LogoutResponse {
543
+ message: string;
544
+ }
490
545
  type AgentWalletStatus = 'ACTIVE' | 'EXPIRED' | 'NOT_FOUND';
546
+ interface GetAgentWalletResponseDto {
547
+ agentWalletAddress?: string;
548
+ agentName: string;
549
+ status: AgentWalletStatus;
550
+ }
491
551
  interface CreateAgentWalletResponseDto {
492
552
  agentWalletAddress: string;
493
553
  message: string;
@@ -534,6 +594,7 @@ interface HLChannelDataMap {
534
594
  allDexsAssetCtxs: AllDexsAssetCtxsData;
535
595
  userFills: any;
536
596
  }
597
+ type UserAbstraction = 'dexAbstraction' | 'disabled' | 'unifiedAccount' | 'portfolioMargin';
537
598
  interface WebData3UserState {
538
599
  agentAddress?: string;
539
600
  agentValidUntil?: number;
@@ -542,6 +603,7 @@ interface WebData3UserState {
542
603
  isVault: boolean;
543
604
  user: string;
544
605
  dexAbstractionEnabled?: boolean;
606
+ abstraction: UserAbstraction;
545
607
  }
546
608
  interface WebData3AssetCtx {
547
609
  funding: string;
@@ -599,8 +661,10 @@ interface AssetCtx {
599
661
  * Collateral token type
600
662
  * 0 = USDC
601
663
  * 360 = USDH
664
+ * 235 = USDE
665
+ * 268 = USDT0
602
666
  */
603
- type CollateralToken = 'USDC' | 'USDH';
667
+ type CollateralToken = 'USDC' | 'USDH' | 'USDE' | 'USDT0';
604
668
  /**
605
669
  * Universe asset metadata
606
670
  */
@@ -612,6 +676,24 @@ interface UniverseAsset {
612
676
  isDelisted?: boolean;
613
677
  collateralToken: CollateralToken;
614
678
  }
679
+ interface PerpMetaAsset extends UniverseAsset {
680
+ marginTableId: number;
681
+ }
682
+ interface MarginTier {
683
+ lowerBound: string;
684
+ maxLeverage: number;
685
+ }
686
+ interface MarginTableDef {
687
+ description: string;
688
+ marginTiers: MarginTier[];
689
+ }
690
+ type MarginTablesEntry = [number, MarginTableDef];
691
+ interface AllPerpMetasItem {
692
+ universe: PerpMetaAsset[];
693
+ marginTables: MarginTablesEntry[];
694
+ collateralToken: number;
695
+ }
696
+ type AllPerpMetasResponse = AllPerpMetasItem[];
615
697
  interface ClearinghouseState {
616
698
  assetPositions: AssetPosition[];
617
699
  crossMaintenanceMarginUsed: string;
@@ -682,6 +764,7 @@ interface RawAssetDto {
682
764
  side: string;
683
765
  fundingPaid?: number;
684
766
  leverage: number;
767
+ targetWeight?: number;
685
768
  }
686
769
  /**
687
770
  * Raw position data from open-positions channel
@@ -757,6 +840,7 @@ interface AssetMarketData {
757
840
  interface PairAssetDto {
758
841
  asset: string;
759
842
  weight: number;
843
+ metadata?: TokenMetadata | null;
760
844
  }
761
845
  interface ActiveAssetGroupItem {
762
846
  longAssets: PairAssetDto[];
@@ -770,7 +854,6 @@ interface ActiveAssetGroupItem {
770
854
  weightedRatio?: string;
771
855
  weightedPrevRatio?: string;
772
856
  weightedChange24h?: string;
773
- collateralType: 'USDC' | 'USDH' | 'MIXED';
774
857
  }
775
858
  interface ActiveAssetsResponse {
776
859
  active: ActiveAssetGroupItem[];
@@ -779,6 +862,12 @@ interface ActiveAssetsResponse {
779
862
  highlighted: ActiveAssetGroupItem[];
780
863
  watchlist: ActiveAssetGroupItem[];
781
864
  }
865
+ interface ActiveAssetsAllResponse {
866
+ active: ActiveAssetGroupItem[];
867
+ all: ActiveAssetGroupItem[];
868
+ highlighted: ActiveAssetGroupItem[];
869
+ watchlist: ActiveAssetGroupItem[];
870
+ }
782
871
  /**
783
872
  * Candle interval options
784
873
  */
@@ -827,6 +916,71 @@ interface SpotState {
827
916
  user: string;
828
917
  balances: SpotBalance[];
829
918
  }
919
+ interface TokenEntry {
920
+ symbol: string;
921
+ data: AssetMarketData;
922
+ }
923
+ interface PerpDex {
924
+ name: string;
925
+ fullName: string;
926
+ deployer: string;
927
+ oracleUpdater: string | null;
928
+ feeRecipient: string | null;
929
+ deployerFeeScale: string;
930
+ assetToStreamingOiCap: [string, string][];
931
+ assetToFundingMultiplier: [string, string][];
932
+ subDeployers: [string, string[]][];
933
+ lastDeployerFeeScaleChangeTime: string;
934
+ }
935
+ type PerpDexsResponse = (PerpDex | null)[];
936
+ interface SpotBalances {
937
+ [coin: string]: number;
938
+ }
939
+ interface AvailableToTrades {
940
+ [collateralCoin: string]: number;
941
+ }
942
+ type ExecutionType = "MARKET" | "TRIGGER" | "TWAP" | "LADDER" | "TP" | "SL" | "SPOT_MARKET" | "SPOT_LIMIT" | "SPOT_TWAP";
943
+ type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE" | "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO";
944
+ interface PairAssetInput {
945
+ asset: string;
946
+ weight?: number;
947
+ }
948
+ interface TpSlThresholdInput {
949
+ type: TpSlThresholdType;
950
+ value?: number;
951
+ isTrailing?: boolean;
952
+ trailingDeltaValue?: number;
953
+ trailingActivationValue?: number;
954
+ }
955
+ interface LadderConfigInput {
956
+ ratioStart: number;
957
+ ratioEnd: number;
958
+ numberOfLevels: number;
959
+ }
960
+ interface CreatePositionRequestInput {
961
+ slippage: number;
962
+ executionType: ExecutionType;
963
+ leverage: number;
964
+ usdValue: number;
965
+ longAssets?: PairAssetInput[];
966
+ shortAssets?: PairAssetInput[];
967
+ triggerValue?: string | number;
968
+ triggerType?: TriggerType;
969
+ direction?: "MORE_THAN" | "LESS_THAN";
970
+ assetName?: string;
971
+ marketCode?: string;
972
+ twapDuration?: number;
973
+ twapIntervalSeconds?: number;
974
+ randomizeExecution?: boolean;
975
+ referralCode?: string;
976
+ ladderConfig?: LadderConfigInput;
977
+ takeProfit?: TpSlThresholdInput | null;
978
+ stopLoss?: TpSlThresholdInput | null;
979
+ }
980
+ interface CreatePositionResponseDto {
981
+ orderId: string;
982
+ fills?: ExternalFillDto[];
983
+ }
830
984
 
831
985
  declare const useAccountSummary: () => {
832
986
  data: AccountSummaryResponseDto | null;
@@ -867,7 +1021,22 @@ interface UserSelectionState {
867
1021
  resetToDefaults: () => void;
868
1022
  }
869
1023
 
870
- declare const useUserSelection: () => UserSelectionState;
1024
+ declare const useUserSelection: () => {
1025
+ longTokens: TokenSelection[];
1026
+ shortTokens: TokenSelection[];
1027
+ candleInterval: CandleInterval;
1028
+ openTokenSelector: boolean;
1029
+ selectorConfig: TokenSelectorConfig | null;
1030
+ openConflictModal: boolean;
1031
+ setLongTokens: (tokens: TokenSelection[]) => void;
1032
+ setShortTokens: (tokens: TokenSelection[]) => void;
1033
+ setCandleInterval: (interval: CandleInterval) => void;
1034
+ setTokenSelections: (longTokens: TokenSelection[], shortTokens: TokenSelection[]) => void;
1035
+ setOpenTokenSelector: (open: boolean) => void;
1036
+ setSelectorConfig: (config: TokenSelectorConfig | null) => void;
1037
+ setOpenConflictModal: (open: boolean) => void;
1038
+ addToken: (isLong: boolean) => boolean;
1039
+ };
871
1040
 
872
1041
  /**
873
1042
  * Hook to access webData
@@ -890,8 +1059,8 @@ interface UseTokenSelectionMetadataReturn {
890
1059
  volume: string;
891
1060
  sumNetFunding: number;
892
1061
  maxLeverage: number;
893
- minMargin: number;
894
1062
  leverageMatched: boolean;
1063
+ minSize: Record<string, number>;
895
1064
  }
896
1065
  declare const useTokenSelectionMetadata: () => UseTokenSelectionMetadataReturn;
897
1066
 
@@ -905,6 +1074,8 @@ interface TokenHistoricalPriceData {
905
1074
  candles: CandleData[];
906
1075
  oldestTime: number | null;
907
1076
  latestTime: number | null;
1077
+ requestedRanges: HistoricalRange[];
1078
+ noDataBefore: number | null;
908
1079
  }
909
1080
  interface HistoricalPriceDataState {
910
1081
  historicalPriceData: Record<string, TokenHistoricalPriceData>;
@@ -912,6 +1083,7 @@ interface HistoricalPriceDataState {
912
1083
  addHistoricalPriceData: (symbol: string, interval: CandleInterval, candles: CandleData[], range: HistoricalRange) => void;
913
1084
  hasHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => boolean;
914
1085
  getHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => CandleData[];
1086
+ getEffectiveDataBoundary: (symbols: string[], interval: CandleInterval) => number | null;
915
1087
  setTokenLoading: (symbol: string, loading: boolean) => void;
916
1088
  isTokenLoading: (symbol: string) => boolean;
917
1089
  removeTokenPriceData: (symbol: string, interval: CandleInterval) => void;
@@ -923,6 +1095,7 @@ interface UseHistoricalPriceDataReturn {
923
1095
  fetchHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval, callback?: (data: Record<string, CandleData[]>) => void) => Promise<Record<string, CandleData[]>>;
924
1096
  hasHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval) => boolean;
925
1097
  getHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval) => Record<string, CandleData[]>;
1098
+ getEffectiveDataBoundary: (interval: CandleInterval) => number | null;
926
1099
  getAllHistoricalPriceData(): Promise<Record<string, TokenHistoricalPriceData>>;
927
1100
  isLoading: (symbol?: string) => boolean;
928
1101
  clearCache: () => void;
@@ -933,6 +1106,7 @@ interface UseBasketCandlesReturn {
933
1106
  fetchBasketCandles: (startTime: number, endTime: number, interval: CandleInterval) => Promise<CandleData[]>;
934
1107
  fetchPerformanceCandles: (startTime: number, endTime: number, interval: CandleInterval, symbol: string) => Promise<CandleData[]>;
935
1108
  fetchOverallPerformanceCandles: (startTime: number, endTime: number, interval: CandleInterval) => Promise<CandleData[]>;
1109
+ getEffectiveDataBoundary: (interval: CandleInterval) => number | null;
936
1110
  isLoading: boolean;
937
1111
  addRealtimeListener: (cb: RealtimeBarsCallback) => string;
938
1112
  removeRealtimeListener: (id: string) => void;
@@ -1040,49 +1214,6 @@ interface SpotOrderResponseDto {
1040
1214
  */
1041
1215
  declare function executeSpotOrder(baseUrl: string, payload: SpotOrderRequestInput): Promise<ApiResponse<SpotOrderResponseDto>>;
1042
1216
 
1043
- type ExecutionType = "MARKET" | "TRIGGER" | "TWAP" | "LADDER" | "TP" | "SL" | "SPOT_MARKET" | "SPOT_LIMIT" | "SPOT_TWAP";
1044
- type TriggerType = "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO" | "BTC_DOM" | "CROSS_ASSET_PRICE" | "PREDICTION_MARKET_OUTCOME";
1045
- type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE" | "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO";
1046
- interface PairAssetInput {
1047
- asset: string;
1048
- weight?: number;
1049
- }
1050
- interface TpSlThresholdInput {
1051
- type: TpSlThresholdType;
1052
- value?: number;
1053
- isTrailing?: boolean;
1054
- trailingDeltaValue?: number;
1055
- trailingActivationValue?: number;
1056
- }
1057
- interface LadderConfigInput {
1058
- ratioStart: number;
1059
- ratioEnd: number;
1060
- numberOfLevels: number;
1061
- }
1062
- interface CreatePositionRequestInput {
1063
- slippage: number;
1064
- executionType: ExecutionType;
1065
- leverage: number;
1066
- usdValue: number;
1067
- longAssets?: PairAssetInput[];
1068
- shortAssets?: PairAssetInput[];
1069
- triggerValue?: string | number;
1070
- triggerType?: TriggerType;
1071
- direction?: "MORE_THAN" | "LESS_THAN";
1072
- assetName?: string;
1073
- marketCode?: string;
1074
- twapDuration?: number;
1075
- twapIntervalSeconds?: number;
1076
- randomizeExecution?: boolean;
1077
- referralCode?: string;
1078
- ladderConfig?: LadderConfigInput;
1079
- takeProfit?: TpSlThresholdInput | null;
1080
- stopLoss?: TpSlThresholdInput | null;
1081
- }
1082
- interface CreatePositionResponseDto {
1083
- orderId: string;
1084
- fills?: ExternalFillDto[];
1085
- }
1086
1217
  /**
1087
1218
  * Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
1088
1219
  * Authorization is derived from headers (Axios defaults or browser localStorage fallback)
@@ -1166,6 +1297,25 @@ interface UpdateLeverageResponseDto {
1166
1297
  }
1167
1298
  declare function updateLeverage(baseUrl: string, positionId: string, payload: UpdateLeverageRequestInput): Promise<ApiResponse<UpdateLeverageResponseDto | null>>;
1168
1299
 
1300
+ interface RebalanceAssetPlan {
1301
+ coin: string;
1302
+ side: 'long' | 'short';
1303
+ currentWeight: number;
1304
+ targetWeight: number;
1305
+ currentValue: number;
1306
+ targetValue: number;
1307
+ deltaValue: number;
1308
+ currentSize: number;
1309
+ newSize: number;
1310
+ deltaSize: number;
1311
+ skipped: boolean;
1312
+ skipReason?: string;
1313
+ }
1314
+ interface RebalancePlan {
1315
+ positionId: string;
1316
+ assets: RebalanceAssetPlan[];
1317
+ canExecute: boolean;
1318
+ }
1169
1319
  declare function usePosition(): {
1170
1320
  readonly createPosition: (payload: CreatePositionRequestInput) => Promise<ApiResponse<CreatePositionResponseDto>>;
1171
1321
  readonly updateRiskParameters: (positionId: string, payload: UpdateRiskParametersRequestInput) => Promise<ApiResponse<UpdateRiskParametersResponseDto>>;
@@ -1176,6 +1326,8 @@ declare function usePosition(): {
1176
1326
  readonly updateLeverage: (positionId: string, leverage: number) => Promise<ApiResponse<UpdateLeverageResponseDto | null>>;
1177
1327
  readonly openPositions: OpenPositionDto[] | null;
1178
1328
  readonly isLoading: boolean;
1329
+ readonly planRebalance: (positionId: string, targetWeights?: Record<string, number>) => RebalancePlan;
1330
+ readonly executeRebalance: (positionId: string, targetWeights?: Record<string, number>) => Promise<ApiResponse<AdjustAdvanceResponseDto>>;
1179
1331
  };
1180
1332
 
1181
1333
  declare function useOrders(): {
@@ -1219,14 +1371,19 @@ interface UseNotificationsResult {
1219
1371
  */
1220
1372
  declare function useNotifications(): UseNotificationsResult;
1221
1373
 
1222
- type CollateralFilter = 'USDC' | 'USDH' | 'ALL';
1223
- declare const useMarketDataPayload: () => ActiveAssetsResponse | null;
1224
- declare const useActiveBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
1225
- declare const useTopGainers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
1226
- declare const useTopLosers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
1227
- declare const useHighlightedBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
1228
- declare const useWatchlistBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
1229
- declare const useFindBasket: (longs: string[], shorts: string[]) => ActiveAssetGroupItem | undefined;
1374
+ interface UseMarketDataHookOptions {
1375
+ topGainersLimit?: number;
1376
+ topLosersLimit?: number;
1377
+ }
1378
+ interface UseMarketDataHookResult {
1379
+ marketData: ActiveAssetsResponse | null;
1380
+ activeBaskets: ActiveAssetGroupItem[];
1381
+ topGainers: ActiveAssetGroupItem[];
1382
+ topLosers: ActiveAssetGroupItem[];
1383
+ highlightedBaskets: ActiveAssetGroupItem[];
1384
+ watchlistBaskets: ActiveAssetGroupItem[];
1385
+ }
1386
+ declare const useMarketDataHook: (options?: UseMarketDataHookOptions) => UseMarketDataHookResult;
1230
1387
 
1231
1388
  declare function useWatchlist(): {
1232
1389
  readonly watchlists: ActiveAssetGroupItem[] | null;
@@ -1289,6 +1446,7 @@ declare function usePortfolio(): UsePortfolioResult;
1289
1446
  declare function useAuth(): {
1290
1447
  readonly isReady: boolean;
1291
1448
  readonly isAuthenticated: boolean;
1449
+ readonly address: string | null;
1292
1450
  readonly accessToken: string | null;
1293
1451
  readonly refreshToken: string | null;
1294
1452
  readonly getEip712: (address: string) => Promise<GetEIP712MessageResponse>;
@@ -1296,16 +1454,32 @@ declare function useAuth(): {
1296
1454
  readonly loginWithPrivyToken: (address: string, appId: string, privyAccessToken: string) => Promise<void>;
1297
1455
  readonly refreshTokens: () => Promise<RefreshTokenResponse>;
1298
1456
  readonly logout: () => Promise<void>;
1457
+ readonly clearSession: () => void;
1458
+ readonly setAddress: (address: string | null) => void;
1299
1459
  };
1300
1460
 
1301
- interface AllUserBalances {
1302
- spotUsdcBalance: number | undefined;
1303
- availableToTradeUsdc: number | undefined;
1304
- spotUsdhBalance: number | undefined;
1305
- availableToTradeUsdh: number | undefined;
1461
+ interface MarginRequiredPerCollateral {
1462
+ collateral: CollateralToken;
1463
+ marginRequired: number;
1464
+ availableBalance: number;
1465
+ hasEnough: boolean;
1466
+ shortfall: number;
1467
+ }
1468
+ interface MarginRequiredResult {
1469
+ totalMarginRequired: number;
1470
+ orderValue: number;
1471
+ perCollateral: MarginRequiredPerCollateral[];
1472
+ hasEnoughTotal: boolean;
1473
+ }
1474
+ interface AllUserBalancesResult {
1475
+ spotBalances: SpotBalances;
1476
+ availableToTrades: AvailableToTrades;
1306
1477
  isLoading: boolean;
1478
+ abstractionMode: UserAbstraction | null;
1479
+ getMarginRequired: (assetsLeverage: Record<string, number>, size: number) => MarginRequiredResult;
1480
+ getMaxSize: (assetsLeverage: Record<string, number>) => number;
1307
1481
  }
1308
- declare const useAllUserBalances: () => AllUserBalances;
1482
+ declare const useAllUserBalances: () => AllUserBalancesResult;
1309
1483
 
1310
1484
  interface UseHyperliquidUserFillsOptions {
1311
1485
  baseUrl: string;
@@ -1324,27 +1498,51 @@ interface UseHyperliquidUserFillsState {
1324
1498
  */
1325
1499
  declare function useHyperliquidUserFills(options: UseHyperliquidUserFillsOptions): UseHyperliquidUserFillsState;
1326
1500
 
1327
- interface UseHyperliquidWebSocketProps {
1328
- wsUrl: string;
1329
- address: string | null;
1330
- enabled?: boolean;
1331
- }
1332
- declare const useHyperliquidWebSocket: ({ wsUrl, address, enabled, }: UseHyperliquidWebSocketProps) => {
1333
- isConnected: boolean;
1334
- lastError: string | null;
1335
- };
1336
-
1337
- interface UseHyperliquidNativeWebSocketProps {
1338
- address: string | null;
1339
- tokens?: string[];
1340
- enabled?: boolean;
1341
- onUserFills?: () => void | Promise<void>;
1501
+ type PnlCalendarTimeframe = '2W' | '3W' | '2M' | '3M';
1502
+ interface PnlCalendarOptions {
1503
+ timeframe?: PnlCalendarTimeframe;
1504
+ startDate?: Date | string;
1505
+ endDate?: Date | string;
1506
+ }
1507
+ interface PnlCalendarDay {
1508
+ date: string;
1509
+ totalPnl: number;
1510
+ volume: number;
1511
+ positionsClosed: number;
1512
+ result: 'profit' | 'loss' | 'breakeven';
1513
+ tokens: string[];
1342
1514
  }
1343
- interface UseHyperliquidNativeWebSocketReturn {
1344
- isConnected: boolean;
1345
- lastError: string | null;
1515
+ interface PeriodSummary {
1516
+ pnl: number;
1517
+ volume: number;
1518
+ winRate: number;
1519
+ wins: number;
1520
+ losses: number;
1521
+ totalProfit: number;
1522
+ totalLoss: number;
1523
+ }
1524
+ interface PnlCalendarWeek {
1525
+ weekStart: string;
1526
+ weekEnd: string;
1527
+ days: PnlCalendarDay[];
1528
+ summary: PeriodSummary;
1529
+ }
1530
+ interface PnlCalendarMonth {
1531
+ month: string;
1532
+ label: string;
1533
+ days: PnlCalendarDay[];
1534
+ summary: PeriodSummary;
1535
+ }
1536
+ interface UsePnlCalendarResult {
1537
+ timeframe: PnlCalendarTimeframe;
1538
+ weeks: PnlCalendarWeek[];
1539
+ months: PnlCalendarMonth[];
1540
+ overall: PeriodSummary;
1541
+ isLoading: boolean;
1542
+ error: string | null;
1543
+ refetch: () => void;
1346
1544
  }
1347
- declare const useHyperliquidNativeWebSocket: ({ address, enabled, onUserFills, }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
1545
+ declare function usePnlCalendar(options?: PnlCalendarTimeframe | PnlCalendarOptions): UsePnlCalendarResult;
1348
1546
 
1349
1547
  /**
1350
1548
  * Mark notifications as read up to a given timestamp (ms)
@@ -1448,23 +1646,6 @@ interface GetKalshiMarketsParams {
1448
1646
  }
1449
1647
  declare function getKalshiMarkets(params?: GetKalshiMarketsParams): Promise<ApiResponse<KalshiMarketsResponse>>;
1450
1648
 
1451
- /**
1452
- * Account summary calculation utility class
1453
- */
1454
- declare class AccountSummaryCalculator {
1455
- private clearinghouseState;
1456
- constructor(clearinghouseState: ClearinghouseState | null);
1457
- /**
1458
- * Calculate account summary from real-time clearinghouse state and platform orders
1459
- */
1460
- calculateAccountSummary(platformAccountSummary: PlatformAccountSummaryResponseDto | null, registeredAgentWallets: ExtraAgent[]): AccountSummaryResponseDto | null;
1461
- getClearinghouseState(): ClearinghouseState | null;
1462
- /**
1463
- * Check if real-time data is available
1464
- */
1465
- hasRealTimeData(): boolean;
1466
- }
1467
-
1468
1649
  /**
1469
1650
  * Detects conflicts between selected tokens and existing positions
1470
1651
  */
@@ -1479,43 +1660,6 @@ declare class ConflictDetector {
1479
1660
  static detectConflicts(longTokens: TokenSelection[], shortTokens: TokenSelection[], openPositions: RawPositionDto[] | null): TokenConflict[];
1480
1661
  }
1481
1662
 
1482
- /**
1483
- * Extracts token metadata from aggregated WebData3 contexts and AllMids data
1484
- */
1485
- declare class TokenMetadataExtractor {
1486
- /**
1487
- * Extracts comprehensive token metadata
1488
- * @param symbol - Token symbol (e.g., "BTC", "TSLA")
1489
- * @param perpMetaAssets - Aggregated universe assets (flattened across dexes)
1490
- * @param finalAssetContexts - Aggregated asset contexts (flattened across dexes)
1491
- * @param allMids - AllMids data containing current prices
1492
- * @param activeAssetData - Optional active asset data containing leverage information
1493
- * @returns TokenMetadata or null if token not found
1494
- */
1495
- static extractTokenMetadata(symbol: string, perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null, finalAtOICaps?: string[] | null): TokenMetadata | null;
1496
- /**
1497
- * Extracts metadata for multiple tokens
1498
- * @param tokens - Array of token strings (e.g., "BTC", "TSLA")
1499
- * @param perpMetaAssets - Aggregated universe assets
1500
- * @param finalAssetContexts - Aggregated asset contexts
1501
- * @param allMids - AllMids data
1502
- * @param activeAssetData - Optional active asset data containing leverage information
1503
- * @returns Record of token string to TokenMetadata (keys match input tokens exactly)
1504
- */
1505
- static extractMultipleTokensMetadata(tokens: string[], perpMetaAssets: UniverseAsset[] | null, finalAssetContexts: WebData3AssetCtx[] | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null, finalAtOICaps?: string[] | null): Record<string, TokenMetadata | null>;
1506
- /**
1507
- * Checks if token data is available in aggregated universe assets
1508
- * @param symbol - Token symbol
1509
- * @param perpMetaAssets - Aggregated universe assets
1510
- * @returns boolean indicating if token exists in universe
1511
- */
1512
- static isTokenAvailable(symbol: string, perpMetaAssets: UniverseAsset[] | null): boolean;
1513
- }
1514
-
1515
- type TokenMetadataBySymbol = Record<string, TokenMetadata | null>;
1516
- declare const selectTokenMetadataBySymbols: (tokenMetadata: TokenMetadataBySymbol, symbols: string[]) => TokenMetadataBySymbol;
1517
- declare const getAssetByName: (tokenMetadata: TokenMetadataBySymbol, symbol: string) => TokenMetadata | null;
1518
-
1519
1663
  /**
1520
1664
  * Create efficient timestamp-based lookup maps for candle data
1521
1665
  */
@@ -1633,7 +1777,7 @@ declare function getOrderTpSlTriggerType(order: OpenLimitOrderDto): TpSlTriggerT
1633
1777
  /**
1634
1778
  * Get trigger type from order parameters (for Trigger orders)
1635
1779
  */
1636
- declare function getOrderTriggerType(order: OpenLimitOrderDto): TriggerType$1 | undefined;
1780
+ declare function getOrderTriggerType(order: OpenLimitOrderDto): TriggerType | undefined;
1637
1781
  /**
1638
1782
  * Get order direction from order parameters (for Trigger orders)
1639
1783
  */
@@ -1674,5 +1818,5 @@ interface MarketDataState {
1674
1818
  }
1675
1819
  declare const useMarketData: zustand.UseBoundStore<zustand.StoreApi<MarketDataState>>;
1676
1820
 
1677
- 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, executeSpotOrder, getAssetByName, getCompleteTimestamps, getKalshiMarkets, getOrderDirection, getOrderLadderConfig, getOrderLeverage, getOrderReduceOnly, getOrderTpSlTriggerType, getOrderTrailingInfo, getOrderTriggerType, getOrderTriggerValue, getOrderTwapDuration, getOrderUsdValue, getPortfolio, isBtcDomOrder, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, selectTokenMetadataBySymbols, toggleWatchlist, updateLeverage, updateRiskParameters, useAccountSummary, useActiveBaskets, useAgentWallet, useAllUserBalances, useAuth, useBasketCandles, useFindBasket, useHighlightedBaskets, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidUserFills, useHyperliquidWebSocket, useMarket, useMarketData, useMarketDataPayload, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePortfolio, usePosition, useSpotOrder, useTokenSelectionMetadata, useTopGainers, useTopLosers, useTradeHistories, useTwap, useUserSelection, useWatchlist, useWatchlistBaskets, validateMaxAssetsPerLeg, validateMinimumAssetSize, validatePositionSize };
1678
- export type { AccountSummaryResponseDto, ActiveAssetGroupItem, ActiveAssetsResponse, AdjustAdvanceAssetInput, AdjustAdvanceItemInput, AdjustAdvanceResponseDto, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, BalanceSummaryDto, BaseTriggerOrderNotificationParams, BtcDomTriggerParams, CancelOrderResponseDto, CancelTwapResponseDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ClearinghouseState, CloseAllPositionsResponseDto, CloseAllPositionsResultDto, CloseExecutionType, ClosePositionRequestInput, ClosePositionResponseDto, CollateralFilter, CollateralToken, CreatePositionRequestInput, CreatePositionResponseDto, CrossAssetPriceTriggerParams, CrossMarginSummaryDto, CumFundingDto, ExecutionType, ExtraAgent, GetKalshiMarketsParams, HLWebSocketResponse, HistoricalRange, KalshiMarket, KalshiMarketsResponse, KalshiMveLeg, KalshiPriceRange, LadderConfigInput, MarginSummaryDto, NotificationCategory, NotificationDto, OpenLimitOrderDto, OpenPositionDto, OrderAssetDto, OrderStatus, PairAssetDto, PairAssetInput, PerformanceOverlay, PlatformAccountSummaryResponseDto, PortfolioBucketDto, PortfolioInterval, PortfolioIntervalsDto, PortfolioOverallDto, PortfolioResponseDto, PositionAdjustmentType, PositionAssetDetailDto, PredictionMarketOutcomeTriggerParams, PriceRatioTriggerParams, PriceTriggerParams, RealtimeBar, RealtimeBarsCallback, SpotBalance, SpotOrderFilledStatus, SpotOrderHyperliquidData, SpotOrderHyperliquidResult, SpotOrderRequestInput, SpotOrderResponseDto, SpotState, ToggleWatchlistResponseDto, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlOrderParameters, TpSlThresholdInput, TpSlThresholdType, TpSlTriggerType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TriggerOrderNotificationAsset, TriggerOrderNotificationParams, TriggerOrderNotificationType, TriggerOrderParameters, TriggerType, TwapChunkStatusDto, TwapMonitoringDto, TwapSliceFillResponseItem, UniverseAsset, UpdateLeverageRequestInput, UpdateLeverageResponseDto, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseHyperliquidUserFillsOptions, UseHyperliquidUserFillsState, UseNotificationsResult, UsePerformanceOverlaysReturn, UsePortfolioResult, UseSpotOrderResult, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WatchlistItemDto, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
1821
+ export { ConflictDetector, MAX_ASSETS_PER_LEG, MINIMUM_ASSET_USD_VALUE, MaxAssetsPerLegError, MinimumPositionSizeError, PearHyperliquidProvider, ReadyState, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, executeSpotOrder, getCompleteTimestamps, getKalshiMarkets, getOrderDirection, getOrderLadderConfig, getOrderLeverage, getOrderReduceOnly, getOrderTpSlTriggerType, getOrderTrailingInfo, getOrderTriggerType, getOrderTriggerValue, getOrderTwapDuration, getOrderUsdValue, getPortfolio, isBtcDomOrder, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, updateLeverage, updateRiskParameters, useAccountSummary, useAgentWallet, useAllUserBalances, useAuth, useBasketCandles, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidUserFills, useMarket, useMarketData, useMarketDataHook, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePnlCalendar, usePortfolio, usePosition, useSpotOrder, useTokenSelectionMetadata, useTradeHistories, useTwap, useUserSelection, useWatchlist, validateMaxAssetsPerLeg, validateMinimumAssetSize, validatePositionSize };
1822
+ export type { AccountSummaryResponseDto, ActiveAssetData, ActiveAssetGroupItem, ActiveAssetsAllResponse, ActiveAssetsResponse, AddressState, AdjustAdvanceAssetInput, AdjustAdvanceItemInput, AdjustAdvanceResponseDto, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, AgentWalletStatus, AllDexsAssetCtxsData, AllDexsClearinghouseStateData, AllPerpMetasItem, AllPerpMetasResponse, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, AuthenticateRequest, AuthenticateResponse, AvailableToTrades, BalanceSummaryDto, BaseTriggerOrderNotificationParams, BtcDomTriggerParams, CancelOrderResponseDto, CancelTwapResponseDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ChunkFillDto, ClearinghouseState, CloseAllPositionsResponseDto, CloseAllPositionsResultDto, CloseExecutionType, ClosePositionRequestInput, ClosePositionResponseDto, CollateralToken, CreateAgentWalletResponseDto, CreatePositionRequestInput, CreatePositionResponseDto, CrossAssetPriceTriggerParams, CrossMarginSummaryDto, CumFundingDto, EIP712AuthDetails, ExecutionType, ExternalFillDto, ExternalLiquidationDto, ExtraAgent, GetAgentWalletResponseDto, GetEIP712MessageResponse, GetKalshiMarketsParams, HLChannel, HLChannelDataMap, HLWebSocketResponse, HistoricalRange, KalshiMarket, KalshiMarketsResponse, KalshiMveLeg, KalshiPriceRange, LadderConfigInput, LadderOrderParameters, LeverageInfo, LogoutRequest, LogoutResponse, MarginRequiredPerCollateral, MarginRequiredResult, MarginSummaryDto, MarginTableDef, MarginTablesEntry, MarginTier, MarketOrderParameters, NotificationCategory, NotificationDto, OpenLimitOrderDto, OpenPositionDto, OrderAssetDto, OrderDirection, OrderParameters, OrderStatus, OrderType, PairAssetDto, PairAssetInput, PerformanceOverlay, PeriodSummary, PerpDex, PerpDexsResponse, PerpMetaAsset, PlatformAccountSummaryResponseDto, PnlCalendarDay, PnlCalendarMonth, PnlCalendarOptions, PnlCalendarTimeframe, PnlCalendarWeek, PortfolioBucketDto, PortfolioInterval, PortfolioIntervalsDto, PortfolioOverallDto, PortfolioResponseDto, PositionAdjustmentType, PositionAssetDetailDto, PredictionMarketOutcomeTriggerParams, PriceRatioTriggerParams, PriceTriggerParams, PrivyAuthDetails, RawAssetDto, RawPositionDto, RealtimeBar, RealtimeBarsCallback, RebalanceAssetPlan, RebalancePlan, RefreshTokenRequest, RefreshTokenResponse, SpotBalance, SpotBalances, SpotOrderFilledStatus, SpotOrderHyperliquidData, SpotOrderHyperliquidResult, SpotOrderRequestInput, SpotOrderResponseDto, SpotState, SyncFillsRequestDto, SyncFillsResponseDto, ToggleWatchlistResponseDto, TokenConflict, TokenEntry, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TokenSelectorConfig, TpSlOrderParameters, TpSlThreshold, TpSlThresholdInput, TpSlThresholdType, TpSlTriggerType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TriggerOrderNotificationAsset, TriggerOrderNotificationParams, TriggerOrderNotificationType, TriggerOrderParameters, TriggerType, TwapChunkStatus, TwapChunkStatusDto, TwapMonitoringDto, TwapOrderOverallStatus, TwapOrderParameters, TwapSliceFillResponseItem, UniverseAsset, UpdateLeverageRequestInput, UpdateLeverageResponseDto, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseHyperliquidUserFillsOptions, UseHyperliquidUserFillsState, UseNotificationsResult, UsePerformanceOverlaysReturn, UsePnlCalendarResult, UsePortfolioResult, UseSpotOrderResult, UseTokenSelectionMetadataReturn, UserAbstraction, UserProfile, UserSelectionState, WatchlistAssetDto, WatchlistItemDto, WebData3AssetCtx, WebData3PerpDexState, WebData3Response, WebData3UserState, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };