@curvefi/api 2.58.8 → 2.58.10

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/lib/curve.js CHANGED
@@ -112,7 +112,7 @@ import { lowerCasePoolDataAddresses, extractDecimals, extractGauges } from "./co
112
112
  import { _getAllGauges, _getHiddenPools } from "./external-api.js";
113
113
  import { L2Networks } from "./constants/L2Networks.js";
114
114
  import { getTwocryptoFactoryPoolData } from "./factory/factory-twocrypto.js";
115
- import { getGasInfoForL2, memoizedContract, memoizedMulticallContract } from "./utils.js";
115
+ import { memoizedContract, memoizedMulticallContract } from "./utils.js";
116
116
  var _killGauges = function (poolsData) { return __awaiter(void 0, void 0, void 0, function () {
117
117
  var gaugeData, isKilled, gaugeStatuses, poolId;
118
118
  return __generator(this, function (_a) {
@@ -903,9 +903,9 @@ var Curve = /** @class */ (function () {
903
903
  var _a;
904
904
  if (options === void 0) { options = {}; }
905
905
  return __awaiter(this, void 0, void 0, function () {
906
- var jsonRpcApiProviderOptions, _b, e_1, _c, network, poolId, _d, cTokens, yTokens, ycTokens, aTokens, customAbiTokens, _e, err_1, _f, _i, _g, pool, _h, _j, coinAddr, _k, _l, coinAddr, _m, _o, coinAddr, _gaugeFactoryABI, factoryContract, _p, curveInstance_1, originalEstimate_1, oldEstimate, newEstimate;
907
- return __generator(this, function (_q) {
908
- switch (_q.label) {
906
+ var jsonRpcApiProviderOptions, _b, e_1, _c, network, poolId, _d, cTokens, yTokens, ycTokens, aTokens, customAbiTokens, _e, err_1, _i, _f, pool, _g, _h, coinAddr, _j, _k, coinAddr, _l, _m, coinAddr, _gaugeFactoryABI, factoryContract, _o, curveInstance_1, originalEstimate_1, oldEstimate, newEstimate;
907
+ return __generator(this, function (_p) {
908
+ switch (_p.label) {
909
909
  case 0:
910
910
  // @ts-ignore
911
911
  this.provider = null;
@@ -960,16 +960,16 @@ var Curve = /** @class */ (function () {
960
960
  return [3 /*break*/, 5];
961
961
  case 1:
962
962
  if (!!((_a = providerSettings.url) === null || _a === void 0 ? void 0 : _a.startsWith("https://rpc.gnosischain.com"))) return [3 /*break*/, 5];
963
- _q.label = 2;
963
+ _p.label = 2;
964
964
  case 2:
965
- _q.trys.push([2, 4, , 5]);
965
+ _p.trys.push([2, 4, , 5]);
966
966
  _b = this;
967
967
  return [4 /*yield*/, this.provider.getSigner()];
968
968
  case 3:
969
- _b.signer = _q.sent();
969
+ _b.signer = _p.sent();
970
970
  return [3 /*break*/, 5];
971
971
  case 4:
972
- e_1 = _q.sent();
972
+ e_1 = _p.sent();
973
973
  this.signer = null;
974
974
  return [3 /*break*/, 5];
975
975
  case 5: return [3 /*break*/, 9];
@@ -980,7 +980,7 @@ var Curve = /** @class */ (function () {
980
980
  _c = this;
981
981
  return [4 /*yield*/, this.provider.getSigner()];
982
982
  case 7:
983
- _c.signer = _q.sent();
983
+ _c.signer = _p.sent();
984
984
  return [3 /*break*/, 9];
985
985
  case 8:
986
986
  if (providerType.toLowerCase() === 'Infura'.toLowerCase()) {
@@ -997,10 +997,10 @@ var Curve = /** @class */ (function () {
997
997
  else {
998
998
  throw Error('Wrong providerType');
999
999
  }
1000
- _q.label = 9;
1000
+ _p.label = 9;
1001
1001
  case 9: return [4 /*yield*/, this.provider.getNetwork()];
1002
1002
  case 10:
1003
- network = _q.sent();
1003
+ network = _p.sent();
1004
1004
  console.log("CURVE-JS IS CONNECTED TO NETWORK:", { name: network.name.toUpperCase(), chainId: Number(network.chainId) });
1005
1005
  this.chainId = Number(network.chainId) === 133 || Number(network.chainId) === 31337 ? 1 : Number(network.chainId);
1006
1006
  this.constants.NATIVE_TOKEN = NATIVE_TOKENS[this.chainId];
@@ -1027,35 +1027,29 @@ var Curve = /** @class */ (function () {
1027
1027
  customAbiTokens = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], cTokens, true), yTokens, true), ycTokens, true), aTokens, true);
1028
1028
  this.multicallProvider = new MulticallProvider(this.chainId, this.provider);
1029
1029
  if (!this.signer) return [3 /*break*/, 15];
1030
- _q.label = 11;
1030
+ _p.label = 11;
1031
1031
  case 11:
1032
- _q.trys.push([11, 13, , 14]);
1032
+ _p.trys.push([11, 13, , 14]);
1033
1033
  _e = this;
1034
1034
  return [4 /*yield*/, this.signer.getAddress()];
1035
1035
  case 12:
1036
- _e.signerAddress = _q.sent();
1036
+ _e.signerAddress = _p.sent();
1037
1037
  return [3 /*break*/, 14];
1038
1038
  case 13:
1039
- err_1 = _q.sent();
1039
+ err_1 = _p.sent();
1040
1040
  this.signer = null;
1041
1041
  return [3 /*break*/, 14];
1042
1042
  case 14: return [3 /*break*/, 16];
1043
1043
  case 15:
1044
1044
  this.signerAddress = '';
1045
- _q.label = 16;
1045
+ _p.label = 16;
1046
1046
  case 16:
1047
1047
  this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
1048
- if (!(this.chainId === 196)) return [3 /*break*/, 18];
1049
- _f = this.setCustomFeeData;
1050
- return [4 /*yield*/, getGasInfoForL2()];
1048
+ return [4 /*yield*/, this.updateFeeData()];
1051
1049
  case 17:
1052
- _f.apply(this, [_q.sent()]);
1053
- _q.label = 18;
1054
- case 18: return [4 /*yield*/, this.updateFeeData()];
1055
- case 19:
1056
- _q.sent();
1057
- for (_i = 0, _g = Object.values(__assign(__assign({}, this.constants.POOLS_DATA), this.constants.LLAMMAS_DATA)); _i < _g.length; _i++) {
1058
- pool = _g[_i];
1050
+ _p.sent();
1051
+ for (_i = 0, _f = Object.values(__assign(__assign({}, this.constants.POOLS_DATA), this.constants.LLAMMAS_DATA)); _i < _f.length; _i++) {
1052
+ pool = _f[_i];
1059
1053
  this.setContract(pool.swap_address, pool.swap_abi);
1060
1054
  if (pool.token_address !== pool.swap_address) {
1061
1055
  this.setContract(pool.token_address, ERC20Abi);
@@ -1066,12 +1060,12 @@ var Curve = /** @class */ (function () {
1066
1060
  if (pool.deposit_address && !this.contracts[pool.deposit_address]) {
1067
1061
  this.setContract(pool.deposit_address, pool.deposit_abi);
1068
1062
  }
1069
- for (_h = 0, _j = pool.underlying_coin_addresses; _h < _j.length; _h++) {
1070
- coinAddr = _j[_h];
1063
+ for (_g = 0, _h = pool.underlying_coin_addresses; _g < _h.length; _g++) {
1064
+ coinAddr = _h[_g];
1071
1065
  this.setContract(coinAddr, ERC20Abi);
1072
1066
  }
1073
- for (_k = 0, _l = pool.wrapped_coin_addresses; _k < _l.length; _k++) {
1074
- coinAddr = _l[_k];
1067
+ for (_j = 0, _k = pool.wrapped_coin_addresses; _j < _k.length; _j++) {
1068
+ coinAddr = _k[_j];
1075
1069
  if (customAbiTokens.includes(coinAddr))
1076
1070
  continue;
1077
1071
  if (coinAddr in this.contracts)
@@ -1079,8 +1073,8 @@ var Curve = /** @class */ (function () {
1079
1073
  this.setContract(coinAddr, ERC20Abi);
1080
1074
  }
1081
1075
  // TODO add all coins
1082
- for (_m = 0, _o = pool.wrapped_coin_addresses; _m < _o.length; _m++) {
1083
- coinAddr = _o[_m];
1076
+ for (_l = 0, _m = pool.wrapped_coin_addresses; _l < _m.length; _l++) {
1077
+ coinAddr = _m[_l];
1084
1078
  if (cTokens.includes(coinAddr)) {
1085
1079
  this.setContract(coinAddr, cERC20Abi);
1086
1080
  }
@@ -1120,15 +1114,15 @@ var Curve = /** @class */ (function () {
1120
1114
  this.setContract(this.constants.ALIASES.crypto_calc, cryptoCalcZapABI);
1121
1115
  this.setContract(this.constants.ALIASES.stable_calc, StableCalcZapABI);
1122
1116
  this.setContract(this.constants.ALIASES.factory, factoryABI);
1123
- if (!(this.chainId !== 1313161554 && this.chainId !== 252 && this.chainId !== 196)) return [3 /*break*/, 21];
1117
+ if (!(this.chainId !== 1313161554 && this.chainId !== 252 && this.chainId !== 196)) return [3 /*break*/, 19];
1124
1118
  factoryContract = this.contracts[this.constants.ALIASES.factory].contract;
1125
- _p = this.constants.ALIASES;
1119
+ _o = this.constants.ALIASES;
1126
1120
  return [4 /*yield*/, factoryContract.admin(this.constantOptions)];
1127
- case 20:
1128
- _p.factory_admin = (_q.sent()).toLowerCase();
1121
+ case 18:
1122
+ _o.factory_admin = (_p.sent()).toLowerCase();
1129
1123
  this.setContract(this.constants.ALIASES.factory_admin, factoryAdminABI);
1130
- _q.label = 21;
1131
- case 21:
1124
+ _p.label = 19;
1125
+ case 19:
1132
1126
  this.setContract(this.constants.ALIASES.crvusd_factory, factoryABI);
1133
1127
  this.setContract(this.constants.ALIASES.eywa_factory, factoryEywaABI);
1134
1128
  this.setContract(this.constants.ALIASES.crypto_factory, cryptoFactoryABI);
package/lib/index.d.ts CHANGED
@@ -44,7 +44,7 @@ declare const curve: {
44
44
  getGasPriceFromL1: () => Promise<number>;
45
45
  getGasPriceFromL2: () => Promise<number>;
46
46
  getGasInfoForL2: () => Promise<Record<string, number | null>>;
47
- getGasPriceByLastTransactions: () => Promise<number>;
47
+ getGasPrice: () => Promise<number>;
48
48
  getTVL: (network?: import("./interfaces.js").INetworkName | import("./interfaces.js").IChainId) => Promise<number>;
49
49
  getBalances: (coins: string[], ...addresses: string[] | string[][]) => Promise<string[] | import("./interfaces.js").IDict<string[]>>;
50
50
  getAllowance: (coins: string[], address: string, spender: string) => Promise<string[]>;
package/lib/index.js CHANGED
@@ -39,7 +39,7 @@ import { getUserPoolListByLiquidity, getUserPoolListByClaimable, getUserPoolList
39
39
  import { getBestRouteAndOutput, getArgs, swapExpected, swapRequired, swapPriceImpact, swapIsApproved, swapApproveEstimateGas, swapApprove, swapEstimateGas, swap, getSwappedAmount, } from "./router.js";
40
40
  import { curve as _curve } from "./curve.js";
41
41
  import { getCrv, getLockedAmountAndUnlockTime, getVeCrv, getVeCrvPct, calcUnlockTime, createLockEstimateGas, createLock, isApproved, approveEstimateGas, approve, increaseAmountEstimateGas, increaseAmount, increaseUnlockTimeEstimateGas, increaseUnlockTime, withdrawLockedCrvEstimateGas, withdrawLockedCrv, claimableFees, claimFeesEstimateGas, claimFees, lastEthBlock, getAnycallBalance, topUpAnycall, topUpAnycallEstimateGas, lastBlockSent, blockToSend, sendBlockhash, sendBlockhashEstimateGas, submitProof, submitProofEstimateGas, } from "./boosting.js";
42
- import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, getUsdRate, getGasPriceFromL1, getGasPriceFromL2, getGasInfoForL2, getTVL, getCoinsData, getVolume, hasDepositAndStake, hasRouter, getBasePools, getGasPriceByLastTransactions, } from "./utils.js";
42
+ import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, getUsdRate, getGasPriceFromL1, getGasPriceFromL2, getGasInfoForL2, getTVL, getCoinsData, getVolume, hasDepositAndStake, hasRouter, getBasePools, getGasPrice, } from "./utils.js";
43
43
  import { deployStablePlainPool, deployStablePlainPoolEstimateGas, getDeployedStablePlainPoolAddress, setOracle, setOracleEstimateGas, deployStableMetaPool, deployStableMetaPoolEstimateGas, getDeployedStableMetaPoolAddress, deployCryptoPool, deployCryptoPoolEstimateGas, getDeployedCryptoPoolAddress, deployTricryptoPool, deployTricryptoPoolEstimateGas, getDeployedTricryptoPoolAddress, deployGauge, deployGaugeEstimateGas, getDeployedGaugeAddress, deployGaugeSidechain, deployGaugeSidechainEstimateGas, deployGaugeMirror, deployGaugeMirrorEstimateGas, getDeployedGaugeMirrorAddress, getDeployedGaugeMirrorAddressByTx, deployStableNgPlainPool, deployStableNgPlainPoolEstimateGas, deployStableNgMetaPool, deployStableNgMetaPoolEstimateGas, deployTwocryptoPool, deployTwocryptoPoolEstimateGas, getDeployedTwocryptoPoolAddress, } from './factory/deploy.js';
44
44
  import { crvSupplyStats, userCrv, userVeCrv, crvLockIsApproved, crvLockApproveEstimateGas, crvLockApprove, calcCrvUnlockTime, createCrvLockEstimateGas, createCrvLock, increaseCrvLockedAmountEstimateGas, increaseCrvLockedAmount, increaseCrvUnlockTimeEstimateGas, increaseCrvUnlockTime, withdrawLockedCrvEstimateGas as daoWithdrawLockedCrvEstimateGas, withdrawLockedCrv as daoWithdrawLockedCrv, claimableFees as daoClaimableFees, claimFeesEstimateGas as daoClaimFeesEstimateGas, claimFees as daoClaimFees, getVotingGaugeList, userGaugeVotes, voteForGaugeNextTime, voteForGaugeEstimateGas, voteForGauge, getProposalList, getProposal, userProposalVotes, voteForProposalEstimateGas, voteForProposal, } from "./dao.js";
45
45
  function init(providerType, providerSettings, options) {
@@ -81,7 +81,7 @@ var curve = {
81
81
  getGasPriceFromL1: getGasPriceFromL1,
82
82
  getGasPriceFromL2: getGasPriceFromL2,
83
83
  getGasInfoForL2: getGasInfoForL2,
84
- getGasPriceByLastTransactions: getGasPriceByLastTransactions,
84
+ getGasPrice: getGasPrice,
85
85
  getTVL: getTVL,
86
86
  getBalances: getBalances,
87
87
  getAllowance: getAllowance,
package/lib/utils.d.ts CHANGED
@@ -39,7 +39,7 @@ export declare const _getRewardsFromApi: () => Promise<IDict<IRewardFromApi[]>>;
39
39
  export declare const _getUsdRate: (assetId: string) => Promise<number>;
40
40
  export declare const getUsdRate: (coin: string) => Promise<number>;
41
41
  export declare const getBaseFeeByLastBlock: () => Promise<number>;
42
- export declare const getGasPriceByLastTransactions: () => Promise<number>;
42
+ export declare const getGasPrice: () => Promise<number>;
43
43
  export declare const getGasPriceFromL1: () => Promise<number>;
44
44
  export declare const getGasPriceFromL2: () => Promise<number>;
45
45
  export declare const getGasInfoForL2: () => Promise<Record<string, number | null>>;
package/lib/utils.js CHANGED
@@ -729,49 +729,16 @@ export var getBaseFeeByLastBlock = function () { return __awaiter(void 0, void 0
729
729
  }
730
730
  });
731
731
  }); };
732
- export var getGasPriceByLastTransactions = function () { return __awaiter(void 0, void 0, void 0, function () {
733
- var provider, latestBlockNumber, totalGasPrice, transactionsCount, txAmount, i, block, _i, _a, txHash, tx;
734
- return __generator(this, function (_b) {
735
- switch (_b.label) {
732
+ export var getGasPrice = function () { return __awaiter(void 0, void 0, void 0, function () {
733
+ var provider, _a, _b;
734
+ return __generator(this, function (_c) {
735
+ switch (_c.label) {
736
736
  case 0:
737
737
  provider = curve.provider;
738
- return [4 /*yield*/, provider.getBlockNumber()];
739
- case 1:
740
- latestBlockNumber = _b.sent();
741
- totalGasPrice = 0;
742
- transactionsCount = 0;
743
- txAmount = 15;
744
- i = latestBlockNumber;
745
- _b.label = 2;
746
- case 2:
747
- if (!(i > latestBlockNumber - txAmount && i >= 0)) return [3 /*break*/, 8];
748
- return [4 /*yield*/, provider.getBlock(i)];
749
- case 3:
750
- block = _b.sent();
751
- if (!block)
752
- return [3 /*break*/, 7];
753
- _i = 0, _a = block.transactions;
754
- _b.label = 4;
755
- case 4:
756
- if (!(_i < _a.length)) return [3 /*break*/, 7];
757
- txHash = _a[_i];
758
- return [4 /*yield*/, provider.getTransaction(txHash)];
759
- case 5:
760
- tx = _b.sent();
761
- if (!tx)
762
- return [3 /*break*/, 6];
763
- totalGasPrice = totalGasPrice + Number(tx.gasPrice);
764
- transactionsCount++;
765
- if (transactionsCount >= txAmount)
766
- return [3 /*break*/, 7]; // Limit to txAmount transactions
767
- _b.label = 6;
768
- case 6:
769
- _i++;
770
- return [3 /*break*/, 4];
771
- case 7:
772
- i--;
773
- return [3 /*break*/, 2];
774
- case 8: return [2 /*return*/, Number((totalGasPrice / transactionsCount / 1e9).toFixed(2))];
738
+ _a = Number;
739
+ _b = Number;
740
+ return [4 /*yield*/, provider.getFeeData()];
741
+ case 1: return [2 /*return*/, _a.apply(void 0, [(_b.apply(void 0, [(_c.sent()).gasPrice]) / 1e9).toFixed(2)])];
775
742
  }
776
743
  });
777
744
  }); };
@@ -796,7 +763,7 @@ export var getGasPriceFromL2 = function () { return __awaiter(void 0, void 0, vo
796
763
  case 1: return [2 /*return*/, _a.sent()];
797
764
  case 2:
798
765
  if (!(curve.chainId === 196)) return [3 /*break*/, 4];
799
- return [4 /*yield*/, getGasPriceByLastTransactions()]; // gwei
766
+ return [4 /*yield*/, getGasPrice()]; // gwei
800
767
  case 3: return [2 /*return*/, _a.sent()]; // gwei
801
768
  case 4:
802
769
  if (!L2Networks.includes(curve.chainId)) return [3 /*break*/, 6];
@@ -823,7 +790,7 @@ export var getGasInfoForL2 = function () { return __awaiter(void 0, void 0, void
823
790
  }];
824
791
  case 2:
825
792
  if (!(curve.chainId === 196)) return [3 /*break*/, 4];
826
- return [4 /*yield*/, getGasPriceByLastTransactions()];
793
+ return [4 /*yield*/, getGasPrice()];
827
794
  case 3:
828
795
  gasPrice = _a.sent();
829
796
  return [2 /*return*/, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.58.8",
3
+ "version": "2.58.10",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",