@1delta/margin-fetcher 0.0.198 → 0.0.199
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
CHANGED
|
@@ -30526,7 +30526,8 @@ async function fetchMorphoGraphQLPrices(chainId) {
|
|
|
30526
30526
|
if (allMarkets.length === 0) return null;
|
|
30527
30527
|
const entries = [];
|
|
30528
30528
|
for (const market of allMarkets) {
|
|
30529
|
-
if (!market.collateralAsset)
|
|
30529
|
+
if (!market.collateralAsset?.address || !market.loanAsset?.address)
|
|
30530
|
+
continue;
|
|
30530
30531
|
const oracle = market.oracleAddress;
|
|
30531
30532
|
const loanAsset = market.loanAsset.address.toLowerCase();
|
|
30532
30533
|
const collateralAsset = market.collateralAsset.address.toLowerCase();
|
|
@@ -30540,19 +30541,45 @@ async function fetchMorphoGraphQLPrices(chainId) {
|
|
|
30540
30541
|
market.loanAsset.decimals,
|
|
30541
30542
|
market.collateralAsset.decimals
|
|
30542
30543
|
) : 0;
|
|
30543
|
-
if (
|
|
30544
|
+
if (loanPriceUSD != null && loanPriceUSD > 0) {
|
|
30545
|
+
const collateralUSD = oracleRatio > 0 ? oracleRatio * loanPriceUSD : collateralPriceUSD ?? 0;
|
|
30546
|
+
if (collateralUSD > 0) {
|
|
30547
|
+
entries.push({
|
|
30548
|
+
asset: collateralAsset,
|
|
30549
|
+
price: oracleRatio,
|
|
30550
|
+
// Raw: collateral price in loan asset terms
|
|
30551
|
+
priceUSD: collateralUSD,
|
|
30552
|
+
marketUid: createMarketUid(chainId, lenderKey, collateralAsset),
|
|
30553
|
+
targetLender: lenderKey
|
|
30554
|
+
});
|
|
30555
|
+
}
|
|
30556
|
+
} else if (collateralPriceUSD != null && collateralPriceUSD > 0) {
|
|
30544
30557
|
entries.push({
|
|
30545
30558
|
asset: collateralAsset,
|
|
30546
|
-
price: oracleRatio
|
|
30559
|
+
price: oracleRatio,
|
|
30560
|
+
// Raw oracle ratio
|
|
30547
30561
|
priceUSD: collateralPriceUSD,
|
|
30548
30562
|
marketUid: createMarketUid(chainId, lenderKey, collateralAsset),
|
|
30549
30563
|
targetLender: lenderKey
|
|
30550
30564
|
});
|
|
30551
30565
|
}
|
|
30552
|
-
if (
|
|
30566
|
+
if (collateralPriceUSD != null && collateralPriceUSD > 0) {
|
|
30567
|
+
const loanUSD = oracleRatio > 0 ? collateralPriceUSD / oracleRatio : loanPriceUSD ?? 0;
|
|
30568
|
+
if (loanUSD > 0) {
|
|
30569
|
+
entries.push({
|
|
30570
|
+
asset: loanAsset,
|
|
30571
|
+
price: oracleRatio > 0 ? 1 / oracleRatio : 0,
|
|
30572
|
+
// Raw: loan price in collateral terms
|
|
30573
|
+
priceUSD: loanUSD,
|
|
30574
|
+
marketUid: createMarketUid(chainId, lenderKey, loanAsset),
|
|
30575
|
+
targetLender: lenderKey
|
|
30576
|
+
});
|
|
30577
|
+
}
|
|
30578
|
+
} else if (loanPriceUSD != null && loanPriceUSD > 0) {
|
|
30553
30579
|
entries.push({
|
|
30554
30580
|
asset: loanAsset,
|
|
30555
|
-
price: oracleRatio > 0 ? 1 / oracleRatio :
|
|
30581
|
+
price: oracleRatio > 0 ? 1 / oracleRatio : 0,
|
|
30582
|
+
// Raw oracle ratio
|
|
30556
30583
|
priceUSD: loanPriceUSD,
|
|
30557
30584
|
marketUid: createMarketUid(chainId, lenderKey, loanAsset),
|
|
30558
30585
|
targetLender: lenderKey
|
|
@@ -31413,7 +31440,7 @@ function selectAssetGroupPrices(structuredPrices, lists = {}, tvlMap = {}, prior
|
|
|
31413
31440
|
if (prio < 0) continue;
|
|
31414
31441
|
const tvl = tvlMap[lender] ?? 0;
|
|
31415
31442
|
for (const entry of entries) {
|
|
31416
|
-
if (entry.priceUSD <= 0) continue;
|
|
31443
|
+
if (!entry?.asset || entry.priceUSD <= 0) continue;
|
|
31417
31444
|
const oracleKey = tokenList[entry.asset]?.assetGroup ?? `${chainId}-${entry.asset.toLowerCase()}`;
|
|
31418
31445
|
candidates.push({
|
|
31419
31446
|
oracleKey,
|