@pear-protocol/hyperliquid-sdk 0.0.22 → 0.0.26

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.
@@ -0,0 +1,49 @@
1
+ import type { ApiResponse } from '../types';
2
+ export type ExecutionType = 'MARKET' | 'LIMIT' | 'TWAP' | 'LADDER' | 'LIMIT_BTCDOM';
3
+ export type TpSlThresholdType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
4
+ export interface PairAssetInput {
5
+ asset: string;
6
+ weight?: number;
7
+ }
8
+ export interface TpSlThresholdInput {
9
+ type: TpSlThresholdType;
10
+ value: number;
11
+ }
12
+ export interface CreatePositionRequestInput {
13
+ slippage: number;
14
+ executionType: ExecutionType;
15
+ leverage: number;
16
+ usdValue: number;
17
+ longAssets?: PairAssetInput[];
18
+ shortAssets?: PairAssetInput[];
19
+ triggerValue?: number;
20
+ direction?: 'MORE_THAN' | 'LESS_THAN';
21
+ twapDuration?: number;
22
+ randomizeExecution?: boolean;
23
+ takeProfit?: TpSlThresholdInput | null;
24
+ stopLoss?: TpSlThresholdInput | null;
25
+ }
26
+ export type PositionResponseStatus = 'SUCCESS' | 'FAILED' | 'PENDING' | 'PARTIALLY_FILLED' | 'OPEN';
27
+ export interface PositionAssetSummaryDto {
28
+ asset: string;
29
+ side: 'LONG' | 'SHORT';
30
+ size: number;
31
+ entryRatio: number;
32
+ usdValue: number;
33
+ orderId: string;
34
+ }
35
+ export interface CreatePositionResponseDto {
36
+ positionId: string | null;
37
+ orderId: string;
38
+ status: PositionResponseStatus;
39
+ createdAt: string;
40
+ assets?: PositionAssetSummaryDto[];
41
+ stopLoss?: TpSlThresholdInput | null;
42
+ takeProfit?: TpSlThresholdInput | null;
43
+ hyperliquidResult?: any;
44
+ }
45
+ /**
46
+ * Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
47
+ * Caller should supply an accessToken from localStorage.getItem('accessToken')
48
+ */
49
+ export declare function createPosition(baseUrl: string, accessToken: string, payload: CreatePositionRequestInput): Promise<ApiResponse<CreatePositionResponseDto>>;
@@ -0,0 +1,9 @@
1
+ import type { ApiResponse, SyncFillsRequestDto, SyncFillsResponseDto } from '../types';
2
+ /**
3
+ * Sync external fills into Pear Hyperliquid service (POST /sync/fills)
4
+ */
5
+ export declare const syncFills: (baseUrl: string, accessToken: string, payload: SyncFillsRequestDto) => Promise<ApiResponse<SyncFillsResponseDto>>;
6
+ /**
7
+ * Convenience: fetch user fills from HyperLiquid, then sync them to Pear backend
8
+ */
9
+ export declare const syncUserFillsFromHyperliquid: (baseUrl: string, accessToken: string, user: string, aggregateByTime?: boolean) => Promise<ApiResponse<SyncFillsResponseDto>>;
@@ -5,3 +5,8 @@ export * from './useWebData';
5
5
  export * from './useTokenSelectionMetadata';
6
6
  export * from './useHistoricalPriceData';
7
7
  export * from './useBasketCandles';
