@1delta/margin-fetcher 5.0.98 → 5.0.100

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
@@ -11829,6 +11829,18 @@ interface GetVaultPublicDataAllOptions {
11829
11829
  interface VaultPublicDataResult {
11830
11830
  data: VaultPublicDataAll;
11831
11831
  lookup: Map<string, VaultLookupEntry>;
11832
+ /**
11833
+ * Providers whose fetch threw (and whose rows are therefore absent from
11834
+ * `data`). A provider returning zero rows without throwing is NOT listed —
11835
+ * absence here plus absence in `data` means "nothing deployed", while
11836
+ * presence here means "the source broke". Callers that log "providers ok"
11837
+ * must check this, or an upstream API change reads as a healthy sweep
11838
+ * (the Morpho rewards→allRewards rename served exactly that lie).
11839
+ */
11840
+ failed: Array<{
11841
+ provider: VaultProvider;
11842
+ error: string;
11843
+ }>;
11832
11844
  }
11833
11845
  /**
11834
11846
  * Universal vault fetcher — the vaults-side analogue of
@@ -12263,8 +12275,15 @@ declare const fetchSiloVaults: (chainId: string, prices?: {
12263
12275
  * read each earn vault's real `decimals()` on-chain
12264
12276
  * (the Data API's `decimals` field is unreliable)
12265
12277
  *
12266
- * @returns `EulerEarnVaults` keyed by lowercased vault address — `{}` when
12267
- * 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.
12268
12287
  */
12269
12288
  declare const fetchEulerEarnVaults: (chainId: string, prices?: {
12270
12289
  [asset: string]: number;
package/dist/index.js CHANGED
@@ -19996,7 +19996,7 @@ var getSiloV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
19996
19996
  }
19997
19997
  };
19998
19998
  }
19999
- return { data: out, chainId };
19999
+ return { [lender]: { data: out, chainId } };
20000
20000
  },
20001
20001
  SILO_V2_CALLS_PER_PAIR
20002
20002
  ];
@@ -20156,7 +20156,7 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
20156
20156
  }
20157
20157
  };
20158
20158
  }
20159
- return { data: out, chainId };
20159
+ return { [lender]: { data: out, chainId } };
20160
20160
  },
20161
20161
  SILO_V3_CALLS_PER_PAIR
20162
20162
  ];
@@ -62708,7 +62708,7 @@ var MORPHO_SHARE_DECIMALS = 18;
62708
62708
  var MORPHO_API_URL = "https://blue-api.morpho.org/graphql";
62709
62709
  var PAGE_SIZE2 = 200;
62710
62710
  var MIN_TOTAL_ASSETS_USD = 100;
