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