@curvefi/llamalend-api 1.0.38 → 1.0.39
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/utils.js +4 -4
- package/package.json +1 -1
- package/src/utils.ts +4 -3
package/lib/utils.js
CHANGED
|
@@ -333,13 +333,13 @@ export const _getUsdRate = function (assetId) {
|
|
|
333
333
|
const url = [nativeTokenName, 'ethereum', 'bitcoin', 'link', 'curve-dao-token', 'stasis-eurs'].includes(assetId.toLowerCase()) ?
|
|
334
334
|
`https://api.coingecko.com/api/v3/simple/price?ids=${assetId}&vs_currencies=usd` :
|
|
335
335
|
`https://api.coingecko.com/api/v3/simple/token_price/${chainName}?contract_addresses=${assetId}&vs_currencies=usd`;
|
|
336
|
-
const response = yield fetch(url);
|
|
337
|
-
const data = yield response.json();
|
|
338
336
|
try {
|
|
337
|
+
const response = yield fetch(url);
|
|
338
|
+
const data = yield response.json();
|
|
339
339
|
_usdRatesCache[assetId] = { 'rate': (_c = data[assetId]['usd']) !== null && _c !== void 0 ? _c : 0, 'time': Date.now() };
|
|
340
340
|
}
|
|
341
|
-
catch (
|
|
342
|
-
|
|
341
|
+
catch (_d) {
|
|
342
|
+
// coingecko often fails due to 429 (rate limit) errors, due to missing CORS headers we get no details
|
|
343
343
|
_usdRatesCache[assetId] = { 'rate': 0, 'time': Date.now() };
|
|
344
344
|
}
|
|
345
345
|
}
|
package/package.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -361,11 +361,12 @@ export const _getUsdRate = async function (this: Llamalend, assetId: string): Pr
|
|
|
361
361
|
const url = [nativeTokenName, 'ethereum', 'bitcoin', 'link', 'curve-dao-token', 'stasis-eurs'].includes(assetId.toLowerCase()) ?
|
|
362
362
|
`https://api.coingecko.com/api/v3/simple/price?ids=${assetId}&vs_currencies=usd` :
|
|
363
363
|
`https://api.coingecko.com/api/v3/simple/token_price/${chainName}?contract_addresses=${assetId}&vs_currencies=usd`
|
|
364
|
-
const response = await fetch(url);
|
|
365
|
-
const data = await response.json() as Record<string, { usd: number }>;
|
|
366
364
|
try {
|
|
365
|
+
const response = await fetch(url);
|
|
366
|
+
const data = await response.json() as Record<string, { usd: number }>;
|
|
367
367
|
_usdRatesCache[assetId] = {'rate': data[assetId]['usd'] ?? 0, 'time': Date.now()};
|
|
368
|
-
} catch {
|
|
368
|
+
} catch {
|
|
369
|
+
// coingecko often fails due to 429 (rate limit) errors, due to missing CORS headers we get no details
|
|
369
370
|
_usdRatesCache[assetId] = {'rate': 0, 'time': Date.now()};
|
|
370
371
|
}
|
|
371
372
|
}
|