@curvefi/api 2.3.2 → 2.4.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.
package/README.md CHANGED
@@ -424,6 +424,7 @@ import curve from "@curvefi/api";
424
424
 
425
425
  await compound.stats.parameters();
426
426
  // {
427
+ // lpTokenSupply: '66658430.461661546713781772',
427
428
  // virtualPrice: '1.107067773320466717',
428
429
  // fee: '0.04',
429
430
  // adminFee: '0.02',
@@ -1070,21 +1071,94 @@ import curve from "@curvefi/api";
1070
1071
  })()
1071
1072
  ```
1072
1073
 
1073
- ## Rewards
1074
+ ## CRV. Profit, claim, boosting
1074
1075
  ```ts
1075
1076
  import curve from "@curvefi/api";
1076
1077
 
1077
1078
  (async () => {
1078
- await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0 });
1079
-
1080
- const pool = curve.getPool('susd');
1079
+ await curve.init('JsonRpc', {}, { gasPrice: 0 });
1081
1080
 
1082
- // CRV
1081
+ const pool = curve.getPool('compound');
1082
+
1083
+ await pool.depositAndStake([1000, 1000]);
1084
+ await pool.crvProfit();
1085
+ // {
1086
+ // day: '0.01861607837347995222',
1087
+ // week: '0.13031254861435966551',
1088
+ // month: '0.55848235120439856649',
1089
+ // year: '6.79486860632018255891',
1090
+ // token: '0xd533a949740bb3306d119cc777fa900ba034cd52',
1091
+ // symbol: 'CRV',
1092
+ // price: 0.978134
1093
+ // }
1094
+ await pool.stats.tokenApy();
1095
+ // [ '0.3324', '0.8309' ]
1096
+ await pool.currentCrvApy();
1097
+ // 0.3324
1098
+ await pool.boost();
1099
+ // 1.0
1100
+
1101
+ await curve.boosting.createLock(10000, 365 * 4);
1102
+ await pool.depositAndStake([1000, 1000]);
1103
+ // crvProfit = {
1104
+ // day: '0.05703837081508656944',
1105
+ // week: '0.39926859570560598606',
1106
+ // month: '1.7111511244525970831',
1107
+ // year: '20.81900534750659784443',
1108
+ // token: '0xd533a949740bb3306d119cc777fa900ba034cd52',
1109
+ // symbol: 'CRV',
1110
+ // price: 0.978134
1111
+ // }
1112
+ //
1113
+ // currentApy = 0.5092
1114
+ // boost = 1.532
1115
+
1116
+ await pool.wallet.lpTokenBalances();
1117
+ // { lpToken: '0.0', gauge: '3610.795806899650569624' }
1118
+ await pool.maxBoostedStake();
1119
+ // 1281.660714834072909477
1120
+
1121
+ // ------ Wait some time... ------
1083
1122
  await pool.claimableCrv();
1084
- // 0.006296257916265276
1123
+ // 0.4085482040149887
1085
1124
  await pool.claimCrv();
1125
+ // claimableCrv = 0.0
1126
+ })()
1127
+ ```
1128
+
1129
+ ## Rewards. Profit and claim
1130
+ ```ts
1131
+ import curve from "@curvefi/api";
1086
1132
 
1087
- // Additional rewards
1133
+ (async () => {
1134
+ await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0 });
1135
+
1136
+ const pool = curve.getPool('susd');
1137
+
1138
+ await pool.rewardTokens();
1139
+ // [
1140
+ // {
1141
+ // token: '0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f',
1142
+ // symbol: 'SNX',
1143
+ // decimals: 18
1144
+ // }
1145
+ // ]
1146
+ await pool.depositAndStake([1000, 1000, 1000, 1000]);
1147
+ await pool.rewardsProfit();
1148
+ // [
1149
+ // {
1150
+ // day: '0.02387645750842563304',
1151
+ // week: '0.16713520255897943129',
1152
+ // month: '0.71629372525276899123',
1153
+ // year: '8.71490699057535605995',
1154
+ // token: '0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f',
1155
+ // symbol: 'SNX',
1156
+ // price: 2.61
1157
+ // }
1158
+ // ]
1159
+
1160
+ // ------ Wait some time... ------
1161
+
1088
1162
  await pool.claimableRewards();
1089
1163
  // [
