@pear-protocol/hyperliquid-sdk 0.0.55 → 0.0.57

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,25 +1,12 @@
1
1
  import React, { ReactNode } from 'react';
2
- import type { UserProfile } from './types';
3
- import { AuthStatus } from './types';
4
2
  export interface PearHyperliquidContextType {
3
+ clientId: string;
5
4
  apiBaseUrl: string;
6
5
  wsUrl: string;
7
- address: string | null;
8
- setAddress: (address: string | null) => void;
9
6
  isConnected: boolean;
10
7
  lastError: string | null;
11
8
  nativeIsConnected: boolean;
12
9
  nativeLastError: string | null;
13
- authStatus: AuthStatus;
14
- isAuthenticated: boolean;
15
- accessToken: string | null;
16
- user: UserProfile | null;
17
- authError: string | null;
18
- getEip712: (address: string) => Promise<any>;
19
- loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
20
- loginWithPrivyToken: (address: string, appId: string, accessToken: string) => Promise<void>;
21
- refreshTokens: () => Promise<any>;
22
- logout: () => Promise<void>;
23
10
  }
24
11
  export declare const PearHyperliquidContext: React.Context<PearHyperliquidContextType | undefined>;
25
12
  interface PearHyperliquidProviderProps {
@@ -37,19 +24,4 @@ export declare const PearHyperliquidProvider: React.FC<PearHyperliquidProviderPr
37
24
  * Prefer using the more specific hooks below when possible.
38
25
  */
39
26
  export declare function usePearHyperliquid(): PearHyperliquidContextType;
40
- /**
41
- * Provider-aware Auth hook. Uses auth state/actions provided by PearHyperliquidProvider.
42
- * Callers do not need to pass baseUrl/clientId.
43
- */
44
- export declare function usePearAuth(): {
45
- readonly status: AuthStatus;
46
- readonly isAuthenticated: boolean;
47
- readonly user: UserProfile | null;
48
- readonly error: string | null;
49
- readonly getEip712: (address: string) => Promise<any>;
50
- readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
51
- readonly loginWithPrivyToken: (address: string, appId: string, accessToken: string) => Promise<void>;
52
- readonly refreshTokens: () => Promise<any>;
53
- readonly logout: () => Promise<void>;
54
- };
55
27
  export {};
package/dist/types.d.ts CHANGED
@@ -180,8 +180,10 @@ export interface TradeHistoryDataDto {
180
180
  exitRatio: number;
181
181
  entryPriceRatio?: number;
182
182
  exitpPriceRatio?: number;
183
- longAssets: TradeHistoryAssetDataDto[];
184
- shortAssets: TradeHistoryAssetDataDto[];
183
+ closedLongAssets: TradeHistoryAssetDataDto[];
184
+ closedShortAssets: TradeHistoryAssetDataDto[];
185
+ positionLongAssets?: string[];
186
+ positionShortAssets?: string[];
185
187
  createdAt: string;
186
188
  }
187
189
  /**
@@ -207,6 +209,7 @@ export interface PositionAssetDetailDto {
207
209
  unrealizedPnl: number;
208
210
  liquidationPrice: number;
209
211
  initialWeight: number;
212
+ fundingPaid?: number;
210
213
  }
211
214
  export interface TpSlThreshold {
212
215
  type: 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
@@ -335,12 +338,6 @@ export interface AddressState {
335
338
  autoConnect: boolean;
336
339
  previousAddresses: string[];
337
340
  }
338
- export declare enum AuthStatus {
339
- Idle = "idle",
340
- Authenticating = "authenticating",
341
- Authenticated = "authenticated",
342
- Error = "error"
343
- }
344
341
  export interface UseAuthOptions {
345
342
  baseUrl: string;
346
343
  clientId: string;
@@ -356,7 +353,7 @@ export interface EIP712AuthDetails {
356
353
  name: string;
357
354
  version: string;
358
355
  chainId: number;
359
- verifyingContract: string;
356
+ verifyingContract: `0x${string}`;
360
357
  };
361
358
  types: Record<string, Array<{
362
359
  name: string;
@@ -600,6 +597,7 @@ export interface RawAssetDto {
600
597
  entryPrice: number;
601
598
  size: number;
602
599
  side: string;
600
+ fundingPaid?: number;
603
601
  }
604
602
  /**
605
603
  * Raw position data from open-positions channel
@@ -1,3 +1,26 @@
1
+ import type { AxiosInstance } from 'axios';
1
2
  import { ApiErrorResponse } from '../types';
2
3
  export declare function toApiError(error: unknown): ApiErrorResponse;
3
4
  export declare function joinUrl(baseUrl: string, path: string): string;
5
+ /**
6
+ * Shared Axios instance with interceptors.
7
+ * - Request: inject Authorization headers from buildAuthHeaders when absent
8
+ * - Response: on 401, clear tokens and emit a logout event
9
+ */
10
+ export declare const apiClient: AxiosInstance;
11
+ /**
12
+ * Attach auth-aware Axios interceptors to `apiClient`.
13
+ * - Request: adds `Authorization: Bearer <accessToken>` for requests to `apiBaseUrl`.
14
+ * - Response: if a request returns 401, attempts token refresh and retries the request.
15
+ * If the 401 came from the refresh endpoint (or refresh fails/returns 401), calls `logout()`.
16
+ *
17
+ */
18
+ export declare function addAuthInterceptors(params: {
19
+ apiBaseUrl: string;
20
+ getAccessToken: () => string | null;
21
+ refreshTokens: () => Promise<{
22
+ accessToken: string;
23
+ refreshToken: string;
24
+ } | any>;
25
+ logout: () => Promise<void> | void;
26
+ }): () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.0.55",
3
+ "version": "0.0.57",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",