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