@gitmyabi/eusd 1.0.2 → 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,1187 +0,0 @@
1
- import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
2
- import { getContract } from 'viem';
3
-
4
- /**
5
- * EUSD_json ABI
6
- *
7
- * This ABI is typed using viem's type system for full type safety.
8
- */
9
- export const EUSD_jsonAbi = [
10
- {
11
- "inputs": [
12
- {
13
- "internalType": "address",
14
- "name": "_config",
15
- "type": "address"
16
- }
17
- ],
18
- "stateMutability": "nonpayable",
19
- "type": "constructor"
20
- },
21
- {
22
- "anonymous": false,
23
- "inputs": [
24
- {
25
- "indexed": true,
26
- "internalType": "address",
27
- "name": "owner",
28
- "type": "address"
29
- },
30
- {
31
- "indexed": true,
32
- "internalType": "address",
33
- "name": "spender",
34
- "type": "address"
35
- },
36
- {
37
- "indexed": false,
38
- "internalType": "uint256",
39
- "name": "value",
40
- "type": "uint256"
41
- }
42
- ],
43
- "name": "Approval",
44
- "type": "event"
45
- },
46
- {
47
- "anonymous": false,
48
- "inputs": [
49
- {
50
- "indexed": true,
51
- "internalType": "address",
52
- "name": "account",
53
- "type": "address"
54
- },
55
- {
56
- "indexed": false,
57
- "internalType": "uint256",
58
- "name": "preRebaseTokenAmount",
59
- "type": "uint256"
60
- },
61
- {
62
- "indexed": false,
63
- "internalType": "uint256",
64
- "name": "postRebaseTokenAmount",
65
- "type": "uint256"
66
- },
67
- {
68
- "indexed": false,
69
- "internalType": "uint256",
70
- "name": "sharesAmount",
71
- "type": "uint256"
72
- }
73
- ],
74
- "name": "SharesBurnt",
75
- "type": "event"
76
- },
77
- {
78
- "anonymous": false,
79
- "inputs": [
80
- {
81
- "indexed": true,
82
- "internalType": "address",
83
- "name": "from",
84
- "type": "address"
85
- },
86
- {
87
- "indexed": true,
88
- "internalType": "address",
89
- "name": "to",
90
- "type": "address"
91
- },
92
- {
93
- "indexed": false,
94
- "internalType": "uint256",
95
- "name": "value",
96
- "type": "uint256"
97
- }
98
- ],
99
- "name": "Transfer",
100
- "type": "event"
101
- },
102
- {
103
- "anonymous": false,
104
- "inputs": [
105
- {
106
- "indexed": true,
107
- "internalType": "address",
108
- "name": "from",
109
- "type": "address"
110
- },
111
- {
112
- "indexed": true,
113
- "internalType": "address",
114
- "name": "to",
115
- "type": "address"
116
- },
117
- {
118
- "indexed": false,
119
- "internalType": "uint256",
120
- "name": "sharesValue",
121
- "type": "uint256"
122
- }
123
- ],
124
- "name": "TransferShares",
125
- "type": "event"
126
- },
127
- {
128
- "inputs": [
129
- {
130
- "internalType": "address",
131
- "name": "_owner",
132
- "type": "address"
133
- },
134
- {
135
- "internalType": "address",
136
- "name": "_spender",
137
- "type": "address"
138
- }
139
- ],
140
- "name": "allowance",
141
- "outputs": [
142
- {
143
- "internalType": "uint256",
144
- "name": "",
145
- "type": "uint256"
146
- }
147
- ],
148
- "stateMutability": "view",
149
- "type": "function"
150
- },
151
- {
152
- "inputs": [
153
- {
154
- "internalType": "address",
155
- "name": "_spender",
156
- "type": "address"
157
- },
158
- {
159
- "internalType": "uint256",
160
- "name": "_amount",
161
- "type": "uint256"
162
- }
163
- ],
164
- "name": "approve",
165
- "outputs": [
166
- {
167
- "internalType": "bool",
168
- "name": "",
169
- "type": "bool"
170
- }
171
- ],
172
- "stateMutability": "nonpayable",
173
- "type": "function"
174
- },
175
- {
176
- "inputs": [
177
- {
178
- "internalType": "address",
179
- "name": "_account",
180
- "type": "address"
181
- }
182
- ],
183
- "name": "balanceOf",
184
- "outputs": [
185
- {
186
- "internalType": "uint256",
187
- "name": "",
188
- "type": "uint256"
189
- }
190
- ],
191
- "stateMutability": "view",
192
- "type": "function"
193
- },
194
- {
195
- "inputs": [
196
- {
197
- "internalType": "address",
198
- "name": "_account",
199
- "type": "address"
200
- },
201
- {
202
- "internalType": "uint256",
203
- "name": "_burnAmount",
204
- "type": "uint256"
205
- }
206
- ],
207
- "name": "burn",
208
- "outputs": [
209
- {
210
- "internalType": "uint256",
211
- "name": "newTotalShares",
212
- "type": "uint256"
213
- }
214
- ],
215
- "stateMutability": "nonpayable",
216
- "type": "function"
217
- },
218
- {
219
- "inputs": [
220
- {
221
- "internalType": "address",
222
- "name": "_account",
223
- "type": "address"
224
- },
225
- {
226
- "internalType": "uint256",
227
- "name": "_sharesAmount",
228
- "type": "uint256"
229
- }
230
- ],
231
- "name": "burnShares",
232
- "outputs": [
233
- {
234
- "internalType": "uint256",
235
- "name": "newTotalShares",
236
- "type": "uint256"
237
- }
238
- ],
239
- "stateMutability": "nonpayable",
240
- "type": "function"
241
- },
242
- {
243
- "inputs": [],
244
- "name": "configurator",
245
- "outputs": [
246
- {
247
- "internalType": "contract Iconfigurator",
248
- "name": "",
249
- "type": "address"
250
- }
251
- ],
252
- "stateMutability": "view",
253
- "type": "function"
254
- },
255
- {
256
- "inputs": [],
257
- "name": "decimals",
258
- "outputs": [
259
- {
260
- "internalType": "uint8",
261
- "name": "",
262
- "type": "uint8"
263
- }
264
- ],
265
- "stateMutability": "pure",
266
- "type": "function"
267
- },
268
- {
269
- "inputs": [
270
- {
271
- "internalType": "address",
272
- "name": "spender",
273
- "type": "address"
274
- },
275
- {
276
- "internalType": "uint256",
277
- "name": "subtractedValue",
278
- "type": "uint256"
279
- }
280
- ],
281
- "name": "decreaseAllowance",
282
- "outputs": [
283
- {
284
- "internalType": "bool",
285
- "name": "",
286
- "type": "bool"
287
- }
288
- ],
289
- "stateMutability": "nonpayable",
290
- "type": "function"
291
- },
292
- {
293
- "inputs": [
294
- {
295
- "internalType": "uint256",
296
- "name": "_sharesAmount",
297
- "type": "uint256"
298
- }
299
- ],
300
- "name": "getMintedEUSDByShares",
301
- "outputs": [
302
- {
303
- "internalType": "uint256",
304
- "name": "",
305
- "type": "uint256"
306
- }
307
- ],
308
- "stateMutability": "view",
309
- "type": "function"
310
- },
311
- {
312
- "inputs": [
313
- {
314
- "internalType": "uint256",
315
- "name": "_EUSDAmount",
316
- "type": "uint256"
317
- }
318
- ],
319
- "name": "getSharesByMintedEUSD",
320
- "outputs": [
321
- {
322
- "internalType": "uint256",
323
- "name": "",
324
- "type": "uint256"
325
- }
326
- ],
327
- "stateMutability": "view",
328
- "type": "function"
329
- },
330
- {
331
- "inputs": [],
332
- "name": "getTotalShares",
333
- "outputs": [
334
- {
335
- "internalType": "uint256",
336
- "name": "",
337
- "type": "uint256"
338
- }
339
- ],
340
- "stateMutability": "view",
341
- "type": "function"
342
- },
343
- {
344
- "inputs": [
345
- {
346
- "internalType": "address",
347
- "name": "_spender",
348
- "type": "address"
349
- },
350
- {
351
- "internalType": "uint256",
352
- "name": "_addedValue",
353
- "type": "uint256"
354
- }
355
- ],
356
- "name": "increaseAllowance",
357
- "outputs": [
358
- {
359
- "internalType": "bool",
360
- "name": "",
361
- "type": "bool"
362
- }
363
- ],
364
- "stateMutability": "nonpayable",
365
- "type": "function"
366
- },
367
- {
368
- "inputs": [
369
- {
370
- "internalType": "address",
371
- "name": "_recipient",
372
- "type": "address"
373
- },
374
- {
375
- "internalType": "uint256",
376
- "name": "_mintAmount",
377
- "type": "uint256"
378
- }
379
- ],
380
- "name": "mint",
381
- "outputs": [
382
- {
383
- "internalType": "uint256",
384
- "name": "newTotalShares",
385
- "type": "uint256"
386
- }
387
- ],
388
- "stateMutability": "nonpayable",
389
- "type": "function"
390
- },
391
- {
392
- "inputs": [],
393
- "name": "name",
394
- "outputs": [
395
- {
396
- "internalType": "string",
397
- "name": "",
398
- "type": "string"
399
- }
400
- ],
401
- "stateMutability": "pure",
402
- "type": "function"
403
- },
404
- {
405
- "inputs": [
406
- {
407
- "internalType": "address",
408
- "name": "_account",
409
- "type": "address"
410
- }
411
- ],
412
- "name": "sharesOf",
413
- "outputs": [
414
- {
415
- "internalType": "uint256",
416
- "name": "",
417
- "type": "uint256"
418
- }
419
- ],
420
- "stateMutability": "view",
421
- "type": "function"
422
- },
423
- {
424
- "inputs": [],
425
- "name": "symbol",
426
- "outputs": [
427
- {
428
- "internalType": "string",
429
- "name": "",
430
- "type": "string"
431
- }
432
- ],
433
- "stateMutability": "pure",
434
- "type": "function"
435
- },
436
- {
437
- "inputs": [],
438
- "name": "totalSupply",
439
- "outputs": [
440
- {
441
- "internalType": "uint256",
442
- "name": "",
443
- "type": "uint256"
444
- }
445
- ],
446
- "stateMutability": "view",
447
- "type": "function"
448
- },
449
- {
450
- "inputs": [
451
- {
452
- "internalType": "address",
453
- "name": "_recipient",
454
- "type": "address"
455
- },
456
- {
457
- "internalType": "uint256",
458
- "name": "_amount",
459
- "type": "uint256"
460
- }
461
- ],
462
- "name": "transfer",
463
- "outputs": [
464
- {
465
- "internalType": "bool",
466
- "name": "",
467
- "type": "bool"
468
- }
469
- ],
470
- "stateMutability": "nonpayable",
471
- "type": "function"
472
- },
473
- {
474
- "inputs": [
475
- {
476
- "internalType": "address",
477
- "name": "from",
478
- "type": "address"
479
- },
480
- {
481
- "internalType": "address",
482
- "name": "to",
483
- "type": "address"
484
- },
485
- {
486
- "internalType": "uint256",
487
- "name": "amount",
488
- "type": "uint256"
489
- }
490
- ],
491
- "name": "transferFrom",
492
- "outputs": [
493
- {
494
- "internalType": "bool",
495
- "name": "",
496
- "type": "bool"
497
- }
498
- ],
499
- "stateMutability": "nonpayable",
500
- "type": "function"
501
- },
502
- {
503
- "inputs": [
504
- {
505
- "internalType": "address",
506
- "name": "_recipient",
507
- "type": "address"
508
- },
509
- {
510
- "internalType": "uint256",
511
- "name": "_sharesAmount",
512
- "type": "uint256"
513
- }
514
- ],
515
- "name": "transferShares",
516
- "outputs": [
517
- {
518
- "internalType": "uint256",
519
- "name": "",
520
- "type": "uint256"
521
- }
522
- ],
523
- "stateMutability": "nonpayable",
524
- "type": "function"
525
- }
526
- ] as const satisfies Abi;
527
-
528
- /**
529
- * Type-safe ABI for EUSD_json
530
- */
531
- export type EUSD_jsonAbi = typeof EUSD_jsonAbi;
532
-
533
- /**
534
- * Contract instance type for EUSD_json
535
- */
536
- // Use any for contract type to avoid complex viem type issues
537
- // The runtime behavior is type-safe through viem's ABI typing
538
- export type EUSD_jsonContract = any;
539
-
540
- /**
541
- * EUSD_json Contract Class
542
- *
543
- * Provides a class-based API similar to TypeChain for interacting with the contract.
544
- *
545
- * @example
546
- * ```typescript
547
- * import { createPublicClient, createWalletClient, http } from 'viem';
548
- * import { mainnet } from 'viem/chains';
549
- * import { EUSD_json } from 'EUSD_json';
550
- *
551
- * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
552
- * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
553
- *
554
- * const contract = new EUSD_json('0x...', { publicClient, walletClient });
555
- *
556
- * // Read functions
557
- * const result = await contract.balanceOf('0x...');
558
- *
559
- * // Write functions
560
- * const hash = await contract.transfer('0x...', 1000n);
561
- *
562
- * // Simulate transactions (dry-run)
563
- * const simulation = await contract.simulate.transfer('0x...', 1000n);
564
- * console.log('Gas estimate:', simulation.request.gas);
565
- *
566
- * // Watch events
567
- * const unwatch = contract.watch.Transfer((event) => {
568
- * console.log('Transfer event:', event);
569
- * });
570
- * ```
571
- */
572
- export class EUSD_json {
573
- private contract: EUSD_jsonContract;
574
- private contractAddress: Address;
575
- private publicClient: PublicClient;
576
-
577
- constructor(
578
- address: Address,
579
- clients: {
580
- publicClient: PublicClient;
581
- walletClient?: WalletClient;
582
- }
583
- ) {
584
- this.contractAddress = address;
585
- this.publicClient = clients.publicClient;
586
- this.contract = getContract({
587
- address,
588
- abi: EUSD_jsonAbi,
589
- client: {
590
- public: clients.publicClient,
591
- wallet: clients.walletClient,
592
- },
593
- });
594
- }
595
-
596
- /**
597
- * Get the contract address
598
- */
599
- get address(): Address {
600
- return this.contractAddress;
601
- }
602
-
603
- /**
604
- * Get the underlying viem contract instance
605
- */
606
- getContract(): EUSD_jsonContract {
607
- return this.contract;
608
- }
609
-
610
- /**
611
- * allowance
612
- * view
613
- */
614
- async allowance(_owner: `0x${string}`, _spender: `0x${string}`): Promise<bigint> {
615
- return this.contract.read.allowance([_owner, _spender] as const) as Promise<bigint>;
616
- }
617
-
618
- /**
619
- * balanceOf
620
- * view
621
- */
622
- async balanceOf(_account: `0x${string}`): Promise<bigint> {
623
- return this.contract.read.balanceOf([_account] as const) as Promise<bigint>;
624
- }
625
-
626
- /**
627
- * configurator
628
- * view
629
- */
630
- async configurator(): Promise<`0x${string}`> {
631
- return this.contract.read.configurator() as Promise<`0x${string}`>;
632
- }
633
-
634
- /**
635
- * decimals
636
- * pure
637
- */
638
- async decimals(): Promise<bigint> {
639
- return this.contract.read.decimals() as Promise<bigint>;
640
- }
641
-
642
- /**
643
- * getMintedEUSDByShares
644
- * view
645
- */
646
- async getMintedEUSDByShares(_sharesAmount: bigint): Promise<bigint> {
647
- return this.contract.read.getMintedEUSDByShares([_sharesAmount] as const) as Promise<bigint>;
648
- }
649
-
650
- /**
651
- * getSharesByMintedEUSD
652
- * view
653
- */
654
- async getSharesByMintedEUSD(_EUSDAmount: bigint): Promise<bigint> {
655
- return this.contract.read.getSharesByMintedEUSD([_EUSDAmount] as const) as Promise<bigint>;
656
- }
657
-
658
- /**
659
- * getTotalShares
660
- * view
661
- */
662
- async getTotalShares(): Promise<bigint> {
663
- return this.contract.read.getTotalShares() as Promise<bigint>;
664
- }
665
-
666
- /**
667
- * name
668
- * pure
669
- */
670
- async name(): Promise<string> {
671
- return this.contract.read.name() as Promise<string>;
672
- }
673
-
674
- /**
675
- * sharesOf
676
- * view
677
- */
678
- async sharesOf(_account: `0x${string}`): Promise<bigint> {
679
- return this.contract.read.sharesOf([_account] as const) as Promise<bigint>;
680
- }
681
-
682
- /**
683
- * symbol
684
- * pure
685
- */
686
- async symbol(): Promise<string> {
687
- return this.contract.read.symbol() as Promise<string>;
688
- }
689
-
690
- /**
691
- * totalSupply
692
- * view
693
- */
694
- async totalSupply(): Promise<bigint> {
695
- return this.contract.read.totalSupply() as Promise<bigint>;
696
- }
697
-
698
- /**
699
- * approve
700
- * nonpayable
701
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
702
- */
703
- async approve(_spender: `0x${string}`, _amount: bigint, options?: {
704
- accessList?: import('viem').AccessList;
705
- authorizationList?: import('viem').AuthorizationList;
706
- chain?: import('viem').Chain | null;
707
- dataSuffix?: `0x${string}`;
708
- gas?: bigint;
709
- gasPrice?: bigint;
710
- maxFeePerGas?: bigint;
711
- maxPriorityFeePerGas?: bigint;
712
- nonce?: number;
713
- value?: bigint;
714
- }): Promise<`0x${string}`> {
715
- if (!this.contract.write) {
716
- throw new Error('Wallet client is required for write operations');
717
- }
718
- return this.contract.write.approve([_spender, _amount] as const, options) as Promise<`0x${string}`>;
719
- }
720
-
721
- /**
722
- * burn
723
- * nonpayable
724
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
725
- */
726
- async burn(_account: `0x${string}`, _burnAmount: bigint, options?: {
727
- accessList?: import('viem').AccessList;
728
- authorizationList?: import('viem').AuthorizationList;
729
- chain?: import('viem').Chain | null;
730
- dataSuffix?: `0x${string}`;
731
- gas?: bigint;
732
- gasPrice?: bigint;
733
- maxFeePerGas?: bigint;
734
- maxPriorityFeePerGas?: bigint;
735
- nonce?: number;
736
- value?: bigint;
737
- }): Promise<`0x${string}`> {
738
- if (!this.contract.write) {
739
- throw new Error('Wallet client is required for write operations');
740
- }
741
- return this.contract.write.burn([_account, _burnAmount] as const, options) as Promise<`0x${string}`>;
742
- }
743
-
744
- /**
745
- * burnShares
746
- * nonpayable
747
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
748
- */
749
- async burnShares(_account: `0x${string}`, _sharesAmount: bigint, options?: {
750
- accessList?: import('viem').AccessList;
751
- authorizationList?: import('viem').AuthorizationList;
752
- chain?: import('viem').Chain | null;
753
- dataSuffix?: `0x${string}`;
754
- gas?: bigint;
755
- gasPrice?: bigint;
756
- maxFeePerGas?: bigint;
757
- maxPriorityFeePerGas?: bigint;
758
- nonce?: number;
759
- value?: bigint;
760
- }): Promise<`0x${string}`> {
761
- if (!this.contract.write) {
762
- throw new Error('Wallet client is required for write operations');
763
- }
764
- return this.contract.write.burnShares([_account, _sharesAmount] as const, options) as Promise<`0x${string}`>;
765
- }
766
-
767
- /**
768
- * decreaseAllowance
769
- * nonpayable
770
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
771
- */
772
- async decreaseAllowance(spender: `0x${string}`, subtractedValue: bigint, options?: {
773
- accessList?: import('viem').AccessList;
774
- authorizationList?: import('viem').AuthorizationList;
775
- chain?: import('viem').Chain | null;
776
- dataSuffix?: `0x${string}`;
777
- gas?: bigint;
778
- gasPrice?: bigint;
779
- maxFeePerGas?: bigint;
780
- maxPriorityFeePerGas?: bigint;
781
- nonce?: number;
782
- value?: bigint;
783
- }): Promise<`0x${string}`> {
784
- if (!this.contract.write) {
785
- throw new Error('Wallet client is required for write operations');
786
- }
787
- return this.contract.write.decreaseAllowance([spender, subtractedValue] as const, options) as Promise<`0x${string}`>;
788
- }
789
-
790
- /**
791
- * increaseAllowance
792
- * nonpayable
793
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
794
- */
795
- async increaseAllowance(_spender: `0x${string}`, _addedValue: bigint, options?: {
796
- accessList?: import('viem').AccessList;
797
- authorizationList?: import('viem').AuthorizationList;
798
- chain?: import('viem').Chain | null;
799
- dataSuffix?: `0x${string}`;
800
- gas?: bigint;
801
- gasPrice?: bigint;
802
- maxFeePerGas?: bigint;
803
- maxPriorityFeePerGas?: bigint;
804
- nonce?: number;
805
- value?: bigint;
806
- }): Promise<`0x${string}`> {
807
- if (!this.contract.write) {
808
- throw new Error('Wallet client is required for write operations');
809
- }
810
- return this.contract.write.increaseAllowance([_spender, _addedValue] as const, options) as Promise<`0x${string}`>;
811
- }
812
-
813
- /**
814
- * mint
815
- * nonpayable
816
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
817
- */
818
- async mint(_recipient: `0x${string}`, _mintAmount: bigint, options?: {
819
- accessList?: import('viem').AccessList;
820
- authorizationList?: import('viem').AuthorizationList;
821
- chain?: import('viem').Chain | null;
822
- dataSuffix?: `0x${string}`;
823
- gas?: bigint;
824
- gasPrice?: bigint;
825
- maxFeePerGas?: bigint;
826
- maxPriorityFeePerGas?: bigint;
827
- nonce?: number;
828
- value?: bigint;
829
- }): Promise<`0x${string}`> {
830
- if (!this.contract.write) {
831
- throw new Error('Wallet client is required for write operations');
832
- }
833
- return this.contract.write.mint([_recipient, _mintAmount] as const, options) as Promise<`0x${string}`>;
834
- }
835
-
836
- /**
837
- * transfer
838
- * nonpayable
839
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
840
- */
841
- async transfer(_recipient: `0x${string}`, _amount: bigint, options?: {
842
- accessList?: import('viem').AccessList;
843
- authorizationList?: import('viem').AuthorizationList;
844
- chain?: import('viem').Chain | null;
845
- dataSuffix?: `0x${string}`;
846
- gas?: bigint;
847
- gasPrice?: bigint;
848
- maxFeePerGas?: bigint;
849
- maxPriorityFeePerGas?: bigint;
850
- nonce?: number;
851
- value?: bigint;
852
- }): Promise<`0x${string}`> {
853
- if (!this.contract.write) {
854
- throw new Error('Wallet client is required for write operations');
855
- }
856
- return this.contract.write.transfer([_recipient, _amount] as const, options) as Promise<`0x${string}`>;
857
- }
858
-
859
- /**
860
- * transferFrom
861
- * nonpayable
862
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
863
- */
864
- async transferFrom(from: `0x${string}`, to: `0x${string}`, amount: bigint, 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.transferFrom([from, to, amount] as const, options) as Promise<`0x${string}`>;
880
- }
881
-
882
- /**
883
- * transferShares
884
- * nonpayable
885
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
886
- */
887
- async transferShares(_recipient: `0x${string}`, _sharesAmount: bigint, 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.transferShares([_recipient, _sharesAmount] as const, options) as Promise<`0x${string}`>;
903
- }
904
-
905
-
906
-
907
- /**
908
- * Simulate contract write operations (dry-run without sending transaction)
909
- *
910
- * @example
911
- * const result = await contract.simulate.transfer('0x...', 1000n);
912
- * console.log('Gas estimate:', result.request.gas);
913
- * console.log('Would succeed:', result.result);
914
- */
915
- get simulate() {
916
- const contract = this.contract;
917
- if (!contract.simulate) {
918
- throw new Error('Public client is required for simulation');
919
- }
920
- return {
921
- /**
922
- * Simulate approve
923
- * Returns gas estimate and result without sending transaction
924
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
925
- */
926
- async approve(_spender: `0x${string}`, _amount: bigint, options?: {
927
- accessList?: import('viem').AccessList;
928
- authorizationList?: import('viem').AuthorizationList;
929
- chain?: import('viem').Chain | null;
930
- dataSuffix?: `0x${string}`;
931
- gas?: bigint;
932
- gasPrice?: bigint;
933
- maxFeePerGas?: bigint;
934
- maxPriorityFeePerGas?: bigint;
935
- nonce?: number;
936
- value?: bigint;
937
- }): Promise<boolean> {
938
- return contract.simulate.approve([_spender, _amount] as const, options) as Promise<boolean>;
939
- },
940
- /**
941
- * Simulate burn
942
- * Returns gas estimate and result without sending transaction
943
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
944
- */
945
- async burn(_account: `0x${string}`, _burnAmount: bigint, options?: {
946
- accessList?: import('viem').AccessList;
947
- authorizationList?: import('viem').AuthorizationList;
948
- chain?: import('viem').Chain | null;
949
- dataSuffix?: `0x${string}`;
950
- gas?: bigint;
951
- gasPrice?: bigint;
952
- maxFeePerGas?: bigint;
953
- maxPriorityFeePerGas?: bigint;
954
- nonce?: number;
955
- value?: bigint;
956
- }): Promise<bigint> {
957
- return contract.simulate.burn([_account, _burnAmount] as const, options) as Promise<bigint>;
958
- },
959
- /**
960
- * Simulate burnShares
961
- * Returns gas estimate and result without sending transaction
962
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
963
- */
964
- async burnShares(_account: `0x${string}`, _sharesAmount: bigint, options?: {
965
- accessList?: import('viem').AccessList;
966
- authorizationList?: import('viem').AuthorizationList;
967
- chain?: import('viem').Chain | null;
968
- dataSuffix?: `0x${string}`;
969
- gas?: bigint;
970
- gasPrice?: bigint;
971
- maxFeePerGas?: bigint;
972
- maxPriorityFeePerGas?: bigint;
973
- nonce?: number;
974
- value?: bigint;
975
- }): Promise<bigint> {
976
- return contract.simulate.burnShares([_account, _sharesAmount] as const, options) as Promise<bigint>;
977
- },
978
- /**
979
- * Simulate decreaseAllowance
980
- * Returns gas estimate and result without sending transaction
981
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
982
- */
983
- async decreaseAllowance(spender: `0x${string}`, subtractedValue: bigint, options?: {
984
- accessList?: import('viem').AccessList;
985
- authorizationList?: import('viem').AuthorizationList;
986
- chain?: import('viem').Chain | null;
987
- dataSuffix?: `0x${string}`;
988
- gas?: bigint;
989
- gasPrice?: bigint;
990
- maxFeePerGas?: bigint;
991
- maxPriorityFeePerGas?: bigint;
992
- nonce?: number;
993
- value?: bigint;
994
- }): Promise<boolean> {
995
- return contract.simulate.decreaseAllowance([spender, subtractedValue] as const, options) as Promise<boolean>;
996
- },
997
- /**
998
- * Simulate increaseAllowance
999
- * Returns gas estimate and result without sending transaction
1000
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1001
- */
1002
- async increaseAllowance(_spender: `0x${string}`, _addedValue: 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<boolean> {
1014
- return contract.simulate.increaseAllowance([_spender, _addedValue] as const, options) as Promise<boolean>;
1015
- },
1016
- /**
1017
- * Simulate mint
1018
- * Returns gas estimate and result without sending transaction
1019
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1020
- */
1021
- async mint(_recipient: `0x${string}`, _mintAmount: bigint, options?: {
1022
- accessList?: import('viem').AccessList;
1023
- authorizationList?: import('viem').AuthorizationList;
1024
- chain?: import('viem').Chain | null;
1025
- dataSuffix?: `0x${string}`;
1026
- gas?: bigint;
1027
- gasPrice?: bigint;
1028
- maxFeePerGas?: bigint;
1029
- maxPriorityFeePerGas?: bigint;
1030
- nonce?: number;
1031
- value?: bigint;
1032
- }): Promise<bigint> {
1033
- return contract.simulate.mint([_recipient, _mintAmount] as const, options) as Promise<bigint>;
1034
- },
1035
- /**
1036
- * Simulate transfer
1037
- * Returns gas estimate and result without sending transaction
1038
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1039
- */
1040
- async transfer(_recipient: `0x${string}`, _amount: bigint, options?: {
1041
- accessList?: import('viem').AccessList;
1042
- authorizationList?: import('viem').AuthorizationList;
1043
- chain?: import('viem').Chain | null;
1044
- dataSuffix?: `0x${string}`;
1045
- gas?: bigint;
1046
- gasPrice?: bigint;
1047
- maxFeePerGas?: bigint;
1048
- maxPriorityFeePerGas?: bigint;
1049
- nonce?: number;
1050
- value?: bigint;
1051
- }): Promise<boolean> {
1052
- return contract.simulate.transfer([_recipient, _amount] as const, options) as Promise<boolean>;
1053
- },
1054
- /**
1055
- * Simulate transferFrom
1056
- * Returns gas estimate and result without sending transaction
1057
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1058
- */
1059
- async transferFrom(from: `0x${string}`, to: `0x${string}`, amount: bigint, options?: {
1060
- accessList?: import('viem').AccessList;
1061
- authorizationList?: import('viem').AuthorizationList;
1062
- chain?: import('viem').Chain | null;
1063
- dataSuffix?: `0x${string}`;
1064
- gas?: bigint;
1065
- gasPrice?: bigint;
1066
- maxFeePerGas?: bigint;
1067
- maxPriorityFeePerGas?: bigint;
1068
- nonce?: number;
1069
- value?: bigint;
1070
- }): Promise<boolean> {
1071
- return contract.simulate.transferFrom([from, to, amount] as const, options) as Promise<boolean>;
1072
- },
1073
- /**
1074
- * Simulate transferShares
1075
- * Returns gas estimate and result without sending transaction
1076
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
1077
- */
1078
- async transferShares(_recipient: `0x${string}`, _sharesAmount: bigint, options?: {
1079
- accessList?: import('viem').AccessList;
1080
- authorizationList?: import('viem').AuthorizationList;
1081
- chain?: import('viem').Chain | null;
1082
- dataSuffix?: `0x${string}`;
1083
- gas?: bigint;
1084
- gasPrice?: bigint;
1085
- maxFeePerGas?: bigint;
1086
- maxPriorityFeePerGas?: bigint;
1087
- nonce?: number;
1088
- value?: bigint;
1089
- }): Promise<bigint> {
1090
- return contract.simulate.transferShares([_recipient, _sharesAmount] as const, options) as Promise<bigint>;
1091
- }
1092
- };
1093
- }
1094
-
1095
- /**
1096
- * Watch contract events
1097
- *
1098
- * @example
1099
- * // Watch all Transfer events
1100
- * const unwatch = contract.watch.Transfer((event) => {
1101
- * console.log('Transfer:', event);
1102
- * });
1103
- *
1104
- * // Stop watching
1105
- * unwatch();
1106
- */
1107
- get watch() {
1108
- return {
1109
- /**
1110
- * Watch Approval events
1111
- * @param callback Function to call when event is emitted
1112
- * @param filter Optional filter for indexed parameters
1113
- * @returns Unwatch function to stop listening
1114
- */
1115
- Approval: (callback: (event: { owner: `0x${string}`; spender: `0x${string}`; value: bigint }) => void, filter?: { owner: `0x${string}`; spender: `0x${string}` }) => {
1116
- return this.publicClient.watchContractEvent({
1117
- address: this.contractAddress,
1118
- abi: EUSD_jsonAbi,
1119
- eventName: 'Approval',
1120
- args: filter,
1121
- onLogs: (logs: any[]) => {
1122
- logs.forEach((log: any) => {
1123
- callback(log.args as any);
1124
- });
1125
- },
1126
- }) as () => void;
1127
- },
1128
- /**
1129
- * Watch SharesBurnt events
1130
- * @param callback Function to call when event is emitted
1131
- * @param filter Optional filter for indexed parameters
1132
- * @returns Unwatch function to stop listening
1133
- */
1134
- SharesBurnt: (callback: (event: { account: `0x${string}`; preRebaseTokenAmount: bigint; postRebaseTokenAmount: bigint; sharesAmount: bigint }) => void, filter?: { account: `0x${string}` }) => {
1135
- return this.publicClient.watchContractEvent({
1136
- address: this.contractAddress,
1137
- abi: EUSD_jsonAbi,
1138
- eventName: 'SharesBurnt',
1139
- args: filter,
1140
- onLogs: (logs: any[]) => {
1141
- logs.forEach((log: any) => {
1142
- callback(log.args as any);
1143
- });
1144
- },
1145
- }) as () => void;
1146
- },
1147
- /**
1148
- * Watch Transfer events
1149
- * @param callback Function to call when event is emitted
1150
- * @param filter Optional filter for indexed parameters
1151
- * @returns Unwatch function to stop listening
1152
- */
1153
- Transfer: (callback: (event: { from: `0x${string}`; to: `0x${string}`; value: bigint }) => void, filter?: { from: `0x${string}`; to: `0x${string}` }) => {
1154
- return this.publicClient.watchContractEvent({
1155
- address: this.contractAddress,
1156
- abi: EUSD_jsonAbi,
1157
- eventName: 'Transfer',
1158
- args: filter,
1159
- onLogs: (logs: any[]) => {
1160
- logs.forEach((log: any) => {
1161
- callback(log.args as any);
1162
- });
1163
- },
1164
- }) as () => void;
1165
- },
1166
- /**
1167
- * Watch TransferShares events
1168
- * @param callback Function to call when event is emitted
1169
- * @param filter Optional filter for indexed parameters
1170
- * @returns Unwatch function to stop listening
1171
- */
1172
- TransferShares: (callback: (event: { from: `0x${string}`; to: `0x${string}`; sharesValue: bigint }) => void, filter?: { from: `0x${string}`; to: `0x${string}` }) => {
1173
- return this.publicClient.watchContractEvent({
1174
- address: this.contractAddress,
1175
- abi: EUSD_jsonAbi,
1176
- eventName: 'TransferShares',
1177
- args: filter,
1178
- onLogs: (logs: any[]) => {
1179
- logs.forEach((log: any) => {
1180
- callback(log.args as any);
1181
- });
1182
- },
1183
- }) as () => void;
1184
- }
1185
- };
1186
- }
1187
- }