@curvefi/api 2.71.0 → 2.71.1

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/cached.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { IDict, IExtendedPoolDataFromApi, INetworkName, IPoolType } from "./interfaces.js";
2
2
  export declare const _getPoolsFromApi: (network: INetworkName, poolType: IPoolType, isLiteChain?: boolean) => Promise<IExtendedPoolDataFromApi>;
3
- export declare const _getPoolTotalLiquidityFromApi: (network: INetworkName, poolId: string, address: string, isCrypto: boolean, isLiteChain: boolean) => Promise<string | undefined>;
4
3
  export declare const _setPoolsFromApi: (network: INetworkName, isLiteChain: boolean, data: Record<IPoolType, IExtendedPoolDataFromApi>) => void;
5
4
  export declare const _getAllPoolsFromApi: (network: INetworkName, isLiteChain: boolean) => Promise<IExtendedPoolDataFromApi[]>;
5
+ export declare const _getPoolTotalLiquidityFromApi: (network: INetworkName, address: string, isLiteChain: boolean) => Promise<string | undefined>;
6
6
  export declare const _getUsdPricesFromApi: (network: INetworkName, isLiteChain: boolean) => Promise<IDict<number>>;
7
7
  export declare const _getCrvApyFromApi: (network: INetworkName, isLiteChain: boolean) => Promise<IDict<[number, number]>>;
package/lib/cached.js CHANGED
@@ -74,18 +74,21 @@ export const _getPoolsFromApi = (network_1, poolType_1, ...args_1) => __awaiter(
74
74
  const { poolsDict } = yield _getCachedData(network, isLiteChain);
75
75
  return poolsDict[poolType];
76
76
  });
77
- export const _getPoolTotalLiquidityFromApi = (network, poolId, address, isCrypto, isLiteChain) => __awaiter(void 0, void 0, void 0, function* () {
78
- const poolType = poolId.startsWith("factory") ? poolId.replace(/-\d+$/, '').replace(/-v2$/, '') : isCrypto ? "crypto" : "main";
79
- const { poolData } = yield _getPoolsFromApi(network, poolType, isLiteChain);
80
- const poolAddress = address.toLowerCase();
81
- const poolEntry = poolData.find((data) => data.address.toLowerCase() === poolAddress);
82
- return poolEntry ? String(poolEntry.usdTotal) : undefined;
83
- });
84
77
  export const _setPoolsFromApi = (network, isLiteChain, data) => _getCachedData.set(createCache(data), network, isLiteChain);
85
78
  export const _getAllPoolsFromApi = (network, isLiteChain) => __awaiter(void 0, void 0, void 0, function* () {
86
79
  const { poolLists } = yield _getCachedData(network, isLiteChain);
87
80
  return poolLists;
88
81
  });
