@curvefi/api 2.49.5 → 2.49.6

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
@@ -1483,12 +1483,18 @@ Gas Price in L1 is required to calculate the fee.
1483
1483
  You can use `getGasPriceFromL1` for get Gas Price in L1.
1484
1484
  ````ts
1485
1485
  const L1GasPrice = await curve.getGasPriceFromL1()
1486
- // 13161051
1486
+ // 23348207475
1487
1487
  ````
1488
1488
 
1489
1489
  **Calculate fee**
1490
1490
  `fee = L2GasUsed*L2GasPrice + L1GasUsed*L1GasPrice`
1491
1491
 
1492
+ For OP and Base networks you can get `L2GasPrice` from `curve.getGasPriceFromL2`
1493
+ ````ts
1494
+ const L2GasPrice = await curve.getGasPriceFromL2()
1495
+ // 13161051
1496
+ ````
1497
+
1492
1498
 
1493
1499
  ## Factory
1494
1500
 
package/lib/index.d.ts CHANGED
@@ -41,6 +41,7 @@ declare const curve: {
41
41
  getPool: (poolId: string) => PoolTemplate;
42
42
  getUsdRate: (coin: string) => Promise<number>;
43
43
  getGasPriceFromL1: () => Promise<number>;
44
+ getGasPriceFromL2: () => Promise<number>;
44
45
  getTVL: (network?: import("./interfaces.js").INetworkName | import("./interfaces.js").IChainId) => Promise<number>;
45
46
  getBalances: (coins: string[], ...addresses: string[] | string[][]) => Promise<string[] | import("./interfaces.js").IDict<string[]>>;
46
47
  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, getTVL, getCoinsData, getVolume, hasDepositAndStake, hasRouter, } from "./utils.js";
42
+ import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, getUsdRate, getGasPriceFromL1, getGasPriceFromL2, getTVL, getCoinsData, getVolume, hasDepositAndStake, hasRouter, } 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, } from './factory/deploy.js';
44
44
  function init(providerType, providerSettings, options) {
45
45
  if (options === void 0) { options = {}; }
@@ -77,6 +77,7 @@ var curve = {
77
77
  getPool: getPool,
78
78
  getUsdRate: getUsdRate,
79
79
  getGasPriceFromL1: getGasPriceFromL1,
80
+ getGasPriceFromL2: getGasPriceFromL2,
80
81
  getTVL: getTVL,
81
82
  getBalances: getBalances,
82
83
  getAllowance: getAllowance,
package/lib/utils.d.ts CHANGED
@@ -36,6 +36,7 @@ export declare const _getRewardsFromApi: () => Promise<IDict<IRewardFromApi[]>>;
36
36
  export declare const _getUsdRate: (assetId: string) => Promise<number>;
37
37
  export declare const getUsdRate: (coin: string) => Promise<number>;
38
38
  export declare const getGasPriceFromL1: () => Promise<number>;
39
+ export declare const getGasPriceFromL2: () => Promise<number>;
39
40
  export declare const getTxCostsUsd: (ethUsdRate: number, gasPrice: number, gas: number | number[], gasPriceL1?: number) => number;
40
41
  export declare const getTVL: (network?: INetworkName | IChainId) => Promise<number>;
41
42
  export declare const getVolume: (network?: INetworkName | IChainId) => Promise<{
package/lib/utils.js CHANGED
@@ -696,6 +696,20 @@ export var getGasPriceFromL1 = function () { return __awaiter(void 0, void 0, vo
696
696
  }
697
697
  });
698
698
  }); };
699
+ export var getGasPriceFromL2 = function () { return __awaiter(void 0, void 0, void 0, function () {
700
+ var gasPrice;
701
+ return __generator(this, function (_a) {
702
+ switch (_a.label) {
703
+ case 0:
704
+ if (!L2Networks.includes(curve.chainId)) return [3 /*break*/, 2];
705
+ return [4 /*yield*/, curve.contracts[curve.constants.ALIASES.gas_oracle].contract.gasPrice()];
706
+ case 1:
707
+ gasPrice = _a.sent();
708
+ return [2 /*return*/, Number(gasPrice)];
709
+ case 2: throw Error("This method exists only for L2 networks");
710
+ }
711
+ });
712
+ }); };
699
713
  export var getTxCostsUsd = function (ethUsdRate, gasPrice, gas, gasPriceL1) {
700
714
  if (gasPriceL1 === void 0) { gasPriceL1 = 0; }
701
715
  if (Array.isArray(gas)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.49.5",
3
+ "version": "2.49.6",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",