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.
Files changed (56) hide show
  1. package/dist/esm/exports/tempo.js +9 -0
  2. package/dist/esm/exports/tempo.js.map +1 -0
  3. package/dist/esm/tempo/hooks/amm.js +485 -0
  4. package/dist/esm/tempo/hooks/amm.js.map +1 -0
  5. package/dist/esm/tempo/hooks/dex.js +1020 -0
  6. package/dist/esm/tempo/hooks/dex.js.map +1 -0
  7. package/dist/esm/tempo/hooks/faucet.js +76 -0
  8. package/dist/esm/tempo/hooks/faucet.js.map +1 -0
  9. package/dist/esm/tempo/hooks/fee.js +155 -0
  10. package/dist/esm/tempo/hooks/fee.js.map +1 -0
  11. package/dist/esm/tempo/hooks/index.js +11 -0
  12. package/dist/esm/tempo/hooks/index.js.map +1 -0
  13. package/dist/esm/tempo/hooks/nonce.js +85 -0
  14. package/dist/esm/tempo/hooks/nonce.js.map +1 -0
  15. package/dist/esm/tempo/hooks/policy.js +545 -0
  16. package/dist/esm/tempo/hooks/policy.js.map +1 -0
  17. package/dist/esm/tempo/hooks/reward.js +385 -0
  18. package/dist/esm/tempo/hooks/reward.js.map +1 -0
  19. package/dist/esm/tempo/hooks/token.js +1730 -0
  20. package/dist/esm/tempo/hooks/token.js.map +1 -0
  21. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  22. package/dist/esm/version.js +1 -1
  23. package/dist/types/exports/tempo.d.ts +4 -0
  24. package/dist/types/exports/tempo.d.ts.map +1 -0
  25. package/dist/types/tempo/hooks/amm.d.ts +384 -0
  26. package/dist/types/tempo/hooks/amm.d.ts.map +1 -0
  27. package/dist/types/tempo/hooks/dex.d.ts +841 -0
  28. package/dist/types/tempo/hooks/dex.d.ts.map +1 -0
  29. package/dist/types/tempo/hooks/faucet.d.ts +70 -0
  30. package/dist/types/tempo/hooks/faucet.d.ts.map +1 -0
  31. package/dist/types/tempo/hooks/fee.d.ts +123 -0
  32. package/dist/types/tempo/hooks/fee.d.ts.map +1 -0
  33. package/dist/types/tempo/hooks/index.d.ts +10 -0
  34. package/dist/types/tempo/hooks/index.d.ts.map +1 -0
  35. package/dist/types/tempo/hooks/nonce.d.ts +60 -0
  36. package/dist/types/tempo/hooks/nonce.d.ts.map +1 -0
  37. package/dist/types/tempo/hooks/policy.d.ts +422 -0
  38. package/dist/types/tempo/hooks/policy.d.ts.map +1 -0
  39. package/dist/types/tempo/hooks/reward.d.ts +304 -0
  40. package/dist/types/tempo/hooks/reward.d.ts.map +1 -0
  41. package/dist/types/tempo/hooks/token.d.ts +1387 -0
  42. package/dist/types/tempo/hooks/token.d.ts.map +1 -0
  43. package/dist/types/version.d.ts +1 -1
  44. package/package.json +12 -4
  45. package/src/exports/tempo.ts +17 -0
  46. package/src/tempo/hooks/amm.ts +776 -0
  47. package/src/tempo/hooks/dex.ts +1737 -0
  48. package/src/tempo/hooks/faucet.ts +142 -0
  49. package/src/tempo/hooks/fee.ts +264 -0
  50. package/src/tempo/hooks/index.ts +10 -0
  51. package/src/tempo/hooks/nonce.ts +126 -0
  52. package/src/tempo/hooks/policy.ts +907 -0
  53. package/src/tempo/hooks/reward.ts +668 -0
  54. package/src/tempo/hooks/token.ts +2979 -0
  55. package/src/version.ts +1 -1
  56. package/tempo/package.json +5 -0
