@1delta/margin-fetcher 0.0.228 → 0.0.230
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 +154 -95
- package/dist/index.js.map +1 -1
- package/dist/lending/public-data/fetchLenderAll.d.ts.map +1 -1
- package/dist/lending/public-data/silo-v2/convertPublic.d.ts.map +1 -1
- package/dist/lending/public-data/silo-v2/fetchPublic.d.ts +12 -0
- package/dist/lending/public-data/silo-v2/fetchPublic.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 +0 -9
- package/dist/lending/public-data/silo-v3/convertPublic.d.ts.map +1 -1
- package/dist/lending/public-data/silo-v3/publicCallParse.d.ts +0 -7
- package/dist/lending/public-data/silo-v3/publicCallParse.d.ts.map +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -7594,6 +7594,10 @@ var getLendersForChain = (c) => {
|
|
|
7594
7594
|
for (const market of siloChainPairs) {
|
|
7595
7595
|
lenders.push(siloV2LenderKey(market.siloConfig));
|
|
7596
7596
|
}
|
|
7597
|
+
const siloV3ChainPairs = siloMarketsV3()?.[c] ?? [];
|
|
7598
|
+
for (const market of siloV3ChainPairs) {
|
|
7599
|
+
lenders.push(siloV3LenderKey(market.siloConfig));
|
|
7600
|
+
}
|
|
7597
7601
|
const v4ChainSpokes = aaveV4Spokes()?.[c] ?? {};
|
|
7598
7602
|
for (const spokeAddr of Object.keys(v4ChainSpokes)) {
|
|
7599
7603
|
lenders.push(aaveV4SpokeLenderKey(spokeAddr));
|
|
@@ -18768,11 +18772,11 @@ var getSiloV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
18768
18772
|
const assetMeta = tokenList[tokenAddrLc];
|
|
18769
18773
|
const oracleKey = toOracleKey(assetMeta?.assetGroup ?? null) || toGenericPriceKey(tokenAddrLc, chainId);
|
|
18770
18774
|
const price = prices[oracleKey] ?? 0;
|
|
18771
|
-
const collateralLt = Number(other.lt) / 1e18;
|
|
18772
|
-
const collateralMaxLtv = Number(other.maxLtv) / 1e18;
|
|
18773
18775
|
const selfLt = Number(self.lt) / 1e18;
|
|
18774
|
-
const
|
|
18776
|
+
const selfMaxLtv = Number(self.maxLtv) / 1e18;
|
|
18777
|
+
const otherLt = Number(other.lt) / 1e18;
|
|
18775
18778
|
const collateralActive = selfLt > 0;
|
|
18779
|
+
const borrowingEnabled = otherLt > 0;
|
|
18776
18780
|
const marketUid = createMarketUid(chainId, lender, self.silo);
|
|
18777
18781
|
out[marketUid] = {
|
|
18778
18782
|
marketUid,
|
|
@@ -18815,11 +18819,11 @@ var getSiloV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
18815
18819
|
config: {
|
|
18816
18820
|
0: {
|
|
18817
18821
|
category: 0,
|
|
18818
|
-
borrowCollateralFactor:
|
|
18819
|
-
collateralFactor:
|
|
18822
|
+
borrowCollateralFactor: selfMaxLtv,
|
|
18823
|
+
collateralFactor: selfLt,
|
|
18820
18824
|
borrowFactor: 1,
|
|
18821
|
-
collateralDisabled: !
|
|
18822
|
-
debtDisabled: !
|
|
18825
|
+
collateralDisabled: !collateralActive,
|
|
18826
|
+
debtDisabled: !borrowingEnabled
|
|
18823
18827
|
}
|
|
18824
18828
|
},
|
|
18825
18829
|
collateralActive,
|
|
@@ -18883,6 +18887,7 @@ function buildSiloV3LenderReserveCall(_chainId, lender) {
|
|
|
18883
18887
|
}
|
|
18884
18888
|
|
|
18885
18889
|
// src/lending/public-data/silo-v3/publicCallParse.ts
|
|
18890
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
18886
18891
|
var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields, tokenList = {}) => {
|
|
18887
18892
|
const market = getSiloV3MarketEntry(chainId, lender);
|
|
18888
18893
|
if (!market) return [() => void 0, 0];
|
|
@@ -18919,11 +18924,11 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
18919
18924
|
const assetMeta = tokenList[tokenAddrLc];
|
|
18920
18925
|
const oracleKey = toOracleKey(assetMeta?.assetGroup ?? null) || toGenericPriceKey(tokenAddrLc, chainId);
|
|
18921
18926
|
const price = prices[oracleKey] ?? 0;
|
|
18922
|
-
const collateralLt = Number(other.lt) / 1e18;
|
|
18923
|
-
const collateralMaxLtv = Number(other.maxLtv) / 1e18;
|
|
18924
18927
|
const selfLt = Number(self.lt) / 1e18;
|
|
18925
|
-
const
|
|
18928
|
+
const selfMaxLtv = Number(self.maxLtv) / 1e18;
|
|
18929
|
+
const otherLt = Number(other.lt) / 1e18;
|
|
18926
18930
|
const collateralActive = selfLt > 0;
|
|
18931
|
+
const borrowingEnabled = otherLt > 0;
|
|
18927
18932
|
const marketUid = createMarketUid(chainId, lender, self.silo);
|
|
18928
18933
|
out[marketUid] = {
|
|
18929
18934
|
marketUid,
|
|
@@ -18958,11 +18963,11 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
18958
18963
|
config: {
|
|
18959
18964
|
0: {
|
|
18960
18965
|
category: 0,
|
|
18961
|
-
borrowCollateralFactor:
|
|
18962
|
-
collateralFactor:
|
|
18966
|
+
borrowCollateralFactor: selfMaxLtv,
|
|
18967
|
+
collateralFactor: selfLt,
|
|
18963
18968
|
borrowFactor: 1,
|
|
18964
|
-
collateralDisabled: !
|
|
18965
|
-
debtDisabled: !
|
|
18969
|
+
collateralDisabled: !collateralActive,
|
|
18970
|
+
debtDisabled: !borrowingEnabled
|
|
18966
18971
|
}
|
|
18967
18972
|
},
|
|
18968
18973
|
collateralActive,
|
|
@@ -18976,8 +18981,8 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
|
|
|
18976
18981
|
silo: self.silo,
|
|
18977
18982
|
counterpartySilo: other.silo,
|
|
18978
18983
|
siloConfig: market.siloConfig,
|
|
18979
|
-
oracle: self.solvencyOracle,
|
|
18980
|
-
irm: self.interestRateModel,
|
|
18984
|
+
oracle: self.solvencyOracle || ZERO_ADDRESS,
|
|
18985
|
+
irm: self.interestRateModel || ZERO_ADDRESS,
|
|
18981
18986
|
shareTokens: {
|
|
18982
18987
|
collateral: self.collateralShareToken,
|
|
18983
18988
|
protected: self.protectedShareToken,
|
|
@@ -19308,6 +19313,61 @@ query GetSilos {
|
|
|
19308
19313
|
}
|
|
19309
19314
|
}
|
|
19310
19315
|
`;
|
|
19316
|
+
var liteQuery = (chainId, limit) => `
|
|
19317
|
+
query GetSilosLite {
|
|
19318
|
+
silos(where: {chainId_in: [${chainId}]}, limit: ${limit}) {
|
|
19319
|
+
items {
|
|
19320
|
+
configAddress
|
|
19321
|
+
protocol { protocolVersion }
|
|
19322
|
+
market1 {
|
|
19323
|
+
index
|
|
19324
|
+
inputTokenId
|
|
19325
|
+
supply
|
|
19326
|
+
borrowed
|
|
19327
|
+
supplyUsd
|
|
19328
|
+
borrowedUsd
|
|
19329
|
+
solvencyOracleAddress
|
|
19330
|
+
solvencyOracle { quote quoteTokenId }
|
|
19331
|
+
}
|
|
19332
|
+
market2 {
|
|
19333
|
+
index
|
|
19334
|
+
inputTokenId
|
|
19335
|
+
supply
|
|
19336
|
+
borrowed
|
|
19337
|
+
supplyUsd
|
|
19338
|
+
borrowedUsd
|
|
19339
|
+
solvencyOracleAddress
|
|
19340
|
+
solvencyOracle { quote quoteTokenId }
|
|
19341
|
+
}
|
|
19342
|
+
}
|
|
19343
|
+
}
|
|
19344
|
+
}
|
|
19345
|
+
`;
|
|
19346
|
+
async function fetchSiloMarketsLite(chainId, options) {
|
|
19347
|
+
if (!SILO_API_SUPPORTED_CHAIN_IDS.has(chainId)) return [];
|
|
19348
|
+
const limit = options?.limit ?? 500;
|
|
19349
|
+
const response = await fetch(BASE_URL2, {
|
|
19350
|
+
method: "POST",
|
|
19351
|
+
headers: { "Content-Type": "application/json" },
|
|
19352
|
+
body: JSON.stringify({ query: liteQuery(chainId, limit) })
|
|
19353
|
+
});
|
|
19354
|
+
if (!response.ok) {
|
|
19355
|
+
throw new Error(
|
|
19356
|
+
`[silo-api] Network error: ${response.status} - ${response.statusText}`
|
|
19357
|
+
);
|
|
19358
|
+
}
|
|
19359
|
+
const payload = await response.json();
|
|
19360
|
+
if (payload?.errors?.length) {
|
|
19361
|
+
throw new Error(
|
|
19362
|
+
`[silo-api] GraphQL error: ${payload.errors.map((e) => e?.message).join("; ")}`
|
|
19363
|
+
);
|
|
19364
|
+
}
|
|
19365
|
+
const items = payload?.data?.silos?.items ?? [];
|
|
19366
|
+
if (!options?.protocolVersion) return items;
|
|
19367
|
+
return items.filter(
|
|
19368
|
+
(s) => s.protocol?.protocolVersion === options.protocolVersion
|
|
19369
|
+
);
|
|
19370
|
+
}
|
|
19311
19371
|
async function fetchSiloMarkets(chainId, options) {
|
|
19312
19372
|
if (!SILO_API_SUPPORTED_CHAIN_IDS.has(chainId)) return [];
|
|
19313
19373
|
const limit = options?.limit ?? 500;
|
|
@@ -19364,21 +19424,20 @@ function convertSiloMarketsToPublicResponse(apiItems, chainId, prices, additiona
|
|
|
19364
19424
|
const totalDebt = safeNumber(api.borrowed);
|
|
19365
19425
|
const totalLiquidity = totalDeposits - totalDebt;
|
|
19366
19426
|
const utilization = totalDeposits > 0 ? totalDebt / totalDeposits : safeNumber(api.utilization);
|
|
19367
|
-
const variableBorrowRatePct = safeNumber(api.borrowRate)
|
|
19368
|
-
const depositRatePct = safeNumber(api.depositRate)
|
|
19427
|
+
const variableBorrowRatePct = safeNumber(api.borrowRate);
|
|
19428
|
+
const depositRatePct = safeNumber(api.depositRate);
|
|
19369
19429
|
const assetMeta = tokenList[tokenAddrLc];
|
|
19370
19430
|
const oracleKey = toOracleKey(assetMeta?.assetGroup ?? null) || toGenericPriceKey(tokenAddrLc, chainId);
|
|
19371
19431
|
const fallbackPrice = prices[oracleKey] ?? 0;
|
|
19372
19432
|
const totalDepositsUSD = api.supplyUsd != null && api.supplyUsd > 0 ? api.supplyUsd : totalDeposits * fallbackPrice;
|
|
19373
19433
|
const totalDebtUSD = api.borrowedUsd != null && api.borrowedUsd > 0 ? api.borrowedUsd : totalDebt * fallbackPrice;
|
|
19374
19434
|
const totalLiquidityUSD = Math.max(totalDepositsUSD - totalDebtUSD, 0);
|
|
19375
|
-
const
|
|
19376
|
-
const collateralMaxLtv = safeLtvOrFee(api, "maxLtv", other.maxLtv);
|
|
19435
|
+
const otherApi = sides[0].api === api ? apiSide1 : apiSide0;
|
|
19377
19436
|
const selfLt = bigintToLtv(api.lt ?? self.lt);
|
|
19378
|
-
const
|
|
19379
|
-
const
|
|
19380
|
-
const borrowingEnabled = (collateralLtFromApi || collateralLt) > 0;
|
|
19437
|
+
const selfMaxLtv = bigintToLtv(api.maxLtv ?? self.maxLtv);
|
|
19438
|
+
const otherLt = bigintToLtv(otherApi.lt ?? other.lt);
|
|
19381
19439
|
const collateralActive = selfLt > 0;
|
|
19440
|
+
const borrowingEnabled = otherLt > 0;
|
|
19382
19441
|
const siloAddrLc = self.silo.toLowerCase();
|
|
19383
19442
|
const marketUid = createMarketUid(chainId, lenderKey, siloAddrLc);
|
|
19384
19443
|
data[marketUid] = {
|
|
@@ -19416,11 +19475,11 @@ function convertSiloMarketsToPublicResponse(apiItems, chainId, prices, additiona
|
|
|
19416
19475
|
config: {
|
|
19417
19476
|
0: {
|
|
19418
19477
|
category: 0,
|
|
19419
|
-
borrowCollateralFactor:
|
|
19420
|
-
collateralFactor:
|
|
19478
|
+
borrowCollateralFactor: selfMaxLtv,
|
|
19479
|
+
collateralFactor: selfLt,
|
|
19421
19480
|
borrowFactor: 1,
|
|
19422
|
-
collateralDisabled: !
|
|
19423
|
-
debtDisabled: !
|
|
19481
|
+
collateralDisabled: !collateralActive,
|
|
19482
|
+
debtDisabled: !borrowingEnabled
|
|
19424
19483
|
}
|
|
19425
19484
|
},
|
|
19426
19485
|
collateralActive,
|
|
@@ -19469,11 +19528,9 @@ function bigintToLtv(v) {
|
|
|
19469
19528
|
return Number.isFinite(n) ? n / 1e18 : 0;
|
|
19470
19529
|
}
|
|
19471
19530
|
}
|
|
19472
|
-
function safeLtvOrFee(api, field5, fallback) {
|
|
19473
|
-
return bigintToLtv(api[field5] ?? fallback);
|
|
19474
|
-
}
|
|
19475
19531
|
|
|
19476
19532
|
// src/lending/public-data/silo-v3/convertPublic.ts
|
|
19533
|
+
var ZERO_ADDRESS2 = "0x0000000000000000000000000000000000000000";
|
|
19477
19534
|
function convertSiloV3MarketsToPublicResponse(apiItems, chainId, prices, additionalYields = {
|
|
19478
19535
|
intrinsicYields: {},
|
|
19479
19536
|
lenderRewards: {},
|
|
@@ -19503,21 +19560,20 @@ function convertSiloV3MarketsToPublicResponse(apiItems, chainId, prices, additio
|
|
|
19503
19560
|
const totalDebt = safeNumber2(api.borrowed);
|
|
19504
19561
|
const totalLiquidity = totalDeposits - totalDebt;
|
|
19505
19562
|
const utilization = totalDeposits > 0 ? totalDebt / totalDeposits : safeNumber2(api.utilization);
|
|
19506
|
-
const variableBorrowRatePct = safeNumber2(api.borrowRate)
|
|
19507
|
-
const depositRatePct = safeNumber2(api.depositRate)
|
|
19563
|
+
const variableBorrowRatePct = safeNumber2(api.borrowRate);
|
|
19564
|
+
const depositRatePct = safeNumber2(api.depositRate);
|
|
19508
19565
|
const assetMeta = tokenList[tokenAddrLc];
|
|
19509
19566
|
const oracleKey = toOracleKey(assetMeta?.assetGroup ?? null) || toGenericPriceKey(tokenAddrLc, chainId);
|
|
19510
19567
|
const fallbackPrice = prices[oracleKey] ?? 0;
|
|
19511
19568
|
const totalDepositsUSD = api.supplyUsd != null && api.supplyUsd > 0 ? api.supplyUsd : totalDeposits * fallbackPrice;
|
|
19512
19569
|
const totalDebtUSD = api.borrowedUsd != null && api.borrowedUsd > 0 ? api.borrowedUsd : totalDebt * fallbackPrice;
|
|
19513
19570
|
const totalLiquidityUSD = Math.max(totalDepositsUSD - totalDebtUSD, 0);
|
|
19514
|
-
const
|
|
19515
|
-
const collateralMaxLtv = safeLtvOrFee2(api, "maxLtv", other.maxLtv);
|
|
19571
|
+
const otherApi = sides[0].api === api ? apiSide1 : apiSide0;
|
|
19516
19572
|
const selfLt = bigintToLtv2(api.lt ?? self.lt);
|
|
19517
|
-
const
|
|
19518
|
-
const
|
|
19519
|
-
const borrowingEnabled = (collateralLtFromApi || collateralLt) > 0;
|
|
19573
|
+
const selfMaxLtv = bigintToLtv2(api.maxLtv ?? self.maxLtv);
|
|
19574
|
+
const otherLt = bigintToLtv2(otherApi.lt ?? other.lt);
|
|
19520
19575
|
const collateralActive = selfLt > 0;
|
|
19576
|
+
const borrowingEnabled = otherLt > 0;
|
|
19521
19577
|
const siloAddrLc = self.silo.toLowerCase();
|
|
19522
19578
|
const marketUid = createMarketUid(chainId, lenderKey, siloAddrLc);
|
|
19523
19579
|
data[marketUid] = {
|
|
@@ -19553,11 +19609,11 @@ function convertSiloV3MarketsToPublicResponse(apiItems, chainId, prices, additio
|
|
|
19553
19609
|
config: {
|
|
19554
19610
|
0: {
|
|
19555
19611
|
category: 0,
|
|
19556
|
-
borrowCollateralFactor:
|
|
19557
|
-
collateralFactor:
|
|
19612
|
+
borrowCollateralFactor: selfMaxLtv,
|
|
19613
|
+
collateralFactor: selfLt,
|
|
19558
19614
|
borrowFactor: 1,
|
|
19559
|
-
collateralDisabled: !
|
|
19560
|
-
debtDisabled: !
|
|
19615
|
+
collateralDisabled: !collateralActive,
|
|
19616
|
+
debtDisabled: !borrowingEnabled
|
|
19561
19617
|
}
|
|
19562
19618
|
},
|
|
19563
19619
|
collateralActive,
|
|
@@ -19571,8 +19627,8 @@ function convertSiloV3MarketsToPublicResponse(apiItems, chainId, prices, additio
|
|
|
19571
19627
|
silo: self.silo.toLowerCase(),
|
|
19572
19628
|
counterpartySilo: other.silo.toLowerCase(),
|
|
19573
19629
|
siloConfig: registryEntry.siloConfig.toLowerCase(),
|
|
19574
|
-
oracle: (api.solvencyOracleAddress
|
|
19575
|
-
irm: (api.interestRateModelId
|
|
19630
|
+
oracle: (api.solvencyOracleAddress || self.solvencyOracle || ZERO_ADDRESS2).toLowerCase(),
|
|
19631
|
+
irm: (api.interestRateModelId || self.interestRateModel || ZERO_ADDRESS2).toLowerCase(),
|
|
19576
19632
|
shareTokens: {
|
|
19577
19633
|
collateral: self.collateralShareToken,
|
|
19578
19634
|
protected: self.protectedShareToken,
|
|
@@ -19606,9 +19662,6 @@ function bigintToLtv2(v) {
|
|
|
19606
19662
|
return Number.isFinite(n) ? n / 1e18 : 0;
|
|
19607
19663
|
}
|
|
19608
19664
|
}
|
|
19609
|
-
function safeLtvOrFee2(api, field5, fallback) {
|
|
19610
|
-
return bigintToLtv2(api[field5] ?? fallback);
|
|
19611
|
-
}
|
|
19612
19665
|
|
|
19613
19666
|
// src/lending/public-data/fetchLenderExt.ts
|
|
19614
19667
|
async function getLenderDataFromApi(lender, chainId, prices, additionalYields, includeUnlisted = false) {
|
|
@@ -19777,40 +19830,46 @@ var getLenderPublicDataAll = async (chainId, lenders, prices, additionalYields,
|
|
|
19777
19830
|
const lendersApi = lenders.filter(
|
|
19778
19831
|
(l) => lenderApiOnly(l, chainId) || lenderApiWithOnChainFallback(l, chainId)
|
|
19779
19832
|
);
|
|
19780
|
-
|
|
19781
|
-
|
|
19782
|
-
|
|
19783
|
-
|
|
19784
|
-
|
|
19785
|
-
|
|
19786
|
-
|
|
19787
|
-
|
|
19788
|
-
|
|
19789
|
-
|
|
19790
|
-
|
|
19791
|
-
|
|
19792
|
-
|
|
19793
|
-
|
|
19794
|
-
|
|
19795
|
-
|
|
19796
|
-
|
|
19797
|
-
const [onChainResult, apiResult] = await Promise.allSettled([
|
|
19798
|
-
onChain,
|
|
19799
|
-
api
|
|
19800
|
-
]);
|
|
19801
|
-
const onChainRes = onChainResult.status === "fulfilled" ? onChainResult.value : {};
|
|
19802
|
-
const apiRes = apiResult.status === "fulfilled" ? apiResult.value : {};
|
|
19803
|
-
if (onChainResult.status === "rejected") {
|
|
19804
|
-
console.warn(
|
|
19805
|
-
`[lending] on-chain fetch failed for chain ${chainId}:`,
|
|
19806
|
-
onChainResult.reason?.message ?? onChainResult.reason
|
|
19807
|
-
);
|
|
19833
|
+
let apiRes = {};
|
|
19834
|
+
if (lendersApi.length > 0) {
|
|
19835
|
+
try {
|
|
19836
|
+
apiRes = await getLenderPublicDataViaApi(
|
|
19837
|
+
chainId,
|
|
19838
|
+
lendersApi,
|
|
19839
|
+
prices,
|
|
19840
|
+
additionalYields,
|
|
19841
|
+
tokenList,
|
|
19842
|
+
includeUnlistedMorphoMarkets
|
|
19843
|
+
);
|
|
19844
|
+
} catch (e) {
|
|
19845
|
+
console.warn(
|
|
19846
|
+
`[lending] API fetch failed for chain ${chainId}:`,
|
|
19847
|
+
e?.message ?? e
|
|
19848
|
+
);
|
|
19849
|
+
}
|
|
19808
19850
|
}
|
|
19809
|
-
|
|
19810
|
-
|
|
19811
|
-
|
|
19812
|
-
|
|
19813
|
-
|
|
19851
|
+
const lendersOnChain = lenders.filter((l) => {
|
|
19852
|
+
if (lenderApiOnly(l, chainId)) return false;
|
|
19853
|
+
if (lenderApiWithOnChainFallback(l, chainId) && apiRes[l]) return false;
|
|
19854
|
+
return true;
|
|
19855
|
+
});
|
|
19856
|
+
let onChainRes = {};
|
|
19857
|
+
if (lendersOnChain.length > 0) {
|
|
19858
|
+
try {
|
|
19859
|
+
onChainRes = await getLenderPublicData(
|
|
19860
|
+
chainId,
|
|
19861
|
+
lendersOnChain,
|
|
19862
|
+
prices,
|
|
19863
|
+
additionalYields,
|
|
19864
|
+
multicallRetry,
|
|
19865
|
+
tokenList
|
|
19866
|
+
);
|
|
19867
|
+
} catch (e) {
|
|
19868
|
+
console.warn(
|
|
19869
|
+
`[lending] on-chain fetch failed for chain ${chainId}:`,
|
|
19870
|
+
e?.message ?? e
|
|
19871
|
+
);
|
|
19872
|
+
}
|
|
19814
19873
|
}
|
|
19815
19874
|
return { ...onChainRes, ...apiRes };
|
|
19816
19875
|
};
|
|
@@ -30462,7 +30521,7 @@ var SiloOracleAbi = [
|
|
|
30462
30521
|
type: "function"
|
|
30463
30522
|
}
|
|
30464
30523
|
];
|
|
30465
|
-
var
|
|
30524
|
+
var ZERO_ADDRESS3 = "0x0000000000000000000000000000000000000000";
|
|
30466
30525
|
function lookupUSD(context, asset) {
|
|
30467
30526
|
const lc = asset.toLowerCase();
|
|
30468
30527
|
const groupKey = context.tokenList?.[lc]?.assetGroup ?? `${context.chainId}-${lc}`;
|
|
@@ -30474,7 +30533,7 @@ function getSiloV2Calls(chainId) {
|
|
|
30474
30533
|
const tokensWithRealOracle = /* @__PURE__ */ new Set();
|
|
30475
30534
|
for (const market of allMarkets) {
|
|
30476
30535
|
for (const half of [market.silo0, market.silo1]) {
|
|
30477
|
-
if (half.solvencyOracle && half.solvencyOracle !==
|
|
30536
|
+
if (half.solvencyOracle && half.solvencyOracle !== ZERO_ADDRESS3) {
|
|
30478
30537
|
tokensWithRealOracle.add(half.token.toLowerCase());
|
|
30479
30538
|
}
|
|
30480
30539
|
}
|
|
@@ -30487,7 +30546,7 @@ function getSiloV2Calls(chainId) {
|
|
|
30487
30546
|
const lenderKey = siloV2LenderKey(market.siloConfig);
|
|
30488
30547
|
const halves = [market.silo0, market.silo1];
|
|
30489
30548
|
const isStatic = halves.map(
|
|
30490
|
-
(h) => !h.solvencyOracle || h.solvencyOracle ===
|
|
30549
|
+
(h) => !h.solvencyOracle || h.solvencyOracle === ZERO_ADDRESS3
|
|
30491
30550
|
);
|
|
30492
30551
|
if (isStatic[0] && isStatic[1]) {
|
|
30493
30552
|
const t0 = halves[0].token.toLowerCase();
|
|
@@ -30507,7 +30566,7 @@ function getSiloV2Calls(chainId) {
|
|
|
30507
30566
|
decimals: half.decimals,
|
|
30508
30567
|
silo: half.silo.toLowerCase(),
|
|
30509
30568
|
lenderKey,
|
|
30510
|
-
oracle:
|
|
30569
|
+
oracle: ZERO_ADDRESS3,
|
|
30511
30570
|
partnerToken: partnerLc,
|
|
30512
30571
|
isStatic: true
|
|
30513
30572
|
});
|
|
@@ -30635,7 +30694,7 @@ var SiloOracleAbi2 = [
|
|
|
30635
30694
|
type: "function"
|
|
30636
30695
|
}
|
|
30637
30696
|
];
|
|
30638
|
-
var
|
|
30697
|
+
var ZERO_ADDRESS4 = "0x0000000000000000000000000000000000000000";
|
|
30639
30698
|
function lookupUSD2(context, asset) {
|
|
30640
30699
|
const lc = asset.toLowerCase();
|
|
30641
30700
|
const groupKey = context.tokenList?.[lc]?.assetGroup ?? `${context.chainId}-${lc}`;
|
|
@@ -30647,7 +30706,7 @@ function getSiloV3Calls(chainId) {
|
|
|
30647
30706
|
const tokensWithRealOracle = /* @__PURE__ */ new Set();
|
|
30648
30707
|
for (const market of allMarkets) {
|
|
30649
30708
|
for (const half of [market.silo0, market.silo1]) {
|
|
30650
|
-
if (half.solvencyOracle && half.solvencyOracle !==
|
|
30709
|
+
if (half.solvencyOracle && half.solvencyOracle !== ZERO_ADDRESS4) {
|
|
30651
30710
|
tokensWithRealOracle.add(half.token.toLowerCase());
|
|
30652
30711
|
}
|
|
30653
30712
|
}
|
|
@@ -30660,7 +30719,7 @@ function getSiloV3Calls(chainId) {
|
|
|
30660
30719
|
const lenderKey = siloV3LenderKey(market.siloConfig);
|
|
30661
30720
|
const halves = [market.silo0, market.silo1];
|
|
30662
30721
|
const isStatic = halves.map(
|
|
30663
|
-
(h) => !h.solvencyOracle || h.solvencyOracle ===
|
|
30722
|
+
(h) => !h.solvencyOracle || h.solvencyOracle === ZERO_ADDRESS4
|
|
30664
30723
|
);
|
|
30665
30724
|
if (isStatic[0] && isStatic[1]) {
|
|
30666
30725
|
const t0 = halves[0].token.toLowerCase();
|
|
@@ -30680,7 +30739,7 @@ function getSiloV3Calls(chainId) {
|
|
|
30680
30739
|
decimals: half.decimals,
|
|
30681
30740
|
silo: half.silo.toLowerCase(),
|
|
30682
30741
|
lenderKey,
|
|
30683
|
-
oracle:
|
|
30742
|
+
oracle: ZERO_ADDRESS4,
|
|
30684
30743
|
partnerToken: partnerLc,
|
|
30685
30744
|
isStatic: true
|
|
30686
30745
|
});
|
|
@@ -30792,7 +30851,7 @@ var siloV3Fetcher = {
|
|
|
30792
30851
|
async function fetchSiloV2GraphQLMarkets(chainId) {
|
|
30793
30852
|
if (!SILO_API_SUPPORTED_CHAIN_IDS.has(chainId)) return null;
|
|
30794
30853
|
try {
|
|
30795
|
-
const items = await
|
|
30854
|
+
const items = await fetchSiloMarketsLite(chainId, { protocolVersion: "v2" });
|
|
30796
30855
|
return items;
|
|
30797
30856
|
} catch (e) {
|
|
30798
30857
|
console.warn(
|
|
@@ -30813,7 +30872,7 @@ function lookupUSD3(context, asset) {
|
|
|
30813
30872
|
return context.usdPrices[groupKey] ?? context.usdPrices[lc] ?? 0;
|
|
30814
30873
|
}
|
|
30815
30874
|
function parseSiloV2GraphQLResults(items, context) {
|
|
30816
|
-
const
|
|
30875
|
+
const ZERO_ADDRESS5 = "0x0000000000000000000000000000000000000000";
|
|
30817
30876
|
const out = [];
|
|
30818
30877
|
const seen = /* @__PURE__ */ new Set();
|
|
30819
30878
|
for (const item of items) {
|
|
@@ -30836,8 +30895,8 @@ function parseSiloV2GraphQLResults(items, context) {
|
|
|
30836
30895
|
const partnerTokenLc = other.token.toLowerCase();
|
|
30837
30896
|
const dedupKey = `${lenderKey}:${tokenLc}`;
|
|
30838
30897
|
if (seen.has(dedupKey)) continue;
|
|
30839
|
-
const oracleAddr = (side.solvencyOracleAddress ?? side.solvencyOracle?.id ?? self.solvencyOracle ??
|
|
30840
|
-
const isStatic = !oracleAddr || oracleAddr ===
|
|
30898
|
+
const oracleAddr = (side.solvencyOracleAddress ?? side.solvencyOracle?.id ?? self.solvencyOracle ?? ZERO_ADDRESS5).toLowerCase();
|
|
30899
|
+
const isStatic = !oracleAddr || oracleAddr === ZERO_ADDRESS5;
|
|
30841
30900
|
const siloAddrLc = self.silo.toLowerCase();
|
|
30842
30901
|
try {
|
|
30843
30902
|
let priceUSD = 0;
|
|
@@ -30891,7 +30950,7 @@ function parseSiloV2GraphQLResults(items, context) {
|
|
|
30891
30950
|
async function fetchSiloV3GraphQLMarkets(chainId) {
|
|
30892
30951
|
if (!SILO_API_SUPPORTED_CHAIN_IDS.has(chainId)) return null;
|
|
30893
30952
|
try {
|
|
30894
|
-
const items = await
|
|
30953
|
+
const items = await fetchSiloMarketsLite(chainId, { protocolVersion: "v3" });
|
|
30895
30954
|
return items;
|
|
30896
30955
|
} catch (e) {
|
|
30897
30956
|
console.warn(
|
|
@@ -30912,7 +30971,7 @@ function lookupUSD4(context, asset) {
|
|
|
30912
30971
|
return context.usdPrices[groupKey] ?? context.usdPrices[lc] ?? 0;
|
|
30913
30972
|
}
|
|
30914
30973
|
function parseSiloV3GraphQLResults(items, context) {
|
|
30915
|
-
const
|
|
30974
|
+
const ZERO_ADDRESS5 = "0x0000000000000000000000000000000000000000";
|
|
30916
30975
|
const out = [];
|
|
30917
30976
|
const seen = /* @__PURE__ */ new Set();
|
|
30918
30977
|
for (const item of items) {
|
|
@@ -30935,8 +30994,8 @@ function parseSiloV3GraphQLResults(items, context) {
|
|
|
30935
30994
|
const partnerTokenLc = other.token.toLowerCase();
|
|
30936
30995
|
const dedupKey = `${lenderKey}:${tokenLc}`;
|
|
30937
30996
|
if (seen.has(dedupKey)) continue;
|
|
30938
|
-
const oracleAddr = (side.solvencyOracleAddress ?? side.solvencyOracle?.id ?? self.solvencyOracle ??
|
|
30939
|
-
const isStatic = !oracleAddr || oracleAddr ===
|
|
30997
|
+
const oracleAddr = (side.solvencyOracleAddress ?? side.solvencyOracle?.id ?? self.solvencyOracle ?? ZERO_ADDRESS5).toLowerCase();
|
|
30998
|
+
const isStatic = !oracleAddr || oracleAddr === ZERO_ADDRESS5;
|
|
30940
30999
|
const siloAddrLc = self.silo.toLowerCase();
|
|
30941
31000
|
try {
|
|
30942
31001
|
let priceUSD = 0;
|