@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
package/README.md
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
# Monaco React SDK
|
|
2
|
+
|
|
3
|
+
React hooks and components for the Monaco Protocol. Build trading applications with React using type-safe hooks for authentication, trading, market data, and WebSocket connections.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install the React SDK and its dependencies
|
|
9
|
+
npm install @0xmonaco/react react wagmi@^2.17.5 viem@^2.31.7
|
|
10
|
+
|
|
11
|
+
# Or with pnpm
|
|
12
|
+
pnpm add @0xmonaco/react react wagmi@^2.17.5 viem@^2.31.7
|
|
13
|
+
|
|
14
|
+
# Or with yarn
|
|
15
|
+
yarn add @0xmonaco/react react wagmi@^2.17.5 viem@^2.31.7
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- 🎣 **React Hooks**: Type-safe hooks for all Monaco Protocol operations
|
|
21
|
+
- 🔐 **Authentication**: `useAuth` hook for wallet-based login and session management
|
|
22
|
+
- 📈 **Trading**: `useTrade` hook for placing and managing orders
|
|
23
|
+
- 📊 **Market Data**: `useMarket` hook for trading pairs and candlestick data
|
|
24
|
+
- 👤 **Profile**: `useProfile` hook for user account information
|
|
25
|
+
- 🔄 **WebSocket**: Real-time hooks for orders, OHLCV, and orderbook updates
|
|
26
|
+
- 💼 **Vault**: `useVault` hook for token deposits and withdrawals
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
### 1. Setup the Monaco Provider
|
|
31
|
+
|
|
32
|
+
Wrap your application with the `MonacoProvider`:
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { MonacoProvider } from "@0xmonaco/react";
|
|
36
|
+
import { WagmiProvider, createConfig, http } from "wagmi";
|
|
37
|
+
import { seiTestnet } from "wagmi/chains";
|
|
38
|
+
|
|
39
|
+
const wagmiConfig = createConfig({
|
|
40
|
+
chains: [seiTestnet],
|
|
41
|
+
transports: {
|
|
42
|
+
[seiTestnet.id]: http("https://evm-rpc-testnet.sei-apis.com"),
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
function App() {
|
|
47
|
+
return (
|
|
48
|
+
<WagmiProvider config={wagmiConfig}>
|
|
49
|
+
<MonacoProvider
|
|
50
|
+
network="testnet"
|
|
51
|
+
seiRpcUrl="https://evm-rpc-testnet.sei-apis.com"
|
|
52
|
+
>
|
|
53
|
+
<YourApp />
|
|
54
|
+
</MonacoProvider>
|
|
55
|
+
</WagmiProvider>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 2. Use Monaco Hooks
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import { useMonaco, useAuth, useTrade, useMarket } from "@0xmonaco/react";
|
|
64
|
+
|
|
65
|
+
function TradingComponent() {
|
|
66
|
+
const sdk = useMonaco();
|
|
67
|
+
const { login, logout, isAuthenticated } = useAuth();
|
|
68
|
+
const { placeLimitOrder, placeMarketOrder } = useTrade();
|
|
69
|
+
const { tradingPairs, getTradingPairBySymbol } = useMarket();
|
|
70
|
+
|
|
71
|
+
// Login
|
|
72
|
+
const handleLogin = async () => {
|
|
73
|
+
await login("your-client-id", { connectWebSocket: true });
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// Place an order
|
|
77
|
+
const handlePlaceOrder = async () => {
|
|
78
|
+
const order = await placeLimitOrder(
|
|
79
|
+
"BTC/USDC",
|
|
80
|
+
"BUY",
|
|
81
|
+
"0.001",
|
|
82
|
+
"50000"
|
|
83
|
+
);
|
|
84
|
+
console.log("Order placed:", order.order_id);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div>
|
|
89
|
+
<button onClick={handleLogin}>
|
|
90
|
+
{isAuthenticated ? "Logout" : "Login"}
|
|
91
|
+
</button>
|
|
92
|
+
<button onClick={handlePlaceOrder}>Place Order</button>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Available Hooks
|
|
99
|
+
|
|
100
|
+
### Core Hooks
|
|
101
|
+
|
|
102
|
+
#### `useMonaco()`
|
|
103
|
+
Access the Monaco SDK instance directly.
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
const sdk = useMonaco();
|
|
107
|
+
const address = sdk.getAccountAddress();
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### `useAuth()`
|
|
111
|
+
Authentication and session management.
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
const { login, logout, isAuthenticated, authState } = useAuth();
|
|
115
|
+
|
|
116
|
+
// Login with auto-connect WebSocket
|
|
117
|
+
await login(clientId, { connectWebSocket: true });
|
|
118
|
+
|
|
119
|
+
// Check authentication status
|
|
120
|
+
if (isAuthenticated) {
|
|
121
|
+
console.log("User:", authState?.user);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Logout
|
|
125
|
+
await logout();
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Trading Hooks
|
|
129
|
+
|
|
130
|
+
#### `useTrade()`
|
|
131
|
+
Place and manage orders.
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
const {
|
|
135
|
+
placeLimitOrder,
|
|
136
|
+
placeMarketOrder,
|
|
137
|
+
cancelOrder,
|
|
138
|
+
replaceOrder,
|
|
139
|
+
getOrder,
|
|
140
|
+
getPaginatedOrders,
|
|
141
|
+
} = useTrade();
|
|
142
|
+
|
|
143
|
+
// Place a limit order
|
|
144
|
+
const order = await placeLimitOrder(
|
|
145
|
+
"BTC/USDC",
|
|
146
|
+
"BUY",
|
|
147
|
+
"0.001",
|
|
148
|
+
"50000",
|
|
149
|
+
{ timeInForce: "GTC" }
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
// Place a market order
|
|
153
|
+
const marketOrder = await placeMarketOrder(
|
|
154
|
+
"BTC/USDC",
|
|
155
|
+
"SELL",
|
|
156
|
+
"0.001",
|
|
157
|
+
{ slippageTolerance: 0.01 } // 1%
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
// Cancel an order
|
|
161
|
+
await cancelOrder(orderId);
|
|
162
|
+
|
|
163
|
+
// Get orders
|
|
164
|
+
const { data: orders } = await getPaginatedOrders({
|
|
165
|
+
status: "PENDING",
|
|
166
|
+
trading_pair: "BTC/USDC",
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Market Data Hooks
|
|
171
|
+
|
|
172
|
+
#### `useMarket()`
|
|
173
|
+
Access trading pair metadata and market data.
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
const { tradingPairs, getTradingPairBySymbol, getCandlestickData } = useMarket();
|
|
177
|
+
|
|
178
|
+
// Get all trading pairs
|
|
179
|
+
const pairs = await tradingPairs();
|
|
180
|
+
|
|
181
|
+
// Get specific pair
|
|
182
|
+
const btcPair = await getTradingPairBySymbol("BTC/USDC");
|
|
183
|
+
|
|
184
|
+
// Get candlestick data
|
|
185
|
+
const candles = await getCandlestickData(
|
|
186
|
+
"BTC/USDC",
|
|
187
|
+
"1h",
|
|
188
|
+
Date.now() - 86400000, // 24h ago
|
|
189
|
+
Date.now()
|
|
190
|
+
);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
#### `useTradeFeed()`
|
|
194
|
+
Get recent trades for a trading pair.
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
const { getTradeFeed } = useTradeFeed();
|
|
198
|
+
|
|
199
|
+
const trades = await getTradeFeed("BTC/USDC", { limit: 50 });
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Vault Hooks
|
|
203
|
+
|
|
204
|
+
#### `useVault()`
|
|
205
|
+
Manage token deposits and withdrawals.
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
const { deposit, withdraw, approve, getBalance, needsApproval } = useVault();
|
|
209
|
+
|
|
210
|
+
// Check balance
|
|
211
|
+
const balance = await getBalance(tokenAddress);
|
|
212
|
+
console.log(`Balance: ${balance.formatted} ${balance.symbol}`);
|
|
213
|
+
|
|
214
|
+
// Approve if needed
|
|
215
|
+
if (await needsApproval(tokenAddress, amount)) {
|
|
216
|
+
await approve(tokenAddress, amount);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Deposit
|
|
220
|
+
await deposit(tokenAddress, amount);
|
|
221
|
+
|
|
222
|
+
// Withdraw
|
|
223
|
+
await withdraw(tokenAddress, amount);
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Profile Hooks
|
|
227
|
+
|
|
228
|
+
#### `useProfile()`
|
|
229
|
+
Access user profile and account information.
|
|
230
|
+
|
|
231
|
+
```tsx
|
|
232
|
+
const { getProfile, getUserBalances, getUserMovements } = useProfile();
|
|
233
|
+
|
|
234
|
+
// Get profile
|
|
235
|
+
const profile = await getProfile();
|
|
236
|
+
|
|
237
|
+
// Get balances
|
|
238
|
+
const balances = await getUserBalances({
|
|
239
|
+
page: 1,
|
|
240
|
+
page_size: 10,
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
// Get movements (transaction history)
|
|
244
|
+
const movements = await getUserMovements({
|
|
245
|
+
page: 1,
|
|
246
|
+
page_size: 20,
|
|
247
|
+
});
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### WebSocket Hooks
|
|
251
|
+
|
|
252
|
+
#### `useOrderWebSocket()`
|
|
253
|
+
Subscribe to real-time order updates.
|
|
254
|
+
|
|
255
|
+
```tsx
|
|
256
|
+
const { subscribe, unsubscribe, connect, disconnect } = useOrderWebSocket();
|
|
257
|
+
|
|
258
|
+
useEffect(() => {
|
|
259
|
+
// Connect and subscribe
|
|
260
|
+
await connect();
|
|
261
|
+
|
|
262
|
+
subscribe("BTC/USDC", "SPOT", (event) => {
|
|
263
|
+
console.log("Order event:", event.eventType);
|
|
264
|
+
if (event.eventType === "ORDER_FILLED") {
|
|
265
|
+
console.log("Order filled:", event.order);
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
return () => {
|
|
270
|
+
unsubscribe("BTC/USDC", "SPOT");
|
|
271
|
+
disconnect();
|
|
272
|
+
};
|
|
273
|
+
}, []);
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
#### `useOHLCVWebSocket()`
|
|
277
|
+
Subscribe to real-time candlestick data.
|
|
278
|
+
|
|
279
|
+
```tsx
|
|
280
|
+
const { subscribe, unsubscribe, connect, disconnect } = useOHLCVWebSocket();
|
|
281
|
+
|
|
282
|
+
useEffect(() => {
|
|
283
|
+
await connect();
|
|
284
|
+
|
|
285
|
+
subscribe("BTC/USDC", "SPOT", "1m", (event) => {
|
|
286
|
+
console.log("New candle:", event.candlestick);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
return () => {
|
|
290
|
+
unsubscribe("BTC/USDC", "SPOT", "1m");
|
|
291
|
+
disconnect();
|
|
292
|
+
};
|
|
293
|
+
}, []);
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
#### `useOrderbook()`
|
|
297
|
+
Subscribe to real-time orderbook updates.
|
|
298
|
+
|
|
299
|
+
```tsx
|
|
300
|
+
const { subscribe, unsubscribe, connect, disconnect } = useOrderbook();
|
|
301
|
+
|
|
302
|
+
useEffect(() => {
|
|
303
|
+
await connect();
|
|
304
|
+
|
|
305
|
+
subscribe("BTC/USDC", "SPOT", (event) => {
|
|
306
|
+
console.log("Orderbook:", {
|
|
307
|
+
bids: event.bids.length,
|
|
308
|
+
asks: event.asks.length,
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
return () => {
|
|
313
|
+
unsubscribe("BTC/USDC", "SPOT");
|
|
314
|
+
disconnect();
|
|
315
|
+
};
|
|
316
|
+
}, []);
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## TypeScript Configuration
|
|
320
|
+
|
|
321
|
+
For optimal type inference, use these TypeScript settings:
|
|
322
|
+
|
|
323
|
+
```json
|
|
324
|
+
{
|
|
325
|
+
"compilerOptions": {
|
|
326
|
+
"target": "ES2020",
|
|
327
|
+
"module": "nodenext",
|
|
328
|
+
"moduleResolution": "nodenext",
|
|
329
|
+
"jsx": "react-jsx",
|
|
330
|
+
"strict": true,
|
|
331
|
+
"esModuleInterop": true,
|
|
332
|
+
"resolveJsonModule": true
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## Examples
|
|
338
|
+
|
|
339
|
+
Check out the [`examples/react-vite-app`](../../examples/react-vite-app) directory for a complete React application using the Monaco SDK.
|
|
340
|
+
|
|
341
|
+
## Development
|
|
342
|
+
|
|
343
|
+
### Build
|
|
344
|
+
|
|
345
|
+
```bash
|
|
346
|
+
pnpm build
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Watch Mode
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
pnpm dev
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Lint
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
pnpm lint
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
## Contributing
|
|
362
|
+
|
|
363
|
+
We welcome contributions! Please see our [Contributing Guide](../../docs/contributing.mdx) for details.
|
|
364
|
+
|
|
365
|
+
## License
|
|
366
|
+
|
|
367
|
+
This project is licensed under the MIT License - see the [LICENSE](../../LICENSE) file for details.
|
|
368
|
+
|
|
369
|
+
## Support
|
|
370
|
+
|
|
371
|
+
For support, please:
|
|
372
|
+
|
|
373
|
+
- Open an issue on GitHub
|
|
374
|
+
- Join our [Discord community](https://discord.gg/monaco)
|
|
375
|
+
- Visit our [documentation site](https://docs.monaco.xyz)
|
|
376
|
+
- Check our [API documentation](../../docs/api-reference.mdx)
|
|
377
|
+
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from "./useAuth
|
|
2
|
-
export * from "./useFees
|
|
3
|
-
export * from "./useMarket
|
|
4
|
-
export * from "./useMonaco
|
|
5
|
-
export * from "./useOrderbook
|
|
6
|
-
export * from "./useProfile
|
|
7
|
-
export * from "./useTokenLifecycle
|
|
8
|
-
export * from "./useTrade
|
|
9
|
-
export * from "./useTradeFeed
|
|
10
|
-
export * from "./useVault
|
|
1
|
+
export * from "./useAuth";
|
|
2
|
+
export * from "./useFees";
|
|
3
|
+
export * from "./useMarket";
|
|
4
|
+
export * from "./useMonaco";
|
|
5
|
+
export * from "./useOrderbook";
|
|
6
|
+
export * from "./useProfile";
|
|
7
|
+
export * from "./useTokenLifecycle";
|
|
8
|
+
export * from "./useTrade";
|
|
9
|
+
export * from "./useTradeFeed";
|
|
10
|
+
export * from "./useVault";
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from "./useAuth
|
|
2
|
-
export * from "./useFees
|
|
3
|
-
export * from "./useMarket
|
|
4
|
-
export * from "./useMonaco
|
|
5
|
-
export * from "./useOrderbook
|
|
6
|
-
export * from "./useProfile
|
|
7
|
-
export * from "./useTokenLifecycle
|
|
8
|
-
export * from "./useTrade
|
|
9
|
-
export * from "./useTradeFeed
|
|
10
|
-
export * from "./useVault
|
|
1
|
+
export * from "./useAuth";
|
|
2
|
+
export * from "./useFees";
|
|
3
|
+
export * from "./useMarket";
|
|
4
|
+
export * from "./useMonaco";
|
|
5
|
+
export * from "./useOrderbook";
|
|
6
|
+
export * from "./useProfile";
|
|
7
|
+
export * from "./useTokenLifecycle";
|
|
8
|
+
export * from "./useTrade";
|
|
9
|
+
export * from "./useTradeFeed";
|
|
10
|
+
export * from "./useVault";
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuth/useAuth.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,eAAO,MAAM,OAAO,QAAO,
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuth/useAuth.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,eAAO,MAAM,OAAO,QAAO,aAyK1B,CAAC"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
2
|
import { useWalletClient } from "wagmi";
|
|
3
|
-
import { AuthenticationStatus } from "../../provider
|
|
4
|
-
import { useMonacoContext } from "../../provider/MonacoProvider
|
|
5
|
-
import { useMonacoSDK } from "../useMonaco
|
|
3
|
+
import { AuthenticationStatus } from "../../provider";
|
|
4
|
+
import { useMonacoContext } from "../../provider/MonacoProvider";
|
|
5
|
+
import { useMonacoSDK } from "../useMonaco";
|
|
6
6
|
export const useAuth = () => {
|
|
7
7
|
const { sdk, clientId } = useMonacoSDK();
|
|
8
8
|
const { authenticationStatus, setAuthenticationStatus, tokenLifecycle } = useMonacoContext();
|
|
9
9
|
const { data: walletClient } = useWalletClient();
|
|
10
|
-
const login = useCallback(async (
|
|
10
|
+
const login = useCallback(async () => {
|
|
11
11
|
if (!sdk)
|
|
12
12
|
throw new Error("SDK not available");
|
|
13
13
|
if (!walletClient)
|
|
14
14
|
throw new Error("Wallet not connected");
|
|
15
15
|
setAuthenticationStatus(AuthenticationStatus.AUTHENTICATING);
|
|
16
16
|
try {
|
|
17
|
-
const authState = await sdk.login(clientId
|
|
17
|
+
const authState = await sdk.login(clientId);
|
|
18
18
|
// Initialize token lifecycle management (caching + auto-refresh)
|
|
19
19
|
tokenLifecycle.initializeTokens(authState);
|
|
20
20
|
const authenticated = sdk.isAuthenticated();
|
|
@@ -49,7 +49,7 @@ export const useAuth = () => {
|
|
|
49
49
|
setAuthenticationStatus(AuthenticationStatus.AUTHENTICATING);
|
|
50
50
|
try {
|
|
51
51
|
const result = await sdk.refreshAuth();
|
|
52
|
-
// Reinitialize token lifecycle with new tokens
|
|
52
|
+
// Reinitialize the token lifecycle with new tokens
|
|
53
53
|
tokenLifecycle.initializeTokens(result);
|
|
54
54
|
const authenticated = sdk.isAuthenticated();
|
|
55
55
|
setAuthenticationStatus(authenticated ? AuthenticationStatus.AUTHENTICATED : AuthenticationStatus.UNAUTHENTICATED);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../../src/hooks/useAuth/useAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../../src/hooks/useAuth/useAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC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
|
-
export type { UseFeesReturn } from "./types
|
|
2
|
-
export { useFees } from "./useFees
|
|
1
|
+
export type { UseFeesReturn } from "./types";
|
|
2
|
+
export { useFees } from "./useFees";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFees/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFees/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { useFees } from "./useFees
|
|
1
|
+
export { useFees } from "./useFees";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/useFees/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/useFees/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MonacoSDK } from "@0xmonaco/types";
|
|
2
2
|
export interface UseMonacoReturn {
|
|
3
3
|
/** Monaco SDK instance */
|
|
4
|
-
sdk:
|
|
4
|
+
sdk: MonacoSDK | null;
|
|
5
5
|
/** Client ID for authentication */
|
|
6
6
|
clientId: string;
|
|
7
7
|
/** Any error that occurred (SDK initialization, authentication, etc.) */
|
|
8
8
|
error: Error | null;
|
|
9
|
-
/** Clear current error state */
|
|
9
|
+
/** Clear the current error state */
|
|
10
10
|
clearError: () => void;
|
|
11
|
-
/** Set error state */
|
|
11
|
+
/** Set an error state */
|
|
12
12
|
setError: (error: Error | null) => void;
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/hooks/useMonaco/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/hooks/useMonaco/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,WAAW,eAAe;IAC9B,0BAA0B;IAC1B,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IACtB,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,oCAAoC;IACpC,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,yBAAyB;IACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,CAAC;CACzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMonaco.d.ts","sourceRoot":"","sources":["../../../src/hooks/useMonaco/useMonaco.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useMonaco.d.ts","sourceRoot":"","sources":["../../../src/hooks/useMonaco/useMonaco.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,YAAY,QAAO,eAY/B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
|
-
import { useMonacoContext } from "../../provider/MonacoProvider
|
|
2
|
+
import { useMonacoContext } from "../../provider/MonacoProvider";
|
|
3
3
|
export const useMonacoSDK = () => {
|
|
4
4
|
const { sdk, clientId, error, setError } = useMonacoContext();
|
|
5
5
|
const clearError = useCallback(() => setError(null), [setError]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMonaco.js","sourceRoot":"","sources":["../../../src/hooks/useMonaco/useMonaco.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useMonaco.js","sourceRoot":"","sources":["../../../src/hooks/useMonaco/useMonaco.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,MAAM,CAAC,MAAM,YAAY,GAAG,GAAoB,EAAE;IAChD,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAE9D,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEjE,OAAO;QACL,GAAG;QACH,QAAQ;QACR,KAAK;QACL,UAAU;QACV,QAAQ;KACT,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OrderbookEvent, OrderbookQuotationMode, TradingMode, WebSocketStatus } from "@0xmonaco/types";
|
|
2
2
|
/**
|
|
3
3
|
* State structure for current subscription ref
|
|
4
4
|
*/
|
|
@@ -19,7 +19,7 @@ export interface UseOrderbookReturn {
|
|
|
19
19
|
/** Current orderbook snapshot */
|
|
20
20
|
orderbook: OrderbookEvent | null;
|
|
21
21
|
/** WebSocket connection status */
|
|
22
|
-
connectionStatus:
|
|
22
|
+
connectionStatus: WebSocketStatus;
|
|
23
23
|
/** Whether currently subscribed to a market */
|
|
24
24
|
subscribed: boolean;
|
|
25
25
|
/** Any error that occurred during connection or subscription */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/hooks/useOrderbook/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/hooks/useOrderbook/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE5G;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,IAAI,EAAE,WAAW,CAAC;IAClB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,aAAa,CAAC,EAAE,sBAAsB,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,iCAAiC;IACjC,SAAS,EAAE,cAAc,GAAG,IAAI,CAAC;IAEjC,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,48 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { UseOrderbookReturn } from "./types
|
|
3
|
-
|
|
4
|
-
* React hook to subscribe to and manage the orderbook for a given trading pair and mode.
|
|
5
|
-
*
|
|
6
|
-
* Connects to the Monaco SDK WebSocket orderbook feed, subscribes to updates,
|
|
7
|
-
* and provides the latest orderbook event, connection status, subscription state, and error handling.
|
|
8
|
-
*
|
|
9
|
-
* @param {string | null} tradingPair - The trading pair to subscribe to (e.g., "BTC/USD"). If null, no subscription is made.
|
|
10
|
-
* @param {TradingMode} tradingMode - The trading mode to use for the subscription (e.g., "live", "test").
|
|
11
|
-
* @param {number} [magnitude] - Optional magnitude for orderbook grouping (0.0001 to 10000, defaults to no grouping).
|
|
12
|
-
* @param {OrderbookQuotationMode} [quotationMode] - Optional quotation mode ("BASE" or "QUOTE"), defaults to "BASE".
|
|
13
|
-
* @returns {UseOrderbookReturn} An object containing the latest orderbook event, connection status, subscription state, error, and error clearing function.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```tsx
|
|
17
|
-
* import { useOrderbook } from "./useOrderbook";
|
|
18
|
-
*
|
|
19
|
-
* function OrderbookComponent() {
|
|
20
|
-
* const { orderbook, connectionStatus, subscribed, error, clearError } = useOrderbook("BTC/USD", "live");
|
|
21
|
-
*
|
|
22
|
-
* if (error) return <div>Error: {error.message} <button onClick={clearError}>Clear</button></div>;
|
|
23
|
-
* if (!subscribed) return <div>Not subscribed</div>;
|
|
24
|
-
* if (!orderbook) return <div>Loading...</div>;
|
|
25
|
-
*
|
|
26
|
-
* return (
|
|
27
|
-
* <div>
|
|
28
|
-
* <h2>Orderbook ({connectionStatus})</h2>
|
|
29
|
-
* {/** Render orderbook data here }
|
|
30
|
-
* </div>
|
|
31
|
-
* );
|
|
32
|
-
* }
|
|
33
|
-
*
|
|
34
|
-
* // With magnitude for grouping
|
|
35
|
-
* function GroupedOrderbookComponent() {
|
|
36
|
-
* const { orderbook } = useOrderbook("BTC/USD", "live", 10);
|
|
37
|
-
* // ... render grouped orderbook
|
|
38
|
-
* }
|
|
39
|
-
*
|
|
40
|
-
* // With QUOTE quotation mode
|
|
41
|
-
* function QuoteOrderbookComponent() {
|
|
42
|
-
* const { orderbook } = useOrderbook("BTC/USD", "live", undefined, "QUOTE");
|
|
43
|
-
* // ... render orderbook in QUOTE mode
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
export declare function useOrderbook(tradingPair: string | null, tradingMode: TradingMode, magnitude?: number, quotationMode?: OrderbookQuotationMode): UseOrderbookReturn;
|
|
1
|
+
import type { OrderbookQuotationMode, TradingMode } from "@0xmonaco/types";
|
|
2
|
+
import type { UseOrderbookReturn } from "./types";
|
|
3
|
+
export declare function useOrderbook(tradingPairId: string, tradingMode: TradingMode, magnitude: number, quotationMode: OrderbookQuotationMode, depth?: number): UseOrderbookReturn;
|
|
48
4
|
//# sourceMappingURL=useOrderbook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOrderbook.d.ts","sourceRoot":"","sources":["../../../src/hooks/useOrderbook/useOrderbook.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useOrderbook.d.ts","sourceRoot":"","sources":["../../../src/hooks/useOrderbook/useOrderbook.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,sBAAsB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE3F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,wBAAgB,YAAY,CAC1B,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,sBAAsB,EACrC,KAAK,SAAK,GACT,kBAAkB,CAuCpB"}
|