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,796 +0,0 @@
1
- import type { DefaultError } from '@tanstack/query-core'
2
- import type { UseMutationResult } from '@tanstack/react-query'
3
- import type { Config, ResolvedRegister } from '@wagmi/core'
4
- import { useEffect } from 'react'
5
- import { useChainId, useConfig } from 'wagmi'
6
- import type { ConfigParameter, QueryParameter } from 'wagmi/internal'
7
- import {
8
- type UseMutationParameters,
9
- type UseQueryReturnType,
10
- useMutation,
11
- useQuery,
12
- } from 'wagmi/query'
13
-
14
- import type { ExactPartial, UnionCompute } from '../../internal/types.js'
15
- import * as Actions from '../Actions/amm.js'
16
-
17
- /**
18
- * Hook for getting the reserves for a liquidity pool.
19
- *
20
- * @example
21
- * ```tsx
22
- * import { Hooks } from 'tempo.ts/wagmi'
23
- *
24
- * function App() {
25
- * const { data, isLoading } = Hooks.amm.usePool({
26
- * userToken: '0x...',
27
- * validatorToken: '0x...',
28
- * })
29
- *
30
- * if (isLoading) return <div>Loading...</div>
31
- * return (
32
- * <div>
33
- * User Token Reserve: {data?.reserveUserToken.toString()}
34
- * Validator Token Reserve: {data?.reserveValidatorToken.toString()}
35
- * </div>
36
- * )
37
- * }
38
- * ```
39
- *
40
- * @param parameters - Parameters.
41
- * @returns Query result with the pool reserves.
42
- */
43
- export function usePool<
44
- config extends Config = ResolvedRegister['config'],
45
- selectData = Actions.getPool.ReturnValue,
46
- >(parameters: usePool.Parameters<config, selectData>) {
47
- const { userToken, validatorToken, query = {} } = parameters
48
-
49
- const config = useConfig(parameters)
50
- const chainId = useChainId({ config })
51
-
52
- const options = Actions.getPool.queryOptions(config, {
53
- ...parameters,
54
- chainId: parameters.chainId ?? chainId,
55
- query: undefined,
56
- } as never)
57
- const enabled = Boolean(
58
- userToken !== undefined &&
59
- validatorToken !== undefined &&
60
- (query.enabled ?? true),
61
- )
62
-
63
- return useQuery({ ...query, ...options, enabled })
64
- }
65
-
66
- export declare namespace usePool {
67
- export type Parameters<
68
- config extends Config = ResolvedRegister['config'],
69
- selectData = Actions.getPool.ReturnValue,
70
- > = ConfigParameter<config> &
71
- QueryParameter<
72
- Actions.getPool.ReturnValue,
73
- DefaultError,
74
- selectData,
75
- Actions.getPool.QueryKey<config>
76
- > &
77
- ExactPartial<
78
- Omit<Actions.getPool.queryOptions.Parameters<config, selectData>, 'query'>
79
- >
80
-
81
- export type ReturnValue<selectData = Actions.getPool.ReturnValue> =
82
- UseQueryReturnType<selectData, Error>
83
- }
84
-
85
- /**
86
- * Hook for getting the LP token balance for an account in a specific pool.
87
- *
88
- * @example
89
- * ```tsx
90
- * import { Hooks } from 'tempo.ts/wagmi'
91
- *
92
- * function App() {
93
- * const { data: poolId } = Hooks.amm.usePoolId({
94
- * userToken: '0x...',
95
- * validatorToken: '0x...',
96
- * })
97
- *
98
- * const { data, isLoading } = Hooks.amm.useLiquidityBalance({
99
- * poolId,
100
- * address: '0x20c...0055',
101
- * })
102
- *
103
- * if (isLoading) return <div>Loading...</div>
104
- * return <div>LP Balance: {data?.toString()}</div>
105
- * }
106
- * ```
107
- *
108
- * @param parameters - Parameters.
109
- * @returns Query result with the LP token balance.
110
- */
111
- export function useLiquidityBalance<
112
- config extends Config = ResolvedRegister['config'],
113
- selectData = Actions.getLiquidityBalance.ReturnValue,
114
- >(parameters: useLiquidityBalance.Parameters<config, selectData> = {}) {
115
- const { address, poolId, userToken, validatorToken, query = {} } = parameters
116
-
117
- const config = useConfig(parameters)
118
- const chainId = useChainId({ config })
119
-
120
- const options = Actions.getLiquidityBalance.queryOptions(config, {
121
- ...parameters,
122
- chainId: parameters.chainId ?? chainId,
123
- query: undefined,
124
- } as never)
125
- const enabled = Boolean(
126
- address &&
127
- (poolId || (userToken !== undefined && validatorToken !== undefined)) &&
128
- (query.enabled ?? true),
129
- )
130
-
131
- return useQuery({ ...query, ...options, enabled })
132
- }
133
-
134
- export declare namespace useLiquidityBalance {
135
- export type Parameters<
136
- config extends Config = ResolvedRegister['config'],
137
- selectData = Actions.getLiquidityBalance.ReturnValue,
138
- > = ConfigParameter<config> &
139
- QueryParameter<
140
- Actions.getLiquidityBalance.ReturnValue,
141
- DefaultError,
142
- selectData,
143
- Actions.getLiquidityBalance.QueryKey<config>
144
- > &
145
- ExactPartial<
146
- Omit<
147
- Actions.getLiquidityBalance.queryOptions.Parameters<config, selectData>,
148
- 'query'
149
- >
150
- >
151
-
152
- export type ReturnValue<
153
- selectData = Actions.getLiquidityBalance.ReturnValue,
154
- > = UseQueryReturnType<selectData, Error>
155
- }
156
-
157
- /**
158
- * Hook for performing a rebalance swap from validator token to user token.
159
- *
160
- * @example
161
- * ```tsx
162
- * import { Hooks } from 'tempo.ts/wagmi'
163
- *
164
- * function App() {
165
- * const { mutate, isPending } = Hooks.amm.useRebalanceSwap()
166
- *
167
- * return (
168
- * <button
169
- * onClick={() =>
170
- * mutate({
171
- * userToken: '0x...',
172
- * validatorToken: '0x...',
173
- * amountOut: 100n,
174
- * to: '0x...',
175
- * })
176
- * }
177
- * disabled={isPending}
178
- * >
179
- * Rebalance Swap
180
- * </button>
181
- * )
182
- * }
183
- * ```
184
- *
185
- * @param parameters - Parameters.
186
- * @returns Mutation result.
187
- */
188
- export function useRebalanceSwap<
189
- config extends Config = ResolvedRegister['config'],
190
- context = unknown,
191
- >(
192
- parameters: useRebalanceSwap.Parameters<config, context> = {},
193
- ): useRebalanceSwap.ReturnType<config, context> {
194
- const { mutation } = parameters
195
- const config = useConfig(parameters)
196
- return useMutation({
197
- ...mutation,
198
- async mutationFn(variables) {
199
- return Actions.rebalanceSwap(config, variables as never)
200
- },
201
- mutationKey: ['rebalanceSwap'],
202
- }) as never
203
- }
204
-
205
- export declare namespace useRebalanceSwap {
206
- type Parameters<
207
- config extends Config = Config,
208
- context = unknown,
209
- > = ConfigParameter<config> & {
210
- mutation?:
211
- | UseMutationParameters<
212
- Actions.rebalanceSwap.ReturnValue,
213
- DefaultError,
214
- Actions.rebalanceSwap.Parameters<config>,
215
- context
216
- >
217
- | undefined
218
- }
219
-
220
- type ReturnType<
221
- config extends Config = Config,
222
- context = unknown,
223
- > = UseMutationResult<
224
- Actions.rebalanceSwap.ReturnValue,
225
- DefaultError,
226
- Actions.rebalanceSwap.Parameters<config>,
227
- context
228
- >
229
- }
230
-
231
- /**
232
- * Hook for performing a rebalance swap from validator token to user token.
233
- *
234
- * Note: This is a synchronous hook that waits for the transaction
235
- * to be included on a block before returning a response.
236
- *
237
- * @example
238
- * ```tsx
239
- * import { Hooks } from 'tempo.ts/wagmi'
240
- *
241
- * function App() {
242
- * const { mutate, isPending } = Hooks.amm.useRebalanceSwapSync()
243
- *
244
- * return (
245
- * <button
246
- * onClick={() =>
247
- * mutate({
248
- * userToken: '0x...',
249
- * validatorToken: '0x...',
250
- * amountOut: 100n,
251
- * to: '0x...',
252
- * })
253
- * }
254
- * disabled={isPending}
255
- * >
256
- * Rebalance Swap
257
- * </button>
258
- * )
259
- * }
260
- * ```
261
- *
262
- * @param parameters - Parameters.
263
- * @returns Mutation result.
264
- */
265
- export function useRebalanceSwapSync<
266
- config extends Config = ResolvedRegister['config'],
267
- context = unknown,
268
- >(
269
- parameters: useRebalanceSwapSync.Parameters<config, context> = {},
270
- ): useRebalanceSwapSync.ReturnType<config, context> {
271
- const { mutation } = parameters
272
- const config = useConfig(parameters)
273
- return useMutation({
274
- ...mutation,
275
- async mutationFn(variables) {
276
- return Actions.rebalanceSwapSync(config, variables as never)
277
- },
278
- mutationKey: ['rebalanceSwapSync'],
279
- }) as never
280
- }
281
-
282
- export declare namespace useRebalanceSwapSync {
283
- type Parameters<
284
- config extends Config = Config,
285
- context = unknown,
286
- > = ConfigParameter<config> & {
287
- mutation?:
288
- | UseMutationParameters<
289
- Actions.rebalanceSwapSync.ReturnValue,
290
- DefaultError,
291
- Actions.rebalanceSwapSync.Parameters<config>,
292
- context
293
- >
294
- | undefined
295
- }
296
-
297
- type ReturnType<
298
- config extends Config = Config,
299
- context = unknown,
300
- > = UseMutationResult<
301
- Actions.rebalanceSwapSync.ReturnValue,
302
- DefaultError,
303
- Actions.rebalanceSwapSync.Parameters<config>,
304
- context
305
- >
306
- }
307
-
308
- /**
309
- * Hook for adding liquidity to a pool.
310
- *
311
- * @example
312
- * ```tsx
313
- * import { Hooks } from 'tempo.ts/wagmi'
314
- *
315
- * function App() {
316
- * const { mutate, isPending } = Hooks.amm.useMint()
317
- *
318
- * return (
319
- * <button
320
- * onClick={() =>
321
- * mutate({
322
- * userTokenAddress: '0x20c0...beef',
323
- * validatorTokenAddress: '0x20c0...babe',
324
- * validatorTokenAmount: 100n,
325
- * to: '0xfeed...fede',
326
- * })
327
- * }
328
- * disabled={isPending}
329
- * >
330
- * Add Liquidity
331
- * </button>
332
- * )
333
- * }
334
- * ```
335
- *
336
- * @param parameters - Parameters.
337
- * @returns Mutation result.
338
- */
339
- export function useMint<
340
- config extends Config = ResolvedRegister['config'],
341
- context = unknown,
342
- >(
343
- parameters: useMint.Parameters<config, context> = {},
344
- ): useMint.ReturnType<config, context> {
345
- const { mutation } = parameters
346
- const config = useConfig(parameters)
347
- return useMutation({
348
- ...mutation,
349
- async mutationFn(variables) {
350
- return Actions.mint(config, variables as never)
351
- },
352
- mutationKey: ['mint'],
353
- }) as never
354
- }
355
-
356
- export declare namespace useMint {
357
- type Parameters<
358
- config extends Config = Config,
359
- context = unknown,
360
- > = ConfigParameter<config> & {
361
- mutation?:
362
- | UseMutationParameters<
363
- Actions.mint.ReturnValue,
364
- DefaultError,
365
- Actions.mint.Parameters<config>,
366
- context
367
- >
368
- | undefined
369
- }
370
-
371
- type ReturnType<
372
- config extends Config = Config,
373
- context = unknown,
374
- > = UseMutationResult<
375
- Actions.mint.ReturnValue,
376
- DefaultError,
377
- Actions.mint.Parameters<config>,
378
- context
379
- >
380
- }
381
-
382
- /**
383
- * Hook for adding liquidity to a pool.
384
- *
385
- * Note: This is a synchronous hook that waits for the transaction
386
- * to be included on a block before returning a response.
387
- *
388
- * @example
389
- * ```tsx
390
- * import { Hooks } from 'tempo.ts/wagmi'
391
- *
392
- * function App() {
393
- * const { mutate, isPending } = Hooks.amm.useMintSync()
394
- *
395
- * return (
396
- * <button
397
- * onClick={() =>
398
- * mutate({
399
- * userTokenAddress: '0x20c0...beef',
400
- * validatorTokenAddress: '0x20c0...babe',
401
- * validatorTokenAmount: 100n,
402
- * to: '0xfeed...fede',
403
- * })
404
- * }
405
- * disabled={isPending}
406
- * >
407
- * Add Liquidity
408
- * </button>
409
- * )
410
- * }
411
- * ```
412
- *
413
- * @param parameters - Parameters.
414
- * @returns Mutation result.
415
- */
416
- export function useMintSync<
417
- config extends Config = ResolvedRegister['config'],
418
- context = unknown,
419
- >(
420
- parameters: useMintSync.Parameters<config, context> = {},
421
- ): useMintSync.ReturnType<config, context> {
422
- const { mutation } = parameters
423
- const config = useConfig(parameters)
424
- return useMutation({
425
- ...mutation,
426
- async mutationFn(variables) {
427
- return Actions.mintSync(config, variables as never)
428
- },
429
- mutationKey: ['mintSync'],
430
- }) as never
431
- }
432
-
433
- export declare namespace useMintSync {
434
- type Parameters<
435
- config extends Config = Config,
436
- context = unknown,
437
- > = ConfigParameter<config> & {
438
- mutation?:
439
- | UseMutationParameters<
440
- Actions.mintSync.ReturnValue,
441
- DefaultError,
442
- Actions.mintSync.Parameters<config>,
443
- context
444
- >
445
- | undefined
446
- }
447
-
448
- type ReturnType<
449
- config extends Config = Config,
450
- context = unknown,
451
- > = UseMutationResult<
452
- Actions.mintSync.ReturnValue,
453
- DefaultError,
454
- Actions.mintSync.Parameters<config>,
455
- context
456
- >
457
- }
458
-
459
- /**
460
- * Hook for removing liquidity from a pool.
461
- *
462
- * @example
463
- * ```tsx
464
- * import { Hooks } from 'tempo.ts/wagmi'
465
- *
466
- * function App() {
467
- * const { mutate, isPending } = Hooks.amm.useBurn()
468
- *
469
- * return (
470
- * <button
471
- * onClick={() =>
472
- * mutate({
473
- * userToken: '0x20c0...beef',
474
- * validatorToken: '0x20c0...babe',
475
- * liquidity: 50n,
476
- * to: '0xfeed...fede',
477
- * })
478
- * }
479
- * disabled={isPending}
480
- * >
481
- * Remove Liquidity
482
- * </button>
483
- * )
484
- * }
485
- * ```
486
- *
487
- * @param parameters - Parameters.
488
- * @returns Mutation result.
489
- */
490
- export function useBurn<
491
- config extends Config = ResolvedRegister['config'],
492
- context = unknown,
493
- >(
494
- parameters: useBurn.Parameters<config, context> = {},
495
- ): useBurn.ReturnType<config, context> {
496
- const { mutation } = parameters
497
- const config = useConfig(parameters)
498
- return useMutation({
499
- ...mutation,
500
- async mutationFn(variables) {
501
- return Actions.burn(config, variables as never)
502
- },
503
- mutationKey: ['burn'],
504
- }) as never
505
- }
506
-
507
- export declare namespace useBurn {
508
- type Parameters<
509
- config extends Config = Config,
510
- context = unknown,
511
- > = ConfigParameter<config> & {
512
- mutation?:
513
- | UseMutationParameters<
514
- Actions.burn.ReturnValue,
515
- DefaultError,
516
- Actions.burn.Parameters<config>,
517
- context
518
- >
519
- | undefined
520
- }
521
-
522
- type ReturnType<
523
- config extends Config = Config,
524
- context = unknown,
525
- > = UseMutationResult<
526
- Actions.burn.ReturnValue,
527
- DefaultError,
528
- Actions.burn.Parameters<config>,
529
- context
530
- >
531
- }
532
-
533
- /**
534
- * Hook for removing liquidity from a pool.
535
- *
536
- * Note: This is a synchronous hook that waits for the transaction
537
- * to be included on a block before returning a response.
538
- *
539
- * @example
540
- * ```tsx
541
- * import { Hooks } from 'tempo.ts/wagmi'
542
- *
543
- * function App() {
544
- * const { mutate, isPending } = Hooks.amm.useBurnSync()
545
- *
546
- * return (
547
- * <button
548
- * onClick={() =>
549
- * mutate({
550
- * userToken: '0x20c0...beef',
551
- * validatorToken: '0x20c0...babe',
552
- * liquidity: 50n,
553
- * to: '0xfeed...fede',
554
- * })
555
- * }
556
- * disabled={isPending}
557
- * >
558
- * Remove Liquidity
559
- * </button>
560
- * )
561
- * }
562
- * ```
563
- *
564
- * @param parameters - Parameters.
565
- * @returns Mutation result.
566
- */
567
- export function useBurnSync<
568
- config extends Config = ResolvedRegister['config'],
569
- context = unknown,
570
- >(
571
- parameters: useBurnSync.Parameters<config, context> = {},
572
- ): useBurnSync.ReturnType<config, context> {
573
- const { mutation } = parameters
574
- const config = useConfig(parameters)
575
- return useMutation({
576
- ...mutation,
577
- async mutationFn(variables) {
578
- return Actions.burnSync(config, variables as never)
579
- },
580
- mutationKey: ['burnSync'],
581
- }) as never
582
- }
583
-
584
- export declare namespace useBurnSync {
585
- type Parameters<
586
- config extends Config = Config,
587
- context = unknown,
588
- > = ConfigParameter<config> & {
589
- mutation?:
590
- | UseMutationParameters<
591
- Actions.burnSync.ReturnValue,
592
- DefaultError,
593
- Actions.burnSync.Parameters<config>,
594
- context
595
- >
596
- | undefined
597
- }
598
-
599
- type ReturnType<
600
- config extends Config = Config,
601
- context = unknown,
602
- > = UseMutationResult<
603
- Actions.burnSync.ReturnValue,
604
- DefaultError,
605
- Actions.burnSync.Parameters<config>,
606
- context
607
- >
608
- }
609
-
610
- /**
611
- * Hook for watching rebalance swap events.
612
- *
613
- * @example
614
- * ```tsx
615
- * import { Hooks } from 'tempo.ts/wagmi'
616
- *
617
- * function App() {
618
- * Hooks.amm.useWatchRebalanceSwap({
619
- * onRebalanceSwap(args) {
620
- * console.log('Rebalance swap:', args)
621
- * },
622
- * })
623
- *
624
- * return <div>Watching for rebalance swaps...</div>
625
- * }
626
- * ```
627
- *
628
- * @param parameters - Parameters.
629
- */
630
- export function useWatchRebalanceSwap<
631
- config extends Config = ResolvedRegister['config'],
632
- >(parameters: useWatchRebalanceSwap.Parameters<config> = {}) {
633
- const { enabled = true, onRebalanceSwap, ...rest } = parameters
634
-
635
- const config = useConfig({ config: parameters.config })
636
- const configChainId = useChainId({ config })
637
- const chainId = parameters.chainId ?? configChainId
638
-
639
- useEffect(() => {
640
- if (!enabled) return
641
- if (!onRebalanceSwap) return
642
- return Actions.watchRebalanceSwap(config, {
643
- ...rest,
644
- chainId,
645
- onRebalanceSwap,
646
- })
647
- }, [config, enabled, onRebalanceSwap, rest, chainId])
648
- }
649
-
650
- export declare namespace useWatchRebalanceSwap {
651
- type Parameters<config extends Config = Config> = UnionCompute<
652
- ExactPartial<Actions.watchRebalanceSwap.Parameters<config>> &
653
- ConfigParameter<config> & { enabled?: boolean | undefined }
654
- >
655
- }
656
-
657
- /**
658
- * Hook for watching fee swap events.
659
- *
660
- * @example
661
- * ```tsx
662
- * import { Hooks } from 'tempo.ts/wagmi'
663
- *
664
- * function App() {
665
- * Hooks.amm.useWatchFeeSwap({
666
- * onFeeSwap(args) {
667
- * console.log('Fee swap:', args)
668
- * },
669
- * })
670
- *
671
- * return <div>Watching for fee swaps...</div>
672
- * }
673
- * ```
674
- *
675
- * @param parameters - Parameters.
676
- */
677
- export function useWatchFeeSwap<
678
- config extends Config = ResolvedRegister['config'],
679
- >(parameters: useWatchFeeSwap.Parameters<config> = {}) {
680
- const { enabled = true, onFeeSwap, ...rest } = parameters
681
-
682
- const config = useConfig({ config: parameters.config })
683
- const configChainId = useChainId({ config })
684
- const chainId = parameters.chainId ?? configChainId
685
-
686
- useEffect(() => {
687
- if (!enabled) return
688
- if (!onFeeSwap) return
689
- return Actions.watchFeeSwap(config, {
690
- ...rest,
691
- chainId,
692
- onFeeSwap,
693
- })
694
- }, [config, enabled, onFeeSwap, rest, chainId])
695
- }
696
-
697
- export declare namespace useWatchFeeSwap {
698
- type Parameters<config extends Config = Config> = UnionCompute<
699
- ExactPartial<Actions.watchFeeSwap.Parameters<config>> &
700
- ConfigParameter<config> & { enabled?: boolean | undefined }
701
- >
702
- }
703
-
704
- /**
705
- * Hook for watching liquidity mint events.
706
- *
707
- * @example
708
- * ```tsx
709
- * import { Hooks } from 'tempo.ts/wagmi'
710
- *
711
- * function App() {
712
- * Hooks.amm.useWatchMint({
713
- * onMint(args) {
714
- * console.log('Liquidity added:', args)
715
- * },
716
- * })
717
- *
718
- * return <div>Watching for liquidity additions...</div>
719
- * }
720
- * ```
721
- *
722
- * @param parameters - Parameters.
723
- */
724
- export function useWatchMint<
725
- config extends Config = ResolvedRegister['config'],
726
- >(parameters: useWatchMint.Parameters<config> = {}) {
727
- const { enabled = true, onMint, ...rest } = parameters
728
-
729
- const config = useConfig({ config: parameters.config })
730
- const configChainId = useChainId({ config })
731
- const chainId = parameters.chainId ?? configChainId
732
-
733
- useEffect(() => {
734
- if (!enabled) return
735
- if (!onMint) return
736
- return Actions.watchMint(config, {
737
- ...rest,
738
- chainId,
739
- onMint,
740
- })
741
- }, [config, enabled, onMint, rest, chainId])
742
- }
743
-
744
- export declare namespace useWatchMint {
745
- type Parameters<config extends Config = Config> = UnionCompute<
746
- ExactPartial<Actions.watchMint.Parameters<config>> &
747
- ConfigParameter<config> & { enabled?: boolean | undefined }
748
- >
749
- }
750
-
751
- /**
752
- * Hook for watching liquidity burn events.
753
- *
754
- * @example
755
- * ```tsx
756
- * import { Hooks } from 'tempo.ts/wagmi'
757
- *
758
- * function App() {
759
- * Hooks.amm.useWatchBurn({
760
- * onBurn(args) {
761
- * console.log('Liquidity removed:', args)
762
- * },
763
- * })
764
- *
765
- * return <div>Watching for liquidity removals...</div>
766
- * }
767
- * ```
768
- *
769
- * @param parameters - Parameters.
770
- */
771
- export function useWatchBurn<
772
- config extends Config = ResolvedRegister['config'],
773
- >(parameters: useWatchBurn.Parameters<config> = {}) {
774
- const { enabled = true, onBurn, ...rest } = parameters
775
-
776
- const config = useConfig({ config: parameters.config })
777
- const configChainId = useChainId({ config })
778
- const chainId = parameters.chainId ?? configChainId
779
-
780
- useEffect(() => {
781
- if (!enabled) return
782
- if (!onBurn) return
783
- return Actions.watchBurn(config, {
784
- ...rest,
785
- chainId,
786
- onBurn,
787
- })
788
- }, [config, enabled, onBurn, rest, chainId])
789
- }
790
-
791
- export declare namespace useWatchBurn {
792
- type Parameters<config extends Config = Config> = UnionCompute<
793
- ExactPartial<Actions.watchBurn.Parameters<config>> &
794
- ConfigParameter<config> & { enabled?: boolean | undefined }
795
- >
796
- }