@hyperix/hooks 0.1.14 → 0.1.15
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 +2 -0
- package/dist/index.js +2 -0
- package/dist/use-all-mids.d.ts +8 -0
- package/dist/use-all-mids.js +25 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./use-all-mids.js";
|
|
1
2
|
export * from "./use-l2-book.js";
|
|
2
3
|
export * from "./use-all-dexs-clearing-house-state.js";
|
|
3
4
|
export * from "./use-historical-orders.js";
|
|
@@ -6,6 +7,7 @@ export * from "./use-trade-history.js";
|
|
|
6
7
|
export * from "./use-trades.js";
|
|
7
8
|
export * from "./use-order-history.js";
|
|
8
9
|
export * from "./use-positions.js";
|
|
10
|
+
export * from "./use-symbol-converter.js";
|
|
9
11
|
export * from "./use-user-fundings.js";
|
|
10
12
|
export * from "./use-user-fills.js";
|
|
11
13
|
export * from "./use-user-non-funding-ledger-updates.js";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./use-all-mids.js";
|
|
1
2
|
export * from "./use-l2-book.js";
|
|
2
3
|
export * from "./use-all-dexs-clearing-house-state.js";
|
|
3
4
|
export * from "./use-historical-orders.js";
|
|
@@ -6,6 +7,7 @@ export * from "./use-trade-history.js";
|
|
|
6
7
|
export * from "./use-trades.js";
|
|
7
8
|
export * from "./use-order-history.js";
|
|
8
9
|
export * from "./use-positions.js";
|
|
10
|
+
export * from "./use-symbol-converter.js";
|
|
9
11
|
export * from "./use-user-fundings.js";
|
|
10
12
|
export * from "./use-user-fills.js";
|
|
11
13
|
export * from "./use-user-non-funding-ledger-updates.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type UseSubscribeState } from "@outofgas/react-stream";
|
|
2
|
+
import type { AllMidsEvent } from "@nktkas/hyperliquid/api/subscription";
|
|
3
|
+
export type AllMidsData = AllMidsEvent;
|
|
4
|
+
export type UseAllMidsOptions = {
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
onUpdate?: (event: AllMidsEvent) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare function useAllMids(options?: UseAllMidsOptions): UseSubscribeState<AllMidsData>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useSubscribe } from "@outofgas/react-stream";
|
|
2
|
+
import { wsClient } from "./config/hl.js";
|
|
3
|
+
export function useAllMids(options = {}) {
|
|
4
|
+
const { enabled = true, onUpdate } = options;
|
|
5
|
+
return useSubscribe({
|
|
6
|
+
key: ["all-mids"],
|
|
7
|
+
enabled,
|
|
8
|
+
subscribe: async ({ onData, onError }) => {
|
|
9
|
+
const subscription = await wsClient.allMids((event) => {
|
|
10
|
+
try {
|
|
11
|
+
onUpdate?.(event);
|
|
12
|
+
onData(event);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
onError(error instanceof Error
|
|
16
|
+
? error
|
|
17
|
+
: new Error("Failed to process all mids event"));
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
unsubscribe: () => subscription.unsubscribe(),
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|