@1delta/margin-fetcher 0.0.229 → 0.0.231
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 +144 -70
- package/dist/index.js.map +1 -1
- package/dist/lending/public-data/silo-v2/convertPublic.d.ts.map +1 -1
- package/dist/lending/public-data/silo-v2/publicCallParse.d.ts.map +1 -1
- package/dist/lending/public-data/silo-v3/convertPublic.d.ts.map +1 -1
- package/dist/lending/public-data/silo-v3/publicCallParse.d.ts.map +1 -1
- package/dist/prices/oracle-prices/fetchOraclePrices.d.ts.map +1 -1
- package/dist/prices/oracle-prices/fetchers/siloV2.d.ts.map +1 -1
- package/dist/prices/oracle-prices/fetchers/siloV2Graphql.d.ts +19 -1
- package/dist/prices/oracle-prices/fetchers/siloV2Graphql.d.ts.map +1 -1
- package/dist/prices/oracle-prices/fetchers/siloV3.d.ts.map +1 -1
- package/dist/prices/oracle-prices/fetchers/siloV3Graphql.d.ts +12 -1
- package/dist/prices/oracle-prices/fetchers/siloV3Graphql.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -18772,11 +18772,11 @@ var getSiloV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
18772
18772
|
const assetMeta = tokenList[tokenAddrLc];
|
|
18773
18773
|
const oracleKey = toOracleKey(assetMeta?.assetGroup ?? null) || toGenericPriceKey(tokenAddrLc, chainId);
|
|
18774
18774
|
const price = prices[oracleKey] ?? 0;
|
|
18775
|
-
const collateralLt = Number(other.lt) / 1e18;
|
|
18776
|
-
const collateralMaxLtv = Number(other.maxLtv) / 1e18;
|
|
18777
18775
|
const selfLt = Number(self.lt) / 1e18;
|
|
18778
|
-
const
|
|
18776
|
+
const selfMaxLtv = Number(self.maxLtv) / 1e18;
|
|
18777
|
+
const otherLt = Number(other.lt) / 1e18;
|
|
18779
18778
|
const collateralActive = selfLt > 0;
|
|
18779
|
+
const borrowingEnabled = otherLt > 0;
|
|
18780
18780
|
const marketUid = createMarketUid(chainId, lender, self.silo);
|
|
18781
18781
|
out[marketUid] = {
|
|
18782
18782
|
marketUid,
|
|
@@ -18819,11 +18819,11 @@ var getSiloV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
18819
18819
|
config: {
|
|
18820
18820
|
0: {
|
|
18821
18821
|
category: 0,
|
|
18822
|
-
borrowCollateralFactor:
|
|
18823
|
-
collateralFactor:
|
|
18822
|
+
borrowCollateralFactor: selfMaxLtv,
|
|
18823
|
+
collateralFactor: selfLt,
|
|
18824
18824
|
borrowFactor: 1,
|
|
18825
|
-
collateralDisabled: !
|
|
18826
|
-
debtDisabled: !
|
|
18825
|
+
collateralDisabled: !collateralActive,
|
|
18826
|
+
debtDisabled: !borrowingEnabled
|
|
18827
18827
|
}
|
|
18828
18828
|
},
|
|
18829
18829
|
collateralActive,
|
|
@@ -18924,11 +18924,11 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
18924
18924
|
const assetMeta = tokenList[tokenAddrLc];
|
|
18925
18925
|
const oracleKey = toOracleKey(assetMeta?.assetGroup ?? null) || toGenericPriceKey(tokenAddrLc, chainId);
|
|
18926
18926
|
const price = prices[oracleKey] ?? 0;
|
|
18927
|
-
const collateralLt = Number(other.lt) / 1e18;
|
|
18928
|
-
const collateralMaxLtv = Number(other.maxLtv) / 1e18;
|
|
18929
18927
|
const selfLt = Number(self.lt) / 1e18;
|
|
18930
|
-
const
|
|
18928
|
+
const selfMaxLtv = Number(self.maxLtv) / 1e18;
|
|
18929
|
+
const otherLt = Number(other.lt) / 1e18;
|
|
18931
18930
|
const collateralActive = selfLt > 0;
|
|
18931
|
+
const borrowingEnabled = otherLt > 0;
|
|
18932
18932
|
const marketUid = createMarketUid(chainId, lender, self.silo);
|
|
18933
18933
|
out[marketUid] = {
|
|
18934
18934
|
marketUid,
|
|
@@ -18963,11 +18963,11 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
18963
18963
|
config: {
|
|
18964
18964
|
0: {
|
|
18965
18965
|
category: 0,
|
|
18966
|
-
borrowCollateralFactor:
|
|
18967
|
-
collateralFactor:
|
|
18966
|
+
borrowCollateralFactor: selfMaxLtv,
|
|
18967
|
+
collateralFactor: selfLt,
|
|
18968
18968
|
borrowFactor: 1,
|
|
18969
|
-
collateralDisabled: !
|
|
18970
|
-
debtDisabled: !
|
|
18969
|
+
collateralDisabled: !collateralActive,
|
|
18970
|
+
debtDisabled: !borrowingEnabled
|
|
18971
18971
|
}
|
|
18972
18972
|
},
|
|
18973
18973
|
collateralActive,
|
|
@@ -19424,21 +19424,20 @@ function convertSiloMarketsToPublicResponse(apiItems, chainId, prices, additiona
|
|
|
19424
19424
|
const totalDebt = safeNumber(api.borrowed);
|
|
19425
19425
|
const totalLiquidity = totalDeposits - totalDebt;
|
|
19426
19426
|
const utilization = totalDeposits > 0 ? totalDebt / totalDeposits : safeNumber(api.utilization);
|
|
19427
|
-
const variableBorrowRatePct = safeNumber(api.borrowRate)
|
|
19428
|
-
const depositRatePct = safeNumber(api.depositRate)
|
|
19427
|
+
const variableBorrowRatePct = safeNumber(api.borrowRate);
|
|
19428
|
+
const depositRatePct = safeNumber(api.depositRate);
|
|
19429
19429
|
const assetMeta = tokenList[tokenAddrLc];
|
|
19430
19430
|
const oracleKey = toOracleKey(assetMeta?.assetGroup ?? null) || toGenericPriceKey(tokenAddrLc, chainId);
|
|
19431
19431
|
const fallbackPrice = prices[oracleKey] ?? 0;
|
|
19432
19432
|
const totalDepositsUSD = api.supplyUsd != null && api.supplyUsd > 0 ? api.supplyUsd : totalDeposits * fallbackPrice;
|
|
19433
19433
|
const totalDebtUSD = api.borrowedUsd != null && api.borrowedUsd > 0 ? api.borrowedUsd : totalDebt * fallbackPrice;
|
|
19434
19434
|
const totalLiquidityUSD = Math.max(totalDepositsUSD - totalDebtUSD, 0);
|
|
19435
|
-
const
|
|
19436
|
-
const collateralMaxLtv = safeLtvOrFee(api, "maxLtv", other.maxLtv);
|
|
19435
|
+
const otherApi = sides[0].api === api ? apiSide1 : apiSide0;
|
|
19437
19436
|
const selfLt = bigintToLtv(api.lt ?? self.lt);
|
|
19438
|
-
const
|
|
19439
|
-
const
|
|
19440
|
-
const borrowingEnabled = (collateralLtFromApi || collateralLt) > 0;
|
|
19437
|
+
const selfMaxLtv = bigintToLtv(api.maxLtv ?? self.maxLtv);
|
|
19438
|
+
const otherLt = bigintToLtv(otherApi.lt ?? other.lt);
|
|
19441
19439
|
const collateralActive = selfLt > 0;
|
|
19440
|
+
const borrowingEnabled = otherLt > 0;
|
|
19442
19441
|
const siloAddrLc = self.silo.toLowerCase();
|
|
19443
19442
|
const marketUid = createMarketUid(chainId, lenderKey, siloAddrLc);
|
|
19444
19443
|
data[marketUid] = {
|
|
@@ -19476,11 +19475,11 @@ function convertSiloMarketsToPublicResponse(apiItems, chainId, prices, additiona
|
|
|
19476
19475
|
config: {
|
|
19477
19476
|
0: {
|
|
19478
19477
|
category: 0,
|
|
19479
|
-
borrowCollateralFactor:
|
|
19480
|
-
collateralFactor:
|
|
19478
|
+
borrowCollateralFactor: selfMaxLtv,
|
|
19479
|
+
collateralFactor: selfLt,
|
|
19481
19480
|
borrowFactor: 1,
|
|
19482
|
-
collateralDisabled: !
|
|
19483
|
-
debtDisabled: !
|
|
19481
|
+
collateralDisabled: !collateralActive,
|
|
19482
|
+
debtDisabled: !borrowingEnabled
|
|
19484
19483
|
}
|
|
19485
19484
|
},
|
|
19486
19485
|
collateralActive,
|
|
@@ -19529,9 +19528,6 @@ function bigintToLtv(v) {
|
|
|
19529
19528
|
return Number.isFinite(n) ? n / 1e18 : 0;
|
|
19530
19529
|
}
|
|
19531
19530
|
}
|
|
19532
|
-
function safeLtvOrFee(api, field5, fallback) {
|
|
19533
|
-
return bigintToLtv(api[field5] ?? fallback);
|
|
19534
|
-
}
|
|
19535
19531
|
|
|
19536
19532
|
// src/lending/public-data/silo-v3/convertPublic.ts
|
|
19537
19533
|
var ZERO_ADDRESS2 = "0x0000000000000000000000000000000000000000";
|
|
@@ -19564,21 +19560,20 @@ function convertSiloV3MarketsToPublicResponse(apiItems, chainId, prices, additio
|
|
|
19564
19560
|
const totalDebt = safeNumber2(api.borrowed);
|
|
19565
19561
|
const totalLiquidity = totalDeposits - totalDebt;
|
|
19566
19562
|
const utilization = totalDeposits > 0 ? totalDebt / totalDeposits : safeNumber2(api.utilization);
|
|
19567
|
-
const variableBorrowRatePct = safeNumber2(api.borrowRate)
|
|
19568
|
-
const depositRatePct = safeNumber2(api.depositRate)
|
|
19563
|
+
const variableBorrowRatePct = safeNumber2(api.borrowRate);
|
|
19564
|
+
const depositRatePct = safeNumber2(api.depositRate);
|
|
19569
19565
|
const assetMeta = tokenList[tokenAddrLc];
|
|
19570
19566
|
const oracleKey = toOracleKey(assetMeta?.assetGroup ?? null) || toGenericPriceKey(tokenAddrLc, chainId);
|
|
19571
19567
|
const fallbackPrice = prices[oracleKey] ?? 0;
|
|
19572
19568
|
const totalDepositsUSD = api.supplyUsd != null && api.supplyUsd > 0 ? api.supplyUsd : totalDeposits * fallbackPrice;
|
|
19573
19569
|
const totalDebtUSD = api.borrowedUsd != null && api.borrowedUsd > 0 ? api.borrowedUsd : totalDebt * fallbackPrice;
|
|
19574
19570
|
const totalLiquidityUSD = Math.max(totalDepositsUSD - totalDebtUSD, 0);
|
|
19575
|
-
const
|
|
19576
|
-
const collateralMaxLtv = safeLtvOrFee2(api, "maxLtv", other.maxLtv);
|
|
19571
|
+
const otherApi = sides[0].api === api ? apiSide1 : apiSide0;
|
|
19577
19572
|
const selfLt = bigintToLtv2(api.lt ?? self.lt);
|
|
19578
|
-
const
|
|
19579
|
-
const
|
|
19580
|
-
const borrowingEnabled = (collateralLtFromApi || collateralLt) > 0;
|
|
19573
|
+
const selfMaxLtv = bigintToLtv2(api.maxLtv ?? self.maxLtv);
|
|
19574
|
+
const otherLt = bigintToLtv2(otherApi.lt ?? other.lt);
|
|
19581
19575
|
const collateralActive = selfLt > 0;
|
|
19576
|
+
const borrowingEnabled = otherLt > 0;
|
|
19582
19577
|
const siloAddrLc = self.silo.toLowerCase();
|
|
19583
19578
|
const marketUid = createMarketUid(chainId, lenderKey, siloAddrLc);
|
|
19584
19579
|
data[marketUid] = {
|
|
@@ -19614,11 +19609,11 @@ function convertSiloV3MarketsToPublicResponse(apiItems, chainId, prices, additio
|
|
|
19614
19609
|
config: {
|
|
19615
19610
|
0: {
|
|
19616
19611
|
category: 0,
|
|
19617
|
-
borrowCollateralFactor:
|
|
19618
|
-
collateralFactor:
|
|
19612
|
+
borrowCollateralFactor: selfMaxLtv,
|
|
19613
|
+
collateralFactor: selfLt,
|
|
19619
19614
|
borrowFactor: 1,
|
|
19620
|
-
collateralDisabled: !
|
|
19621
|
-
debtDisabled: !
|
|
19615
|
+
collateralDisabled: !collateralActive,
|
|
19616
|
+
debtDisabled: !borrowingEnabled
|
|
19622
19617
|
}
|
|
19623
19618
|
},
|
|
19624
19619
|
collateralActive,
|
|
@@ -19667,9 +19662,6 @@ function bigintToLtv2(v) {
|
|
|
19667
19662
|
return Number.isFinite(n) ? n / 1e18 : 0;
|
|
19668
19663
|
}
|
|
19669
19664
|
}
|
|
19670
|
-
function safeLtvOrFee2(api, field5, fallback) {
|
|
19671
|
-
return bigintToLtv2(api[field5] ?? fallback);
|
|
19672
|
-
}
|
|
19673
19665
|
|
|
19674
19666
|
// src/lending/public-data/fetchLenderExt.ts
|
|
19675
19667
|
async function getLenderDataFromApi(lender, chainId, prices, additionalYields, includeUnlisted = false) {
|
|
@@ -30645,9 +30637,7 @@ function parseSiloV2Results(data, meta, context) {
|
|
|
30645
30637
|
const rawQt = data[qtIdx];
|
|
30646
30638
|
if (!rawQt || rawQt === "0x") continue;
|
|
30647
30639
|
const quoteTokenAddr = rawQt.toLowerCase();
|
|
30648
|
-
const
|
|
30649
|
-
const qtDecimals = qtMeta?.decimals ?? 18;
|
|
30650
|
-
const priceInQt = Number(quoteAmount) / Number(10n ** BigInt(qtDecimals));
|
|
30640
|
+
const priceInQt = Number(quoteAmount) / 1e18;
|
|
30651
30641
|
if (isNaN(priceInQt) || priceInQt === 0) continue;
|
|
30652
30642
|
const qtUSD = lookupUSD(context, quoteTokenAddr);
|
|
30653
30643
|
if (!qtUSD) continue;
|
|
@@ -30818,9 +30808,7 @@ function parseSiloV3Results(data, meta, context) {
|
|
|
30818
30808
|
const rawQt = data[qtIdx];
|
|
30819
30809
|
if (!rawQt || rawQt === "0x") continue;
|
|
30820
30810
|
const quoteTokenAddr = rawQt.toLowerCase();
|
|
30821
|
-
const
|
|
30822
|
-
const qtDecimals = qtMeta?.decimals ?? 18;
|
|
30823
|
-
const priceInQt = Number(quoteAmount) / Number(10n ** BigInt(qtDecimals));
|
|
30811
|
+
const priceInQt = Number(quoteAmount) / 1e18;
|
|
30824
30812
|
if (isNaN(priceInQt) || priceInQt === 0) continue;
|
|
30825
30813
|
const qtUSD = lookupUSD2(context, quoteTokenAddr);
|
|
30826
30814
|
if (!qtUSD) continue;
|
|
@@ -30869,6 +30857,51 @@ async function fetchSiloV2GraphQLMarkets(chainId) {
|
|
|
30869
30857
|
return null;
|
|
30870
30858
|
}
|
|
30871
30859
|
}
|
|
30860
|
+
async function fetchSiloV2GraphQLPrices(chainId, basePrices = {}, tokenList = {}) {
|
|
30861
|
+
const items = await fetchSiloV2GraphQLMarkets(chainId);
|
|
30862
|
+
if (items == null) return null;
|
|
30863
|
+
const usdPrices = buildSelfDerivedUsdMap(chainId, items, basePrices, tokenList);
|
|
30864
|
+
const context = { chainId, usdPrices, tokenList };
|
|
30865
|
+
const entries = parseSiloV2GraphQLResults(items, context);
|
|
30866
|
+
if (entries.length === 0) {
|
|
30867
|
+
console.warn(
|
|
30868
|
+
`[silo-v2-gql] chain ${chainId}: ${items.length} markets fetched but 0 price entries produced`
|
|
30869
|
+
);
|
|
30870
|
+
return null;
|
|
30871
|
+
}
|
|
30872
|
+
return entries;
|
|
30873
|
+
}
|
|
30874
|
+
function buildSelfDerivedUsdMap(chainId, items, basePrices, tokenList) {
|
|
30875
|
+
const map = {};
|
|
30876
|
+
const set = (tokenLc, priceUSD) => {
|
|
30877
|
+
if (!Number.isFinite(priceUSD) || priceUSD === 0) return;
|
|
30878
|
+
const groupKey = tokenList[tokenLc]?.assetGroup ?? `${chainId}-${tokenLc}`;
|
|
30879
|
+
if (map[groupKey] == null) map[groupKey] = priceUSD;
|
|
30880
|
+
if (map[tokenLc] == null) map[tokenLc] = priceUSD;
|
|
30881
|
+
};
|
|
30882
|
+
for (const item of items) {
|
|
30883
|
+
for (const market of [item.market1, item.market2]) {
|
|
30884
|
+
if (!market) continue;
|
|
30885
|
+
const tokenLc = (market.inputTokenId ?? market.inputToken?.id ?? "").toLowerCase();
|
|
30886
|
+
if (!tokenLc) continue;
|
|
30887
|
+
const supply = safeNumber3(market.supply);
|
|
30888
|
+
const supplyUsd = market.supplyUsd != null ? Number(market.supplyUsd) : 0;
|
|
30889
|
+
if (supply > 0 && supplyUsd > 0) {
|
|
30890
|
+
set(tokenLc, supplyUsd / supply);
|
|
30891
|
+
continue;
|
|
30892
|
+
}
|
|
30893
|
+
const borrowed = safeNumber3(market.borrowed);
|
|
30894
|
+
const borrowedUsd = market.borrowedUsd != null ? Number(market.borrowedUsd) : 0;
|
|
30895
|
+
if (borrowed > 0 && borrowedUsd > 0) {
|
|
30896
|
+
set(tokenLc, borrowedUsd / borrowed);
|
|
30897
|
+
}
|
|
30898
|
+
}
|
|
30899
|
+
}
|
|
30900
|
+
for (const [k, v] of Object.entries(basePrices)) {
|
|
30901
|
+
if (Number.isFinite(v) && v > 0) map[k] = v;
|
|
30902
|
+
}
|
|
30903
|
+
return map;
|
|
30904
|
+
}
|
|
30872
30905
|
function safeNumber3(v) {
|
|
30873
30906
|
if (v == null) return 0;
|
|
30874
30907
|
const n = typeof v === "number" ? v : Number(v);
|
|
@@ -30968,6 +31001,51 @@ async function fetchSiloV3GraphQLMarkets(chainId) {
|
|
|
30968
31001
|
return null;
|
|
30969
31002
|
}
|
|
30970
31003
|
}
|
|
31004
|
+
async function fetchSiloV3GraphQLPrices(chainId, basePrices = {}, tokenList = {}) {
|
|
31005
|
+
const items = await fetchSiloV3GraphQLMarkets(chainId);
|
|
31006
|
+
if (items == null) return null;
|
|
31007
|
+
const usdPrices = buildSelfDerivedUsdMap2(chainId, items, basePrices, tokenList);
|
|
31008
|
+
const context = { chainId, usdPrices, tokenList };
|
|
31009
|
+
const entries = parseSiloV3GraphQLResults(items, context);
|
|
31010
|
+
if (entries.length === 0) {
|
|
31011
|
+
console.warn(
|
|
31012
|
+
`[silo-v3-gql] chain ${chainId}: ${items.length} markets fetched but 0 price entries produced`
|
|
31013
|
+
);
|
|
31014
|
+
return null;
|
|
31015
|
+
}
|
|
31016
|
+
return entries;
|
|
31017
|
+
}
|
|
31018
|
+
function buildSelfDerivedUsdMap2(chainId, items, basePrices, tokenList) {
|
|
31019
|
+
const map = {};
|
|
31020
|
+
const set = (tokenLc, priceUSD) => {
|
|
31021
|
+
if (!Number.isFinite(priceUSD) || priceUSD === 0) return;
|
|
31022
|
+
const groupKey = tokenList[tokenLc]?.assetGroup ?? `${chainId}-${tokenLc}`;
|
|
31023
|
+
if (map[groupKey] == null) map[groupKey] = priceUSD;
|
|
31024
|
+
if (map[tokenLc] == null) map[tokenLc] = priceUSD;
|
|
31025
|
+
};
|
|
31026
|
+
for (const item of items) {
|
|
31027
|
+
for (const market of [item.market1, item.market2]) {
|
|
31028
|
+
if (!market) continue;
|
|
31029
|
+
const tokenLc = (market.inputTokenId ?? market.inputToken?.id ?? "").toLowerCase();
|
|
31030
|
+
if (!tokenLc) continue;
|
|
31031
|
+
const supply = safeNumber4(market.supply);
|
|
31032
|
+
const supplyUsd = market.supplyUsd != null ? Number(market.supplyUsd) : 0;
|
|
31033
|
+
if (supply > 0 && supplyUsd > 0) {
|
|
31034
|
+
set(tokenLc, supplyUsd / supply);
|
|
31035
|
+
continue;
|
|
31036
|
+
}
|
|
31037
|
+
const borrowed = safeNumber4(market.borrowed);
|
|
31038
|
+
const borrowedUsd = market.borrowedUsd != null ? Number(market.borrowedUsd) : 0;
|
|
31039
|
+
if (borrowed > 0 && borrowedUsd > 0) {
|
|
31040
|
+
set(tokenLc, borrowedUsd / borrowed);
|
|
31041
|
+
}
|
|
31042
|
+
}
|
|
31043
|
+
}
|
|
31044
|
+
for (const [k, v] of Object.entries(basePrices)) {
|
|
31045
|
+
if (Number.isFinite(v) && v > 0) map[k] = v;
|
|
31046
|
+
}
|
|
31047
|
+
return map;
|
|
31048
|
+
}
|
|
30971
31049
|
function safeNumber4(v) {
|
|
30972
31050
|
if (v == null) return 0;
|
|
30973
31051
|
const n = typeof v === "number" ? v : Number(v);
|
|
@@ -31295,8 +31373,8 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
31295
31373
|
}
|
|
31296
31374
|
const chainBatchSize = batchSize?.[chainId];
|
|
31297
31375
|
const morphoGqlPromise = isActive("morpho") ? fetchMorphoGraphQLPrices(chainId) : Promise.resolve(null);
|
|
31298
|
-
const siloV2GqlPromise =
|
|
31299
|
-
const siloV3GqlPromise =
|
|
31376
|
+
const siloV2GqlPromise = isActive("silov2") ? fetchSiloV2GraphQLPrices(chainId, basePrices, tokenList) : Promise.resolve(null);
|
|
31377
|
+
const siloV3GqlPromise = isActive("silov3") ? fetchSiloV3GraphQLPrices(chainId, basePrices, tokenList) : Promise.resolve(null);
|
|
31300
31378
|
const [
|
|
31301
31379
|
aaveData,
|
|
31302
31380
|
compoundV2Data,
|
|
@@ -31305,8 +31383,8 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
31305
31383
|
eulerData,
|
|
31306
31384
|
aaveV4Data,
|
|
31307
31385
|
morphoGqlEntries,
|
|
31308
|
-
|
|
31309
|
-
|
|
31386
|
+
siloV2GqlEntries,
|
|
31387
|
+
siloV3GqlEntries
|
|
31310
31388
|
] = await Promise.all([
|
|
31311
31389
|
executeGroup(
|
|
31312
31390
|
aaveGroup,
|
|
@@ -31360,12 +31438,12 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
31360
31438
|
siloV2GqlPromise,
|
|
31361
31439
|
siloV3GqlPromise
|
|
31362
31440
|
]);
|
|
31363
|
-
if (
|
|
31441
|
+
if (siloV2GqlEntries == null && siloV2Group.calls.length > 0) {
|
|
31364
31442
|
console.warn(
|
|
31365
|
-
`[prices] chain ${chainId}: Silo v2 GraphQL
|
|
31443
|
+
`[prices] chain ${chainId}: Silo v2 GraphQL returned null, falling back to on-chain (${siloV2Group.trackers.length} trackers)`
|
|
31366
31444
|
);
|
|
31367
31445
|
}
|
|
31368
|
-
const siloV2Data =
|
|
31446
|
+
const siloV2Data = siloV2GqlEntries != null ? { results: [], error: void 0 } : await executeGroup(
|
|
31369
31447
|
siloV2Group,
|
|
31370
31448
|
chainId,
|
|
31371
31449
|
chainBatchSize,
|
|
@@ -31373,12 +31451,12 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
31373
31451
|
allowFailure,
|
|
31374
31452
|
rpcOverrides
|
|
31375
31453
|
);
|
|
31376
|
-
if (
|
|
31454
|
+
if (siloV3GqlEntries == null && siloV3Group.calls.length > 0) {
|
|
31377
31455
|
console.warn(
|
|
31378
|
-
`[prices] chain ${chainId}: Silo v3 GraphQL
|
|
31456
|
+
`[prices] chain ${chainId}: Silo v3 GraphQL returned null, falling back to on-chain (${siloV3Group.trackers.length} trackers)`
|
|
31379
31457
|
);
|
|
31380
31458
|
}
|
|
31381
|
-
const siloV3Data =
|
|
31459
|
+
const siloV3Data = siloV3GqlEntries != null ? { results: [], error: void 0 } : await executeGroup(
|
|
31382
31460
|
siloV3Group,
|
|
31383
31461
|
chainId,
|
|
31384
31462
|
chainBatchSize,
|
|
@@ -31407,8 +31485,8 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
31407
31485
|
{ group: listaGroup, data: listaData },
|
|
31408
31486
|
{ group: eulerGroup, data: eulerData },
|
|
31409
31487
|
{ group: aaveV4Group, data: aaveV4Data },
|
|
31410
|
-
...
|
|
31411
|
-
...
|
|
31488
|
+
...siloV2GqlEntries != null ? [] : [{ group: siloV2Group, data: siloV2Data }],
|
|
31489
|
+
...siloV3GqlEntries != null ? [] : [{ group: siloV3Group, data: siloV3Data }],
|
|
31412
31490
|
...useMorphoGql ? [] : [{ group: morphoGroup, data: morphoData }]
|
|
31413
31491
|
];
|
|
31414
31492
|
for (const { group, data } of groupResults) {
|
|
@@ -31493,16 +31571,14 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
31493
31571
|
true,
|
|
31494
31572
|
(t) => !!t.meta.baseAssetSource
|
|
31495
31573
|
);
|
|
31496
|
-
if (
|
|
31497
|
-
const context = { chainId, usdPrices, tokenList };
|
|
31498
|
-
const entries = parseSiloV2GraphQLResults(siloV2GqlItems, context);
|
|
31574
|
+
if (siloV2GqlEntries != null) {
|
|
31499
31575
|
const diag2 = {
|
|
31500
31576
|
lender: "SILO_V2 (GraphQL)",
|
|
31501
31577
|
callCount: 0,
|
|
31502
31578
|
failedCalls: 0,
|
|
31503
|
-
parsedEntries:
|
|
31579
|
+
parsedEntries: siloV2GqlEntries.length
|
|
31504
31580
|
};
|
|
31505
|
-
for (const entry of
|
|
31581
|
+
for (const entry of siloV2GqlEntries) {
|
|
31506
31582
|
const lender = entry.targetLender ?? "SILO_V2";
|
|
31507
31583
|
if (!chainResult[lender]) chainResult[lender] = [];
|
|
31508
31584
|
chainResult[lender].push(entry);
|
|
@@ -31514,16 +31590,14 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
31514
31590
|
} else {
|
|
31515
31591
|
parseTrackers(siloV2Group, siloV2Data.results);
|
|
31516
31592
|
}
|
|
31517
|
-
if (
|
|
31518
|
-
const context = { chainId, usdPrices, tokenList };
|
|
31519
|
-
const entries = parseSiloV3GraphQLResults(siloV3GqlItems, context);
|
|
31593
|
+
if (siloV3GqlEntries != null) {
|
|
31520
31594
|
const diag2 = {
|
|
31521
31595
|
lender: "SILO_V3 (GraphQL)",
|
|
31522
31596
|
callCount: 0,
|
|
31523
31597
|
failedCalls: 0,
|
|
31524
|
-
parsedEntries:
|
|
31598
|
+
parsedEntries: siloV3GqlEntries.length
|
|
31525
31599
|
};
|
|
31526
|
-
for (const entry of
|
|
31600
|
+
for (const entry of siloV3GqlEntries) {
|
|
31527
31601
|
const lender = entry.targetLender ?? "SILO_V3";
|
|
31528
31602
|
if (!chainResult[lender]) chainResult[lender] = [];
|
|
31529
31603
|
chainResult[lender].push(entry);
|