@wagmi/core 3.0.2 → 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.
Files changed (83) hide show
  1. package/dist/esm/exports/internal.js.map +1 -1
  2. package/dist/esm/exports/query.js +1 -1
  3. package/dist/esm/exports/query.js.map +1 -1
  4. package/dist/esm/exports/tempo.js +9 -0
  5. package/dist/esm/exports/tempo.js.map +1 -0
  6. package/dist/esm/tempo/Connectors.js +534 -0
  7. package/dist/esm/tempo/Connectors.js.map +1 -0
  8. package/dist/esm/tempo/KeyManager.js +106 -0
  9. package/dist/esm/tempo/KeyManager.js.map +1 -0
  10. package/dist/esm/tempo/actions/amm.js +437 -0
  11. package/dist/esm/tempo/actions/amm.js.map +1 -0
  12. package/dist/esm/tempo/actions/dex.js +1059 -0
  13. package/dist/esm/tempo/actions/dex.js.map +1 -0
  14. package/dist/esm/tempo/actions/faucet.js +64 -0
  15. package/dist/esm/tempo/actions/faucet.js.map +1 -0
  16. package/dist/esm/tempo/actions/fee.js +160 -0
  17. package/dist/esm/tempo/actions/fee.js.map +1 -0
  18. package/dist/esm/tempo/actions/index.js +11 -0
  19. package/dist/esm/tempo/actions/index.js.map +1 -0
  20. package/dist/esm/tempo/actions/nonce.js +91 -0
  21. package/dist/esm/tempo/actions/nonce.js.map +1 -0
  22. package/dist/esm/tempo/actions/policy.js +532 -0
  23. package/dist/esm/tempo/actions/policy.js.map +1 -0
  24. package/dist/esm/tempo/actions/reward.js +384 -0
  25. package/dist/esm/tempo/actions/reward.js.map +1 -0
  26. package/dist/esm/tempo/actions/token.js +1717 -0
  27. package/dist/esm/tempo/actions/token.js.map +1 -0
  28. package/dist/esm/tempo/actions/utils.js +2 -0
  29. package/dist/esm/tempo/actions/utils.js.map +1 -0
  30. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  31. package/dist/esm/version.js +1 -1
  32. package/dist/types/exports/internal.d.ts +1 -1
  33. package/dist/types/exports/internal.d.ts.map +1 -1
  34. package/dist/types/exports/query.d.ts +1 -1
  35. package/dist/types/exports/query.d.ts.map +1 -1
  36. package/dist/types/exports/tempo.d.ts +5 -0
  37. package/dist/types/exports/tempo.d.ts.map +1 -0
  38. package/dist/types/tempo/Connectors.d.ts +99 -0
  39. package/dist/types/tempo/Connectors.d.ts.map +1 -0
  40. package/dist/types/tempo/KeyManager.d.ts +71 -0
  41. package/dist/types/tempo/KeyManager.d.ts.map +1 -0
  42. package/dist/types/tempo/actions/amm.d.ts +387 -0
  43. package/dist/types/tempo/actions/amm.d.ts.map +1 -0
  44. package/dist/types/tempo/actions/dex.d.ts +926 -0
  45. package/dist/types/tempo/actions/dex.d.ts.map +1 -0
  46. package/dist/types/tempo/actions/faucet.d.ts +70 -0
  47. package/dist/types/tempo/actions/faucet.d.ts.map +1 -0
  48. package/dist/types/tempo/actions/fee.d.ts +141 -0
  49. package/dist/types/tempo/actions/fee.d.ts.map +1 -0
  50. package/dist/types/tempo/actions/index.d.ts +10 -0
  51. package/dist/types/tempo/actions/index.d.ts.map +1 -0
  52. package/dist/types/tempo/actions/nonce.d.ts +79 -0
  53. package/dist/types/tempo/actions/nonce.d.ts.map +1 -0
  54. package/dist/types/tempo/actions/policy.d.ts +478 -0
  55. package/dist/types/tempo/actions/policy.d.ts.map +1 -0
  56. package/dist/types/tempo/actions/reward.d.ts +340 -0
  57. package/dist/types/tempo/actions/reward.d.ts.map +1 -0
  58. package/dist/types/tempo/actions/token.d.ts +1531 -0
  59. package/dist/types/tempo/actions/token.d.ts.map +1 -0
  60. package/dist/types/tempo/actions/utils.d.ts +9 -0
  61. package/dist/types/tempo/actions/utils.d.ts.map +1 -0
  62. package/dist/types/types/utils.d.ts +16 -0
  63. package/dist/types/types/utils.d.ts.map +1 -1
  64. package/dist/types/version.d.ts +1 -1
  65. package/package.json +14 -2
  66. package/src/exports/internal.ts +3 -0
  67. package/src/exports/query.ts +4 -1
  68. package/src/exports/tempo.ts +14 -0
  69. package/src/tempo/Connectors.ts +762 -0
  70. package/src/tempo/KeyManager.ts +176 -0
  71. package/src/tempo/actions/amm.ts +678 -0
  72. package/src/tempo/actions/dex.ts +1685 -0
  73. package/src/tempo/actions/faucet.ts +95 -0
  74. package/src/tempo/actions/fee.ts +259 -0
  75. package/src/tempo/actions/index.ts +10 -0
  76. package/src/tempo/actions/nonce.ts +147 -0
  77. package/src/tempo/actions/policy.ts +827 -0
  78. package/src/tempo/actions/reward.ts +624 -0
  79. package/src/tempo/actions/token.ts +2598 -0
  80. package/src/tempo/actions/utils.ts +26 -0
  81. package/src/types/utils.ts +19 -0
  82. package/src/version.ts +1 -1
  83. package/tempo/package.json +5 -0
