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