@hyperix/hooks 0.2.2 → 0.2.4

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/README.md CHANGED
@@ -40,6 +40,23 @@ export function App() {
40
40
  }
41
41
  ```
42
42
 
43
+ ## Shared websocket client
44
+
45
+ When you need imperative websocket access outside React hooks, reuse the
46
+ package singleton instead of creating a second socket connection.
47
+
48
+ ```ts
49
+ import { wsClient, wsTransport } from "@hyperix/hooks";
50
+
51
+ const subscription = await wsClient.allMids((event) => {
52
+ console.log(event);
53
+ });
54
+
55
+ console.log(wsTransport.socket.readyState);
56
+
57
+ await subscription.unsubscribe();
58
+ ```
59
+
43
60
  ## Tests
44
61
 
45
62
  ```bash
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./use-all-mids.js";
2
2
  export * from "./use-all-perp-metas.js";
3
3
  export * from "./use-active-asset-data.js";
4
4
  export * from "./use-all-dexs-asset-ctxs.js";
5
+ export * from "./config/hl.js";
5
6
  export * from "./use-l2-book.js";
6
7
  export * from "./use-max-builder-fee.js";
7
8
  export * from "./use-mid.js";
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ export * from "./use-all-mids.js";
2
2
  export * from "./use-all-perp-metas.js";
3
3
  export * from "./use-active-asset-data.js";
4
4
  export * from "./use-all-dexs-asset-ctxs.js";
5
+ export * from "./config/hl.js";
5
6
  export * from "./use-l2-book.js";
6
7
  export * from "./use-max-builder-fee.js";
7
8
  export * from "./use-mid.js";
@@ -154,7 +154,7 @@ export function buildBalancesData(input) {
154
154
  const perpBalances = input.isUnifiedAccount
155
155
  ? []
156
156
  : buildPerpBalances(input.clearinghouseState, input.perpMarkets);
157
- const balances = [...perpBalances, ...spotBalances];
157
+ const balances = [...perpBalances, ...spotBalances].filter((balance) => balance.value !== 0);
158
158
  const rawSpotEquity = sumBy(balances.filter((balance) => balance.type === "spot"), (balance) => balance.value);
159
159
  const rawPerpEquity = sumBy(balances.filter((balance) => balance.type === "perp"), (balance) => balance.value);
160
160
  const tradingEquity = input.isUnifiedAccount
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperix/hooks",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",