@pear-protocol/hyperliquid-sdk 0.0.70 → 0.0.71-beta

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.
Files changed (2) hide show
  1. package/dist/index.js +16 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1389,20 +1389,20 @@ const useTokenSelectionMetadataStore = create((set) => ({
1389
1389
  });
1390
1390
  return totalFunding;
1391
1391
  })();
1392
- // Max leverage (minimum across all tokens)
1392
+ // Max leverage (maximum across all tokens)
1393
1393
  const maxLeverage = (() => {
1394
1394
  if (!perpMetaAssets)
1395
1395
  return 0;
1396
1396
  const allTokenSymbols = [...longTokens, ...shortTokens].map((t) => t.symbol);
1397
1397
  if (allTokenSymbols.length === 0)
1398
1398
  return 0;
1399
- let minLev = Infinity;
1399
+ let maxLev = 0;
1400
1400
  allTokenSymbols.forEach((symbol) => {
1401
1401
  const tokenUniverse = perpMetaAssets.find((u) => u.name === symbol);
1402
1402
  if (tokenUniverse === null || tokenUniverse === void 0 ? void 0 : tokenUniverse.maxLeverage)
1403
- minLev = Math.min(minLev, tokenUniverse.maxLeverage);
1403
+ maxLev = Math.max(maxLev, tokenUniverse.maxLeverage);
1404
1404
  });
1405
- return minLev === Infinity ? 0 : minLev;
1405
+ return maxLev;
1406
1406
  })();
1407
1407
  // Min margin (10 * total number of tokens)
1408
1408
  const minMargin = (() => {
@@ -6701,8 +6701,18 @@ const buildPositionValue = (rawPositions, clearinghouseState, allMids) => {
6701
6701
  const short = position.shortAssets[0];
6702
6702
  const longMark = parseFloat(allMids.mids[long.coin]);
6703
6703
  const shortMark = parseFloat(allMids.mids[short.coin]);
6704
- mappedPosition.entryPriceRatio = long.entryPrice / short.entryPrice;
6705
- mappedPosition.markPriceRatio = longMark / shortMark;
6704
+ if (long.size > 0 && short.size > 0) {
6705
+ mappedPosition.entryPriceRatio = long.entryPrice / short.entryPrice;
6706
+ mappedPosition.markPriceRatio = longMark / shortMark;
6707
+ }
6708
+ else if (long.size > 0) {
6709
+ mappedPosition.entryPriceRatio = long.entryPrice;
6710
+ mappedPosition.markPriceRatio = longMark;
6711
+ }
6712
+ else if (short.size > 0) {
6713
+ mappedPosition.entryPriceRatio = short.entryPrice;
6714
+ mappedPosition.markPriceRatio = shortMark;
6715
+ }
6706
6716
  }
6707
6717
  if (position.longAssets.length === 1 && position.shortAssets.length === 0) {
6708
6718
  const long = position.longAssets[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.0.70",
3
+ "version": "0.0.71-beta",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",