tempo.ts 0.12.0 → 0.13.0

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