@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 +1 -0
- package/dist/index.js +8 -2
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
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 :
|
|
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 :
|
|
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