62711
- var vaultsQuery = (first, skip, chainId) => `
62711
+ var vaultsQuery = (first, skip, chainId, tier = "decorated") => `
62712
62712
  query GetVaults {
62713
62713
  vaults(
62714
62714
  first: ${first},
@@ -62720,8 +62720,7 @@ query GetVaults {
62720
62720
  items {
62721
62721
  address
62722
62722
  symbol
62723
- name
62724
- whitelisted: listed
62723
+ name${tier === "decorated" ? "\n whitelisted: listed" : ""}
62725
62724
  asset {
62726
62725
  address
62727
62726
  name
@@ -62743,29 +62742,31 @@ query GetVaults {
62743
62742
  timelock
62744
62743
  owner
62745
62744
  curator
62746
- guardian
62745
+ guardian${tier === "decorated" ? `
62747
62746
  curators {
62748
62747
  id
62749
62748
  name
62750
62749
  image
62751
62750
  verified
62752
62751
  }
62753
- rewards {
62752
+ rewards: allRewards {
62754
62753
  supplyApr
62755
62754
  asset {
62756
62755
  address
62757
62756
  }
62758
- }
62757
+ }` : ""}
62759
62758
  }
62760
62759
  }
62761
62760
  }
62762
62761
  }
62763
62762
  `;
62764
- async function fetchPage(chainId, first, skip) {
62763
+ var isSchemaFieldError = (errors) => errors.some((e) => /cannot query field/i.test(e?.message ?? ""));
62764
+ var decoratedTierBroken = false;
62765
+ async function runQuery(chainId, first, skip, tier) {
62765
62766
  const response = await fetch(MORPHO_API_URL, {
62766
62767
  method: "POST",
62767
62768
  headers: { "Content-Type": "application/json" },
62768
- body: JSON.stringify({ query: vaultsQuery(first, skip, chainId) })
62769
+ body: JSON.stringify({ query: vaultsQuery(first, skip, chainId, tier) })
62769
62770
  });
62770
62771
  if (!response.ok) {
62771
62772
  throw new Error(
@@ -62774,11 +62775,31 @@ async function fetchPage(chainId, first, skip) {
62774
62775
  }
62775
62776
  const json = await response.json();
62776
62777
  if (json?.errors?.length) {
62778
+ return { items: [], errors: json.errors };
62779
+ }
62780
+ return { items: json?.data?.vaults?.items ?? [] };
62781
+ }
62782
+ async function fetchPage(chainId, first, skip) {
62783
+ if (!decoratedTierBroken) {
62784
+ const full = await runQuery(chainId, first, skip, "decorated");
62785
+ if (!full.errors) return full.items;
62786
+ if (!isSchemaFieldError(full.errors)) {
62787
+ throw new Error(
62788
+ `Morpho vaults API GraphQL error: ${full.errors.map((e) => e?.message).join("; ")}`
62789
+ );
62790
+ }
62791
+ decoratedTierBroken = true;
62792
+ console.error(
62793
+ `[morpho-vaults] API schema drift \u2014 decorated query rejected, serving core fields only (rewardsRate=0, curators dropped) until the query is updated: ${full.errors.map((e) => e?.message).join("; ")}`
62794
+ );
62795
+ }
62796
+ const core = await runQuery(chainId, first, skip, "core");
62797
+ if (core.errors) {
62777
62798
  throw new Error(
62778
- `Morpho vaults API GraphQL error: ${json.errors.map((e) => e?.message).join("; ")}`
62799
+ `Morpho vaults API GraphQL error (core query): ${core.errors.map((e) => e?.message).join("; ")}`
62779
62800
  );
62780
62801
  }
62781
- return json?.data?.vaults?.items ?? [];
62802
+ return core.items;
62782
62803
  }
62783
62804
  var parseCurators = (curators) => {
62784
62805
  if (!curators?.length) return void 0;
@@ -64789,14 +64810,18 @@ var fetchEulerEarnVaults = async (chainId, prices = {}, tokenList = {}, multical
64789
64810
  ).catch(() => void 0);
64790
64811
  if (isNonEmpty(fromApi)) return fromApi;
64791
64812
  const subgraphUrl = getEulerEarnSubgraphUrl(chainId);
64792
- if (!subgraphUrl) return fromApi ?? {};
64793
- const fromSubgraph = await fetchEulerEarnVaultsFromSubgraph(
64813
+ const fromSubgraph = subgraphUrl ? await fetchEulerEarnVaultsFromSubgraph(
64794
64814
  chainId,
64795
64815
  prices,
64796
64816
  tokenList,
64797
64817
  multicallRetry
64798
- ).catch(() => void 0);
64799
- return isNonEmpty(fromSubgraph) ? fromSubgraph : fromApi ?? {};
64818
+ ).catch(() => void 0) : void 0;
64819
+ if (isNonEmpty(fromSubgraph)) return fromSubgraph;
64820
+ if (fromSubgraph !== void 0) return fromSubgraph;
64821
+ if (fromApi !== void 0) return fromApi;
64822
+ throw new Error(
64823
+ `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"})`
64824
+ );
64800
64825
  };
64801
64826
  var warn6 = (...args) => {
64802
64827
  };
@@ -79455,7 +79480,10 @@ function stampVaultTermSheets(data, chainId) {
79455
79480
  stampBag(data.hypercore, "hypercore");
79456
79481
  stampBag(data.gmx, "gmx");
79457
79482
  }
79483
+
79484
+ // src/vaults/fetchVaultsAll.ts
79458
79485
  var warn8 = (...args) => {
79486
+ console.error(...args);
79459
79487
  };
