@1delta/margin-fetcher 5.0.99 → 5.0.101

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.d.ts CHANGED
@@ -12275,8 +12275,15 @@ declare const fetchSiloVaults: (chainId: string, prices?: {
12275
12275
  * read each earn vault's real `decimals()` on-chain
12276
12276
  * (the Data API's `decimals` field is unreliable)
12277
12277
  *
12278
- * @returns `EulerEarnVaults` keyed by lowercased vault address — `{}` when
12279
- * neither source returns data.
12278
+ * @returns `EulerEarnVaults` keyed by lowercased vault address — `{}` only
12279
+ * when a source ANSWERED with zero vaults. When every source
12280
+ * FAILED (API request error / chain unsupported, subgraph gone),
12281
+ * this throws so the dispatcher records it in `result.failed`
12282
+ * instead of serving a silent empty. Sonic (146) froze for 80
12283
+ * days exactly this way: the Data API 404s the chain, the Goldsky
12284
+ * subgraph was deleted, both failures were swallowed into `{}`,
12285
+ * and the cron logged "providers ok" while stale rows sat in
12286
+ * `vaults_latest` untouched.
12280
12287
  */
12281
12288
  declare const fetchEulerEarnVaults: (chainId: string, prices?: {
12282
12289
  [asset: string]: number;
package/dist/index.js CHANGED
@@ -7186,10 +7186,7 @@ var calculateRateForCompoundType = (n, chainId, scale3 = 1 /* SECOND */, unitSec
7186
7186
  const perUnit = unitSeconds && unitSeconds > 0 ? unitSeconds : scale3 === 0 /* BLOCK */ ? Number(BLOCK_TIMES[chainId] ?? 1) : 1;
7187
7187
  return (Math.pow(rate * 60 * 60 * 24 / perUnit + 1, 365) - 1) * 100;
7188
7188
  };
7189
- var formatAaveRawApyToApr = (raw) => {
7190
- const apy = formatAaveYieldToNumber(raw);
7191
- return apyToApr(apy / 100) * 100;
7192
- };
7189
+ var formatAaveRayToApr = (raw) => formatAaveYieldToNumber(raw);
7193
7190
  var convertRateToApr = (ratePerSecond) => {
7194
7191
  const rps = Number(ratePerSecond);
7195
7192
  if (isNaN(rps)) return 0;
@@ -7277,13 +7274,13 @@ var getAaveV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
7277
7274
  reserveData?.[8 /* variableBorrowIndex */]
7278
7275
  ),
7279
7276
  // rates
7280
- depositRate: formatAaveRawApyToApr(
7277
+ depositRate: formatAaveRayToApr(
7281
7278
  reserveData?.[3 /* liquidityRate */]?.toString()
7282
7279
  ),
7283
- variableBorrowRate: formatAaveRawApyToApr(
7280
+ variableBorrowRate: formatAaveRayToApr(
7284
7281
  reserveData?.[4 /* variableBorrowRate */]?.toString()
7285
7282
  ),
7286
- stableBorrowRate: formatAaveRawApyToApr(
7283
+ stableBorrowRate: formatAaveRayToApr(
7287
7284
  reserveData?.[5 /* stableBorrowRate */]?.toString()
7288
7285
  ),
7289
7286
  intrinsicYield: additionalYields?.intrinsicYields?.[oracleKey] ?? 0,
@@ -7504,13 +7501,13 @@ var getAaveV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
7504
7501
  reserveData?.[10 /* variableBorrowIndex */]
7505
7502
  ),
7506
7503
  // rates
7507
- depositRate: formatAaveRawApyToApr(
7504
+ depositRate: formatAaveRayToApr(
7508
7505
  reserveData?.[5 /* liquidityRate */]?.toString()
7509
7506
  ),
7510
- variableBorrowRate: formatAaveRawApyToApr(
7507
+ variableBorrowRate: formatAaveRayToApr(
7511
7508
  reserveData?.[6 /* variableBorrowRate */]?.toString()
7512
7509
  ),
7513
- stableBorrowRate: formatAaveRawApyToApr(
7510
+ stableBorrowRate: formatAaveRayToApr(
7514
7511
  reserveData?.[7 /* stableBorrowRate */]?.toString()
7515
7512
  ),
7516
7513
  intrinsicYield: additionalYields?.intrinsicYields?.[toOracleKey(assetMeta?.assetGroup)] ?? 0,
@@ -7766,10 +7763,10 @@ function parseYLDRCall(chainId, lender, additionalYields, prices, tokenList) {
7766
7763
  reserveData?.[6 /* variableBorrowIndex */]
7767
7764
  ),
7768
7765
  // rates
7769
- depositRate: formatAaveRawApyToApr(
7766
+ depositRate: formatAaveRayToApr(
7770
7767
  reserveData?.[3 /* liquidityRate */]?.toString()
7771
7768
  ),
7772
- variableBorrowRate: formatAaveRawApyToApr(
7769
+ variableBorrowRate: formatAaveRayToApr(
7773
7770
  reserveData?.[4 /* variableBorrowRate */]?.toString()
7774
7771
  ),
7775
7772
  stableBorrowRate: 0,
@@ -7941,13 +7938,13 @@ function parseAave32(chainId, lender, prices, additionalYields, tokenList) {
7941
7938
  reserveData?.[10 /* variableBorrowIndex */]
7942
7939
  ),
7943
7940
  // rates
7944
- depositRate: formatAaveRawApyToApr(
7941
+ depositRate: formatAaveRayToApr(
7945
7942
  reserveData?.[5 /* liquidityRate */]?.toString()
7946
7943
  ),
7947
- variableBorrowRate: formatAaveRawApyToApr(
7944
+ variableBorrowRate: formatAaveRayToApr(
7948
7945
  reserveData?.[6 /* variableBorrowRate */]?.toString()
7949
7946
  ),
7950
- stableBorrowRate: formatAaveRawApyToApr(
7947
+ stableBorrowRate: formatAaveRayToApr(
7951
7948
  reserveData?.[7 /* stableBorrowRate */]?.toString()
7952
7949
  ),
7953
7950
  intrinsicYield: additionalYields?.intrinsicYields?.[toOracleKey(assetMeta?.assetGroup)] ?? 0,
@@ -19996,7 +19993,7 @@ var getSiloV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
19996
19993
  }
19997
19994
  };
19998
19995
  }
19999
- return { data: out, chainId };
19996
+ return { [lender]: { data: out, chainId } };
20000
19997
  },
20001
19998
  SILO_V2_CALLS_PER_PAIR
20002
19999
  ];
@@ -20156,7 +20153,7 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
20156
20153
  }
20157
20154
  };
20158
20155
  }
20159
- return { data: out, chainId };
20156
+ return { [lender]: { data: out, chainId } };
20160
20157
  },
20161
20158
  SILO_V3_CALLS_PER_PAIR
20162
20159
  ];
@@ -64810,14 +64807,18 @@ var fetchEulerEarnVaults = async (chainId, prices = {}, tokenList = {}, multical
64810
64807
  ).catch(() => void 0);
64811
64808
  if (isNonEmpty(fromApi)) return fromApi;
64812
64809
  const subgraphUrl = getEulerEarnSubgraphUrl(chainId);
64813
- if (!subgraphUrl) return fromApi ?? {};
64814
- const fromSubgraph = await fetchEulerEarnVaultsFromSubgraph(
64810
+ const fromSubgraph = subgraphUrl ? await fetchEulerEarnVaultsFromSubgraph(
64815
64811
  chainId,
64816
64812
  prices,
64817
64813
  tokenList,
64818
64814
  multicallRetry
64819
- ).catch(() => void 0);
64820
- return isNonEmpty(fromSubgraph) ? fromSubgraph : fromApi ?? {};
64815
+ ).catch(() => void 0) : void 0;
64816
+ if (isNonEmpty(fromSubgraph)) return fromSubgraph;
64817
+ if (fromSubgraph !== void 0) return fromSubgraph;
64818
+ if (fromApi !== void 0) return fromApi;
64819
+ throw new Error(
64820
+ `euler-earn: no data source answered for chain ${chainId} (Data API failed or does not serve the chain; ${subgraphUrl ? "subgraph fallback also failed" : "no subgraph fallback configured"})`
64821
+ );
64821
64822
  };
64822
64823
  var warn6 = (...args) => {
64823
64824
  };