@pear-protocol/hyperliquid-sdk 0.0.20 → 0.0.24

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.
@@ -8,6 +8,7 @@ interface UserSelectionState {
8
8
  openConflictModal: boolean;
9
9
  conflicts: TokenConflict[];
10
10
  candleInterval: CandleInterval;
11
+ isWeightBalanced: boolean;
11
12
  setLongTokens: (tokens: TokenSelection[]) => void;
12
13
  setShortTokens: (tokens: TokenSelection[]) => void;
13
14
  setOpenTokenSelector: (open: boolean) => void;
package/dist/types.d.ts CHANGED
@@ -287,6 +287,7 @@ export interface PositionAssetDetailDto {
287
287
  unrealizedPnl: number;
288
288
  liquidationPrice: number;
289
289
  isExternallyModified: boolean;
290
+ initialWeight: number;
290
291
  }
291
292
  /**
292
293
  * Position sync status
@@ -620,22 +621,19 @@ export type CandleInterval = "1m" | "3m" | "5m" | "15m" | "30m" | "1h" | "2h" |
620
621
  * Candle data structure from WebSocket
621
622
  */
622
623
  export interface CandleData {
624
+ s?: string;
623
625
  t: number;
624
626
  T: number;
625
- s: string;
626
- i: string;
627
- o: string;
628
- c: string;
629
- h: string;
630
- l: string;
631
- v: string;
632
- n: number;
627
+ o: number;
628
+ c: number;
629
+ h: number;
630
+ l: number;
633
631
  }
634
632
  /**
635
633
  * Candle chart data organized by symbol only
636
634
  * Since new candles always have latest timestamp, no need to store per interval
637
635
  */
638
- export type CandleChartData = Record<string, CandleData>;
636
+ export type CandleChartData = Map<string, CandleData>;
639
637
  /**
640
638
  * Historical candle data request
641
639
  */
@@ -648,16 +646,3 @@ export interface CandleSnapshotRequest {
648
646
  };
649
647
  type: "candleSnapshot";
650
648
  }
651
- /**
652
- * Weighted candle data for chart visualization
653
- */
654
- export interface WeightedCandleData {
655
- t: number;
656
- T: number;
657
- o: number;
658
- c: number;
659
- h: number;
660
- l: number;
661
- v: number;
662
- n: number;
663
- }
@@ -1,4 +1,4 @@
1
- import type { CandleData, TokenSelection, WeightedCandleData } from '../types';
1
+ import type { CandleData, TokenSelection } from '../types';
2
2
  /**
3
3
  * Create efficient timestamp-based lookup maps for candle data
4
4
  */
@@ -21,4 +21,4 @@ export declare const getCompleteTimestamps: (candleLookups: Record<string, Map<n
21
21
  * Compute basket candles from individual token candles using weighted ratios
22
22
  * Optimized version that creates lookup maps once and reuses them
23
23
  */
24
- export declare const computeBasketCandles: (longTokens: TokenSelection[], shortTokens: TokenSelection[], tokenCandles: Record<string, CandleData[]>) => WeightedCandleData[];
24
+ export declare const computeBasketCandles: (longTokens: TokenSelection[], shortTokens: TokenSelection[], tokenCandles: Record<string, CandleData[]>) => CandleData[];
@@ -0,0 +1,9 @@
1
+ import type { CandleInterval } from '../types';
2
+ /**
3
+ * Maps TradingView ResolutionString to CandleInterval
4
+ */
5
+ export declare function mapTradingViewIntervalToCandleInterval(interval: string): CandleInterval;
6
+ /**
7
+ * Maps CandleInterval to TradingView ResolutionString
8
+ */
9
+ export declare function mapCandleIntervalToTradingViewInterval(interval: CandleInterval): string;
@@ -1,22 +1,2 @@
1
- import type { OpenPositionDto, WebData2Response, WsAllMidsData, RawPositionDto } from '../types';
2
- export declare class PositionProcessor {
3
- private webData2;
4
- private allMids;
5
- constructor(webData2: WebData2Response | null, allMids: WsAllMidsData | null);
6
- execute(rawPositions: RawPositionDto[]): OpenPositionDto[];
7
- private getUserPositions;
8
- private getMarketPrice;
9
- private calculatePlatformTotalsByAsset;
10
- private extractBaseCurrency;
11
- private syncPositionWithAggregateData;
12
- private determineSyncStatus;
13
- private syncAssetWithAggregateData;
14
- private mapPositionToDtoWithSyncData;
15
- private mapAssetToDetailDto;
16
- private calculateEntryRatio;
17
- private calculateMarkRatio;
18
- private calculateNetFundingFromSyncResults;
19
- private calculateTotalUnrealizedPnlFromSyncResults;
20
- private calculateCurrentTotalPositionValue;
21
- private calculateEntryTotalPositionValue;
22
- }
1
+ import { OpenPositionDto, RawPositionDto, WebData2Response, WsAllMidsData } from "../types";
2
+ export declare const buildPositionValue: (rawPositions: RawPositionDto[], webData2: WebData2Response, allMids: WsAllMidsData) => OpenPositionDto[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.0.20",
3
+ "version": "0.0.24",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -18,6 +18,8 @@
18
18
  "scripts": {
19
19
  "build": "rollup -c",
20
20
  "dev": "rollup -c -w",
21
+ "copy-watch": "nodemon --watch dist --exec \"npm run copy-to-node-modules\"",
22
+ "copy-to-node-modules": "cp -r dist/* ../node_modules/@pear-protocol/hyperliquid-sdk/dist/",
21
23
  "type-check": "tsc --noEmit",
22
24
  "clean": "rimraf dist"
23
25
  },
@@ -35,9 +37,10 @@
35
37
  "@rollup/plugin-terser": "^0.4.4",
36
38
  "@rollup/plugin-typescript": "^11.0.0",
37
39
  "@types/react": "^18.0.0",
40
+ "concurrently": "^9.2.1",
41
+ "esbuild": "^0.25.9",
38
42
  "react": "^18.3.1",
39
43
  "react-dom": "^18.3.1",
40
- "esbuild": "^0.25.9",
41
44
  "rimraf": "^5.0.0",
42
45
  "rollup": "^3.0.0",
43
46
  "rollup-plugin-dts": "^6.0.0",