@1delta/margin-fetcher 0.0.312 → 0.0.313

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/dist/index.js CHANGED
@@ -38372,15 +38372,15 @@ async function getJson(url) {
38372
38372
  clearTimeout(timer);
38373
38373
  }
38374
38374
  }
38375
- function mapApiDetail(d, chainId, prices, tokenList) {
38375
+ function mapApiDetail(d, chainId, prices, tokenList, shareDecimalsByVault) {
38376
38376
  const address = (d.address ?? "").toLowerCase();
38377
38377
  const underlying = (d.asset?.address ?? "").toLowerCase();
38378
38378
  if (!address || !underlying) return null;
38379
38379
  const assetMeta = tokenList[underlying];
38380
- const decimals = Number(d.decimals ?? d.asset?.decimals ?? 18);
38381
38380
  const assetDecimals = Number(
38382
- d.asset?.decimals ?? assetMeta?.decimals ?? decimals
38381
+ d.asset?.decimals ?? assetMeta?.decimals ?? 18
38383
38382
  );
38383
+ const decimals = shareDecimalsByVault.get(address) ?? assetDecimals;
38384
38384
  const totalAssetsRaw = String(d.totalAssets ?? "0");
38385
38385
  const totalSupplyRaw = String(d.totalShares ?? "0");
38386
38386
  const convertToAssets = d.exchangeRate != null ? rescaleExchangeRate(d.exchangeRate, decimals) : deriveConvertToAssets(totalAssetsRaw, totalSupplyRaw, decimals);
@@ -38447,7 +38447,7 @@ async function mapWithConcurrency(items, limit, fn) {
38447
38447
  );
38448
38448
  return out;
38449
38449
  }
38450
- async function fetchEulerEarnVaultsFromApi(chainId, prices = {}, tokenList = {}) {
38450
+ async function fetchEulerEarnVaultsFromApi(chainId, prices = {}, tokenList = {}, multicallRetry) {
38451
38451
  const list = await getJson(
38452
38452
  `${EULER_DATA_API_BASE2}/earn/vaults?chainId=${chainId}&limit=200`
38453
38453
  );
@@ -38461,10 +38461,16 @@ async function fetchEulerEarnVaultsFromApi(chainId, prices = {}, tokenList = {})
38461
38461
  `${EULER_DATA_API_BASE2}/earn/vaults/${chainId}/${row.address}?include=strategies`
38462
38462
  ).then((d) => d?.data)
38463
38463
  );
38464
+ const vaultAddrs = details.map((d) => d?.address).filter((a) => !!a);
38465
+ const shareDecimalsByVault = await fetchShareDecimals(
38466
+ chainId,
38467
+ vaultAddrs,
38468
+ multicallRetry
38469
+ );
38464
38470
  const out = {};
38465
38471
  for (const d of details) {
38466
38472
  if (!d) continue;
38467
- const v = mapApiDetail(d, chainId, prices, tokenList);
38473
+ const v = mapApiDetail(d, chainId, prices, tokenList, shareDecimalsByVault);
38468
38474
  if (v) out[v.address] = v;
38469
38475
  }
38470
38476
  return out;
@@ -38476,7 +38482,8 @@ var fetchEulerEarnVaults = async (chainId, prices = {}, tokenList = {}, multical
38476
38482
  const fromApi = await fetchEulerEarnVaultsFromApi(
38477
38483
  chainId,
38478
38484
  prices,
38479
- tokenList
38485
+ tokenList,
38486
+ multicallRetry
38480
38487
  ).catch(() => void 0);
38481
38488
  if (isNonEmpty(fromApi)) return fromApi;
38482
38489
  const subgraphUrl = getEulerEarnSubgraphUrl(chainId);