@pear-protocol/hyperliquid-sdk 0.0.66 → 0.0.68

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/index.d.ts CHANGED
@@ -560,6 +560,7 @@ interface RawAssetDto {
560
560
  size: number;
561
561
  side: string;
562
562
  fundingPaid?: number;
563
+ leverage: number;
563
564
  }
564
565
  /**
565
566
  * Raw position data from open-positions channel
package/dist/index.js CHANGED
@@ -673,6 +673,12 @@ const useHyperliquidNativeWebSocket = ({ address, enabled = true, }) => {
673
673
  break;
674
674
  case 'allDexsClearinghouseState':
675
675
  {
676
+ // If the user is not authenticated, ignore clearinghouse state to avoid
677
+ // populating summaries with the default zero address data.
678
+ if (!address) {
679
+ setAggregatedClearingHouseState(null);
680
+ break;
681
+ }
676
682
  const data = response.data;
677
683
  const states = (data.clearinghouseStates || [])
678
684
  .map(([, s]) => s)
@@ -6610,7 +6616,7 @@ const buildPositionValue = (rawPositions, clearinghouseState, allMids) => {
6610
6616
  var _a, _b, _c;
6611
6617
  const currentPrice = parseFloat(allMids.mids[longAsset.coin]);
6612
6618
  const assetState = (_a = clearinghouseState.assetPositions.find(ap => toDisplaySymbol(ap.position.coin) === longAsset.coin)) === null || _a === void 0 ? void 0 : _a.position;
6613
- const leverage = (_c = (_b = assetState === null || assetState === void 0 ? void 0 : assetState.leverage) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : 0;
6619
+ const leverage = (_c = (_b = assetState === null || assetState === void 0 ? void 0 : assetState.leverage) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : longAsset.leverage;
6614
6620
  const mappedPositionAssets = calculatePositionAsset(longAsset, currentPrice, totalInitialPositionSize, leverage, true);
6615
6621
  mappedPosition.entryPositionValue += mappedPositionAssets.entryPositionValue;
6616
6622
  mappedPosition.unrealizedPnl += mappedPositionAssets.unrealizedPnl;
@@ -6624,7 +6630,7 @@ const buildPositionValue = (rawPositions, clearinghouseState, allMids) => {
6624
6630
  var _a, _b, _c;
6625
6631
  const currentPrice = parseFloat(allMids.mids[shortAsset.coin]);
6626
6632
  const assetState = (_a = clearinghouseState.assetPositions.find(ap => toDisplaySymbol(ap.position.coin) === shortAsset.coin)) === null || _a === void 0 ? void 0 : _a.position;
6627
- const leverage = (_c = (_b = assetState === null || assetState === void 0 ? void 0 : assetState.leverage) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : 0;
6633
+ const leverage = (_c = (_b = assetState === null || assetState === void 0 ? void 0 : assetState.leverage) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : shortAsset.leverage;
6628
6634
  const mappedPositionAssets = calculatePositionAsset(shortAsset, currentPrice, totalInitialPositionSize, leverage, false);
6629
6635
  mappedPosition.entryPositionValue += mappedPositionAssets.entryPositionValue;
6630
6636
  mappedPosition.unrealizedPnl += mappedPositionAssets.unrealizedPnl;
package/dist/types.d.ts CHANGED
@@ -608,6 +608,7 @@ export interface RawAssetDto {
608
608
  size: number;
609
609
  side: string;
610
610
  fundingPaid?: number;
611
+ leverage: number;
611
612
  }
612
613
  /**
613
614
  * Raw position data from open-positions channel
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.0.66",
3
+ "version": "0.0.68",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",