@1delta/margin-fetcher 0.0.254 → 0.0.257
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 +119 -19
- package/dist/index.js.map +1 -1
- package/dist/lending/public-data/fetchLenderAll.d.ts.map +1 -1
- package/dist/lending/user-data/morpho/userCallBuild.d.ts.map +1 -1
- package/dist/prices/oracle-prices/fetchOraclePrices.d.ts.map +1 -1
- package/dist/prices/oracle-prices/fetchers/fetchMorphoMysticPrices.d.ts +3 -0
- package/dist/prices/oracle-prices/fetchers/fetchMorphoMysticPrices.d.ts.map +1 -0
- package/dist/prices/oracle-prices/fetchers/fetchMysticApi.d.ts +46 -0
- package/dist/prices/oracle-prices/fetchers/fetchMysticApi.d.ts.map +1 -0
- package/dist/prices/oracle-prices/fetchers/index.d.ts +1 -1
- package/dist/prices/oracle-prices/fetchers/index.d.ts.map +1 -1
- package/dist/prices/oracle-prices/fetchers/morpho.d.ts +23 -0
- package/dist/prices/oracle-prices/fetchers/morpho.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -11108,7 +11108,8 @@ var MORPHO_LENS = {
|
|
|
11108
11108
|
[Chain.STABLE_MAINNET]: "0x8E24CfC19c6C00c524353CB8816f5f1c2F33c201",
|
|
11109
11109
|
[Chain.CORN]: "0x8E24CfC19c6C00c524353CB8816f5f1c2F33c201",
|
|
11110
11110
|
[Chain.LISK]: "0x8E24CfC19c6C00c524353CB8816f5f1c2F33c201",
|
|
11111
|
-
[Chain.ABSTRACT]: "0x8e24cfc19c6c00c524353cb8816f5f1c2f33c201"
|
|
11111
|
+
[Chain.ABSTRACT]: "0x8e24cfc19c6c00c524353cb8816f5f1c2f33c201",
|
|
11112
|
+
[Chain.INK]: "0x0bd7473CbBf81d9dD936c61117eD230d95006CA2"
|
|
11112
11113
|
};
|
|
11113
11114
|
var buildMorphoUserCallWithLens = (chainId, account, lender, marketsToQuery) => {
|
|
11114
11115
|
const marketSlices = chunk(marketsToQuery, 100);
|
|
@@ -20514,11 +20515,13 @@ function lenderApiOnly(lender, chainId) {
|
|
|
20514
20515
|
if (chainId === Chain.HEMI_NETWORK) return false;
|
|
20515
20516
|
if (chainId === Chain.BERACHAIN) return false;
|
|
20516
20517
|
if (chainId === Chain.SEI_NETWORK) return false;
|
|
20518
|
+
if (chainId === Chain.BNB_SMART_CHAIN_MAINNET) return false;
|
|
20517
20519
|
if (chainId === Chain.CELO_MAINNET) return false;
|
|
20518
|
-
if (chainId === Chain.CORN) return false;
|
|
20519
|
-
if (chainId === Chain.ABSTRACT) return false;
|
|
20520
|
-
if (chainId === Chain.PLUME_MAINNET) return false;
|
|
20521
20520
|
if (chainId === Chain.LISK) return false;
|
|
20521
|
+
if (chainId === Chain.TAC_MAINNET) return false;
|
|
20522
|
+
if (chainId === Chain.FLARE_MAINNET) return false;
|
|
20523
|
+
if (chainId === Chain.PLUME_MAINNET) return false;
|
|
20524
|
+
if (chainId === "4114") return false;
|
|
20522
20525
|
return true;
|
|
20523
20526
|
}
|
|
20524
20527
|
return false;
|
|
@@ -31306,16 +31309,6 @@ var ProxyOracleAbi = [
|
|
|
31306
31309
|
}
|
|
31307
31310
|
];
|
|
31308
31311
|
|
|
31309
|
-
// src/lending/public-data/morpho/fetchMorphoGoldsky.ts
|
|
31310
|
-
({
|
|
31311
|
-
[Chain.SEI_NETWORK]: "https://api.goldsky.com/api/public/project_cmiergfbv4vma01vb642yaeam/subgraphs/morphoblue-sei/1.0.1/gn",
|
|
31312
|
-
[Chain.CELO_MAINNET]: "https://api.goldsky.com/api/public/project_cmiergfbv4vma01vb642yaeam/subgraphs/morphoblue-celo/1.0.4/gn",
|
|
31313
|
-
[Chain.LISK]: "https://api.goldsky.com/api/public/project_cmiergfbv4vma01vb642yaeam/subgraphs/morphobluelisk/1.0.1/gn",
|
|
31314
|
-
[Chain.SONEIUM]: "https://api.goldsky.com/api/public/project_cmiergfbv4vma01vb642yaeam/subgraphs/morphobluesoneium/1.0.2/gn",
|
|
31315
|
-
[Chain.TAC_MAINNET]: "https://api.goldsky.com/api/public/project_cmiergfbv4vma01vb642yaeam/subgraphs/morphoblue-tac/1.0.0/gn",
|
|
31316
|
-
[Chain.HEMI_NETWORK]: "https://feather.securesecrets.org/hemi-mopho-blue/"
|
|
31317
|
-
});
|
|
31318
|
-
|
|
31319
31312
|
// src/prices/oracle-prices/fetchers/morpho.ts
|
|
31320
31313
|
function morphoApiAvailable(chainId) {
|
|
31321
31314
|
if (chainId === Chain.SONEIUM) return false;
|
|
@@ -31330,6 +31323,17 @@ function morphoApiAvailable(chainId) {
|
|
|
31330
31323
|
if (chainId === Chain.BNB_SMART_CHAIN_MAINNET) return false;
|
|
31331
31324
|
return true;
|
|
31332
31325
|
}
|
|
31326
|
+
var MORPHO_API_INCOMPLETE_CHAINS = /* @__PURE__ */ new Set([
|
|
31327
|
+
Chain.FLARE_MAINNET,
|
|
31328
|
+
// Mystic — no state.price
|
|
31329
|
+
Chain.PLUME_MAINNET,
|
|
31330
|
+
// Mystic — no state.price
|
|
31331
|
+
"4114"
|
|
31332
|
+
// Citrea (Mystic) — not yet in chain-registry
|
|
31333
|
+
]);
|
|
31334
|
+
function morphoApiIncomplete(chainId) {
|
|
31335
|
+
return MORPHO_API_INCOMPLETE_CHAINS.has(chainId);
|
|
31336
|
+
}
|
|
31333
31337
|
function generateMarketId(oracle, loanAsset, collateralAsset) {
|
|
31334
31338
|
return `${oracle}${loanAsset}${collateralAsset}`.replace(/0x/gi, "").toUpperCase();
|
|
31335
31339
|
}
|
|
@@ -32903,6 +32907,66 @@ function parseSiloV3GraphQLResults(items, context) {
|
|
|
32903
32907
|
return out;
|
|
32904
32908
|
}
|
|
32905
32909
|
|
|
32910
|
+
// src/prices/oracle-prices/fetchers/fetchMysticApi.ts
|
|
32911
|
+
var MYSTIC_CHAIN_IDS = /* @__PURE__ */ new Set([
|
|
32912
|
+
"14",
|
|
32913
|
+
// Flare
|
|
32914
|
+
"98866",
|
|
32915
|
+
// Plume
|
|
32916
|
+
"4114"
|
|
32917
|
+
// Citrea
|
|
32918
|
+
]);
|
|
32919
|
+
function hasMysticApi(chainId) {
|
|
32920
|
+
return MYSTIC_CHAIN_IDS.has(chainId);
|
|
32921
|
+
}
|
|
32922
|
+
|
|
32923
|
+
// src/prices/oracle-prices/fetchers/fetchMorphoMysticPrices.ts
|
|
32924
|
+
var FULL_URL = "https://api.mysticfinance.xyz/morphoCache/";
|
|
32925
|
+
async function fetchMorphoMysticPrices(chainId) {
|
|
32926
|
+
try {
|
|
32927
|
+
const res = await fetch(`${FULL_URL}?chainId=${chainId}`);
|
|
32928
|
+
if (!res.ok) {
|
|
32929
|
+
console.warn(
|
|
32930
|
+
`[morpho-mystic] chain ${chainId}: ${res.status} ${res.statusText}`
|
|
32931
|
+
);
|
|
32932
|
+
return null;
|
|
32933
|
+
}
|
|
32934
|
+
const body = await res.json();
|
|
32935
|
+
const raw = body.markets ?? [];
|
|
32936
|
+
const allMarkets = [];
|
|
32937
|
+
for (const m of raw) {
|
|
32938
|
+
const loanAddr = (m.loanToken ?? m.asset?.asset ?? "").toLowerCase();
|
|
32939
|
+
const collateralAddr = (m.collateralToken ?? m.collateral?.asset ?? "").toLowerCase();
|
|
32940
|
+
if (!m.marketId || !m.oracle || !loanAddr || !collateralAddr) continue;
|
|
32941
|
+
const loanPrice = typeof m.assetPrice === "number" && Number.isFinite(m.assetPrice) ? m.assetPrice : null;
|
|
32942
|
+
const collateralPrice = typeof m.collateralPrice === "number" && Number.isFinite(m.collateralPrice) ? m.collateralPrice : null;
|
|
32943
|
+
allMarkets.push({
|
|
32944
|
+
uniqueKey: m.marketId,
|
|
32945
|
+
oracleAddress: m.oracle,
|
|
32946
|
+
loanAsset: {
|
|
32947
|
+
address: loanAddr,
|
|
32948
|
+
decimals: m.asset?.decimals ?? 18,
|
|
32949
|
+
priceUsd: loanPrice
|
|
32950
|
+
},
|
|
32951
|
+
collateralAsset: {
|
|
32952
|
+
address: collateralAddr,
|
|
32953
|
+
decimals: m.collateral?.decimals ?? 18,
|
|
32954
|
+
priceUsd: collateralPrice
|
|
32955
|
+
},
|
|
32956
|
+
// Mystic does not return the on-chain oracle ratio.
|
|
32957
|
+
state: null
|
|
32958
|
+
});
|
|
32959
|
+
}
|
|
32960
|
+
return processMarketsToEntries(chainId, allMarkets, "morpho-mystic");
|
|
32961
|
+
} catch (err) {
|
|
32962
|
+
console.warn(
|
|
32963
|
+
`[morpho-mystic] chain ${chainId}: fetch error, skipping`,
|
|
32964
|
+
err
|
|
32965
|
+
);
|
|
32966
|
+
return null;
|
|
32967
|
+
}
|
|
32968
|
+
}
|
|
32969
|
+
|
|
32906
32970
|
// src/prices/oracle-prices/fetchOraclePrices.ts
|
|
32907
32971
|
function countFailures(data, offset, count) {
|
|
32908
32972
|
let failures = 0;
|
|
@@ -33046,8 +33110,11 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
33046
33110
|
() => aaveV4Fetcher.getCalls(chainId),
|
|
33047
33111
|
getCallsErrors
|
|
33048
33112
|
) : [];
|
|
33049
|
-
const
|
|
33050
|
-
const
|
|
33113
|
+
const morphoUseMystic = isActive("morpho") && hasMysticApi(chainId);
|
|
33114
|
+
const morphoUseApi = isActive("morpho") && !morphoUseMystic && morphoApiAvailable(chainId);
|
|
33115
|
+
const morphoUseRemote = morphoUseMystic || morphoUseApi;
|
|
33116
|
+
const morphoUseHybrid = morphoUseRemote && morphoApiIncomplete(chainId);
|
|
33117
|
+
const morphoUseOnChain = isActive("morpho") && (!morphoUseRemote || morphoUseHybrid);
|
|
33051
33118
|
const morphoResults = morphoUseOnChain ? safeGetCalls(
|
|
33052
33119
|
"morpho",
|
|
33053
33120
|
() => morphoFetcher.getCalls(chainId, {
|
|
@@ -33170,7 +33237,7 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
33170
33237
|
return { chainId, data: chainResult, diagnostic: diag2 };
|
|
33171
33238
|
}
|
|
33172
33239
|
const chainBatchSize = batchSize?.[chainId];
|
|
33173
|
-
const morphoGqlPromise = morphoUseApi ? fetchMorphoGraphQLPrices(chainId) : Promise.resolve(null);
|
|
33240
|
+
const morphoGqlPromise = morphoUseMystic ? fetchMorphoMysticPrices(chainId) : morphoUseApi ? fetchMorphoGraphQLPrices(chainId) : Promise.resolve(null);
|
|
33174
33241
|
const siloV2GqlPromise = isActive("silov2") ? fetchSiloV2GraphQLPrices(chainId, basePrices, tokenList) : Promise.resolve(null);
|
|
33175
33242
|
const siloV3GqlPromise = isActive("silov3") ? fetchSiloV3GraphQLPrices(chainId, basePrices, tokenList) : Promise.resolve(null);
|
|
33176
33243
|
const [
|
|
@@ -33289,6 +33356,7 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
33289
33356
|
rpcOverrides
|
|
33290
33357
|
) : { results: [], error: void 0 };
|
|
33291
33358
|
const useMorphoGql = morphoGqlEntries != null;
|
|
33359
|
+
const useMorphoHybrid = useMorphoGql && morphoUseHybrid;
|
|
33292
33360
|
const groupResults = [
|
|
33293
33361
|
{ group: aaveGroup, data: aaveData },
|
|
33294
33362
|
{ group: compoundV2Group, data: compoundV2Data },
|
|
@@ -33300,7 +33368,8 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
33300
33368
|
{ group: gearboxV3Group, data: gearboxV3Data },
|
|
33301
33369
|
...siloV2GqlEntries != null ? [] : [{ group: siloV2Group, data: siloV2Data }],
|
|
33302
33370
|
...siloV3GqlEntries != null ? [] : [{ group: siloV3Group, data: siloV3Data }],
|
|
33303
|
-
|
|
33371
|
+
// In hybrid mode the on-chain multicall ran too — surface its errors.
|
|
33372
|
+
...useMorphoGql && !useMorphoHybrid ? [] : [{ group: morphoGroup, data: morphoData }]
|
|
33304
33373
|
];
|
|
33305
33374
|
for (const { group, data } of groupResults) {
|
|
33306
33375
|
if (data.error) {
|
|
@@ -33424,7 +33493,38 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
33424
33493
|
} else {
|
|
33425
33494
|
parseTrackers(siloV3Group, siloV3Data.results);
|
|
33426
33495
|
}
|
|
33427
|
-
if (
|
|
33496
|
+
if (useMorphoHybrid) {
|
|
33497
|
+
for (const entry of morphoGqlEntries) {
|
|
33498
|
+
if (!(entry.priceUSD > 0)) continue;
|
|
33499
|
+
const oracleKey = tokenList[entry.asset]?.assetGroup ?? `${chainId}-${entry.asset}`;
|
|
33500
|
+
usdPrices[oracleKey] = entry.priceUSD;
|
|
33501
|
+
usdPrices[entry.asset] = entry.priceUSD;
|
|
33502
|
+
}
|
|
33503
|
+
parseTrackers(morphoGroup, morphoData.results, false);
|
|
33504
|
+
const onChainKeys = /* @__PURE__ */ new Set();
|
|
33505
|
+
for (const lender of Object.keys(chainResult)) {
|
|
33506
|
+
for (const e of chainResult[lender]) {
|
|
33507
|
+
if (!e.targetLender) continue;
|
|
33508
|
+
if (!e.targetLender.startsWith("MORPHO")) continue;
|
|
33509
|
+
onChainKeys.add(`${e.targetLender}|${e.marketUid}|${e.asset}`);
|
|
33510
|
+
}
|
|
33511
|
+
}
|
|
33512
|
+
let gqlPushed = 0;
|
|
33513
|
+
for (const entry of morphoGqlEntries) {
|
|
33514
|
+
const lender = entry.targetLender ?? "MORPHO_BLUE";
|
|
33515
|
+
const key = `${lender}|${entry.marketUid}|${entry.asset}`;
|
|
33516
|
+
if (onChainKeys.has(key)) continue;
|
|
33517
|
+
if (!chainResult[lender]) chainResult[lender] = [];
|
|
33518
|
+
chainResult[lender].push(entry);
|
|
33519
|
+
gqlPushed++;
|
|
33520
|
+
}
|
|
33521
|
+
trackerDiags.push({
|
|
33522
|
+
lender: "MORPHO_BLUE (hybrid-fill)",
|
|
33523
|
+
callCount: 0,
|
|
33524
|
+
failedCalls: 0,
|
|
33525
|
+
parsedEntries: gqlPushed
|
|
33526
|
+
});
|
|
33527
|
+
} else if (useMorphoGql) {
|
|
33428
33528
|
const morphoGqlDiag = {
|
|
33429
33529
|
lender: "MORPHO_BLUE (GraphQL)",
|
|
33430
33530
|
callCount: 0,
|