@pear-protocol/hyperliquid-sdk 0.1.38 → 0.1.39

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 +7 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8409,6 +8409,10 @@ function useAuth() {
8409
8409
  };
8410
8410
  }
8411
8411
 
8412
+ const parseBalanceValue = (value) => {
8413
+ const parsed = parseFloat(String(value !== null && value !== void 0 ? value : '0'));
8414
+ return Number.isFinite(parsed) ? parsed : 0;
8415
+ };
8412
8416
  const useAllUserBalances = () => {
8413
8417
  const spotState = useUserData((state) => state.spotState);
8414
8418
  const { longTokensMetadata, shortTokensMetadata } = useTokenSelectionMetadata();
@@ -8420,8 +8424,9 @@ const useAllUserBalances = () => {
8420
8424
  const availableToTrades = {};
8421
8425
  if (spotState === null || spotState === void 0 ? void 0 : spotState.balances) {
8422
8426
  for (const balance of spotState.balances) {
8423
- const total = parseFloat(balance.total || '0');
8424
- spotBalances[balance.coin] = total;
8427
+ const total = parseBalanceValue(balance.total);
8428
+ const hold = parseBalanceValue(balance.hold);
8429
+ spotBalances[balance.coin] = Math.max(0, total - hold);
8425
8430
  }
8426
8431
  }
8427
8432
  const allMetadataWithSource = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.1.38",
3
+ "version": "0.1.39",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",