@pear-protocol/hyperliquid-sdk 0.0.11 → 0.0.13

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.
@@ -3,7 +3,7 @@ import { ReadyState } from 'react-use-websocket';
3
3
  import { PearHyperliquidClient } from './client';
4
4
  import { PearHyperliquidConfig } from './types';
5
5
  import { PearMigrationSDK } from './migration-sdk';
6
- import type { RawPositionDto, OpenLimitOrderDto, AccountSummaryResponseDto, WebData2Response, WsAllMidsData, TradeHistoryDataDto, TokenSelection, TokenConflict } from './types';
6
+ import type { RawPositionDto, OpenLimitOrderDto, AccountSummaryResponseDto, WebData2Response, WsAllMidsData, TradeHistoryDataDto, TokenSelection, TokenConflict, ActiveAssetData } from './types';
7
7
  interface WebSocketData {
8
8
  tradeHistories: TradeHistoryDataDto[] | null;
9
9
  openPositions: RawPositionDto[] | null;
@@ -21,6 +21,7 @@ interface TokenSelectionState {
21
21
  selectorConfig: TokenSelectorConfig | null;
22
22
  openConflictModal: boolean;
23
23
  conflicts: TokenConflict[];
24
+ leverageMatched: boolean;
24
25
  }
25
26
  export interface PearHyperliquidContextType {
26
27
  client: PearHyperliquidClient;
@@ -36,6 +37,7 @@ export interface PearHyperliquidContextType {
36
37
  nativeLastError: string | null;
37
38
  webData2: WebData2Response | null;
38
39
  allMids: WsAllMidsData | null;
40
+ activeAssetData: Record<string, ActiveAssetData> | null;
39
41
  tokenSelection: TokenSelectionState;
40
42
  setTokenSelection: React.Dispatch<React.SetStateAction<TokenSelectionState>>;
41
43
  }
package/dist/types.d.ts CHANGED
@@ -212,7 +212,7 @@ export type WebSocketConnectionState = 'connecting' | 'connected' | 'disconnecte
212
212
  /**
213
213
  * WebSocket channels
214
214
  */
215
- export type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'webData2' | 'allMids';
215
+ export type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'webData2' | 'allMids' | 'activeAssetData';
216
216
  /**
217
217
  * WebSocket subscription message
218
218
  */
@@ -548,6 +548,24 @@ export interface RawPositionDto {
548
548
  longAssets: RawAssetDto[];
549
549
  shortAssets: RawAssetDto[];
550
550
  }
551
+ /**
552
+ * Leverage information from activeAssetData
553
+ */
554
+ export interface LeverageInfo {
555
+ type: string;
556
+ value: number;
557
+ }
558
+ /**
559
+ * Active asset data from WebSocket
560
+ */
561
+ export interface ActiveAssetData {
562
+ user: string;
563
+ coin: string;
564
+ leverage: LeverageInfo;
565
+ maxTradeSzs: [string, string];
566
+ availableToTrade: [string, string];
567
+ markPx: string;
568
+ }
551
569
  /**
552
570
  * Token metadata from WebData2 and AllMids
553
571
  */
@@ -562,6 +580,9 @@ export interface TokenMetadata {
562
580
  oraclePrice: number;
563
581
  openInterest: string;
564
582
  dayVolume: string;
583
+ leverage?: LeverageInfo;
584
+ maxTradeSzs?: [string, string];
585
+ availableToTrade?: [string, string];
565
586
  }
566
587
  /**
567
588
  * Enhanced token selection with weight and metadata for basket trading
@@ -1,4 +1,4 @@
1
- import type { WebData2Response, WsAllMidsData, TokenMetadata } from '../types';
1
+ import type { WebData2Response, WsAllMidsData, TokenMetadata, ActiveAssetData } from '../types';
2
2
  /**
3
3
  * Extracts token metadata from WebData2 and AllMids data
4
4
  */
@@ -8,17 +8,19 @@ export declare class TokenMetadataExtractor {
8
8
  * @param symbol - Token symbol
9
9
  * @param webData2 - WebData2 response containing asset context and universe data
10
10
  * @param allMids - AllMids data containing current prices
11
+ * @param activeAssetData - Optional active asset data containing leverage information
11
12
  * @returns TokenMetadata or null if token not found
12
13
  */
13
- static extractTokenMetadata(symbol: string, webData2: WebData2Response | null, allMids: WsAllMidsData | null): TokenMetadata | null;
14
+ static extractTokenMetadata(symbol: string, webData2: WebData2Response | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): TokenMetadata | null;
14
15
  /**
15
16
  * Extracts metadata for multiple tokens
16
17
  * @param symbols - Array of token symbols
17
18
  * @param webData2 - WebData2 response
18
19
  * @param allMids - AllMids data
20
+ * @param activeAssetData - Optional active asset data containing leverage information
19
21
  * @returns Record of symbol to TokenMetadata
20
22
  */
21
- static extractMultipleTokensMetadata(symbols: string[], webData2: WebData2Response | null, allMids: WsAllMidsData | null): Record<string, TokenMetadata | null>;
23
+ static extractMultipleTokensMetadata(symbols: string[], webData2: WebData2Response | null, allMids: WsAllMidsData | null, activeAssetData?: Record<string, ActiveAssetData> | null): Record<string, TokenMetadata | null>;
22
24
  /**
23
25
  * Checks if token data is available in WebData2
24
26
  * @param symbol - Token symbol
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "main": "dist/index.js",
6
- "module": "dist/index.esm.js",
6
+ "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "files": [
9
9
  "dist"
@@ -15,25 +15,35 @@
15
15
  "clean": "rimraf dist"
16
16
  },
17
17
  "dependencies": {
18
- "axios": "^1.6.0",
19
18
  "react-use-websocket": "^4.8.1"
20
19
  },
21
20
  "peerDependencies": {
22
- "react": ">=16.8.0"
21
+ "react": ">=16.8.0",
22
+ "react-dom": ">=16.8.0",
23
+ "axios": "^1.6.0"
23
24
  },
24
25
  "devDependencies": {
25
26
  "@rollup/plugin-commonjs": "^25.0.0",
26
27
  "@rollup/plugin-node-resolve": "^15.0.0",
28
+ "@rollup/plugin-terser": "^0.4.4",
27
29
  "@rollup/plugin-typescript": "^11.0.0",
28
30
  "@types/react": "^18.0.0",
29
- "react": "^18.0.0",
31
+ "esbuild": "^0.25.9",
30
32
  "rimraf": "^5.0.0",
31
33
  "rollup": "^3.0.0",
32
34
  "rollup-plugin-dts": "^6.0.0",
35
+ "rollup-plugin-esbuild": "^6.2.1",
33
36
  "tslib": "^2.6.0",
34
37
  "typescript": "^5.0.0"
35
38
  },
36
- "keywords": ["pear", "hyperliquid", "sdk", "react", "trading", "api"],
39
+ "keywords": [
40
+ "pear",
41
+ "hyperliquid",
42
+ "sdk",
43
+ "react",
44
+ "trading",
45
+ "api"
46
+ ],
37
47
  "author": "Pear Protocol",
38
48
  "license": "MIT",
39
49
  "repository": {
@@ -46,4 +56,4 @@
46
56
  "access": "public"
47
57
  },
48
58
  "private": false
49
- }
59
+ }