@pear-protocol/hyperliquid-sdk 0.0.7 → 0.0.9

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,5 +1,5 @@
1
- import type { OpenPositionDto, WebData2Response, WsAllMidsData } from '../types';
1
+ import type { OpenPositionDto, RawPositionDto, WebData2Response, WsAllMidsData } from '../types';
2
2
  /**
3
3
  * Hook that calculates open positions by syncing platform positions with HyperLiquid real-time data
4
4
  */
5
- export declare const useCalculatedOpenPositions: (platformPositions: OpenPositionDto[] | null, webData2: WebData2Response | null, allMids: WsAllMidsData | null) => OpenPositionDto[] | null;
5
+ export declare const useCalculatedOpenPositions: (platformPositions: RawPositionDto[] | null, webData2: WebData2Response | null, allMids: WsAllMidsData | null) => OpenPositionDto[] | null;
package/dist/index.d.ts CHANGED
@@ -490,13 +490,13 @@ interface AssetPosition {
490
490
  returnOnEquity: string;
491
491
  szi: string;
492
492
  unrealizedPnl: string;
493
+ cumFunding: {
494
+ allTime: string;
495
+ sinceChange: string;
496
+ sinceOpen: string;
497
+ };
493
498
  };
494
499
  type: string;
495
- cumFunding: {
496
- allTime: string;
497
- sinceChange: string;
498
- sinceOpen: string;
499
- };
500
500
  }
501
501
  /**
502
502
  * Asset information detail
@@ -514,6 +514,30 @@ interface AssetInformationDetail {
514
514
  priceChange: number;
515
515
  assetIndex: number;
516
516
  }
517
+ /**
518
+ * Raw asset data from open-positions channel
519
+ */
520
+ interface RawAssetDto {
521
+ coin: string;
522
+ entryPrice: number;
523
+ size: number;
524
+ side: string;
525
+ }
526
+ /**
527
+ * Raw position data from open-positions channel
528
+ */
529
+ interface RawPositionDto {
530
+ positionId: string;
531
+ address: string;
532
+ leverage: number;
533
+ stopLoss: number | null;
534
+ takeProfit: number | null;
535
+ status: string;
536
+ createdAt: string;
537
+ updatedAt: string;
538
+ longAssets: RawAssetDto[];
539
+ shortAssets: RawAssetDto[];
540
+ }
517
541
 
518
542
  /**
519
543
  * Main SDK client for Pear Protocol Hyperliquid API integration
@@ -668,7 +692,7 @@ declare const useAccountSummary: () => AccountSummaryResponseDto | null;
668
692
  /**
669
693
  * Hook that calculates open positions by syncing platform positions with HyperLiquid real-time data
670
694
  */
671
- declare const useCalculatedOpenPositions: (platformPositions: OpenPositionDto[] | null, webData2: WebData2Response | null, allMids: WsAllMidsData | null) => OpenPositionDto[] | null;
695
+ declare const useCalculatedOpenPositions: (platformPositions: RawPositionDto[] | null, webData2: WebData2Response | null, allMids: WsAllMidsData | null) => OpenPositionDto[] | null;
672
696
 