8
+ export * from './usePerformanceOverlays';
9
+ export * from './useAuth';
10
+ export * from './useAgentWallet';
11
+ export * from './useAutoSyncFills';
12
+ export * from './usePosition';
@@ -0,0 +1,10 @@
1
+ import type { GetAgentWalletResponseDto, CreateAgentWalletResponseDto, UseAgentWalletOptions, AgentWalletState } from '../types';
2
+ export declare function useAgentWallet({ baseUrl }: UseAgentWalletOptions): {
3
+ readonly agentWallet: AgentWalletState;
4
+ readonly isReady: boolean;
5
+ readonly loading: false;
6
+ readonly error: null;
7
+ readonly refreshAgentWalletStatus: () => Promise<GetAgentWalletResponseDto>;
8
+ readonly createAgentWallet: () => Promise<CreateAgentWalletResponseDto>;
9
+ readonly notifyAgentWalletApproved: () => Promise<GetAgentWalletResponseDto>;
10
+ };
@@ -0,0 +1,12 @@
1
+ export declare function useAuth(): {
2
+ readonly status: import("..").AuthStatus;
3
+ readonly isAuthenticated: boolean;
4
+ readonly accessToken: string | null;
5
+ readonly user: import("..").UserProfile | null;
6
+ readonly error: string | null;
7
+ readonly getEip712: (address: string) => Promise<any>;
8
+ readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
9
+ readonly loginWithPrivyToken: (address: string, appId: string, accessToken: string) => Promise<void>;
10
+ readonly refreshTokens: () => Promise<any>;
11
+ readonly logout: () => Promise<void>;
12
+ };
@@ -0,0 +1,21 @@
1
+ import type { SyncFillsResponseDto } from '../types';
2
+ export interface AutoSyncFillsOptions {
3
+ baseUrl: string;
4
+ accessToken: string;
5
+ address: string | null;
6
+ intervalMs?: number;
7
+ aggregateByTime?: boolean;
8
+ enabled?: boolean;
9
+ }
10
+ export interface AutoSyncFillsState {
11
+ lastRunAt: number | null;
12
+ lastResult: SyncFillsResponseDto | null;
13
+ error: string | null;
14
+ isSyncing: boolean;
15
+ triggerSync: () => Promise<void>;
16
+ }
17
+ /**
18
+ * Listens to address changes and periodically syncs user fills
19
+ * Defaults: aggregate=true, interval=60s
20
+ */
21
+ export declare function useAutoSyncFills(options: AutoSyncFillsOptions): AutoSyncFillsState;
@@ -1,6 +1,8 @@
1
- import type { CandleInterval, WeightedCandleData } from '../types';
1
+ import type { CandleData, CandleInterval } from '../types';
2
2
  export interface UseBasketCandlesReturn {
3
- fetchBasketCandles: (startTime: number, endTime: number, interval: CandleInterval) => Promise<WeightedCandleData[]>;
3
+ fetchBasketCandles: (startTime: number, endTime: number, interval: CandleInterval) => Promise<CandleData[]>;
4
+ fetchPerformanceCandles: (startTime: number, endTime: number, interval: CandleInterval, symbol: string) => Promise<CandleData[]>;
5
+ fetchOverallPerformanceCandles: (startTime: number, endTime: number, interval: CandleInterval) => Promise<CandleData[]>;
4
6
  isLoading: boolean;
5
7
  addRealtimeListener: (cb: RealtimeBarsCallback) => string;
6
8
  removeRealtimeListener: (id: string) => void;
@@ -1,8 +1,10 @@
1
+ import { TokenHistoricalPriceData } from '../store/historicalPriceDataStore';
1
2
  import type { CandleData, CandleInterval } from '../types';
2
3
  export interface UseHistoricalPriceDataReturn {
3
4
  fetchHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval, callback?: (data: Record<string, CandleData[]>) => void) => Promise<Record<string, CandleData[]>>;
4
5
  hasHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval) => boolean;
5
6
  getHistoricalPriceData: (startTime: number, endTime: number, interval: CandleInterval) => Record<string, CandleData[]>;
7
+ getAllHistoricalPriceData(): Promise<Record<string, TokenHistoricalPriceData>>;
6
8
  isLoading: (symbol?: string) => boolean;
7
9
  clearCache: () => void;
8
10
  }
@@ -0,0 +1,14 @@
1
+ export interface PerformanceOverlay {
2
+ id: string;
3
+ symbol: string;
4
+ label: string;
5
+ color: string;
6
+ enabled: boolean;
7
+ type: 'asset' | 'portfolio';
8
+ weight?: number;
9
+ }
10
+ export interface UsePerformanceOverlaysReturn {
11
+ overlays: PerformanceOverlay[];
12
+ generateOverlaySymbols: () => string[];
13
+ }
14
+ export declare const usePerformanceOverlays: () => UsePerformanceOverlaysReturn;
@@ -0,0 +1,7 @@
1
+ import { type CreatePositionRequestInput, type CreatePositionResponseDto } from '../clients/positions';
2
+ import type { ApiResponse, OpenPositionDto } from '../types';
3
+ export declare function usePosition(): {
4
+ readonly createPosition: (payload: CreatePositionRequestInput) => Promise<ApiResponse<CreatePositionResponseDto>>;
5
+ readonly openPositions: OpenPositionDto[] | null;
6
+ readonly isLoading: boolean;
7
+ };
@@ -1,20 +1,9 @@
1
1
  import type { AccountSummaryResponseDto, OpenLimitOrderDto } from '../types';
2
2
  import type { TradeHistoryDataDto } from '../types';
3
- import type { OpenPositionDto } from '../types';
4
3
  export declare const useTradeHistories: () => {
5
4
  data: TradeHistoryDataDto[] | null;
6
5
  isLoading: boolean;
7
6
  };
8
- /**
9
- * Hook to access open positions with real-time calculations and loading state
10
- */
11
- export declare const useOpenPositions: () => {
12
- data: null;
13
- isLoading: boolean;
14
- } | {
15
- data: OpenPositionDto[];
16
- isLoading: boolean;
17
- };
18
7
  /**
19
8
  * Hook to access open orders with loading state
20
9
  */