@0xmonaco/react 0.4.1 → 0.4.2
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 +377 -0
- package/dist/hooks/index.d.ts +10 -10
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +10 -10
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useAuth/useAuth.d.ts.map +1 -1
- package/dist/hooks/useAuth/useAuth.js +6 -6
- package/dist/hooks/useAuth/useAuth.js.map +1 -1
- package/dist/hooks/useFees/index.d.ts +2 -2
- package/dist/hooks/useFees/index.d.ts.map +1 -1
- package/dist/hooks/useFees/index.js +1 -1
- package/dist/hooks/useFees/index.js.map +1 -1
- package/dist/hooks/useMonaco/types.d.ts +4 -4
- package/dist/hooks/useMonaco/types.d.ts.map +1 -1
- package/dist/hooks/useMonaco/useMonaco.d.ts +1 -1
- package/dist/hooks/useMonaco/useMonaco.d.ts.map +1 -1
- package/dist/hooks/useMonaco/useMonaco.js +1 -1
- package/dist/hooks/useMonaco/useMonaco.js.map +1 -1
- package/dist/hooks/useOrderbook/types.d.ts +2 -2
- package/dist/hooks/useOrderbook/types.d.ts.map +1 -1
- package/dist/hooks/useOrderbook/useOrderbook.d.ts +3 -47
- package/dist/hooks/useOrderbook/useOrderbook.d.ts.map +1 -1
- package/dist/hooks/useOrderbook/useOrderbook.js +24 -146
- package/dist/hooks/useOrderbook/useOrderbook.js.map +1 -1
- package/dist/hooks/useTrade/useTrade.d.ts +1 -1
- package/dist/hooks/useTrade/useTrade.d.ts.map +1 -1
- package/dist/hooks/useTrade/useTrade.js +1 -1
- package/dist/hooks/useTrade/useTrade.js.map +1 -1
- package/dist/hooks/useTradeFeed/types.d.ts +4 -36
- package/dist/hooks/useTradeFeed/types.d.ts.map +1 -1
- package/dist/hooks/useTradeFeed/useTradeFeed.d.ts +5 -28
- package/dist/hooks/useTradeFeed/useTradeFeed.d.ts.map +1 -1
- package/dist/hooks/useTradeFeed/useTradeFeed.js +35 -136
- package/dist/hooks/useTradeFeed/useTradeFeed.js.map +1 -1
- package/dist/hooks/useVault/useVault.d.ts +1 -1
- package/dist/hooks/useVault/useVault.d.ts.map +1 -1
- package/dist/hooks/useVault/useVault.js +1 -1
- package/dist/hooks/useVault/useVault.js.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/provider/MonacoProvider.d.ts +2 -2
- package/dist/provider/MonacoProvider.d.ts.map +1 -1
- package/dist/provider/MonacoProvider.js +9 -8
- package/dist/provider/MonacoProvider.js.map +1 -1
- package/dist/provider/index.d.ts +2 -2
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +2 -2
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/types.d.ts +5 -4
- package/dist/provider/types.d.ts.map +1 -1
- package/dist/provider/types.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/hooks/useTradeFeed/utils.d.ts +0 -4
- package/dist/hooks/useTradeFeed/utils.d.ts.map +0 -1
- package/dist/hooks/useTradeFeed/utils.js +0 -16
- package/dist/hooks/useTradeFeed/utils.js.map +0 -1
|
@@ -1,156 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useCallback, useEffect,
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* React hook to subscribe to and manage the orderbook for a given trading pair and mode.
|
|
6
|
-
*
|
|
7
|
-
* Connects to the Monaco SDK WebSocket orderbook feed, subscribes to updates,
|
|
8
|
-
* and provides the latest orderbook event, connection status, subscription state, and error handling.
|
|
9
|
-
*
|
|
10
|
-
* @param {string | null} tradingPair - The trading pair to subscribe to (e.g., "BTC/USD"). If null, no subscription is made.
|
|
11
|
-
* @param {TradingMode} tradingMode - The trading mode to use for the subscription (e.g., "live", "test").
|
|
12
|
-
* @param {number} [magnitude] - Optional magnitude for orderbook grouping (0.0001 to 10000, defaults to no grouping).
|
|
13
|
-
* @param {OrderbookQuotationMode} [quotationMode] - Optional quotation mode ("BASE" or "QUOTE"), defaults to "BASE".
|
|
14
|
-
* @returns {UseOrderbookReturn} An object containing the latest orderbook event, connection status, subscription state, error, and error clearing function.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```tsx
|
|
18
|
-
* import { useOrderbook } from "./useOrderbook";
|
|
19
|
-
*
|
|
20
|
-
* function OrderbookComponent() {
|
|
21
|
-
* const { orderbook, connectionStatus, subscribed, error, clearError } = useOrderbook("BTC/USD", "live");
|
|
22
|
-
*
|
|
23
|
-
* if (error) return <div>Error: {error.message} <button onClick={clearError}>Clear</button></div>;
|
|
24
|
-
* if (!subscribed) return <div>Not subscribed</div>;
|
|
25
|
-
* if (!orderbook) return <div>Loading...</div>;
|
|
26
|
-
*
|
|
27
|
-
* return (
|
|
28
|
-
* <div>
|
|
29
|
-
* <h2>Orderbook ({connectionStatus})</h2>
|
|
30
|
-
* {/** Render orderbook data here }
|
|
31
|
-
* </div>
|
|
32
|
-
* );
|
|
33
|
-
* }
|
|
34
|
-
*
|
|
35
|
-
* // With magnitude for grouping
|
|
36
|
-
* function GroupedOrderbookComponent() {
|
|
37
|
-
* const { orderbook } = useOrderbook("BTC/USD", "live", 10);
|
|
38
|
-
* // ... render grouped orderbook
|
|
39
|
-
* }
|
|
40
|
-
*
|
|
41
|
-
* // With QUOTE quotation mode
|
|
42
|
-
* function QuoteOrderbookComponent() {
|
|
43
|
-
* const { orderbook } = useOrderbook("BTC/USD", "live", undefined, "QUOTE");
|
|
44
|
-
* // ... render orderbook in QUOTE mode
|
|
45
|
-
* }
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export function useOrderbook(tradingPair, tradingMode, magnitude, quotationMode) {
|
|
1
|
+
import { useMonacoSDK } from "@0xmonaco/react";
|
|
2
|
+
import { useCallback, useEffect, useState } from "react";
|
|
3
|
+
export function useOrderbook(tradingPairId, tradingMode, magnitude, quotationMode, depth = 10) {
|
|
49
4
|
const { sdk } = useMonacoSDK();
|
|
50
5
|
const [orderbook, setOrderbook] = useState(null);
|
|
51
6
|
const [error, setError] = useState(null);
|
|
52
|
-
const [
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const connect = useCallback(async () => {
|
|
61
|
-
if (!orderbookWSClient)
|
|
62
|
-
return;
|
|
63
|
-
if (connectionStatus === WebSocketStatus.Connecting || connectionStatus === WebSocketStatus.Connected)
|
|
7
|
+
const [subscribed, setSubscribed] = useState(false);
|
|
8
|
+
const clearError = useCallback(() => setError(null), []);
|
|
9
|
+
// Get connection status directly from SDK
|
|
10
|
+
const connectionStatus = sdk?.ws?.getStatus() ?? "disconnected";
|
|
11
|
+
// Connect and subscribe to orderbook updates
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!sdk?.ws || !sdk?.orderbook || !tradingPairId) {
|
|
14
|
+
setSubscribed(false);
|
|
64
15
|
return;
|
|
65
|
-
setError(null);
|
|
66
|
-
setConnectionStatus(WebSocketStatus.Connecting);
|
|
67
|
-
try {
|
|
68
|
-
await orderbookWSClient.connect();
|
|
69
|
-
setConnectionStatus(WebSocketStatus.Connected);
|
|
70
|
-
}
|
|
71
|
-
catch (err) {
|
|
72
|
-
setConnectionStatus(WebSocketStatus.Disconnected);
|
|
73
|
-
setError(err instanceof Error ? err : new Error(String(err)));
|
|
74
16
|
}
|
|
75
|
-
}, [orderbookWSClient, connectionStatus]);
|
|
76
|
-
const subscribe = useCallback(async (pair, mode, mag, qMode) => {
|
|
77
|
-
if (!orderbookWSClient)
|
|
78
|
-
return;
|
|
79
|
-
if (connectionStatus !== WebSocketStatus.Connected)
|
|
80
|
-
return;
|
|
81
17
|
setOrderbook(null);
|
|
82
18
|
setError(null);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}, [orderbookWSClient, connectionStatus]);
|
|
93
|
-
const unsubscribe = useCallback(() => {
|
|
94
|
-
if (!orderbookWSClient)
|
|
95
|
-
return;
|
|
96
|
-
if (!currentSubscriptionRef.current)
|
|
97
|
-
return;
|
|
98
|
-
if (connectionStatus !== WebSocketStatus.Connected)
|
|
99
|
-
return;
|
|
100
|
-
try {
|
|
101
|
-
const tradingMode = currentSubscriptionRef.current.mode;
|
|
102
|
-
const magnitude = currentSubscriptionRef.current.magnitude;
|
|
103
|
-
const quotationMode = currentSubscriptionRef.current.quotationMode;
|
|
104
|
-
orderbookWSClient.unsubscribeFromOrderbookEvents(currentSubscriptionRef.current.pair, tradingMode, magnitude, quotationMode);
|
|
105
|
-
currentSubscriptionRef.current = null;
|
|
106
|
-
setOrderbook(null);
|
|
107
|
-
}
|
|
108
|
-
catch (err) {
|
|
109
|
-
setError(err instanceof Error ? err : new Error(String(err)));
|
|
110
|
-
}
|
|
111
|
-
}, [orderbookWSClient, connectionStatus]);
|
|
112
|
-
const disconnect = useCallback(() => {
|
|
113
|
-
if (connectionStatus !== WebSocketStatus.Connected)
|
|
114
|
-
return;
|
|
115
|
-
try {
|
|
116
|
-
orderbookWSClient?.disconnect();
|
|
117
|
-
setConnectionStatus(WebSocketStatus.Disconnected);
|
|
118
|
-
setOrderbook(null);
|
|
119
|
-
setError(null);
|
|
120
|
-
}
|
|
121
|
-
catch (err) {
|
|
122
|
-
setError(err instanceof Error ? err : new Error(String(err)));
|
|
123
|
-
}
|
|
124
|
-
}, [orderbookWSClient, connectionStatus]);
|
|
125
|
-
useEffect(() => {
|
|
126
|
-
if (tradingPair && tradingMode && connectionStatus === WebSocketStatus.Connected) {
|
|
127
|
-
if (tradingPair === currentSubscriptionRef.current?.pair &&
|
|
128
|
-
tradingMode === currentSubscriptionRef.current?.mode &&
|
|
129
|
-
magnitude === currentSubscriptionRef.current?.magnitude &&
|
|
130
|
-
quotationMode === currentSubscriptionRef.current?.quotationMode)
|
|
131
|
-
return;
|
|
19
|
+
// Fetch initial orderbook via REST
|
|
20
|
+
sdk.orderbook
|
|
21
|
+
.getOrderbook(tradingPairId, { depth, tradingMode, magnitude, denomination: quotationMode })
|
|
22
|
+
.then((initial) => setOrderbook(initial))
|
|
23
|
+
.catch((err) => setError(err instanceof Error ? err : new Error(String(err))));
|
|
24
|
+
// Subscribe to WebSocket updates (ws connection handled by MonacoProvider)
|
|
25
|
+
const unsubscribe = sdk.ws.orderbook(tradingPairId, tradingMode, magnitude, quotationMode, setOrderbook);
|
|
26
|
+
setSubscribed(true);
|
|
27
|
+
return () => {
|
|
132
28
|
unsubscribe();
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
}, [
|
|
136
|
-
|
|
137
|
-
if (isSDKAuthenticated) {
|
|
138
|
-
void connect(); // Connect when SDK is available
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
// Clear state when SDK is disconnected
|
|
142
|
-
setOrderbook(null);
|
|
143
|
-
setConnectionStatus(WebSocketStatus.Disconnected);
|
|
144
|
-
currentSubscriptionRef.current = null;
|
|
145
|
-
}
|
|
146
|
-
return () => disconnect(); // Disconnect from ws on unmount
|
|
147
|
-
}, [isSDKAuthenticated, connect, disconnect]);
|
|
148
|
-
return {
|
|
149
|
-
orderbook,
|
|
150
|
-
connectionStatus,
|
|
151
|
-
subscribed,
|
|
152
|
-
error,
|
|
153
|
-
clearError,
|
|
154
|
-
};
|
|
29
|
+
setSubscribed(false);
|
|
30
|
+
};
|
|
31
|
+
}, [sdk?.ws, sdk?.orderbook, tradingPairId, tradingMode, magnitude, quotationMode, depth]);
|
|
32
|
+
return { orderbook, connectionStatus, subscribed, error, clearError };
|
|
155
33
|
}
|
|
156
34
|
//# sourceMappingURL=useOrderbook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOrderbook.js","sourceRoot":"","sources":["../../../src/hooks/useOrderbook/useOrderbook.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useOrderbook.js","sourceRoot":"","sources":["../../../src/hooks/useOrderbook/useOrderbook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGzD,MAAM,UAAU,YAAY,CAC1B,aAAqB,EACrB,WAAwB,EACxB,SAAiB,EACjB,aAAqC,EACrC,KAAK,GAAG,EAAE;IAEV,MAAM,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,CAAC;IAE/B,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAwB,IAAI,CAAC,CAAC;IACxE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IACvD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEpD,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAEzD,0CAA0C;IAC1C,MAAM,gBAAgB,GAAG,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,cAAc,CAAC;IAEhE,6CAA6C;IAC7C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,aAAa,EAAE,CAAC;YAClD,aAAa,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO;QACT,CAAC;QAED,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEf,mCAAmC;QACnC,GAAG,CAAC,SAAS;aACV,YAAY,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;aAC3F,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;aACxC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjF,2EAA2E;QAC3E,MAAM,WAAW,GAAG,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;QACzG,aAAa,CAAC,IAAI,CAAC,CAAC;QAEpB,OAAO,GAAG,EAAE;YACV,WAAW,EAAE,CAAC;YACd,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC;IAE3F,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACxE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTrade.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTrade/useTrade.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useTrade.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTrade/useTrade.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,eAAO,MAAM,QAAQ,QAAO,cAkH3B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
|
-
import { useMonacoSDK } from "../useMonaco
|
|
2
|
+
import { useMonacoSDK } from "../useMonaco";
|
|
3
3
|
export const useTrade = () => {
|
|
4
4
|
const { sdk } = useMonacoSDK();
|
|
5
5
|
const placeLimitOrder = useCallback(async (tradingPairId, side, quantity, price, options) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTrade.js","sourceRoot":"","sources":["../../../src/hooks/useTrade/useTrade.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useTrade.js","sourceRoot":"","sources":["../../../src/hooks/useTrade/useTrade.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAmB,EAAE;IAC3C,MAAM,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,CAAC;IAE/B,MAAM,eAAe,GAAG,WAAW,CACjC,KAAK,EACH,aAAqB,EACrB,IAAe,EACf,QAAgB,EAChB,KAAa,EACb,OAAuH,EACzF,EAAE;QAChC,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QAC/F,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACrD,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QACnF,IAAI,CAAC,K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AO,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC,EACD,CAAC,GAAG,CAAC,CACN,CAAC;IAEF,MAAM,kBAAkB,GAAG,WAAW,CACpC,KAAK,EAAE,MAAiC,EAAuC,EAAE;QAC/E,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAE/C,OAAO,MAAM,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC,EACD,CAAC,GAAG,CAAC,CACN,CAAC;IAEF,MAAM,QAAQ,GAAG,WAAW,CAC1B,KAAK,EAAE,OAAe,EAA6B,EAAE;QACnD,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAElF,OAAO,MAAM,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC,EACD,CAAC,GAAG,CAAC,CACN,CAAC;IAEF,OAAO;QACL,kBAAkB;QAClB,eAAe;QACf,gBAAgB;QAEhB,mBAAmB;QACnB,WAAW;QACX,YAAY;QAEZ,gBAAgB;QAChB,kBAAkB;QAClB,QAAQ;KACT,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,44 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
/**
|
|
3
|
-
* State structure for current subscription ref
|
|
4
|
-
*/
|
|
5
|
-
export interface TradeFeedSubscriptionRef {
|
|
6
|
-
/** The pair subscribed to */
|
|
7
|
-
pair: string;
|
|
8
|
-
/** The mode subscribed to */
|
|
9
|
-
mode: TradingMode;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Standardized trade data extracted from order events
|
|
13
|
-
*/
|
|
14
|
-
export interface Trade {
|
|
15
|
-
/** Execution price of the trade */
|
|
16
|
-
price: string;
|
|
17
|
-
/** Trading pair symbol (e.g., "BTC/USDC") */
|
|
18
|
-
tradingPair: string;
|
|
19
|
-
/** Trading pair ID (UUID) */
|
|
20
|
-
tradingPairId: string | undefined;
|
|
21
|
-
/** Quantity executed in this trade */
|
|
22
|
-
quantity: string;
|
|
23
|
-
/** User ID (UUID) */
|
|
24
|
-
userId: string;
|
|
25
|
-
/** Trading mode (e.g., "Spot", "Margin") */
|
|
26
|
-
tradingMode: TradingMode;
|
|
27
|
-
/** Original order ID */
|
|
28
|
-
orderId: string;
|
|
29
|
-
/** Event timestamp */
|
|
30
|
-
timestamp: string;
|
|
31
|
-
/** Order side ("BUY" or "SELL") */
|
|
32
|
-
side?: OrderSide;
|
|
33
|
-
}
|
|
1
|
+
import type { TradeEvent, WebSocketStatus } from "@0xmonaco/types";
|
|
34
2
|
/**
|
|
35
3
|
* Return type for the useTradeFeed hook
|
|
36
4
|
*/
|
|
37
5
|
export interface UseTradeFeedReturn {
|
|
38
|
-
/** Array of
|
|
39
|
-
trades:
|
|
6
|
+
/** Array of trade events from WebSocket and REST API */
|
|
7
|
+
trades: TradeEvent[];
|
|
40
8
|
/** WebSocket connection status */
|
|
41
|
-
connectionStatus:
|
|
9
|
+
connectionStatus: WebSocketStatus;
|
|
42
10
|
/** Whether currently subscribed to a market */
|
|
43
11
|
subscribed: boolean;
|
|
44
12
|
/** Any error that occurred during connection or subscription */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTradeFeed/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTradeFeed/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,wDAAwD;IACxD,MAAM,EAAE,UAAU,EAAE,CAAC;IAErB,kCAAkC;IAClC,gBAAgB,EAAE,eAAe,CAAC;IAElC,+CAA+C;IAC/C,UAAU,EAAE,OAAO,CAAC;IAEpB,gEAAgE;IAChE,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAEpB,oCAAoC;IACpC,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB"}
|
|
@@ -1,32 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { UseTradeFeedReturn } from "./types.js";
|
|
1
|
+
import type { UseTradeFeedReturn } from "./types";
|
|
3
2
|
/**
|
|
4
|
-
* Hook for subscribing to real-time
|
|
3
|
+
* Hook for subscribing to real-time trade events via WebSocket (public)
|
|
5
4
|
*
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @param maxEvents - Maximum number of trades to keep in memory (default: 50)
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```tsx
|
|
12
|
-
* const { trades, connectionStatus, subscribed, error, clearError } = useTradeFeed("BTC/USDC", "spot");
|
|
13
|
-
*
|
|
14
|
-
* if (error) {
|
|
15
|
-
* return <ErrorMessage error={error} onDismiss={clearError} />;
|
|
16
|
-
* }
|
|
17
|
-
*
|
|
18
|
-
* if (connectionStatus === ConnectionStatus.Connecting) {
|
|
19
|
-
* return <Spinner message="Connecting to WebSocket..." />;
|
|
20
|
-
* }
|
|
21
|
-
*
|
|
22
|
-
* if (connectionStatus === ConnectionStatus.Connected && !subscribed) {
|
|
23
|
-
* return <Spinner message="Subscribing to market..." />;
|
|
24
|
-
* }
|
|
25
|
-
*
|
|
26
|
-
* if (subscribed) {
|
|
27
|
-
* return <TradeFeed trades={trades} />;
|
|
28
|
-
* }
|
|
29
|
-
* ```
|
|
5
|
+
* @param tradingPairId - The trading pair UUID to subscribe to
|
|
6
|
+
* @param maxTrades - Maximum number of trades to keep in state (default: 50)
|
|
30
7
|
*/
|
|
31
|
-
export declare function useTradeFeed(
|
|
8
|
+
export declare function useTradeFeed(tradingPairId: string, maxTrades?: number): UseTradeFeedReturn;
|
|
32
9
|
//# sourceMappingURL=useTradeFeed.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTradeFeed.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTradeFeed/useTradeFeed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTradeFeed.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTradeFeed/useTradeFeed.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,SAAK,GAAG,kBAAkB,CAgDtF"}
|
|
@@ -1,150 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { useMonacoSDK } from "../useMonaco/index.js";
|
|
4
|
-
import { convertOrderEventToTrade } from "./utils.js";
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
2
|
+
import { useMonacoSDK } from "../useMonaco";
|
|
5
3
|
/**
|
|
6
|
-
* Hook for subscribing to real-time
|
|
4
|
+
* Hook for subscribing to real-time trade events via WebSocket (public)
|
|
7
5
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
* @param maxEvents - Maximum number of trades to keep in memory (default: 50)
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```tsx
|
|
14
|
-
* const { trades, connectionStatus, subscribed, error, clearError } = useTradeFeed("BTC/USDC", "spot");
|
|
15
|
-
*
|
|
16
|
-
* if (error) {
|
|
17
|
-
* return <ErrorMessage error={error} onDismiss={clearError} />;
|
|
18
|
-
* }
|
|
19
|
-
*
|
|
20
|
-
* if (connectionStatus === ConnectionStatus.Connecting) {
|
|
21
|
-
* return <Spinner message="Connecting to WebSocket..." />;
|
|
22
|
-
* }
|
|
23
|
-
*
|
|
24
|
-
* if (connectionStatus === ConnectionStatus.Connected && !subscribed) {
|
|
25
|
-
* return <Spinner message="Subscribing to market..." />;
|
|
26
|
-
* }
|
|
27
|
-
*
|
|
28
|
-
* if (subscribed) {
|
|
29
|
-
* return <TradeFeed trades={trades} />;
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
6
|
+
* @param tradingPairId - The trading pair UUID to subscribe to
|
|
7
|
+
* @param maxTrades - Maximum number of trades to keep in state (default: 50)
|
|
32
8
|
*/
|
|
33
|
-
export function useTradeFeed(
|
|
34
|
-
const validatedMaxEvents = maxEvents < 1 ? 50 : maxEvents;
|
|
35
|
-
if (maxEvents < 1) {
|
|
36
|
-
console.warn("useTradeFeed: maxEvents must be >= 1, defaulting to 50");
|
|
37
|
-
}
|
|
9
|
+
export function useTradeFeed(tradingPairId, maxTrades = 50) {
|
|
38
10
|
const { sdk } = useMonacoSDK();
|
|
39
11
|
const [trades, setTrades] = useState([]);
|
|
40
12
|
const [error, setError] = useState(null);
|
|
41
|
-
const [
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const connect = useCallback(async () => {
|
|
50
|
-
if (!ordersWSClient)
|
|
51
|
-
return;
|
|
52
|
-
if (connectionStatus === WebSocketStatus.Connecting || connectionStatus === WebSocketStatus.Connected)
|
|
13
|
+
const [subscribed, setSubscribed] = useState(false);
|
|
14
|
+
const clearError = useCallback(() => setError(null), []);
|
|
15
|
+
// Get connection status directly from SDK
|
|
16
|
+
const connectionStatus = sdk?.ws?.getStatus() ?? "disconnected";
|
|
17
|
+
// Fetch initial trades and subscribe to WebSocket updates
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!sdk?.ws || !sdk?.trades || !tradingPairId) {
|
|
20
|
+
setSubscribed(false);
|
|
53
21
|
return;
|
|
54
|
-
setError(null);
|
|
55
|
-
setConnectionStatus(WebSocketStatus.Connecting);
|
|
56
|
-
try {
|
|
57
|
-
await ordersWSClient.connect();
|
|
58
|
-
setConnectionStatus(WebSocketStatus.Connected);
|
|
59
22
|
}
|
|
60
|
-
catch (err) {
|
|
61
|
-
setConnectionStatus(WebSocketStatus.Disconnected);
|
|
62
|
-
setError(err instanceof Error ? err : new Error(String(err)));
|
|
63
|
-
}
|
|
64
|
-
}, [ordersWSClient, connectionStatus]);
|
|
65
|
-
const subscribe = useCallback(async (pair, mode) => {
|
|
66
|
-
if (!ordersWSClient)
|
|
67
|
-
return;
|
|
68
|
-
if (connectionStatus !== WebSocketStatus.Connected)
|
|
69
|
-
return;
|
|
70
23
|
setTrades([]);
|
|
71
24
|
setError(null);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
25
|
+
// Fetch initial trades via REST API
|
|
26
|
+
const limit = Number.isFinite(maxTrades) ? maxTrades : 50;
|
|
27
|
+
sdk.trades
|
|
28
|
+
.getTrades(tradingPairId, { limit })
|
|
29
|
+
.then((initialTrades) => setTrades(initialTrades))
|
|
30
|
+
.catch((err) => setError(err instanceof Error ? err : new Error(String(err))));
|
|
31
|
+
// Subscribe to WebSocket trade updates
|
|
32
|
+
const unsubscribe = sdk.ws.trades(tradingPairId, (event) => {
|
|
33
|
+
setTrades((prev) => {
|
|
34
|
+
// Deduplicate by tradeId and keep newest first
|
|
35
|
+
const exists = prev.some((t) => t.data.tradeId === event.data.tradeId);
|
|
36
|
+
if (exists)
|
|
37
|
+
return prev;
|
|
38
|
+
return [event, ...prev].slice(0, limit);
|
|
85
39
|
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
setError(err instanceof Error ? err : new Error(String(err)));
|
|
90
|
-
}
|
|
91
|
-
}, [ordersWSClient, connectionStatus, validatedMaxEvents]);
|
|
92
|
-
const unsubscribe = useCallback(() => {
|
|
93
|
-
if (!ordersWSClient)
|
|
94
|
-
return;
|
|
95
|
-
if (!currentSubscriptionRef.current)
|
|
96
|
-
return;
|
|
97
|
-
if (connectionStatus !== WebSocketStatus.Connected)
|
|
98
|
-
return;
|
|
99
|
-
try {
|
|
100
|
-
const tradingMode = currentSubscriptionRef.current.mode;
|
|
101
|
-
ordersWSClient.unsubscribeFromOrderEvents(currentSubscriptionRef.current.pair, tradingMode);
|
|
102
|
-
currentSubscriptionRef.current = null;
|
|
103
|
-
setTrades([]);
|
|
104
|
-
}
|
|
105
|
-
catch (err) {
|
|
106
|
-
setError(err instanceof Error ? err : new Error(String(err)));
|
|
107
|
-
}
|
|
108
|
-
}, [ordersWSClient, connectionStatus]);
|
|
109
|
-
const disconnect = useCallback(() => {
|
|
110
|
-
if (connectionStatus !== WebSocketStatus.Connected)
|
|
111
|
-
return;
|
|
112
|
-
try {
|
|
113
|
-
ordersWSClient?.disconnect();
|
|
114
|
-
setConnectionStatus(WebSocketStatus.Disconnected);
|
|
115
|
-
setTrades([]);
|
|
116
|
-
setError(null);
|
|
117
|
-
}
|
|
118
|
-
catch (err) {
|
|
119
|
-
setError(err instanceof Error ? err : new Error(String(err)));
|
|
120
|
-
}
|
|
121
|
-
}, [ordersWSClient, connectionStatus]);
|
|
122
|
-
useEffect(() => {
|
|
123
|
-
if (tradingPair && tradingMode && connectionStatus === WebSocketStatus.Connected) {
|
|
124
|
-
if (tradingPair === currentSubscriptionRef.current?.pair && tradingMode === currentSubscriptionRef.current?.mode)
|
|
125
|
-
return;
|
|
40
|
+
});
|
|
41
|
+
setSubscribed(true);
|
|
42
|
+
return () => {
|
|
126
43
|
unsubscribe();
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
}, [
|
|
130
|
-
|
|
131
|
-
if (isSDKAuthenticated) {
|
|
132
|
-
void connect(); // Connect when SDK is available
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
// Clear state when SDK is disconnected
|
|
136
|
-
setTrades([]);
|
|
137
|
-
setConnectionStatus(WebSocketStatus.Disconnected);
|
|
138
|
-
currentSubscriptionRef.current = null;
|
|
139
|
-
}
|
|
140
|
-
return () => disconnect(); // Disconnect from ws on unmount
|
|
141
|
-
}, [isSDKAuthenticated, connect, disconnect]);
|
|
142
|
-
return {
|
|
143
|
-
trades,
|
|
144
|
-
connectionStatus,
|
|
145
|
-
subscribed,
|
|
146
|
-
error,
|
|
147
|
-
clearError,
|
|
148
|
-
};
|
|
44
|
+
setSubscribed(false);
|
|
45
|
+
};
|
|
46
|
+
}, [sdk?.ws, sdk?.trades, tradingPairId, maxTrades]);
|
|
47
|
+
return { trades, connectionStatus, subscribed, error, clearError };
|
|
149
48
|
}
|
|
150
49
|
//# sourceMappingURL=useTradeFeed.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTradeFeed.js","sourceRoot":"","sources":["../../../src/hooks/useTradeFeed/useTradeFeed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTradeFeed.js","sourceRoot":"","sources":["../../../src/hooks/useTradeFeed/useTradeFeed.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,aAAqB,EAAE,SAAS,GAAG,EAAE;IAChE,MAAM,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,CAAC;IAE/B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAe,EAAE,CAAC,CAAC;IACvD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IACvD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEp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KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACvE,IAAI,MAAM;oBAAE,OAAO,IAAI,CAAC;gBACxB,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YAC1C,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,aAAa,CAAC,IAAI,CAAC,CAAC;QAEpB,OAAO,GAAG,EAAE;YACV,WAAW,EAAE,CAAC;YACd,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC;IAErD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACrE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVault.d.ts","sourceRoot":"","sources":["../../../src/hooks/useVault/useVault.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useVault.d.ts","sourceRoot":"","sources":["../../../src/hooks/useVault/useVault.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,eAAO,MAAM,QAAQ,QAAO,cA8E3B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
|
-
import { useMonacoSDK } from "../useMonaco
|
|
2
|
+
import { useMonacoSDK } from "../useMonaco";
|
|
3
3
|
export const useVault = () => {
|
|
4
4
|
const { sdk } = useMonacoSDK();
|
|
5
5
|
const approve = useCallback(async (token, amount, autoWait) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVault.js","sourceRoot":"","sources":["../../../src/hooks/useVault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AO,MAAM,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC,EACD,CAAC,GAAG,CAAC,CACN,CAAC;IAEF,MAAM,aAAa,GAAG,WAAW,CAC/B,KAAK,EAAE,KAAa,EAAE,MAAc,EAAoB,EAAE;QACxD,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC/C,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACrF,IAAI,MAAM,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAEnE,OAAO,MAAM,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACtD,CAAC,EACD,CAAC,GAAG,CAAC,CACN,CAAC;IAEF,OAAO;QACL,mBAAmB;QACnB,OAAO;QACP,OAAO;QACP,QAAQ;QAER,gCAAgC;QAChC,UAAU;QACV,YAAY;QACZ,aAAa;KACd,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./provider/index.js";
|
|
5
|
-
export * from "./utils/index.js";
|
|
1
|
+
export * from "./hooks";
|
|
2
|
+
export * from "./provider";
|
|
3
|
+
export * from "./utils";
|
|
6
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./hooks
|
|
2
|
-
export * from "./provider
|
|
3
|
-
export * from "./utils
|
|
1
|
+
export * from "./hooks";
|
|
2
|
+
export * from "./provider";
|
|
3
|
+
export * from "./utils";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|