@curvefi/api 2.69.12 → 2.69.13

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.
Files changed (62) hide show
  1. package/lib/constants/abis/avaxcrypto/swap.json +1195 -0
  2. package/lib/constants/abis/avaxcrypto/zap.json +250 -0
  3. package/lib/constants/abis/factory-v2/MetaUSDGeist.json +932 -0
  4. package/lib/constants/chainIds.d.ts +1 -0
  5. package/lib/constants/chainIds.js +1 -0
  6. package/lib/constants/coins/aurora.d.ts +3 -0
  7. package/lib/constants/coins/aurora.js +9 -0
  8. package/lib/constants/coins/avalanche.d.ts +4 -0
  9. package/lib/constants/coins/avalanche.js +34 -0
  10. package/lib/constants/coins/celo.d.ts +3 -0
  11. package/lib/constants/coins/celo.js +9 -0
  12. package/lib/constants/coins/index.d.ts +10 -1
  13. package/lib/constants/coins/index.js +10 -1
  14. package/lib/constants/coins/kava.d.ts +3 -0
  15. package/lib/constants/coins/kava.js +9 -0
  16. package/lib/constants/coins/mantle.d.ts +2 -0
  17. package/lib/constants/coins/mantle.js +5 -0
  18. package/lib/constants/coins/moonbeam.d.ts +3 -0
  19. package/lib/constants/coins/moonbeam.js +9 -0
  20. package/lib/constants/coins/sonic.d.ts +2 -0
  21. package/lib/constants/coins/sonic.js +5 -0
  22. package/lib/constants/coins/xlayer.d.ts +2 -0
  23. package/lib/constants/coins/xlayer.js +5 -0
  24. package/lib/constants/coins/zksync.d.ts +2 -0
  25. package/lib/constants/coins/zksync.js +6 -0
  26. package/lib/constants/factory/crypto.d.ts +45 -0
  27. package/lib/constants/factory/crypto.js +72 -0
  28. package/lib/constants/factory/stable.d.ts +9 -0
  29. package/lib/constants/factory/stable.js +119 -0
  30. package/lib/constants/network_constants.js +258 -2
  31. package/lib/constants/pools/aurora.d.ts +2 -0
  32. package/lib/constants/pools/aurora.js +31 -0
  33. package/lib/constants/pools/avalanche.d.ts +2 -0
  34. package/lib/constants/pools/avalanche.js +166 -0
  35. package/lib/constants/pools/celo.d.ts +2 -0
  36. package/lib/constants/pools/celo.js +2 -0
  37. package/lib/constants/pools/index.d.ts +10 -1
  38. package/lib/constants/pools/index.js +10 -1
  39. package/lib/constants/pools/kava.d.ts +2 -0
  40. package/lib/constants/pools/kava.js +2 -0
  41. package/lib/constants/pools/mantle.d.ts +2 -0
  42. package/lib/constants/pools/mantle.js +2 -0
  43. package/lib/constants/pools/moonbeam.d.ts +2 -0
  44. package/lib/constants/pools/moonbeam.js +31 -0
  45. package/lib/constants/pools/sonic.d.ts +2 -0
  46. package/lib/constants/pools/sonic.js +2 -0
  47. package/lib/constants/pools/xlayer.d.ts +2 -0
  48. package/lib/constants/pools/xlayer.js +2 -0
  49. package/lib/constants/pools/zksync.d.ts +2 -0
  50. package/lib/constants/pools/zksync.js +2 -0
  51. package/lib/constants/rewardNetworks.js +1 -1
  52. package/lib/constants/volumeNetworks.d.ts +2 -0
  53. package/lib/constants/volumeNetworks.js +3 -1
  54. package/lib/curve.js +4 -1
  55. package/lib/external-api.d.ts +2 -0
  56. package/lib/external-api.js +41 -0
  57. package/lib/pools/PoolTemplate.js +2 -0
  58. package/lib/pools/subClasses/statsPool.js +2 -2
  59. package/lib/pools/utils.js +7 -2
  60. package/lib/route-graph.worker.js +3 -2
  61. package/lib/utils.js +55 -3
  62. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ import { IPoolData, IDict } from "../../interfaces.js";
