@curvefi/api 2.49.5 → 2.49.7
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 +7 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/pools/PoolTemplate.d.ts +3 -3
- package/lib/pools/PoolTemplate.js +18 -16
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +14 -0
- package/package.json +1 -1
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
|
-
//
|
|
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,
|
|
@@ -40,8 +40,8 @@ export declare class PoolTemplate {
|
|
|
40
40
|
depositWrapped: (amounts: (number | string)[]) => Promise<number | number[]>;
|
|
41
41
|
stakeApprove: (lpTokenAmount: number | string) => Promise<number | number[]>;
|
|
42
42
|
stake: (lpTokenAmount: number | string) => Promise<number>;
|
|
43
|
-
unstake: (lpTokenAmount: number | string) => Promise<number>;
|
|
44
|
-
claimCrv: () => Promise<number>;
|
|
43
|
+
unstake: (lpTokenAmount: number | string) => Promise<number | number[]>;
|
|
44
|
+
claimCrv: () => Promise<number | number[]>;
|
|
45
45
|
claimRewards: () => Promise<number>;
|
|
46
46
|
depositAndStakeApprove: (amounts: (number | string)[]) => Promise<number | number[]>;
|
|
47
47
|
depositAndStake: (amounts: (number | string)[]) => Promise<number>;
|
|
@@ -137,7 +137,7 @@ export declare class PoolTemplate {
|
|
|
137
137
|
unstake(lpTokenAmount: number | string): Promise<string>;
|
|
138
138
|
crvProfit: (address?: string) => Promise<IProfit>;
|
|
139
139
|
claimableCrv(address?: string): Promise<string>;
|
|
140
|
-
claimCrvEstimateGas(): Promise<number>;
|
|
140
|
+
claimCrvEstimateGas(): Promise<number | number[]>;
|
|
141
141
|
claimCrv(): Promise<string>;
|
|
142
142
|
boost: (address?: string) => Promise<string>;
|
|
143
143
|
userCrvApy: (address?: string) => Promise<number>;
|
|
@@ -56,7 +56,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
56
56
|
};
|
|
57
57
|
import memoize from "memoizee";
|
|
58
58
|
import { _getPoolsFromApi, _getSubgraphData, _getFactoryAPYsAndVolumes, _getLegacyAPYsAndVolumes } from '../external-api.js';
|
|
59
|
-
import { _getCoinAddresses, _getBalances, _prepareAddresses, _ensureAllowance, _getUsdRate, hasAllowance, ensureAllowance, ensureAllowanceEstimateGas, BN, toBN, toStringFromBN, parseUnits, getEthIndex, fromBN, _cutZeros, _setContracts, _get_small_x, _get_price_impact, checkNumber, _getCrvApyFromApi, _getRewardsFromApi, mulBy1_3, smartNumber, } from '../utils.js';
|
|
59
|
+
import { _getCoinAddresses, _getBalances, _prepareAddresses, _ensureAllowance, _getUsdRate, hasAllowance, ensureAllowance, ensureAllowanceEstimateGas, BN, toBN, toStringFromBN, parseUnits, getEthIndex, fromBN, _cutZeros, _setContracts, _get_small_x, _get_price_impact, checkNumber, _getCrvApyFromApi, _getRewardsFromApi, mulBy1_3, smartNumber, DIGas, } from '../utils.js';
|
|
60
60
|
import { curve as _curve, curve } from "../curve.js";
|
|
61
61
|
import ERC20Abi from '../constants/abis/ERC20.json' assert { type: 'json' };
|
|
62
62
|
var DAY = 86400;
|
|
@@ -1689,7 +1689,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1689
1689
|
throw Error("unstakeEstimateGas method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
1690
1690
|
}
|
|
1691
1691
|
_lpTokenAmount = parseUnits(lpTokenAmount);
|
|
1692
|
-
_c =
|
|
1692
|
+
_c = smartNumber;
|
|
1693
1693
|
return [4 /*yield*/, curve.contracts[this.gauge].contract.withdraw.estimateGas(_lpTokenAmount, curve.constantOptions)];
|
|
1694
1694
|
case 1: return [2 /*return*/, _c.apply(void 0, [_d.sent()])];
|
|
1695
1695
|
}
|
|
@@ -1698,9 +1698,9 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1698
1698
|
};
|
|
1699
1699
|
PoolTemplate.prototype.unstake = function (lpTokenAmount) {
|
|
1700
1700
|
return __awaiter(this, void 0, void 0, function () {
|
|
1701
|
-
var _lpTokenAmount, gasLimit;
|
|
1702
|
-
return __generator(this, function (
|
|
1703
|
-
switch (
|
|
1701
|
+
var _lpTokenAmount, gasLimit, _c;
|
|
1702
|
+
return __generator(this, function (_d) {
|
|
1703
|
+
switch (_d.label) {
|
|
1704
1704
|
case 0:
|
|
1705
1705
|
if (this.gauge === curve.constants.ZERO_ADDRESS) {
|
|
1706
1706
|
throw Error("unstake method doesn't exist for pool ".concat(this.name, " (id: ").concat(this.name, "). There is no gauge"));
|
|
@@ -1708,12 +1708,13 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1708
1708
|
_lpTokenAmount = parseUnits(lpTokenAmount);
|
|
1709
1709
|
return [4 /*yield*/, curve.updateFeeData()];
|
|
1710
1710
|
case 1:
|
|
1711
|
-
|
|
1711
|
+
_d.sent();
|
|
1712
|
+
_c = DIGas;
|
|
1712
1713
|
return [4 /*yield*/, curve.contracts[this.gauge].contract.withdraw.estimateGas(_lpTokenAmount, curve.constantOptions)];
|
|
1713
1714
|
case 2:
|
|
1714
|
-
gasLimit =
|
|
1715
|
+
gasLimit = _c.apply(void 0, [(_d.sent())]) * curve.parseUnits("200", 0) / curve.parseUnits("100", 0);
|
|
1715
1716
|
return [4 /*yield*/, curve.contracts[this.gauge].contract.withdraw(_lpTokenAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
1716
|
-
case 3: return [2 /*return*/, (
|
|
1717
|
+
case 3: return [2 /*return*/, (_d.sent()).hash];
|
|
1717
1718
|
}
|
|
1718
1719
|
});
|
|
1719
1720
|
});
|
|
@@ -1750,7 +1751,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1750
1751
|
return [4 /*yield*/, curve.contracts[curve.constants.ALIASES.minter].contract.mint.estimateGas(this.gauge, curve.constantOptions)];
|
|
1751
1752
|
case 1: return [2 /*return*/, _c.apply(void 0, [_e.sent()])];
|
|
1752
1753
|
case 2:
|
|
1753
|
-
_d =
|
|
1754
|
+
_d = smartNumber;
|
|
1754
1755
|
return [4 /*yield*/, curve.contracts[curve.constants.ALIASES.gauge_factory].contract.mint.estimateGas(this.gauge, curve.constantOptions)];
|
|
1755
1756
|
case 3: return [2 /*return*/, _d.apply(void 0, [_e.sent()])];
|
|
1756
1757
|
}
|
|
@@ -1759,19 +1760,20 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1759
1760
|
};
|
|
1760
1761
|
PoolTemplate.prototype.claimCrv = function () {
|
|
1761
1762
|
return __awaiter(this, void 0, void 0, function () {
|
|
1762
|
-
var contract, gasLimit, _c;
|
|
1763
|
-
return __generator(this, function (
|
|
1764
|
-
switch (
|
|
1763
|
+
var contract, gasLimit, _c, _d;
|
|
1764
|
+
return __generator(this, function (_e) {
|
|
1765
|
+
switch (_e.label) {
|
|
1765
1766
|
case 0:
|
|
1766
1767
|
if (this.rewardsOnly())
|
|
1767
1768
|
throw Error("".concat(this.name, " has Rewards-Only Gauge. Use claimRewards instead"));
|
|
1768
1769
|
contract = curve.chainId === 1 ? curve.contracts[curve.constants.ALIASES.minter].contract : curve.contracts[curve.constants.ALIASES.gauge_factory].contract;
|
|
1769
1770
|
_c = mulBy1_3;
|
|
1771
|
+
_d = DIGas;
|
|
1770
1772
|
return [4 /*yield*/, contract.mint.estimateGas(this.gauge, curve.constantOptions)];
|
|
1771
1773
|
case 1:
|
|
1772
|
-
gasLimit = _c.apply(void 0, [_d.sent()]);
|
|
1774
|
+
gasLimit = _c.apply(void 0, [_d.apply(void 0, [_e.sent()])]);
|
|
1773
1775
|
return [4 /*yield*/, contract.mint(this.gauge, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
1774
|
-
case 2: return [2 /*return*/, (
|
|
1776
|
+
case 2: return [2 /*return*/, (_e.sent()).hash];
|
|
1775
1777
|
}
|
|
1776
1778
|
});
|
|
1777
1779
|
});
|
|
@@ -2268,11 +2270,11 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2268
2270
|
case 17:
|
|
2269
2271
|
_gas = (_q.sent());
|
|
2270
2272
|
if (estimateGas)
|
|
2271
|
-
return [2 /*return*/,
|
|
2273
|
+
return [2 /*return*/, smartNumber(_gas)];
|
|
2272
2274
|
return [4 /*yield*/, curve.updateFeeData()];
|
|
2273
2275
|
case 18:
|
|
2274
2276
|
_q.sent();
|
|
2275
|
-
gasLimit = _gas * curve.parseUnits("200", 0) / curve.parseUnits("100", 0);
|
|
2277
|
+
gasLimit = DIGas(_gas) * curve.parseUnits("200", 0) / curve.parseUnits("100", 0);
|
|
2276
2278
|
return [4 /*yield*/, contract.deposit_and_stake(depositAddress, this.lpToken, this.gauge, coins.length, coinAddresses, _amounts, _minMintAmount, useUnderlying, this.isMetaFactory && isUnderlying ? this.address : curve.constants.ZERO_ADDRESS, __assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value }))];
|
|
2277
2279
|
case 19: return [2 /*return*/, (_q.sent()).hash];
|
|
2278
2280
|
}
|
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)) {
|