@wagmi/core 3.0.2 → 3.1.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/internal.js.map +1 -1
- package/dist/esm/exports/query.js +1 -1
- package/dist/esm/exports/query.js.map +1 -1
- package/dist/esm/exports/tempo.js +9 -0
- package/dist/esm/exports/tempo.js.map +1 -0
- package/dist/esm/tempo/Actions/amm.js +469 -0
- package/dist/esm/tempo/Actions/amm.js.map +1 -0
- package/dist/esm/tempo/Actions/dex.js +983 -0
- package/dist/esm/tempo/Actions/dex.js.map +1 -0
- package/dist/esm/tempo/Actions/faucet.js +64 -0
- package/dist/esm/tempo/Actions/faucet.js.map +1 -0
- package/dist/esm/tempo/Actions/fee.js +160 -0
- package/dist/esm/tempo/Actions/fee.js.map +1 -0
- package/dist/esm/tempo/Actions/index.js +11 -0
- package/dist/esm/tempo/Actions/index.js.map +1 -0
- package/dist/esm/tempo/Actions/nonce.js +176 -0
- package/dist/esm/tempo/Actions/nonce.js.map +1 -0
- package/dist/esm/tempo/Actions/policy.js +532 -0
- package/dist/esm/tempo/Actions/policy.js.map +1 -0
- package/dist/esm/tempo/Actions/reward.js +384 -0
- package/dist/esm/tempo/Actions/reward.js.map +1 -0
- package/dist/esm/tempo/Actions/token.js +1717 -0
- package/dist/esm/tempo/Actions/token.js.map +1 -0
- package/dist/esm/tempo/Actions/utils.js +2 -0
- package/dist/esm/tempo/Actions/utils.js.map +1 -0
- package/dist/esm/tempo/Connectors.js +534 -0
- package/dist/esm/tempo/Connectors.js.map +1 -0
- package/dist/esm/tempo/KeyManager.js +106 -0
- package/dist/esm/tempo/KeyManager.js.map +1 -0
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/exports/internal.d.ts +1 -1
- package/dist/types/exports/internal.d.ts.map +1 -1
- package/dist/types/exports/query.d.ts +1 -1
- package/dist/types/exports/query.d.ts.map +1 -1
- package/dist/types/exports/tempo.d.ts +5 -0
- package/dist/types/exports/tempo.d.ts.map +1 -0
- package/dist/types/tempo/Actions/amm.d.ts +418 -0
- package/dist/types/tempo/Actions/amm.d.ts.map +1 -0
- package/dist/types/tempo/Actions/dex.d.ts +858 -0
- package/dist/types/tempo/Actions/dex.d.ts.map +1 -0
- package/dist/types/tempo/Actions/faucet.d.ts +70 -0
- package/dist/types/tempo/Actions/faucet.d.ts.map +1 -0
- package/dist/types/tempo/Actions/fee.d.ts +141 -0
- package/dist/types/tempo/Actions/fee.d.ts.map +1 -0
- package/dist/types/tempo/Actions/index.d.ts +10 -0
- package/dist/types/tempo/Actions/index.d.ts.map +1 -0
- package/dist/types/tempo/Actions/nonce.d.ts +150 -0
- package/dist/types/tempo/Actions/nonce.d.ts.map +1 -0
- package/dist/types/tempo/Actions/policy.d.ts +478 -0
- package/dist/types/tempo/Actions/policy.d.ts.map +1 -0
- package/dist/types/tempo/Actions/reward.d.ts +340 -0
- package/dist/types/tempo/Actions/reward.d.ts.map +1 -0
- package/dist/types/tempo/Actions/token.d.ts +1531 -0
- package/dist/types/tempo/Actions/token.d.ts.map +1 -0
- package/dist/types/tempo/Actions/utils.d.ts +9 -0
- package/dist/types/tempo/Actions/utils.d.ts.map +1 -0
- package/dist/types/tempo/Connectors.d.ts +99 -0
- package/dist/types/tempo/Connectors.d.ts.map +1 -0
- package/dist/types/tempo/KeyManager.d.ts +71 -0
- package/dist/types/tempo/KeyManager.d.ts.map +1 -0
- package/dist/types/types/utils.d.ts +16 -0
- package/dist/types/types/utils.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +14 -2
- package/src/exports/internal.ts +3 -0
- package/src/exports/query.ts +4 -1
- package/src/exports/tempo.ts +14 -0
- package/src/tempo/Actions/amm.ts +719 -0
- package/src/tempo/Actions/dex.ts +1571 -0
- package/src/tempo/Actions/faucet.ts +95 -0
- package/src/tempo/Actions/fee.ts +259 -0
- package/src/tempo/Actions/index.ts +10 -0
- package/src/tempo/Actions/nonce.ts +283 -0
- package/src/tempo/Actions/policy.ts +827 -0
- package/src/tempo/Actions/reward.ts +621 -0
- package/src/tempo/Actions/token.ts +2598 -0
- package/src/tempo/Actions/utils.ts +26 -0
- package/src/tempo/Connectors.ts +762 -0
- package/src/tempo/KeyManager.ts +176 -0
- package/src/types/utils.ts +19 -0
- package/src/version.ts +1 -1
- package/tempo/package.json +5 -0
|
@@ -0,0 +1,719 @@
|
|
|
1
|
+
import type { Account, BaseErrorType } from 'viem'
|
|
2
|
+
import { Actions } from 'viem/tempo'
|
|
3
|
+
import { getConnectorClient } from '../../actions/getConnectorClient.js'
|
|
4
|
+
import type { Config } from '../../createConfig.js'
|
|
5
|
+
import { filterQueryOptions } from '../../query/utils.js'
|
|
6
|
+
import type {
|
|
7
|
+
ChainIdParameter,
|
|
8
|
+
ConnectorParameter,
|
|
9
|
+
} from '../../types/properties.js'
|
|
10
|
+
import type { UnionLooseOmit } from '../../types/utils.js'
|
|
11
|
+
import type { QueryOptions, QueryParameter } from './utils.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Gets the reserves for a liquidity pool.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
19
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
20
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
21
|
+
*
|
|
22
|
+
* const config = createConfig({
|
|
23
|
+
* chains: [tempoTestnet],
|
|
24
|
+
* transports: {
|
|
25
|
+
* [tempo.id]: http(),
|
|
26
|
+
* },
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* const pool = await Actions.amm.getPool(config, {
|
|
30
|
+
* userToken: '0x...',
|
|
31
|
+
* validatorToken: '0x...',
|
|
32
|
+
* })
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @param config - Config.
|
|
36
|
+
* @param parameters - Parameters.
|
|
37
|
+
* @returns The pool reserves.
|
|
38
|
+
*/
|
|
39
|
+
export function getPool<config extends Config>(
|
|
40
|
+
config: config,
|
|
41
|
+
parameters: getPool.Parameters<config>,
|
|
42
|
+
): Promise<getPool.ReturnValue> {
|
|
43
|
+
const { chainId, ...rest } = parameters
|
|
44
|
+
const client = config.getClient({ chainId })
|
|
45
|
+
return Actions.amm.getPool(client, rest)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export namespace getPool {
|
|
49
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
50
|
+
Actions.amm.getPool.Parameters
|
|
51
|
+
|
|
52
|
+
export type ReturnValue = Actions.amm.getPool.ReturnValue
|
|
53
|
+
|
|
54
|
+
export type ErrorType = BaseErrorType
|
|
55
|
+
|
|
56
|
+
export function queryKey<config extends Config>(
|
|
57
|
+
parameters: Parameters<config>,
|
|
58
|
+
) {
|
|
59
|
+
return ['getPool', filterQueryOptions(parameters)] as const
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type QueryKey<config extends Config> = ReturnType<
|
|
63
|
+
typeof queryKey<config>
|
|
64
|
+
>
|
|
65
|
+
|
|
66
|
+
export function queryOptions<config extends Config, selectData = ReturnValue>(
|
|
67
|
+
config: Config,
|
|
68
|
+
parameters: queryOptions.Parameters<config, selectData>,
|
|
69
|
+
): queryOptions.ReturnValue<config, selectData> {
|
|
70
|
+
const { query, ...rest } = parameters
|
|
71
|
+
return {
|
|
72
|
+
...query,
|
|
73
|
+
enabled: Boolean(
|
|
74
|
+
rest.userToken && rest.validatorToken && (query?.enabled ?? true),
|
|
75
|
+
),
|
|
76
|
+
queryKey: queryKey(rest),
|
|
77
|
+
async queryFn({ queryKey }) {
|
|
78
|
+
const [, parameters] = queryKey
|
|
79
|
+
return await getPool(config, parameters)
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export declare namespace queryOptions {
|
|
85
|
+
export type Parameters<
|
|
86
|
+
config extends Config,
|
|
87
|
+
selectData = getPool.ReturnValue,
|
|
88
|
+
> = getPool.Parameters<config> &
|
|
89
|
+
QueryParameter<
|
|
90
|
+
getPool.ReturnValue,
|
|
91
|
+
getPool.ErrorType,
|
|
92
|
+
selectData,
|
|
93
|
+
getPool.QueryKey<config>
|
|
94
|
+
>
|
|
95
|
+
|
|
96
|
+
export type ReturnValue<
|
|
97
|
+
config extends Config,
|
|
98
|
+
selectData = getPool.ReturnValue,
|
|
99
|
+
> = QueryOptions<
|
|
100
|
+
getPool.ReturnValue,
|
|
101
|
+
getPool.ErrorType,
|
|
102
|
+
selectData,
|
|
103
|
+
getPool.QueryKey<config>
|
|
104
|
+
>
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Gets the LP token balance for an account in a specific pool.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
114
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
115
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
116
|
+
*
|
|
117
|
+
* const config = createConfig({
|
|
118
|
+
* chains: [tempoTestnet],
|
|
119
|
+
* transports: {
|
|
120
|
+
* [tempo.id]: http(),
|
|
121
|
+
* },
|
|
122
|
+
* })
|
|
123
|
+
*
|
|
124
|
+
* const poolId = await Actions.amm.getPoolId(config, {
|
|
125
|
+
* userToken: '0x...',
|
|
126
|
+
* validatorToken: '0x...',
|
|
127
|
+
* })
|
|
128
|
+
*
|
|
129
|
+
* const balance = await Actions.amm.getLiquidityBalance(config, {
|
|
130
|
+
* poolId,
|
|
131
|
+
* address: '0x...',
|
|
132
|
+
* })
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @param config - Config.
|
|
136
|
+
* @param parameters - Parameters.
|
|
137
|
+
* @returns The LP token balance.
|
|
138
|
+
*/
|
|
139
|
+
export function getLiquidityBalance<config extends Config>(
|
|
140
|
+
config: config,
|
|
141
|
+
parameters: getLiquidityBalance.Parameters<config>,
|
|
142
|
+
): Promise<getLiquidityBalance.ReturnValue> {
|
|
143
|
+
const { chainId, ...rest } = parameters
|
|
144
|
+
const client = config.getClient({ chainId })
|
|
145
|
+
return Actions.amm.getLiquidityBalance(client, rest)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export namespace getLiquidityBalance {
|
|
149
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
150
|
+
Actions.amm.getLiquidityBalance.Parameters
|
|
151
|
+
|
|
152
|
+
export type ReturnValue = Actions.amm.getLiquidityBalance.ReturnValue
|
|
153
|
+
|
|
154
|
+
export type ErrorType = BaseErrorType
|
|
155
|
+
|
|
156
|
+
export function queryKey<config extends Config>(
|
|
157
|
+
parameters: Parameters<config>,
|
|
158
|
+
) {
|
|
159
|
+
return ['getLiquidityBalance', filterQueryOptions(parameters)] as const
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export type QueryKey<config extends Config> = ReturnType<
|
|
163
|
+
typeof queryKey<config>
|
|
164
|
+
>
|
|
165
|
+
|
|
166
|
+
export function queryOptions<config extends Config, selectData = ReturnValue>(
|
|
167
|
+
config: Config,
|
|
168
|
+
parameters: queryOptions.Parameters<config, selectData>,
|
|
169
|
+
): queryOptions.ReturnValue<config, selectData> {
|
|
170
|
+
const { query, ...rest } = parameters
|
|
171
|
+
return {
|
|
172
|
+
...query,
|
|
173
|
+
enabled: Boolean(
|
|
174
|
+
rest.address &&
|
|
175
|
+
(rest.poolId ||
|
|
176
|
+
(rest.userToken !== undefined &&
|
|
177
|
+
rest.validatorToken !== undefined)) &&
|
|
178
|
+
(query?.enabled ?? true),
|
|
179
|
+
),
|
|
180
|
+
queryKey: queryKey(rest),
|
|
181
|
+
async queryFn({ queryKey }) {
|
|
182
|
+
const [, parameters] = queryKey
|
|
183
|
+
return await getLiquidityBalance(config, parameters)
|
|
184
|
+
},
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export declare namespace queryOptions {
|
|
189
|
+
export type Parameters<
|
|
190
|
+
config extends Config,
|
|
191
|
+
selectData = getLiquidityBalance.ReturnValue,
|
|
192
|
+
> = getLiquidityBalance.Parameters<config> &
|
|
193
|
+
QueryParameter<
|
|
194
|
+
getLiquidityBalance.ReturnValue,
|
|
195
|
+
getLiquidityBalance.ErrorType,
|
|
196
|
+
selectData,
|
|
197
|
+
getLiquidityBalance.QueryKey<config>
|
|
198
|
+
>
|
|
199
|
+
|
|
200
|
+
export type ReturnValue<
|
|
201
|
+
config extends Config,
|
|
202
|
+
selectData = getLiquidityBalance.ReturnValue,
|
|
203
|
+
> = QueryOptions<
|
|
204
|
+
getLiquidityBalance.ReturnValue,
|
|
205
|
+
getLiquidityBalance.ErrorType,
|
|
206
|
+
selectData,
|
|
207
|
+
getLiquidityBalance.QueryKey<config>
|
|
208
|
+
>
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Performs a rebalance swap from validator token to user token.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```ts
|
|
217
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
218
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
219
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
220
|
+
*
|
|
221
|
+
* const config = createConfig({
|
|
222
|
+
* chains: [tempoTestnet],
|
|
223
|
+
* transports: {
|
|
224
|
+
* [tempo.id]: http(),
|
|
225
|
+
* },
|
|
226
|
+
* })
|
|
227
|
+
*
|
|
228
|
+
* const hash = await Actions.amm.rebalanceSwap(config, {
|
|
229
|
+
* userToken: '0x...',
|
|
230
|
+
* validatorToken: '0x...',
|
|
231
|
+
* amountOut: 100n,
|
|
232
|
+
* to: '0x...',
|
|
233
|
+
* })
|
|
234
|
+
* ```
|
|
235
|
+
*
|
|
236
|
+
* @param config - Config.
|
|
237
|
+
* @param parameters - Parameters.
|
|
238
|
+
* @returns The transaction hash.
|
|
239
|
+
*/
|
|
240
|
+
export async function rebalanceSwap<config extends Config>(
|
|
241
|
+
config: config,
|
|
242
|
+
parameters: rebalanceSwap.Parameters<config>,
|
|
243
|
+
): Promise<Actions.amm.rebalanceSwap.ReturnValue> {
|
|
244
|
+
const { account, chainId, connector } = parameters
|
|
245
|
+
|
|
246
|
+
const client = await getConnectorClient(config, {
|
|
247
|
+
account,
|
|
248
|
+
assertChainId: false,
|
|
249
|
+
chainId,
|
|
250
|
+
connector,
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
return Actions.amm.rebalanceSwap(client, parameters as never)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export declare namespace rebalanceSwap {
|
|
257
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
258
|
+
ConnectorParameter &
|
|
259
|
+
UnionLooseOmit<
|
|
260
|
+
Actions.amm.rebalanceSwap.Parameters<config['chains'][number], Account>,
|
|
261
|
+
'chain'
|
|
262
|
+
>
|
|
263
|
+
|
|
264
|
+
export type ReturnValue = Actions.amm.rebalanceSwap.ReturnValue
|
|
265
|
+
|
|
266
|
+
export type ErrorType = BaseErrorType
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Performs a rebalance swap from validator token to user token.
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```ts
|
|
274
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
275
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
276
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
277
|
+
*
|
|
278
|
+
* const config = createConfig({
|
|
279
|
+
* chains: [tempoTestnet],
|
|
280
|
+
* transports: {
|
|
281
|
+
* [tempo.id]: http(),
|
|
282
|
+
* },
|
|
283
|
+
* })
|
|
284
|
+
*
|
|
285
|
+
* const result = await Actions.amm.rebalanceSwapSync(config, {
|
|
286
|
+
* userToken: '0x...',
|
|
287
|
+
* validatorToken: '0x...',
|
|
288
|
+
* amountOut: 100n,
|
|
289
|
+
* to: '0x...',
|
|
290
|
+
* })
|
|
291
|
+
* ```
|
|
292
|
+
*
|
|
293
|
+
* @param config - Config.
|
|
294
|
+
* @param parameters - Parameters.
|
|
295
|
+
* @returns The transaction receipt and event data.
|
|
296
|
+
*/
|
|
297
|
+
export async function rebalanceSwapSync<config extends Config>(
|
|
298
|
+
config: config,
|
|
299
|
+
parameters: rebalanceSwapSync.Parameters<config>,
|
|
300
|
+
): Promise<Actions.amm.rebalanceSwapSync.ReturnValue> {
|
|
301
|
+
const { account, chainId, connector } = parameters
|
|
302
|
+
|
|
303
|
+
const client = await getConnectorClient(config, {
|
|
304
|
+
account,
|
|
305
|
+
assertChainId: false,
|
|
306
|
+
chainId,
|
|
307
|
+
connector,
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
return Actions.amm.rebalanceSwapSync(client, parameters as never)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export declare namespace rebalanceSwapSync {
|
|
314
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
315
|
+
ConnectorParameter &
|
|
316
|
+
UnionLooseOmit<
|
|
317
|
+
Actions.amm.rebalanceSwapSync.Parameters<
|
|
318
|
+
config['chains'][number],
|
|
319
|
+
Account
|
|
320
|
+
>,
|
|
321
|
+
'chain'
|
|
322
|
+
>
|
|
323
|
+
|
|
324
|
+
export type ReturnValue = Actions.amm.rebalanceSwapSync.ReturnValue
|
|
325
|
+
|
|
326
|
+
export type ErrorType = BaseErrorType
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Adds liquidity to a pool.
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* ```ts
|
|
334
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
335
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
336
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
337
|
+
*
|
|
338
|
+
* const config = createConfig({
|
|
339
|
+
* chains: [tempoTestnet],
|
|
340
|
+
* transports: {
|
|
341
|
+
* [tempo.id]: http(),
|
|
342
|
+
* },
|
|
343
|
+
* })
|
|
344
|
+
*
|
|
345
|
+
* const hash = await Actions.amm.mint(config, {
|
|
346
|
+
* userTokenAddress: '0x20c0...beef',
|
|
347
|
+
* validatorTokenAddress: '0x20c0...babe',
|
|
348
|
+
* validatorTokenAmount: 100n,
|
|
349
|
+
* to: '0xfeed...fede',
|
|
350
|
+
* })
|
|
351
|
+
* ```
|
|
352
|
+
*
|
|
353
|
+
* @param config - Config.
|
|
354
|
+
* @param parameters - Parameters.
|
|
355
|
+
* @returns The transaction hash.
|
|
356
|
+
*/
|
|
357
|
+
export async function mint<config extends Config>(
|
|
358
|
+
config: config,
|
|
359
|
+
parameters: mint.Parameters<config>,
|
|
360
|
+
): Promise<Actions.amm.mint.ReturnValue> {
|
|
361
|
+
const { account, chainId, connector } = parameters
|
|
362
|
+
|
|
363
|
+
const client = await getConnectorClient(config, {
|
|
364
|
+
account,
|
|
365
|
+
assertChainId: false,
|
|
366
|
+
chainId,
|
|
367
|
+
connector,
|
|
368
|
+
})
|
|
369
|
+
|
|
370
|
+
return Actions.amm.mint(client, parameters as never)
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export declare namespace mint {
|
|
374
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
375
|
+
ConnectorParameter &
|
|
376
|
+
UnionLooseOmit<
|
|
377
|
+
Actions.amm.mint.Parameters<config['chains'][number], Account>,
|
|
378
|
+
'chain'
|
|
379
|
+
>
|
|
380
|
+
|
|
381
|
+
export type ReturnValue = Actions.amm.mint.ReturnValue
|
|
382
|
+
|
|
383
|
+
export type ErrorType = BaseErrorType
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Adds liquidity to a pool.
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```ts
|
|
391
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
392
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
393
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
394
|
+
*
|
|
395
|
+
* const config = createConfig({
|
|
396
|
+
* chains: [tempoTestnet],
|
|
397
|
+
* transports: {
|
|
398
|
+
* [tempo.id]: http(),
|
|
399
|
+
* },
|
|
400
|
+
* })
|
|
401
|
+
*
|
|
402
|
+
* const result = await Actions.amm.mintSync(config, {
|
|
403
|
+
* userTokenAddress: '0x20c0...beef',
|
|
404
|
+
* validatorTokenAddress: '0x20c0...babe',
|
|
405
|
+
* validatorTokenAmount: 100n,
|
|
406
|
+
* to: '0xfeed...fede',
|
|
407
|
+
* })
|
|
408
|
+
* ```
|
|
409
|
+
*
|
|
410
|
+
* @param config - Config.
|
|
411
|
+
* @param parameters - Parameters.
|
|
412
|
+
* @returns The transaction receipt and event data.
|
|
413
|
+
*/
|
|
414
|
+
export async function mintSync<config extends Config>(
|
|
415
|
+
config: config,
|
|
416
|
+
parameters: mintSync.Parameters<config>,
|
|
417
|
+
): Promise<Actions.amm.mintSync.ReturnValue> {
|
|
418
|
+
const { account, chainId, connector } = parameters
|
|
419
|
+
|
|
420
|
+
const client = await getConnectorClient(config, {
|
|
421
|
+
account,
|
|
422
|
+
assertChainId: false,
|
|
423
|
+
chainId,
|
|
424
|
+
connector,
|
|
425
|
+
})
|
|
426
|
+
|
|
427
|
+
return Actions.amm.mintSync(client, parameters as never)
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export declare namespace mintSync {
|
|
431
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
432
|
+
ConnectorParameter &
|
|
433
|
+
UnionLooseOmit<
|
|
434
|
+
Actions.amm.mintSync.Parameters<config['chains'][number], Account>,
|
|
435
|
+
'chain'
|
|
436
|
+
>
|
|
437
|
+
|
|
438
|
+
export type ReturnValue = Actions.amm.mintSync.ReturnValue
|
|
439
|
+
|
|
440
|
+
export type ErrorType = BaseErrorType
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Removes liquidity from a pool.
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* ```ts
|
|
448
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
449
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
450
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
451
|
+
*
|
|
452
|
+
* const config = createConfig({
|
|
453
|
+
* chains: [tempoTestnet],
|
|
454
|
+
* transports: {
|
|
455
|
+
* [tempo.id]: http(),
|
|
456
|
+
* },
|
|
457
|
+
* })
|
|
458
|
+
*
|
|
459
|
+
* const hash = await Actions.amm.burn(config, {
|
|
460
|
+
* userToken: '0x20c0...beef',
|
|
461
|
+
* validatorToken: '0x20c0...babe',
|
|
462
|
+
* liquidity: 50n,
|
|
463
|
+
* to: '0xfeed...fede',
|
|
464
|
+
* })
|
|
465
|
+
* ```
|
|
466
|
+
*
|
|
467
|
+
* @param config - Config.
|
|
468
|
+
* @param parameters - Parameters.
|
|
469
|
+
* @returns The transaction hash.
|
|
470
|
+
*/
|
|
471
|
+
export async function burn<config extends Config>(
|
|
472
|
+
config: config,
|
|
473
|
+
parameters: burn.Parameters<config>,
|
|
474
|
+
): Promise<Actions.amm.burn.ReturnValue> {
|
|
475
|
+
const { account, chainId, connector } = parameters
|
|
476
|
+
|
|
477
|
+
const client = await getConnectorClient(config, {
|
|
478
|
+
account,
|
|
479
|
+
assertChainId: false,
|
|
480
|
+
chainId,
|
|
481
|
+
connector,
|
|
482
|
+
})
|
|
483
|
+
|
|
484
|
+
return Actions.amm.burn(client, parameters as never)
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
export declare namespace burn {
|
|
488
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
489
|
+
ConnectorParameter &
|
|
490
|
+
UnionLooseOmit<
|
|
491
|
+
Actions.amm.burn.Parameters<config['chains'][number], Account>,
|
|
492
|
+
'chain'
|
|
493
|
+
>
|
|
494
|
+
|
|
495
|
+
export type ReturnValue = Actions.amm.burn.ReturnValue
|
|
496
|
+
|
|
497
|
+
export type ErrorType = BaseErrorType
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Removes liquidity from a pool.
|
|
502
|
+
*
|
|
503
|
+
* @example
|
|
504
|
+
* ```ts
|
|
505
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
506
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
507
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
508
|
+
*
|
|
509
|
+
* const config = createConfig({
|
|
510
|
+
* chains: [tempoTestnet],
|
|
511
|
+
* transports: {
|
|
512
|
+
* [tempo.id]: http(),
|
|
513
|
+
* },
|
|
514
|
+
* })
|
|
515
|
+
*
|
|
516
|
+
* const result = await Actions.amm.burnSync(config, {
|
|
517
|
+
* userToken: '0x20c0...beef',
|
|
518
|
+
* validatorToken: '0x20c0...babe',
|
|
519
|
+
* liquidity: 50n,
|
|
520
|
+
* to: '0xfeed...fede',
|
|
521
|
+
* })
|
|
522
|
+
* ```
|
|
523
|
+
*
|
|
524
|
+
* @param config - Config.
|
|
525
|
+
* @param parameters - Parameters.
|
|
526
|
+
* @returns The transaction receipt and event data.
|
|
527
|
+
*/
|
|
528
|
+
export async function burnSync<config extends Config>(
|
|
529
|
+
config: config,
|
|
530
|
+
parameters: burnSync.Parameters<config>,
|
|
531
|
+
): Promise<Actions.amm.burnSync.ReturnValue> {
|
|
532
|
+
const { account, chainId, connector } = parameters
|
|
533
|
+
|
|
534
|
+
const client = await getConnectorClient(config, {
|
|
535
|
+
account,
|
|
536
|
+
assertChainId: false,
|
|
537
|
+
chainId,
|
|
538
|
+
connector,
|
|
539
|
+
})
|
|
540
|
+
|
|
541
|
+
return Actions.amm.burnSync(client, parameters as never)
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
export declare namespace burnSync {
|
|
545
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
546
|
+
ConnectorParameter &
|
|
547
|
+
UnionLooseOmit<
|
|
548
|
+
Actions.amm.burnSync.Parameters<config['chains'][number], Account>,
|
|
549
|
+
'chain'
|
|
550
|
+
>
|
|
551
|
+
|
|
552
|
+
export type ReturnValue = Actions.amm.burnSync.ReturnValue
|
|
553
|
+
|
|
554
|
+
export type ErrorType = BaseErrorType
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Watches for rebalance swap events.
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* ```ts
|
|
562
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
563
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
564
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
565
|
+
*
|
|
566
|
+
* const config = createConfig({
|
|
567
|
+
* chains: [tempoTestnet],
|
|
568
|
+
* transports: {
|
|
569
|
+
* [tempo.id]: http(),
|
|
570
|
+
* },
|
|
571
|
+
* })
|
|
572
|
+
*
|
|
573
|
+
* const unwatch = Actions.amm.watchRebalanceSwap(config, {
|
|
574
|
+
* onRebalanceSwap: (args, log) => {
|
|
575
|
+
* console.log('Rebalance swap:', args)
|
|
576
|
+
* },
|
|
577
|
+
* })
|
|
578
|
+
* ```
|
|
579
|
+
*
|
|
580
|
+
* @param config - Config.
|
|
581
|
+
* @param parameters - Parameters.
|
|
582
|
+
* @returns A function to unsubscribe from the event.
|
|
583
|
+
*/
|
|
584
|
+
export function watchRebalanceSwap<config extends Config>(
|
|
585
|
+
config: config,
|
|
586
|
+
parameters: watchRebalanceSwap.Parameters<config>,
|
|
587
|
+
) {
|
|
588
|
+
const { chainId, ...rest } = parameters
|
|
589
|
+
const client = config.getClient({ chainId })
|
|
590
|
+
return Actions.amm.watchRebalanceSwap(client, rest)
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
export declare namespace watchRebalanceSwap {
|
|
594
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
595
|
+
Actions.amm.watchRebalanceSwap.Parameters
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Watches for fee swap events.
|
|
600
|
+
*
|
|
601
|
+
* @example
|
|
602
|
+
* ```ts
|
|
603
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
604
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
605
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
606
|
+
*
|
|
607
|
+
* const config = createConfig({
|
|
608
|
+
* chains: [tempoTestnet],
|
|
609
|
+
* transports: {
|
|
610
|
+
* [tempo.id]: http(),
|
|
611
|
+
* },
|
|
612
|
+
* })
|
|
613
|
+
*
|
|
614
|
+
* const unwatch = Actions.amm.watchFeeSwap(config, {
|
|
615
|
+
* onFeeSwap: (args, log) => {
|
|
616
|
+
* console.log('Fee swap:', args)
|
|
617
|
+
* },
|
|
618
|
+
* })
|
|
619
|
+
* ```
|
|
620
|
+
*
|
|
621
|
+
* @param config - Config.
|
|
622
|
+
* @param parameters - Parameters.
|
|
623
|
+
* @returns A function to unsubscribe from the event.
|
|
624
|
+
*/
|
|
625
|
+
export function watchFeeSwap<config extends Config>(
|
|
626
|
+
config: config,
|
|
627
|
+
parameters: watchFeeSwap.Parameters<config>,
|
|
628
|
+
) {
|
|
629
|
+
const { chainId, ...rest } = parameters
|
|
630
|
+
const client = config.getClient({ chainId })
|
|
631
|
+
return Actions.amm.watchFeeSwap(client, rest)
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
export declare namespace watchFeeSwap {
|
|
635
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
636
|
+
Actions.amm.watchFeeSwap.Parameters
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Watches for liquidity mint events.
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
* ```ts
|
|
644
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
645
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
646
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
647
|
+
*
|
|
648
|
+
* const config = createConfig({
|
|
649
|
+
* chains: [tempoTestnet],
|
|
650
|
+
* transports: {
|
|
651
|
+
* [tempo.id]: http(),
|
|
652
|
+
* },
|
|
653
|
+
* })
|
|
654
|
+
*
|
|
655
|
+
* const unwatch = Actions.amm.watchMint(config, {
|
|
656
|
+
* onMint: (args, log) => {
|
|
657
|
+
* console.log('Liquidity added:', args)
|
|
658
|
+
* },
|
|
659
|
+
* })
|
|
660
|
+
* ```
|
|
661
|
+
*
|
|
662
|
+
* @param config - Config.
|
|
663
|
+
* @param parameters - Parameters.
|
|
664
|
+
* @returns A function to unsubscribe from the event.
|
|
665
|
+
*/
|
|
666
|
+
export function watchMint<config extends Config>(
|
|
667
|
+
config: config,
|
|
668
|
+
parameters: watchMint.Parameters<config>,
|
|
669
|
+
) {
|
|
670
|
+
const { chainId, ...rest } = parameters
|
|
671
|
+
const client = config.getClient({ chainId })
|
|
672
|
+
return Actions.amm.watchMint(client, rest)
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
export declare namespace watchMint {
|
|
676
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
677
|
+
Actions.amm.watchMint.Parameters
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Watches for liquidity burn events.
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
* ```ts
|
|
685
|
+
* import { createConfig, http } from '@wagmi/core'
|
|
686
|
+
* import { tempo } from '@wagmi/core/chains'
|
|
687
|
+
* import { Actions } from '@wagmi/core/tempo'
|
|
688
|
+
*
|
|
689
|
+
* const config = createConfig({
|
|
690
|
+
* chains: [tempoTestnet],
|
|
691
|
+
* transports: {
|
|
692
|
+
* [tempo.id]: http(),
|
|
693
|
+
* },
|
|
694
|
+
* })
|
|
695
|
+
*
|
|
696
|
+
* const unwatch = Actions.amm.watchBurn(config, {
|
|
697
|
+
* onBurn: (args, log) => {
|
|
698
|
+
* console.log('Liquidity removed:', args)
|
|
699
|
+
* },
|
|
700
|
+
* })
|
|
701
|
+
* ```
|
|
702
|
+
*
|
|
703
|
+
* @param config - Config.
|
|
704
|
+
* @param parameters - Parameters.
|
|
705
|
+
* @returns A function to unsubscribe from the event.
|
|
706
|
+
*/
|
|
707
|
+
export function watchBurn<config extends Config>(
|
|
708
|
+
config: config,
|
|
709
|
+
parameters: watchBurn.Parameters<config>,
|
|
710
|
+
) {
|
|
711
|
+
const { chainId, ...rest } = parameters
|
|
712
|
+
const client = config.getClient({ chainId })
|
|
713
|
+
return Actions.amm.watchBurn(client, rest)
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
export declare namespace watchBurn {
|
|
717
|
+
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
718
|
+
Actions.amm.watchBurn.Parameters
|
|
719
|
+
}
|