@curvefi/api 2.56.12 → 2.56.14
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/constants/aliases.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/utils.d.ts +2 -0
- package/lib/utils.js +46 -5
- package/package.json +1 -1
package/lib/constants/aliases.js
CHANGED
|
@@ -40,7 +40,7 @@ export var ALIASES_POLYGON = lowerCaseValues({
|
|
|
40
40
|
"eywa_factory": '0x37F22A0B028f2152e6CAcef210e0C4d3b875f367',
|
|
41
41
|
"crypto_factory": "0xE5De15A9C9bBedb4F5EC13B131E61245f2983A69",
|
|
42
42
|
"twocrypto_factory": '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F',
|
|
43
|
-
"tricrypto_factory": '
|
|
43
|
+
"tricrypto_factory": '0xC1b393EfEF38140662b91441C6710Aa704973228',
|
|
44
44
|
"stable_ng_factory": '0x1764ee18e8B3ccA4787249Ceb249356192594585',
|
|
45
45
|
"factory_admin": "",
|
|
46
46
|
});
|
package/lib/index.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ declare const curve: {
|
|
|
43
43
|
getUsdRate: (coin: string) => Promise<number>;
|
|
44
44
|
getGasPriceFromL1: () => Promise<number>;
|
|
45
45
|
getGasPriceFromL2: () => Promise<number>;
|
|
46
|
+
getGasInfoForL2: () => Promise<Record<string, number>>;
|
|
46
47
|
getTVL: (network?: import("./interfaces.js").INetworkName | import("./interfaces.js").IChainId) => Promise<number>;
|
|
47
48
|
getBalances: (coins: string[], ...addresses: string[] | string[][]) => Promise<string[] | import("./interfaces.js").IDict<string[]>>;
|
|
48
49
|
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, getTVL, getCoinsData, getVolume, hasDepositAndStake, hasRouter, getBasePools, } from "./utils.js";
|
|
42
|
+
import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, getUsdRate, getGasPriceFromL1, getGasPriceFromL2, getGasInfoForL2, getTVL, getCoinsData, getVolume, hasDepositAndStake, hasRouter, getBasePools, } 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) {
|
|
@@ -80,6 +80,7 @@ var curve = {
|
|
|
80
80
|
getUsdRate: getUsdRate,
|
|
81
81
|
getGasPriceFromL1: getGasPriceFromL1,
|
|
82
82
|
getGasPriceFromL2: getGasPriceFromL2,
|
|
83
|
+
getGasInfoForL2: getGasInfoForL2,
|
|
83
84
|
getTVL: getTVL,
|
|
84
85
|
getBalances: getBalances,
|
|
85
86
|
getAllowance: getAllowance,
|
package/lib/utils.d.ts
CHANGED
|
@@ -37,8 +37,10 @@ export declare const _getCrvApyFromApi: () => Promise<IDict<[number, number]>>;
|
|
|
37
37
|
export declare const _getRewardsFromApi: () => Promise<IDict<IRewardFromApi[]>>;
|
|
38
38
|
export declare const _getUsdRate: (assetId: string) => Promise<number>;
|
|
39
39
|
export declare const getUsdRate: (coin: string) => Promise<number>;
|
|
40
|
+
export declare const getBaseFeeByLastBlock: () => Promise<number>;
|
|
40
41
|
export declare const getGasPriceFromL1: () => Promise<number>;
|
|
41
42
|
export declare const getGasPriceFromL2: () => Promise<number>;
|
|
43
|
+
export declare const getGasInfoForL2: () => Promise<Record<string, number>>;
|
|
42
44
|
export declare const getTxCostsUsd: (ethUsdRate: number, gasPrice: number, gas: number | number[], gasPriceL1?: number) => number;
|
|
43
45
|
export declare const getTVL: (network?: INetworkName | IChainId) => Promise<number>;
|
|
44
46
|
export declare const getVolumeApiController: (network: INetworkName) => Promise<IVolumeAndAPYs>;
|
package/lib/utils.js
CHANGED
|
@@ -704,6 +704,29 @@ export var getUsdRate = function (coin) { return __awaiter(void 0, void 0, void
|
|
|
704
704
|
}
|
|
705
705
|
});
|
|
706
706
|
}); };
|
|
707
|
+
export var getBaseFeeByLastBlock = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
708
|
+
var provider, block, error_1;
|
|
709
|
+
return __generator(this, function (_a) {
|
|
710
|
+
switch (_a.label) {
|
|
711
|
+
case 0:
|
|
712
|
+
provider = curve.provider;
|
|
713
|
+
_a.label = 1;
|
|
714
|
+
case 1:
|
|
715
|
+
_a.trys.push([1, 3, , 4]);
|
|
716
|
+
return [4 /*yield*/, provider.getBlock('latest')];
|
|
717
|
+
case 2:
|
|
718
|
+
block = _a.sent();
|
|
719
|
+
if (!block) {
|
|
720
|
+
return [2 /*return*/, 0.01];
|
|
721
|
+
}
|
|
722
|
+
return [2 /*return*/, Number(block.baseFeePerGas) / (Math.pow(10, 9))];
|
|
723
|
+
case 3:
|
|
724
|
+
error_1 = _a.sent();
|
|
725
|
+
throw new Error(error_1);
|
|
726
|
+
case 4: return [2 /*return*/];
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
}); };
|
|
707
730
|
export var getGasPriceFromL1 = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
708
731
|
return __generator(this, function (_a) {
|
|
709
732
|
if (L2Networks.includes(curve.chainId) && curve.L1WeightedGasPrice) {
|
|
@@ -720,14 +743,32 @@ export var getGasPriceFromL2 = function () { return __awaiter(void 0, void 0, vo
|
|
|
720
743
|
return __generator(this, function (_a) {
|
|
721
744
|
switch (_a.label) {
|
|
722
745
|
case 0:
|
|
723
|
-
if (curve.chainId === 42161)
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
746
|
+
if (!(curve.chainId === 42161)) return [3 /*break*/, 2];
|
|
747
|
+
return [4 /*yield*/, getBaseFeeByLastBlock()];
|
|
748
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
749
|
+
case 2:
|
|
750
|
+
if (!L2Networks.includes(curve.chainId)) return [3 /*break*/, 4];
|
|
727
751
|
return [4 /*yield*/, curve.contracts[curve.constants.ALIASES.gas_oracle_blob].contract.gasPrice({ "gasPrice": "0x2000000" })];
|
|
728
|
-
case
|
|
752
|
+
case 3:
|
|
729
753
|
gasPrice = _a.sent();
|
|
730
754
|
return [2 /*return*/, Number(gasPrice)];
|
|
755
|
+
case 4: throw Error("This method exists only for L2 networks");
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
}); };
|
|
759
|
+
export var getGasInfoForL2 = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
760
|
+
var baseFee;
|
|
761
|
+
return __generator(this, function (_a) {
|
|
762
|
+
switch (_a.label) {
|
|
763
|
+
case 0:
|
|
764
|
+
if (!(curve.chainId === 42161)) return [3 /*break*/, 2];
|
|
765
|
+
return [4 /*yield*/, getBaseFeeByLastBlock()];
|
|
766
|
+
case 1:
|
|
767
|
+
baseFee = _a.sent();
|
|
768
|
+
return [2 /*return*/, {
|
|
769
|
+
maxFeePerGas: (baseFee * 1.1) + 0.01,
|
|
770
|
+
maxPriorityFeePerGas: 0.01,
|
|
771
|
+
}];
|
|
731
772
|
case 2: throw Error("This method exists only for L2 networks");
|
|
732
773
|
}
|
|
733
774
|
});
|