@pear-protocol/hyperliquid-sdk 0.1.2 → 0.1.4-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;
@@ -600,9 +662,9 @@ interface AssetCtx {
600
662
  * 0 = USDC
601
663
  * 360 = USDH
602
664
  * 235 = USDE
603
- * 268 = USDT
665
+ * 268 = USDT0
604
666
  */
605
- type CollateralToken = 'USDC' | 'USDH' | 'USDE' | 'USDT';
667
+ type CollateralToken = 'USDC' | 'USDH' | 'USDE' | 'USDT0';
606
668
  /**
607
669
  * Universe asset metadata
608
670
  */
@@ -614,6 +676,24 @@ interface UniverseAsset {
614
676
  isDelisted?: boolean;
615
677
  collateralToken: CollateralToken;
616
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[];
617
697
  interface ClearinghouseState {
618
698
  assetPositions: AssetPosition[];
619
699
  crossMaintenanceMarginUsed: string;
@@ -684,6 +764,7 @@ interface RawAssetDto {
684
764
  side: string;
685
765
  fundingPaid?: number;
686
766
  leverage: number;
767
+ targetWeight?: number;
687
768
  }
688
769
  /**
689
770
  * Raw position data from open-positions channel
@@ -759,6 +840,7 @@ interface AssetMarketData {
759
840
  interface PairAssetDto {
760
841
  asset: string;
761
842
  weight: number;
843
+ metadata?: TokenMetadata | null;
762
844
  }
763
845
  interface ActiveAssetGroupItem {
764
846
  longAssets: PairAssetDto[];
@@ -772,7 +854,6 @@ interface ActiveAssetGroupItem {
772
854
  weightedRatio?: string;
773
855
  weightedPrevRatio?: string;
774
856
  weightedChange24h?: string;
775
- collateralType: 'USDC' | 'USDH' | 'MIXED';
776
857
  }
777
858
  interface ActiveAssetsResponse {
778
859
  active: ActiveAssetGroupItem[];
@@ -781,6 +862,12 @@ interface ActiveAssetsResponse {
781
862
  highlighted: ActiveAssetGroupItem[];
782
863
  watchlist: ActiveAssetGroupItem[];
783
864
  }
865
+ interface ActiveAssetsAllResponse {
866
+ active: ActiveAssetGroupItem[];
867
+ all: ActiveAssetGroupItem[];
868
+ highlighted: ActiveAssetGroupItem[];
869
+ watchlist: ActiveAssetGroupItem[];
870
+ }
784
871
  /**
785
872
  * Candle interval options
786
873
  */
@@ -829,6 +916,71 @@ interface SpotState {
829
916
  user: string;
830
917
  balances: SpotBalance[];
831
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
+ }
832
984
 
833
985
  declare const useAccountSummary: () => {
834
986
  data: AccountSummaryResponseDto | null;
@@ -869,7 +1021,22 @@ interface UserSelectionState {
869
1021
  resetToDefaults: () => void;
870
1022
  }
871
1023
 
872
- 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
+ };
873
1040
 
874
1041
  /**
875
1042
  * Hook to access webData
@@ -892,8 +1059,8 @@ interface UseTokenSelectionMetadataReturn {
892
1059
  volume: string;
893
1060
  sumNetFunding: number;
894
1061
  maxLeverage: number;
895
- minMargin: number;
896
1062
  leverageMatched: boolean;
1063
+ minSize: Record<string, number>;
897
1064
  }
898
1065
  declare const useTokenSelectionMetadata: () => UseTokenSelectionMetadataReturn;
899
1066
 
@@ -907,6 +1074,8 @@ interface TokenHistoricalPriceData {
907
1074
  candles: CandleData[];
908
1075
  oldestTime: number | null;
909
1076
  latestTime: number | null;
1077
+ requestedRanges: HistoricalRange[];
1078
+ noDataBefore: number | null;
910
1079
  }
911
1080
  interface HistoricalPriceDataState {
912
1081
  historicalPriceData: Record<string, TokenHistoricalPriceData>;
@@ -914,6 +1083,7 @@ interface HistoricalPriceDataState {
914
1083
  addHistoricalPriceData: (symbol: string, interval: CandleInterval, candles: CandleData[], range: HistoricalRange) => void;
915
1084
  hasHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => boolean;
916
1085
  getHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => CandleData[];
1086
+ getEffectiveDataBoundary: (symbols: string[], interval: CandleInterval) => number | null;
917
1087
  setTokenLoading: (symbol: string, loading: boolean) => void;
918
1088
  isTokenLoading: (symbol: string) => boolean;
919
1089
  removeTokenPriceData: (symbol: string, interval: CandleInterval) => void;
@@ -925,6 +1095,7 @@ interface UseHistoricalPriceDataReturn {
925
1095
  fetchHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval, callback?: (data: Record<string, CandleData[]>) => void) => Promise<Record<string, CandleData[]>>;
926
1096
  hasHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval) => boolean;
927
1097
  getHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval) => Record<string, CandleData[]>;
1098
+ getEffectiveDataBoundary: (interval: CandleInterval) => number | null;
928
1099
  getAllHistoricalPriceData(): Promise<Record<string, TokenHistoricalPriceData>>;
929
1100
  isLoading: (symbol?: string) => boolean;
930
1101
  clearCache: () => void;
@@ -935,6 +1106,7 @@ interface UseBasketCandlesReturn {
935
1106
  fetchBasketCandles: (startTime: number, endTime: number, interval: CandleInterval) => Promise<CandleData[]>;
936
1107
  fetchPerformanceCandles: (startTime: number, endTime: number, interval: CandleInterval, symbol: string) => Promise<CandleData[]>;
937
1108
  fetchOverallPerformanceCandles: (startTime: number, endTime: number, interval: CandleInterval) => Promise<CandleData[]>;
1109
+ getEffectiveDataBoundary: (interval: CandleInterval) => number | null;
938
1110
  isLoading: boolean;
939
1111
  addRealtimeListener: (cb: RealtimeBarsCallback) => string;
940
1112
  removeRealtimeListener: (id: string) => void;
@@ -1042,49 +1214,6 @@ interface SpotOrderResponseDto {
1042
1214
  */
1043
1215
  declare function executeSpotOrder(baseUrl: string, payload: SpotOrderRequestInput): Promise<ApiResponse<SpotOrderResponseDto>>;
1044
1216
 
1045
- type ExecutionType = "MARKET" | "TRIGGER" | "TWAP" | "LADDER" | "TP" | "SL" | "SPOT_MARKET" | "SPOT_LIMIT" | "SPOT_TWAP";
1046
- type TriggerType = "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO" | "BTC_DOM" | "CROSS_ASSET_PRICE" | "PREDICTION_MARKET_OUTCOME";
1047
- type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE" | "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO";
1048
- interface PairAssetInput {
1049
- asset: string;
1050
- weight?: number;
1051
- }
1052
- interface TpSlThresholdInput {
1053
- type: TpSlThresholdType;
1054
- value?: number;
1055
- isTrailing?: boolean;
1056
- trailingDeltaValue?: number;
1057
- trailingActivationValue?: number;
1058
- }
1059
- interface LadderConfigInput {
1060
- ratioStart: number;
1061
- ratioEnd: number;
1062
- numberOfLevels: number;
1063
- }
1064
- interface CreatePositionRequestInput {
1065
- slippage: number;
1066
- executionType: ExecutionType;
1067
- leverage: number;
1068
- usdValue: number;
1069
- longAssets?: PairAssetInput[];
1070
- shortAssets?: PairAssetInput[];
1071
- triggerValue?: string | number;
1072
- triggerType?: TriggerType;
1073
- direction?: "MORE_THAN" | "LESS_THAN";
1074
- assetName?: string;
1075
- marketCode?: string;
1076
- twapDuration?: number;
1077
- twapIntervalSeconds?: number;
1078
- randomizeExecution?: boolean;
1079
- referralCode?: string;
1080
- ladderConfig?: LadderConfigInput;
1081
- takeProfit?: TpSlThresholdInput | null;
1082
- stopLoss?: TpSlThresholdInput | null;
1083
- }
1084
- interface CreatePositionResponseDto {
1085
- orderId: string;
1086
- fills?: ExternalFillDto[];
1087
- }
1088
1217
  /**
1089
1218
  * Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
1090
1219
  * Authorization is derived from headers (Axios defaults or browser localStorage fallback)
@@ -1168,6 +1297,25 @@ interface UpdateLeverageResponseDto {
1168
1297
  }
1169
1298
  declare function updateLeverage(baseUrl: string, positionId: string, payload: UpdateLeverageRequestInput): Promise<ApiResponse<UpdateLeverageResponseDto | null>>;
1170
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
+ }
1171
1319
  declare function usePosition(): {
1172
1320
  readonly createPosition: (payload: CreatePositionRequestInput) => Promise<ApiResponse<CreatePositionResponseDto>>;
1173
1321
  readonly updateRiskParameters: (positionId: string, payload: UpdateRiskParametersRequestInput) => Promise<ApiResponse<UpdateRiskParametersResponseDto>>;
@@ -1178,6 +1326,8 @@ declare function usePosition(): {
1178
1326
  readonly updateLeverage: (positionId: string, leverage: number) => Promise<ApiResponse<UpdateLeverageResponseDto | null>>;
1179
1327
  readonly openPositions: OpenPositionDto[] | null;
1180
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>>;
1181
1331
  };
1182
1332
 
1183
1333
  declare function useOrders(): {
@@ -1221,14 +1371,19 @@ interface UseNotificationsResult {
1221
1371
  */
1222
1372
  declare function useNotifications(): UseNotificationsResult;
1223
1373
 
1224
- type CollateralFilter = 'USDC' | 'USDH' | 'ALL';
1225
- declare const useMarketDataPayload: () => ActiveAssetsResponse | null;
1226
- declare const useActiveBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
1227
- declare const useTopGainers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
1228
- declare const useTopLosers: (limit?: number, collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
1229
- declare const useHighlightedBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
1230
- declare const useWatchlistBaskets: (collateralFilter?: CollateralFilter) => ActiveAssetGroupItem[];
1231
- 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;
1232
1387
 
1233
1388
  declare function useWatchlist(): {
1234
1389
  readonly watchlists: ActiveAssetGroupItem[] | null;
@@ -1291,6 +1446,7 @@ declare function usePortfolio(): UsePortfolioResult;
1291
1446
  declare function useAuth(): {
1292
1447
  readonly isReady: boolean;
1293
1448
  readonly isAuthenticated: boolean;
1449
+ readonly address: string | null;
1294
1450
  readonly accessToken: string | null;
1295
1451
  readonly refreshToken: string | null;
1296
1452
  readonly getEip712: (address: string) => Promise<GetEIP712MessageResponse>;
@@ -1298,16 +1454,32 @@ declare function useAuth(): {
1298
1454
  readonly loginWithPrivyToken: (address: string, appId: string, privyAccessToken: string) => Promise<void>;
1299
1455
  readonly refreshTokens: () => Promise<RefreshTokenResponse>;
1300
1456
  readonly logout: () => Promise<void>;
1457
+ readonly clearSession: () => void;
1458
+ readonly setAddress: (address: string | null) => void;
1301
1459
  };
1302
1460
 
1303
- interface AllUserBalances {
1304
- spotUsdcBalance: number | undefined;
1305
- availableToTradeUsdc: number | undefined;
1306
- spotUsdhBalance: number | undefined;
1307
- 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;
1308
1477
  isLoading: boolean;
1478
+ abstractionMode: UserAbstraction | null;
1479
+ getMarginRequired: (assetsLeverage: Record<string, number>, size: number) => MarginRequiredResult;
1480
+ getMaxSize: (assetsLeverage: Record<string, number>) => number;
1309
1481
  }
1310
- declare const useAllUserBalances: () => AllUserBalances;
1482
+ declare const useAllUserBalances: () => AllUserBalancesResult;
1311
1483
 
1312
1484
  interface UseHyperliquidUserFillsOptions {
1313
1485
  baseUrl: string;
@@ -1326,27 +1498,75 @@ interface UseHyperliquidUserFillsState {
1326
1498
  */
1327
1499
  declare function useHyperliquidUserFills(options: UseHyperliquidUserFillsOptions): UseHyperliquidUserFillsState;
1328
1500
 
1329
- interface UseHyperliquidWebSocketProps {
1330
- wsUrl: string;
1331
- address: string | null;
1332
- enabled?: boolean;
1501
+ type PnlCalendarTimeframe = '2W' | '3W' | '2M' | '3M';
1502
+ interface PnlCalendarOptions {
1503
+ timeframe?: PnlCalendarTimeframe;
1504
+ startDate?: Date | string;
1505
+ endDate?: Date | string;
1333
1506
  }
1334
- declare const useHyperliquidWebSocket: ({ wsUrl, address, enabled, }: UseHyperliquidWebSocketProps) => {
1335
- isConnected: boolean;
1336
- lastError: string | null;
1337
- };
1507
+ interface PnlCalendarAsset {
1508
+ coin: string;
1509
+ metadata: TokenMetadata | null;
1510
+ }
1511
+ interface PnlCalendarTrade {
1512
+ tradeHistoryId: string;
1513
+ realizedPnl: number;
1514
+ result: 'profit' | 'loss' | 'breakeven';
1515
+ closedLongAssets: PnlCalendarAsset[];
1516
+ closedShortAssets: PnlCalendarAsset[];
1517
+ }
1518
+ interface PnlCalendarDay {
1519
+ date: string;
1520
+ totalPnl: number;
1521
+ volume: number;
1522
+ positionsClosed: number;
1523
+ result: 'profit' | 'loss' | 'breakeven';
1524
+ trades: PnlCalendarTrade[];
1525
+ }
1526
+ interface PeriodSummary {
1527
+ pnl: number;
1528
+ volume: number;
1529
+ winRate: number;
1530
+ wins: number;
1531
+ losses: number;
1532
+ totalProfit: number;
1533
+ totalLoss: number;
1534
+ }
1535
+ interface PnlCalendarWeek {
1536
+ weekStart: string;
1537
+ weekEnd: string;
1538
+ days: PnlCalendarDay[];
1539
+ summary: PeriodSummary;
1540
+ }
1541
+ interface PnlCalendarMonth {
1542
+ month: string;
1543
+ label: string;
1544
+ days: PnlCalendarDay[];
1545
+ summary: PeriodSummary;
1546
+ }
1547
+ interface UsePnlCalendarResult {
1548
+ timeframe: PnlCalendarTimeframe;
1549
+ weeks: PnlCalendarWeek[];
1550
+ months: PnlCalendarMonth[];
1551
+ overall: PeriodSummary;
1552
+ isLoading: boolean;
1553
+ error: string | null;
1554
+ refetch: () => void;
1555
+ }
1556
+ declare function usePnlCalendar(options?: PnlCalendarTimeframe | PnlCalendarOptions): UsePnlCalendarResult;
1338
1557
 
1339
- interface UseHyperliquidNativeWebSocketProps {
1340
- address: string | null;
1341
- tokens?: string[];
1342
- enabled?: boolean;
1343
- onUserFills?: () => void | Promise<void>;
1558
+ type PnlHeatmapTimeframe = 'allTime' | '100D' | '30D' | '7D';
1559
+ interface PnlHeatmapTrade extends PnlCalendarTrade {
1560
+ percentage: number;
1344
1561
  }
1345
- interface UseHyperliquidNativeWebSocketReturn {
1346
- isConnected: boolean;
1347
- lastError: string | null;
1562
+ interface UsePnlHeatmapResult {
1563
+ timeframe: PnlHeatmapTimeframe;
1564
+ trades: PnlHeatmapTrade[];
1565
+ isLoading: boolean;
1566
+ error: string | null;
1567
+ refetch: () => void;
1348
1568
  }
1349
- declare const useHyperliquidNativeWebSocket: ({ address, enabled, onUserFills, }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
1569
+ declare function usePnlHeatmap(timeframe?: PnlHeatmapTimeframe): UsePnlHeatmapResult;
1350
1570
 
1351
1571
  /**
1352
1572
  * Mark notifications as read up to a given timestamp (ms)
@@ -1450,23 +1670,6 @@ interface GetKalshiMarketsParams {
1450
1670
  }
1451
1671
  declare function getKalshiMarkets(params?: GetKalshiMarketsParams): Promise<ApiResponse<KalshiMarketsResponse>>;
1452
1672
 
1453
- /**
1454
- * Account summary calculation utility class
1455
- */
1456
- declare class AccountSummaryCalculator {
1457
- private clearinghouseState;
1458
- constructor(clearinghouseState: ClearinghouseState | null);
1459
- /**
1460
- * Calculate account summary from real-time clearinghouse state and platform orders
1461
- */
1462
- calculateAccountSummary(platformAccountSummary: PlatformAccountSummaryResponseDto | null, registeredAgentWallets: ExtraAgent[]): AccountSummaryResponseDto | null;
1463
- getClearinghouseState(): ClearinghouseState | null;
1464
- /**
1465
- * Check if real-time data is available
1466
- */
1467
- hasRealTimeData(): boolean;
1468
- }
1469
-
1470
1673
  /**
1471
1674
  * Detects conflicts between selected tokens and existing positions
1472
1675
  */
@@ -1481,34 +1684,6 @@ declare class ConflictDetector {
1481
1684
  static detectConflicts(longTokens: TokenSelection[], shortTokens: TokenSelection[], openPositions: RawPositionDto[] | null): TokenConflict[];
1482
1685
  }
1483
1686
 
1484
- /**
1485
- * Extracts token metadata from aggregated WebData3 contexts and AllMids data
1486
- */
1487
- declare class TokenMetadataExtractor {
1488
- /**
1489
- * Checks if token data is available in aggregated universe assets
1490
- * @param symbol - Token symbol
1491
- * @param perpMetaAssets - Aggregated universe assets
1492
- * @returns boolean indicating if token exists in universe
1493
- */
1494
- static isTokenAvailable(symbol: string, perpMetaAssets: UniverseAsset[] | null): boolean;
1495
- /**
1496
- * Extracts token metadata using DEX-aware lookup (correctly matches perpMetas to assetContexts)
1497
- * @param symbol - Token symbol (e.g., "BTC", "TSLA")
1498
- * @param perpMetasByDex - Map of DEX name to UniverseAsset[]
1499
- * @param assetContextsByDex - Map of DEX name to WebData3AssetCtx[]
1500
- * @param allMids - AllMids data containing current prices
1501
- * @param activeAssetData - Optional active asset data containing leverage information
1502
- * @param finalAtOICaps - Optional array of symbols at OI caps
1503
- * @returns TokenMetadata or null if token not found
1504
- */
1505
- static extractTokenMetadataByDex(symbol: string, perpMetasByDex: Map<string, UniverseAsset[]>, assetContextsByDex: Map<string, WebData3AssetCtx[]>, allMids: WsAllMidsData, activeAssetData?: Record<string, ActiveAssetData> | null, finalAtOICaps?: string[] | null): TokenMetadata | null;
1506
- }
1507
-
1508
- type TokenMetadataBySymbol = Record<string, TokenMetadata | null>;
1509
- declare const selectTokenMetadataBySymbols: (tokenMetadata: TokenMetadataBySymbol, symbols: string[]) => TokenMetadataBySymbol;
1510
- declare const getAssetByName: (tokenMetadata: TokenMetadataBySymbol, symbol: string) => TokenMetadata | null;
1511
-
1512
1687
  /**
1513
1688
  * Create efficient timestamp-based lookup maps for candle data
1514
1689
  */
@@ -1626,7 +1801,7 @@ declare function getOrderTpSlTriggerType(order: OpenLimitOrderDto): TpSlTriggerT
1626
1801
  /**
1627
1802
  * Get trigger type from order parameters (for Trigger orders)
1628
1803
  */
1629
- declare function getOrderTriggerType(order: OpenLimitOrderDto): TriggerType$1 | undefined;
1804
+ declare function getOrderTriggerType(order: OpenLimitOrderDto): TriggerType | undefined;
1630
1805
  /**
1631
1806
  * Get order direction from order parameters (for Trigger orders)
1632
1807
  */
@@ -1667,5 +1842,5 @@ interface MarketDataState {
1667
1842
  }
1668
1843
  declare const useMarketData: zustand.UseBoundStore<zustand.StoreApi<MarketDataState>>;
1669
1844
 
1670
- 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 };
1671
- 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 };
1845
+ 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, usePnlHeatmap, usePortfolio, usePosition, useSpotOrder, useTokenSelectionMetadata, useTradeHistories, useTwap, useUserSelection, useWatchlist, validateMaxAssetsPerLeg, validateMinimumAssetSize, validatePositionSize };
1846
+ 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, PnlCalendarAsset, PnlCalendarDay, PnlCalendarMonth, PnlCalendarOptions, PnlCalendarTimeframe, PnlCalendarTrade, PnlCalendarWeek, PnlHeatmapTimeframe, PnlHeatmapTrade, 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, UsePnlHeatmapResult, UsePortfolioResult, UseSpotOrderResult, UseTokenSelectionMetadataReturn, UserAbstraction, UserProfile, UserSelectionState, WatchlistAssetDto, WatchlistItemDto, WebData3AssetCtx, WebData3PerpDexState, WebData3Response, WebData3UserState, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };