@curvefi/api 2.65.7 → 2.65.8

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.
@@ -223,6 +223,7 @@ export const _getLiteNetworksData = memoize((networkName) => __awaiter(void 0, v
223
223
  },
224
224
  API_CONSTANTS: {
225
225
  nativeTokenName: config.native_currency_coingecko_id,
226
+ wrappedNativeTokenAddress: config.wrapped_native_token,
226
227
  },
227
228
  };
228
229
  }
@@ -89,6 +89,7 @@ export interface INetworkConstants {
89
89
  ZERO_ADDRESS: string;
90
90
  API_CONSTANTS?: {
91
91
  nativeTokenName: string;
92
+ wrappedNativeTokenAddress: string;
92
93
  };
93
94
  }
94
95
  export interface ICurve {
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;
369
+ var _f, _g, _h, _j, _k;
370
370
  if (curve.chainId === 1 && assetId.toLowerCase() === '0x8762db106b2c2a0bccb3a80d1ed41273552616e8')
371
371
  return 0; // RSR
372
372
  const pricesFromApi = yield _getUsdPricesFromApi();
@@ -435,13 +435,16 @@ export const _getUsdRate = (assetId) => __awaiter(void 0, void 0, void 0, functi
435
435
  if (assetId.toLowerCase() === curve.constants.ALIASES.crv) {
436
436
  assetId = 'curve-dao-token';
437
437
  }
438
- if ((((_h = _usdRatesCache[assetId]) === null || _h === void 0 ? void 0 : _h.time) || 0) + 600000 < Date.now()) {
438
+ if (curve.isLiteChain && assetId.toLowerCase() === ((_h = curve.constants.API_CONSTANTS) === null || _h === void 0 ? void 0 : _h.wrappedNativeTokenAddress.toLowerCase())) {
439
+ assetId = nativeTokenName;
440
+ }
441
+ if ((((_j = _usdRatesCache[assetId]) === null || _j === void 0 ? void 0 : _j.time) || 0) + 600000 < Date.now()) {
439
442
  const url = [nativeTokenName, 'ethereum', 'bitcoin', 'link', 'curve-dao-token', 'stasis-eurs'].includes(assetId.toLowerCase()) ?
440
443
  `https://api.coingecko.com/api/v3/simple/price?ids=${assetId}&vs_currencies=usd` :
441
444
  `https://api.coingecko.com/api/v3/simple/token_price/${chainName}?contract_addresses=${assetId}&vs_currencies=usd`;
442
445
  const response = yield axios.get(url);
443
446
  try {
444
- _usdRatesCache[assetId] = { 'rate': (_j = response.data[assetId]['usd']) !== null && _j !== void 0 ? _j : 0, 'time': Date.now() };
447
+ _usdRatesCache[assetId] = { 'rate': (_k = response.data[assetId]['usd']) !== null && _k !== void 0 ? _k : 0, 'time': Date.now() };
445
448
  }
446
449
  catch (err) { // TODO pay attention!
447
450
  _usdRatesCache[assetId] = { 'rate': 0, 'time': Date.now() };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.65.7",
3
+ "version": "2.65.8",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",