@gitmyabi/usd 1.0.0 → 1.0.3

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