@0xmonaco/react 1.1.5 → 1.1.6

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.
@@ -134,6 +134,22 @@ export declare const INTENTIONALLY_EXCLUDED: {
134
134
  get_user_trades: string;
135
135
  health_check: string;
136
136
  get_region_status: string;
137
+ get_protocol_totals: string;
138
+ get_protocol_series: string;
139
+ list_market_volumes: string;
140
+ get_treasury_net_fees: string;
141
+ list_builders: string;
142
+ get_builder: string;
143
+ get_builder_totals: string;
144
+ get_builder_series: string;
145
+ list_builder_leaderboard: string;
146
+ list_wallet_leaderboard: string;
147
+ get_wallet_summary: string;
148
+ list_wallet_liquidations: string;
149
+ list_token_custody: string;
150
+ get_token_custody: string;
151
+ list_vault_deposits: string;
152
+ list_vault_withdrawals: string;
137
153
  list_application_balances: string;
138
154
  list_application_movements: string;
139
155
  list_application_orders: string;
package/dist/coverage.js CHANGED
@@ -134,6 +134,22 @@ export const INTENTIONALLY_EXCLUDED = {
134
134
  get_user_trades: "Trade-history lookup with a core client method but no dedicated React hook yet.",
135
135
  health_check: "Infrastructure liveness probe (GET /health); not part of the data SDK surface.",
136
136
  get_region_status: "Caller region status for a region notice; available via the core client but no dedicated React hook yet.",
137
+ get_protocol_totals: "Explorer analytics read covered by @0xmonaco/core; no React hook.",
138
+ get_protocol_series: "Explorer analytics read covered by @0xmonaco/core; no React hook.",
139
+ list_market_volumes: "Explorer analytics read covered by @0xmonaco/core; no React hook.",
140
+ get_treasury_net_fees: "Explorer analytics read covered by @0xmonaco/core; no React hook.",
141
+ list_builders: "Explorer analytics read covered by @0xmonaco/core; no React hook.",
142
+ get_builder: "Explorer analytics read covered by @0xmonaco/core; no React hook.",
143
+ get_builder_totals: "Explorer analytics read covered by @0xmonaco/core; no React hook.",
144
+ get_builder_series: "Explorer analytics read covered by @0xmonaco/core; no React hook.",
145
+ list_builder_leaderboard: "Explorer analytics read covered by @0xmonaco/core; no React hook.",
146
+ list_wallet_leaderboard: "Explorer analytics read covered by @0xmonaco/core; no React hook.",
147
+ get_wallet_summary: "Explorer analytics read covered by @0xmonaco/core; no React hook.",
148
+ list_wallet_liquidations: "Explorer analytics read covered by @0xmonaco/core; no React hook.",
149
+ list_token_custody: "Explorer analytics read covered by @0xmonaco/core; no React hook.",
150
+ get_token_custody: "Explorer analytics read covered by @0xmonaco/core; no React hook.",
151
+ list_vault_deposits: "Explorer analytics read covered by @0xmonaco/core; no React hook.",
152
+ list_vault_withdrawals: "Explorer analytics read covered by @0xmonaco/core; no React hook.",
137
153
  list_application_balances: "Application reporting endpoint (public, selected by clientId) for frontend operators; not a user-wallet React workflow.",
138
154
  list_application_movements: "Application reporting endpoint (public, selected by clientId) for frontend operators; not a user-wallet React workflow.",
139
155
  list_application_orders: "Application reporting endpoint (public, selected by clientId) for frontend operators; not a user-wallet React workflow.",
@@ -1,6 +1,8 @@
1
1
  export * from "./useAuth";
2
+ export * from "./useBbo";
2
3
  export * from "./useCopyEvents";
3
4
  export * from "./useCopyTrading";
5
+ export * from "./useDepth";
4
6
  export * from "./useFees";
5
7
  export * from "./useInstruments";
6
8
  export * from "./useLiquidationFeed";
@@ -1,6 +1,8 @@
1
1
  export * from "./useAuth";
2
+ export * from "./useBbo";
2
3
  export * from "./useCopyEvents";
3
4
  export * from "./useCopyTrading";
5
+ export * from "./useDepth";
4
6
  export * from "./useFees";
5
7
  export * from "./useInstruments";
6
8
  export * from "./useLiquidationFeed";
@@ -0,0 +1,2 @@
1
+ export type { UseBboReturn } from "./types";
2
+ export { useBbo } from "./useBbo";
@@ -0,0 +1 @@
1
+ export { useBbo } from "./useBbo";
@@ -0,0 +1,12 @@
1
+ import type { Bbo, LocalBookError, LocalBookResyncReason } from "@0xmonaco/types";
2
+ /** Return type for the useBbo hook. */
3
+ export interface UseBboReturn {
4
+ /** The current best bid and ask, or `null` until the first snapshot (and while rebuilding). */
5
+ bbo: Bbo | null;
6
+ /** Whether a subscription is active. */
7
+ subscribed: boolean;
8
+ /** Why the top of book was last discarded to be rebuilt, if it has been. */
9
+ lastResync: LocalBookResyncReason | null;
10
+ /** The server's rejection of the subscription (e.g. `INVALID_SUBSCRIPTION`), if any. */
11
+ error: LocalBookError | null;
12
+ }
File without changes
@@ -0,0 +1,8 @@
1
+ import type { TradingMode } from "@0xmonaco/types";
2
+ import type { UseBboReturn } from "./types";
3
+ /**
4
+ * The live best bid and ask for one market, kept by `sdk.ws.bbo` from the
5
+ * market-data `bbo` channel, with the same snapshot handoff and rebuild on a
6
+ * gap as `useDepth`. An empty side is `null`.
7
+ */
8
+ export declare function useBbo(tradingPairId: string, tradingMode: TradingMode): UseBboReturn;
@@ -0,0 +1,50 @@
1
+ import { useEffect, useState } from "react";
2
+ import { useMonacoSDK } from "../useMonaco";
3
+ /**
4
+ * The live best bid and ask for one market, kept by `sdk.ws.bbo` from the
5
+ * market-data `bbo` channel, with the same snapshot handoff and rebuild on a
6
+ * gap as `useDepth`. An empty side is `null`.
7
+ */
8
+ export function useBbo(tradingPairId, tradingMode) {
9
+ const { sdk } = useMonacoSDK();
10
+ const [bbo, setBbo] = useState(null);
11
+ const [subscribed, setSubscribed] = useState(false);
12
+ const [lastResync, setLastResync] = useState(null);
13
+ const [error, setError] = useState(null);
14
+ useEffect(() => {
15
+ setBbo(null);
16
+ setLastResync(null);
17
+ setError(null);
18
+ if (!sdk?.ws || !tradingPairId) {
19
+ setSubscribed(false);
20
+ return;
21
+ }
22
+ let unsubscribe;
23
+ try {
24
+ unsubscribe = sdk.ws.bbo(tradingPairId, tradingMode, (value) => {
25
+ // A live value means any earlier channel error has cleared.
26
+ setBbo(value);
27
+ setError(null);
28
+ }, {
29
+ onResync: (reason) => {
30
+ setLastResync(reason);
31
+ setBbo(null);
32
+ },
33
+ onError: setError,
34
+ });
35
+ }
36
+ catch (err) {
37
+ // An id that is not a UUID or a mode other than SPOT/MARGIN is refused
38
+ // synchronously; surface it rather than throwing out of the effect.
39
+ setError({ code: "INVALID_ARGUMENT", message: err instanceof Error ? err.message : String(err) });
40
+ setSubscribed(false);
41
+ return;
42
+ }
43
+ setSubscribed(true);
44
+ return () => {
45
+ unsubscribe();
46
+ setSubscribed(false);
47
+ };
48
+ }, [sdk?.ws, tradingPairId, tradingMode]);
49
+ return { bbo, subscribed, lastResync, error };
50
+ }
@@ -0,0 +1,2 @@
1
+ export type { UseDepthReturn } from "./types";
2
+ export { useDepth } from "./useDepth";
@@ -0,0 +1 @@
1
+ export { useDepth } from "./useDepth";
@@ -0,0 +1,12 @@
1
+ import type { DepthBook, LocalBookError, LocalBookResyncReason } from "@0xmonaco/types";
2
+ /** Return type for the useDepth hook. */
3
+ export interface UseDepthReturn {
4
+ /** The local depth book, or `null` until the first snapshot (and while rebuilding). */
5
+ book: DepthBook | null;
6
+ /** Whether a subscription is active. */
7
+ subscribed: boolean;
8
+ /** Why the book was last discarded to be rebuilt, if it has been. */
9
+ lastResync: LocalBookResyncReason | null;
10
+ /** The server's rejection of the subscription (e.g. `INVALID_SUBSCRIPTION`), if any. */
11
+ error: LocalBookError | null;
12
+ }
File without changes
@@ -0,0 +1,9 @@
1
+ import type { TradingMode } from "@0xmonaco/types";
2
+ import type { UseDepthReturn } from "./types";
3
+ /**
4
+ * A live local depth book (up to 1000 levels per side) for one market, kept
5
+ * by `sdk.ws.depth` from the market-data `depth` channel: the subscribe-time
6
+ * snapshot is the base, linked frames update it, and a gap rebuilds it from a
7
+ * fresh snapshot (the book reads `null` until it arrives).
8
+ */
9
+ export declare function useDepth(tradingPairId: string, tradingMode: TradingMode): UseDepthReturn;
@@ -0,0 +1,51 @@
1
+ import { useEffect, useState } from "react";
2
+ import { useMonacoSDK } from "../useMonaco";
3
+ /**
4
+ * A live local depth book (up to 1000 levels per side) for one market, kept
5
+ * by `sdk.ws.depth` from the market-data `depth` channel: the subscribe-time
6
+ * snapshot is the base, linked frames update it, and a gap rebuilds it from a
7
+ * fresh snapshot (the book reads `null` until it arrives).
8
+ */
9
+ export function useDepth(tradingPairId, tradingMode) {
10
+ const { sdk } = useMonacoSDK();
11
+ const [book, setBook] = useState(null);
12
+ const [subscribed, setSubscribed] = useState(false);
13
+ const [lastResync, setLastResync] = useState(null);
14
+ const [error, setError] = useState(null);
15
+ useEffect(() => {
16
+ setBook(null);
17
+ setLastResync(null);
18
+ setError(null);
19
+ if (!sdk?.ws || !tradingPairId) {
20
+ setSubscribed(false);
21
+ return;
22
+ }
23
+ let unsubscribe;
24
+ try {
25
+ unsubscribe = sdk.ws.depth(tradingPairId, tradingMode, (value) => {
26
+ // A live value means any earlier channel error has cleared.
27
+ setBook(value);
28
+ setError(null);
29
+ }, {
30
+ onResync: (reason) => {
31
+ setLastResync(reason);
32
+ setBook(null);
33
+ },
34
+ onError: setError,
35
+ });
36
+ }
37
+ catch (err) {
38
+ // An id that is not a UUID or a mode other than SPOT/MARGIN is refused
39
+ // synchronously; surface it rather than throwing out of the effect.
40
+ setError({ code: "INVALID_ARGUMENT", message: err instanceof Error ? err.message : String(err) });
41
+ setSubscribed(false);
42
+ return;
43
+ }
44
+ setSubscribed(true);
45
+ return () => {
46
+ unsubscribe();
47
+ setSubscribed(false);
48
+ };
49
+ }, [sdk?.ws, tradingPairId, tradingMode]);
50
+ return { book, subscribed, lastResync, error };
51
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/react",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "type": "module",
5
5
  "homepage": "https://docs.0xmonaco.com/sdk/typescript",
6
6
  "main": "./dist/index.js",
@@ -16,8 +16,8 @@
16
16
  "lint": "biome lint ."
17
17
  },
18
18
  "dependencies": {
19
- "@0xmonaco/core": "1.1.5",
20
- "@0xmonaco/types": "1.1.5"
19
+ "@0xmonaco/core": "1.1.6",
20
+ "@0xmonaco/types": "1.1.6"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/react": "^19.3.0",