673
697
  /**
674
698
  * Hook that calculates account summary by syncing platform data with HyperLiquid real-time data
@@ -677,7 +701,7 @@ declare const useCalculatedAccountSummary: (platformAccountSummary: AccountSumma
677
701
 
678
702
  interface WebSocketData {
679
703
  tradeHistories: PaginatedTradeHistoryResponseDto | null;
680
- openPositions: OpenPositionDto[] | null;
704
+ openPositions: RawPositionDto[] | null;
681
705
  openOrders: OpenLimitOrderDto[] | null;
682
706
  accountSummary: AccountSummaryResponseDto | null;
683
707
  }
@@ -705,82 +729,6 @@ interface UseHyperliquidNativeWebSocketReturn {
705
729
  }
706
730
  declare const useHyperliquidNativeWebSocket: ({ address }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
707
731
 
708
- /**
709
- * Position side enum for calculations
710
- */
711
- declare enum PositionSide {
712
- LONG = "LONG",
713
- SHORT = "SHORT"
714
- }
715
- /**
716
- * Position calculation utility class
717
- */
718
- declare class PositionCalculator {
719
- private webData2;
720
- private allMids;
721
- constructor(webData2: WebData2Response | null, allMids: WsAllMidsData | null);
722
- /**
723
- * Get market price for a coin from allMids data
724
- */
725
- getMarketPrice(coin: string): number;
726
- /**
727
- * Get user positions from webData2
728
- */
729
- getUserPositions(): AssetPosition[];
730
- /**
731
- * Calculate updated open positions by syncing platform positions with HyperLiquid data
732
- */
733
- calculateOpenPositions(platformPositions: OpenPositionDto[]): OpenPositionDto[];
734
- /**
735
- * Sync a single position with HyperLiquid data
736
- */
737
- private syncPositionWithHyperliquid;
738
- /**
739
- * Group assets by their base currency
740
- */
741
- private groupAssetsByBaseCurrency;
742
- /**
743
- * Sync a group of assets (same base currency) with HyperLiquid position data
744
- */
745
- private syncAssetGroupWithHyperliquid;
746
- /**
747
- * Determine sync status based on asset sync results
748
- */
749
- private determineSyncStatus;
750
- /**
751
- * Build updated position with synced data
752
- */
753
- private buildUpdatedPosition;
754
- /**
755
- * Map sync result to PositionAssetDetailDto
756
- */
757
- private mapSyncResultToAssetDto;
758
- /**
759
- * Calculate entry ratio (weighted long entry value / weighted short entry value)
760
- */
761
- private calculateEntryRatio;
762
- /**
763
- * Calculate mark ratio (weighted long mark value / weighted short mark value)
764
- */
765
- private calculateMarkRatio;
766
- /**
767
- * Calculate net funding from sync results
768
- */
769
- private calculateNetFundingFromSyncResults;
770
- /**
771
- * Calculate total unrealized PnL from sync results
772
- */
773
- private calculateTotalUnrealizedPnlFromSyncResults;
774
- /**
775
- * Calculate current total position value using market prices
776
- */
777
- private calculateCurrentTotalPositionValue;
778
- /**
779
- * Calculate entry total position value using entry prices
780
- */
781
- private calculateEntryTotalPositionValue;
782
- }
783
-
784
732
  /**
785
733
  * Account summary calculation utility class
786
734
  */
@@ -822,5 +770,5 @@ declare class AccountSummaryCalculator {
822
770
  hasRealTimeData(): boolean;
823
771
  }
824
772
 
825
- export { AccountSummaryCalculator, PearHyperliquidClient, PearHyperliquidProvider, PearMigrationSDK, PositionCalculator, PositionSide, PearHyperliquidClient as default, useAccountSummary, useAddress, useCalculatedAccountSummary, useCalculatedOpenPositions, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMigrationSDK, useOpenOrders, useOpenPositions, usePearHyperliquidClient, useTradeHistories };
773
+ export { AccountSummaryCalculator, PearHyperliquidClient, PearHyperliquidProvider, PearMigrationSDK, PearHyperliquidClient as default, useAccountSummary, useAddress, useCalculatedAccountSummary, useCalculatedOpenPositions, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useMigrationSDK, useOpenOrders, useOpenPositions, usePearHyperliquidClient, useTradeHistories };
826
774
  export type { AccountSummaryResponseDto, AgentWalletDto, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetPosition, BalanceSummaryDto, CrossMarginSummaryDto, CumFundingDto, MarginSummaryDto, MigrationHookState, MigrationHooks, OpenLimitOrderDto, OpenOrderV1Dto, OpenPositionDto, OpenPositionV1Dto, OrderAssetDto, OrderStatus, PaginatedTradeHistoryResponseDto, PearHyperliquidConfig, PnlDto, PositionAssetDetailDto, PositionSideDto, PositionSyncStatus, RawValueDto, SyncOpenOrderDto, SyncOpenOrderResponseDto, SyncOpenPositionDto, SyncOpenPositionResponseDto, SyncTradeHistoryDto, SyncTradeHistoryResponseDto, TpSlDto, TradeHistoryAssetDataDto, TradeHistoryDataDto, TradeHistoryV1Dto, UniverseAsset, WebData2Response, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketResponse, WebSocketSubscribeMessage, WsAllMidsData };