@@ -0,0 +1,106 @@
1
+ import * as Json from 'ox/Json';
2
+ import { createStorage, } from '../createStorage.js';
3
+ /** Instantiates a key manager. */
4
+ export function from(manager) {
5
+ return manager;
6
+ }
7
+ /** Instantiates a key manager from a Storage instance. */
8
+ export function fromStorage(storage) {
9
+ return from({
10
+ async getPublicKey(parameters) {
11
+ const publicKey = await storage.getItem(parameters.credential.id);
12
+ if (!publicKey)
13
+ throw new Error('publicKey not found.');
14
+ return publicKey;
15
+ },
16
+ async setPublicKey(parameters) {
17
+ await storage.setItem(parameters.credential.id, parameters.publicKey);
18
+ },
19
+ });
20
+ }
21
+ /**
22
+ * Instantiates a key manager from a localStorage instance.
23
+ *
24
+ * WARNING: Do not use this in production.
25
+ * This is because we are unable to extract a user's public key after the registration
26
+ * process. If a user clears their storage, or visits the website on a different device,
27
+ * they will not be able to access their account.
28
+ *
29
+ * Instead, we recommend to set up a remote store such as [`KeyManager.http`](#http) to register
30
+ * public keys against their WebAuthn credential.
31
+ *
32
+ * @see {@link http}
33
+ *
34
+ * @deprecated
35
+ */
36
+ export function localStorage(options = {}) {
37
+ const { key = 'wagmi.keyManager' } = options;
38
+ const storage = createStorage({
39
+ ...options,
40
+ key,
41
+ storage: typeof window !== 'undefined' ? window.localStorage : undefined,
42
+ });
43
+ return fromStorage(storage);
44
+ }
45
+ /**
46
+ * Instantiates a key manager that uses HTTP endpoints for credential management.
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * import { KeyManager } from '@wagmi/core/tempo'
51
+ *
52
+ * const keyManager = KeyManager.http('https://api.example.com')
53
+ * ```
54
+ *
55
+ * @param url - The URL to use for the HTTP endpoints.
56
+ * @param options - Configuration options for HTTP endpoints.
57
+ * @returns A KeyManager instance that uses HTTP for credential operations.
58
+ */
59
+ export function http(url, options = {}) {
60
+ const { fetch: fetchFn = globalThis.fetch } = options;
61
+ const { getChallenge, getPublicKey, setPublicKey } = (() => {
62
+ const base = typeof url === 'string' ? url : '';
63
+ const urls = typeof url === 'object' ? url : {};
64
+ return {
65
+ getChallenge: urls.getChallenge ?? `${base}/challenge`,
66
+ getPublicKey: urls.getPublicKey ?? `${base}/:credentialId`,
67
+ setPublicKey: urls.setPublicKey ?? `${base}/:credentialId`,
68
+ };
69
+ })();
70
+ return from({
71
+ async getChallenge() {
72
+ const request = getChallenge instanceof Request
73
+ ? getChallenge
74
+ : new Request(getChallenge);
75
+ const response = await fetchFn(request);
76
+ if (!response.ok)
77
+ throw new Error(`Failed to get create options: ${response.statusText}`);
78
+ return await response.json();
79
+ },
80
+ async getPublicKey(parameters) {
81
+ const request = getPublicKey instanceof Request
82
+ ? getPublicKey
83
+ : new Request(getPublicKey);
84
+ const response = await fetchFn(new Request(request.url.replace(':credentialId', parameters.credential.id), request));
85
+ if (!response.ok)
86
+ throw new Error(`Failed to get public key: ${response.statusText}`);
87
+ const data = await response.json();
88
+ return data.publicKey;
89
+ },
90
+ async setPublicKey(parameters) {
91
+ const request = setPublicKey instanceof Request
92
+ ? setPublicKey
93
+ : new Request(setPublicKey);
94
+ const response = await fetchFn(new Request(request.url.replace(':credentialId', parameters.credential.id), request), {
95
+ method: 'POST',
96
+ headers: {
97
+ 'Content-Type': 'application/json',
98
+ },
99
+ body: Json.stringify(parameters),
100
+ });
101
+ if (!response.ok)
102
+ throw new Error(`Failed to set public key: ${response.statusText}`);
103
+ },
104
+ });
105
+ }
106
+ //# sourceMappingURL=KeyManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyManager.js","sourceRoot":"","sources":["../../../src/tempo/KeyManager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,SAAS,CAAA;AAC/B,OAAO,EAEL,aAAa,GAEd,MAAM,qBAAqB,CAAA;AAqB5B,kCAAkC;AAClC,MAAM,UAAU,IAAI,CAA6B,OAAgB;IAC/D,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,OAAO,IAAI,CAAC;QACV,KAAK,CAAC,YAAY,CAAC,UAAU;YAC3B,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;YACjE,IAAI,CAAC,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;YACvD,OAAO,SAAoB,CAAA;QAC7B,CAAC;QACD,KAAK,CAAC,YAAY,CAAC,UAAU;YAC3B,MAAM,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;QACvE,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,YAAY,CAAC,UAAgC,EAAE;IAC7D,MAAM,EAAE,GAAG,GAAG,kBAAkB,EAAE,GAAG,OAAO,CAAA;IAC5C,MAAM,OAAO,GAAG,aAAa,CAAC;QAC5B,GAAG,OAAO;QACV,GAAG;QACH,OAAO,EAAE,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;KACzE,CAAC,CAAA;IACF,OAAO,WAAW,CAAC,OAAO,CAAC,CAAA;AAC7B,CAAC;AAMD;;;;;;;;;;;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C,CAAA;YAE/B,MAAM,QAAQ,GAAG,MAAM,OAAO,CAC5B,IAAI,OAAO,CACT,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,EAC9D,OAAO,CACR,CACF,CAAA;YAED,IAAI,CAAC,QAAQ,CAAC,EAAE;gBACd,MAAM,IAAI,KAAK,CAAC,6BAA6B,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;YACrE,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;YAClC,OAAO,IAAI,CAAC,SAAoB,CAAA;QAClC,CAAC;QAED,KAAK,CAAC,YAAY,CAAC,UAAU;YAC3B,MAAM,OAAO,GACX,YAAY,YAAY,OAAO;gBAC7B,CAAC,CAAC,YAAY;gBACd,CAAC,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC,CAAA;YAE/B,MAAM,QAAQ,GAAG,MAAM,OAAO,CAC5B,IAAI,OAAO,CACT,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,EAC9D,OAAO,CACR,EACD;gBACE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;aACjC,CACF,CAAA;YAED,IAAI,CAAC,QAAQ,CAAC,EAAE;gBACd,MAAM,IAAI,KAAK,CAAC,6BAA6B,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;QACvE,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,437 @@
1
+ import { Actions } from 'viem/tempo';
2
+ import { getConnectorClient } from '../../actions/getConnectorClient.js';
3
+ import { filterQueryOptions } from '../../query/utils.js';
4
+ /**
5
+ * Gets the reserves for a liquidity pool.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { createConfig, http } from '@wagmi/core'
10
+ * import { tempo } from '@wagmi/core/chains'
11
+ * import { Actions } from '@wagmi/core/tempo'
12
+ *
13
+ * const config = createConfig({
14
+ * chains: [tempoModerato],
15
+ * transports: {
16
+ * [tempo.id]: http(),
17
+ * },
18
+ * })
19
+ *
20
+ * const pool = await Actions.amm.getPool(config, {
21
+ * userToken: '0x...',
22
+ * validatorToken: '0x...',
23
+ * })
24
+ * ```
25
+ *
26
+ * @param config - Config.
27
+ * @param parameters - Parameters.
28
+ * @returns The pool reserves.
29
+ */
30
+ export function getPool(config, parameters) {
31
+ const { chainId, ...rest } = parameters;
32
+ const client = config.getClient({ chainId });
33
+ return Actions.amm.getPool(client, rest);
34
+ }
35
+ (function (getPool) {
36
+ function queryKey(parameters) {
37
+ return ['getPool', filterQueryOptions(parameters)];
38
+ }
39
+ getPool.queryKey = queryKey;
40
+ function queryOptions(config, parameters) {
41
+ const { query, ...rest } = parameters;
42
+ return {
43
+ ...query,
44
+ enabled: Boolean(rest.userToken && rest.validatorToken && (query?.enabled ?? true)),
45
+ queryKey: queryKey(rest),
46
+ async queryFn({ queryKey }) {
47
+ const [, parameters] = queryKey;
48
+ return await getPool(config, parameters);
49
+ },
50
+ };
51
+ }
52
+ getPool.queryOptions = queryOptions;
53
+ })(getPool || (getPool = {}));
54
+ /**
55
+ * Gets the LP token balance for an account in a specific pool.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * import { createConfig, http } from '@wagmi/core'
60
+ * import { tempo } from '@wagmi/core/chains'
61
+ * import { Actions } from '@wagmi/core/tempo'
62
+ *
63
+ * const config = createConfig({
64
+ * chains: [tempoModerato],
65
+ * transports: {
66
+ * [tempo.id]: http(),
67
+ * },
68
+ * })
69
+ *
70
+ * const poolId = await Actions.amm.getPoolId(config, {
71
+ * userToken: '0x...',
72
+ * validatorToken: '0x...',
73
+ * })
74
+ *
75
+ * const balance = await Actions.amm.getLiquidityBalance(config, {
76
+ * poolId,
77
+ * address: '0x...',
78
+ * })
79
+ * ```
80
+ *
81
+ * @param config - Config.
82
+ * @param parameters - Parameters.
83
+ * @returns The LP token balance.
84
+ */
85
+ export function getLiquidityBalance(config, parameters) {
86
+ const { chainId, ...rest } = parameters;
87
+ const client = config.getClient({ chainId });
88
+ return Actions.amm.getLiquidityBalance(client, rest);
89
+ }
90
+ (function (getLiquidityBalance) {
91
+ function queryKey(parameters) {
92
+ return ['getLiquidityBalance', filterQueryOptions(parameters)];
93
+ }
94
+ getLiquidityBalance.queryKey = queryKey;
95
+ function queryOptions(config, parameters) {
96
+ const { query, ...rest } = parameters;
97
+ return {
98
+ ...query,
99
+ enabled: Boolean(rest.address &&
100
+ (rest.poolId ||
101
+ (rest.userToken !== undefined &&
102
+ rest.validatorToken !== undefined)) &&
103
+ (query?.enabled ?? true)),
104
+ queryKey: queryKey(rest),
105
+ async queryFn({ queryKey }) {
106
+ const [, parameters] = queryKey;
107
+ return await getLiquidityBalance(config, parameters);
108
+ },
109
+ };
110
+ }
111
+ getLiquidityBalance.queryOptions = queryOptions;
112
+ })(getLiquidityBalance || (getLiquidityBalance = {}));
113
+ /**
114
+ * Performs a rebalance swap from validator token to user token.
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * import { createConfig, http } from '@wagmi/core'
119
+ * import { tempo } from '@wagmi/core/chains'
120
+ * import { Actions } from '@wagmi/core/tempo'
121
+ *
122
+ * const config = createConfig({
123
+ * chains: [tempoModerato],
124
+ * transports: {
125
+ * [tempo.id]: http(),
126
+ * },
127
+ * })
128
+ *
129
+ * const hash = await Actions.amm.rebalanceSwap(config, {
130
+ * userToken: '0x...',
131
+ * validatorToken: '0x...',
132
+ * amountOut: 100n,
133
+ * to: '0x...',
134
+ * })
135
+ * ```
136
+ *
137
+ * @param config - Config.
138
+ * @param parameters - Parameters.
139
+ * @returns The transaction hash.
140
+ */
141
+ export async function rebalanceSwap(config, parameters) {
142
+ const { account, chainId, connector } = parameters;
143
+ const client = await getConnectorClient(config, {
144
+ account,
145
+ assertChainId: false,
146
+ chainId,
147
+ connector,
148
+ });
149
+ return Actions.amm.rebalanceSwap(client, parameters);
150
+ }
151
+ /**
152
+ * Performs a rebalance swap from validator token to user token.
153
+ *
154
+ * @example
155
+ * ```ts
156
+ * import { createConfig, http } from '@wagmi/core'
157
+ * import { tempo } from '@wagmi/core/chains'
158
+ * import { Actions } from '@wagmi/core/tempo'
159
+ *
160
+ * const config = createConfig({
161
+ * chains: [tempoModerato],
162
+ * transports: {
163
+ * [tempo.id]: http(),
164
+ * },
165
+ * })
166
+ *
167
+ * const result = await Actions.amm.rebalanceSwapSync(config, {
168
+ * userToken: '0x...',
169
+ * validatorToken: '0x...',
170
+ * amountOut: 100n,
171
+ * to: '0x...',
172
+ * })
173
+ * ```
174
+ *
175
+ * @param config - Config.
176
+ * @param parameters - Parameters.
177
+ * @returns The transaction receipt and event data.
178
+ */
179
+ export async function rebalanceSwapSync(config, parameters) {
180
+ const { account, chainId, connector } = parameters;
181
+ const client = await getConnectorClient(config, {
182
+ account,
183
+ assertChainId: false,
184
+ chainId,
185
+ connector,
186
+ });
187
+ return Actions.amm.rebalanceSwapSync(client, parameters);
188
+ }
189
+ /**
190
+ * Adds liquidity to a pool.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * import { createConfig, http } from '@wagmi/core'
195
+ * import { tempo } from '@wagmi/core/chains'
196
+ * import { Actions } from '@wagmi/core/tempo'
197
+ *
198
+ * const config = createConfig({
199
+ * chains: [tempoModerato],
200
+ * transports: {
201
+ * [tempo.id]: http(),
202
+ * },
203
+ * })
204
+ *
205
+ * const hash = await Actions.amm.mint(config, {
206
+ * userTokenAddress: '0x20c0...beef',
207
+ * validatorTokenAddress: '0x20c0...babe',
208
+ * validatorTokenAmount: 100n,
209
+ * to: '0xfeed...fede',
210
+ * })
211
+ * ```
212
+ *
213
+ * @param config - Config.
214
+ * @param parameters - Parameters.
215
+ * @returns The transaction hash.
216
+ */
217
+ export async function mint(config, parameters) {
218
+ const { account, chainId, connector } = parameters;
219
+ const client = await getConnectorClient(config, {
220
+ account,
221
+ assertChainId: false,
222
+ chainId,
223
+ connector,
224
+ });
225
+ return Actions.amm.mint(client, parameters);
226
+ }
227
+ /**
228
+ * Adds liquidity to a pool.
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * import { createConfig, http } from '@wagmi/core'
233
+ * import { tempo } from '@wagmi/core/chains'
234
+ * import { Actions } from '@wagmi/core/tempo'
235
+ *
236
+ * const config = createConfig({
237
+ * chains: [tempoModerato],
238
+ * transports: {
239
+ * [tempo.id]: http(),
240
+ * },
241
+ * })
242
+ *
243
+ * const result = await Actions.amm.mintSync(config, {
244
+ * userTokenAddress: '0x20c0...beef',
245
+ * validatorTokenAddress: '0x20c0...babe',
246
+ * validatorTokenAmount: 100n,
247
+ * to: '0xfeed...fede',
248
+ * })
249
+ * ```
250
+ *
251
+ * @param config - Config.
252
+ * @param parameters - Parameters.
253
+ * @returns The transaction receipt and event data.
254
+ */
255
+ export async function mintSync(config, parameters) {
256
+ const { account, chainId, connector } = parameters;
257
+ const client = await getConnectorClient(config, {
258
+ account,
259
+ assertChainId: false,
260
+ chainId,
261
+ connector,
262
+ });
263
+ return Actions.amm.mintSync(client, parameters);
264
+ }
265
+ /**
266
+ * Removes liquidity from a pool.
267
+ *
268
+ * @example
269
+ * ```ts
270
+ * import { createConfig, http } from '@wagmi/core'
271
+ * import { tempo } from '@wagmi/core/chains'
272
+ * import { Actions } from '@wagmi/core/tempo'
273
+ *
274
+ * const config = createConfig({
275
+ * chains: [tempoModerato],
276
+ * transports: {
277
+ * [tempo.id]: http(),
278
+ * },
279
+ * })
280
+ *
281
+ * const hash = await Actions.amm.burn(config, {
282
+ * userToken: '0x20c0...beef',
283
+ * validatorToken: '0x20c0...babe',
284
+ * liquidity: 50n,
285
+ * to: '0xfeed...fede',
286
+ * })
287
+ * ```
288
+ *
289
+ * @param config - Config.
290
+ * @param parameters - Parameters.
291
+ * @returns The transaction hash.
292
+ */
293
+ export async function burn(config, parameters) {
294
+ const { account, chainId, connector } = parameters;
295
+ const client = await getConnectorClient(config, {
296
+ account,
297
+ assertChainId: false,
298
+ chainId,
299
+ connector,
300
+ });
301
+ return Actions.amm.burn(client, parameters);
302
+ }
303
+ /**
304
+ * Removes liquidity from a pool.
305
+ *
306
+ * @example
307
+ * ```ts
308
+ * import { createConfig, http } from '@wagmi/core'
309
+ * import { tempo } from '@wagmi/core/chains'
310
+ * import { Actions } from '@wagmi/core/tempo'
311
+ *
312
+ * const config = createConfig({
313
+ * chains: [tempoModerato],
314
+ * transports: {
315
+ * [tempo.id]: http(),
316
+ * },
317
+ * })
318
+ *
319
+ * const result = await Actions.amm.burnSync(config, {
320
+ * userToken: '0x20c0...beef',
321
+ * validatorToken: '0x20c0...babe',
322
+ * liquidity: 50n,
323
+ * to: '0xfeed...fede',
324
+ * })
325
+ * ```
326
+ *
327
+ * @param config - Config.
328
+ * @param parameters - Parameters.
329
+ * @returns The transaction receipt and event data.
330
+ */
331
+ export async function burnSync(config, parameters) {
332
+ const { account, chainId, connector } = parameters;
333
+ const client = await getConnectorClient(config, {
334
+ account,
335
+ assertChainId: false,
336
+ chainId,
337
+ connector,
338
+ });
339
+ return Actions.amm.burnSync(client, parameters);
340
+ }
341
+ /**
342
+ * Watches for rebalance swap events.
343
+ *
344
+ * @example
345
+ * ```ts
346
+ * import { createConfig, http } from '@wagmi/core'
347
+ * import { tempo } from '@wagmi/core/chains'
348
+ * import { Actions } from '@wagmi/core/tempo'
349
+ *
350
+ * const config = createConfig({
351
+ * chains: [tempoModerato],
352
+ * transports: {
353
+ * [tempo.id]: http(),
354
+ * },
355
+ * })
356
+ *
357
+ * const unwatch = Actions.amm.watchRebalanceSwap(config, {
358
+ * onRebalanceSwap: (args, log) => {
359
+ * console.log('Rebalance swap:', args)
360
+ * },
361
+ * })
362
+ * ```
363
+ *
364
+ * @param config - Config.
365
+ * @param parameters - Parameters.
366
+ * @returns A function to unsubscribe from the event.
367
+ */
368
+ export function watchRebalanceSwap(config, parameters) {
369
+ const { chainId, ...rest } = parameters;
370
+ const client = config.getClient({ chainId });
371
+ return Actions.amm.watchRebalanceSwap(client, rest);
372
+ }
373
+ /**
374
+ * Watches for liquidity mint events.
375
+ *
376
+ * @example
377
+ * ```ts
378
+ * import { createConfig, http } from '@wagmi/core'
379
+ * import { tempo } from '@wagmi/core/chains'
380
+ * import { Actions } from '@wagmi/core/tempo'
381
+ *
382
+ * const config = createConfig({
383
+ * chains: [tempoModerato],
384
+ * transports: {
385
+ * [tempo.id]: http(),
386
+ * },
387
+ * })
388
+ *
389
+ * const unwatch = Actions.amm.watchMint(config, {
390
+ * onMint: (args, log) => {
391
+ * console.log('Liquidity added:', args)
392
+ * },
393
+ * })
394
+ * ```
395
+ *
396
+ * @param config - Config.
397
+ * @param parameters - Parameters.
398
+ * @returns A function to unsubscribe from the event.
399
+ */
400
+ export function watchMint(config, parameters) {
401
+ const { chainId, ...rest } = parameters;
402
+ const client = config.getClient({ chainId });
403
+ return Actions.amm.watchMint(client, rest);
404
+ }
405
+ /**
406
+ * Watches for liquidity burn events.
407
+ *
408
+ * @example
409
+ * ```ts
410
+ * import { createConfig, http } from '@wagmi/core'
411
+ * import { tempo } from '@wagmi/core/chains'
412
+ * import { Actions } from '@wagmi/core/tempo'
413
+ *
414
+ * const config = createConfig({
415
+ * chains: [tempoModerato],
416
+ * transports: {
417
+ * [tempo.id]: http(),
418
+ * },
419
+ * })
420
+ *
421
+ * const unwatch = Actions.amm.watchBurn(config, {
422
+ * onBurn: (args, log) => {
423
+ * console.log('Liquidity removed:', args)
424
+ * },
425
+ * })
426
+ * ```
427
+ *
428
+ * @param config - Config.
429
+ * @param parameters - Parameters.
430
+ * @returns A function to unsubscribe from the event.
431
+ */
432
+ export function watchBurn(config, parameters) {
433
+ const { chainId, ...rest } = parameters;
434
+ const client = config.getClient({ chainId });
435
+ return Actions.amm.watchBurn(client, rest);
436
+ }
437
+ //# sourceMappingURL=amm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amm.js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