79460
79488
  var VAULT_PROVIDERS = [
79461
79489
  "fluid",
@@ -79479,18 +79507,23 @@ var VAULT_PROVIDERS = [
79479
79507
  var HYPERCORE_PROVIDER_CHAIN = "999";
79480
79508
  var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices = {}, tokenList = {}, options) => {
79481
79509
  const requested = new Set(providers);
79482
- if (requested.size === 0) return { data: {}, lookup: /* @__PURE__ */ new Map() };
79510
+ if (requested.size === 0) return { data: {}, lookup: /* @__PURE__ */ new Map(), failed: [] };
79483
79511
  const tasks = [];
79484
79512
  const out = {};
79513
+ const failed = [];
79514
+ const fail = (provider, e) => {
79515
+ failed.push({ provider, error: String(e?.message ?? e) });
79516
+ warn8(
79517
+ `[vaults] ${provider} fetch failed for chain ${chainId}:`,
79518
+ e?.message ?? e
79519
+ );
79520
+ };
79485
79521
  if (requested.has("fluid")) {
79486
79522
  tasks.push(
79487
79523
  fetchFluidFTokens(chainId, multicallRetry, prices, tokenList).then((res) => {
79488
79524
  out.fluid = res;
79489
79525
  }).catch((e) => {
79490
- warn8(
79491
- `[vaults] fluid fetch failed for chain ${chainId}:`,
79492
- e?.message ?? e
79493
- );
79526
+ fail("fluid", e);
79494
79527
  })
79495
79528
  );
79496
79529
  }
@@ -79499,10 +79532,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79499
79532
  fetchGearboxV3Pools(chainId, multicallRetry, prices, tokenList).then((res) => {
79500
79533
  out.gearbox = res;
79501
79534
  }).catch((e) => {
79502
- warn8(
79503
- `[vaults] gearbox fetch failed for chain ${chainId}:`,
79504
- e?.message ?? e
79505
- );
79535
+ fail("gearbox", e);
79506
79536
  })
79507
79537
  );
79508
79538
  }
@@ -79511,10 +79541,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79511
79541
  fetchMorphoVaults(chainId, multicallRetry, prices, tokenList).then((res) => {
79512
79542
  out.morpho = res;
79513
79543
  }).catch((e) => {
79514
- warn8(
79515
- `[vaults] morpho fetch failed for chain ${chainId}:`,
79516
- e?.message ?? e
79517
- );
79544
+ fail("morpho", e);
79518
79545
  })
79519
79546
  );
79520
79547
  }
@@ -79523,10 +79550,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79523
79550
  fetchListaVaultsFromChain(chainId, multicallRetry, prices, tokenList).then((res) => {
79524
79551
  out.lista = res;
79525
79552
  }).catch((e) => {
79526
- warn8(
79527
- `[vaults] lista fetch failed for chain ${chainId}:`,
79528
- e?.message ?? e
79529
- );
79553
+ fail("lista", e);
79530
79554
  })
79531
79555
  );
79532
79556
  }
@@ -79538,10 +79562,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79538
79562
  }).then((res) => {
79539
79563
  out.silo = res;
79540
79564
  }).catch((e) => {
79541
- warn8(
79542
- `[vaults] silo fetch failed for chain ${chainId}:`,
79543
- e?.message ?? e
79544
- );
79565
+ fail("silo", e);
79545
79566
  })
79546
79567
  );
79547
79568
  }
@@ -79550,10 +79571,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79550
79571
  fetchEulerEarnVaults(chainId, prices, tokenList, multicallRetry).then((res) => {
79551
79572
  out["euler-earn"] = res;
79552
79573
  }).catch((e) => {
79553
- warn8(
79554
- `[vaults] euler-earn fetch failed for chain ${chainId}:`,
79555
- e?.message ?? e
79556
- );
79574
+ fail("euler-earn", e);
79557
79575
  })
79558
79576
  );
79559
79577
  }
@@ -79562,10 +79580,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79562
79580
  fetchTermMaxVaults(chainId, multicallRetry, prices, tokenList).then((res) => {
79563
79581
  out.termmax = res;
79564
79582
  }).catch((e) => {
79565
- warn8(
79566
- `[vaults] termmax fetch failed for chain ${chainId}:`,
79567
- e?.message ?? e
79568
- );
79583
+ fail("termmax", e);
79569
79584
  })
79570
79585
  );
79571
79586
  }
@@ -79574,10 +79589,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79574
79589
  fetchLstShareTokens(chainId, multicallRetry, prices, tokenList).then((res) => {
79575
79590
  out.lst = res;
79576
79591
  }).catch((e) => {
79577
- warn8(
79578
- `[vaults] lst fetch failed for chain ${chainId}:`,
79579
- e?.message ?? e
79580
- );
79592
+ fail("lst", e);
79581
79593
  })
79582
79594
  );
79583
79595
  }