@@ -0,0 +1,1737 @@
1
+ import type { UseMutationResult } from '@tanstack/react-query'
2
+ import type { Config, ResolvedRegister } from '@wagmi/core'
3
+ import type { ExactPartial, UnionCompute } from '@wagmi/core/internal'
4
+ import { Actions } from '@wagmi/core/tempo'
5
+ import { useEffect } from 'react'
6
+
7
+ import { useChainId } from '../../hooks/useChainId.js'
8
+ import { useConfig } from '../../hooks/useConfig.js'
9
+ import type { ConfigParameter, QueryParameter } from '../../types/properties.js'
10
+ import {
11
+ type UseMutationParameters,
12
+ type UseQueryReturnType,
13
+ useMutation,
14
+ useQuery,
15
+ } from '../../utils/query.js'
16
+
17
+ /**
18
+ * Hook for buying a specific amount of tokens.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * import { Hooks } from 'wagmi/tempo'
23
+ *
24
+ * function App() {
25
+ * const { mutate, isPending } = Hooks.dex.useBuy()
26
+ *
27
+ * return (
28
+ * <button
29
+ * onClick={() => mutate({
30
+ * tokenIn: '0x20c...11',
31
+ * tokenOut: '0x20c...20',
32
+ * amountOut: parseUnits('100', 6),
33
+ * maxAmountIn: parseUnits('105', 6),
34
+ * })}
35
+ * disabled={isPending}
36
+ * >
37
+ * Buy Tokens
38
+ * </button>
39
+ * )
40
+ * }
41
+ * ```
42
+ *
43
+ * @param parameters - Parameters.
44
+ * @returns Mutation result.
45
+ */
46
+ export function useBuy<
47
+ config extends Config = ResolvedRegister['config'],
48
+ context = unknown,
49
+ >(
50
+ parameters: useBuy.Parameters<config, context> = {},
51
+ ): useBuy.ReturnType<config, context> {
52
+ const { mutation } = parameters
53
+ const config = useConfig(parameters)
54
+ return useMutation({
55
+ ...mutation,
56
+ async mutationFn(variables) {
57
+ return Actions.dex.buy(config, variables as never)
58
+ },
59
+ mutationKey: ['buy'],
60
+ }) as never
61
+ }
62
+
63
+ export declare namespace useBuy {
64
+ type Parameters<
65
+ config extends Config = Config,
66
+ context = unknown,
67
+ > = ConfigParameter<config> & {
68
+ mutation?:
69
+ | UseMutationParameters<
70
+ Actions.dex.buy.ReturnValue,
71
+ Actions.dex.buy.ErrorType,
72
+ Actions.dex.buy.Parameters<config>,
73
+ context
74
+ >
75
+ | undefined
76
+ }
77
+
78
+ type ReturnType<
79
+ config extends Config = Config,
80
+ context = unknown,
81
+ > = UseMutationResult<
82
+ Actions.dex.buy.ReturnValue,
83
+ Actions.dex.buy.ErrorType,
84
+ Actions.dex.buy.Parameters<config>,
85
+ context
86
+ >
87
+ }
88
+
89
+ /**
90
+ * Hook for buying a specific amount of tokens.
91
+ *
92
+ * Note: This is a synchronous hook that waits for the transaction
93
+ * to be included on a block before returning a response.
94
+ *
95
+ * @example
96
+ * ```tsx
97
+ * import { Hooks } from 'wagmi/tempo'
98
+ *
99
+ * function App() {
100
+ * const { mutate, isPending } = Hooks.dex.useBuySync()
101
+ *
102
+ * return (
103
+ * <button
104
+ * onClick={() => mutate({
105
+ * tokenIn: '0x20c...11',
106
+ * tokenOut: '0x20c...20',
107
+ * amountOut: parseUnits('100', 6),
108
+ * maxAmountIn: parseUnits('105', 6),
109
+ * })}
110
+ * disabled={isPending}
111
+ * >
112
+ * Buy Tokens
113
+ * </button>
114
+ * )
115
+ * }
116
+ * ```
117
+ *
118
+ * @param parameters - Parameters.
119
+ * @returns Mutation result.
120
+ */
121
+ export function useBuySync<
122
+ config extends Config = ResolvedRegister['config'],
123
+ context = unknown,
124
+ >(
125
+ parameters: useBuySync.Parameters<config, context> = {},
126
+ ): useBuySync.ReturnType<config, context> {
127
+ const { mutation } = parameters
128
+ const config = useConfig(parameters)
129
+ return useMutation({
130
+ ...mutation,
131
+ async mutationFn(variables) {
132
+ return Actions.dex.buySync(config, variables as never)
133
+ },
134
+ mutationKey: ['buySync'],
135
+ }) as never
136
+ }
137
+
138
+ export declare namespace useBuySync {
139
+ type Parameters<
140
+ config extends Config = Config,
141
+ context = unknown,
142
+ > = ConfigParameter<config> & {
143
+ mutation?:
144
+ | UseMutationParameters<
145
+ Actions.dex.buySync.ReturnValue,
146
+ Actions.dex.buySync.ErrorType,
147
+ Actions.dex.buySync.Parameters<config>,
148
+ context
149
+ >
150
+ | undefined
151
+ }
152
+
153
+ type ReturnType<
154
+ config extends Config = Config,
155
+ context = unknown,
156
+ > = UseMutationResult<
157
+ Actions.dex.buySync.ReturnValue,
158
+ Actions.dex.buySync.ErrorType,
159
+ Actions.dex.buySync.Parameters<config>,
160
+ context
161
+ >
162
+ }
163
+
164
+ /**
165
+ * Hook for canceling an order from the orderbook.
166
+ *
167
+ * @example
168
+ * ```tsx
169
+ * import { Hooks } from 'wagmi/tempo'
170
+ *
171
+ * function App() {
172
+ * const { mutate, isPending } = Hooks.dex.useCancel()
173
+ *
174
+ * return (
175
+ * <button
176
+ * onClick={() => mutate({ orderId: 123n })}
177
+ * disabled={isPending}
178
+ * >
179
+ * Cancel Order
180
+ * </button>
181
+ * )
182
+ * }
183
+ * ```
184
+ *
185
+ * @param parameters - Parameters.
186
+ * @returns Mutation result.
187
+ */
188
+ export function useCancel<
189
+ config extends Config = ResolvedRegister['config'],
190
+ context = unknown,
191
+ >(
192
+ parameters: useCancel.Parameters<config, context> = {},
193
+ ): useCancel.ReturnType<config, context> {
194
+ const { mutation } = parameters
195
+ const config = useConfig(parameters)
196
+ return useMutation({
197
+ ...mutation,
198
+ async mutationFn(variables) {
199
+ return Actions.dex.cancel(config, variables as never)
200
+ },
201
+ mutationKey: ['cancel'],
202
+ }) as never
203
+ }
204
+
205
+ export declare namespace useCancel {
206
+ type Parameters<
207
+ config extends Config = Config,
208
+ context = unknown,
209
+ > = ConfigParameter<config> & {
210
+ mutation?:
211
+ | UseMutationParameters<
212
+ Actions.dex.cancel.ReturnValue,
213
+ Actions.dex.cancel.ErrorType,
214
+ Actions.dex.cancel.Parameters<config>,
215
+ context
216
+ >
217
+ | undefined
218
+ }
219
+
220
+ type ReturnType<
221
+ config extends Config = Config,
222
+ context = unknown,
223
+ > = UseMutationResult<
224
+ Actions.dex.cancel.ReturnValue,
225
+ Actions.dex.cancel.ErrorType,
226
+ Actions.dex.cancel.Parameters<config>,
227
+ context
228
+ >
229
+ }
230
+
231
+ /**
232
+ * Hook for canceling an order from the orderbook.
233
+ *
234
+ * Note: This is a synchronous hook that waits for the transaction
235
+ * to be included on a block before returning a response.
236
+ *
237
+ * @example
238
+ * ```tsx
239
+ * import { Hooks } from 'wagmi/tempo'
240
+ *
241
+ * function App() {
242
+ * const { mutate, isPending } = Hooks.dex.useCancelSync()
243
+ *
244
+ * return (
245
+ * <button
246
+ * onClick={() => mutate({ orderId: 123n })}
247
+ * disabled={isPending}
248
+ * >
249
+ * Cancel Order
250
+ * </button>
251
+ * )
252
+ * }
253
+ * ```
254
+ *
255
+ * @param parameters - Parameters.
256
+ * @returns Mutation result.
257
+ */
258
+ export function useCancelSync<
259
+ config extends Config = ResolvedRegister['config'],
260
+ context = unknown,
261
+ >(
262
+ parameters: useCancelSync.Parameters<config, context> = {},
263
+ ): useCancelSync.ReturnType<config, context> {
264
+ const { mutation } = parameters
265
+ const config = useConfig(parameters)
266
+ return useMutation({
267
+ ...mutation,
268
+ async mutationFn(variables) {
269
+ return Actions.dex.cancelSync(config, variables as never)
270
+ },
271
+ mutationKey: ['cancelSync'],
272
+ }) as never
273
+ }
274
+
275
+ export declare namespace useCancelSync {
276
+ type Parameters<
277
+ config extends Config = Config,
278
+ context = unknown,
279
+ > = ConfigParameter<config> & {
280
+ mutation?:
281
+ | UseMutationParameters<
282
+ Actions.dex.cancelSync.ReturnValue,
283
+ Actions.dex.cancelSync.ErrorType,
284
+ Actions.dex.cancelSync.Parameters<config>,
285
+ context
286
+ >
287
+ | undefined
288
+ }
289
+
290
+ type ReturnType<
291
+ config extends Config = Config,
292
+ context = unknown,
293
+ > = UseMutationResult<
294
+ Actions.dex.cancelSync.ReturnValue,
295
+ Actions.dex.cancelSync.ErrorType,
296
+ Actions.dex.cancelSync.Parameters<config>,
297
+ context
298
+ >
299
+ }
300
+
301
+ /**
302
+ * Hook for cancelling a stale order from the orderbook.
303
+ *
304
+ * A stale order is one where the owner's balance or allowance has dropped
305
+ * below the order amount.
306
+ *
307
+ * @example
308
+ * ```tsx
309
+ * import { Hooks } from 'wagmi/tempo'
310
+ *
311
+ * function App() {
312
+ * const { mutate, isPending } = Hooks.dex.useCancelStale()
313
+ *
314
+ * return (
315
+ * <button
316
+ * onClick={() => mutate({ orderId: 123n })}
317
+ * disabled={isPending}
318
+ * >
319
+ * Cancel Stale Order
320
+ * </button>
321
+ * )
322
+ * }
323
+ * ```
324
+ *
325
+ * @param parameters - Parameters.
326
+ * @returns Mutation result.
327
+ */
328
+ export function useCancelStale<
329
+ config extends Config = ResolvedRegister['config'],
330
+ context = unknown,
331
+ >(
332
+ parameters: useCancelStale.Parameters<config, context> = {},
333
+ ): useCancelStale.ReturnType<config, context> {
334
+ const { mutation } = parameters
335
+ const config = useConfig(parameters)
336
+ return useMutation({
337
+ ...mutation,
338
+ async mutationFn(variables) {
339
+ return Actions.dex.cancelStale(config, variables as never)
340
+ },
341
+ mutationKey: ['cancelStale'],
342
+ }) as never
343
+ }
344
+
345
+ export declare namespace useCancelStale {
346
+ type Parameters<
347
+ config extends Config = Config,
348
+ context = unknown,
349
+ > = ConfigParameter<config> & {
350
+ mutation?:
351
+ | UseMutationParameters<
352
+ Actions.dex.cancelStale.ReturnValue,
353
+ Actions.dex.cancelStale.ErrorType,
354
+ Actions.dex.cancelStale.Parameters<config>,
355
+ context
356
+ >
357
+ | undefined
358
+ }
359
+
360
+ type ReturnType<
361
+ config extends Config = Config,
362
+ context = unknown,
363
+ > = UseMutationResult<
364
+ Actions.dex.cancelStale.ReturnValue,
365
+ Actions.dex.cancelStale.ErrorType,
366
+ Actions.dex.cancelStale.Parameters<config>,
367
+ context
368
+ >
369
+ }
370
+
371
+ /**
372
+ * Hook for cancelling a stale order and waiting for confirmation.
373
+ *
374
+ * A stale order is one where the owner's balance or allowance has dropped
375
+ * below the order amount.
376
+ *
377
+ * @example
378
+ * ```tsx
379
+ * import { Hooks } from 'wagmi/tempo'
380
+ *
381
+ * function App() {
382
+ * const { mutate, isPending } = Hooks.dex.useCancelStaleSync()
383
+ *
384
+ * return (
385
+ * <button
386
+ * onClick={() => mutate({ orderId: 123n })}
387
+ * disabled={isPending}
388
+ * >
389
+ * Cancel Stale Order
390
+ * </button>
391
+ * )
392
+ * }
393
+ * ```
394
+ *
395
+ * @param parameters - Parameters.
396
+ * @returns Mutation result.
397
+ */
398
+ export function useCancelStaleSync<
399
+ config extends Config = ResolvedRegister['config'],
400
+ context = unknown,
401
+ >(
402
+ parameters: useCancelStaleSync.Parameters<config, context> = {},
403
+ ): useCancelStaleSync.ReturnType<config, context> {
404
+ const { mutation } = parameters
405
+ const config = useConfig(parameters)
406
+ return useMutation({
407
+ ...mutation,
408
+ async mutationFn(variables) {
409
+ return Actions.dex.cancelStaleSync(config, variables as never)
410
+ },
411
+ mutationKey: ['cancelStaleSync'],
412
+ }) as never
413
+ }
414
+
415
+ export declare namespace useCancelStaleSync {
416
+ type Parameters<
417
+ config extends Config = Config,
418
+ context = unknown,
419
+ > = ConfigParameter<config> & {
420
+ mutation?:
421
+ | UseMutationParameters<
422
+ Actions.dex.cancelStaleSync.ReturnValue,
423
+ Actions.dex.cancelStaleSync.ErrorType,
424
+ Actions.dex.cancelStaleSync.Parameters<config>,
425
+ context
426
+ >
427
+ | undefined
428
+ }
429
+
430
+ type ReturnType<
431
+ config extends Config = Config,
432
+ context = unknown,
433
+ > = UseMutationResult<
434
+ Actions.dex.cancelStaleSync.ReturnValue,
435
+ Actions.dex.cancelStaleSync.ErrorType,
436
+ Actions.dex.cancelStaleSync.Parameters<config>,
437
+ context
438
+ >
439
+ }
440
+
441
+ /**
442
+ * Hook for creating a new trading pair on the DEX.
443
+ *
444
+ * @example
445
+ * ```tsx
446
+ * import { Hooks } from 'wagmi/tempo'
447
+ *
448
+ * function App() {
449
+ * const { mutate, isPending } = Hooks.dex.useCreatePair()
450
+ *
451
+ * return (
452
+ * <button
453
+ * onClick={() => mutate({ base: '0x20c...11' })}
454
+ * disabled={isPending}
455
+ * >
456
+ * Create Pair
457
+ * </button>
458
+ * )
459
+ * }
460
+ * ```
461
+ *
462
+ * @param parameters - Parameters.
463
+ * @returns Mutation result.
464
+ */
465
+ export function useCreatePair<
466
+ config extends Config = ResolvedRegister['config'],
467
+ context = unknown,
468
+ >(
469
+ parameters: useCreatePair.Parameters<config, context> = {},
470
+ ): useCreatePair.ReturnType<config, context> {
471
+ const { mutation } = parameters
472
+ const config = useConfig(parameters)
473
+ return useMutation({
474
+ ...mutation,
475
+ async mutationFn(variables) {
476
+ return Actions.dex.createPair(config, variables as never)
477
+ },
478
+ mutationKey: ['createPair'],
479
+ }) as never
480
+ }
481
+
482
+ export declare namespace useCreatePair {
483
+ type Parameters<
484
+ config extends Config = Config,
485
+ context = unknown,
486
+ > = ConfigParameter<config> & {
487
+ mutation?:
488
+ | UseMutationParameters<
489
+ Actions.dex.createPair.ReturnValue,
490
+ Actions.dex.createPair.ErrorType,
491
+ Actions.dex.createPair.Parameters<config>,
492
+ context
493
+ >
494
+ | undefined
495
+ }
496
+
497
+ type ReturnType<
498
+ config extends Config = Config,
499
+ context = unknown,
500
+ > = UseMutationResult<
501
+ Actions.dex.createPair.ReturnValue,
502
+ Actions.dex.createPair.ErrorType,
503
+ Actions.dex.createPair.Parameters<config>,
504
+ context
505
+ >
506
+ }
507
+
508
+ /**
509
+ * Hook for creating a new trading pair on the DEX.
510
+ *
511
+ * Note: This is a synchronous hook that waits for the transaction
512
+ * to be included on a block before returning a response.
513
+ *
514
+ * @example
515
+ * ```tsx
516
+ * import { Hooks } from 'wagmi/tempo'
517
+ *
518
+ * function App() {
519
+ * const { mutate, isPending } = Hooks.dex.useCreatePairSync()
520
+ *
521
+ * return (
522
+ * <button
523
+ * onClick={() => mutate({ base: '0x20c...11' })}
524
+ * disabled={isPending}
525
+ * >
526
+ * Create Pair
527
+ * </button>
528
+ * )
529
+ * }
530
+ * ```
531
+ *
532
+ * @param parameters - Parameters.
533
+ * @returns Mutation result.
534
+ */
535
+ export function useCreatePairSync<
536
+ config extends Config = ResolvedRegister['config'],
537
+ context = unknown,
538
+ >(
539
+ parameters: useCreatePairSync.Parameters<config, context> = {},
540
+ ): useCreatePairSync.ReturnType<config, context> {
541
+ const { mutation } = parameters
542
+ const config = useConfig(parameters)
543
+ return useMutation({
544
+ ...mutation,
545
+ async mutationFn(variables) {
546
+ return Actions.dex.createPairSync(config, variables as never)
547
+ },
548
+ mutationKey: ['createPairSync'],
549
+ }) as never
550
+ }
551
+
552
+ export declare namespace useCreatePairSync {
553
+ type Parameters<
554
+ config extends Config = Config,
555
+ context = unknown,
556
+ > = ConfigParameter<config> & {
557
+ mutation?:
558
+ | UseMutationParameters<
559
+ Actions.dex.createPairSync.ReturnValue,
560
+ Actions.dex.createPairSync.ErrorType,
561
+ Actions.dex.createPairSync.Parameters<config>,
562
+ context
563
+ >
564
+ | undefined
565
+ }
566
+
567
+ type ReturnType<
568
+ config extends Config = Config,
569
+ context = unknown,
570
+ > = UseMutationResult<
571
+ Actions.dex.createPairSync.ReturnValue,
572
+ Actions.dex.createPairSync.ErrorType,
573
+ Actions.dex.createPairSync.Parameters<config>,
574
+ context
575
+ >
576
+ }
577
+
578
+ /**
579
+ * Hook for getting a user's token balance on the DEX.
580
+ *
581
+ * @example
582
+ * ```tsx
583
+ * import { Hooks } from 'wagmi/tempo'
584
+ *
585
+ * function App() {
586
+ * const { data, isLoading } = Hooks.dex.useBalance({
587
+ * account: '0x...',
588
+ * token: '0x20c...11',
589
+ * })
590
+ *
591
+ * if (isLoading) return <div>Loading...</div>
592
+ * return <div>Balance: {data}</div>
593
+ * }
594
+ * ```
595
+ *
596
+ * @param parameters - Parameters.
597
+ * @returns Query result with the user's token balance on the DEX.
598
+ */
599
+ export function useBalance<
600
+ config extends Config = ResolvedRegister['config'],
601
+ selectData = Actions.dex.getBalance.ReturnValue,
602
+ >(
603
+ parameters: useBalance.Parameters<config, selectData>,
604
+ ): useBalance.ReturnValue<selectData> {
605
+ const config = useConfig(parameters)
606
+ const chainId = useChainId({ config })
607
+ const options = Actions.dex.getBalance.queryOptions(config, {
608
+ ...parameters,
609
+ chainId: parameters.chainId ?? chainId,
610
+ } as never)
611
+ return useQuery(options) as never
612
+ }
613
+
614
+ export declare namespace useBalance {
615
+ export type Parameters<
616
+ config extends Config = ResolvedRegister['config'],
617
+ selectData = Actions.dex.getBalance.ReturnValue,
618
+ > = ConfigParameter<config> &
619
+ QueryParameter<
620
+ Actions.dex.getBalance.ReturnValue,
621
+ Actions.dex.getBalance.ErrorType,
622
+ selectData,
623
+ Actions.dex.getBalance.QueryKey<config>
624
+ > &
625
+ Omit<
626
+ Actions.dex.getBalance.queryOptions.Parameters<config, selectData>,
627
+ 'query'
628
+ >
629
+
630
+ export type ReturnValue<selectData = Actions.dex.getBalance.ReturnValue> =
631
+ UseQueryReturnType<selectData, Error>
632
+ }
633
+
634
+ /**
635
+ * Hook for getting the quote for buying a specific amount of tokens.
636
+ *
637
+ * @example
638
+ * ```tsx
639
+ * import { Hooks } from 'wagmi/tempo'
640
+ *
641
+ * function App() {
642
+ * const { data, isLoading } = Hooks.dex.useBuyQuote({
643
+ * amountOut: parseUnits('100', 6),
644
+ * tokenIn: '0x20c...11',
645
+ * tokenOut: '0x20c...20',
646
+ * })
647
+ *
648
+ * if (isLoading) return <div>Loading...</div>
649
+ * return <div>Required Input: {data}</div>
650
+ * }
651
+ * ```
652
+ *
653
+ * @param parameters - Parameters.
654
+ * @returns Query result with the amount of tokenIn needed.
655
+ */
656
+ export function useBuyQuote<
657
+ config extends Config = ResolvedRegister['config'],
658
+ selectData = Actions.dex.getBuyQuote.ReturnValue,
659
+ >(
660
+ parameters: useBuyQuote.Parameters<config, selectData>,
661
+ ): useBuyQuote.ReturnValue<selectData> {
662
+ const config = useConfig(parameters)
663
+ const chainId = useChainId({ config })
664
+ const options = Actions.dex.getBuyQuote.queryOptions(config, {
665
+ ...parameters,
666
+ chainId: parameters.chainId ?? chainId,
667
+ } as never)
668
+ return useQuery(options) as never
669
+ }
670
+
671
+ export declare namespace useBuyQuote {
672
+ export type Parameters<
673
+ config extends Config = ResolvedRegister['config'],
674
+ selectData = Actions.dex.getBuyQuote.ReturnValue,
675
+ > = ConfigParameter<config> &
676
+ QueryParameter<
677
+ Actions.dex.getBuyQuote.ReturnValue,
678
+ Actions.dex.getBuyQuote.ErrorType,
679
+ selectData,
680
+ Actions.dex.getBuyQuote.QueryKey<config>
681
+ > &
682
+ Omit<
683
+ Actions.dex.getBuyQuote.queryOptions.Parameters<config, selectData>,
684
+ 'query'
685
+ >
686
+
687
+ export type ReturnValue<selectData = Actions.dex.getBuyQuote.ReturnValue> =
688
+ UseQueryReturnType<selectData, Error>
689
+ }
690
+
691
+ /**
692
+ * Hook for getting an order's details from the orderbook.
693
+ *
694
+ * @example
695
+ * ```tsx
696
+ * import { Hooks } from 'wagmi/tempo'
697
+ *
698
+ * function App() {
699
+ * const { data, isLoading } = Hooks.dex.useOrder({
700
+ * orderId: 123n,
701
+ * })
702
+ *
703
+ * if (isLoading) return <div>Loading...</div>
704
+ * return <div>Order: {JSON.stringify(data)}</div>
705
+ * }
706
+ * ```
707
+ *
708
+ * @param parameters - Parameters.
709
+ * @returns Query result with the order details.
710
+ */
711
+ export function useOrder<
712
+ config extends Config = ResolvedRegister['config'],
713
+ selectData = Actions.dex.getOrder.ReturnValue,
714
+ >(
715
+ parameters: useOrder.Parameters<config, selectData>,
716
+ ): useOrder.ReturnValue<selectData> {
717
+ const config = useConfig(parameters)
718
+ const chainId = useChainId({ config })
719
+ const options = Actions.dex.getOrder.queryOptions(config, {
720
+ ...parameters,
721
+ chainId: parameters.chainId ?? chainId,
722
+ } as never)
723
+ return useQuery(options) as never
724
+ }
725
+
726
+ export declare namespace useOrder {
727
+ export type Parameters<
728
+ config extends Config = ResolvedRegister['config'],
729
+ selectData = Actions.dex.getOrder.ReturnValue,
730
+ > = ConfigParameter<config> &
731
+ QueryParameter<
732
+ Actions.dex.getOrder.ReturnValue,
733
+ Actions.dex.getOrder.ErrorType,
734
+ selectData,
735
+ Actions.dex.getOrder.QueryKey<config>
736
+ > &
737
+ Omit<
738
+ Actions.dex.getOrder.queryOptions.Parameters<config, selectData>,
739
+ 'query'
740
+ >
741
+
742
+ export type ReturnValue<selectData = Actions.dex.getOrder.ReturnValue> =
743
+ UseQueryReturnType<selectData, Error>
744
+ }
745
+
746
+ /**
747
+ * Hook for getting orderbook information for a trading pair.
748
+ *
749
+ * @example
750
+ * ```tsx
751
+ * import { Hooks } from 'wagmi/tempo'
752
+ *
753
+ * function App() {
754
+ * const { data, isLoading } = Hooks.dex.useOrderbook({
755
+ * base: '0x20c...11',
756
+ * quote: '0x20c...20',
757
+ * })
758
+ *
759
+ * if (isLoading) return <div>Loading...</div>
760
+ * return <div>Orderbook: {JSON.stringify(data)}</div>
761
+ * }
762
+ * ```
763
+ *
764
+ * @param parameters - Parameters.
765
+ * @returns Query result with the orderbook information.
766
+ */
767
+ export function useOrderbook<
768
+ config extends Config = ResolvedRegister['config'],
769
+ selectData = Actions.dex.getOrderbook.ReturnValue,
770
+ >(
771
+ parameters: useOrderbook.Parameters<config, selectData>,
772
+ ): useOrderbook.ReturnValue<selectData> {
773
+ const config = useConfig(parameters)
774
+ const chainId = useChainId({ config })
775
+ const options = Actions.dex.getOrderbook.queryOptions(config, {
776
+ ...parameters,
777
+ chainId: parameters.chainId ?? chainId,
778
+ } as never)
779
+ return useQuery(options) as never
780
+ }
781
+
782
+ export declare namespace useOrderbook {
783
+ export type Parameters<
784
+ config extends Config = ResolvedRegister['config'],
785
+ selectData = Actions.dex.getOrderbook.ReturnValue,
786
+ > = ConfigParameter<config> &
787
+ QueryParameter<
788
+ Actions.dex.getOrderbook.ReturnValue,
789
+ Actions.dex.getOrderbook.ErrorType,
790
+ selectData,
791
+ Actions.dex.getOrderbook.QueryKey<config>
792
+ > &
793
+ Omit<
794
+ Actions.dex.getOrderbook.queryOptions.Parameters<config, selectData>,
795
+ 'query'
796
+ >
797
+
798
+ export type ReturnValue<selectData = Actions.dex.getOrderbook.ReturnValue> =
799
+ UseQueryReturnType<selectData, Error>
800
+ }
801
+
802
+ /**
803
+ * Hook for getting the tick level information at a specific tick.
804
+ *
805
+ * @example
806
+ * ```tsx
807
+ * import { Hooks } from 'wagmi/tempo'
808
+ * import { Tick } from 'viem/tempo'
809
+ *
810
+ * function App() {
811
+ * const { data, isLoading } = Hooks.dex.useTickLevel({
812
+ * base: '0x20c...11',
813
+ * tick: Tick.fromPrice('1.001'),
814
+ * isBid: true,
815
+ * })
816
+ *
817
+ * if (isLoading) return <div>Loading...</div>
818
+ * return <div>Tick Level: {JSON.stringify(data)}</div>
819
+ * }
820
+ * ```
821
+ *
822
+ * @param parameters - Parameters.
823
+ * @returns Query result with the tick level information.
824
+ */
825
+ export function useTickLevel<
826
+ config extends Config = ResolvedRegister['config'],
827
+ selectData = Actions.dex.getTickLevel.ReturnValue,
828
+ >(
829
+ parameters: useTickLevel.Parameters<config, selectData>,
830
+ ): useTickLevel.ReturnValue<selectData> {
831
+ const config = useConfig(parameters)
832
+ const chainId = useChainId({ config })
833
+ const options = Actions.dex.getTickLevel.queryOptions(config, {
834
+ ...parameters,
835
+ chainId: parameters.chainId ?? chainId,
836
+ } as never)
837
+ return useQuery(options) as never
838
+ }
839
+
840
+ export declare namespace useTickLevel {
841
+ export type Parameters<
842
+ config extends Config = ResolvedRegister['config'],
843
+ selectData = Actions.dex.getTickLevel.ReturnValue,
844
+ > = ConfigParameter<config> &
845
+ QueryParameter<
846
+ Actions.dex.getTickLevel.ReturnValue,
847
+ Actions.dex.getTickLevel.ErrorType,
848
+ selectData,
849
+ Actions.dex.getTickLevel.QueryKey<config>
850
+ > &
851
+ Omit<
852
+ Actions.dex.getTickLevel.queryOptions.Parameters<config, selectData>,
853
+ 'query'
854
+ >
855
+
856
+ export type ReturnValue<selectData = Actions.dex.getTickLevel.ReturnValue> =
857
+ UseQueryReturnType<selectData, Error>
858
+ }
859
+
860
+ /**
861
+ * Hook for getting the quote for selling a specific amount of tokens.
862
+ *
863
+ * @example
864
+ * ```tsx
865
+ * import { Hooks } from 'wagmi/tempo'
866
+ *
867
+ * function App() {
868
+ * const { data, isLoading } = Hooks.dex.useSellQuote({
869
+ * amountIn: parseUnits('100', 6),
870
+ * tokenIn: '0x20c...11',
871
+ * tokenOut: '0x20c...20',
872
+ * })
873
+ *
874
+ * if (isLoading) return <div>Loading...</div>
875
+ * return <div>Expected Output: {data}</div>
876
+ * }
877
+ * ```
878
+ *
879
+ * @param parameters - Parameters.
880
+ * @returns Query result with the amount of tokenOut received.
881
+ */
882
+ export function useSellQuote<
883
+ config extends Config = ResolvedRegister['config'],
884
+ selectData = Actions.dex.getSellQuote.ReturnValue,
885
+ >(
886
+ parameters: useSellQuote.Parameters<config, selectData>,
887
+ ): useSellQuote.ReturnValue<selectData> {
888
+ const config = useConfig(parameters)
889
+ const chainId = useChainId({ config })
890
+ const options = Actions.dex.getSellQuote.queryOptions(config, {
891
+ ...parameters,
892
+ chainId: parameters.chainId ?? chainId,
893
+ } as never)
894
+ return useQuery(options) as never
895
+ }
896
+
897
+ export declare namespace useSellQuote {
898
+ export type Parameters<
899
+ config extends Config = ResolvedRegister['config'],
900
+ selectData = Actions.dex.getSellQuote.ReturnValue,
901
+ > = ConfigParameter<config> &
902
+ QueryParameter<
903
+ Actions.dex.getSellQuote.ReturnValue,
904
+ Actions.dex.getSellQuote.ErrorType,
905
+ selectData,
906
+ Actions.dex.getSellQuote.QueryKey<config>
907
+ > &
908
+ Omit<
909
+ Actions.dex.getSellQuote.queryOptions.Parameters<config, selectData>,
910
+ 'query'
911
+ >
912
+
913
+ export type ReturnValue<selectData = Actions.dex.getSellQuote.ReturnValue> =
914
+ UseQueryReturnType<selectData, Error>
915
+ }
916
+
917
+ /**
918
+ * Hook for placing a limit order on the orderbook.
919
+ *
920
+ * @example
921
+ * ```tsx
922
+ * import { Hooks } from 'wagmi/tempo'
923
+ *
924
+ * function App() {
925
+ * const { mutate, isPending } = Hooks.dex.usePlace()
926
+ *
927
+ * return (
928
+ * <button
929
+ * onClick={() => mutate({
930
+ * amount: parseUnits('100', 6),
931
+ * tick: Tick.fromPrice('0.99'),
932
+ * token: '0x20c...11',
933
+ * type: 'buy',
934
+ * })}
935
+ * disabled={isPending}
936
+ * >
937
+ * Place Order
938
+ * </button>
939
+ * )
940
+ * }
941
+ * ```
942
+ *
943
+ * @param parameters - Parameters.
944
+ * @returns Mutation result.
945
+ */
946
+ export function usePlace<
947
+ config extends Config = ResolvedRegister['config'],
948
+ context = unknown,
949
+ >(
950
+ parameters: usePlace.Parameters<config, context> = {},
951
+ ): usePlace.ReturnType<config, context> {
952
+ const { mutation } = parameters
953
+ const config = useConfig(parameters)
954
+ return useMutation({
955
+ ...mutation,
956
+ async mutationFn(variables) {
957
+ return Actions.dex.place(config, variables as never)
958
+ },
959
+ mutationKey: ['place'],
960
+ }) as never
961
+ }
962
+
963
+ export declare namespace usePlace {
964
+ type Parameters<
965
+ config extends Config = Config,
966
+ context = unknown,
967
+ > = ConfigParameter<config> & {
968
+ mutation?:
969
+ | UseMutationParameters<
970
+ Actions.dex.place.ReturnValue,
971
+ Actions.dex.place.ErrorType,
972
+ Actions.dex.place.Parameters<config>,
973
+ context
974
+ >
975
+ | undefined
976
+ }
977
+
978
+ type ReturnType<
979
+ config extends Config = Config,
980
+ context = unknown,
981
+ > = UseMutationResult<
982
+ Actions.dex.place.ReturnValue,
983
+ Actions.dex.place.ErrorType,
984
+ Actions.dex.place.Parameters<config>,
985
+ context
986
+ >
987
+ }
988
+
989
+ /**
990
+ * Hook for placing a flip order that automatically flips when filled.
991
+ *
992
+ * @example
993
+ * ```tsx
994
+ * import { Hooks } from 'wagmi/tempo'
995
+ *
996
+ * function App() {
997
+ * const { mutate, isPending } = Hooks.dex.usePlaceFlip()
998
+ *
999
+ * return (
1000
+ * <button
1001
+ * onClick={() => mutate({
1002
+ * amount: parseUnits('100', 6),
1003
+ * flipTick: Tick.fromPrice('1.01'),
1004
+ * tick: Tick.fromPrice('0.99'),
1005
+ * token: '0x20c...11',
1006
+ * type: 'buy',
1007
+ * })}
1008
+ * disabled={isPending}
1009
+ * >
1010
+ * Place Flip Order
1011
+ * </button>
1012
+ * )
1013
+ * }
1014
+ * ```
1015
+ *
1016
+ * @param parameters - Parameters.
1017
+ * @returns Mutation result.
1018
+ */
1019
+ export function usePlaceFlip<
1020
+ config extends Config = ResolvedRegister['config'],
1021
+ context = unknown,
1022
+ >(
1023
+ parameters: usePlaceFlip.Parameters<config, context> = {},
1024
+ ): usePlaceFlip.ReturnType<config, context> {
1025
+ const { mutation } = parameters
1026
+ const config = useConfig(parameters)
1027
+ return useMutation({
1028
+ ...mutation,
1029
+ async mutationFn(variables) {
1030
+ return Actions.dex.placeFlip(config, variables as never)
1031
+ },
1032
+ mutationKey: ['placeFlip'],
1033
+ }) as never
1034
+ }
1035
+
1036
+ export declare namespace usePlaceFlip {
1037
+ type Parameters<
1038
+ config extends Config = Config,
1039
+ context = unknown,
1040
+ > = ConfigParameter<config> & {
1041
+ mutation?:
1042
+ | UseMutationParameters<
1043
+ Actions.dex.placeFlip.ReturnValue,
1044
+ Actions.dex.placeFlip.ErrorType,
1045
+ Actions.dex.placeFlip.Parameters<config>,
1046
+ context
1047
+ >
1048
+ | undefined
1049
+ }
1050
+
1051
+ type ReturnType<
1052
+ config extends Config = Config,
1053
+ context = unknown,
1054
+ > = UseMutationResult<
1055
+ Actions.dex.placeFlip.ReturnValue,
1056
+ Actions.dex.placeFlip.ErrorType,
1057
+ Actions.dex.placeFlip.Parameters<config>,
1058
+ context
1059
+ >
1060
+ }
1061
+
1062
+ /**
1063
+ * Hook for placing a flip order that automatically flips when filled.
1064
+ *
1065
+ * Note: This is a synchronous hook that waits for the transaction
1066
+ * to be included on a block before returning a response.
1067
+ *
1068
+ * @example
1069
+ * ```tsx
1070
+ * import { Hooks } from 'wagmi/tempo'
1071
+ *
1072
+ * function App() {
1073
+ * const { mutate, isPending } = Hooks.dex.usePlaceFlipSync()
1074
+ *
1075
+ * return (
1076
+ * <button
1077
+ * onClick={() => mutate({
1078
+ * amount: parseUnits('100', 6),
1079
+ * flipTick: Tick.fromPrice('1.01'),
1080
+ * tick: Tick.fromPrice('0.99'),
1081
+ * token: '0x20c...11',
1082
+ * type: 'buy',
1083
+ * })}
1084
+ * disabled={isPending}
1085
+ * >
1086
+ * Place Flip Order
1087
+ * </button>
1088
+ * )
1089
+ * }
1090
+ * ```
1091
+ *
1092
+ * @param parameters - Parameters.
1093
+ * @returns Mutation result.
1094
+ */
1095
+ export function usePlaceFlipSync<
1096
+ config extends Config = ResolvedRegister['config'],
1097
+ context = unknown,
1098
+ >(
1099
+ parameters: usePlaceFlipSync.Parameters<config, context> = {},
1100
+ ): usePlaceFlipSync.ReturnType<config, context> {
1101
+ const { mutation } = parameters
1102
+ const config = useConfig(parameters)
1103
+ return useMutation({
1104
+ ...mutation,
1105
+ async mutationFn(variables) {
1106
+ return Actions.dex.placeFlipSync(config, variables as never)
1107
+ },
1108
+ mutationKey: ['placeFlipSync'],
1109
+ }) as never
1110
+ }
1111
+
1112
+ export declare namespace usePlaceFlipSync {
1113
+ type Parameters<
1114
+ config extends Config = Config,
1115
+ context = unknown,
1116
+ > = ConfigParameter<config> & {
1117
+ mutation?:
1118
+ | UseMutationParameters<
1119
+ Actions.dex.placeFlipSync.ReturnValue,
1120
+ Actions.dex.placeFlipSync.ErrorType,
1121
+ Actions.dex.placeFlipSync.Parameters<config>,
1122
+ context
1123
+ >
1124
+ | undefined
1125
+ }
1126
+
1127
+ type ReturnType<
1128
+ config extends Config = Config,
1129
+ context = unknown,
1130
+ > = UseMutationResult<
1131
+ Actions.dex.placeFlipSync.ReturnValue,
1132
+ Actions.dex.placeFlipSync.ErrorType,
1133
+ Actions.dex.placeFlipSync.Parameters<config>,
1134
+ context
1135
+ >
1136
+ }
1137
+
1138
+ /**
1139
+ * Hook for placing a limit order on the orderbook.
1140
+ *
1141
+ * Note: This is a synchronous hook that waits for the transaction
1142
+ * to be included on a block before returning a response.
1143
+ *
1144
+ * @example
1145
+ * ```tsx
1146
+ * import { Hooks } from 'wagmi/tempo'
1147
+ *
1148
+ * function App() {
1149
+ * const { mutate, isPending } = Hooks.dex.usePlaceSync()
1150
+ *
1151
+ * return (
1152
+ * <button
1153
+ * onClick={() => mutate({
1154
+ * amount: parseUnits('100', 6),
1155
+ * tick: Tick.fromPrice('0.99'),
1156
+ * token: '0x20c...11',
1157
+ * type: 'buy',
1158
+ * })}
1159
+ * disabled={isPending}
1160
+ * >
1161
+ * Place Order
1162
+ * </button>
1163
+ * )
1164
+ * }
1165
+ * ```
1166
+ *
1167
+ * @param parameters - Parameters.
1168
+ * @returns Mutation result.
1169
+ */
1170
+ export function usePlaceSync<
1171
+ config extends Config = ResolvedRegister['config'],
1172
+ context = unknown,
1173
+ >(
1174
+ parameters: usePlaceSync.Parameters<config, context> = {},
1175
+ ): usePlaceSync.ReturnType<config, context> {
1176
+ const { mutation } = parameters
1177
+ const config = useConfig(parameters)
1178
+ return useMutation({
1179
+ ...mutation,
1180
+ async mutationFn(variables) {
1181
+ return Actions.dex.placeSync(config, variables as never)
1182
+ },
1183
+ mutationKey: ['placeSync'],
1184
+ }) as never
1185
+ }
1186
+
1187
+ export declare namespace usePlaceSync {
1188
+ type Parameters<
1189
+ config extends Config = Config,
1190
+ context = unknown,
1191
+ > = ConfigParameter<config> & {
1192
+ mutation?:
1193
+ | UseMutationParameters<
1194
+ Actions.dex.placeSync.ReturnValue,
1195
+ Actions.dex.placeSync.ErrorType,
1196
+ Actions.dex.placeSync.Parameters<config>,
1197
+ context
1198
+ >
1199
+ | undefined
1200
+ }
1201
+
1202
+ type ReturnType<
1203
+ config extends Config = Config,
1204
+ context = unknown,
1205
+ > = UseMutationResult<
1206
+ Actions.dex.placeSync.ReturnValue,
1207
+ Actions.dex.placeSync.ErrorType,
1208
+ Actions.dex.placeSync.Parameters<config>,
1209
+ context
1210
+ >
1211
+ }
1212
+
1213
+ /**
1214
+ * Hook for selling a specific amount of tokens.
1215
+ *
1216
+ * @example
1217
+ * ```tsx
1218
+ * import { Hooks } from 'wagmi/tempo'
1219
+ *
1220
+ * function App() {
1221
+ * const { mutate, isPending } = Hooks.dex.useSell()
1222
+ *
1223
+ * return (
1224
+ * <button
1225
+ * onClick={() => mutate({
1226
+ * amountIn: parseUnits('100', 6),
1227
+ * minAmountOut: parseUnits('95', 6),
1228
+ * tokenIn: '0x20c...11',
1229
+ * tokenOut: '0x20c...20',
1230
+ * })}
1231
+ * disabled={isPending}
1232
+ * >
1233
+ * Sell Tokens
1234
+ * </button>
1235
+ * )
1236
+ * }
1237
+ * ```
1238
+ *
1239
+ * @param parameters - Parameters.
1240
+ * @returns Mutation result.
1241
+ */
1242
+ export function useSell<
1243
+ config extends Config = ResolvedRegister['config'],
1244
+ context = unknown,
1245
+ >(
1246
+ parameters: useSell.Parameters<config, context> = {},
1247
+ ): useSell.ReturnType<config, context> {
1248
+ const { mutation } = parameters
1249
+ const config = useConfig(parameters)
1250
+ return useMutation({
1251
+ ...mutation,
1252
+ async mutationFn(variables) {
1253
+ return Actions.dex.sell(config, variables as never)
1254
+ },
1255
+ mutationKey: ['sell'],
1256
+ }) as never
1257
+ }
1258
+
1259
+ export declare namespace useSell {
1260
+ type Parameters<
1261
+ config extends Config = Config,
1262
+ context = unknown,
1263
+ > = ConfigParameter<config> & {
1264
+ mutation?:
1265
+ | UseMutationParameters<
1266
+ Actions.dex.sell.ReturnValue,
1267
+ Actions.dex.sell.ErrorType,
1268
+ Actions.dex.sell.Parameters<config>,
1269
+ context
1270
+ >
1271
+ | undefined
1272
+ }
1273
+
1274
+ type ReturnType<
1275
+ config extends Config = Config,
1276
+ context = unknown,
1277
+ > = UseMutationResult<
1278
+ Actions.dex.sell.ReturnValue,
1279
+ Actions.dex.sell.ErrorType,
1280
+ Actions.dex.sell.Parameters<config>,
1281
+ context
1282
+ >
1283
+ }
1284
+
1285
+ /**
1286
+ * Hook for selling a specific amount of tokens.
1287
+ *
1288
+ * Note: This is a synchronous hook that waits for the transaction
1289
+ * to be included on a block before returning a response.
1290
+ *
1291
+ * @example
1292
+ * ```tsx
1293
+ * import { Hooks } from 'wagmi/tempo'
1294
+ *
1295
+ * function App() {
1296
+ * const { mutate, isPending } = Hooks.dex.useSellSync()
1297
+ *
1298
+ * return (
1299
+ * <button
1300
+ * onClick={() => mutate({
1301
+ * amountIn: parseUnits('100', 6),
1302
+ * minAmountOut: parseUnits('95', 6),
1303
+ * tokenIn: '0x20c...11',
1304
+ * tokenOut: '0x20c...20',
1305
+ * })}
1306
+ * disabled={isPending}
1307
+ * >
1308
+ * Sell Tokens
1309
+ * </button>
1310
+ * )
1311
+ * }
1312
+ * ```
1313
+ *
1314
+ * @param parameters - Parameters.
1315
+ * @returns Mutation result.
1316
+ */
1317
+ export function useSellSync<
1318
+ config extends Config = ResolvedRegister['config'],
1319
+ context = unknown,
1320
+ >(
1321
+ parameters: useSellSync.Parameters<config, context> = {},
1322
+ ): useSellSync.ReturnType<config, context> {
1323
+ const { mutation } = parameters
1324
+ const config = useConfig(parameters)
1325
+ return useMutation({
1326
+ ...mutation,
1327
+ async mutationFn(variables) {
1328
+ return Actions.dex.sellSync(config, variables as never)
1329
+ },
1330
+ mutationKey: ['sellSync'],
1331
+ }) as never
1332
+ }
1333
+
1334
+ export declare namespace useSellSync {
1335
+ type Parameters<
1336
+ config extends Config = Config,
1337
+ context = unknown,
1338
+ > = ConfigParameter<config> & {
1339
+ mutation?:
1340
+ | UseMutationParameters<
1341
+ Actions.dex.sellSync.ReturnValue,
1342
+ Actions.dex.sellSync.ErrorType,
1343
+ Actions.dex.sellSync.Parameters<config>,
1344
+ context
1345
+ >
1346
+ | undefined
1347
+ }
1348
+
1349
+ type ReturnType<
1350
+ config extends Config = Config,
1351
+ context = unknown,
1352
+ > = UseMutationResult<
1353
+ Actions.dex.sellSync.ReturnValue,
1354
+ Actions.dex.sellSync.ErrorType,
1355
+ Actions.dex.sellSync.Parameters<config>,
1356
+ context
1357
+ >
1358
+ }
1359
+
1360
+ /**
1361
+ * Hook for withdrawing tokens from the DEX to the caller's wallet.
1362
+ *
1363
+ * @example
1364
+ * ```tsx
1365
+ * import { Hooks } from 'wagmi/tempo'
1366
+ *
1367
+ * function App() {
1368
+ * const { mutate, isPending } = Hooks.dex.useWithdraw()
1369
+ *
1370
+ * return (
1371
+ * <button
1372
+ * onClick={() => mutate({
1373
+ * amount: 100n,
1374
+ * token: '0x20c...11',
1375
+ * })}
1376
+ * disabled={isPending}
1377
+ * >
1378
+ * Withdraw
1379
+ * </button>
1380
+ * )
1381
+ * }
1382
+ * ```
1383
+ *
1384
+ * @param parameters - Parameters.
1385
+ * @returns Mutation result.
1386
+ */
1387
+ export function useWithdraw<
1388
+ config extends Config = ResolvedRegister['config'],
1389
+ context = unknown,
1390
+ >(
1391
+ parameters: useWithdraw.Parameters<config, context> = {},
1392
+ ): useWithdraw.ReturnType<config, context> {
1393
+ const { mutation } = parameters
1394
+ const config = useConfig(parameters)
1395
+ return useMutation({
1396
+ ...mutation,
1397
+ async mutationFn(variables) {
1398
+ return Actions.dex.withdraw(config, variables as never)
1399
+ },
1400
+ mutationKey: ['withdraw'],
1401
+ }) as never
1402
+ }
1403
+
1404
+ export declare namespace useWithdraw {
1405
+ type Parameters<
1406
+ config extends Config = Config,
1407
+ context = unknown,
1408
+ > = ConfigParameter<config> & {
1409
+ mutation?:
1410
+ | UseMutationParameters<
1411
+ Actions.dex.withdraw.ReturnValue,
1412
+ Actions.dex.withdraw.ErrorType,
1413
+ Actions.dex.withdraw.Parameters<config>,
1414
+ context
1415
+ >
1416
+ | undefined
1417
+ }
1418
+
1419
+ type ReturnType<
1420
+ config extends Config = Config,
1421
+ context = unknown,
1422
+ > = UseMutationResult<
1423
+ Actions.dex.withdraw.ReturnValue,
1424
+ Actions.dex.withdraw.ErrorType,
1425
+ Actions.dex.withdraw.Parameters<config>,
1426
+ context
1427
+ >
1428
+ }
1429
+
1430
+ /**
1431
+ * Hook for withdrawing tokens from the DEX to the caller's wallet.
1432
+ *
1433
+ * Note: This is a synchronous hook that waits for the transaction
1434
+ * to be included on a block before returning a response.
1435
+ *
1436
+ * @example
1437
+ * ```tsx
1438
+ * import { Hooks } from 'wagmi/tempo'
1439
+ *
1440
+ * function App() {
1441
+ * const { mutate, isPending } = Hooks.dex.useWithdrawSync()
1442
+ *
1443
+ * return (
1444
+ * <button
1445
+ * onClick={() => mutate({
1446
+ * amount: 100n,
1447
+ * token: '0x20c...11',
1448
+ * })}
1449
+ * disabled={isPending}
1450
+ * >
1451
+ * Withdraw
1452
+ * </button>
1453
+ * )
1454
+ * }
1455
+ * ```
1456
+ *
1457
+ * @param parameters - Parameters.
1458
+ * @returns Mutation result.
1459
+ */
1460
+ export function useWithdrawSync<
1461
+ config extends Config = ResolvedRegister['config'],
1462
+ context = unknown,
1463
+ >(
1464
+ parameters: useWithdrawSync.Parameters<config, context> = {},
1465
+ ): useWithdrawSync.ReturnType<config, context> {
1466
+ const { mutation } = parameters
1467
+ const config = useConfig(parameters)
1468
+ return useMutation({
1469
+ ...mutation,
1470
+ async mutationFn(variables) {
1471
+ return Actions.dex.withdrawSync(config, variables as never)
1472
+ },
1473
+ mutationKey: ['withdrawSync'],
1474
+ }) as never
1475
+ }
1476
+
1477
+ export declare namespace useWithdrawSync {
1478
+ type Parameters<
1479
+ config extends Config = Config,
1480
+ context = unknown,
1481
+ > = ConfigParameter<config> & {
1482
+ mutation?:
1483
+ | UseMutationParameters<
1484
+ Actions.dex.withdrawSync.ReturnValue,
1485
+ Actions.dex.withdrawSync.ErrorType,
1486
+ Actions.dex.withdrawSync.Parameters<config>,
1487
+ context
1488
+ >
1489
+ | undefined
1490
+ }
1491
+
1492
+ type ReturnType<
1493
+ config extends Config = Config,
1494
+ context = unknown,
1495
+ > = UseMutationResult<
1496
+ Actions.dex.withdrawSync.ReturnValue,
1497
+ Actions.dex.withdrawSync.ErrorType,
1498
+ Actions.dex.withdrawSync.Parameters<config>,
1499
+ context
1500
+ >
1501
+ }
1502
+
1503
+ /**
1504
+ * Hook for watching flip order placement events on the DEX.
1505
+ *
1506
+ * @example
1507
+ * ```tsx
1508
+ * import { Hooks } from 'wagmi/tempo'
1509
+ *
1510
+ * function App() {
1511
+ * Hooks.dex.useWatchFlipOrderPlaced({
1512
+ * onFlipOrderPlaced(args) {
1513
+ * console.log('Flip order placed:', args)
1514
+ * },
1515
+ * })
1516
+ *
1517
+ * return <div>Watching for flip order placements...</div>
1518
+ * }
1519
+ * ```
1520
+ *
1521
+ * @param parameters - Parameters.
1522
+ */
1523
+ export function useWatchFlipOrderPlaced<
1524
+ config extends Config = ResolvedRegister['config'],
1525
+ >(parameters: useWatchFlipOrderPlaced.Parameters<config> = {}) {
1526
+ const { enabled = true, onFlipOrderPlaced, ...rest } = parameters
1527
+
1528
+ const config = useConfig({ config: parameters.config })
1529
+ const configChainId = useChainId({ config })
1530
+ const chainId = parameters.chainId ?? configChainId
1531
+
1532
+ // biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
1533
+ useEffect(() => {
1534
+ if (!enabled) return
1535
+ if (!onFlipOrderPlaced) return
1536
+ return Actions.dex.watchFlipOrderPlaced(config, {
1537
+ ...rest,
1538
+ chainId,
1539
+ onFlipOrderPlaced,
1540
+ })
1541
+ }, [
1542
+ config,
1543
+ enabled,
1544
+ chainId,
1545
+ onFlipOrderPlaced,
1546
+ rest.fromBlock,
1547
+ rest.maker,
1548
+ rest.onError,
1549
+ rest.poll,
1550
+ rest.pollingInterval,
1551
+ rest.token,
1552
+ ])
1553
+ }
1554
+
1555
+ export declare namespace useWatchFlipOrderPlaced {
1556
+ type Parameters<config extends Config = Config> = UnionCompute<
1557
+ ExactPartial<Actions.dex.watchFlipOrderPlaced.Parameters<config>> &
1558
+ ConfigParameter<config> & { enabled?: boolean | undefined }
1559
+ >
1560
+ }
1561
+
1562
+ /**
1563
+ * Hook for watching order cancellation events on the DEX.
1564
+ *
1565
+ * @example
1566
+ * ```tsx
1567
+ * import { Hooks } from 'wagmi/tempo'
1568
+ *
1569
+ * function App() {
1570
+ * Hooks.dex.useWatchOrderCancelled({
1571
+ * onOrderCancelled(args) {
1572
+ * console.log('Order cancelled:', args)
1573
+ * },
1574
+ * })
1575
+ *
1576
+ * return <div>Watching for order cancellations...</div>
1577
+ * }
1578
+ * ```
1579
+ *
1580
+ * @param parameters - Parameters.
1581
+ */
1582
+ export function useWatchOrderCancelled<
1583
+ config extends Config = ResolvedRegister['config'],
1584
+ >(parameters: useWatchOrderCancelled.Parameters<config> = {}) {
1585
+ const { enabled = true, onOrderCancelled, ...rest } = parameters
1586
+
1587
+ const config = useConfig({ config: parameters.config })
1588
+ const configChainId = useChainId({ config })
1589
+ const chainId = parameters.chainId ?? configChainId
1590
+
1591
+ // biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
1592
+ useEffect(() => {
1593
+ if (!enabled) return
1594
+ if (!onOrderCancelled) return
1595
+ return Actions.dex.watchOrderCancelled(config, {
1596
+ ...rest,
1597
+ chainId,
1598
+ onOrderCancelled,
1599
+ })
1600
+ }, [
1601
+ config,
1602
+ enabled,
1603
+ chainId,
1604
+ onOrderCancelled,
1605
+ rest.fromBlock,
1606
+ rest.onError,
1607
+ rest.orderId,
1608
+ rest.poll,
1609
+ rest.pollingInterval,
1610
+ ])
1611
+ }
1612
+
1613
+ export declare namespace useWatchOrderCancelled {
1614
+ type Parameters<config extends Config = Config> = UnionCompute<
1615
+ ExactPartial<Actions.dex.watchOrderCancelled.Parameters<config>> &
1616
+ ConfigParameter<config> & { enabled?: boolean | undefined }
1617
+ >
1618
+ }
1619
+
1620
+ /**
1621
+ * Hook for watching order filled events on the DEX.
1622
+ *
1623
+ * @example
1624
+ * ```tsx
1625
+ * import { Hooks } from 'wagmi/tempo'
1626
+ *
1627
+ * function App() {
1628
+ * Hooks.dex.useWatchOrderFilled({
1629
+ * onOrderFilled(args) {
1630
+ * console.log('Order filled:', args)
1631
+ * },
1632
+ * })
1633
+ *
1634
+ * return <div>Watching for order fills...</div>
1635
+ * }
1636
+ * ```
1637
+ *
1638
+ * @param parameters - Parameters.
1639
+ */
1640
+ export function useWatchOrderFilled<
1641
+ config extends Config = ResolvedRegister['config'],
1642
+ >(parameters: useWatchOrderFilled.Parameters<config> = {}) {
1643
+ const { enabled = true, onOrderFilled, ...rest } = parameters
1644
+
1645
+ const config = useConfig({ config: parameters.config })
1646
+ const configChainId = useChainId({ config })
1647
+ const chainId = parameters.chainId ?? configChainId
1648
+
1649
+ // biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
1650
+ useEffect(() => {
1651
+ if (!enabled) return
1652
+ if (!onOrderFilled) return
1653
+ return Actions.dex.watchOrderFilled(config, {
1654
+ ...rest,
1655
+ chainId,
1656
+ onOrderFilled,
1657
+ })
1658
+ }, [
1659
+ config,
1660
+ enabled,
1661
+ chainId,
1662
+ onOrderFilled,
1663
+ rest.fromBlock,
1664
+ rest.maker,
1665
+ rest.onError,
1666
+ rest.orderId,
1667
+ rest.poll,
1668
+ rest.pollingInterval,
1669
+ rest.taker,
1670
+ ])
1671
+ }
1672
+
1673
+ export declare namespace useWatchOrderFilled {
1674
+ type Parameters<config extends Config = Config> = UnionCompute<
1675
+ ExactPartial<Actions.dex.watchOrderFilled.Parameters<config>> &
1676
+ ConfigParameter<config> & { enabled?: boolean | undefined }
1677
+ >
1678
+ }
1679
+
1680
+ /**
1681
+ * Hook for watching order placement events on the DEX.
1682
+ *
1683
+ * @example
1684
+ * ```tsx
1685
+ * import { Hooks } from 'wagmi/tempo'
1686
+ *
1687
+ * function App() {
1688
+ * Hooks.dex.useWatchOrderPlaced({
1689
+ * onOrderPlaced(args) {
1690
+ * console.log('Order placed:', args)
1691
+ * },
1692
+ * })
1693
+ *
1694
+ * return <div>Watching for order placements...</div>
1695
+ * }
1696
+ * ```
1697
+ *
1698
+ * @param parameters - Parameters.
1699
+ */
1700
+ export function useWatchOrderPlaced<
1701
+ config extends Config = ResolvedRegister['config'],
1702
+ >(parameters: useWatchOrderPlaced.Parameters<config> = {}) {
1703
+ const { enabled = true, onOrderPlaced, ...rest } = parameters
1704
+
1705
+ const config = useConfig({ config: parameters.config })
1706
+ const configChainId = useChainId({ config })
1707
+ const chainId = parameters.chainId ?? configChainId
1708
+
1709
+ // biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
1710
+ useEffect(() => {
1711
+ if (!enabled) return
1712
+ if (!onOrderPlaced) return
1713
+ return Actions.dex.watchOrderPlaced(config, {
1714
+ ...rest,
1715
+ chainId,
1716
+ onOrderPlaced,
1717
+ })
1718
+ }, [
1719
+ config,
1720
+ enabled,
1721
+ chainId,
1722
+ onOrderPlaced,
1723
+ rest.fromBlock,
1724
+ rest.maker,
1725
+ rest.onError,
1726
+ rest.poll,
1727
+ rest.pollingInterval,
1728
+ rest.token,
1729
+ ])
1730
+ }
1731
+
1732
+ export declare namespace useWatchOrderPlaced {
1733
+ type Parameters<config extends Config = Config> = UnionCompute<
1734
+ ExactPartial<Actions.dex.watchOrderPlaced.Parameters<config>> &
1735
+ ConfigParameter<config> & { enabled?: boolean | undefined }
1736
+ >
1737
+ }