1090
1164
  // {
@@ -1094,8 +1168,56 @@ import curve from "@curvefi/api";
1094
1168
  // }
1095
1169
  // ]
1096
1170
  await pool.claimRewards();
1171
+ // claimableRewards = [
1172
+ // {
1173
+ // token: '0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f',
1174
+ // symbol: 'SNX',
1175
+ // amount: '0.0'
1176
+ // }
1177
+ // ]
1097
1178
  })()
1098
1179
  ```
1180
+ ## User balances, base profit and share
1181
+ ```ts
1182
+ (async () => {
1183
+ await curve.init('JsonRpc', {}, { gasPrice: 0 });
1184
+
1185
+ const pool = curve.getPool('frax');
1186
+
1187
+ await pool.deposit([1000, 1000, 1000, 1000]);
1188
+ // { lpToken: '3967.761942945398518479', gauge: '0.0' }
1189
+ await pool.stake(2000);
1190
+ // { lpToken: '1967.761942945398518479', gauge: '2000.0' }
1191
+
1192
+ await pool.userBalances();
1193
+ // [
1194
+ // '2489.266644542275414077',
1195
+ // '276.21290758040371998',
1196
+ // '280.160024',
1197
+ // '955.058471'
1198
+ // ]
1199
+ await pool.userWrappedBalances();
1200
+ // [ '2489.266644542275414077', '1479.135765218522838249' ]
1201
+ await pool.userLiquidityUSD();
1202
+ // 4003.16466431
1203
+ await pool.baseProfit();
1204
+ // {
1205
+ // day: '0.01476134356908610233',
1206
+ // week: '0.1036132769753159106',
1207
+ // month: '0.44899086689303561258',
1208
+ // year: '5.38789040271642735101374407'
1209
+ // }
1210
+ await pool.userShare();
1211
+ // {
1212
+ // lpUser: '3967.761942945398518479',
1213
+ // lpTotal: '1124490985.047288488832152598',
1214
+ // lpShare: '0.000352849600015116',
1215
+ // gaugeUser: '2000.0',
1216
+ // gaugeTotal: '1123703753.306098922471106555',
1217
+ // gaugeShare: '0.000177982853053192'
1218
+ // }
1219
+ })()
1220
+ ````
1099
1221
 
1100
1222
  ## Gas estimation
1101
1223
  Every non-constant method has corresponding gas estimation method. Rule: ```obj.method -> obj.estimateGas.method```
@@ -529,32 +529,6 @@
529
529
  ],
530
530
  "gas": "2611832"
531
531
  },
532
- {
533
- "stateMutability": "nonpayable",
534
- "type": "function",
535
- "name": "add_liquidity",
536
- "inputs": [
537
- {
538
- "name": "_amounts",
539
- "type": "uint256[2]"
540
- },
541
- {
542
- "name": "_min_mint_amount",
543
- "type": "uint256"
544
- },
545
- {
546
- "name": "_receiver",
547
- "type": "address"
548
- }
549
- ],
550
- "outputs": [
551
- {
552
- "name": "",
553
- "type": "uint256"
554
- }
555
- ],
556
- "gas": "2611832"
557
- },
558
532
  {
559
533
  "stateMutability": "view",
560
534
  "type": "function",
@@ -637,70 +611,6 @@
637
611
  ],
638
612
  "gas": "1300799"
639
613
  },
640
- {
641
- "stateMutability": "nonpayable",
642
- "type": "function",
643
- "name": "exchange",
644
- "inputs": [
645
- {
646
- "name": "i",
647
- "type": "int128"
648
- },
649
- {
650
- "name": "j",
651
- "type": "int128"
652
- },
653
- {
654
- "name": "_dx",
655
- "type": "uint256"
656
- },
657
- {
658
- "name": "_min_dy",
659
- "type": "uint256"
660
- },
661
- {
662
- "name": "_receiver",
663
- "type": "address"
664
- }
665
- ],
666
- "outputs": [
667
- {
668
- "name": "",
669
- "type": "uint256"
670
- }
671
- ],
672
- "gas": "1300799"
673
- },
674
- {
675
- "stateMutability": "nonpayable",
676
- "type": "function",
677
- "name": "exchange_underlying",
678
- "inputs": [
679
- {
680
- "name": "i",
681
- "type": "int128"
682
- },
683
- {
684
- "name": "j",
685
- "type": "int128"
686
- },
687
- {
688
- "name": "_dx",
689
- "type": "uint256"
690
- },
691
- {
692
- "name": "_min_dy",
693
- "type": "uint256"
694
- }
695
- ],
696
- "outputs": [
697
- {
698
- "name": "",
699
- "type": "uint256"
700
- }
701
- ],
702
- "gas": "1323223"
703
- },
704
614
  {
705
615
  "stateMutability": "nonpayable",
706
616
  "type": "function",
@@ -721,10 +631,6 @@
721
631
  {
722
632
  "name": "_min_dy",
723
633
  "type": "uint256"
724
- },
725
- {
726
- "name": "_receiver",
727
- "type": "address"
728
634
  }
729
635
  ],