@@ -79586,10 +79598,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79586
79598
  fetchSavingsVaults(chainId, multicallRetry, prices, tokenList).then((res) => {
79587
79599
  out.savings = res;
79588
79600
  }).catch((e) => {
79589
- warn8(
79590
- `[vaults] savings fetch failed for chain ${chainId}:`,
79591
- e?.message ?? e
79592
- );
79601
+ fail("savings", e);
79593
79602
  })
79594
79603
  );
79595
79604
  }
@@ -79598,10 +79607,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79598
79607
  fetchLagoonVaults(chainId, prices, tokenList).then((res) => {
79599
79608
  out.lagoon = res;
79600
79609
  }).catch((e) => {
79601
- warn8(
79602
- `[vaults] lagoon fetch failed for chain ${chainId}:`,
79603
- e?.message ?? e
79604
- );
79610
+ fail("lagoon", e);
79605
79611
  })
79606
79612
  );
79607
79613
  }
@@ -79610,10 +79616,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79610
79616
  fetchAaveEarnVaults(chainId, multicallRetry, prices, tokenList).then((res) => {
79611
79617
  out["aave-earn"] = res;
79612
79618
  }).catch((e) => {
79613
- warn8(
79614
- `[vaults] aave-earn fetch failed for chain ${chainId}:`,
79615
- e?.message ?? e
79616
- );
79619
+ fail("aave-earn", e);
79617
79620
  })
79618
79621
  );
79619
79622
  }
@@ -79622,10 +79625,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79622
79625
  fetchUpshiftVaults(chainId, prices, tokenList).then((res) => {
79623
79626
  out.upshift = res;
79624
79627
  }).catch((e) => {
79625
- warn8(
79626
- `[vaults] upshift fetch failed for chain ${chainId}:`,
79627
- e?.message ?? e
79628
- );
79628
+ fail("upshift", e);
79629
79629
  })
79630
79630
  );
79631
79631
  }
@@ -79634,10 +79634,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79634
79634
  fetchYearnVaults(chainId, multicallRetry, prices, tokenList).then((res) => {
79635
79635
  out.yearn = res;
79636
79636
  }).catch((e) => {
79637
- warn8(
79638
- `[vaults] yearn fetch failed for chain ${chainId}:`,
79639
- e?.message ?? e
79640
- );
79637
+ fail("yearn", e);
79641
79638
  })
79642
79639
  );
79643
79640
  }
@@ -79646,10 +79643,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79646
79643
  fetchHypercoreVaults().then((res) => {
79647
79644
  out.hypercore = res;
79648
79645
  }).catch((e) => {
79649
- warn8(
79650
- `[vaults] hypercore fetch failed for chain ${chainId}:`,
79651
- e?.message ?? e
79652
- );
79646
+ fail("hypercore", e);
79653
79647
  })
79654
79648
  );
79655
79649
  }
@@ -79660,10 +79654,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79660
79654
  }).then((res) => {
79661
79655
  out.pendle = res;
79662
79656
  }).catch((e) => {
79663
- warn8(
79664
- `[vaults] pendle fetch failed for chain ${chainId}:`,
79665
- e?.message ?? e
79666
- );
79657
+ fail("pendle", e);
79667
79658
  })
79668
79659
  );
79669
79660
  }
@@ -79674,10 +79665,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79674
79665
  }).then((res) => {
79675
79666
  out.spectra = res;
79676
79667
  }).catch((e) => {
79677
- warn8(
79678
- `[vaults] spectra fetch failed for chain ${chainId}:`,
79679
- e?.message ?? e
79680
- );
79668
+ fail("spectra", e);
79681
79669
  })
79682
79670
  );
79683
79671
  }
@@ -79686,10 +79674,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79686
79674
  fetchGmxVaults(chainId, multicallRetry).then((res) => {
79687
79675
  out.gmx = res;
79688
79676
  }).catch((e) => {
79689
- warn8(
79690
- `[vaults] gmx fetch failed for chain ${chainId}:`,
79691
- e?.message ?? e
79692
- );
79677
+ fail("gmx", e);
79693
79678
  })
79694
79679
  );
79695
79680
  tasks.push(
@@ -79712,7 +79697,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
79712
79697
  await Promise.all(tasks);
79713
79698
  stampVaultClassification(out, chainId, tokenList);
79714
79699
  stampVaultTermSheets(out, chainId);
79715
- return { data: out, lookup: buildVaultLookup(out) };
79700
+ return { data: out, lookup: buildVaultLookup(out), failed };
79716
79701
  };
79717
79702
 
79718
79703
  // src/vaults/interfaceKind.ts