2
+ export declare const POOLS_DATA_ZKSYNC: IDict<IPoolData>;
@@ -0,0 +1,2 @@
1
+ import { lowerCasePoolDataAddresses } from "../utils.js";
2
+ export const POOLS_DATA_ZKSYNC = lowerCasePoolDataAddresses({});
@@ -1,4 +1,4 @@
1
1
  export const rewardNetworks = {
2
2
  tokenApyLiteChainExceptions: [146, 167000, 42793], // Sonic, Taiko, Etherlink
3
- tokenApyDisabledChains: [], // Aurora
3
+ tokenApyDisabledChains: [1313161554], // Aurora
4
4
  };
@@ -1,5 +1,7 @@
1
1
  import { IChainId } from "../interfaces";
2
2
  export interface IVolumeNetworks {
3
3
  getVolumes: IChainId[];
4
+ getSubgraphData: IChainId[];
5
+ getFactoryAPYs: IChainId[];
4
6
  }
5
7
  export declare const volumeNetworks: IVolumeNetworks;
@@ -1,3 +1,5 @@
1
1
  export const volumeNetworks = {
2
- getVolumes: [1, 10, 56, 100, 137, 252, 999, 8453, 42161],
2
+ getVolumes: [1, 10, 56, 100, 137, 252, 999, 8453, 42161, 146],
3
+ getSubgraphData: [43114],
4
+ getFactoryAPYs: [196, 324, 1284, 2222, 5000, 42220, 1313161554],
3
5
  };
package/lib/curve.js CHANGED
@@ -54,7 +54,7 @@ import { L2Networks } from "./constants/L2Networks.js";
54
54
  import { getTwocryptoFactoryPoolData } from "./factory/factory-twocrypto.js";
55
55
  import { applyFeeDataOverride, computeEip1559Fees, computeLegacyOrFallback, fetchFeeHistory, getNetworkConstants, } from "./utils.js";
56
56
  import { _setPoolsFromApi } from "./cached.js";
