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