@pear-protocol/hyperliquid-sdk 0.1.29 → 0.1.30

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 +13 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7291,7 +7291,9 @@ const calculatePositionAsset = (asset, currentPrice, totalInitialPositionSize, t
7291
7291
  };
7292
7292
  };
7293
7293
  const buildPositionValue = (rawPositions, clearinghouseState, getAssetByName) => {
7294
- return rawPositions.map((position) => {
7294
+ const ifHip4Position = (position) => position.longAssets.some((a) => a.coin.startsWith("#")) ||
7295
+ position.shortAssets.some((a) => a.coin.startsWith("#"));
7296
+ return rawPositions.filter((p) => !ifHip4Position(p)).map((position) => {
7295
7297
  var _a, _b, _c, _d, _e, _f, _g, _h;
7296
7298
  let mappedPosition = {
7297
7299
  positionId: position.positionId,
@@ -7434,7 +7436,12 @@ function usePosition() {
7434
7436
  Object.keys(tokenMetadata).length === 0)
7435
7437
  return null;
7436
7438
  return buildPositionValue(userOpenPositions, aggregatedClearingHouseState, getAssetByName);
7437
- }, [userOpenPositions, aggregatedClearingHouseState, tokenMetadata, getAssetByName]);
7439
+ }, [
7440
+ userOpenPositions,
7441
+ aggregatedClearingHouseState,
7442
+ tokenMetadata,
7443
+ getAssetByName,
7444
+ ]);
7438
7445
  const planRebalance = (positionId, targetWeights) => {
7439
7446
  var _a;
7440
7447
  if (!openPositions) {
@@ -7447,7 +7454,10 @@ function usePosition() {
7447
7454
  const assets = [];
7448
7455
  const allAssets = [
7449
7456
  ...position.longAssets.map((a) => ({ asset: a, side: 'long' })),
7450
- ...position.shortAssets.map((a) => ({ asset: a, side: 'short' })),
7457
+ ...position.shortAssets.map((a) => ({
7458
+ asset: a,
7459
+ side: 'short',
7460
+ })),
7451
7461
  ];
7452
7462
  const totalValue = allAssets.reduce((sum, { asset }) => sum + asset.positionValue, 0);
7453
7463
  for (const { asset, side } of allAssets) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.1.29",
3
+ "version": "0.1.30",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",