@1delta/margin-fetcher 0.0.310 → 0.0.311

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
@@ -11276,6 +11276,7 @@ var MORPHO_LENS = {
11276
11276
  [Chain.PLUME_MAINNET]: "0x8E24CfC19c6C00c524353CB8816f5f1c2F33c201",
11277
11277
  [Chain.FLARE_MAINNET]: "0x8E24CfC19c6C00c524353CB8816f5f1c2F33c201",
11278
11278
  [Chain.PHAROS_MAINNET]: "0x8E24CfC19c6C00c524353CB8816f5f1c2F33c201",
11279
+ [Chain.ROBINHOOD_CHAIN]: "0x8E24CfC19c6C00c524353CB8816f5f1c2F33c201",
11279
11280
  [Chain.STABLE_MAINNET]: "0x8E24CfC19c6C00c524353CB8816f5f1c2F33c201",
11280
11281
  [Chain.CORN]: "0x8E24CfC19c6C00c524353CB8816f5f1c2F33c201",
11281
11282
  [Chain.LISK]: "0x8E24CfC19c6C00c524353CB8816f5f1c2F33c201",
@@ -45590,6 +45591,15 @@ var Erc4626ConvertAbi = [
45590
45591
  outputs: [{ type: "uint256", name: "assets" }]
45591
45592
  }
45592
45593
  ];
45594
+ var Erc4626TotalAssetsAbi = [
45595
+ {
45596
+ name: "totalAssets",
45597
+ type: "function",
45598
+ stateMutability: "view",
45599
+ inputs: [],
45600
+ outputs: [{ type: "uint256" }]
45601
+ }
45602
+ ];
45593
45603
 
45594
45604
  // src/vaults/aave-earn/api.ts
45595
45605
  var AAVE_EARN_API_URL = "https://api.v3.aave.com/graphql";
@@ -45742,16 +45752,19 @@ var fetchAaveEarnVaults = async (chainId, multicallRetry, prices = {}, tokenList
45742
45752
  (v) => !!v?.address && !!v?.usedReserve?.underlyingToken?.address && v.usedReserve.underlyingToken.decimals != null
45743
45753
  );
45744
45754
  if (usable.length === 0) return {};
45755
+ const CALLS_PER_VAULT2 = 4;
45745
45756
  const calls = usable.flatMap((v) => {
45746
45757
  const underlyingDec = v.usedReserve.underlyingToken.decimals;
45747
45758
  const shareUnit = 10n ** BigInt(underlyingDec);
45748
45759
  return [
45760
+ { address: v.address, name: "totalAssets", params: [] },
45749
45761
  { address: v.address, name: "decimals", params: [] },
45750
45762
  { address: v.address, name: "totalSupply", params: [] },
45751
45763
  { address: v.address, name: "convertToAssets", params: [shareUnit] }
45752
45764
  ];
45753
45765
  });
45754
45766
  const abis = usable.flatMap(() => [
45767
+ Erc4626TotalAssetsAbi,
45755
45768
  Erc20MetaAbi,
45756
45769
  Erc20MetaAbi,
45757
45770
  Erc4626ConvertAbi
@@ -45764,25 +45777,25 @@ var fetchAaveEarnVaults = async (chainId, multicallRetry, prices = {}, tokenList
45764
45777
  const out = {};
45765
45778
  for (let i = 0; i < usable.length; i++) {
45766
45779
  const v = usable[i];
45767
- const slice = rawResults.slice(i * 3, i * 3 + 3);
45780
+ const base = i * CALLS_PER_VAULT2;
45781
+ const slice = rawResults.slice(base, base + CALLS_PER_VAULT2);
45768
45782
  const addressLc = v.address.toLowerCase();
45769
45783
  const token = v.usedReserve.underlyingToken;
45770
45784
  const underlyingLc = token.address.toLowerCase();
45771
45785
  const assetDecimals = token.decimals;
45772
- const shareDecOnChain = toBigInt13(slice[0]);
45786
+ const shareDecOnChain = toBigInt13(slice[1]);
45773
45787
  const decimals = shareDecOnChain !== void 0 ? Number(shareDecOnChain) : assetDecimals;
45774
- const totalSupply = toBigInt13(slice[1]);
45788
+ const totalSupply = toBigInt13(slice[2]);
45775
45789
  if (totalSupply === void 0) continue;
45776
45790
  const shareUnit = 10n ** BigInt(decimals);
45777
45791
  const underlyingUnit = 10n ** BigInt(assetDecimals);
45778
- const convertToAssets = toBigInt13(slice[2]) ?? 0n;
45792
+ const convertToAssets = toBigInt13(slice[3]) ?? 0n;
45779
45793
  const convertToShares = convertToAssets > 0n ? shareUnit * underlyingUnit / convertToAssets : 0n;
45780
- const totalAssetsRaw = v.balance?.amount?.raw ?? "0";
45781
- const totalAssets = toBigInt13(totalAssetsRaw) ?? 0n;
45794
+ const totalAssets = toBigInt13(slice[0]) ?? totalSupply * convertToAssets / shareUnit;
45782
45795
  const totalAssetsFormatted = Number(totalAssets) / 10 ** assetDecimals;
45783
45796
  const asset = tokenList[underlyingLc];
45784
45797
  const priceUsd = prices[underlyingLc] ?? (v.balance?.usdPerToken != null ? num2(v.balance.usdPerToken) : void 0);
45785
- const totalAssetsUsd = v.balance?.usd != null ? num2(v.balance.usd) : priceUsd !== void 0 ? totalAssetsFormatted * priceUsd : 0;
45798
+ const totalAssetsUsd = priceUsd !== void 0 ? totalAssetsFormatted * priceUsd : 0;
45786
45799
  const supplyRate = num2(v.vaultApr?.formatted);
45787
45800
  const rewardsRate = 0;
45788
45801
  const depositRate = supplyRate + rewardsRate;
@@ -46476,7 +46489,11 @@ var stampVaultClassification = (data, chainId, tokenList = {}) => {
46476
46489
  const longLogo = v.longToken != null ? tokenList[v.longToken.toLowerCase()]?.logoURI : void 0;
46477
46490
  const icon = v.shareAsset?.logoURI ?? v.asset?.logoURI ?? longLogo;
46478
46491
  if (icon) v.logoURI = icon;
46479
- if (!classify) continue;
46492
+ if (!classify) {
46493
+ if (v.priceUsd != null && Number.isFinite(v.priceUsd))
46494
+ v.sharePriceUSD = v.priceUsd;
46495
+ continue;
46496
+ }
46480
46497
  const c = classifyVault({
46481
46498
  provider,
46482
46499
  chainId,