@curvefi/api 2.69.5 → 2.69.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 -0
- package/lib/constants/chainIds.d.ts +4 -0
- package/lib/constants/chainIds.js +4 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -1
- package/lib/route-graph.worker.js +4 -2
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +17 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -535,6 +535,13 @@ import curve from "@curvefi/api";
|
|
|
535
535
|
await steth.stats.volume();
|
|
536
536
|
// 174737430.35185483
|
|
537
537
|
|
|
538
|
+
await curve.getPoolVolumes();
|
|
539
|
+
// {
|
|
540
|
+
// '0xa2b47e3d5c44877cca798226b7b8118f9bfb7a56': '123456789.123',
|
|
541
|
+
// '0xdc24316b9ae028f1497c275eb9192a3ea0f67022': '174737430.35185483',
|
|
542
|
+
// ...
|
|
543
|
+
// }
|
|
544
|
+
|
|
538
545
|
await steth.stats.baseApy();
|
|
539
546
|
// { day: '3.1587592896017647', week: '2.6522145719060752' } (as %)
|
|
540
547
|
|
package/lib/index.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ export declare const createCurve: () => {
|
|
|
65
65
|
cryptoVolume: number;
|
|
66
66
|
cryptoShare: number;
|
|
67
67
|
}>;
|
|
68
|
+
getPoolVolumes: () => Promise<Record<`0x${string}`, `${number}`>>;
|
|
68
69
|
hasDepositAndStake: () => boolean;
|
|
69
70
|
hasRouter: () => boolean;
|
|
70
71
|
getCurveLiteNetworks: () => Promise<import("./interfaces.js").ICurveLiteNetwork[]>;
|
|
@@ -398,6 +399,7 @@ declare const _default: {
|
|
|
398
399
|
cryptoVolume: number;
|
|
399
400
|
cryptoShare: number;
|
|
400
401
|
}>;
|
|
402
|
+
getPoolVolumes: () => Promise<Record<`0x${string}`, `${number}`>>;
|
|
401
403
|
hasDepositAndStake: () => boolean;
|
|
402
404
|
hasRouter: () => boolean;
|
|
403
405
|
getCurveLiteNetworks: () => Promise<import("./interfaces.js").ICurveLiteNetwork[]>;
|
package/lib/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { getBestRouteAndOutput, getArgs, swapExpected, swapRequired, swapPriceIm
|
|
|
13
13
|
import { isSupported, assertIsSupported, allowedToBridge, bridgeCost, bridgeIsApproved, bridgeApproveEstimateGas, bridgeApprove, bridgeEstimateGas, bridge, getSupportedNetworks, } from "./bridge.js";
|
|
14
14
|
import { Curve } from "./curve.js";
|
|
15
15
|
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, claimFeesCrvUSDEstimateGas, claimableFeesCrvUSD, claimFeesCrvUSD, calculateVeCrv, } from "./boosting.js";
|
|
16
|
-
import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, populateApprove, getUsdRate, getGasPriceFromL1, getGasPriceFromL2, getGasInfoForL2, getTVL, getCoinsData, getVolume, hasDepositAndStake, hasRouter, getBasePools, getGasPrice, getCurveLiteNetworks, } from "./utils.js";
|
|
16
|
+
import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, populateApprove, getUsdRate, getGasPriceFromL1, getGasPriceFromL2, getGasInfoForL2, getTVL, getCoinsData, getVolume, getPoolVolumes, hasDepositAndStake, hasRouter, getBasePools, getGasPrice, getCurveLiteNetworks, } from "./utils.js";
|
|
17
17
|
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';
|
|
18
18
|
import { getTwoCryptoImplementations } from './constants/twoCryptoImplementations.js';
|
|
19
19
|
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, executeVote, executeVoteEstimateGas, isCanVoteExecute, } from "./dao.js";
|
|
@@ -56,6 +56,7 @@ export const createCurve = () => {
|
|
|
56
56
|
populateApprove: populateApprove.bind(_curve),
|
|
57
57
|
getCoinsData: getCoinsData.bind(_curve),
|
|
58
58
|
getVolume: getVolume.bind(_curve),
|
|
59
|
+
getPoolVolumes: getPoolVolumes.bind(_curve),
|
|
59
60
|
hasDepositAndStake: hasDepositAndStake.bind(_curve),
|
|
60
61
|
hasRouter: hasRouter.bind(_curve),
|
|
61
62
|
getCurveLiteNetworks: getCurveLiteNetworks.bind(_curve),
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export function routeGraphWorker() {
|
|
2
2
|
const GRAPH_MAX_EDGES = 3;
|
|
3
|
+
const CELO_CHAIN_ID = 42220;
|
|
4
|
+
const ARC_CHAIN_ID = 5042; // native USDC is the same asset as its ERC-20 interface
|
|
3
5
|
// Pools excluded from router
|
|
4
6
|
const EXCLUDED_POOLS_FROM_ROUTER = {
|
|
5
7
|
1: ['usdt'], // Ethereum mainnet
|
|
@@ -9,8 +11,8 @@ export function routeGraphWorker() {
|
|
|
9
11
|
const routerGraph = {};
|
|
10
12
|
// Pool addresses we don't want to index when building routes
|
|
11
13
|
const blacklistedPools = new Set((blacklist !== null && blacklist !== void 0 ? blacklist : []).map((a) => a.toLowerCase()));
|
|
12
|
-
// ETH <-> WETH (exclude Celo)
|
|
13
|
-
if (chainId !==
|
|
14
|
+
// ETH <-> WETH (exclude Celo, Arc — native USDC = ERC-20 USDC)
|
|
15
|
+
if (chainId !== CELO_CHAIN_ID && chainId !== ARC_CHAIN_ID) {
|
|
14
16
|
const wrapperAddress = constants.NATIVE_TOKEN.wrapperAddress || constants.NATIVE_TOKEN.wrappedAddress;
|
|
15
17
|
routerGraph[constants.NATIVE_TOKEN.address] = {};
|
|
16
18
|
routerGraph[constants.NATIVE_TOKEN.address][constants.NATIVE_TOKEN.wrappedAddress] = [{
|
package/lib/utils.d.ts
CHANGED
|
@@ -83,6 +83,7 @@ export declare function getVolume(this: Curve, chainId?: number): Promise<{
|
|
|
83
83
|
cryptoVolume: number;
|
|
84
84
|
cryptoShare: number;
|
|
85
85
|
}>;
|
|
86
|
+
export declare function getPoolVolumes(this: Curve): Promise<Record<`0x${string}`, `${number}`>>;
|
|
86
87
|
export declare function _setContracts(this: Curve, address: string, abi: any): {
|
|
87
88
|
abi: any;
|
|
88
89
|
contract: Contract;
|
package/lib/utils.js
CHANGED
|
@@ -19,6 +19,7 @@ import { getPool } from "./pools/index.js";
|
|
|
19
19
|
import { NETWORK_CONSTANTS } from "./constants/network_constants.js";
|
|
20
20
|
import { formatUnits } from "./constants/utils.js";
|
|
21
21
|
import { FEE_HISTORY_BLOCK_COUNT, GAS_STRATEGIES, MAINNET_CHAIN_ID, } from "./constants/gas.js";
|
|
22
|
+
import { ARC_CHAIN_ID, POLYGON_CHAIN_ID, STABLE_CHAIN_ID } from "./constants/chainIds.js";
|
|
22
23
|
export const ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
23
24
|
// export const MAX_ALLOWANCE = curve.parseUnits(new BigNumber(2).pow(256).minus(1).toFixed(), 0);
|
|
24
25
|
export const MAX_ALLOWANCE = BigInt("115792089237316195423570985008687907853269984665640564039457584007913129639935"); // 2**256 - 1
|
|
@@ -342,7 +343,10 @@ export function _getUsdRate(assetId) {
|
|
|
342
343
|
const pricesFromApi = yield _getUsdPricesFromApi(this.constants.NETWORK_NAME, this.isLiteChain);
|
|
343
344
|
if (assetId.toLowerCase() in pricesFromApi)
|
|
344
345
|
return pricesFromApi[assetId.toLowerCase()];
|
|
345
|
-
if (assetId === 'USD' || (this.chainId ===
|
|
346
|
+
if (assetId === 'USD' || (this.chainId === POLYGON_CHAIN_ID && (assetId.toLowerCase() === this.constants.COINS.am3crv.toLowerCase())))
|
|
347
|
+
return 1;
|
|
348
|
+
if (this.chainId === ARC_CHAIN_ID && (this.isEth(assetId) ||
|
|
349
|
+
assetId.toLowerCase() === this.constants.NATIVE_TOKEN.wrappedAddress.toLowerCase()))
|
|
346
350
|
return 1;
|
|
347
351
|
let chainName = this.isLiteChain ? yield this.constants.NETWORK_NAME : {
|
|
348
352
|
1: 'ethereum',
|
|
@@ -404,8 +408,8 @@ export function _getUsdRate(assetId) {
|
|
|
404
408
|
'ETH': 'ethereum',
|
|
405
409
|
'LINK': 'link',
|
|
406
410
|
}[assetId.toUpperCase()] || assetId;
|
|
407
|
-
// Special case for chainId
|
|
408
|
-
if (this.chainId ===
|
|
411
|
+
// Special case for chainId STABLE_CHAIN_ID native and wrapped tokens are USDT
|
|
412
|
+
if (this.chainId === STABLE_CHAIN_ID) {
|
|
409
413
|
if (this.isEth(assetId) || assetId.toLowerCase() === this.constants.NATIVE_TOKEN.wrappedAddress.toLowerCase()) {
|
|
410
414
|
assetId = 'tether';
|
|
411
415
|
}
|
|
@@ -414,7 +418,7 @@ export function _getUsdRate(assetId) {
|
|
|
414
418
|
assetId = this.isEth(assetId) ? nativeTokenName : assetId.toLowerCase();
|
|
415
419
|
}
|
|
416
420
|
// No EURT on Coingecko Polygon
|
|
417
|
-
if (this.chainId ===
|
|
421
|
+
if (this.chainId === POLYGON_CHAIN_ID && assetId.toLowerCase() === this.constants.COINS.eurt) {
|
|
418
422
|
chainName = 'ethereum';
|
|
419
423
|
assetId = '0xC581b735A1688071A1746c968e0798D642EDE491'.toLowerCase(); // EURT Ethereum
|
|
420
424
|
}
|
|
@@ -423,8 +427,8 @@ export function _getUsdRate(assetId) {
|
|
|
423
427
|
assetId = 'curve-dao-token';
|
|
424
428
|
}
|
|
425
429
|
if (this.isLiteChain && assetId.toLowerCase() === ((_f = this.constants.API_CONSTANTS) === null || _f === void 0 ? void 0 : _f.wrappedNativeTokenAddress.toLowerCase())) {
|
|
426
|
-
// For chainId
|
|
427
|
-
if (this.chainId !==
|
|
430
|
+
// For chainId STABLE_CHAIN_ID, already handled above (tether)
|
|
431
|
+
if (this.chainId !== STABLE_CHAIN_ID) {
|
|
428
432
|
assetId = nativeTokenName;
|
|
429
433
|
}
|
|
430
434
|
}
|
|
@@ -698,6 +702,13 @@ export function getVolume() {
|
|
|
698
702
|
return { totalVolume, cryptoVolume, cryptoShare };
|
|
699
703
|
});
|
|
700
704
|
}
|
|
705
|
+
export function getPoolVolumes() {
|
|
706
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
707
|
+
const { poolsData } = yield getVolumeApiController.call(this, this.constants.NETWORK_NAME);
|
|
708
|
+
const entries = poolsData.map(({ address, volumeUSD }) => [address.toLowerCase(), `${volumeUSD}`]);
|
|
709
|
+
return Object.fromEntries(entries);
|
|
710
|
+
});
|
|
711
|
+
}
|
|
701
712
|
export function _setContracts(address, abi) {
|
|
702
713
|
const contracts = {
|
|
703
714
|
abi,
|