57
- export const OLD_CHAINS = [1, 10, 56, 100, 137, 8453, 42161]; // these chains have non-ng pools
57
+ export const OLD_CHAINS = [1, 10, 56, 100, 137, 1284, 2222, 8453, 42161, 42220, 43114, 1313161554]; // these chains have non-ng pools
58
58
  export const memoizedContract = () => {
59
59
  const cache = {};
60
60
  return (address, abi, provider) => {
@@ -481,6 +481,9 @@ export class Curve {
481
481
  this.constants.STABLE_FACTORY_CONSTANTS = (_k = STABLE_FACTORY_CONSTANTS[this.chainId]) !== null && _k !== void 0 ? _k : {};
482
482
  this.constants.CRYPTO_FACTORY_CONSTANTS = (_l = CRYPTO_FACTORY_CONSTANTS[this.chainId]) !== null && _l !== void 0 ? _l : {};
483
483
  }
484
+ if (this.chainId === 5000) {
485
+ this.constantOptions = {};
486
+ }
484
487
  this.multicallProvider = new MulticallProvider(this.chainId, this.provider);
485
488
  if (this.signer) {
486
489
  try {
@@ -3,7 +3,9 @@ import { ICurveLiteNetwork, IDaoProposal, IDaoProposalListItem, IDict, IExtended
3
3
  export declare const uncached_getAllPoolsFromApi: (network: INetworkName, isLiteChain: boolean) => Promise<Record<IPoolType, IExtendedPoolDataFromApi>>;
4
4
  export declare const createUsdPricesDict: (allTypesExtendedPoolData: IExtendedPoolDataFromApi[]) => IDict<number>;
5
5
  export declare const createCrvApyDict: (allTypesExtendedPoolData: IExtendedPoolDataFromApi[]) => IDict<[number, number]>;
6
+ export declare const _getSubgraphData: ((network: INetworkName) => Promise<IVolumeAndAPYs>) & memoize.Memoized<(network: INetworkName) => Promise<IVolumeAndAPYs>>;
6
7
  export declare const _getVolumes: ((network: string) => Promise<IVolumeAndAPYs>) & memoize.Memoized<(network: string) => Promise<IVolumeAndAPYs>>;
8
+ export declare const _getFactoryAPYs: ((network: string) => Promise<IVolumeAndAPYs>) & memoize.Memoized<(network: string) => Promise<IVolumeAndAPYs>>;
7
9
  export declare const _getAllGauges: (() => Promise<IDict<IGaugesDataFromApi>>) & memoize.Memoized<() => Promise<IDict<IGaugesDataFromApi>>>;
8
10
  export declare const _getAllGaugesFormatted: (() => Promise<IDict<any>>) & memoize.Memoized<() => Promise<IDict<any>>>;
9
11
  export declare const _getHiddenPools: ((isLiteChain: boolean) => Promise<IDict<string[]>>) & memoize.Memoized<(isLiteChain: boolean) => Promise<IDict<string[]>>>;
@@ -107,6 +107,25 @@ export const createCrvApyDict = (allTypesExtendedPoolData) => {
107
107
  }
108
108
  return apyDict;
109
109
  };
110
+ export const _getSubgraphData = memoize((network) => __awaiter(void 0, void 0, void 0, function* () {
111
+ var _a, _b, _c;
112
+ const data = yield fetchData(`https://api.curve.finance/api/getSubgraphData/${network}`);
113
+ const poolsData = data.poolList.map((data) => ({
114
+ address: data.address,
115
+ volumeUSD: data.volumeUSD,
116
+ day: data.latestDailyApy,
117
+ week: data.latestWeeklyApy,
118
+ }));
119
+ return {
120
+ poolsData: poolsData,
121
+ totalVolume: (_a = data.totalVolume) !== null && _a !== void 0 ? _a : 0,
122
+ cryptoVolume: (_b = data.cryptoVolume) !== null && _b !== void 0 ? _b : 0,
123
+ cryptoShare: (_c = data.cryptoShare) !== null && _c !== void 0 ? _c : 0,
124
+ };
125
+ }), {
126
+ promise: true,
127
+ maxAge: 5 * 60 * 1000, // 5m
128
+ });
110
129
  export const _getVolumes = memoize((network) => __awaiter(void 0, void 0, void 0, function* () {
111
130
  var _a, _b, _c;
112
131
  const { pools, totalVolumes } = yield fetchData(`https://api.curve.finance/api/getVolumes/${network}`);
@@ -126,6 +145,28 @@ export const _getVolumes = memoize((network) => __awaiter(void 0, void 0, void 0
126
145
  promise: true,
127
146
  maxAge: 5 * 60 * 1000, // 5m
128
147
  });
148
+ export const _getFactoryAPYs = memoize((network) => __awaiter(void 0, void 0, void 0, function* () {
149
+ const [stableData, cryptoData] = yield Promise.all(['stable', 'crypto'].map((type) => fetchData(`https://api.curve.finance/api/getFactoryAPYs/${network}/${type}`)));
150
+ const stableVolume = stableData.totalVolumeUsd || stableData.totalVolume || 0;
151
+ const cryptoVolume = cryptoData.totalVolumeUsd || cryptoData.totalVolume || 0;
152
+ return {
153
+ poolsData: [...stableData.poolDetails, ...cryptoData.poolDetails].map((item) => {
154
+ var _a, _b, _c;
155
+ return ({
156
+ address: item.poolAddress,
157
+ volumeUSD: (_a = item.totalVolumeUsd) !== null && _a !== void 0 ? _a : 0,
158
+ day: (_b = item.apy) !== null && _b !== void 0 ? _b : 0,
159
+ week: ((_c = item.apy) !== null && _c !== void 0 ? _c : 0) * 7, // Because api does not return week apy
160
+ });
161
+ }),
162
+ totalVolume: stableVolume + cryptoVolume,
163
+ cryptoVolume,
164
+ cryptoShare: 100 * cryptoVolume / (stableVolume + cryptoVolume),
165
+ };
166
+ }), {
167
+ promise: true,
168
+ maxAge: 5 * 60 * 1000, // 5m
169
+ });
129
170
  export const _getAllGauges = memoize(() => fetchData(`https://api.curve.finance/api/getAllGauges`), {
130
171
  promise: true,
131
172
  maxAge: 5 * 60 * 1000, // 5m
@@ -591,6 +591,8 @@ export class PoolTemplate extends CorePool {
591
591
  return checkVyperVulnerability(this.curve.chainId, this.id, this.implementation);
592
592
  }
593
593
  rewardsOnly() {
594
+ if (this.curve.chainId === 2222 || this.curve.chainId === 324)
595
+ return true; // TODO remove this for Kava and ZkSync
594
596
  if (this.gauge.address === this.curve.constants.ZERO_ADDRESS)
595
597
  throw Error(`${this.name} doesn't have gauge`);
596
598
  return !findAbiFunction(this.curve.contracts[this.gauge.address].abi, 'inflation_rate')
@@ -134,7 +134,7 @@ export class StatsPool {
134
134
  });
135
135
  this.volume = () => __awaiter(this, void 0, void 0, function* () {
136
136
  const curve = this.pool.curve;
137
- if (curve.isLiteChain) {
137
+ if (curve.isLiteChain && curve.chainId !== 146) {
138
138
  throw Error('This method is not supported for the lite version');
139
139
  }
140
140
  const network = curve.constants.NETWORK_NAME;
@@ -147,7 +147,7 @@ export class StatsPool {
147
147
  });
148
148
  this.baseApy = () => __awaiter(this, void 0, void 0, function* () {
149
149
  const curve = this.pool.curve;
150
- if (curve.isLiteChain) {
150
+ if (curve.isLiteChain && curve.chainId !== 146) {
151
151
  throw Error('baseApy is not supported for the lite version');
152
152
  }
153
153
  const network = curve.constants.NETWORK_NAME;
@@ -94,7 +94,7 @@ function _getUserClaimable(pools, address, useCache) {
94
94
  const hasCrvReward = [];
95
95
  for (const poolId of poolsToFetch) {
96
96
  const pool = getPool.call(this, poolId);
97
- if (pool.gauge.address === this.constants.ZERO_ADDRESS) {
97
+ if (this.chainId === 324 || this.chainId === 2222 || pool.gauge.address === this.constants.ZERO_ADDRESS) { // TODO remove this for ZkSync and Kava
98
98
  hasCrvReward.push(false);
99
99
  continue;
100
100
  }
@@ -227,7 +227,7 @@ function _getUserClaimableUseApi(pools, address, useCache) {
227
227
  const hasCrvReward = [];
228
228
  for (const poolId of poolsToFetch) {
229
229
  const pool = getPool.call(this, poolId);
230
- if (pool.gauge.address === this.constants.ZERO_ADDRESS) {
230
+ if (this.chainId === 324 || this.chainId === 2222 || pool.gauge.address === this.constants.ZERO_ADDRESS) { // TODO remove this for ZkSync and Kava
231
231
  hasCrvReward.push(false);
232
232
  continue;
233
233
  }
@@ -383,6 +383,11 @@ export const checkVyperVulnerability = (chainId, poolId, implementation) => {
383
383
  "0xAAe75FAebCae43b9d541Fd875622BE48D9B4f5D0",
384
384
  "0x89287c32c2CAC1C76227F6d300B2DBbab6b75C08",
385
385
  ].map((a) => a.toLowerCase()),
386
+ 43114: [
387
+ "0x64448B78561690B70E17CBE8029a3e5c1bB7136e",
388
+ "0xF1f85a74AD6c64315F85af52d3d46bF715236ADc",
389
+ "0x0eb0F1FaF5F509Ac53fA224477509EAD167cf410",
390
+ ].map((a) => a.toLowerCase()),
386
391
  };
387
392
  const implementations = (_a = vulnerableImplementations[chainId]) !== null && _a !== void 0 ? _a : [];
388
393
  return implementations.includes((_b = implementation === null || implementation === void 0 ? void 0 : implementation.toLowerCase()) !== null && _b !== void 0 ? _b : "");
@@ -1,5 +1,6 @@
1
1
  export function routeGraphWorker() {
2
2
  const GRAPH_MAX_EDGES = 3;
3
+ const CELO_CHAIN_ID = 42220;
3
4
  const ARC_CHAIN_ID = 5042; // native USDC is the same asset as its ERC-20 interface
4
5
  // Pools excluded from router
5
6
  const EXCLUDED_POOLS_FROM_ROUTER = {
@@ -10,8 +11,8 @@ export function routeGraphWorker() {
10
11
  const routerGraph = {};
11
12
  // Pool addresses we don't want to index when building routes
12
13
  const blacklistedPools = new Set((blacklist !== null && blacklist !== void 0 ? blacklist : []).map((a) => a.toLowerCase()));
13
- // ETH <-> WETH (exclude Arc — native USDC = ERC-20 USDC)
14
- if (chainId !== ARC_CHAIN_ID) {
14
+ // ETH <-> WETH (exclude Celo, Arc — native USDC = ERC-20 USDC)
15
+ if (chainId !== CELO_CHAIN_ID && chainId !== ARC_CHAIN_ID) {
15
16
  const wrapperAddress = constants.NATIVE_TOKEN.wrapperAddress || constants.NATIVE_TOKEN.wrappedAddress;
16
17
  routerGraph[constants.NATIVE_TOKEN.address] = {};
17
18
  routerGraph[constants.NATIVE_TOKEN.address][constants.NATIVE_TOKEN.wrappedAddress] = [{
package/lib/utils.js CHANGED
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { Contract, ethers } from 'ethers';
11
11
  import { Contract as MulticallContract } from "@curvefi/ethcall";
12
12
  import BigNumber from 'bignumber.js';
13
- import { _getCurveLiteNetworks, _getLiteNetworksData, _getVolumes, } from "./external-api.js";
13
+ import { _getCurveLiteNetworks, _getFactoryAPYs, _getLiteNetworksData, _getSubgraphData, _getVolumes, } from "./external-api.js";
14
14
  import { _getAllPoolsFromApi, _getUsdPricesFromApi } from "./cached.js";
15
15
  import ERC20Abi from './constants/abis/ERC20.json' with { type: 'json' };
16
16
  import { L2Networks } from './constants/L2Networks.js';
@@ -354,10 +354,19 @@ export function _getUsdRate(assetId) {
354
354
  56: "binance-smart-chain",
355
355
  100: 'xdai',
356
356
  137: 'polygon-pos',
357
+ 146: 'sonic',
358
+ 196: 'x-layer',
357
359
  252: 'fraxtal',
360
+ 324: 'zksync',
358
361
  999: 'hyperliquid',
362
+ 1284: 'moonbeam',
363
+ 2222: 'kava',
364
+ 5000: 'mantle',
359
365
  8453: 'base',
366
+ 42220: 'celo',
367
+ 43114: 'avalanche',
360
368
  42161: 'arbitrum-one',
369
+ 1313161554: 'aurora',
361
370
  }[this.chainId];
362
371
  const nativeTokenName = this.isLiteChain ? (_b = (_a = this.constants) === null || _a === void 0 ? void 0 : _a.API_CONSTANTS) === null || _b === void 0 ? void 0 : _b.nativeTokenName : {
363
372
  1: 'ethereum',
@@ -365,10 +374,19 @@ export function _getUsdRate(assetId) {
365
374
  56: 'binancecoin',
366
375
  100: 'xdai',
367
376
  137: 'matic-network',
377
+ 146: 'sonic-3',
378
+ 196: 'okb',
368
379
  252: 'frax-share',
380
+ 324: 'ethereum',
381
+ 1284: 'moonbeam',
369
382
  999: 'hyperliquid',
383
+ 2222: 'kava',
384
+ 5000: 'mantle',
370
385
  8453: 'ethereum',
386
+ 42220: 'celo',
387
+ 43114: 'avalanche-2',
371
388
  42161: 'ethereum',
389
+ 1313161554: 'ethereum',
372
390
  }[this.chainId];
373
391
  if (chainName === undefined) {
374
392
  throw Error('curve object is not initialized');
@@ -490,6 +508,15 @@ export function getGasPriceFromL2() {
490
508
  if (this.chainId === 42161) {
491
509
  return yield getBaseFeeByLastBlock.call(this);
492
510
  }
511
+ if (this.chainId === 196) {
512
+ return yield getGasPrice.call(this); // gwei
513
+ }
514
+ if (this.chainId === 324) {
515
+ return yield getGasPrice.call(this); // gwei
516
+ }
517
+ if (this.chainId === 5000) {
518
+ return yield getGasPrice.call(this); // gwei
519
+ }
493
520
  if (L2Networks.includes(this.chainId)) {
494
521
  const gasPrice = yield this.contracts[this.constants.ALIASES.gas_oracle_blob].contract.gasPrice({ "gasPrice": "0x2000000" });
495
522
  return Number(gasPrice);
@@ -508,6 +535,25 @@ export function getGasInfoForL2() {
508
535
  maxPriorityFeePerGas: 0.01,
509
536
  };
510
537
  }
538
+ else if (this.chainId === 196) {
539
+ const gasPrice = yield getGasPrice.call(this);
540
+ return {
541
+ gasPrice,
542
+ };
543
+ }
544
+ else if (this.chainId === 324) {
545
+ const gasPrice = yield getGasPrice.call(this);
546
+ return {
547
+ gasPrice,
548
+ };
549
+ }
550
+ else if (this.chainId === 5000) {
551
+ const baseFee = yield getBaseFeeByLastBlock.call(this);
552
+ return {
553
+ maxFeePerGas: Number(((baseFee * 1.1) + 0.01).toFixed(2)),
554
+ maxPriorityFeePerGas: 0.01,
555
+ };
556
+ }
511
557
  else {
512
558
  throw Error("This method exists only for L2 networks");
513
559
  }
@@ -629,18 +675,24 @@ export function getTVL() {
629
675
  }
630
676
  export function getVolumeApiController(network) {
631
677
  return __awaiter(this, void 0, void 0, function* () {
632
- if (this.isLiteChain) {
678
+ if (this.isLiteChain && this.chainId !== 146) {
633
679
  throw Error('This method is not supported for the lite version');
634
680
  }
635
681
  if (volumeNetworks.getVolumes.includes(this.chainId)) {
636
682
  return yield _getVolumes(network);
637
683
  }
684
+ if (volumeNetworks.getFactoryAPYs.includes(this.chainId)) {
685
+ return yield _getFactoryAPYs(network);
686
+ }
687
+ if (volumeNetworks.getSubgraphData.includes(this.chainId)) {
688
+ return yield _getSubgraphData(network);
689
+ }
638
690
  throw Error(`Can't get volume for network: ${network}`);
639
691
  });
640
692
  }
641
693
  export function getVolume() {
642
694
  return __awaiter(this, arguments, void 0, function* (chainId = this.chainId) {
643
- if (this.isLiteChain) {
695
+ if (this.isLiteChain && this.chainId !== 146) {
644
696
  throw Error('This method is not supported for the lite version');
645
697
  }
646
698
  const networkConstants = yield getNetworkConstants.call(this, chainId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.69.12",
3
+ "version": "2.69.13",
4
4
  "description": "JavaScript library for curve.finance",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",