@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.
@@ -1,4 +1,4 @@
1
- import React, { ReactNode } from 'react';
1
+ import React, { ReactNode } from "react";
2
2
  export interface PearHyperliquidContextType {
3
3
  clientId: string;
4
4
  apiBaseUrl: string;
@@ -9,6 +9,8 @@ interface TokenHistoricalPriceData {
9
9
  candles: CandleData[];
10
10
  oldestTime: number | null;
11
11
  latestTime: number | null;
12
+ requestedRanges: HistoricalRange[];
13
+ noDataBefore: number | null;
12
14
  }
13
15
  interface HistoricalPriceDataState {
14
16
  historicalPriceData: Record<string, TokenHistoricalPriceData>;
@@ -16,6 +18,7 @@ interface HistoricalPriceDataState {
16
18
  addHistoricalPriceData: (symbol: string, interval: CandleInterval, candles: CandleData[], range: HistoricalRange) => void;
17
19
  hasHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => boolean;
18
20
  getHistoricalPriceData: (symbol: string, interval: CandleInterval, startTime: number, endTime: number) => CandleData[];
21
+ getEffectiveDataBoundary: (symbols: string[], interval: CandleInterval) => number | null;
19
22
  setTokenLoading: (symbol: string, loading: boolean) => void;
20
23
  isTokenLoading: (symbol: string) => boolean;
21
24
  removeTokenPriceData: (symbol: string, interval: CandleInterval) => void;
@@ -1,5 +1,5 @@
1
- import { ActiveAssetData, CandleChartData, CandleData, ClearinghouseState, UniverseAsset, WebData3AssetCtx, WsAllMidsData, PerpDexsResponse } from '../types';
2
- import { TokenMetadataBySymbol } from '../utils/token-metadata-extractor';
1
+ import { ActiveAssetData, CandleChartData, CandleData, ClearinghouseState, UniverseAsset, WebData3AssetCtx, WsAllMidsData, PerpDexsResponse } from "../types";
2
+ import { TokenMetadataBySymbol } from "../utils/token-metadata-extractor";
3
3
  interface HyperliquidDataState {
4
4
  allMids: WsAllMidsData | null;
5
5
  activeAssetData: Record<string, ActiveAssetData> | null;
@@ -28,6 +28,7 @@ interface HyperliquidDataState {
28
28
  setPerpDexs: (value: PerpDexsResponse | null) => void;
29
29
  setPerpMetasByDex: (value: Map<string, UniverseAsset[]> | null) => void;
30
30
  setAssetContextsByDex: (value: Map<string, WebData3AssetCtx[]> | null) => void;
31
+ clearUserData: () => void;
31
32
  }
32
33
  export declare const useHyperliquidData: import("zustand").UseBoundStore<import("zustand").StoreApi<HyperliquidDataState>>;
33
34
  export {};
@@ -1,4 +1,4 @@
1
- import type { TokenSelection, TokenMetadata, ActiveAssetsResponse, UniverseAsset } from "../types";
1
+ import type { TokenSelection, TokenMetadata, ActiveAssetsResponse } from "../types";
2
2
  export interface TokenSelectionMetadataState {
3
3
  isPriceDataReady: boolean;
4
4
  isLoading: boolean;
@@ -12,10 +12,9 @@ export interface TokenSelectionMetadataState {
12
12
  volume: string;
13
13
  sumNetFunding: number;
14
14
  maxLeverage: number;
15
- minMargin: number;
15
+ minSize: Record<string, number>;
16
16
  leverageMatched: boolean;
17
17
  recompute: (args: {
18
- perpMetaAssets: UniverseAsset[] | null;
19
18
  tokenMetadata: Record<string, TokenMetadata | null>;
20
19
  marketData: ActiveAssetsResponse | null;
21
20
  longTokens: TokenSelection[];
@@ -1,8 +1,9 @@
1
- import { PlatformAccountSummaryResponseDto, OpenLimitOrderDto, RawPositionDto, TradeHistoryDataDto, TwapMonitoringDto, NotificationDto, ExtraAgent, SpotState } from "../types";
1
+ import { PlatformAccountSummaryResponseDto, OpenLimitOrderDto, RawPositionDto, TradeHistoryDataDto, TwapMonitoringDto, NotificationDto, ExtraAgent, SpotState, UserAbstraction } from "../types";
2
2
  interface UserDataState {
3
3
  accessToken: string | null;
4
4
  refreshToken: string | null;
5
5
  isAuthenticated: boolean;
6
+ isReady: boolean;
6
7
  address: string | null;
7
8
  tradeHistories: TradeHistoryDataDto[] | null;
8
9
  rawOpenPositions: RawPositionDto[] | null;
@@ -12,6 +13,7 @@ interface UserDataState {
12
13
  notifications: NotificationDto[] | null;
13
14
  userExtraAgents: ExtraAgent[] | null;
14
15
  spotState: SpotState | null;
16
+ userAbstractionMode: UserAbstraction | null;
15
17
  setAccessToken: (token: string | null) => void;
16
18
  setRefreshToken: (token: string | null) => void;
17
19
  setIsAuthenticated: (value: boolean) => void;
@@ -24,6 +26,8 @@ interface UserDataState {
24
26
  setTwapDetails: (value: TwapMonitoringDto[] | null) => void;
25
27
  setNotifications: (value: NotificationDto[] | null) => void;
26
28
  setSpotState: (value: SpotState | null) => void;
29
+ setUserAbstractionMode: (value: UserAbstraction | null) => void;
30
+ setIsReady: (value: boolean) => void;
27
31
  clean: () => void;
28
32
  }
29
33
  export declare const useUserData: import("zustand").UseBoundStore<import("zustand").StoreApi<UserDataState>>;
package/dist/types.d.ts CHANGED
@@ -200,6 +200,7 @@ export interface TwapMonitoringDto {
200
200
  export interface TradeHistoryAssetDataDto {
201
201
  coin: string;
202
202
  entryWeight: number;
203
+ closeWeight: number;
203
204
  entryPrice: number;
204
205
  limitPrice: number;
205
206
  leverage: number;
@@ -255,7 +256,9 @@ export interface PositionAssetDetailDto {
255
256
  unrealizedPnl: number;
256
257
  liquidationPrice: number;
257
258
  initialWeight: number;
259
+ currentWeight: number;
258
260
  fundingPaid?: number;
261
+ targetWeight?: number;
259
262
  metadata?: TokenMetadata | null;
260
263
  }
261
264
  export interface TpSlThreshold {
@@ -563,6 +566,7 @@ export interface HLChannelDataMap {
563
566
  allDexsAssetCtxs: AllDexsAssetCtxsData;
564
567
  userFills: any;
565
568
  }
569
+ export type UserAbstraction = 'dexAbstraction' | 'disabled' | 'unifiedAccount' | 'portfolioMargin';
566
570
  export interface WebData3UserState {
567
571
  agentAddress?: string;
568
572
  agentValidUntil?: number;
@@ -571,6 +575,7 @@ export interface WebData3UserState {
571
575
  isVault: boolean;
572
576
  user: string;
573
577
  dexAbstractionEnabled?: boolean;
578
+ abstraction: UserAbstraction;
574
579
  }
575
580
  export interface WebData3AssetCtx {
576
581
  funding: string;
@@ -629,9 +634,9 @@ export interface AssetCtx {
629
634
  * 0 = USDC
630
635
  * 360 = USDH
631
636
  * 235 = USDE
632
- * 268 = USDT
637
+ * 268 = USDT0
633
638
  */
634
- export type CollateralToken = 'USDC' | 'USDH' | 'USDE' | 'USDT';
639
+ export type CollateralToken = 'USDC' | 'USDH' | 'USDE' | 'USDT0';
635
640
  /**
636
641
  * Universe asset metadata
637
642
  */
@@ -731,6 +736,7 @@ export interface RawAssetDto {
731
736
  side: string;
732
737
  fundingPaid?: number;
733
738
  leverage: number;
739
+ targetWeight?: number;
734
740
  }
735
741
  /**
736
742
  * Raw position data from open-positions channel
@@ -806,6 +812,7 @@ export interface AssetMarketData {
806
812
  export interface PairAssetDto {
807
813
  asset: string;
808
814
  weight: number;
815
+ metadata?: TokenMetadata | null;
809
816
  }
810
817
  export interface ActiveAssetGroupItem {
811
818
  longAssets: PairAssetDto[];
@@ -819,7 +826,6 @@ export interface ActiveAssetGroupItem {
819
826
  weightedRatio?: string;
820
827
  weightedPrevRatio?: string;
821
828
  weightedChange24h?: string;
822
- collateralType: 'USDC' | 'USDH' | 'MIXED';
823
829
  }
824
830
  export interface ActiveAssetsResponse {
825
831
  active: ActiveAssetGroupItem[];
@@ -899,3 +905,51 @@ export interface PerpDex {
899
905
  lastDeployerFeeScaleChangeTime: string;
900
906
  }
901
907
  export type PerpDexsResponse = (PerpDex | null)[];
908
+ export interface SpotBalances {
909
+ [coin: string]: number;
910
+ }
911
+ export interface AvailableToTrades {
912
+ [collateralCoin: string]: number;
913
+ }
914
+ export type ExecutionType = "MARKET" | "TRIGGER" | "TWAP" | "LADDER" | "TP" | "SL" | "SPOT_MARKET" | "SPOT_LIMIT" | "SPOT_TWAP";
915
+ export type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE" | "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO";
916
+ export interface PairAssetInput {
917
+ asset: string;
918
+ weight?: number;
919
+ }
920
+ export interface TpSlThresholdInput {
921
+ type: TpSlThresholdType;
922
+ value?: number;
923
+ isTrailing?: boolean;
924
+ trailingDeltaValue?: number;
925
+ trailingActivationValue?: number;
926
+ }
927
+ export interface LadderConfigInput {
928
+ ratioStart: number;
929
+ ratioEnd: number;
930
+ numberOfLevels: number;
931
+ }
932
+ export interface CreatePositionRequestInput {
933
+ slippage: number;
934
+ executionType: ExecutionType;
935
+ leverage: number;
936
+ usdValue: number;
937
+ longAssets?: PairAssetInput[];
938
+ shortAssets?: PairAssetInput[];
939
+ triggerValue?: string | number;
940
+ triggerType?: TriggerType;
941
+ direction?: "MORE_THAN" | "LESS_THAN";
942
+ assetName?: string;
943
+ marketCode?: string;
944
+ twapDuration?: number;
945
+ twapIntervalSeconds?: number;
946
+ randomizeExecution?: boolean;
947
+ referralCode?: string;
948
+ ladderConfig?: LadderConfigInput;
949
+ takeProfit?: TpSlThresholdInput | null;
950
+ stopLoss?: TpSlThresholdInput | null;
951
+ }
952
+ export interface CreatePositionResponseDto {
953
+ orderId: string;
954
+ fills?: ExternalFillDto[];
955
+ }
@@ -1,5 +1,5 @@
1
- import type { AxiosInstance } from 'axios';
2
- import { ApiErrorResponse } from '../types';
1
+ import type { AxiosInstance } from "axios";
2
+ import { ApiErrorResponse } from "../types";
3
3
  export declare function toApiError(error: unknown): ApiErrorResponse;
4
4
  export declare function joinUrl(baseUrl: string, path: string): string;
5
5
  /**
@@ -1,4 +1,4 @@
1
- import type { PairAssetInput } from "../clients/positions";
1
+ import { PairAssetInput } from "../types";
2
2
  /**
3
3
  * Minimum USD value required per asset when creating a position
4
4
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.4-pnl",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",