@1delta/margin-fetcher 0.0.310 → 0.0.312

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",
@@ -32032,6 +32033,7 @@ var usdaiFetcher = {
32032
32033
  var MAPLE_URL = "https://api.maple.finance/v2/graphql";
32033
32034
  var SYRUP_USDT_ID = "0x356b8d89c1e1239cbbb9de4815c39a1474d5ba7d";
32034
32035
  var SYRUP_USDC_ID = "0x80ac24aa929eaf5013f6436cda2a7ba190f5cc0b";
32036
+ var SYRUP_USDG_ID = "0x87b65c4aaffa76881f9e96f3e7ed945ddfc3cd7a";
32035
32037
  var mapleFetcher = {
32036
32038
  label: "MAPLE",
32037
32039
  fetch: async () => {
@@ -32057,10 +32059,12 @@ var mapleFetcher = {
32057
32059
  const pools = res.data.poolV2S;
32058
32060
  const usdtPool = pools.find((p) => p.id === SYRUP_USDT_ID);
32059
32061
  const usdcPool = pools.find((p) => p.id === SYRUP_USDC_ID);
32062
+ const usdgPool = pools.find((p) => p.id === SYRUP_USDG_ID);
32060
32063
  const parseApy = (raw) => Number(raw) / 1e28;
32061
32064
  return {
32062
32065
  SYRUPUSDT: apyToAprPercent(parseApy(usdtPool.weeklyApy)),
32063
- SYRUPUSDC: apyToAprPercent(parseApy(usdcPool.weeklyApy))
32066
+ SYRUPUSDC: apyToAprPercent(parseApy(usdcPool.weeklyApy)),
32067
+ SYRUPUSDG: apyToAprPercent(parseApy(usdgPool.weeklyApy))
32064
32068
  };
32065
32069
  }
32066
32070
  };
@@ -45182,6 +45186,20 @@ var SINGLE_CHAIN_ENTRIES = {
45182
45186
  yieldFetcher: mapleFetcher,
45183
45187
  yieldKey: "SYRUPUSDT"
45184
45188
  },
45189
+ {
45190
+ address: "0x87b65c4aaffa76881f9e96f3e7ed945ddfc3cd7a",
45191
+ underlying: "0xe343167631d89b6ffc58b88d6b7fb0228795491d",
45192
+ // USDG
45193
+ symbol: "syrupUSDG",
45194
+ brand: "Maple",
45195
+ decimals: 6,
45196
+ isRebasing: false,
45197
+ isMintable: true,
45198
+ withdrawalMode: "request-based",
45199
+ withdrawalCooldownSeconds: 604800,
45200
+ yieldFetcher: mapleFetcher,
45201
+ yieldKey: "SYRUPUSDG"
45202
+ },
45185
45203
  {
45186
45204
  // Hastra Democratized PRIME — ERC-4626 over wYLDS (itself ERC-4626 over
45187
45205
  // USDC), so the share/asset ratio accrues on-chain (`convertToAssets`).
@@ -45590,6 +45608,15 @@ var Erc4626ConvertAbi = [
45590
45608
  outputs: [{ type: "uint256", name: "assets" }]
45591
45609
  }
45592
45610
  ];
45611
+ var Erc4626TotalAssetsAbi = [
45612
+ {
45613
+ name: "totalAssets",
45614
+ type: "function",
45615
+ stateMutability: "view",
45616
+ inputs: [],
45617
+ outputs: [{ type: "uint256" }]
45618
+ }
45619
+ ];
45593
45620
 
45594
45621
  // src/vaults/aave-earn/api.ts
45595
45622
  var AAVE_EARN_API_URL = "https://api.v3.aave.com/graphql";
@@ -45742,16 +45769,19 @@ var fetchAaveEarnVaults = async (chainId, multicallRetry, prices = {}, tokenList
45742
45769
  (v) => !!v?.address && !!v?.usedReserve?.underlyingToken?.address && v.usedReserve.underlyingToken.decimals != null
45743
45770
  );
45744
45771
  if (usable.length === 0) return {};
45772
+ const CALLS_PER_VAULT2 = 4;
45745
45773
  const calls = usable.flatMap((v) => {
45746
45774
  const underlyingDec = v.usedReserve.underlyingToken.decimals;
45747
45775
  const shareUnit = 10n ** BigInt(underlyingDec);
45748
45776
  return [
45777
+ { address: v.address, name: "totalAssets", params: [] },
45749
45778
  { address: v.address, name: "decimals", params: [] },
45750
45779
  { address: v.address, name: "totalSupply", params: [] },
45751
45780
  { address: v.address, name: "convertToAssets", params: [shareUnit] }
45752
45781
  ];
45753
45782
  });
45754
45783
  const abis = usable.flatMap(() => [
45784
+ Erc4626TotalAssetsAbi,
45755
45785
  Erc20MetaAbi,
45756
45786
  Erc20MetaAbi,
45757
45787
  Erc4626ConvertAbi
@@ -45764,39 +45794,36 @@ var fetchAaveEarnVaults = async (chainId, multicallRetry, prices = {}, tokenList
45764
45794
  const out = {};
45765
45795
  for (let i = 0; i < usable.length; i++) {
45766
45796
  const v = usable[i];
45767
- const slice = rawResults.slice(i * 3, i * 3 + 3);
45797
+ const base = i * CALLS_PER_VAULT2;
45798
+ const slice = rawResults.slice(base, base + CALLS_PER_VAULT2);
45768
45799
  const addressLc = v.address.toLowerCase();
45769
45800
  const token = v.usedReserve.underlyingToken;
45770
45801
  const underlyingLc = token.address.toLowerCase();
45771
45802
  const assetDecimals = token.decimals;
45772
- const shareDecOnChain = toBigInt13(slice[0]);
45803
+ const shareDecOnChain = toBigInt13(slice[1]);
45773
45804
  const decimals = shareDecOnChain !== void 0 ? Number(shareDecOnChain) : assetDecimals;
45774
- const totalSupply = toBigInt13(slice[1]);
45805
+ const totalSupply = toBigInt13(slice[2]);
45775
45806
  if (totalSupply === void 0) continue;
45776
45807
  const shareUnit = 10n ** BigInt(decimals);
45777
45808
  const underlyingUnit = 10n ** BigInt(assetDecimals);
45778
- const convertToAssets = toBigInt13(slice[2]) ?? 0n;
45809
+ const convertToAssets = toBigInt13(slice[3]) ?? 0n;
45779
45810
  const convertToShares = convertToAssets > 0n ? shareUnit * underlyingUnit / convertToAssets : 0n;
45780
- const totalAssetsRaw = v.balance?.amount?.raw ?? "0";
45781
- const totalAssets = toBigInt13(totalAssetsRaw) ?? 0n;
45811
+ const totalAssets = toBigInt13(slice[0]) ?? totalSupply * convertToAssets / shareUnit;
45782
45812
  const totalAssetsFormatted = Number(totalAssets) / 10 ** assetDecimals;
45783
45813
  const asset = tokenList[underlyingLc];
45784
45814
  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;
45815
+ const totalAssetsUsd = priceUsd !== void 0 ? totalAssetsFormatted * priceUsd : 0;
45786
45816
  const supplyRate = num2(v.vaultApr?.formatted);
45787
45817
  const rewardsRate = 0;
45788
45818
  const depositRate = supplyRate + rewardsRate;
45789
45819
  const fee = num2(v.fee?.value);
45790
45820
  const symbol = (v.shareSymbol ?? "").trim();
45791
- const name = (v.shareName ?? "").trim() || symbol;
45821
+ const shareName = (v.shareName ?? "").trim();
45822
+ const name = shareName || symbol;
45823
+ const assetForName = asset ?? (token.symbol ? {
45824
+ symbol: token.symbol} : void 0);
45792
45825
  const curatorName = resolveAaveEarnCuratorName(chainId, v.owner);
45793
- const displayName = composeVaultDisplayName(
45794
- BRAND2,
45795
- curatorName,
45796
- asset ?? (token.symbol ? {
45797
- symbol: token.symbol} : void 0),
45798
- name
45799
- );
45826
+ const displayName = curatorName ? composeVaultDisplayName(BRAND2, curatorName, assetForName, name) : shareName || composeVaultDisplayName(BRAND2, void 0, assetForName, symbol);
45800
45827
  out[addressLc] = {
45801
45828
  address: addressLc,
45802
45829
  underlying: underlyingLc,
@@ -46476,7 +46503,11 @@ var stampVaultClassification = (data, chainId, tokenList = {}) => {
46476
46503
  const longLogo = v.longToken != null ? tokenList[v.longToken.toLowerCase()]?.logoURI : void 0;
46477
46504
  const icon = v.shareAsset?.logoURI ?? v.asset?.logoURI ?? longLogo;
46478
46505
  if (icon) v.logoURI = icon;
46479
- if (!classify) continue;
46506
+ if (!classify) {
46507
+ if (v.priceUsd != null && Number.isFinite(v.priceUsd))
46508
+ v.sharePriceUSD = v.priceUsd;
46509
+ continue;
46510
+ }
46480
46511
  const c = classifyVault({
46481
46512
  provider,
46482
46513
  chainId,