@gitmyabi/oracle 1.0.0 → 1.0.1

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