wagmi 3.1.4 → 3.3.0
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/esm/exports/tempo.js +9 -0
- package/dist/esm/exports/tempo.js.map +1 -0
- package/dist/esm/tempo/hooks/amm.js +485 -0
- package/dist/esm/tempo/hooks/amm.js.map +1 -0
- package/dist/esm/tempo/hooks/dex.js +1020 -0
- package/dist/esm/tempo/hooks/dex.js.map +1 -0
- package/dist/esm/tempo/hooks/faucet.js +76 -0
- package/dist/esm/tempo/hooks/faucet.js.map +1 -0
- package/dist/esm/tempo/hooks/fee.js +155 -0
- package/dist/esm/tempo/hooks/fee.js.map +1 -0
- package/dist/esm/tempo/hooks/index.js +11 -0
- package/dist/esm/tempo/hooks/index.js.map +1 -0
- package/dist/esm/tempo/hooks/nonce.js +85 -0
- package/dist/esm/tempo/hooks/nonce.js.map +1 -0
- package/dist/esm/tempo/hooks/policy.js +545 -0
- package/dist/esm/tempo/hooks/policy.js.map +1 -0
- package/dist/esm/tempo/hooks/reward.js +385 -0
- package/dist/esm/tempo/hooks/reward.js.map +1 -0
- package/dist/esm/tempo/hooks/token.js +1730 -0
- package/dist/esm/tempo/hooks/token.js.map +1 -0
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/exports/tempo.d.ts +4 -0
- package/dist/types/exports/tempo.d.ts.map +1 -0
- package/dist/types/tempo/hooks/amm.d.ts +384 -0
- package/dist/types/tempo/hooks/amm.d.ts.map +1 -0
- package/dist/types/tempo/hooks/dex.d.ts +841 -0
- package/dist/types/tempo/hooks/dex.d.ts.map +1 -0
- package/dist/types/tempo/hooks/faucet.d.ts +70 -0
- package/dist/types/tempo/hooks/faucet.d.ts.map +1 -0
- package/dist/types/tempo/hooks/fee.d.ts +123 -0
- package/dist/types/tempo/hooks/fee.d.ts.map +1 -0
- package/dist/types/tempo/hooks/index.d.ts +10 -0
- package/dist/types/tempo/hooks/index.d.ts.map +1 -0
- package/dist/types/tempo/hooks/nonce.d.ts +60 -0
- package/dist/types/tempo/hooks/nonce.d.ts.map +1 -0
- package/dist/types/tempo/hooks/policy.d.ts +422 -0
- package/dist/types/tempo/hooks/policy.d.ts.map +1 -0
- package/dist/types/tempo/hooks/reward.d.ts +304 -0
- package/dist/types/tempo/hooks/reward.d.ts.map +1 -0
- package/dist/types/tempo/hooks/token.d.ts +1387 -0
- package/dist/types/tempo/hooks/token.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +12 -4
- package/src/exports/tempo.ts +17 -0
- package/src/tempo/hooks/amm.ts +776 -0
- package/src/tempo/hooks/dex.ts +1737 -0
- package/src/tempo/hooks/faucet.ts +142 -0
- package/src/tempo/hooks/fee.ts +264 -0
- package/src/tempo/hooks/index.ts +10 -0
- package/src/tempo/hooks/nonce.ts +126 -0
- package/src/tempo/hooks/policy.ts +907 -0
- package/src/tempo/hooks/reward.ts +668 -0
- package/src/tempo/hooks/token.ts +2979 -0
- package/src/version.ts +1 -1
- package/tempo/package.json +5 -0
|
@@ -0,0 +1,1020 @@
|
|
|
1
|
+
import { Actions } from '@wagmi/core/tempo';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { useChainId } from '../../hooks/useChainId.js';
|
|
4
|
+
import { useConfig } from '../../hooks/useConfig.js';
|
|
5
|
+
import { useMutation, useQuery, } from '../../utils/query.js';
|
|
6
|
+
/**
|
|
7
|
+
* Hook for buying a specific amount of tokens.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
12
|
+
*
|
|
13
|
+
* function App() {
|
|
14
|
+
* const { mutate, isPending } = Hooks.dex.useBuy()
|
|
15
|
+
*
|
|
16
|
+
* return (
|
|
17
|
+
* <button
|
|
18
|
+
* onClick={() => mutate({
|
|
19
|
+
* tokenIn: '0x20c...11',
|
|
20
|
+
* tokenOut: '0x20c...20',
|
|
21
|
+
* amountOut: parseUnits('100', 6),
|
|
22
|
+
* maxAmountIn: parseUnits('105', 6),
|
|
23
|
+
* })}
|
|
24
|
+
* disabled={isPending}
|
|
25
|
+
* >
|
|
26
|
+
* Buy Tokens
|
|
27
|
+
* </button>
|
|
28
|
+
* )
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @param parameters - Parameters.
|
|
33
|
+
* @returns Mutation result.
|
|
34
|
+
*/
|
|
35
|
+
export function useBuy(parameters = {}) {
|
|
36
|
+
const { mutation } = parameters;
|
|
37
|
+
const config = useConfig(parameters);
|
|
38
|
+
return useMutation({
|
|
39
|
+
...mutation,
|
|
40
|
+
async mutationFn(variables) {
|
|
41
|
+
return Actions.dex.buy(config, variables);
|
|
42
|
+
},
|
|
43
|
+
mutationKey: ['buy'],
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Hook for buying a specific amount of tokens.
|
|
48
|
+
*
|
|
49
|
+
* Note: This is a synchronous hook that waits for the transaction
|
|
50
|
+
* to be included on a block before returning a response.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
55
|
+
*
|
|
56
|
+
* function App() {
|
|
57
|
+
* const { mutate, isPending } = Hooks.dex.useBuySync()
|
|
58
|
+
*
|
|
59
|
+
* return (
|
|
60
|
+
* <button
|
|
61
|
+
* onClick={() => mutate({
|
|
62
|
+
* tokenIn: '0x20c...11',
|
|
63
|
+
* tokenOut: '0x20c...20',
|
|
64
|
+
* amountOut: parseUnits('100', 6),
|
|
65
|
+
* maxAmountIn: parseUnits('105', 6),
|
|
66
|
+
* })}
|
|
67
|
+
* disabled={isPending}
|
|
68
|
+
* >
|
|
69
|
+
* Buy Tokens
|
|
70
|
+
* </button>
|
|
71
|
+
* )
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @param parameters - Parameters.
|
|
76
|
+
* @returns Mutation result.
|
|
77
|
+
*/
|
|
78
|
+
export function useBuySync(parameters = {}) {
|
|
79
|
+
const { mutation } = parameters;
|
|
80
|
+
const config = useConfig(parameters);
|
|
81
|
+
return useMutation({
|
|
82
|
+
...mutation,
|
|
83
|
+
async mutationFn(variables) {
|
|
84
|
+
return Actions.dex.buySync(config, variables);
|
|
85
|
+
},
|
|
86
|
+
mutationKey: ['buySync'],
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Hook for canceling an order from the orderbook.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```tsx
|
|
94
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
95
|
+
*
|
|
96
|
+
* function App() {
|
|
97
|
+
* const { mutate, isPending } = Hooks.dex.useCancel()
|
|
98
|
+
*
|
|
99
|
+
* return (
|
|
100
|
+
* <button
|
|
101
|
+
* onClick={() => mutate({ orderId: 123n })}
|
|
102
|
+
* disabled={isPending}
|
|
103
|
+
* >
|
|
104
|
+
* Cancel Order
|
|
105
|
+
* </button>
|
|
106
|
+
* )
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @param parameters - Parameters.
|
|
111
|
+
* @returns Mutation result.
|
|
112
|
+
*/
|
|
113
|
+
export function useCancel(parameters = {}) {
|
|
114
|
+
const { mutation } = parameters;
|
|
115
|
+
const config = useConfig(parameters);
|
|
116
|
+
return useMutation({
|
|
117
|
+
...mutation,
|
|
118
|
+
async mutationFn(variables) {
|
|
119
|
+
return Actions.dex.cancel(config, variables);
|
|
120
|
+
},
|
|
121
|
+
mutationKey: ['cancel'],
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Hook for canceling an order from the orderbook.
|
|
126
|
+
*
|
|
127
|
+
* Note: This is a synchronous hook that waits for the transaction
|
|
128
|
+
* to be included on a block before returning a response.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```tsx
|
|
132
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
133
|
+
*
|
|
134
|
+
* function App() {
|
|
135
|
+
* const { mutate, isPending } = Hooks.dex.useCancelSync()
|
|
136
|
+
*
|
|
137
|
+
* return (
|
|
138
|
+
* <button
|
|
139
|
+
* onClick={() => mutate({ orderId: 123n })}
|
|
140
|
+
* disabled={isPending}
|
|
141
|
+
* >
|
|
142
|
+
* Cancel Order
|
|
143
|
+
* </button>
|
|
144
|
+
* )
|
|
145
|
+
* }
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @param parameters - Parameters.
|
|
149
|
+
* @returns Mutation result.
|
|
150
|
+
*/
|
|
151
|
+
export function useCancelSync(parameters = {}) {
|
|
152
|
+
const { mutation } = parameters;
|
|
153
|
+
const config = useConfig(parameters);
|
|
154
|
+
return useMutation({
|
|
155
|
+
...mutation,
|
|
156
|
+
async mutationFn(variables) {
|
|
157
|
+
return Actions.dex.cancelSync(config, variables);
|
|
158
|
+
},
|
|
159
|
+
mutationKey: ['cancelSync'],
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Hook for cancelling a stale order from the orderbook.
|
|
164
|
+
*
|
|
165
|
+
* A stale order is one where the owner's balance or allowance has dropped
|
|
166
|
+
* below the order amount.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```tsx
|
|
170
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
171
|
+
*
|
|
172
|
+
* function App() {
|
|
173
|
+
* const { mutate, isPending } = Hooks.dex.useCancelStale()
|
|
174
|
+
*
|
|
175
|
+
* return (
|
|
176
|
+
* <button
|
|
177
|
+
* onClick={() => mutate({ orderId: 123n })}
|
|
178
|
+
* disabled={isPending}
|
|
179
|
+
* >
|
|
180
|
+
* Cancel Stale Order
|
|
181
|
+
* </button>
|
|
182
|
+
* )
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* @param parameters - Parameters.
|
|
187
|
+
* @returns Mutation result.
|
|
188
|
+
*/
|
|
189
|
+
export function useCancelStale(parameters = {}) {
|
|
190
|
+
const { mutation } = parameters;
|
|
191
|
+
const config = useConfig(parameters);
|
|
192
|
+
return useMutation({
|
|
193
|
+
...mutation,
|
|
194
|
+
async mutationFn(variables) {
|
|
195
|
+
return Actions.dex.cancelStale(config, variables);
|
|
196
|
+
},
|
|
197
|
+
mutationKey: ['cancelStale'],
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Hook for cancelling a stale order and waiting for confirmation.
|
|
202
|
+
*
|
|
203
|
+
* A stale order is one where the owner's balance or allowance has dropped
|
|
204
|
+
* below the order amount.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```tsx
|
|
208
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
209
|
+
*
|
|
210
|
+
* function App() {
|
|
211
|
+
* const { mutate, isPending } = Hooks.dex.useCancelStaleSync()
|
|
212
|
+
*
|
|
213
|
+
* return (
|
|
214
|
+
* <button
|
|
215
|
+
* onClick={() => mutate({ orderId: 123n })}
|
|
216
|
+
* disabled={isPending}
|
|
217
|
+
* >
|
|
218
|
+
* Cancel Stale Order
|
|
219
|
+
* </button>
|
|
220
|
+
* )
|
|
221
|
+
* }
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* @param parameters - Parameters.
|
|
225
|
+
* @returns Mutation result.
|
|
226
|
+
*/
|
|
227
|
+
export function useCancelStaleSync(parameters = {}) {
|
|
228
|
+
const { mutation } = parameters;
|
|
229
|
+
const config = useConfig(parameters);
|
|
230
|
+
return useMutation({
|
|
231
|
+
...mutation,
|
|
232
|
+
async mutationFn(variables) {
|
|
233
|
+
return Actions.dex.cancelStaleSync(config, variables);
|
|
234
|
+
},
|
|
235
|
+
mutationKey: ['cancelStaleSync'],
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Hook for creating a new trading pair on the DEX.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```tsx
|
|
243
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
244
|
+
*
|
|
245
|
+
* function App() {
|
|
246
|
+
* const { mutate, isPending } = Hooks.dex.useCreatePair()
|
|
247
|
+
*
|
|
248
|
+
* return (
|
|
249
|
+
* <button
|
|
250
|
+
* onClick={() => mutate({ base: '0x20c...11' })}
|
|
251
|
+
* disabled={isPending}
|
|
252
|
+
* >
|
|
253
|
+
* Create Pair
|
|
254
|
+
* </button>
|
|
255
|
+
* )
|
|
256
|
+
* }
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
259
|
+
* @param parameters - Parameters.
|
|
260
|
+
* @returns Mutation result.
|
|
261
|
+
*/
|
|
262
|
+
export function useCreatePair(parameters = {}) {
|
|
263
|
+
const { mutation } = parameters;
|
|
264
|
+
const config = useConfig(parameters);
|
|
265
|
+
return useMutation({
|
|
266
|
+
...mutation,
|
|
267
|
+
async mutationFn(variables) {
|
|
268
|
+
return Actions.dex.createPair(config, variables);
|
|
269
|
+
},
|
|
270
|
+
mutationKey: ['createPair'],
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Hook for creating a new trading pair on the DEX.
|
|
275
|
+
*
|
|
276
|
+
* Note: This is a synchronous hook that waits for the transaction
|
|
277
|
+
* to be included on a block before returning a response.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```tsx
|
|
281
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
282
|
+
*
|
|
283
|
+
* function App() {
|
|
284
|
+
* const { mutate, isPending } = Hooks.dex.useCreatePairSync()
|
|
285
|
+
*
|
|
286
|
+
* return (
|
|
287
|
+
* <button
|
|
288
|
+
* onClick={() => mutate({ base: '0x20c...11' })}
|
|
289
|
+
* disabled={isPending}
|
|
290
|
+
* >
|
|
291
|
+
* Create Pair
|
|
292
|
+
* </button>
|
|
293
|
+
* )
|
|
294
|
+
* }
|
|
295
|
+
* ```
|
|
296
|
+
*
|
|
297
|
+
* @param parameters - Parameters.
|
|
298
|
+
* @returns Mutation result.
|
|
299
|
+
*/
|
|
300
|
+
export function useCreatePairSync(parameters = {}) {
|
|
301
|
+
const { mutation } = parameters;
|
|
302
|
+
const config = useConfig(parameters);
|
|
303
|
+
return useMutation({
|
|
304
|
+
...mutation,
|
|
305
|
+
async mutationFn(variables) {
|
|
306
|
+
return Actions.dex.createPairSync(config, variables);
|
|
307
|
+
},
|
|
308
|
+
mutationKey: ['createPairSync'],
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Hook for getting a user's token balance on the DEX.
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* ```tsx
|
|
316
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
317
|
+
*
|
|
318
|
+
* function App() {
|
|
319
|
+
* const { data, isLoading } = Hooks.dex.useBalance({
|
|
320
|
+
* account: '0x...',
|
|
321
|
+
* token: '0x20c...11',
|
|
322
|
+
* })
|
|
323
|
+
*
|
|
324
|
+
* if (isLoading) return <div>Loading...</div>
|
|
325
|
+
* return <div>Balance: {data}</div>
|
|
326
|
+
* }
|
|
327
|
+
* ```
|
|
328
|
+
*
|
|
329
|
+
* @param parameters - Parameters.
|
|
330
|
+
* @returns Query result with the user's token balance on the DEX.
|
|
331
|
+
*/
|
|
332
|
+
export function useBalance(parameters) {
|
|
333
|
+
const config = useConfig(parameters);
|
|
334
|
+
const chainId = useChainId({ config });
|
|
335
|
+
const options = Actions.dex.getBalance.queryOptions(config, {
|
|
336
|
+
...parameters,
|
|
337
|
+
chainId: parameters.chainId ?? chainId,
|
|
338
|
+
});
|
|
339
|
+
return useQuery(options);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Hook for getting the quote for buying a specific amount of tokens.
|
|
343
|
+
*
|
|
344
|
+
* @example
|
|
345
|
+
* ```tsx
|
|
346
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
347
|
+
*
|
|
348
|
+
* function App() {
|
|
349
|
+
* const { data, isLoading } = Hooks.dex.useBuyQuote({
|
|
350
|
+
* amountOut: parseUnits('100', 6),
|
|
351
|
+
* tokenIn: '0x20c...11',
|
|
352
|
+
* tokenOut: '0x20c...20',
|
|
353
|
+
* })
|
|
354
|
+
*
|
|
355
|
+
* if (isLoading) return <div>Loading...</div>
|
|
356
|
+
* return <div>Required Input: {data}</div>
|
|
357
|
+
* }
|
|
358
|
+
* ```
|
|
359
|
+
*
|
|
360
|
+
* @param parameters - Parameters.
|
|
361
|
+
* @returns Query result with the amount of tokenIn needed.
|
|
362
|
+
*/
|
|
363
|
+
export function useBuyQuote(parameters) {
|
|
364
|
+
const config = useConfig(parameters);
|
|
365
|
+
const chainId = useChainId({ config });
|
|
366
|
+
const options = Actions.dex.getBuyQuote.queryOptions(config, {
|
|
367
|
+
...parameters,
|
|
368
|
+
chainId: parameters.chainId ?? chainId,
|
|
369
|
+
});
|
|
370
|
+
return useQuery(options);
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Hook for getting an order's details from the orderbook.
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```tsx
|
|
377
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
378
|
+
*
|
|
379
|
+
* function App() {
|
|
380
|
+
* const { data, isLoading } = Hooks.dex.useOrder({
|
|
381
|
+
* orderId: 123n,
|
|
382
|
+
* })
|
|
383
|
+
*
|
|
384
|
+
* if (isLoading) return <div>Loading...</div>
|
|
385
|
+
* return <div>Order: {JSON.stringify(data)}</div>
|
|
386
|
+
* }
|
|
387
|
+
* ```
|
|
388
|
+
*
|
|
389
|
+
* @param parameters - Parameters.
|
|
390
|
+
* @returns Query result with the order details.
|
|
391
|
+
*/
|
|
392
|
+
export function useOrder(parameters) {
|
|
393
|
+
const config = useConfig(parameters);
|
|
394
|
+
const chainId = useChainId({ config });
|
|
395
|
+
const options = Actions.dex.getOrder.queryOptions(config, {
|
|
396
|
+
...parameters,
|
|
397
|
+
chainId: parameters.chainId ?? chainId,
|
|
398
|
+
});
|
|
399
|
+
return useQuery(options);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Hook for getting orderbook information for a trading pair.
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```tsx
|
|
406
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
407
|
+
*
|
|
408
|
+
* function App() {
|
|
409
|
+
* const { data, isLoading } = Hooks.dex.useOrderbook({
|
|
410
|
+
* base: '0x20c...11',
|
|
411
|
+
* quote: '0x20c...20',
|
|
412
|
+
* })
|
|
413
|
+
*
|
|
414
|
+
* if (isLoading) return <div>Loading...</div>
|
|
415
|
+
* return <div>Orderbook: {JSON.stringify(data)}</div>
|
|
416
|
+
* }
|
|
417
|
+
* ```
|
|
418
|
+
*
|
|
419
|
+
* @param parameters - Parameters.
|
|
420
|
+
* @returns Query result with the orderbook information.
|
|
421
|
+
*/
|
|
422
|
+
export function useOrderbook(parameters) {
|
|
423
|
+
const config = useConfig(parameters);
|
|
424
|
+
const chainId = useChainId({ config });
|
|
425
|
+
const options = Actions.dex.getOrderbook.queryOptions(config, {
|
|
426
|
+
...parameters,
|
|
427
|
+
chainId: parameters.chainId ?? chainId,
|
|
428
|
+
});
|
|
429
|
+
return useQuery(options);
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Hook for getting the tick level information at a specific tick.
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
* ```tsx
|
|
436
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
437
|
+
* import { Tick } from 'viem/tempo'
|
|
438
|
+
*
|
|
439
|
+
* function App() {
|
|
440
|
+
* const { data, isLoading } = Hooks.dex.useTickLevel({
|
|
441
|
+
* base: '0x20c...11',
|
|
442
|
+
* tick: Tick.fromPrice('1.001'),
|
|
443
|
+
* isBid: true,
|
|
444
|
+
* })
|
|
445
|
+
*
|
|
446
|
+
* if (isLoading) return <div>Loading...</div>
|
|
447
|
+
* return <div>Tick Level: {JSON.stringify(data)}</div>
|
|
448
|
+
* }
|
|
449
|
+
* ```
|
|
450
|
+
*
|
|
451
|
+
* @param parameters - Parameters.
|
|
452
|
+
* @returns Query result with the tick level information.
|
|
453
|
+
*/
|
|
454
|
+
export function useTickLevel(parameters) {
|
|
455
|
+
const config = useConfig(parameters);
|
|
456
|
+
const chainId = useChainId({ config });
|
|
457
|
+
const options = Actions.dex.getTickLevel.queryOptions(config, {
|
|
458
|
+
...parameters,
|
|
459
|
+
chainId: parameters.chainId ?? chainId,
|
|
460
|
+
});
|
|
461
|
+
return useQuery(options);
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Hook for getting the quote for selling a specific amount of tokens.
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
* ```tsx
|
|
468
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
469
|
+
*
|
|
470
|
+
* function App() {
|
|
471
|
+
* const { data, isLoading } = Hooks.dex.useSellQuote({
|
|
472
|
+
* amountIn: parseUnits('100', 6),
|
|
473
|
+
* tokenIn: '0x20c...11',
|
|
474
|
+
* tokenOut: '0x20c...20',
|
|
475
|
+
* })
|
|
476
|
+
*
|
|
477
|
+
* if (isLoading) return <div>Loading...</div>
|
|
478
|
+
* return <div>Expected Output: {data}</div>
|
|
479
|
+
* }
|
|
480
|
+
* ```
|
|
481
|
+
*
|
|
482
|
+
* @param parameters - Parameters.
|
|
483
|
+
* @returns Query result with the amount of tokenOut received.
|
|
484
|
+
*/
|
|
485
|
+
export function useSellQuote(parameters) {
|
|
486
|
+
const config = useConfig(parameters);
|
|
487
|
+
const chainId = useChainId({ config });
|
|
488
|
+
const options = Actions.dex.getSellQuote.queryOptions(config, {
|
|
489
|
+
...parameters,
|
|
490
|
+
chainId: parameters.chainId ?? chainId,
|
|
491
|
+
});
|
|
492
|
+
return useQuery(options);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Hook for placing a limit order on the orderbook.
|
|
496
|
+
*
|
|
497
|
+
* @example
|
|
498
|
+
* ```tsx
|
|
499
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
500
|
+
*
|
|
501
|
+
* function App() {
|
|
502
|
+
* const { mutate, isPending } = Hooks.dex.usePlace()
|
|
503
|
+
*
|
|
504
|
+
* return (
|
|
505
|
+
* <button
|
|
506
|
+
* onClick={() => mutate({
|
|
507
|
+
* amount: parseUnits('100', 6),
|
|
508
|
+
* tick: Tick.fromPrice('0.99'),
|
|
509
|
+
* token: '0x20c...11',
|
|
510
|
+
* type: 'buy',
|
|
511
|
+
* })}
|
|
512
|
+
* disabled={isPending}
|
|
513
|
+
* >
|
|
514
|
+
* Place Order
|
|
515
|
+
* </button>
|
|
516
|
+
* )
|
|
517
|
+
* }
|
|
518
|
+
* ```
|
|
519
|
+
*
|
|
520
|
+
* @param parameters - Parameters.
|
|
521
|
+
* @returns Mutation result.
|
|
522
|
+
*/
|
|
523
|
+
export function usePlace(parameters = {}) {
|
|
524
|
+
const { mutation } = parameters;
|
|
525
|
+
const config = useConfig(parameters);
|
|
526
|
+
return useMutation({
|
|
527
|
+
...mutation,
|
|
528
|
+
async mutationFn(variables) {
|
|
529
|
+
return Actions.dex.place(config, variables);
|
|
530
|
+
},
|
|
531
|
+
mutationKey: ['place'],
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Hook for placing a flip order that automatically flips when filled.
|
|
536
|
+
*
|
|
537
|
+
* @example
|
|
538
|
+
* ```tsx
|
|
539
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
540
|
+
*
|
|
541
|
+
* function App() {
|
|
542
|
+
* const { mutate, isPending } = Hooks.dex.usePlaceFlip()
|
|
543
|
+
*
|
|
544
|
+
* return (
|
|
545
|
+
* <button
|
|
546
|
+
* onClick={() => mutate({
|
|
547
|
+
* amount: parseUnits('100', 6),
|
|
548
|
+
* flipTick: Tick.fromPrice('1.01'),
|
|
549
|
+
* tick: Tick.fromPrice('0.99'),
|
|
550
|
+
* token: '0x20c...11',
|
|
551
|
+
* type: 'buy',
|
|
552
|
+
* })}
|
|
553
|
+
* disabled={isPending}
|
|
554
|
+
* >
|
|
555
|
+
* Place Flip Order
|
|
556
|
+
* </button>
|
|
557
|
+
* )
|
|
558
|
+
* }
|
|
559
|
+
* ```
|
|
560
|
+
*
|
|
561
|
+
* @param parameters - Parameters.
|
|
562
|
+
* @returns Mutation result.
|
|
563
|
+
*/
|
|
564
|
+
export function usePlaceFlip(parameters = {}) {
|
|
565
|
+
const { mutation } = parameters;
|
|
566
|
+
const config = useConfig(parameters);
|
|
567
|
+
return useMutation({
|
|
568
|
+
...mutation,
|
|
569
|
+
async mutationFn(variables) {
|
|
570
|
+
return Actions.dex.placeFlip(config, variables);
|
|
571
|
+
},
|
|
572
|
+
mutationKey: ['placeFlip'],
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Hook for placing a flip order that automatically flips when filled.
|
|
577
|
+
*
|
|
578
|
+
* Note: This is a synchronous hook that waits for the transaction
|
|
579
|
+
* to be included on a block before returning a response.
|
|
580
|
+
*
|
|
581
|
+
* @example
|
|
582
|
+
* ```tsx
|
|
583
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
584
|
+
*
|
|
585
|
+
* function App() {
|
|
586
|
+
* const { mutate, isPending } = Hooks.dex.usePlaceFlipSync()
|
|
587
|
+
*
|
|
588
|
+
* return (
|
|
589
|
+
* <button
|
|
590
|
+
* onClick={() => mutate({
|
|
591
|
+
* amount: parseUnits('100', 6),
|
|
592
|
+
* flipTick: Tick.fromPrice('1.01'),
|
|
593
|
+
* tick: Tick.fromPrice('0.99'),
|
|
594
|
+
* token: '0x20c...11',
|
|
595
|
+
* type: 'buy',
|
|
596
|
+
* })}
|
|
597
|
+
* disabled={isPending}
|
|
598
|
+
* >
|
|
599
|
+
* Place Flip Order
|
|
600
|
+
* </button>
|
|
601
|
+
* )
|
|
602
|
+
* }
|
|
603
|
+
* ```
|
|
604
|
+
*
|
|
605
|
+
* @param parameters - Parameters.
|
|
606
|
+
* @returns Mutation result.
|
|
607
|
+
*/
|
|
608
|
+
export function usePlaceFlipSync(parameters = {}) {
|
|
609
|
+
const { mutation } = parameters;
|
|
610
|
+
const config = useConfig(parameters);
|
|
611
|
+
return useMutation({
|
|
612
|
+
...mutation,
|
|
613
|
+
async mutationFn(variables) {
|
|
614
|
+
return Actions.dex.placeFlipSync(config, variables);
|
|
615
|
+
},
|
|
616
|
+
mutationKey: ['placeFlipSync'],
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Hook for placing a limit order on the orderbook.
|
|
621
|
+
*
|
|
622
|
+
* Note: This is a synchronous hook that waits for the transaction
|
|
623
|
+
* to be included on a block before returning a response.
|
|
624
|
+
*
|
|
625
|
+
* @example
|
|
626
|
+
* ```tsx
|
|
627
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
628
|
+
*
|
|
629
|
+
* function App() {
|
|
630
|
+
* const { mutate, isPending } = Hooks.dex.usePlaceSync()
|
|
631
|
+
*
|
|
632
|
+
* return (
|
|
633
|
+
* <button
|
|
634
|
+
* onClick={() => mutate({
|
|
635
|
+
* amount: parseUnits('100', 6),
|
|
636
|
+
* tick: Tick.fromPrice('0.99'),
|
|
637
|
+
* token: '0x20c...11',
|
|
638
|
+
* type: 'buy',
|
|
639
|
+
* })}
|
|
640
|
+
* disabled={isPending}
|
|
641
|
+
* >
|
|
642
|
+
* Place Order
|
|
643
|
+
* </button>
|
|
644
|
+
* )
|
|
645
|
+
* }
|
|
646
|
+
* ```
|
|
647
|
+
*
|
|
648
|
+
* @param parameters - Parameters.
|
|
649
|
+
* @returns Mutation result.
|
|
650
|
+
*/
|
|
651
|
+
export function usePlaceSync(parameters = {}) {
|
|
652
|
+
const { mutation } = parameters;
|
|
653
|
+
const config = useConfig(parameters);
|
|
654
|
+
return useMutation({
|
|
655
|
+
...mutation,
|
|
656
|
+
async mutationFn(variables) {
|
|
657
|
+
return Actions.dex.placeSync(config, variables);
|
|
658
|
+
},
|
|
659
|
+
mutationKey: ['placeSync'],
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Hook for selling a specific amount of tokens.
|
|
664
|
+
*
|
|
665
|
+
* @example
|
|
666
|
+
* ```tsx
|
|
667
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
668
|
+
*
|
|
669
|
+
* function App() {
|
|
670
|
+
* const { mutate, isPending } = Hooks.dex.useSell()
|
|
671
|
+
*
|
|
672
|
+
* return (
|
|
673
|
+
* <button
|
|
674
|
+
* onClick={() => mutate({
|
|
675
|
+
* amountIn: parseUnits('100', 6),
|
|
676
|
+
* minAmountOut: parseUnits('95', 6),
|
|
677
|
+
* tokenIn: '0x20c...11',
|
|
678
|
+
* tokenOut: '0x20c...20',
|
|
679
|
+
* })}
|
|
680
|
+
* disabled={isPending}
|
|
681
|
+
* >
|
|
682
|
+
* Sell Tokens
|
|
683
|
+
* </button>
|
|
684
|
+
* )
|
|
685
|
+
* }
|
|
686
|
+
* ```
|
|
687
|
+
*
|
|
688
|
+
* @param parameters - Parameters.
|
|
689
|
+
* @returns Mutation result.
|
|
690
|
+
*/
|
|
691
|
+
export function useSell(parameters = {}) {
|
|
692
|
+
const { mutation } = parameters;
|
|
693
|
+
const config = useConfig(parameters);
|
|
694
|
+
return useMutation({
|
|
695
|
+
...mutation,
|
|
696
|
+
async mutationFn(variables) {
|
|
697
|
+
return Actions.dex.sell(config, variables);
|
|
698
|
+
},
|
|
699
|
+
mutationKey: ['sell'],
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Hook for selling a specific amount of tokens.
|
|
704
|
+
*
|
|
705
|
+
* Note: This is a synchronous hook that waits for the transaction
|
|
706
|
+
* to be included on a block before returning a response.
|
|
707
|
+
*
|
|
708
|
+
* @example
|
|
709
|
+
* ```tsx
|
|
710
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
711
|
+
*
|
|
712
|
+
* function App() {
|
|
713
|
+
* const { mutate, isPending } = Hooks.dex.useSellSync()
|
|
714
|
+
*
|
|
715
|
+
* return (
|
|
716
|
+
* <button
|
|
717
|
+
* onClick={() => mutate({
|
|
718
|
+
* amountIn: parseUnits('100', 6),
|
|
719
|
+
* minAmountOut: parseUnits('95', 6),
|
|
720
|
+
* tokenIn: '0x20c...11',
|
|
721
|
+
* tokenOut: '0x20c...20',
|
|
722
|
+
* })}
|
|
723
|
+
* disabled={isPending}
|
|
724
|
+
* >
|
|
725
|
+
* Sell Tokens
|
|
726
|
+
* </button>
|
|
727
|
+
* )
|
|
728
|
+
* }
|
|
729
|
+
* ```
|
|
730
|
+
*
|
|
731
|
+
* @param parameters - Parameters.
|
|
732
|
+
* @returns Mutation result.
|
|
733
|
+
*/
|
|
734
|
+
export function useSellSync(parameters = {}) {
|
|
735
|
+
const { mutation } = parameters;
|
|
736
|
+
const config = useConfig(parameters);
|
|
737
|
+
return useMutation({
|
|
738
|
+
...mutation,
|
|
739
|
+
async mutationFn(variables) {
|
|
740
|
+
return Actions.dex.sellSync(config, variables);
|
|
741
|
+
},
|
|
742
|
+
mutationKey: ['sellSync'],
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Hook for withdrawing tokens from the DEX to the caller's wallet.
|
|
747
|
+
*
|
|
748
|
+
* @example
|
|
749
|
+
* ```tsx
|
|
750
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
751
|
+
*
|
|
752
|
+
* function App() {
|
|
753
|
+
* const { mutate, isPending } = Hooks.dex.useWithdraw()
|
|
754
|
+
*
|
|
755
|
+
* return (
|
|
756
|
+
* <button
|
|
757
|
+
* onClick={() => mutate({
|
|
758
|
+
* amount: 100n,
|
|
759
|
+
* token: '0x20c...11',
|
|
760
|
+
* })}
|
|
761
|
+
* disabled={isPending}
|
|
762
|
+
* >
|
|
763
|
+
* Withdraw
|
|
764
|
+
* </button>
|
|
765
|
+
* )
|
|
766
|
+
* }
|
|
767
|
+
* ```
|
|
768
|
+
*
|
|
769
|
+
* @param parameters - Parameters.
|
|
770
|
+
* @returns Mutation result.
|
|
771
|
+
*/
|
|
772
|
+
export function useWithdraw(parameters = {}) {
|
|
773
|
+
const { mutation } = parameters;
|
|
774
|
+
const config = useConfig(parameters);
|
|
775
|
+
return useMutation({
|
|
776
|
+
...mutation,
|
|
777
|
+
async mutationFn(variables) {
|
|
778
|
+
return Actions.dex.withdraw(config, variables);
|
|
779
|
+
},
|
|
780
|
+
mutationKey: ['withdraw'],
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Hook for withdrawing tokens from the DEX to the caller's wallet.
|
|
785
|
+
*
|
|
786
|
+
* Note: This is a synchronous hook that waits for the transaction
|
|
787
|
+
* to be included on a block before returning a response.
|
|
788
|
+
*
|
|
789
|
+
* @example
|
|
790
|
+
* ```tsx
|
|
791
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
792
|
+
*
|
|
793
|
+
* function App() {
|
|
794
|
+
* const { mutate, isPending } = Hooks.dex.useWithdrawSync()
|
|
795
|
+
*
|
|
796
|
+
* return (
|
|
797
|
+
* <button
|
|
798
|
+
* onClick={() => mutate({
|
|
799
|
+
* amount: 100n,
|
|
800
|
+
* token: '0x20c...11',
|
|
801
|
+
* })}
|
|
802
|
+
* disabled={isPending}
|
|
803
|
+
* >
|
|
804
|
+
* Withdraw
|
|
805
|
+
* </button>
|
|
806
|
+
* )
|
|
807
|
+
* }
|
|
808
|
+
* ```
|
|
809
|
+
*
|
|
810
|
+
* @param parameters - Parameters.
|
|
811
|
+
* @returns Mutation result.
|
|
812
|
+
*/
|
|
813
|
+
export function useWithdrawSync(parameters = {}) {
|
|
814
|
+
const { mutation } = parameters;
|
|
815
|
+
const config = useConfig(parameters);
|
|
816
|
+
return useMutation({
|
|
817
|
+
...mutation,
|
|
818
|
+
async mutationFn(variables) {
|
|
819
|
+
return Actions.dex.withdrawSync(config, variables);
|
|
820
|
+
},
|
|
821
|
+
mutationKey: ['withdrawSync'],
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Hook for watching flip order placement events on the DEX.
|
|
826
|
+
*
|
|
827
|
+
* @example
|
|
828
|
+
* ```tsx
|
|
829
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
830
|
+
*
|
|
831
|
+
* function App() {
|
|
832
|
+
* Hooks.dex.useWatchFlipOrderPlaced({
|
|
833
|
+
* onFlipOrderPlaced(args) {
|
|
834
|
+
* console.log('Flip order placed:', args)
|
|
835
|
+
* },
|
|
836
|
+
* })
|
|
837
|
+
*
|
|
838
|
+
* return <div>Watching for flip order placements...</div>
|
|
839
|
+
* }
|
|
840
|
+
* ```
|
|
841
|
+
*
|
|
842
|
+
* @param parameters - Parameters.
|
|
843
|
+
*/
|
|
844
|
+
export function useWatchFlipOrderPlaced(parameters = {}) {
|
|
845
|
+
const { enabled = true, onFlipOrderPlaced, ...rest } = parameters;
|
|
846
|
+
const config = useConfig({ config: parameters.config });
|
|
847
|
+
const configChainId = useChainId({ config });
|
|
848
|
+
const chainId = parameters.chainId ?? configChainId;
|
|
849
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
|
|
850
|
+
useEffect(() => {
|
|
851
|
+
if (!enabled)
|
|
852
|
+
return;
|
|
853
|
+
if (!onFlipOrderPlaced)
|
|
854
|
+
return;
|
|
855
|
+
return Actions.dex.watchFlipOrderPlaced(config, {
|
|
856
|
+
...rest,
|
|
857
|
+
chainId,
|
|
858
|
+
onFlipOrderPlaced,
|
|
859
|
+
});
|
|
860
|
+
}, [
|
|
861
|
+
config,
|
|
862
|
+
enabled,
|
|
863
|
+
chainId,
|
|
864
|
+
onFlipOrderPlaced,
|
|
865
|
+
rest.fromBlock,
|
|
866
|
+
rest.maker,
|
|
867
|
+
rest.onError,
|
|
868
|
+
rest.poll,
|
|
869
|
+
rest.pollingInterval,
|
|
870
|
+
rest.token,
|
|
871
|
+
]);
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Hook for watching order cancellation events on the DEX.
|
|
875
|
+
*
|
|
876
|
+
* @example
|
|
877
|
+
* ```tsx
|
|
878
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
879
|
+
*
|
|
880
|
+
* function App() {
|
|
881
|
+
* Hooks.dex.useWatchOrderCancelled({
|
|
882
|
+
* onOrderCancelled(args) {
|
|
883
|
+
* console.log('Order cancelled:', args)
|
|
884
|
+
* },
|
|
885
|
+
* })
|
|
886
|
+
*
|
|
887
|
+
* return <div>Watching for order cancellations...</div>
|
|
888
|
+
* }
|
|
889
|
+
* ```
|
|
890
|
+
*
|
|
891
|
+
* @param parameters - Parameters.
|
|
892
|
+
*/
|
|
893
|
+
export function useWatchOrderCancelled(parameters = {}) {
|
|
894
|
+
const { enabled = true, onOrderCancelled, ...rest } = parameters;
|
|
895
|
+
const config = useConfig({ config: parameters.config });
|
|
896
|
+
const configChainId = useChainId({ config });
|
|
897
|
+
const chainId = parameters.chainId ?? configChainId;
|
|
898
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
|
|
899
|
+
useEffect(() => {
|
|
900
|
+
if (!enabled)
|
|
901
|
+
return;
|
|
902
|
+
if (!onOrderCancelled)
|
|
903
|
+
return;
|
|
904
|
+
return Actions.dex.watchOrderCancelled(config, {
|
|
905
|
+
...rest,
|
|
906
|
+
chainId,
|
|
907
|
+
onOrderCancelled,
|
|
908
|
+
});
|
|
909
|
+
}, [
|
|
910
|
+
config,
|
|
911
|
+
enabled,
|
|
912
|
+
chainId,
|
|
913
|
+
onOrderCancelled,
|
|
914
|
+
rest.fromBlock,
|
|
915
|
+
rest.onError,
|
|
916
|
+
rest.orderId,
|
|
917
|
+
rest.poll,
|
|
918
|
+
rest.pollingInterval,
|
|
919
|
+
]);
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Hook for watching order filled events on the DEX.
|
|
923
|
+
*
|
|
924
|
+
* @example
|
|
925
|
+
* ```tsx
|
|
926
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
927
|
+
*
|
|
928
|
+
* function App() {
|
|
929
|
+
* Hooks.dex.useWatchOrderFilled({
|
|
930
|
+
* onOrderFilled(args) {
|
|
931
|
+
* console.log('Order filled:', args)
|
|
932
|
+
* },
|
|
933
|
+
* })
|
|
934
|
+
*
|
|
935
|
+
* return <div>Watching for order fills...</div>
|
|
936
|
+
* }
|
|
937
|
+
* ```
|
|
938
|
+
*
|
|
939
|
+
* @param parameters - Parameters.
|
|
940
|
+
*/
|
|
941
|
+
export function useWatchOrderFilled(parameters = {}) {
|
|
942
|
+
const { enabled = true, onOrderFilled, ...rest } = parameters;
|
|
943
|
+
const config = useConfig({ config: parameters.config });
|
|
944
|
+
const configChainId = useChainId({ config });
|
|
945
|
+
const chainId = parameters.chainId ?? configChainId;
|
|
946
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
|
|
947
|
+
useEffect(() => {
|
|
948
|
+
if (!enabled)
|
|
949
|
+
return;
|
|
950
|
+
if (!onOrderFilled)
|
|
951
|
+
return;
|
|
952
|
+
return Actions.dex.watchOrderFilled(config, {
|
|
953
|
+
...rest,
|
|
954
|
+
chainId,
|
|
955
|
+
onOrderFilled,
|
|
956
|
+
});
|
|
957
|
+
}, [
|
|
958
|
+
config,
|
|
959
|
+
enabled,
|
|
960
|
+
chainId,
|
|
961
|
+
onOrderFilled,
|
|
962
|
+
rest.fromBlock,
|
|
963
|
+
rest.maker,
|
|
964
|
+
rest.onError,
|
|
965
|
+
rest.orderId,
|
|
966
|
+
rest.poll,
|
|
967
|
+
rest.pollingInterval,
|
|
968
|
+
rest.taker,
|
|
969
|
+
]);
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Hook for watching order placement events on the DEX.
|
|
973
|
+
*
|
|
974
|
+
* @example
|
|
975
|
+
* ```tsx
|
|
976
|
+
* import { Hooks } from 'wagmi/tempo'
|
|
977
|
+
*
|
|
978
|
+
* function App() {
|
|
979
|
+
* Hooks.dex.useWatchOrderPlaced({
|
|
980
|
+
* onOrderPlaced(args) {
|
|
981
|
+
* console.log('Order placed:', args)
|
|
982
|
+
* },
|
|
983
|
+
* })
|
|
984
|
+
*
|
|
985
|
+
* return <div>Watching for order placements...</div>
|
|
986
|
+
* }
|
|
987
|
+
* ```
|
|
988
|
+
*
|
|
989
|
+
* @param parameters - Parameters.
|
|
990
|
+
*/
|
|
991
|
+
export function useWatchOrderPlaced(parameters = {}) {
|
|
992
|
+
const { enabled = true, onOrderPlaced, ...rest } = parameters;
|
|
993
|
+
const config = useConfig({ config: parameters.config });
|
|
994
|
+
const configChainId = useChainId({ config });
|
|
995
|
+
const chainId = parameters.chainId ?? configChainId;
|
|
996
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
|
|
997
|
+
useEffect(() => {
|
|
998
|
+
if (!enabled)
|
|
999
|
+
return;
|
|
1000
|
+
if (!onOrderPlaced)
|
|
1001
|
+
return;
|
|
1002
|
+
return Actions.dex.watchOrderPlaced(config, {
|
|
1003
|
+
...rest,
|
|
1004
|
+
chainId,
|
|
1005
|
+
onOrderPlaced,
|
|
1006
|
+
});
|
|
1007
|
+
}, [
|
|
1008
|
+
config,
|
|
1009
|
+
enabled,
|
|
1010
|
+
chainId,
|
|
1011
|
+
onOrderPlaced,
|
|
1012
|
+
rest.fromBlock,
|
|
1013
|
+
rest.maker,
|
|
1014
|
+
rest.onError,
|
|
1015
|
+
rest.poll,
|
|
1016
|
+
rest.pollingInterval,
|
|
1017
|
+
rest.token,
|
|
1018
|
+
]);
|
|
1019
|
+
}
|
|
1020
|
+
//# sourceMappingURL=dex.js.map
|