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