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