@pear-protocol/hyperliquid-sdk 0.0.7 → 0.0.8

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.
@@ -7,9 +7,9 @@ export declare enum PositionSide {
7
7
  SHORT = "SHORT"
8
8
  }
9
9
  /**
10
- * Position calculation utility class
10
+ * Aggregate position calculation utility class that handles cross-position asset syncing
11
11
  */
12
- export declare class PositionCalculator {
12
+ export declare class AggregatePositionCalculator {
13
13
  private webData2;
14
14
  private allMids;
15
15
  constructor(webData2: WebData2Response | null, allMids: WsAllMidsData | null);
@@ -23,22 +23,27 @@ export declare class PositionCalculator {
23
23
  getUserPositions(): AssetPosition[];
24
24
  /**
25
25
  * Calculate updated open positions by syncing platform positions with HyperLiquid data
26
+ * Uses aggregate totals across all positions for accurate cross-position sync
26
27
  */
27
28
  calculateOpenPositions(platformPositions: OpenPositionDto[]): OpenPositionDto[];
28
29
  /**
29
- * Sync a single position with HyperLiquid data
30
+ * Calculate total platform sizes per asset across all positions
30
31
  */
31
- private syncPositionWithHyperliquid;
32
+ private calculatePlatformTotalsByAsset;
32
33
  /**
33
- * Group assets by their base currency
34
+ * Extract base currency from asset name (handles "LINK/USD" -> "LINK")
34
35
  */
35
- private groupAssetsByBaseCurrency;
36
+ private extractBaseCurrency;
36
37
  /**
37
- * Sync a group of assets (same base currency) with HyperLiquid position data
38
+ * Sync a single position with HyperLiquid data using aggregate totals
38
39
  */
39
- private syncAssetGroupWithHyperliquid;
40
+ private syncPositionWithAggregateData;
40
41
  /**
41
- * Determine sync status based on asset sync results
42
+ * Sync individual asset with aggregate data awareness
43
+ */
44
+ private syncAssetWithAggregateData;
45
+ /**
46
+ * Determine sync status with sophisticated side-aware logic
42
47
  */
43
48
  private determineSyncStatus;
44
49
  /**
@@ -50,11 +55,11 @@ export declare class PositionCalculator {
50
55
  */
51
56
  private mapSyncResultToAssetDto;
52
57
  /**
53
- * Calculate entry ratio (weighted long entry value / weighted short entry value)
58
+ * Calculate entry ratio using actual sizes from sync results
54
59
  */
55
60
  private calculateEntryRatio;
56
61
  /**
57
- * Calculate mark ratio (weighted long mark value / weighted short mark value)
62
+ * Calculate mark ratio using actual sizes and current prices
58
63
  */
59
64
  private calculateMarkRatio;
60
65
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",