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