@1delta/margin-fetcher 5.0.98 → 5.0.99
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 +12 -0
- package/dist/index.js +61 -80
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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
|
package/dist/index.js
CHANGED
|
@@ -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
|
-
|
|
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: ${
|
|
62799
|
+
`Morpho vaults API GraphQL error (core query): ${core.errors.map((e) => e?.message).join("; ")}`
|
|
62779
62800
|
);
|
|
62780
62801
|
}
|
|
62781
|
-
return
|
|
62802
|
+
return core.items;
|
|
62782
62803
|
}
|
|
62783
62804
|
var parseCurators = (curators) => {
|
|
62784
62805
|
if (!curators?.length) return void 0;
|
|
@@ -79455,7 +79476,10 @@ function stampVaultTermSheets(data, chainId) {
|
|
|
79455
79476
|
stampBag(data.hypercore, "hypercore");
|
|
79456
79477
|
stampBag(data.gmx, "gmx");
|
|
79457
79478
|
}
|
|
79479
|
+
|
|
79480
|
+
// src/vaults/fetchVaultsAll.ts
|
|
79458
79481
|
var warn8 = (...args) => {
|
|
79482
|
+
console.error(...args);
|
|
79459
79483
|
};
|
|
79460
79484
|
var VAULT_PROVIDERS = [
|
|
79461
79485
|
"fluid",
|
|
@@ -79479,18 +79503,23 @@ var VAULT_PROVIDERS = [
|
|
|
79479
79503
|
var HYPERCORE_PROVIDER_CHAIN = "999";
|
|
79480
79504
|
var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices = {}, tokenList = {}, options) => {
|
|
79481
79505
|
const requested = new Set(providers);
|
|
79482
|
-
if (requested.size === 0) return { data: {}, lookup: /* @__PURE__ */ new Map() };
|
|
79506
|
+
if (requested.size === 0) return { data: {}, lookup: /* @__PURE__ */ new Map(), failed: [] };
|
|
79483
79507
|
const tasks = [];
|
|
79484
79508
|
const out = {};
|
|
79509
|
+
const failed = [];
|
|
79510
|
+
const fail = (provider, e) => {
|
|
79511
|
+
failed.push({ provider, error: String(e?.message ?? e) });
|
|
79512
|
+
warn8(
|
|
79513
|
+
`[vaults] ${provider} fetch failed for chain ${chainId}:`,
|
|
79514
|
+
e?.message ?? e
|
|
79515
|
+
);
|
|
79516
|
+
};
|
|
79485
79517
|
if (requested.has("fluid")) {
|
|
79486
79518
|
tasks.push(
|
|
79487
79519
|
fetchFluidFTokens(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
79488
79520
|
out.fluid = res;
|
|
79489
79521
|
}).catch((e) => {
|
|
79490
|
-
|
|
79491
|
-
`[vaults] fluid fetch failed for chain ${chainId}:`,
|
|
79492
|
-
e?.message ?? e
|
|
79493
|
-
);
|
|
79522
|
+
fail("fluid", e);
|
|
79494
79523
|
})
|
|
79495
79524
|
);
|
|
79496
79525
|
}
|
|
@@ -79499,10 +79528,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79499
79528
|
fetchGearboxV3Pools(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
79500
79529
|
out.gearbox = res;
|
|
79501
79530
|
}).catch((e) => {
|
|
79502
|
-
|
|
79503
|
-
`[vaults] gearbox fetch failed for chain ${chainId}:`,
|
|
79504
|
-
e?.message ?? e
|
|
79505
|
-
);
|
|
79531
|
+
fail("gearbox", e);
|
|
79506
79532
|
})
|
|
79507
79533
|
);
|
|
79508
79534
|
}
|
|
@@ -79511,10 +79537,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79511
79537
|
fetchMorphoVaults(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
79512
79538
|
out.morpho = res;
|
|
79513
79539
|
}).catch((e) => {
|
|
79514
|
-
|
|
79515
|
-
`[vaults] morpho fetch failed for chain ${chainId}:`,
|
|
79516
|
-
e?.message ?? e
|
|
79517
|
-
);
|
|
79540
|
+
fail("morpho", e);
|
|
79518
79541
|
})
|
|
79519
79542
|
);
|
|
79520
79543
|
}
|
|
@@ -79523,10 +79546,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79523
79546
|
fetchListaVaultsFromChain(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
79524
79547
|
out.lista = res;
|
|
79525
79548
|
}).catch((e) => {
|
|
79526
|
-
|
|
79527
|
-
`[vaults] lista fetch failed for chain ${chainId}:`,
|
|
79528
|
-
e?.message ?? e
|
|
79529
|
-
);
|
|
79549
|
+
fail("lista", e);
|
|
79530
79550
|
})
|
|
79531
79551
|
);
|
|
79532
79552
|
}
|
|
@@ -79538,10 +79558,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79538
79558
|
}).then((res) => {
|
|
79539
79559
|
out.silo = res;
|
|
79540
79560
|
}).catch((e) => {
|
|
79541
|
-
|
|
79542
|
-
`[vaults] silo fetch failed for chain ${chainId}:`,
|
|
79543
|
-
e?.message ?? e
|
|
79544
|
-
);
|
|
79561
|
+
fail("silo", e);
|
|
79545
79562
|
})
|
|
79546
79563
|
);
|
|
79547
79564
|
}
|
|
@@ -79550,10 +79567,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79550
79567
|
fetchEulerEarnVaults(chainId, prices, tokenList, multicallRetry).then((res) => {
|
|
79551
79568
|
out["euler-earn"] = res;
|
|
79552
79569
|
}).catch((e) => {
|
|
79553
|
-
|
|
79554
|
-
`[vaults] euler-earn fetch failed for chain ${chainId}:`,
|
|
79555
|
-
e?.message ?? e
|
|
79556
|
-
);
|
|
79570
|
+
fail("euler-earn", e);
|
|
79557
79571
|
})
|
|
79558
79572
|
);
|
|
79559
79573
|
}
|
|
@@ -79562,10 +79576,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79562
79576
|
fetchTermMaxVaults(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
79563
79577
|
out.termmax = res;
|
|
79564
79578
|
}).catch((e) => {
|
|
79565
|
-
|
|
79566
|
-
`[vaults] termmax fetch failed for chain ${chainId}:`,
|
|
79567
|
-
e?.message ?? e
|
|
79568
|
-
);
|
|
79579
|
+
fail("termmax", e);
|
|
79569
79580
|
})
|
|
79570
79581
|
);
|
|
79571
79582
|
}
|
|
@@ -79574,10 +79585,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79574
79585
|
fetchLstShareTokens(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
79575
79586
|
out.lst = res;
|
|
79576
79587
|
}).catch((e) => {
|
|
79577
|
-
|
|
79578
|
-
`[vaults] lst fetch failed for chain ${chainId}:`,
|
|
79579
|
-
e?.message ?? e
|
|
79580
|
-
);
|
|
79588
|
+
fail("lst", e);
|
|
79581
79589
|
})
|
|
79582
79590
|
);
|
|
79583
79591
|
}
|
|
@@ -79586,10 +79594,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79586
79594
|
fetchSavingsVaults(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
79587
79595
|
out.savings = res;
|
|
79588
79596
|
}).catch((e) => {
|
|
79589
|
-
|
|
79590
|
-
`[vaults] savings fetch failed for chain ${chainId}:`,
|
|
79591
|
-
e?.message ?? e
|
|
79592
|
-
);
|
|
79597
|
+
fail("savings", e);
|
|
79593
79598
|
})
|
|
79594
79599
|
);
|
|
79595
79600
|
}
|
|
@@ -79598,10 +79603,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79598
79603
|
fetchLagoonVaults(chainId, prices, tokenList).then((res) => {
|
|
79599
79604
|
out.lagoon = res;
|
|
79600
79605
|
}).catch((e) => {
|
|
79601
|
-
|
|
79602
|
-
`[vaults] lagoon fetch failed for chain ${chainId}:`,
|
|
79603
|
-
e?.message ?? e
|
|
79604
|
-
);
|
|
79606
|
+
fail("lagoon", e);
|
|
79605
79607
|
})
|
|
79606
79608
|
);
|
|
79607
79609
|
}
|
|
@@ -79610,10 +79612,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79610
79612
|
fetchAaveEarnVaults(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
79611
79613
|
out["aave-earn"] = res;
|
|
79612
79614
|
}).catch((e) => {
|
|
79613
|
-
|
|
79614
|
-
`[vaults] aave-earn fetch failed for chain ${chainId}:`,
|
|
79615
|
-
e?.message ?? e
|
|
79616
|
-
);
|
|
79615
|
+
fail("aave-earn", e);
|
|
79617
79616
|
})
|
|
79618
79617
|
);
|
|
79619
79618
|
}
|
|
@@ -79622,10 +79621,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79622
79621
|
fetchUpshiftVaults(chainId, prices, tokenList).then((res) => {
|
|
79623
79622
|
out.upshift = res;
|
|
79624
79623
|
}).catch((e) => {
|
|
79625
|
-
|
|
79626
|
-
`[vaults] upshift fetch failed for chain ${chainId}:`,
|
|
79627
|
-
e?.message ?? e
|
|
79628
|
-
);
|
|
79624
|
+
fail("upshift", e);
|
|
79629
79625
|
})
|
|
79630
79626
|
);
|
|
79631
79627
|
}
|
|
@@ -79634,10 +79630,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79634
79630
|
fetchYearnVaults(chainId, multicallRetry, prices, tokenList).then((res) => {
|
|
79635
79631
|
out.yearn = res;
|
|
79636
79632
|
}).catch((e) => {
|
|
79637
|
-
|
|
79638
|
-
`[vaults] yearn fetch failed for chain ${chainId}:`,
|
|
79639
|
-
e?.message ?? e
|
|
79640
|
-
);
|
|
79633
|
+
fail("yearn", e);
|
|
79641
79634
|
})
|
|
79642
79635
|
);
|
|
79643
79636
|
}
|
|
@@ -79646,10 +79639,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79646
79639
|
fetchHypercoreVaults().then((res) => {
|
|
79647
79640
|
out.hypercore = res;
|
|
79648
79641
|
}).catch((e) => {
|
|
79649
|
-
|
|
79650
|
-
`[vaults] hypercore fetch failed for chain ${chainId}:`,
|
|
79651
|
-
e?.message ?? e
|
|
79652
|
-
);
|
|
79642
|
+
fail("hypercore", e);
|
|
79653
79643
|
})
|
|
79654
79644
|
);
|
|
79655
79645
|
}
|
|
@@ -79660,10 +79650,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79660
79650
|
}).then((res) => {
|
|
79661
79651
|
out.pendle = res;
|
|
79662
79652
|
}).catch((e) => {
|
|
79663
|
-
|
|
79664
|
-
`[vaults] pendle fetch failed for chain ${chainId}:`,
|
|
79665
|
-
e?.message ?? e
|
|
79666
|
-
);
|
|
79653
|
+
fail("pendle", e);
|
|
79667
79654
|
})
|
|
79668
79655
|
);
|
|
79669
79656
|
}
|
|
@@ -79674,10 +79661,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79674
79661
|
}).then((res) => {
|
|
79675
79662
|
out.spectra = res;
|
|
79676
79663
|
}).catch((e) => {
|
|
79677
|
-
|
|
79678
|
-
`[vaults] spectra fetch failed for chain ${chainId}:`,
|
|
79679
|
-
e?.message ?? e
|
|
79680
|
-
);
|
|
79664
|
+
fail("spectra", e);
|
|
79681
79665
|
})
|
|
79682
79666
|
);
|
|
79683
79667
|
}
|
|
@@ -79686,10 +79670,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79686
79670
|
fetchGmxVaults(chainId, multicallRetry).then((res) => {
|
|
79687
79671
|
out.gmx = res;
|
|
79688
79672
|
}).catch((e) => {
|
|
79689
|
-
|
|
79690
|
-
`[vaults] gmx fetch failed for chain ${chainId}:`,
|
|
79691
|
-
e?.message ?? e
|
|
79692
|
-
);
|
|
79673
|
+
fail("gmx", e);
|
|
79693
79674
|
})
|
|
79694
79675
|
);
|
|
79695
79676
|
tasks.push(
|
|
@@ -79712,7 +79693,7 @@ var getVaultPublicDataAll = async (chainId, providers, multicallRetry, prices =
|
|
|
79712
79693
|
await Promise.all(tasks);
|
|
79713
79694
|
stampVaultClassification(out, chainId, tokenList);
|
|
79714
79695
|
stampVaultTermSheets(out, chainId);
|
|
79715
|
-
return { data: out, lookup: buildVaultLookup(out) };
|
|
79696
|
+
return { data: out, lookup: buildVaultLookup(out), failed };
|
|
79716
79697
|
};
|
|
79717
79698
|
|
|
79718
79699
|
// src/vaults/interfaceKind.ts
|