@pear-protocol/hyperliquid-sdk 0.0.10 → 0.0.12
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/hooks/index.d.ts +2 -0
- package/dist/hooks/useTokenSelection.d.ts +33 -0
- package/dist/index.d.ts +111 -2
- package/dist/index.js +11 -3447
- package/dist/provider.d.ts +15 -1
- package/dist/types.d.ts +31 -0
- package/dist/utils/conflict-detector.d.ts +14 -0
- package/dist/utils/token-metadata-extractor.d.ts +29 -0
- package/package.json +18 -8
- package/dist/index.esm.js +0 -3439
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/provider.d.ts
CHANGED
|
@@ -3,13 +3,25 @@ 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 } from './types';
|
|
6
|
+
import type { RawPositionDto, OpenLimitOrderDto, AccountSummaryResponseDto, WebData2Response, WsAllMidsData, TradeHistoryDataDto, TokenSelection, TokenConflict } from './types';
|
|
7
7
|
interface WebSocketData {
|
|
8
8
|
tradeHistories: TradeHistoryDataDto[] | null;
|
|
9
9
|
openPositions: RawPositionDto[] | null;
|
|
10
10
|
openOrders: OpenLimitOrderDto[] | null;
|
|
11
11
|
accountSummary: AccountSummaryResponseDto | null;
|
|
12
12
|
}
|
|
13
|
+
export interface TokenSelectorConfig {
|
|
14
|
+
isLong: boolean;
|
|
15
|
+
index: number;
|
|
16
|
+
}
|
|
17
|
+
interface TokenSelectionState {
|
|
18
|
+
longTokens: TokenSelection[];
|
|
19
|
+
shortTokens: TokenSelection[];
|
|
20
|
+
openTokenSelector: boolean;
|
|
21
|
+
selectorConfig: TokenSelectorConfig | null;
|
|
22
|
+
openConflictModal: boolean;
|
|
23
|
+
conflicts: TokenConflict[];
|
|
24
|
+
}
|
|
13
25
|
export interface PearHyperliquidContextType {
|
|
14
26
|
client: PearHyperliquidClient;
|
|
15
27
|
migrationSDK: PearMigrationSDK;
|
|
@@ -24,6 +36,8 @@ export interface PearHyperliquidContextType {
|
|
|
24
36
|
nativeLastError: string | null;
|
|
25
37
|
webData2: WebData2Response | null;
|
|
26
38
|
allMids: WsAllMidsData | null;
|
|
39
|
+
tokenSelection: TokenSelectionState;
|
|
40
|
+
setTokenSelection: React.Dispatch<React.SetStateAction<TokenSelectionState>>;
|
|
27
41
|
}
|
|
28
42
|
export declare const PearHyperliquidContext: React.Context<PearHyperliquidContextType | undefined>;
|
|
29
43
|
interface PearHyperliquidProviderProps {
|
package/dist/types.d.ts
CHANGED
|
@@ -548,3 +548,34 @@ export interface RawPositionDto {
|
|
|
548
548
|
longAssets: RawAssetDto[];
|
|
549
549
|
shortAssets: RawAssetDto[];
|
|
550
550
|
}
|
|
551
|
+
/**
|
|
552
|
+
* Token metadata from WebData2 and AllMids
|
|
553
|
+
*/
|
|
554
|
+
export interface TokenMetadata {
|
|
555
|
+
currentPrice: number;
|
|
556
|
+
prevDayPrice: number;
|
|
557
|
+
priceChange24h: number;
|
|
558
|
+
priceChange24hPercent: number;
|
|
559
|
+
netFunding: number;
|
|
560
|
+
maxLeverage: number;
|
|
561
|
+
markPrice: number;
|
|
562
|
+
oraclePrice: number;
|
|
563
|
+
openInterest: string;
|
|
564
|
+
dayVolume: string;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Enhanced token selection with weight and metadata for basket trading
|
|
568
|
+
*/
|
|
569
|
+
export interface TokenSelection {
|
|
570
|
+
symbol: string;
|
|
571
|
+
weight: number;
|
|
572
|
+
metadata?: TokenMetadata;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Token conflict information for position conflicts
|
|
576
|
+
*/
|
|
577
|
+
export interface TokenConflict {
|
|
578
|
+
symbol: string;
|
|
579
|
+
conflictType: 'long' | 'short';
|
|
580
|
+
conflictMessage: string;
|
|
581
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TokenSelection, TokenConflict } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Detects conflicts between selected tokens and existing positions
|
|
4
|
+
*/
|
|
5
|
+
export declare class ConflictDetector {
|
|
6
|
+
/**
|
|
7
|
+
* Detects conflicts between token selections and open positions
|
|
8
|
+
* @param longTokens - Selected long tokens
|
|
9
|
+
* @param shortTokens - Selected short tokens
|
|
10
|
+
* @param openPositions - Current open positions from API
|
|
11
|
+
* @returns Array of detected conflicts
|
|
12
|
+
*/
|
|
13
|
+
static detectConflicts(longTokens: TokenSelection[], shortTokens: TokenSelection[], openPositions: any[] | null): TokenConflict[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { WebData2Response, WsAllMidsData, TokenMetadata } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Extracts token metadata from WebData2 and AllMids data
|
|
4
|
+
*/
|
|
5
|
+
export declare class TokenMetadataExtractor {
|
|
6
|
+
/**
|
|
7
|
+
* Extracts comprehensive token metadata
|
|
8
|
+
* @param symbol - Token symbol
|
|
9
|
+
* @param webData2 - WebData2 response containing asset context and universe data
|
|
10
|
+
* @param allMids - AllMids data containing current prices
|
|
11
|
+
* @returns TokenMetadata or null if token not found
|
|
12
|
+
*/
|
|
13
|
+
static extractTokenMetadata(symbol: string, webData2: WebData2Response | null, allMids: WsAllMidsData | null): TokenMetadata | null;
|
|
14
|
+
/**
|
|
15
|
+
* Extracts metadata for multiple tokens
|
|
16
|
+
* @param symbols - Array of token symbols
|
|
17
|
+
* @param webData2 - WebData2 response
|
|
18
|
+
* @param allMids - AllMids data
|
|
19
|
+
* @returns Record of symbol to TokenMetadata
|
|
20
|
+
*/
|
|
21
|
+
static extractMultipleTokensMetadata(symbols: string[], webData2: WebData2Response | null, allMids: WsAllMidsData | null): Record<string, TokenMetadata | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Checks if token data is available in WebData2
|
|
24
|
+
* @param symbol - Token symbol
|
|
25
|
+
* @param webData2 - WebData2 response
|
|
26
|
+
* @returns boolean indicating if token exists in universe
|
|
27
|
+
*/
|
|
28
|
+
static isTokenAvailable(symbol: string, webData2: WebData2Response | null): boolean;
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pear-protocol/hyperliquid-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "React SDK for Pear Protocol Hyperliquid API integration",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.
|
|
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
|
-
"react-use-websocket": "^4.8.1"
|
|
18
|
+
"axios": "^1.6.0"
|
|
20
19
|
},
|
|
21
20
|
"peerDependencies": {
|
|
22
|
-
"react": ">=16.8.0"
|
|
21
|
+
"react": ">=16.8.0",
|
|
22
|
+
"react-dom": ">=16.8.0",
|
|
23
|
+
"react-use-websocket": "^4.8.1"
|
|
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
|
-
"
|
|
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": [
|
|
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
|
+
}
|