730
636
  "outputs": [
@@ -757,32 +663,6 @@
757
663
  ],
758
664
  "gas": "229848"
759
665
  },
760
- {
761
- "stateMutability": "nonpayable",
762
- "type": "function",
763
- "name": "remove_liquidity",
764
- "inputs": [
765
- {
766
- "name": "_burn_amount",
767
- "type": "uint256"
768
- },
769
- {
770
- "name": "_min_amounts",
771
- "type": "uint256[2]"
772
- },
773
- {
774
- "name": "_receiver",
775
- "type": "address"
776
- }
777
- ],
778
- "outputs": [
779
- {
780
- "name": "",
781
- "type": "uint256[2]"
782
- }
783
- ],
784
- "gas": "229848"
785
- },
786
666
  {
787
667
  "stateMutability": "nonpayable",
788
668
  "type": "function",
@@ -805,32 +685,6 @@
805
685
  ],
806
686
  "gas": "2612120"
807
687
  },
808
- {
809
- "stateMutability": "nonpayable",
810
- "type": "function",
811
- "name": "remove_liquidity_imbalance",
812
- "inputs": [
813
- {
814
- "name": "_amounts",
815
- "type": "uint256[2]"
816
- },
817
- {
818
- "name": "_max_burn_amount",
819
- "type": "uint256"
820
- },
821
- {
822
- "name": "_receiver",
823
- "type": "address"
824
- }
825
- ],
826
- "outputs": [
827
- {
828
- "name": "",
829
- "type": "uint256"
830
- }
831
- ],
832
- "gas": "2612120"
833
- },
834
688
  {
835
689
  "stateMutability": "view",
836
690
  "type": "function",
@@ -879,36 +733,6 @@
879
733
  ],
880
734
  "gas": "1688189"
881
735
  },
882
- {
883
- "stateMutability": "nonpayable",
884
- "type": "function",
885
- "name": "remove_liquidity_one_coin",
886
- "inputs": [
887
- {
888
- "name": "_burn_amount",
889
- "type": "uint256"
890
- },
891
- {
892
- "name": "i",
893
- "type": "int128"
894
- },
895
- {
896
- "name": "_min_received",
897
- "type": "uint256"
898
- },
899
- {
900
- "name": "_receiver",
901
- "type": "address"
902
- }
903
- ],
904
- "outputs": [
905
- {
906
- "name": "",
907
- "type": "uint256"
908
- }
909
- ],
910
- "gas": "1688189"
911
- },
912
736
  {
913
737
  "stateMutability": "nonpayable",
914
738
  "type": "function",
@@ -560,32 +560,6 @@
560
560
  ],
561
561
  "gas": "2636969"
562
562
  },
563
- {
564
- "stateMutability": "nonpayable",
565
- "type": "function",
566
- "name": "add_liquidity",
567
- "inputs": [
568
- {
569
- "name": "_amounts",
570
- "type": "uint256[2]"
571
- },
572
- {
573
- "name": "_min_mint_amount",
574
- "type": "uint256"
575
- },
576
- {
577
- "name": "_receiver",
578
- "type": "address"
579
- }
580
- ],
581
- "outputs": [
582
- {
583
- "name": "",
584
- "type": "uint256"
585
- }
586
- ],
587
- "gas": "2636969"
588
- },
589
563
  {
590
564
  "stateMutability": "view",
591
565
  "type": "function",
@@ -668,70 +642,6 @@
668
642
  ],
669
643
  "gas": "1283011"
670
644
  },
