@curvefi/api 2.65.22 → 2.65.24

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 (2) hide show
  1. package/lib/utils.js +10 -5
  2. package/package.json +1 -1
package/lib/utils.js CHANGED
@@ -366,7 +366,7 @@ export const _getRewardsFromApi = () => __awaiter(void 0, void 0, void 0, functi
366
366
  });
367
367
  const _usdRatesCache = {};
368
368
  export const _getUsdRate = (assetId) => __awaiter(void 0, void 0, void 0, function* () {
369
- var _f, _g, _h, _j, _k;
369
+ var _f, _g, _h, _j, _k, _l, _m, _o;
370
370
  if (curve.chainId === 1 && assetId.toLowerCase() === '0x8762db106b2c2a0bccb3a80d1ed41273552616e8')
371
371
  return 0; // RSR
372
372
  const pricesFromApi = yield _getUsdPricesFromApi();
@@ -416,7 +416,12 @@ export const _getUsdRate = (assetId) => __awaiter(void 0, void 0, void 0, functi
416
416
  throw Error('curve object is not initialized');
417
417
  }
418
418
  if (nativeTokenName === undefined) {
419
- throw Error('nativeTokenName not found');
419
+ if (curve.isLiteChain && ((_h = curve.constants.API_CONSTANTS) === null || _h === void 0 ? void 0 : _h.wrappedNativeTokenAddress.toLowerCase()) && ((_j = curve.constants.API_CONSTANTS) === null || _j === void 0 ? void 0 : _j.wrappedNativeTokenAddress.toLowerCase()) in pricesFromApi) {
420
+ return pricesFromApi[(_k = curve.constants.API_CONSTANTS) === null || _k === void 0 ? void 0 : _k.wrappedNativeTokenAddress.toLowerCase()];
421
+ }
422
+ else {
423
+ throw Error('nativeTokenName not found');
424
+ }
420
425
  }
421
426
  assetId = {
422
427
  'CRV': 'curve-dao-token',
@@ -435,10 +440,10 @@ export const _getUsdRate = (assetId) => __awaiter(void 0, void 0, void 0, functi
435
440
  if (assetId.toLowerCase() === curve.constants.ALIASES.crv) {
436
441
  assetId = 'curve-dao-token';
437
442
  }
438
- if (curve.isLiteChain && assetId.toLowerCase() === ((_h = curve.constants.API_CONSTANTS) === null || _h === void 0 ? void 0 : _h.wrappedNativeTokenAddress.toLowerCase())) {
443
+ if (curve.isLiteChain && assetId.toLowerCase() === ((_l = curve.constants.API_CONSTANTS) === null || _l === void 0 ? void 0 : _l.wrappedNativeTokenAddress.toLowerCase())) {
439
444
  assetId = nativeTokenName;
440
445
  }
441
- if ((((_j = _usdRatesCache[assetId]) === null || _j === void 0 ? void 0 : _j.time) || 0) + 600000 < Date.now()) {
446
+ if ((((_m = _usdRatesCache[assetId]) === null || _m === void 0 ? void 0 : _m.time) || 0) + 600000 < Date.now()) {
442
447
  const url = [nativeTokenName, 'ethereum', 'bitcoin', 'link', 'curve-dao-token', 'stasis-eurs'].includes(assetId.toLowerCase()) ?
443
448
  `https://api.coingecko.com/api/v3/simple/price?ids=${assetId}&vs_currencies=usd` :
444
449
  `https://api.coingecko.com/api/v3/simple/token_price/${chainName}?contract_addresses=${assetId}&vs_currencies=usd`;
@@ -446,7 +451,7 @@ export const _getUsdRate = (assetId) => __awaiter(void 0, void 0, void 0, functi
446
451
  const response = yield axios.get(url, {
447
452
  validateStatus: (status) => status < 500,
448
453
  });
449
- if (response.status === 200 && ((_k = response.data[assetId]) === null || _k === void 0 ? void 0 : _k.usd) !== undefined) {
454
+ if (response.status === 200 && ((_o = response.data[assetId]) === null || _o === void 0 ? void 0 : _o.usd) !== undefined) {
450
455
  _usdRatesCache[assetId] = {
451
456
  'rate': response.data[assetId].usd,
452
457
  'time': Date.now(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.65.22",
3
+ "version": "2.65.24",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",