tempo.ts 0.12.1 → 0.13.0

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