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