671
- {
672
- "stateMutability": "nonpayable",
673
- "type": "function",
674
- "name": "exchange",
675
- "inputs": [
676
- {
677
- "name": "i",
678
- "type": "int128"
679
- },
680
- {
681
- "name": "j",
682
- "type": "int128"
683
- },
684
- {
685
- "name": "_dx",
686
- "type": "uint256"
687
- },
688
- {
689
- "name": "_min_dy",
690
- "type": "uint256"
691
- },
692
- {
693
- "name": "_receiver",
694
- "type": "address"
695
- }
696
- ],
697
- "outputs": [
698
- {
699
- "name": "",
700
- "type": "uint256"
701
- }
702
- ],
703
- "gas": "1283011"
704
- },
705
- {
706
- "stateMutability": "nonpayable",
707
- "type": "function",
708
- "name": "exchange_underlying",
709
- "inputs": [
710
- {
711
- "name": "i",
712
- "type": "int128"
713
- },
714
- {
715
- "name": "j",
716
- "type": "int128"
717
- },
718
- {
719
- "name": "_dx",
720
- "type": "uint256"
721
- },
722
- {
723
- "name": "_min_dy",
724
- "type": "uint256"
725
- }
726
- ],
727
- "outputs": [
728
- {
729
- "name": "",
730
- "type": "uint256"
731
- }
732
- ],
733
- "gas": "1305450"
734
- },
735
645
  {
736
646
  "stateMutability": "nonpayable",
737
647
  "type": "function",
@@ -752,10 +662,6 @@
752
662
  {
753
663
  "name": "_min_dy",
754
664
  "type": "uint256"
755
- },
756
- {
757
- "name": "_receiver",
758
- "type": "address"
759
665
  }
760
666
  ],
761
667
  "outputs": [
@@ -788,32 +694,6 @@
788
694
  ],
789
695
  "gas": "169867"
790
696
  },
791
- {
792
- "stateMutability": "nonpayable",
793
- "type": "function",
794
- "name": "remove_liquidity",
795
- "inputs": [
796
- {
797
- "name": "_burn_amount",
798
- "type": "uint256"
799
- },
800
- {
801
- "name": "_min_amounts",
802
- "type": "uint256[2]"
803
- },
804
- {
805
- "name": "_receiver",
806
- "type": "address"
807
- }
808
- ],
809
- "outputs": [
810
- {
811
- "name": "",
812
- "type": "uint256[2]"
813
- }
814
- ],
815
- "gas": "169867"
816
- },
817
697
  {
818
698
  "stateMutability": "nonpayable",
819
699
  "type": "function",
@@ -836,32 +716,6 @@
836
716
  ],
837
717
  "gas": "2627335"
838
718
  },
839
- {
840
- "stateMutability": "nonpayable",
841
- "type": "function",
842
- "name": "remove_liquidity_imbalance",
843
- "inputs": [
844
- {
845
- "name": "_amounts",
846
- "type": "uint256[2]"
847
- },
848
- {
849
- "name": "_max_burn_amount",
850
- "type": "uint256"
851
- },
852
- {
853
- "name": "_receiver",
854
- "type": "address"
855
- }
856
- ],
857
- "outputs": [
858
- {
859
- "name": "",
860
- "type": "uint256"
861
- }
862
- ],
863
- "gas": "2627335"
864
- },
865
719
  {
866
720
  "stateMutability": "view",
867
721
  "type": "function",
@@ -910,36 +764,6 @@
910
764
  ],
911
765
  "gas": "1699060"
912
766
  },
913
- {
914
- "stateMutability": "nonpayable",
915
- "type": "function",
916
- "name": "remove_liquidity_one_coin",
917
- "inputs": [
918
- {
919
- "name": "_burn_amount",
920
- "type": "uint256"
921
- },
922
- {
923
- "name": "i",
924
- "type": "int128"
925
- },
926
- {
927
- "name": "_min_received",
928
- "type": "uint256"
929
- },
930
- {
931
- "name": "_receiver",
932
- "type": "address"
933
- }
934
- ],
935
- "outputs": [
936
- {
937
- "name": "",
938
- "type": "uint256"
939
- }
940
- ],
941
- "gas": "1699060"
942
- },
943
767
  {
944
768
  "stateMutability": "nonpayable",
945
769
  "type": "function",