@gitmyabi/uni-v2 1.0.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/README.md +108 -0
- package/contracts/UniswapV2Pair_json.d.ts +1160 -0
- package/contracts/UniswapV2Pair_json.js +1235 -0
- package/contracts/UniswapV2Pair_json.ts +1510 -0
- package/contracts/index.d.ts +2 -0
- package/contracts/index.js +7 -0
- package/contracts/index.ts +3 -0
- package/index.d.ts +1 -0
- package/index.js +19 -0
- package/package.json +43 -0
|
@@ -0,0 +1,1510 @@
|
|
|
1
|
+
import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
|
|
2
|
+
import { getContract } from 'viem';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* UniswapV2Pair_json ABI
|
|
6
|
+
*
|
|
7
|
+
* This ABI is typed using viem's type system for full type safety.
|
|
8
|
+
*/
|
|
9
|
+
export const UniswapV2Pair_jsonAbi = [
|
|
10
|
+
{
|
|
11
|
+
"inputs": [],
|
|
12
|
+
"payable": false,
|
|
13
|
+
"stateMutability": "nonpayable",
|
|
14
|
+
"type": "constructor"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"anonymous": false,
|
|
18
|
+
"inputs": [
|
|
19
|
+
{
|
|
20
|
+
"indexed": true,
|
|
21
|
+
"internalType": "address",
|
|
22
|
+
"name": "owner",
|
|
23
|
+
"type": "address"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"indexed": true,
|
|
27
|
+
"internalType": "address",
|
|
28
|
+
"name": "spender",
|
|
29
|
+
"type": "address"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"indexed": false,
|
|
33
|
+
"internalType": "uint256",
|
|
34
|
+
"name": "value",
|
|
35
|
+
"type": "uint256"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"name": "Approval",
|
|
39
|
+
"type": "event"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"anonymous": false,
|
|
43
|
+
"inputs": [
|
|
44
|
+
{
|
|
45
|
+
"indexed": true,
|
|
46
|
+
"internalType": "address",
|
|
47
|
+
"name": "sender",
|
|
48
|
+
"type": "address"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"indexed": false,
|
|
52
|
+
"internalType": "uint256",
|
|
53
|
+
"name": "amount0",
|
|
54
|
+
"type": "uint256"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"indexed": false,
|
|
58
|
+
"internalType": "uint256",
|
|
59
|
+
"name": "amount1",
|
|
60
|
+
"type": "uint256"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"indexed": true,
|
|
64
|
+
"internalType": "address",
|
|
65
|
+
"name": "to",
|
|
66
|
+
"type": "address"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"name": "Burn",
|
|
70
|
+
"type": "event"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"anonymous": false,
|
|
74
|
+
"inputs": [
|
|
75
|
+
{
|
|
76
|
+
"indexed": true,
|
|
77
|
+
"internalType": "address",
|
|
78
|
+
"name": "sender",
|
|
79
|
+
"type": "address"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"indexed": false,
|
|
83
|
+
"internalType": "uint256",
|
|
84
|
+
"name": "amount0",
|
|
85
|
+
"type": "uint256"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"indexed": false,
|
|
89
|
+
"internalType": "uint256",
|
|
90
|
+
"name": "amount1",
|
|
91
|
+
"type": "uint256"
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"name": "Mint",
|
|
95
|
+
"type": "event"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"anonymous": false,
|
|
99
|
+
"inputs": [
|
|
100
|
+
{
|
|
101
|
+
"indexed": true,
|
|
102
|
+
"internalType": "address",
|
|
103
|
+
"name": "sender",
|
|
104
|
+
"type": "address"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"indexed": false,
|
|
108
|
+
"internalType": "uint256",
|
|
109
|
+
"name": "amount0In",
|
|
110
|
+
"type": "uint256"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"indexed": false,
|
|
114
|
+
"internalType": "uint256",
|
|
115
|
+
"name": "amount1In",
|
|
116
|
+
"type": "uint256"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"indexed": false,
|
|
120
|
+
"internalType": "uint256",
|
|
121
|
+
"name": "amount0Out",
|
|
122
|
+
"type": "uint256"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"indexed": false,
|
|
126
|
+
"internalType": "uint256",
|
|
127
|
+
"name": "amount1Out",
|
|
128
|
+
"type": "uint256"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"indexed": true,
|
|
132
|
+
"internalType": "address",
|
|
133
|
+
"name": "to",
|
|
134
|
+
"type": "address"
|
|
135
|
+
}
|
|
136
|
+
],
|
|
137
|
+
"name": "Swap",
|
|
138
|
+
"type": "event"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"anonymous": false,
|
|
142
|
+
"inputs": [
|
|
143
|
+
{
|
|
144
|
+
"indexed": false,
|
|
145
|
+
"internalType": "uint112",
|
|
146
|
+
"name": "reserve0",
|
|
147
|
+
"type": "uint112"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"indexed": false,
|
|
151
|
+
"internalType": "uint112",
|
|
152
|
+
"name": "reserve1",
|
|
153
|
+
"type": "uint112"
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"name": "Sync",
|
|
157
|
+
"type": "event"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"anonymous": false,
|
|
161
|
+
"inputs": [
|
|
162
|
+
{
|
|
163
|
+
"indexed": true,
|
|
164
|
+
"internalType": "address",
|
|
165
|
+
"name": "from",
|
|
166
|
+
"type": "address"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"indexed": true,
|
|
170
|
+
"internalType": "address",
|
|
171
|
+
"name": "to",
|
|
172
|
+
"type": "address"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"indexed": false,
|
|
176
|
+
"internalType": "uint256",
|
|
177
|
+
"name": "value",
|
|
178
|
+
"type": "uint256"
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
"name": "Transfer",
|
|
182
|
+
"type": "event"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"constant": true,
|
|
186
|
+
"inputs": [],
|
|
187
|
+
"name": "DOMAIN_SEPARATOR",
|
|
188
|
+
"outputs": [
|
|
189
|
+
{
|
|
190
|
+
"internalType": "bytes32",
|
|
191
|
+
"name": "",
|
|
192
|
+
"type": "bytes32"
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
"payable": false,
|
|
196
|
+
"stateMutability": "view",
|
|
197
|
+
"type": "function"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"constant": true,
|
|
201
|
+
"inputs": [],
|
|
202
|
+
"name": "MINIMUM_LIQUIDITY",
|
|
203
|
+
"outputs": [
|
|
204
|
+
{
|
|
205
|
+
"internalType": "uint256",
|
|
206
|
+
"name": "",
|
|
207
|
+
"type": "uint256"
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
"payable": false,
|
|
211
|
+
"stateMutability": "view",
|
|
212
|
+
"type": "function"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"constant": true,
|
|
216
|
+
"inputs": [],
|
|
217
|
+
"name": "PERMIT_TYPEHASH",
|
|
218
|
+
"outputs": [
|
|
219
|
+
{
|
|
220
|
+
"internalType": "bytes32",
|
|
221
|
+
"name": "",
|
|
222
|
+
"type": "bytes32"
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
"payable": false,
|
|
226
|
+
"stateMutability": "view",
|
|
227
|
+
"type": "function"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"constant": true,
|
|
231
|
+
"inputs": [
|
|
232
|
+
{
|
|
233
|
+
"internalType": "address",
|
|
234
|
+
"name": "",
|
|
235
|
+
"type": "address"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"internalType": "address",
|
|
239
|
+
"name": "",
|
|
240
|
+
"type": "address"
|
|
241
|
+
}
|
|
242
|
+
],
|
|
243
|
+
"name": "allowance",
|
|
244
|
+
"outputs": [
|
|
245
|
+
{
|
|
246
|
+
"internalType": "uint256",
|
|
247
|
+
"name": "",
|
|
248
|
+
"type": "uint256"
|
|
249
|
+
}
|
|
250
|
+
],
|
|
251
|
+
"payable": false,
|
|
252
|
+
"stateMutability": "view",
|
|
253
|
+
"type": "function"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"constant": false,
|
|
257
|
+
"inputs": [
|
|
258
|
+
{
|
|
259
|
+
"internalType": "address",
|
|
260
|
+
"name": "spender",
|
|
261
|
+
"type": "address"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"internalType": "uint256",
|
|
265
|
+
"name": "value",
|
|
266
|
+
"type": "uint256"
|
|
267
|
+
}
|
|
268
|
+
],
|
|
269
|
+
"name": "approve",
|
|
270
|
+
"outputs": [
|
|
271
|
+
{
|
|
272
|
+
"internalType": "bool",
|
|
273
|
+
"name": "",
|
|
274
|
+
"type": "bool"
|
|
275
|
+
}
|
|
276
|
+
],
|
|
277
|
+
"payable": false,
|
|
278
|
+
"stateMutability": "nonpayable",
|
|
279
|
+
"type": "function"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"constant": true,
|
|
283
|
+
"inputs": [
|
|
284
|
+
{
|
|
285
|
+
"internalType": "address",
|
|
286
|
+
"name": "",
|
|
287
|
+
"type": "address"
|
|
288
|
+
}
|
|
289
|
+
],
|
|
290
|
+
"name": "balanceOf",
|
|
291
|
+
"outputs": [
|
|
292
|
+
{
|
|
293
|
+
"internalType": "uint256",
|
|
294
|
+
"name": "",
|
|
295
|
+
"type": "uint256"
|
|
296
|
+
}
|
|
297
|
+
],
|
|
298
|
+
"payable": false,
|
|
299
|
+
"stateMutability": "view",
|
|
300
|
+
"type": "function"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"constant": false,
|
|
304
|
+
"inputs": [
|
|
305
|
+
{
|
|
306
|
+
"internalType": "address",
|
|
307
|
+
"name": "to",
|
|
308
|
+
"type": "address"
|
|
309
|
+
}
|
|
310
|
+
],
|
|
311
|
+
"name": "burn",
|
|
312
|
+
"outputs": [
|
|
313
|
+
{
|
|
314
|
+
"internalType": "uint256",
|
|
315
|
+
"name": "amount0",
|
|
316
|
+
"type": "uint256"
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"internalType": "uint256",
|
|
320
|
+
"name": "amount1",
|
|
321
|
+
"type": "uint256"
|
|
322
|
+
}
|
|
323
|
+
],
|
|
324
|
+
"payable": false,
|
|
325
|
+
"stateMutability": "nonpayable",
|
|
326
|
+
"type": "function"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"constant": true,
|
|
330
|
+
"inputs": [],
|
|
331
|
+
"name": "decimals",
|
|
332
|
+
"outputs": [
|
|
333
|
+
{
|
|
334
|
+
"internalType": "uint8",
|
|
335
|
+
"name": "",
|
|
336
|
+
"type": "uint8"
|
|
337
|
+
}
|
|
338
|
+
],
|
|
339
|
+
"payable": false,
|
|
340
|
+
"stateMutability": "view",
|
|
341
|
+
"type": "function"
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
"constant": true,
|
|
345
|
+
"inputs": [],
|
|
346
|
+
"name": "factory",
|
|
347
|
+
"outputs": [
|
|
348
|
+
{
|
|
349
|
+
"internalType": "address",
|
|
350
|
+
"name": "",
|
|
351
|
+
"type": "address"
|
|
352
|
+
}
|
|
353
|
+
],
|
|
354
|
+
"payable": false,
|
|
355
|
+
"stateMutability": "view",
|
|
356
|
+
"type": "function"
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
"constant": true,
|
|
360
|
+
"inputs": [],
|
|
361
|
+
"name": "getReserves",
|
|
362
|
+
"outputs": [
|
|
363
|
+
{
|
|
364
|
+
"internalType": "uint112",
|
|
365
|
+
"name": "_reserve0",
|
|
366
|
+
"type": "uint112"
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
"internalType": "uint112",
|
|
370
|
+
"name": "_reserve1",
|
|
371
|
+
"type": "uint112"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
"internalType": "uint32",
|
|
375
|
+
"name": "_blockTimestampLast",
|
|
376
|
+
"type": "uint32"
|
|
377
|
+
}
|
|
378
|
+
],
|
|
379
|
+
"payable": false,
|
|
380
|
+
"stateMutability": "view",
|
|
381
|
+
"type": "function"
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
"constant": false,
|
|
385
|
+
"inputs": [
|
|
386
|
+
{
|
|
387
|
+
"internalType": "address",
|
|
388
|
+
"name": "_token0",
|
|
389
|
+
"type": "address"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"internalType": "address",
|
|
393
|
+
"name": "_token1",
|
|
394
|
+
"type": "address"
|
|
395
|
+
}
|
|
396
|
+
],
|
|
397
|
+
"name": "initialize",
|
|
398
|
+
"outputs": [],
|
|
399
|
+
"payable": false,
|
|
400
|
+
"stateMutability": "nonpayable",
|
|
401
|
+
"type": "function"
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
"constant": true,
|
|
405
|
+
"inputs": [],
|
|
406
|
+
"name": "kLast",
|
|
407
|
+
"outputs": [
|
|
408
|
+
{
|
|
409
|
+
"internalType": "uint256",
|
|
410
|
+
"name": "",
|
|
411
|
+
"type": "uint256"
|
|
412
|
+
}
|
|
413
|
+
],
|
|
414
|
+
"payable": false,
|
|
415
|
+
"stateMutability": "view",
|
|
416
|
+
"type": "function"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
"constant": false,
|
|
420
|
+
"inputs": [
|
|
421
|
+
{
|
|
422
|
+
"internalType": "address",
|
|
423
|
+
"name": "to",
|
|
424
|
+
"type": "address"
|
|
425
|
+
}
|
|
426
|
+
],
|
|
427
|
+
"name": "mint",
|
|
428
|
+
"outputs": [
|
|
429
|
+
{
|
|
430
|
+
"internalType": "uint256",
|
|
431
|
+
"name": "liquidity",
|
|
432
|
+
"type": "uint256"
|
|
433
|
+
}
|
|
434
|
+
],
|
|
435
|
+
"payable": false,
|
|
436
|
+
"stateMutability": "nonpayable",
|
|
437
|
+
"type": "function"
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
"constant": true,
|
|
441
|
+
"inputs": [],
|
|
442
|
+
"name": "name",
|
|
443
|
+
"outputs": [
|
|
444
|
+
{
|
|
445
|
+
"internalType": "string",
|
|
446
|
+
"name": "",
|
|
447
|
+
"type": "string"
|
|
448
|
+
}
|
|
449
|
+
],
|
|
450
|
+
"payable": false,
|
|
451
|
+
"stateMutability": "view",
|
|
452
|
+
"type": "function"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
"constant": true,
|
|
456
|
+
"inputs": [
|
|
457
|
+
{
|
|
458
|
+
"internalType": "address",
|
|
459
|
+
"name": "",
|
|
460
|
+
"type": "address"
|
|
461
|
+
}
|
|
462
|
+
],
|
|
463
|
+
"name": "nonces",
|
|
464
|
+
"outputs": [
|
|
465
|
+
{
|
|
466
|
+
"internalType": "uint256",
|
|
467
|
+
"name": "",
|
|
468
|
+
"type": "uint256"
|
|
469
|
+
}
|
|
470
|
+
],
|
|
471
|
+
"payable": false,
|
|
472
|
+
"stateMutability": "view",
|
|
473
|
+
"type": "function"
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
"constant": false,
|
|
477
|
+
"inputs": [
|
|
478
|
+
{
|
|
479
|
+
"internalType": "address",
|
|
480
|
+
"name": "owner",
|
|
481
|
+
"type": "address"
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
"internalType": "address",
|
|
485
|
+
"name": "spender",
|
|
486
|
+
"type": "address"
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
"internalType": "uint256",
|
|
490
|
+
"name": "value",
|
|
491
|
+
"type": "uint256"
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
"internalType": "uint256",
|
|
495
|
+
"name": "deadline",
|
|
496
|
+
"type": "uint256"
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
"internalType": "uint8",
|
|
500
|
+
"name": "v",
|
|
501
|
+
"type": "uint8"
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
"internalType": "bytes32",
|
|
505
|
+
"name": "r",
|
|
506
|
+
"type": "bytes32"
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
"internalType": "bytes32",
|
|
510
|
+
"name": "s",
|
|
511
|
+
"type": "bytes32"
|
|
512
|
+
}
|
|
513
|
+
],
|
|
514
|
+
"name": "permit",
|
|
515
|
+
"outputs": [],
|
|
516
|
+
"payable": false,
|
|
517
|
+
"stateMutability": "nonpayable",
|
|
518
|
+
"type": "function"
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
"constant": true,
|
|
522
|
+
"inputs": [],
|
|
523
|
+
"name": "price0CumulativeLast",
|
|
524
|
+
"outputs": [
|
|
525
|
+
{
|
|
526
|
+
"internalType": "uint256",
|
|
527
|
+
"name": "",
|
|
528
|
+
"type": "uint256"
|
|
529
|
+
}
|
|
530
|
+
],
|
|
531
|
+
"payable": false,
|
|
532
|
+
"stateMutability": "view",
|
|
533
|
+
"type": "function"
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
"constant": true,
|
|
537
|
+
"inputs": [],
|
|
538
|
+
"name": "price1CumulativeLast",
|
|
539
|
+
"outputs": [
|
|
540
|
+
{
|
|
541
|
+
"internalType": "uint256",
|
|
542
|
+
"name": "",
|
|
543
|
+
"type": "uint256"
|
|
544
|
+
}
|
|
545
|
+
],
|
|
546
|
+
"payable": false,
|
|
547
|
+
"stateMutability": "view",
|
|
548
|
+
"type": "function"
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
"constant": false,
|
|
552
|
+
"inputs": [
|
|
553
|
+
{
|
|
554
|
+
"internalType": "address",
|
|
555
|
+
"name": "to",
|
|
556
|
+
"type": "address"
|
|
557
|
+
}
|
|
558
|
+
],
|
|
559
|
+
"name": "skim",
|
|
560
|
+
"outputs": [],
|
|
561
|
+
"payable": false,
|
|
562
|
+
"stateMutability": "nonpayable",
|
|
563
|
+
"type": "function"
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
"constant": false,
|
|
567
|
+
"inputs": [
|
|
568
|
+
{
|
|
569
|
+
"internalType": "uint256",
|
|
570
|
+
"name": "amount0Out",
|
|
571
|
+
"type": "uint256"
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
"internalType": "uint256",
|
|
575
|
+
"name": "amount1Out",
|
|
576
|
+
"type": "uint256"
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
"internalType": "address",
|
|
580
|
+
"name": "to",
|
|
581
|
+
"type": "address"
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
"internalType": "bytes",
|
|
585
|
+
"name": "data",
|
|
586
|
+
"type": "bytes"
|
|
587
|
+
}
|
|
588
|
+
],
|
|
589
|
+
"name": "swap",
|
|
590
|
+
"outputs": [],
|
|
591
|
+
"payable": false,
|
|
592
|
+
"stateMutability": "nonpayable",
|
|
593
|
+
"type": "function"
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
"constant": true,
|
|
597
|
+
"inputs": [],
|
|
598
|
+
"name": "symbol",
|
|
599
|
+
"outputs": [
|
|
600
|
+
{
|
|
601
|
+
"internalType": "string",
|
|
602
|
+
"name": "",
|
|
603
|
+
"type": "string"
|
|
604
|
+
}
|
|
605
|
+
],
|
|
606
|
+
"payable": false,
|
|
607
|
+
"stateMutability": "view",
|
|
608
|
+
"type": "function"
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
"constant": false,
|
|
612
|
+
"inputs": [],
|
|
613
|
+
"name": "sync",
|
|
614
|
+
"outputs": [],
|
|
615
|
+
"payable": false,
|
|
616
|
+
"stateMutability": "nonpayable",
|
|
617
|
+
"type": "function"
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
"constant": true,
|
|
621
|
+
"inputs": [],
|
|
622
|
+
"name": "token0",
|
|
623
|
+
"outputs": [
|
|
624
|
+
{
|
|
625
|
+
"internalType": "address",
|
|
626
|
+
"name": "",
|
|
627
|
+
"type": "address"
|
|
628
|
+
}
|
|
629
|
+
],
|
|
630
|
+
"payable": false,
|
|
631
|
+
"stateMutability": "view",
|
|
632
|
+
"type": "function"
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
"constant": true,
|
|
636
|
+
"inputs": [],
|
|
637
|
+
"name": "token1",
|
|
638
|
+
"outputs": [
|
|
639
|
+
{
|
|
640
|
+
"internalType": "address",
|
|
641
|
+
"name": "",
|
|
642
|
+
"type": "address"
|
|
643
|
+
}
|
|
644
|
+
],
|
|
645
|
+
"payable": false,
|
|
646
|
+
"stateMutability": "view",
|
|
647
|
+
"type": "function"
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
"constant": true,
|
|
651
|
+
"inputs": [],
|
|
652
|
+
"name": "totalSupply",
|
|
653
|
+
"outputs": [
|
|
654
|
+
{
|
|
655
|
+
"internalType": "uint256",
|
|
656
|
+
"name": "",
|
|
657
|
+
"type": "uint256"
|
|
658
|
+
}
|
|
659
|
+
],
|
|
660
|
+
"payable": false,
|
|
661
|
+
"stateMutability": "view",
|
|
662
|
+
"type": "function"
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
"constant": false,
|
|
666
|
+
"inputs": [
|
|
667
|
+
{
|
|
668
|
+
"internalType": "address",
|
|
669
|
+
"name": "to",
|
|
670
|
+
"type": "address"
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
"internalType": "uint256",
|
|
674
|
+
"name": "value",
|
|
675
|
+
"type": "uint256"
|
|
676
|
+
}
|
|
677
|
+
],
|
|
678
|
+
"name": "transfer",
|
|
679
|
+
"outputs": [
|
|
680
|
+
{
|
|
681
|
+
"internalType": "bool",
|
|
682
|
+
"name": "",
|
|
683
|
+
"type": "bool"
|
|
684
|
+
}
|
|
685
|
+
],
|
|
686
|
+
"payable": false,
|
|
687
|
+
"stateMutability": "nonpayable",
|
|
688
|
+
"type": "function"
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
"constant": false,
|
|
692
|
+
"inputs": [
|
|
693
|
+
{
|
|
694
|
+
"internalType": "address",
|
|
695
|
+
"name": "from",
|
|
696
|
+
"type": "address"
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
"internalType": "address",
|
|
700
|
+
"name": "to",
|
|
701
|
+
"type": "address"
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
"internalType": "uint256",
|
|
705
|
+
"name": "value",
|
|
706
|
+
"type": "uint256"
|
|
707
|
+
}
|
|
708
|
+
],
|
|
709
|
+
"name": "transferFrom",
|
|
710
|
+
"outputs": [
|
|
711
|
+
{
|
|
712
|
+
"internalType": "bool",
|
|
713
|
+
"name": "",
|
|
714
|
+
"type": "bool"
|
|
715
|
+
}
|
|
716
|
+
],
|
|
717
|
+
"payable": false,
|
|
718
|
+
"stateMutability": "nonpayable",
|
|
719
|
+
"type": "function"
|
|
720
|
+
}
|
|
721
|
+
] as const satisfies Abi;
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Type-safe ABI for UniswapV2Pair_json
|
|
725
|
+
*/
|
|
726
|
+
export type UniswapV2Pair_jsonAbi = typeof UniswapV2Pair_jsonAbi;
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* Contract instance type for UniswapV2Pair_json
|
|
730
|
+
*/
|
|
731
|
+
// Use any for contract type to avoid complex viem type issues
|
|
732
|
+
// The runtime behavior is type-safe through viem's ABI typing
|
|
733
|
+
export type UniswapV2Pair_jsonContract = any;
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* UniswapV2Pair_json Contract Class
|
|
737
|
+
*
|
|
738
|
+
* Provides a class-based API similar to TypeChain for interacting with the contract.
|
|
739
|
+
*
|
|
740
|
+
* @example
|
|
741
|
+
* ```typescript
|
|
742
|
+
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
743
|
+
* import { mainnet } from 'viem/chains';
|
|
744
|
+
* import { UniswapV2Pair_json } from 'UniswapV2Pair_json';
|
|
745
|
+
*
|
|
746
|
+
* const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
747
|
+
* const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
748
|
+
*
|
|
749
|
+
* const contract = new UniswapV2Pair_json('0x...', { publicClient, walletClient });
|
|
750
|
+
*
|
|
751
|
+
* // Read functions
|
|
752
|
+
* const result = await contract.balanceOf('0x...');
|
|
753
|
+
*
|
|
754
|
+
* // Write functions
|
|
755
|
+
* const hash = await contract.transfer('0x...', 1000n);
|
|
756
|
+
*
|
|
757
|
+
* // Simulate transactions (dry-run)
|
|
758
|
+
* const simulation = await contract.simulate.transfer('0x...', 1000n);
|
|
759
|
+
* console.log('Gas estimate:', simulation.request.gas);
|
|
760
|
+
*
|
|
761
|
+
* // Watch events
|
|
762
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
763
|
+
* console.log('Transfer event:', event);
|
|
764
|
+
* });
|
|
765
|
+
* ```
|
|
766
|
+
*/
|
|
767
|
+
export class UniswapV2Pair_json {
|
|
768
|
+
private contract: UniswapV2Pair_jsonContract;
|
|
769
|
+
private contractAddress: Address;
|
|
770
|
+
private publicClient: PublicClient;
|
|
771
|
+
|
|
772
|
+
constructor(
|
|
773
|
+
address: Address,
|
|
774
|
+
clients: {
|
|
775
|
+
publicClient: PublicClient;
|
|
776
|
+
walletClient?: WalletClient;
|
|
777
|
+
}
|
|
778
|
+
) {
|
|
779
|
+
this.contractAddress = address;
|
|
780
|
+
this.publicClient = clients.publicClient;
|
|
781
|
+
this.contract = getContract({
|
|
782
|
+
address,
|
|
783
|
+
abi: UniswapV2Pair_jsonAbi,
|
|
784
|
+
client: {
|
|
785
|
+
public: clients.publicClient,
|
|
786
|
+
wallet: clients.walletClient,
|
|
787
|
+
},
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Get the contract address
|
|
793
|
+
*/
|
|
794
|
+
get address(): Address {
|
|
795
|
+
return this.contractAddress;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Get the underlying viem contract instance
|
|
800
|
+
*/
|
|
801
|
+
getContract(): UniswapV2Pair_jsonContract {
|
|
802
|
+
return this.contract;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* DOMAIN_SEPARATOR
|
|
807
|
+
* view
|
|
808
|
+
*/
|
|
809
|
+
async DOMAIN_SEPARATOR(): Promise<`0x${string}`> {
|
|
810
|
+
return this.contract.read.DOMAIN_SEPARATOR() as Promise<`0x${string}`>;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* MINIMUM_LIQUIDITY
|
|
815
|
+
* view
|
|
816
|
+
*/
|
|
817
|
+
async MINIMUM_LIQUIDITY(): Promise<bigint> {
|
|
818
|
+
return this.contract.read.MINIMUM_LIQUIDITY() as Promise<bigint>;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* PERMIT_TYPEHASH
|
|
823
|
+
* view
|
|
824
|
+
*/
|
|
825
|
+
async PERMIT_TYPEHASH(): Promise<`0x${string}`> {
|
|
826
|
+
return this.contract.read.PERMIT_TYPEHASH() as Promise<`0x${string}`>;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* allowance
|
|
831
|
+
* view
|
|
832
|
+
*/
|
|
833
|
+
async allowance(arg0: `0x${string}`, arg1: `0x${string}`): Promise<bigint> {
|
|
834
|
+
return this.contract.read.allowance([arg0, arg1] as const) as Promise<bigint>;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* balanceOf
|
|
839
|
+
* view
|
|
840
|
+
*/
|
|
841
|
+
async balanceOf(arg0: `0x${string}`): Promise<bigint> {
|
|
842
|
+
return this.contract.read.balanceOf([arg0] as const) as Promise<bigint>;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* decimals
|
|
847
|
+
* view
|
|
848
|
+
*/
|
|
849
|
+
async decimals(): Promise<bigint> {
|
|
850
|
+
return this.contract.read.decimals() as Promise<bigint>;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* factory
|
|
855
|
+
* view
|
|
856
|
+
*/
|
|
857
|
+
async factory(): Promise<`0x${string}`> {
|
|
858
|
+
return this.contract.read.factory() as Promise<`0x${string}`>;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
* getReserves
|
|
863
|
+
* view
|
|
864
|
+
*/
|
|
865
|
+
async getReserves(): Promise<[bigint, bigint, bigint]> {
|
|
866
|
+
return this.contract.read.getReserves() as Promise<[bigint, bigint, bigint]>;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* kLast
|
|
871
|
+
* view
|
|
872
|
+
*/
|
|
873
|
+
async kLast(): Promise<bigint> {
|
|
874
|
+
return this.contract.read.kLast() as Promise<bigint>;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* name
|
|
879
|
+
* view
|
|
880
|
+
*/
|
|
881
|
+
async name(): Promise<string> {
|
|
882
|
+
return this.contract.read.name() as Promise<string>;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* nonces
|
|
887
|
+
* view
|
|
888
|
+
*/
|
|
889
|
+
async nonces(arg0: `0x${string}`): Promise<bigint> {
|
|
890
|
+
return this.contract.read.nonces([arg0] as const) as Promise<bigint>;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* price0CumulativeLast
|
|
895
|
+
* view
|
|
896
|
+
*/
|
|
897
|
+
async price0CumulativeLast(): Promise<bigint> {
|
|
898
|
+
return this.contract.read.price0CumulativeLast() as Promise<bigint>;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* price1CumulativeLast
|
|
903
|
+
* view
|
|
904
|
+
*/
|
|
905
|
+
async price1CumulativeLast(): Promise<bigint> {
|
|
906
|
+
return this.contract.read.price1CumulativeLast() as Promise<bigint>;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* symbol
|
|
911
|
+
* view
|
|
912
|
+
*/
|
|
913
|
+
async symbol(): Promise<string> {
|
|
914
|
+
return this.contract.read.symbol() as Promise<string>;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* token0
|
|
919
|
+
* view
|
|
920
|
+
*/
|
|
921
|
+
async token0(): Promise<`0x${string}`> {
|
|
922
|
+
return this.contract.read.token0() as Promise<`0x${string}`>;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* token1
|
|
927
|
+
* view
|
|
928
|
+
*/
|
|
929
|
+
async token1(): Promise<`0x${string}`> {
|
|
930
|
+
return this.contract.read.token1() as Promise<`0x${string}`>;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* totalSupply
|
|
935
|
+
* view
|
|
936
|
+
*/
|
|
937
|
+
async totalSupply(): Promise<bigint> {
|
|
938
|
+
return this.contract.read.totalSupply() as Promise<bigint>;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* approve
|
|
943
|
+
* nonpayable
|
|
944
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
945
|
+
*/
|
|
946
|
+
async approve(spender: `0x${string}`, value: bigint, options?: {
|
|
947
|
+
accessList?: import('viem').AccessList;
|
|
948
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
949
|
+
chain?: import('viem').Chain | null;
|
|
950
|
+
dataSuffix?: `0x${string}`;
|
|
951
|
+
gas?: bigint;
|
|
952
|
+
gasPrice?: bigint;
|
|
953
|
+
maxFeePerGas?: bigint;
|
|
954
|
+
maxPriorityFeePerGas?: bigint;
|
|
955
|
+
nonce?: number;
|
|
956
|
+
value?: bigint;
|
|
957
|
+
}): Promise<`0x${string}`> {
|
|
958
|
+
if (!this.contract.write) {
|
|
959
|
+
throw new Error('Wallet client is required for write operations');
|
|
960
|
+
}
|
|
961
|
+
return this.contract.write.approve([spender, value] as const, options) as Promise<`0x${string}`>;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* burn
|
|
966
|
+
* nonpayable
|
|
967
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
968
|
+
*/
|
|
969
|
+
async burn(to: `0x${string}`, options?: {
|
|
970
|
+
accessList?: import('viem').AccessList;
|
|
971
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
972
|
+
chain?: import('viem').Chain | null;
|
|
973
|
+
dataSuffix?: `0x${string}`;
|
|
974
|
+
gas?: bigint;
|
|
975
|
+
gasPrice?: bigint;
|
|
976
|
+
maxFeePerGas?: bigint;
|
|
977
|
+
maxPriorityFeePerGas?: bigint;
|
|
978
|
+
nonce?: number;
|
|
979
|
+
value?: bigint;
|
|
980
|
+
}): Promise<`0x${string}`> {
|
|
981
|
+
if (!this.contract.write) {
|
|
982
|
+
throw new Error('Wallet client is required for write operations');
|
|
983
|
+
}
|
|
984
|
+
return this.contract.write.burn([to] as const, options) as Promise<`0x${string}`>;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* initialize
|
|
989
|
+
* nonpayable
|
|
990
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
991
|
+
*/
|
|
992
|
+
async initialize(_token0: `0x${string}`, _token1: `0x${string}`, options?: {
|
|
993
|
+
accessList?: import('viem').AccessList;
|
|
994
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
995
|
+
chain?: import('viem').Chain | null;
|
|
996
|
+
dataSuffix?: `0x${string}`;
|
|
997
|
+
gas?: bigint;
|
|
998
|
+
gasPrice?: bigint;
|
|
999
|
+
maxFeePerGas?: bigint;
|
|
1000
|
+
maxPriorityFeePerGas?: bigint;
|
|
1001
|
+
nonce?: number;
|
|
1002
|
+
value?: bigint;
|
|
1003
|
+
}): Promise<`0x${string}`> {
|
|
1004
|
+
if (!this.contract.write) {
|
|
1005
|
+
throw new Error('Wallet client is required for write operations');
|
|
1006
|
+
}
|
|
1007
|
+
return this.contract.write.initialize([_token0, _token1] as const, options) as Promise<`0x${string}`>;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
/**
|
|
1011
|
+
* mint
|
|
1012
|
+
* nonpayable
|
|
1013
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1014
|
+
*/
|
|
1015
|
+
async mint(to: `0x${string}`, options?: {
|
|
1016
|
+
accessList?: import('viem').AccessList;
|
|
1017
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1018
|
+
chain?: import('viem').Chain | null;
|
|
1019
|
+
dataSuffix?: `0x${string}`;
|
|
1020
|
+
gas?: bigint;
|
|
1021
|
+
gasPrice?: bigint;
|
|
1022
|
+
maxFeePerGas?: bigint;
|
|
1023
|
+
maxPriorityFeePerGas?: bigint;
|
|
1024
|
+
nonce?: number;
|
|
1025
|
+
value?: bigint;
|
|
1026
|
+
}): Promise<`0x${string}`> {
|
|
1027
|
+
if (!this.contract.write) {
|
|
1028
|
+
throw new Error('Wallet client is required for write operations');
|
|
1029
|
+
}
|
|
1030
|
+
return this.contract.write.mint([to] as const, options) as Promise<`0x${string}`>;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* permit
|
|
1035
|
+
* nonpayable
|
|
1036
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1037
|
+
*/
|
|
1038
|
+
async permit(owner: `0x${string}`, spender: `0x${string}`, value: bigint, deadline: bigint, v: bigint, r: `0x${string}`, s: `0x${string}`, options?: {
|
|
1039
|
+
accessList?: import('viem').AccessList;
|
|
1040
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1041
|
+
chain?: import('viem').Chain | null;
|
|
1042
|
+
dataSuffix?: `0x${string}`;
|
|
1043
|
+
gas?: bigint;
|
|
1044
|
+
gasPrice?: bigint;
|
|
1045
|
+
maxFeePerGas?: bigint;
|
|
1046
|
+
maxPriorityFeePerGas?: bigint;
|
|
1047
|
+
nonce?: number;
|
|
1048
|
+
value?: bigint;
|
|
1049
|
+
}): Promise<`0x${string}`> {
|
|
1050
|
+
if (!this.contract.write) {
|
|
1051
|
+
throw new Error('Wallet client is required for write operations');
|
|
1052
|
+
}
|
|
1053
|
+
return this.contract.write.permit([owner, spender, value, deadline, v, r, s] as const, options) as Promise<`0x${string}`>;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* skim
|
|
1058
|
+
* nonpayable
|
|
1059
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1060
|
+
*/
|
|
1061
|
+
async skim(to: `0x${string}`, options?: {
|
|
1062
|
+
accessList?: import('viem').AccessList;
|
|
1063
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1064
|
+
chain?: import('viem').Chain | null;
|
|
1065
|
+
dataSuffix?: `0x${string}`;
|
|
1066
|
+
gas?: bigint;
|
|
1067
|
+
gasPrice?: bigint;
|
|
1068
|
+
maxFeePerGas?: bigint;
|
|
1069
|
+
maxPriorityFeePerGas?: bigint;
|
|
1070
|
+
nonce?: number;
|
|
1071
|
+
value?: bigint;
|
|
1072
|
+
}): Promise<`0x${string}`> {
|
|
1073
|
+
if (!this.contract.write) {
|
|
1074
|
+
throw new Error('Wallet client is required for write operations');
|
|
1075
|
+
}
|
|
1076
|
+
return this.contract.write.skim([to] as const, options) as Promise<`0x${string}`>;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* swap
|
|
1081
|
+
* nonpayable
|
|
1082
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1083
|
+
*/
|
|
1084
|
+
async swap(amount0Out: bigint, amount1Out: bigint, to: `0x${string}`, data: `0x${string}`, options?: {
|
|
1085
|
+
accessList?: import('viem').AccessList;
|
|
1086
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1087
|
+
chain?: import('viem').Chain | null;
|
|
1088
|
+
dataSuffix?: `0x${string}`;
|
|
1089
|
+
gas?: bigint;
|
|
1090
|
+
gasPrice?: bigint;
|
|
1091
|
+
maxFeePerGas?: bigint;
|
|
1092
|
+
maxPriorityFeePerGas?: bigint;
|
|
1093
|
+
nonce?: number;
|
|
1094
|
+
value?: bigint;
|
|
1095
|
+
}): Promise<`0x${string}`> {
|
|
1096
|
+
if (!this.contract.write) {
|
|
1097
|
+
throw new Error('Wallet client is required for write operations');
|
|
1098
|
+
}
|
|
1099
|
+
return this.contract.write.swap([amount0Out, amount1Out, to, data] as const, options) as Promise<`0x${string}`>;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* sync
|
|
1104
|
+
* nonpayable
|
|
1105
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1106
|
+
*/
|
|
1107
|
+
async sync(options?: {
|
|
1108
|
+
accessList?: import('viem').AccessList;
|
|
1109
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1110
|
+
chain?: import('viem').Chain | null;
|
|
1111
|
+
dataSuffix?: `0x${string}`;
|
|
1112
|
+
gas?: bigint;
|
|
1113
|
+
gasPrice?: bigint;
|
|
1114
|
+
maxFeePerGas?: bigint;
|
|
1115
|
+
maxPriorityFeePerGas?: bigint;
|
|
1116
|
+
nonce?: number;
|
|
1117
|
+
value?: bigint;
|
|
1118
|
+
}): Promise<`0x${string}`> {
|
|
1119
|
+
if (!this.contract.write) {
|
|
1120
|
+
throw new Error('Wallet client is required for write operations');
|
|
1121
|
+
}
|
|
1122
|
+
return this.contract.write.sync(options) as Promise<`0x${string}`>;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* transfer
|
|
1127
|
+
* nonpayable
|
|
1128
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1129
|
+
*/
|
|
1130
|
+
async transfer(to: `0x${string}`, value: bigint, options?: {
|
|
1131
|
+
accessList?: import('viem').AccessList;
|
|
1132
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1133
|
+
chain?: import('viem').Chain | null;
|
|
1134
|
+
dataSuffix?: `0x${string}`;
|
|
1135
|
+
gas?: bigint;
|
|
1136
|
+
gasPrice?: bigint;
|
|
1137
|
+
maxFeePerGas?: bigint;
|
|
1138
|
+
maxPriorityFeePerGas?: bigint;
|
|
1139
|
+
nonce?: number;
|
|
1140
|
+
value?: bigint;
|
|
1141
|
+
}): Promise<`0x${string}`> {
|
|
1142
|
+
if (!this.contract.write) {
|
|
1143
|
+
throw new Error('Wallet client is required for write operations');
|
|
1144
|
+
}
|
|
1145
|
+
return this.contract.write.transfer([to, value] as const, options) as Promise<`0x${string}`>;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* transferFrom
|
|
1150
|
+
* nonpayable
|
|
1151
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1152
|
+
*/
|
|
1153
|
+
async transferFrom(from: `0x${string}`, to: `0x${string}`, value: bigint, options?: {
|
|
1154
|
+
accessList?: import('viem').AccessList;
|
|
1155
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1156
|
+
chain?: import('viem').Chain | null;
|
|
1157
|
+
dataSuffix?: `0x${string}`;
|
|
1158
|
+
gas?: bigint;
|
|
1159
|
+
gasPrice?: bigint;
|
|
1160
|
+
maxFeePerGas?: bigint;
|
|
1161
|
+
maxPriorityFeePerGas?: bigint;
|
|
1162
|
+
nonce?: number;
|
|
1163
|
+
value?: bigint;
|
|
1164
|
+
}): Promise<`0x${string}`> {
|
|
1165
|
+
if (!this.contract.write) {
|
|
1166
|
+
throw new Error('Wallet client is required for write operations');
|
|
1167
|
+
}
|
|
1168
|
+
return this.contract.write.transferFrom([from, to, value] as const, options) as Promise<`0x${string}`>;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
/**
|
|
1174
|
+
* Simulate contract write operations (dry-run without sending transaction)
|
|
1175
|
+
*
|
|
1176
|
+
* @example
|
|
1177
|
+
* const result = await contract.simulate.transfer('0x...', 1000n);
|
|
1178
|
+
* console.log('Gas estimate:', result.request.gas);
|
|
1179
|
+
* console.log('Would succeed:', result.result);
|
|
1180
|
+
*/
|
|
1181
|
+
get simulate() {
|
|
1182
|
+
const contract = this.contract;
|
|
1183
|
+
if (!contract.simulate) {
|
|
1184
|
+
throw new Error('Public client is required for simulation');
|
|
1185
|
+
}
|
|
1186
|
+
return {
|
|
1187
|
+
/**
|
|
1188
|
+
* Simulate approve
|
|
1189
|
+
* Returns gas estimate and result without sending transaction
|
|
1190
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1191
|
+
*/
|
|
1192
|
+
async approve(spender: `0x${string}`, value: bigint, options?: {
|
|
1193
|
+
accessList?: import('viem').AccessList;
|
|
1194
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1195
|
+
chain?: import('viem').Chain | null;
|
|
1196
|
+
dataSuffix?: `0x${string}`;
|
|
1197
|
+
gas?: bigint;
|
|
1198
|
+
gasPrice?: bigint;
|
|
1199
|
+
maxFeePerGas?: bigint;
|
|
1200
|
+
maxPriorityFeePerGas?: bigint;
|
|
1201
|
+
nonce?: number;
|
|
1202
|
+
value?: bigint;
|
|
1203
|
+
}): Promise<boolean> {
|
|
1204
|
+
return contract.simulate.approve([spender, value] as const, options) as Promise<boolean>;
|
|
1205
|
+
},
|
|
1206
|
+
/**
|
|
1207
|
+
* Simulate burn
|
|
1208
|
+
* Returns gas estimate and result without sending transaction
|
|
1209
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1210
|
+
*/
|
|
1211
|
+
async burn(to: `0x${string}`, options?: {
|
|
1212
|
+
accessList?: import('viem').AccessList;
|
|
1213
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1214
|
+
chain?: import('viem').Chain | null;
|
|
1215
|
+
dataSuffix?: `0x${string}`;
|
|
1216
|
+
gas?: bigint;
|
|
1217
|
+
gasPrice?: bigint;
|
|
1218
|
+
maxFeePerGas?: bigint;
|
|
1219
|
+
maxPriorityFeePerGas?: bigint;
|
|
1220
|
+
nonce?: number;
|
|
1221
|
+
value?: bigint;
|
|
1222
|
+
}): Promise<[bigint, bigint]> {
|
|
1223
|
+
return contract.simulate.burn([to] as const, options) as Promise<[bigint, bigint]>;
|
|
1224
|
+
},
|
|
1225
|
+
/**
|
|
1226
|
+
* Simulate initialize
|
|
1227
|
+
* Returns gas estimate and result without sending transaction
|
|
1228
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1229
|
+
*/
|
|
1230
|
+
async initialize(_token0: `0x${string}`, _token1: `0x${string}`, options?: {
|
|
1231
|
+
accessList?: import('viem').AccessList;
|
|
1232
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1233
|
+
chain?: import('viem').Chain | null;
|
|
1234
|
+
dataSuffix?: `0x${string}`;
|
|
1235
|
+
gas?: bigint;
|
|
1236
|
+
gasPrice?: bigint;
|
|
1237
|
+
maxFeePerGas?: bigint;
|
|
1238
|
+
maxPriorityFeePerGas?: bigint;
|
|
1239
|
+
nonce?: number;
|
|
1240
|
+
value?: bigint;
|
|
1241
|
+
}): Promise<void> {
|
|
1242
|
+
return contract.simulate.initialize([_token0, _token1] as const, options) as Promise<void>;
|
|
1243
|
+
},
|
|
1244
|
+
/**
|
|
1245
|
+
* Simulate mint
|
|
1246
|
+
* Returns gas estimate and result without sending transaction
|
|
1247
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1248
|
+
*/
|
|
1249
|
+
async mint(to: `0x${string}`, options?: {
|
|
1250
|
+
accessList?: import('viem').AccessList;
|
|
1251
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1252
|
+
chain?: import('viem').Chain | null;
|
|
1253
|
+
dataSuffix?: `0x${string}`;
|
|
1254
|
+
gas?: bigint;
|
|
1255
|
+
gasPrice?: bigint;
|
|
1256
|
+
maxFeePerGas?: bigint;
|
|
1257
|
+
maxPriorityFeePerGas?: bigint;
|
|
1258
|
+
nonce?: number;
|
|
1259
|
+
value?: bigint;
|
|
1260
|
+
}): Promise<bigint> {
|
|
1261
|
+
return contract.simulate.mint([to] as const, options) as Promise<bigint>;
|
|
1262
|
+
},
|
|
1263
|
+
/**
|
|
1264
|
+
* Simulate permit
|
|
1265
|
+
* Returns gas estimate and result without sending transaction
|
|
1266
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1267
|
+
*/
|
|
1268
|
+
async permit(owner: `0x${string}`, spender: `0x${string}`, value: bigint, deadline: bigint, v: bigint, r: `0x${string}`, s: `0x${string}`, options?: {
|
|
1269
|
+
accessList?: import('viem').AccessList;
|
|
1270
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1271
|
+
chain?: import('viem').Chain | null;
|
|
1272
|
+
dataSuffix?: `0x${string}`;
|
|
1273
|
+
gas?: bigint;
|
|
1274
|
+
gasPrice?: bigint;
|
|
1275
|
+
maxFeePerGas?: bigint;
|
|
1276
|
+
maxPriorityFeePerGas?: bigint;
|
|
1277
|
+
nonce?: number;
|
|
1278
|
+
value?: bigint;
|
|
1279
|
+
}): Promise<void> {
|
|
1280
|
+
return contract.simulate.permit([owner, spender, value, deadline, v, r, s] as const, options) as Promise<void>;
|
|
1281
|
+
},
|
|
1282
|
+
/**
|
|
1283
|
+
* Simulate skim
|
|
1284
|
+
* Returns gas estimate and result without sending transaction
|
|
1285
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1286
|
+
*/
|
|
1287
|
+
async skim(to: `0x${string}`, options?: {
|
|
1288
|
+
accessList?: import('viem').AccessList;
|
|
1289
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1290
|
+
chain?: import('viem').Chain | null;
|
|
1291
|
+
dataSuffix?: `0x${string}`;
|
|
1292
|
+
gas?: bigint;
|
|
1293
|
+
gasPrice?: bigint;
|
|
1294
|
+
maxFeePerGas?: bigint;
|
|
1295
|
+
maxPriorityFeePerGas?: bigint;
|
|
1296
|
+
nonce?: number;
|
|
1297
|
+
value?: bigint;
|
|
1298
|
+
}): Promise<void> {
|
|
1299
|
+
return contract.simulate.skim([to] as const, options) as Promise<void>;
|
|
1300
|
+
},
|
|
1301
|
+
/**
|
|
1302
|
+
* Simulate swap
|
|
1303
|
+
* Returns gas estimate and result without sending transaction
|
|
1304
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1305
|
+
*/
|
|
1306
|
+
async swap(amount0Out: bigint, amount1Out: bigint, to: `0x${string}`, data: `0x${string}`, options?: {
|
|
1307
|
+
accessList?: import('viem').AccessList;
|
|
1308
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1309
|
+
chain?: import('viem').Chain | null;
|
|
1310
|
+
dataSuffix?: `0x${string}`;
|
|
1311
|
+
gas?: bigint;
|
|
1312
|
+
gasPrice?: bigint;
|
|
1313
|
+
maxFeePerGas?: bigint;
|
|
1314
|
+
maxPriorityFeePerGas?: bigint;
|
|
1315
|
+
nonce?: number;
|
|
1316
|
+
value?: bigint;
|
|
1317
|
+
}): Promise<void> {
|
|
1318
|
+
return contract.simulate.swap([amount0Out, amount1Out, to, data] as const, options) as Promise<void>;
|
|
1319
|
+
},
|
|
1320
|
+
/**
|
|
1321
|
+
* Simulate sync
|
|
1322
|
+
* Returns gas estimate and result without sending transaction
|
|
1323
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1324
|
+
*/
|
|
1325
|
+
async sync(options?: {
|
|
1326
|
+
accessList?: import('viem').AccessList;
|
|
1327
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1328
|
+
chain?: import('viem').Chain | null;
|
|
1329
|
+
dataSuffix?: `0x${string}`;
|
|
1330
|
+
gas?: bigint;
|
|
1331
|
+
gasPrice?: bigint;
|
|
1332
|
+
maxFeePerGas?: bigint;
|
|
1333
|
+
maxPriorityFeePerGas?: bigint;
|
|
1334
|
+
nonce?: number;
|
|
1335
|
+
value?: bigint;
|
|
1336
|
+
}): Promise<void> {
|
|
1337
|
+
return contract.simulate.sync(options) as Promise<void>;
|
|
1338
|
+
},
|
|
1339
|
+
/**
|
|
1340
|
+
* Simulate transfer
|
|
1341
|
+
* Returns gas estimate and result without sending transaction
|
|
1342
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1343
|
+
*/
|
|
1344
|
+
async transfer(to: `0x${string}`, value: bigint, options?: {
|
|
1345
|
+
accessList?: import('viem').AccessList;
|
|
1346
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1347
|
+
chain?: import('viem').Chain | null;
|
|
1348
|
+
dataSuffix?: `0x${string}`;
|
|
1349
|
+
gas?: bigint;
|
|
1350
|
+
gasPrice?: bigint;
|
|
1351
|
+
maxFeePerGas?: bigint;
|
|
1352
|
+
maxPriorityFeePerGas?: bigint;
|
|
1353
|
+
nonce?: number;
|
|
1354
|
+
value?: bigint;
|
|
1355
|
+
}): Promise<boolean> {
|
|
1356
|
+
return contract.simulate.transfer([to, value] as const, options) as Promise<boolean>;
|
|
1357
|
+
},
|
|
1358
|
+
/**
|
|
1359
|
+
* Simulate transferFrom
|
|
1360
|
+
* Returns gas estimate and result without sending transaction
|
|
1361
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
1362
|
+
*/
|
|
1363
|
+
async transferFrom(from: `0x${string}`, to: `0x${string}`, value: bigint, options?: {
|
|
1364
|
+
accessList?: import('viem').AccessList;
|
|
1365
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
1366
|
+
chain?: import('viem').Chain | null;
|
|
1367
|
+
dataSuffix?: `0x${string}`;
|
|
1368
|
+
gas?: bigint;
|
|
1369
|
+
gasPrice?: bigint;
|
|
1370
|
+
maxFeePerGas?: bigint;
|
|
1371
|
+
maxPriorityFeePerGas?: bigint;
|
|
1372
|
+
nonce?: number;
|
|
1373
|
+
value?: bigint;
|
|
1374
|
+
}): Promise<boolean> {
|
|
1375
|
+
return contract.simulate.transferFrom([from, to, value] as const, options) as Promise<boolean>;
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
/**
|
|
1381
|
+
* Watch contract events
|
|
1382
|
+
*
|
|
1383
|
+
* @example
|
|
1384
|
+
* // Watch all Transfer events
|
|
1385
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
1386
|
+
* console.log('Transfer:', event);
|
|
1387
|
+
* });
|
|
1388
|
+
*
|
|
1389
|
+
* // Stop watching
|
|
1390
|
+
* unwatch();
|
|
1391
|
+
*/
|
|
1392
|
+
get watch() {
|
|
1393
|
+
return {
|
|
1394
|
+
/**
|
|
1395
|
+
* Watch Approval events
|
|
1396
|
+
* @param callback Function to call when event is emitted
|
|
1397
|
+
* @param filter Optional filter for indexed parameters
|
|
1398
|
+
* @returns Unwatch function to stop listening
|
|
1399
|
+
*/
|
|
1400
|
+
Approval: (callback: (event: { owner: `0x${string}`; spender: `0x${string}`; value: bigint }) => void, filter?: { owner: `0x${string}`; spender: `0x${string}` }) => {
|
|
1401
|
+
return this.publicClient.watchContractEvent({
|
|
1402
|
+
address: this.contractAddress,
|
|
1403
|
+
abi: UniswapV2Pair_jsonAbi,
|
|
1404
|
+
eventName: 'Approval',
|
|
1405
|
+
args: filter,
|
|
1406
|
+
onLogs: (logs: any[]) => {
|
|
1407
|
+
logs.forEach((log: any) => {
|
|
1408
|
+
callback(log.args as any);
|
|
1409
|
+
});
|
|
1410
|
+
},
|
|
1411
|
+
}) as () => void;
|
|
1412
|
+
},
|
|
1413
|
+
/**
|
|
1414
|
+
* Watch Burn events
|
|
1415
|
+
* @param callback Function to call when event is emitted
|
|
1416
|
+
* @param filter Optional filter for indexed parameters
|
|
1417
|
+
* @returns Unwatch function to stop listening
|
|
1418
|
+
*/
|
|
1419
|
+
Burn: (callback: (event: { sender: `0x${string}`; to: `0x${string}`; amount0: bigint; amount1: bigint }) => void, filter?: { sender: `0x${string}`; to: `0x${string}` }) => {
|
|
1420
|
+
return this.publicClient.watchContractEvent({
|
|
1421
|
+
address: this.contractAddress,
|
|
1422
|
+
abi: UniswapV2Pair_jsonAbi,
|
|
1423
|
+
eventName: 'Burn',
|
|
1424
|
+
args: filter,
|
|
1425
|
+
onLogs: (logs: any[]) => {
|
|
1426
|
+
logs.forEach((log: any) => {
|
|
1427
|
+
callback(log.args as any);
|
|
1428
|
+
});
|
|
1429
|
+
},
|
|
1430
|
+
}) as () => void;
|
|
1431
|
+
},
|
|
1432
|
+
/**
|
|
1433
|
+
* Watch Mint events
|
|
1434
|
+
* @param callback Function to call when event is emitted
|
|
1435
|
+
* @param filter Optional filter for indexed parameters
|
|
1436
|
+
* @returns Unwatch function to stop listening
|
|
1437
|
+
*/
|
|
1438
|
+
Mint: (callback: (event: { sender: `0x${string}`; amount0: bigint; amount1: bigint }) => void, filter?: { sender: `0x${string}` }) => {
|
|
1439
|
+
return this.publicClient.watchContractEvent({
|
|
1440
|
+
address: this.contractAddress,
|
|
1441
|
+
abi: UniswapV2Pair_jsonAbi,
|
|
1442
|
+
eventName: 'Mint',
|
|
1443
|
+
args: filter,
|
|
1444
|
+
onLogs: (logs: any[]) => {
|
|
1445
|
+
logs.forEach((log: any) => {
|
|
1446
|
+
callback(log.args as any);
|
|
1447
|
+
});
|
|
1448
|
+
},
|
|
1449
|
+
}) as () => void;
|
|
1450
|
+
},
|
|
1451
|
+
/**
|
|
1452
|
+
* Watch Swap events
|
|
1453
|
+
* @param callback Function to call when event is emitted
|
|
1454
|
+
* @param filter Optional filter for indexed parameters
|
|
1455
|
+
* @returns Unwatch function to stop listening
|
|
1456
|
+
*/
|
|
1457
|
+
Swap: (callback: (event: { sender: `0x${string}`; to: `0x${string}`; amount0In: bigint; amount1In: bigint; amount0Out: bigint; amount1Out: bigint }) => void, filter?: { sender: `0x${string}`; to: `0x${string}` }) => {
|
|
1458
|
+
return this.publicClient.watchContractEvent({
|
|
1459
|
+
address: this.contractAddress,
|
|
1460
|
+
abi: UniswapV2Pair_jsonAbi,
|
|
1461
|
+
eventName: 'Swap',
|
|
1462
|
+
args: filter,
|
|
1463
|
+
onLogs: (logs: any[]) => {
|
|
1464
|
+
logs.forEach((log: any) => {
|
|
1465
|
+
callback(log.args as any);
|
|
1466
|
+
});
|
|
1467
|
+
},
|
|
1468
|
+
}) as () => void;
|
|
1469
|
+
},
|
|
1470
|
+
/**
|
|
1471
|
+
* Watch Sync events
|
|
1472
|
+
* @param callback Function to call when event is emitted
|
|
1473
|
+
* @param filter Optional filter for indexed parameters
|
|
1474
|
+
* @returns Unwatch function to stop listening
|
|
1475
|
+
*/
|
|
1476
|
+
Sync: (callback: (event: { reserve0: bigint; reserve1: bigint }) => void) => {
|
|
1477
|
+
return this.publicClient.watchContractEvent({
|
|
1478
|
+
address: this.contractAddress,
|
|
1479
|
+
abi: UniswapV2Pair_jsonAbi,
|
|
1480
|
+
eventName: 'Sync',
|
|
1481
|
+
|
|
1482
|
+
onLogs: (logs: any[]) => {
|
|
1483
|
+
logs.forEach((log: any) => {
|
|
1484
|
+
callback(log.args as any);
|
|
1485
|
+
});
|
|
1486
|
+
},
|
|
1487
|
+
}) as () => void;
|
|
1488
|
+
},
|
|
1489
|
+
/**
|
|
1490
|
+
* Watch Transfer events
|
|
1491
|
+
* @param callback Function to call when event is emitted
|
|
1492
|
+
* @param filter Optional filter for indexed parameters
|
|
1493
|
+
* @returns Unwatch function to stop listening
|
|
1494
|
+
*/
|
|
1495
|
+
Transfer: (callback: (event: { from: `0x${string}`; to: `0x${string}`; value: bigint }) => void, filter?: { from: `0x${string}`; to: `0x${string}` }) => {
|
|
1496
|
+
return this.publicClient.watchContractEvent({
|
|
1497
|
+
address: this.contractAddress,
|
|
1498
|
+
abi: UniswapV2Pair_jsonAbi,
|
|
1499
|
+
eventName: 'Transfer',
|
|
1500
|
+
args: filter,
|
|
1501
|
+
onLogs: (logs: any[]) => {
|
|
1502
|
+
logs.forEach((log: any) => {
|
|
1503
|
+
callback(log.args as any);
|
|
1504
|
+
});
|
|
1505
|
+
},
|
|
1506
|
+
}) as () => void;
|
|
1507
|
+
}
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
}
|