82
+ export const _getPoolTotalLiquidityFromApi = (network, address, isLiteChain) => __awaiter(void 0, void 0, void 0, function* () {
83
+ const poolAddress = address.toLowerCase();
84
+ const poolLists = yield _getAllPoolsFromApi(network, isLiteChain);
85
+ for (const { poolData } of poolLists) {
86
+ const poolEntry = poolData.find((data) => data.address.toLowerCase() === poolAddress);
87
+ if (poolEntry)
88
+ return String(poolEntry.usdTotal);
89
+ }
90
+ return undefined;
91
+ });
89
92
  export const _getUsdPricesFromApi = (network, isLiteChain) => __awaiter(void 0, void 0, void 0, function* () {
90
93
  const { usdPrices } = yield _getCachedData(network, isLiteChain);
91
94
  return usdPrices;
@@ -322,7 +322,7 @@ export const basePoolIdZapDictArbitrum = {
322
322
  address: "0x803A2B40c5a9BB2B86DD630B274Fa2A9202874C2".toLowerCase(),
323
323
  ABI: MetaZapFantomABI,
324
324
  },
325
- "factory-v2-41": {
325
+ "0xc9b8a3fdecb9d5b218d02555a8baf332e5b740d5": {
326
326
  address: "0x58AC91f5BE7dC0c35b24B96B19BAc55FBB8E705e".toLowerCase(),
327
327
  ABI: MetaZapFantomABI,
328
328
  },
@@ -332,7 +332,7 @@ export const basePoolIdZapDictOptimism = {
332
332
  address: "0x167e42a1c7ab4be03764a2222aac57f5f6754411".toLowerCase(),
333
333
  ABI: factoryDepositABI,
334
334
  },
335
- "factory-v2-16": {
335
+ "0x29a3d66b30bc4ad674a4fdaf27578b64f6afbfe7": {
336
336
  address: "0x4244eB811D6e0Ef302326675207A95113dB4E1F8".toLowerCase(),
337
337
  ABI: MetaZapFantomABI,
338
338
  },
@@ -142,7 +142,7 @@ export const POOLS_DATA_AVALANCHE = lowerCasePoolDataAddresses({
142
142
  deposit_address: '0x9f2Fa7709B30c75047980a0d70A106728f0Ef2db',
143
143
  is_meta: true,
144
144
  is_crypto: true,
145
- base_pool: 'factory-v2-99',
145
+ base_pool: '0x0974d9d3bc463fa17497aafc3a87535553298fbe',
146
146
  meta_coin_idx: 0,
147
147
  underlying_coins: ['USDC', 'USDt', 'BTC.b', 'AVAX'],
148
148
  wrapped_coins: ['2CRV', 'BTC.b', 'WAVAX'],
@@ -13,7 +13,7 @@ import { getLiteDeploymentFromApi2, getLiteNetworksFromApi2, getLitePoolsFromApi
13
13
  // Core chains that ARE fully configured in the library (static POOLS_DATA / ALIASES /
14
14
  // implementationABIDict) but whose live pool data is NOT indexed by prices.curve.finance.
15
15
  // Their factory pools live in api2 instead, so we fetch from there while keeping them core
16
- // (static main/crypto pools + on-chain reconcile + impl-ABI dict all keep working).
16
+ // (static main/crypto pools + impl-ABI dict all keep working).
17
17
  const API2_BACKED_CORE_CHAINS = ["avalanche"];
18
18
  const uncached_getPoolsFromApi = (network, poolType, isLiteChain) => __awaiter(void 0, void 0, void 0, function* () {
19
19
  if (isLiteChain || API2_BACKED_CORE_CHAINS.includes(network))
@@ -17,44 +17,11 @@ import tricryptoFactorySwapABI from "../constants/abis/factory-tricrypto/factory
17
17
  import tricryptoFactoryEthDisabledSwapABI from "../constants/abis/factory-tricrypto/factory-tricrypto-pool-eth-disabled.json" with { type: "json" };
18
18
  import { getPoolIdByAddress, setFactoryZapContracts } from "./common.js";
19
19
  import { _getPoolsFromApi } from "../cached.js";
20
- import { assetTypeNameHandler, getPoolName, isStableNgPool } from "../utils.js";
20
+ import { assetTypeNameHandler, getPoolName } from "../utils.js";
21
21
  import StableNgBasePoolZapABI from "../constants/abis/stable-ng-base-pool-zap.json" with { type: "json" };
22
22
  import MetaStableSwapNGABI from "../constants/abis/factory-stable-ng/meta-stableswap-ng.json" with { type: "json" };
23
23
  import PlainStableSwapNGABI from "../constants/abis/factory-stable-ng/plain-stableswap-ng.json" with { type: "json" };
24
24
  import { isYBPool } from "../constants/ybPools.js";
25
- const FACTORY_ALIAS_BY_TYPE = {
26
- "factory": "factory",
27
- "factory-crvusd": "crvusd_factory",
28
- "factory-crypto": "crypto_factory",
29
- "factory-twocrypto": "twocrypto_factory",
30
- "factory-tricrypto": "tricrypto_factory",
31
- "factory-stable-ng": "stable_ng_factory",
32
- };
33
- const ID_PREFIX_BY_FACTORY_TYPE = {
34
- "factory": "factory-v2",
35
- "factory-crvusd": "factory-crvusd",
36
- "factory-crypto": "factory-crypto",
37
- "factory-twocrypto": "factory-twocrypto",
38
- "factory-tricrypto": "factory-tricrypto",
39
- "factory-stable-ng": "factory-stable-ng",
40
- };
41
- function reconcilePoolIdsWithChain(poolList, factoryType) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- const factoryAddress = this.constants.ALIASES[FACTORY_ALIAS_BY_TYPE[factoryType]];
44
- const factoryMulticallContract = this.contracts[factoryAddress].multicallContract;
45
- const poolCount = Number(this.formatUnits(yield this.contracts[factoryAddress].contract.pool_count(this.constantOptions), 0));
46
- const calls = [];
47
- for (let i = 0; i < poolCount; i++)
48
- calls.push(factoryMulticallContract.pool_list(i));
49
- const addresses = (yield this.multicallProvider.all(calls));
50
- const indexByAddress = new Map();
51
- addresses.forEach((address, i) => indexByAddress.set(address.toLowerCase(), i));
52
- const prefix = ID_PREFIX_BY_FACTORY_TYPE[factoryType];
53
- return poolList
54
- .filter((pool) => indexByAddress.has(pool.address))
55
- .map((pool) => (Object.assign(Object.assign({}, pool), { id: `${prefix}-${indexByAddress.get(pool.address)}` })));
56
- });
57
- }
58
25
  export const lowerCasePoolDataAddresses = (poolsData) => {
59
26
  var _a;
60
27
  for (const poolData of poolsData) {
@@ -124,8 +91,7 @@ function setFactoryCoinsContracts(rawPoolList) {
124
91
  export function getFactoryPoolsDataFromApi(factoryType) {
125
92
  return __awaiter(this, void 0, void 0, function* () {
126
93
  const network = this.constants.NETWORK_NAME;
127
- let rawPoolList = lowerCasePoolDataAddresses((yield _getPoolsFromApi(network, factoryType, this.isLiteChain)).poolData);
128
- rawPoolList = yield reconcilePoolIdsWithChain.call(this, rawPoolList, factoryType);
94
+ const rawPoolList = lowerCasePoolDataAddresses((yield _getPoolsFromApi(network, factoryType, this.isLiteChain)).poolData);
129
95
  return buildFactoryPoolsData.call(this, factoryType, rawPoolList);
130
96
  });
131
97
  }
@@ -231,6 +197,7 @@ export function buildFactoryPoolsData(factoryType, rawPoolListInput) {
231
197
  deposit_abi: basePoolZap.ABI,
232
198
  in_api: true,
233
199
  is_ng,
200
+ factory_type: factoryType,
234
201
  };
235
202
  }
236
203
  else {
@@ -255,6 +222,7 @@ export function buildFactoryPoolsData(factoryType, rawPoolListInput) {
255
222
  gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
256
223
  in_api: true,
257
224
  is_ng,
225
+ factory_type: factoryType,
258
226
  };
259
227
  }
260
228
  }
@@ -270,7 +238,7 @@ export function buildFactoryPoolsData(factoryType, rawPoolListInput) {
270
238
  const basePoolIdZapDict = (_g = this.constants.STABLE_FACTORY_CONSTANTS.basePoolIdZapDict) !== null && _g !== void 0 ? _g : {};
271
239
  let deposit_address = (_h = this.constants.STABLE_FACTORY_CONSTANTS.stableNgBasePoolZap) !== null && _h !== void 0 ? _h : this.constants.ZERO_ADDRESS;
272
240
  let deposit_abi = StableNgBasePoolZapABI;
273
- if (isStableNgPool(basePoolId)) {
241
+ if (allPoolsData[basePoolId].is_ng) {
274
242
  this.setContract(deposit_address, StableNgBasePoolZapABI);
275
243
  }
276
244
  else {
@@ -301,6 +269,7 @@ export function buildFactoryPoolsData(factoryType, rawPoolListInput) {
301
269
  deposit_abi,
302
270
  in_api: true,
303
271
  is_ng,
272
+ factory_type: factoryType,
304
273
  };
305
274
  }
306
275
  else {
@@ -325,6 +294,7 @@ export function buildFactoryPoolsData(factoryType, rawPoolListInput) {
325
294
  gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
326
295
  in_api: true,
327
296
  is_ng,
297
+ factory_type: factoryType,
328
298
  };
329
299
  }
330
300
  });
@@ -20,7 +20,7 @@ function getRecentlyCreatedCryptoPoolId(swapAddress) {
20
20
  for (let i = 1; i <= poolCount; i++) {
21
21
  const address = yield factoryContract.pool_list(poolCount - i);
22
22
  if (address.toLowerCase() === swapAddress.toLowerCase())
23
- return `factory-crypto-${poolCount - i}`;
23
+ return address.toLowerCase();
24
24
  }
25
25
  throw Error("Unknown pool");
26
26
  });
@@ -36,7 +36,7 @@ function getCryptoFactoryIdsAndSwapAddresses() {
36
36
  }
37
37
  if (calls.length === 0)
38
38
  return [[], []];
39
- let factories = (yield this.multicallProvider.all(calls)).map((addr, i) => ({ id: `factory-crypto-${fromIdx + i}`, address: addr.toLowerCase() }));
39
+ let factories = (yield this.multicallProvider.all(calls)).map((addr) => ({ id: addr.toLowerCase(), address: addr.toLowerCase() }));
40
40
  const swapAddresses = Object.values(this.constants.POOLS_DATA).map((pool) => pool.swap_address.toLowerCase());
41
41
  factories = factories.filter((f) => !swapAddresses.includes(f.address));
42
42
  return [factories.map((f) => f.id), factories.map((f) => f.address)];
@@ -247,6 +247,7 @@ export function getCryptoFactoryPoolData() {
247
247
  swap_abi: cryptoFactorySwapABI,
248
248
  gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
249
249
  deposit_abi: basePoolZap.ABI,
250
+ factory_type: "factory-crypto",
250
251
  };
251
252
  }
252
253
  else {
@@ -269,6 +270,7 @@ export function getCryptoFactoryPoolData() {
269
270
  wrapped_decimals: [...coinAddresses[i].map((addr) => coinAddressDecimalsDict[addr])],
270
271
  swap_abi: cryptoFactorySwapABI,
271
272
  gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
273
+ factory_type: "factory-crypto",
272
274
  };
273
275
  }
274
276
  }
@@ -20,7 +20,7 @@ function getRecentlyCreatedCryptoPoolId(swapAddress) {
20
20
  for (let i = 1; i <= poolCount; i++) {
21
21
  const address = yield factoryContract.pool_list(poolCount - i);
22
22
  if (address.toLowerCase() === swapAddress.toLowerCase())
23
- return `factory-tricrypto-${poolCount - i}`;
23
+ return address.toLowerCase();
24
24
  }
25
25
  throw Error("Unknown pool");
26
26
  });
@@ -36,7 +36,7 @@ function getCryptoFactoryIdsAndSwapAddresses() {
36
36
  }
37
37
  if (calls.length === 0)
38
38
  return [[], []];
39
- let factories = (yield this.multicallProvider.all(calls)).map((addr, i) => ({ id: `factory-tricrypto-${fromIdx + i}`, address: addr.toLowerCase() }));
39
+ let factories = (yield this.multicallProvider.all(calls)).map((addr) => ({ id: addr.toLowerCase(), address: addr.toLowerCase() }));
40
40
  const swapAddresses = Object.values(this.constants.POOLS_DATA).map((pool) => pool.swap_address.toLowerCase());
41
41
  factories = factories.filter((f) => !swapAddresses.includes(f.address));
42
42
  return [factories.map((f) => f.id), factories.map((f) => f.address)];
@@ -215,6 +215,7 @@ export function getTricryptoFactoryPoolData() {
215
215
  swap_abi: isETHEnabled ? tricryptoFactorySwapABI : tricryptoFactoryEthDisabledSwapABI,
216
216
  gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
217
217
  is_ng: true,
218
+ factory_type: "factory-tricrypto",
218
219
  };
219
220
  }
220
221
  return TRICRYPTO_FACTORY_POOLS_DATA;
@@ -21,7 +21,7 @@ function getRecentlyCreatedCryptoPoolId(swapAddress) {
21
21
  for (let i = 1; i <= poolCount; i++) {
22
22
  const address = yield factoryContract.pool_list(poolCount - i);
23
23
  if (address.toLowerCase() === swapAddress.toLowerCase())
24
- return `factory-twocrypto-${poolCount - i}`;
24
+ return address.toLowerCase();
25
25
  }
26
26
  throw Error("Unknown pool");
27
27
  });
@@ -37,7 +37,7 @@ function getTwocryptoFactoryIdsAndSwapAddresses() {
37
37
  }
38
38
  if (calls.length === 0)
39
39
  return [[], []];
40
- let factories = (yield this.multicallProvider.all(calls)).map((addr, i) => ({ id: `factory-twocrypto-${fromIdx + i}`, address: addr.toLowerCase() }));
40
+ let factories = (yield this.multicallProvider.all(calls)).map((addr) => ({ id: addr.toLowerCase(), address: addr.toLowerCase() }));
41
41
  const swapAddresses = Object.values(this.constants.POOLS_DATA).map((pool) => pool.swap_address.toLowerCase());
42
42
  factories = factories.filter((f) => !swapAddresses.includes(f.address));
43
43
  return [factories.map((f) => f.id), factories.map((f) => f.address)];
@@ -207,6 +207,7 @@ export function getTwocryptoFactoryPoolData() {
207
207
  swap_abi: twocryptoFactorySwapABI,
208
208
  gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
209
209
  is_ng: true,
210
+ factory_type: "factory-twocrypto",
210
211
  };
211
212
  }
