@curvefi/api 2.58.8 → 2.58.9
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/index.d.ts +1 -1
- package/lib/index.js +2 -2
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +10 -43
- package/package.json +1 -1
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
|
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
|
|
733
|
-
var provider,
|
|
734
|
-
return __generator(this, function (
|
|
735
|
-
switch (
|
|
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
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
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*/,
|
|
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*/,
|
|
793
|
+
return [4 /*yield*/, getGasPrice()];
|
|
827
794
|
case 3:
|
|
828
795
|
gasPrice = _a.sent();
|
|
829
796
|
return [2 /*return*/, {
|