212
213
  return TWOCRYPTO_FACTORY_POOLS_DATA;
@@ -15,7 +15,7 @@ import factoryGaugeABI from "../constants/abis/gauge_factory.json" with { type:
15
15
  import gaugeChildABI from "../constants/abis/gauge_child.json" with { type: "json" };
16
16
  import StableNgBasePoolZapABI from "../constants/abis/stable-ng-base-pool-zap.json" with { type: "json" };
17
17
  import { getPoolIdByAddress, setFactoryZapContracts } from "./common.js";
18
- import { getPoolName, isStableNgPool } from "../utils.js";
18
+ import { getPoolName } from "../utils.js";
19
19
  import { formatUnits } from "../constants/utils.js";
20
20
  export const BLACK_LIST = {
21
21
  1: [
@@ -61,12 +61,11 @@ export function getBasePools(factoryAddress, rawSwapAddresses, tmpPools) {
61
61
  function getRecentlyCreatedPoolId(swapAddress, factoryAddress) {
62
62
  return __awaiter(this, void 0, void 0, function* () {
63
63
  const factoryContract = this.contracts[factoryAddress].contract;
64
- const prefix = factoryAddress === this.constants.ALIASES.factory ? 'factory-v2' : 'factory-stable-ng';
65
64
  const poolCount = Number(this.formatUnits(yield factoryContract.pool_count(this.constantOptions), 0));
66
65
  for (let i = 1; i <= poolCount; i++) {
67
66
  const address = yield factoryContract.pool_list(poolCount - i);
68
67
  if (address.toLowerCase() === swapAddress.toLowerCase())
69
- return `${prefix}-${poolCount - i}`;
68
+ return address.toLowerCase();
70
69
  }
71
70
  throw Error("Unknown pool");
72
71
  });
@@ -84,9 +83,7 @@ function getFactoryIdsAndSwapAddresses() {
84
83
  }
85
84
  if (calls.length === 0)
86
85
  return [[], []];
87
- const prefix = factoryAddress === this.constants.ALIASES.factory ? "factory-v2-" :
88
- factoryAddress === this.constants.ALIASES.crvusd_factory ? "factory-crvusd-" : "factory-stable-ng-";
89
- let factories = (yield this.multicallProvider.all(calls)).map((addr, i) => ({ id: prefix + (fromIdx + i), address: addr.toLowerCase() }));
86
+ let factories = (yield this.multicallProvider.all(calls)).map((addr) => ({ id: addr.toLowerCase(), address: addr.toLowerCase() }));
90
87
  const swapAddresses = Object.values(this.constants.POOLS_DATA).map((pool) => pool.swap_address.toLowerCase());
91
88
  const blacklist = (_a = BLACK_LIST[this.chainId]) !== null && _a !== void 0 ? _a : [];
92
89
  factories = factories.filter((f) => !swapAddresses.includes(f.address) && !blacklist.includes(f.address));
@@ -228,13 +225,15 @@ function getCoinsData(coinAddresses, existingCoinAddrNameDict, existingCoinAddrD
228
225
  }
229
226
  export function getFactoryPoolData() {
230
227
  return __awaiter(this, arguments, void 0, function* (fromIdx = 0, swapAddress, factoryAddress = this.constants.ALIASES.factory) {
231
- var _a, _b, _c;
228
+ var _a, _b, _c, _e;
232
229
  const [rawPoolIds, rawSwapAddresses] = swapAddress ?
233
230
  [[yield getRecentlyCreatedPoolId.call(this, swapAddress, factoryAddress)], [swapAddress.toLowerCase()]]
234
231
  : yield getFactoryIdsAndSwapAddresses.call(this, fromIdx, factoryAddress);
235
232
  if (rawPoolIds.length === 0)
236
233
  return {};
237
234
  const is_ng = factoryAddress === this.constants.ALIASES.stable_ng_factory;
235
+ const factory_type = factoryAddress === this.constants.ALIASES.crvusd_factory ? "factory-crvusd" :
236
+ is_ng ? "factory-stable-ng" : "factory";
238
237
  const [rawImplementations, rawGauges, rawOldGauges, rawReferenceAssets, rawPoolSymbols, rawPoolNames, rawIsMeta, rawCoinAddresses] = yield getPoolsData.call(this, rawSwapAddresses, factoryAddress);
239
238
  const poolIds = [];
240
239
  const swapAddresses = [];
@@ -298,6 +297,7 @@ export function getFactoryPoolData() {
298
297
  swap_abi: swapABIs[i],
299
298
  gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
300
299
  is_ng,
300
+ factory_type,
301
301
  };
302
302
  }
303
303
  else {
@@ -309,7 +309,7 @@ export function getFactoryPoolData() {
309
309
  this.constants.BASE_POOLS[basePools.ids[i]] = this.constants.BASE_POOLS[basePools.ids[i]] ? this.constants.BASE_POOLS[basePools.ids[i]] + 1 : 1;
310
310
  let deposit_address = (_c = this.constants.STABLE_FACTORY_CONSTANTS.stableNgBasePoolZap) !== null && _c !== void 0 ? _c : this.constants.ZERO_ADDRESS;
311
311
  let deposit_abi = StableNgBasePoolZapABI;
312
- if (isStableNgPool(basePools.ids[i])) {
312
+ if ((_e = allPoolsData[basePools.ids[i]]) === null || _e === void 0 ? void 0 : _e.is_ng) {
313
313
  this.setContract(deposit_address, StableNgBasePoolZapABI);
314
314
  }
315
315
  else {
@@ -339,6 +339,7 @@ export function getFactoryPoolData() {
339
339
  gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
340
340
  deposit_abi,
341
341
  is_ng,
342
+ factory_type,
342
343
  };
343
344
  }
344
345
  }
@@ -31,6 +31,7 @@ export interface IPoolData {
31
31
  is_factory?: boolean;
32
32
  is_llamma?: boolean;
33
33
  is_ng?: boolean;
34
+ factory_type?: IFactoryPoolType;
34
35
  base_pool?: string;
35
36
  meta_coin_idx?: number;
36
37
  underlying_coins: string[];
package/lib/lite-api.js CHANGED
@@ -66,10 +66,10 @@ const _getApi2PoolsData = memoize((chainId) => __awaiter(void 0, void 0, void 0,
66
66
  promise: true,
67
67
  maxAge: 5 * 60 * 1000,
68
68
  });
69
- const adaptLitePool = (pool, poolType) => {
69
+ const adaptLitePool = (pool) => {
70
70
  var _a, _b, _c, _d, _e, _f, _g;
71
71
  return ({
72
- id: pool.id.replace(pool.registry_id, poolType),
72
+ id: pool.address.toLowerCase(),
73
73
  name: pool.name,
74
74
  symbol: pool.symbol,
75
75
  assetTypeName: null,
@@ -111,7 +111,7 @@ export const getLitePoolsFromApi2 = (network, poolType) => __awaiter(void 0, voi
111
111
  return { poolData: [], tvl: 0, tvlAll: 0 };
112
112
  const { pool_data, tvl } = yield _getApi2PoolsData(chainId);
113
113
  const poolsOfType = (pool_data !== null && pool_data !== void 0 ? pool_data : []).filter((pool) => API2_REGISTRY_TO_POOL_TYPE[pool.registry_id] === poolType);
114
- const poolData = poolsOfType.map((pool) => adaptLitePool(pool, poolType));
114
+ const poolData = poolsOfType.map((pool) => adaptLitePool(pool));
115
115
  return {
116
116
  poolData,
117
117
  tvl: poolData.reduce((sum, p) => sum + p.usdTotal, 0),
@@ -757,7 +757,7 @@ export class PoolTemplate extends CorePool {
757
757
  const multicallContract = this.curve.contracts[this.address].multicallContract;
758
758
  if (this.isCrypto || this.id === 'wsteth') {
759
759
  if (this.curve.isLiteChain) {
760
- const prices = this.id.includes('twocrypto')
760
+ const prices = this.factoryType === 'factory-twocrypto'
761
761
  ? [
762
762
  1,
763
763
  Number(yield this.curve.contracts[this.address].contract.price_oracle()) / (Math.pow(10, 18)),
@@ -1415,7 +1415,7 @@ export class PoolTemplate extends CorePool {
1415
1415
  const multicallContract = this.curve.contracts[this.address].multicallContract;
1416
1416
  if (this.isCrypto || this.id === 'wsteth') {
1417
1417
  if (this.curve.isLiteChain) {
1418
- const prices = this.id.includes('twocrypto')
1418
+ const prices = this.factoryType === 'factory-twocrypto'
1419
1419
  ? [
1420
1420
  1,
1421
1421
  Number(yield this.curve.contracts[this.address].contract.price_oracle()) / (Math.pow(10, 18)),
@@ -1550,7 +1550,7 @@ export class PoolTemplate extends CorePool {
1550
1550
  const multicallContract = this.curve.contracts[this.address].multicallContract;
1551
1551
  if (this.isCrypto || this.id === 'wsteth') {
1552
1552
  if (this.curve.isLiteChain) {
1553
- const prices = this.id.includes('twocrypto')
1553
+ const prices = this.factoryType === 'factory-twocrypto'
1554
1554
  ? [
1555
1555
  1,
1556
1556
  Number(yield this.curve.contracts[this.address].contract.price_oracle()) / (Math.pow(10, 18)),
@@ -1,6 +1,6 @@
1
1
  import { type Curve } from "../../curve.js";
2
2
  import { IGaugePool } from "./gaugePool.js";
3
- import { IPoolData } from "../../interfaces";
3
+ import { IFactoryPoolType, IPoolData } from "../../interfaces";
4
4
  export interface ICorePool {
5
5
  id: string;
6
6
  name: string;
@@ -23,6 +23,7 @@ export interface ICorePool {
23
23
  isMetaFactory: boolean;
24
24
  isNg: boolean;
25
25
  isLlamma: boolean;
26
+ factoryType: IFactoryPoolType | null;
26
27
  basePool: string;
27
28
  metaCoinIdx: number;
28
29
  underlyingCoins: string[];
@@ -57,6 +58,7 @@ export declare class CorePool implements ICorePool {
57
58
  isMetaFactory: boolean;
58
59
  isNg: boolean;
59
60
  isLlamma: boolean;
61
+ factoryType: IFactoryPoolType | null;
60
62
  basePool: string;
61
63
  metaCoinIdx: number;
62
64
  underlyingCoins: string[];
@@ -27,6 +27,7 @@ export class CorePool {
27
27
  this.isMetaFactory = (this.isMeta && this.isFactory) || this.zap === '0xa79828df1850e8a3a3064576f380d90aecdd3359';
28
28
  this.isNg = poolData.is_ng || false;
29
29
  this.isLlamma = poolData.is_llamma || false;
30
+ this.factoryType = poolData.factory_type || null;
30
31
  this.basePool = poolData.base_pool || '';
31
32
  this.metaCoinIdx = this.isMeta ? (_a = poolData.meta_coin_idx) !== null && _a !== void 0 ? _a : poolData.wrapped_coins.length - 1 : -1;
32
33
  this.underlyingCoins = poolData.underlying_coins;
@@ -107,7 +107,7 @@ export class StatsPool {
107
107
  return stablecoinTvlBN.plus(collateralTvlBN).toString();
108
108
  }
109
109
  if (useApi) {
110
- const totalLiquidity = yield _getPoolTotalLiquidityFromApi(curve.constants.NETWORK_NAME, this.pool.id, this.pool.address, this.pool.isCrypto, curve.isLiteChain);
110
+ const totalLiquidity = yield _getPoolTotalLiquidityFromApi(curve.constants.NETWORK_NAME, this.pool.address, curve.isLiteChain);
111
111
  if (totalLiquidity !== undefined)
112
112
  return totalLiquidity;
113
113
  }
package/lib/prices-api.js CHANGED
@@ -28,16 +28,6 @@ export const PRICES_POOL_TYPE_TO_LEGACY = {
28
28
  stableswapng: "factory-stable-ng",
29
29
  twocryptong: "factory-twocrypto",
30
30
  };
31
- const ID_PREFIX_BY_POOL_TYPE = {
32
- "main": "main",
33
- "crypto": "crypto",
34
- "factory": "factory-v2",
35
- "factory-crvusd": "factory-crvusd",
36
- "factory-crypto": "factory-crypto",
37
- "factory-twocrypto": "factory-twocrypto",
38
- "factory-tricrypto": "factory-tricrypto",
39
- "factory-stable-ng": "factory-stable-ng",
40
- };
41
31
  function fetchJson(url) {
42
32
  return __awaiter(this, void 0, void 0, function* () {
43
33
  var _a;
@@ -67,12 +57,11 @@ export const getGaugesOverview = () => __awaiter(void 0, void 0, void 0, functio
67
57
  const { gauges } = yield _getGaugesOverview();
68
58
  return gauges !== null && gauges !== void 0 ? gauges : [];
69
59
  });
70
- const getPoolId = (poolType, indexWithinType) => `${ID_PREFIX_BY_POOL_TYPE[poolType]}-${indexWithinType}`;
71
- const adaptPoolFromPricesApi = (pool, id, gaugeAddressByPoolAddress) => {
60
+ const adaptPoolFromPricesApi = (pool, gaugeAddressByPoolAddress) => {
72
61
  var _a, _b, _c, _d, _e;
73
62
  const coins = [...pool.coins].sort((a, b) => a.pool_index - b.pool_index).slice(0, pool.n_coins);
74
63
  return {
75
- id,
64
+ id: pool.address.toLowerCase(),
76
65
  name: pool.name,
77
66
  symbol: (_a = pool.lp_token_symbol) !== null && _a !== void 0 ? _a : pool.name,
78
67
  assetTypeName: null,
@@ -113,7 +102,7 @@ export const getPoolsFromPricesApi = (network, poolType) => __awaiter(void 0, vo
113
102
  const poolsOfType = chainData.data
114
103
  .filter((pool) => PRICES_POOL_TYPE_TO_LEGACY[pool.pool_type] === poolType)
115
104
  .sort((a, b) => a.creation_block_number - b.creation_block_number);
116
- const poolData = poolsOfType.map((pool, i) => adaptPoolFromPricesApi(pool, getPoolId(poolType, i), gaugeAddressByPoolAddress));
105
+ const poolData = poolsOfType.map((pool) => adaptPoolFromPricesApi(pool, gaugeAddressByPoolAddress));
117
106
  return {
118
107
  poolData,
119
108
  tvl: poolData.reduce((sum, p) => sum + p.usdTotal, 0),
package/lib/router.js CHANGED
@@ -27,10 +27,10 @@ export function setRouterBlacklist(blacklist) {
27
27
  delete this._getBestRoute;
28
28
  }
29
29
  function _getTVL(poolId_1, _a) {
30
- return __awaiter(this, arguments, void 0, function* (poolId, { is_crypto, is_llamma, swap_address }) {
30
+ return __awaiter(this, arguments, void 0, function* (poolId, { is_llamma, swap_address }) {
31
31
  // LLAMMA liquidity must be calculated on-chain, even when the API has an entry.
32
32
  if (!is_llamma) {
33
- const totalLiquidity = yield _getPoolTotalLiquidityFromApi(this.constants.NETWORK_NAME, poolId, swap_address, is_crypto !== null && is_crypto !== void 0 ? is_crypto : false, this.isLiteChain);
33
+ const totalLiquidity = yield _getPoolTotalLiquidityFromApi(this.constants.NETWORK_NAME, swap_address, this.isLiteChain);
34
34
  if (totalLiquidity !== undefined)
35
35
  return Number(totalLiquidity);
36
36
  }
package/lib/utils.d.ts CHANGED
@@ -102,7 +102,6 @@ export declare const findAbiFunction: (abi: Abi, methodName: string) => AbiFunct
102
102
  export declare const getCountArgsOfMethodByAbi: (abi: Abi, methodName: string) => number;
103
103
  export declare const findAbiSignature: (abi: Abi, methodName: string, signature: string) => AbiFunction | undefined;
104
104
  export declare const getPoolName: (name: string) => string;
105
- export declare const isStableNgPool: (name: string) => boolean;
106
105
  export declare const assetTypeNameHandler: (assetTypeName: string | null) => REFERENCE_ASSET;
107
106
  export declare function getBasePools(this: Curve): Promise<IBasePoolShortItem[]>;
108
107
  export declare function log(fnName: string, ...args: unknown[]): void;
package/lib/utils.js CHANGED
@@ -779,7 +779,6 @@ export const getPoolName = (name) => {
779
779
  return separatedName[0].trim();
780
780
  }
781
781
  };
782
- export const isStableNgPool = (name) => name.includes('factory-stable-ng');
783
782
  export const assetTypeNameHandler = (assetTypeName) => {
784
783
  if (!assetTypeName || assetTypeName.toUpperCase() === 'UNKNOWN') {
785
784
  return 'OTHER';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.71.0",
3
+ "version": "2.71.1",
4
4
  "description": "JavaScript library for curve.finance",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",