@1delta/margin-fetcher 0.0.199 → 0.0.202
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/abis/euler/index.d.ts +1 -0
- package/dist/abis/euler/index.d.ts.map +1 -1
- package/dist/abis/euler/priceLens.d.ts +58 -0
- package/dist/abis/euler/priceLens.d.ts.map +1 -0
- package/dist/index.js +232 -72
- package/dist/index.js.map +1 -1
- package/dist/lending/public-data/morpho/fetchMorphoGoldsky.d.ts +105 -0
- package/dist/lending/public-data/morpho/fetchMorphoGoldsky.d.ts.map +1 -0
- package/dist/prices/oracle-prices/fetchOraclePrices.d.ts.map +1 -1
- package/dist/prices/oracle-prices/fetchers/euler.d.ts +61 -7
- package/dist/prices/oracle-prices/fetchers/euler.d.ts.map +1 -1
- package/dist/prices/oracle-prices/fetchers/morpho.d.ts.map +1 -1
- package/dist/token/fetchTokenBalance.d.ts.map +1 -1
- package/dist/yields/intrinsic/fetchers/falcon.d.ts +3 -0
- package/dist/yields/intrinsic/fetchers/falcon.d.ts.map +1 -0
- package/dist/yields/intrinsic/fetchers/yuzu.d.ts +3 -0
- package/dist/yields/intrinsic/fetchers/yuzu.d.ts.map +1 -0
- package/dist/yields/intrinsic/index.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { genericFactoryAbi } from "./genericFactory.js";
|
|
2
2
|
export { vaultLensAbi } from "./vaultLens.js";
|
|
3
|
+
export { priceLensAbi } from "./priceLens.js";
|
|
3
4
|
export { eVaultAbi } from "./eVault.js";
|
|
4
5
|
export { evcAbi } from "./evc.js";
|
|
5
6
|
export { orchestratorAbi } from "./orchestrator.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/abis/euler/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/abis/euler/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export declare const priceLensAbi: readonly [{
|
|
2
|
+
readonly inputs: readonly [{
|
|
3
|
+
readonly name: "vault";
|
|
4
|
+
readonly type: "address";
|
|
5
|
+
}];
|
|
6
|
+
readonly name: "getVaultPrice";
|
|
7
|
+
readonly outputs: readonly [{
|
|
8
|
+
readonly components: readonly [{
|
|
9
|
+
readonly name: "asset";
|
|
10
|
+
readonly type: "address";
|
|
11
|
+
}, {
|
|
12
|
+
readonly name: "unitOfAccount";
|
|
13
|
+
readonly type: "address";
|
|
14
|
+
}, {
|
|
15
|
+
readonly name: "unitOfAccountDecimals";
|
|
16
|
+
readonly type: "uint8";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "amountOutMid";
|
|
19
|
+
readonly type: "uint256";
|
|
20
|
+
}, {
|
|
21
|
+
readonly name: "queryFailure";
|
|
22
|
+
readonly type: "bool";
|
|
23
|
+
}];
|
|
24
|
+
readonly name: "result";
|
|
25
|
+
readonly type: "tuple";
|
|
26
|
+
}];
|
|
27
|
+
readonly stateMutability: "view";
|
|
28
|
+
readonly type: "function";
|
|
29
|
+
}, {
|
|
30
|
+
readonly inputs: readonly [{
|
|
31
|
+
readonly name: "vaults";
|
|
32
|
+
readonly type: "address[]";
|
|
33
|
+
}];
|
|
34
|
+
readonly name: "getVaultPrices";
|
|
35
|
+
readonly outputs: readonly [{
|
|
36
|
+
readonly components: readonly [{
|
|
37
|
+
readonly name: "asset";
|
|
38
|
+
readonly type: "address";
|
|
39
|
+
}, {
|
|
40
|
+
readonly name: "unitOfAccount";
|
|
41
|
+
readonly type: "address";
|
|
42
|
+
}, {
|
|
43
|
+
readonly name: "unitOfAccountDecimals";
|
|
44
|
+
readonly type: "uint8";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "amountOutMid";
|
|
47
|
+
readonly type: "uint256";
|
|
48
|
+
}, {
|
|
49
|
+
readonly name: "queryFailure";
|
|
50
|
+
readonly type: "bool";
|
|
51
|
+
}];
|
|
52
|
+
readonly name: "results";
|
|
53
|
+
readonly type: "tuple[]";
|
|
54
|
+
}];
|
|
55
|
+
readonly stateMutability: "view";
|
|
56
|
+
readonly type: "function";
|
|
57
|
+
}];
|
|
58
|
+
//# sourceMappingURL=priceLens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"priceLens.d.ts","sourceRoot":"","sources":["../../../src/abis/euler/priceLens.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuCf,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -27231,6 +27231,29 @@ var ondoFetcher = {
|
|
|
27231
27231
|
}
|
|
27232
27232
|
};
|
|
27233
27233
|
|
|
27234
|
+
// src/yields/intrinsic/fetchers/yuzu.ts
|
|
27235
|
+
var YUZU_APY_URL = "https://defi-api.yuzu.money/proxy/apy";
|
|
27236
|
+
var syzUSD = "Staked Yuzu USD::syzUSD";
|
|
27237
|
+
var syzusdFetcher = {
|
|
27238
|
+
label: "SYZUSD",
|
|
27239
|
+
fetch: async () => {
|
|
27240
|
+
const res = await fetch(YUZU_APY_URL).then((r) => r.json());
|
|
27241
|
+
return { [syzUSD]: apyToAprPercent(res?.data?.syzusd_apy ?? 0) };
|
|
27242
|
+
}
|
|
27243
|
+
};
|
|
27244
|
+
|
|
27245
|
+
// src/yields/intrinsic/fetchers/falcon.ts
|
|
27246
|
+
var FALCON_URL = "https://api.falcon.finance/api/v1/statistics";
|
|
27247
|
+
var sUSDf = "Staked Falcon USD::sUSDf";
|
|
27248
|
+
var susdfFetcher = {
|
|
27249
|
+
label: "SUSDF",
|
|
27250
|
+
fetch: async () => {
|
|
27251
|
+
const res = await fetch(FALCON_URL).then((r) => r.json());
|
|
27252
|
+
const apy = Number(res?.sUSDf_7d_apy ?? 0) * 100;
|
|
27253
|
+
return { [sUSDf]: apyToAprPercent(apy) };
|
|
27254
|
+
}
|
|
27255
|
+
};
|
|
27256
|
+
|
|
27234
27257
|
// src/yields/intrinsic/index.ts
|
|
27235
27258
|
async function fetchIntrinsicYields() {
|
|
27236
27259
|
const wstethPromise = safeFetch(wstethFetcher.label, wstethFetcher.fetch);
|
|
@@ -27278,7 +27301,9 @@ async function fetchIntrinsicYields() {
|
|
|
27278
27301
|
pendleFetcher,
|
|
27279
27302
|
usdaiFetcher,
|
|
27280
27303
|
mapleFetcher,
|
|
27281
|
-
ondoFetcher
|
|
27304
|
+
ondoFetcher,
|
|
27305
|
+
syzusdFetcher,
|
|
27306
|
+
susdfFetcher
|
|
27282
27307
|
];
|
|
27283
27308
|
const results = await Promise.all([
|
|
27284
27309
|
wstethPromise,
|
|
@@ -30361,6 +30386,18 @@ var aaveFetcher = {
|
|
|
30361
30386
|
parse: parseAaveResults2,
|
|
30362
30387
|
getAbi: getAaveAbi
|
|
30363
30388
|
};
|
|
30389
|
+
|
|
30390
|
+
// src/lending/public-data/morpho/fetchMorphoGoldsky.ts
|
|
30391
|
+
({
|
|
30392
|
+
[Chain.SEI_NETWORK]: "https://api.goldsky.com/api/public/project_cmiergfbv4vma01vb642yaeam/subgraphs/morphoblue-sei/1.0.1/gn",
|
|
30393
|
+
[Chain.CELO_MAINNET]: "https://api.goldsky.com/api/public/project_cmiergfbv4vma01vb642yaeam/subgraphs/morphoblue-celo/1.0.4/gn",
|
|
30394
|
+
[Chain.LISK]: "https://api.goldsky.com/api/public/project_cmiergfbv4vma01vb642yaeam/subgraphs/morphobluelisk/1.0.1/gn",
|
|
30395
|
+
[Chain.SONEIUM]: "https://api.goldsky.com/api/public/project_cmiergfbv4vma01vb642yaeam/subgraphs/morphobluesoneium/1.0.2/gn",
|
|
30396
|
+
[Chain.TAC_MAINNET]: "https://api.goldsky.com/api/public/project_cmiergfbv4vma01vb642yaeam/subgraphs/morphoblue-tac/1.0.0/gn",
|
|
30397
|
+
[Chain.HEMI_NETWORK]: "https://feather.securesecrets.org/hemi-mopho-blue/"
|
|
30398
|
+
});
|
|
30399
|
+
|
|
30400
|
+
// src/prices/oracle-prices/fetchers/morpho.ts
|
|
30364
30401
|
function morphoApiAvailable(chainId) {
|
|
30365
30402
|
if (chainId === Chain.SONEIUM) return false;
|
|
30366
30403
|
if (chainId === Chain.HEMI_NETWORK) return false;
|
|
@@ -30520,76 +30557,90 @@ async function fetchMorphoGraphQLPrices(chainId) {
|
|
|
30520
30557
|
const allMarkets = [];
|
|
30521
30558
|
for (const result of results) {
|
|
30522
30559
|
const items = result?.data?.markets?.items;
|
|
30523
|
-
if (!Array.isArray(items))
|
|
30560
|
+
if (!Array.isArray(items)) {
|
|
30561
|
+
console.warn(`[morpho-gql] chain ${chainId}: unexpected API shape, items is not an array`);
|
|
30562
|
+
return null;
|
|
30563
|
+
}
|
|
30524
30564
|
allMarkets.push(...items);
|
|
30525
30565
|
}
|
|
30526
|
-
|
|
30527
|
-
|
|
30528
|
-
|
|
30529
|
-
|
|
30530
|
-
|
|
30531
|
-
|
|
30532
|
-
|
|
30533
|
-
|
|
30534
|
-
|
|
30535
|
-
|
|
30536
|
-
|
|
30537
|
-
|
|
30538
|
-
|
|
30539
|
-
|
|
30540
|
-
|
|
30541
|
-
|
|
30542
|
-
|
|
30543
|
-
|
|
30544
|
-
|
|
30545
|
-
|
|
30546
|
-
|
|
30547
|
-
|
|
30548
|
-
|
|
30549
|
-
|
|
30550
|
-
|
|
30551
|
-
|
|
30552
|
-
|
|
30553
|
-
|
|
30554
|
-
|
|
30555
|
-
|
|
30556
|
-
|
|
30566
|
+
return processMarketsToEntries(chainId, allMarkets, "morpho-gql");
|
|
30567
|
+
} catch (err) {
|
|
30568
|
+
console.warn(`[morpho-gql] chain ${chainId}: API error, falling back to on-chain`, err);
|
|
30569
|
+
return null;
|
|
30570
|
+
}
|
|
30571
|
+
}
|
|
30572
|
+
function processMarketsToEntries(chainId, allMarkets, source) {
|
|
30573
|
+
if (allMarkets.length === 0) {
|
|
30574
|
+
console.warn(`[${source}] chain ${chainId}: returned 0 markets`);
|
|
30575
|
+
return null;
|
|
30576
|
+
}
|
|
30577
|
+
const entries = [];
|
|
30578
|
+
for (const market of allMarkets) {
|
|
30579
|
+
if (!market.collateralAsset?.address || !market.loanAsset?.address)
|
|
30580
|
+
continue;
|
|
30581
|
+
const oracle = market.oracleAddress;
|
|
30582
|
+
const loanAsset = market.loanAsset.address.toLowerCase();
|
|
30583
|
+
const collateralAsset = market.collateralAsset.address.toLowerCase();
|
|
30584
|
+
const marketId = market.uniqueKey?.replace(/^0x/i, "").toUpperCase() ?? generateMarketId(oracle, loanAsset, collateralAsset);
|
|
30585
|
+
const lenderKey = generateMorphoLenderKey(marketId);
|
|
30586
|
+
const loanPriceUSD = market.loanAsset.priceUsd;
|
|
30587
|
+
const collateralPriceUSD = market.collateralAsset.priceUsd;
|
|
30588
|
+
const statePrice = market.state?.price;
|
|
30589
|
+
const oracleRatio = statePrice != null ? formatMorphoPrice(
|
|
30590
|
+
statePrice,
|
|
30591
|
+
market.loanAsset.decimals,
|
|
30592
|
+
market.collateralAsset.decimals
|
|
30593
|
+
) : 0;
|
|
30594
|
+
if (loanPriceUSD != null && loanPriceUSD > 0) {
|
|
30595
|
+
const collateralUSD = oracleRatio > 0 ? oracleRatio * loanPriceUSD : collateralPriceUSD ?? 0;
|
|
30596
|
+
if (collateralUSD > 0) {
|
|
30557
30597
|
entries.push({
|
|
30558
30598
|
asset: collateralAsset,
|
|
30559
30599
|
price: oracleRatio,
|
|
30560
|
-
// Raw
|
|
30561
|
-
priceUSD:
|
|
30600
|
+
// Raw: collateral price in loan asset terms
|
|
30601
|
+
priceUSD: collateralUSD,
|
|
30562
30602
|
marketUid: createMarketUid(chainId, lenderKey, collateralAsset),
|
|
30563
30603
|
targetLender: lenderKey
|
|
30564
30604
|
});
|
|
30565
30605
|
}
|
|
30566
|
-
|
|
30567
|
-
|
|
30568
|
-
|
|
30569
|
-
|
|
30570
|
-
|
|
30571
|
-
|
|
30572
|
-
|
|
30573
|
-
|
|
30574
|
-
|
|
30575
|
-
|
|
30576
|
-
|
|
30577
|
-
|
|
30578
|
-
|
|
30606
|
+
} else if (collateralPriceUSD != null && collateralPriceUSD > 0) {
|
|
30607
|
+
entries.push({
|
|
30608
|
+
asset: collateralAsset,
|
|
30609
|
+
price: oracleRatio,
|
|
30610
|
+
// Raw oracle ratio
|
|
30611
|
+
priceUSD: collateralPriceUSD,
|
|
30612
|
+
marketUid: createMarketUid(chainId, lenderKey, collateralAsset),
|
|
30613
|
+
targetLender: lenderKey
|
|
30614
|
+
});
|
|
30615
|
+
}
|
|
30616
|
+
if (collateralPriceUSD != null && collateralPriceUSD > 0) {
|
|
30617
|
+
const loanUSD = oracleRatio > 0 ? collateralPriceUSD / oracleRatio : loanPriceUSD ?? 0;
|
|
30618
|
+
if (loanUSD > 0) {
|
|
30579
30619
|
entries.push({
|
|
30580
30620
|
asset: loanAsset,
|
|
30581
30621
|
price: oracleRatio > 0 ? 1 / oracleRatio : 0,
|
|
30582
|
-
// Raw
|
|
30583
|
-
priceUSD:
|
|
30622
|
+
// Raw: loan price in collateral terms
|
|
30623
|
+
priceUSD: loanUSD,
|
|
30584
30624
|
marketUid: createMarketUid(chainId, lenderKey, loanAsset),
|
|
30585
30625
|
targetLender: lenderKey
|
|
30586
30626
|
});
|
|
30587
30627
|
}
|
|
30628
|
+
} else if (loanPriceUSD != null && loanPriceUSD > 0) {
|
|
30629
|
+
entries.push({
|
|
30630
|
+
asset: loanAsset,
|
|
30631
|
+
price: oracleRatio > 0 ? 1 / oracleRatio : 0,
|
|
30632
|
+
// Raw oracle ratio
|
|
30633
|
+
priceUSD: loanPriceUSD,
|
|
30634
|
+
marketUid: createMarketUid(chainId, lenderKey, loanAsset),
|
|
30635
|
+
targetLender: lenderKey
|
|
30636
|
+
});
|
|
30588
30637
|
}
|
|
30589
|
-
|
|
30590
|
-
|
|
30638
|
+
}
|
|
30639
|
+
if (entries.length === 0) {
|
|
30640
|
+
console.warn(`[${source}] chain ${chainId}: ${allMarkets.length} markets fetched but 0 price entries produced`);
|
|
30591
30641
|
return null;
|
|
30592
30642
|
}
|
|
30643
|
+
return entries;
|
|
30593
30644
|
}
|
|
30594
30645
|
var morphoFetcher = {
|
|
30595
30646
|
getCalls: getMorphoCalls2,
|
|
@@ -30862,17 +30913,88 @@ var listaFetcher = {
|
|
|
30862
30913
|
getAbi: getListaAbi
|
|
30863
30914
|
};
|
|
30864
30915
|
|
|
30916
|
+
// src/abis/euler/priceLens.ts
|
|
30917
|
+
var priceLensAbi = [
|
|
30918
|
+
{
|
|
30919
|
+
inputs: [{ name: "vault", type: "address" }],
|
|
30920
|
+
name: "getVaultPrice",
|
|
30921
|
+
outputs: [
|
|
30922
|
+
{
|
|
30923
|
+
components: [
|
|
30924
|
+
{ name: "asset", type: "address" },
|
|
30925
|
+
{ name: "unitOfAccount", type: "address" },
|
|
30926
|
+
{ name: "unitOfAccountDecimals", type: "uint8" },
|
|
30927
|
+
{ name: "amountOutMid", type: "uint256" },
|
|
30928
|
+
{ name: "queryFailure", type: "bool" }
|
|
30929
|
+
],
|
|
30930
|
+
name: "result",
|
|
30931
|
+
type: "tuple"
|
|
30932
|
+
}
|
|
30933
|
+
],
|
|
30934
|
+
stateMutability: "view",
|
|
30935
|
+
type: "function"
|
|
30936
|
+
},
|
|
30937
|
+
{
|
|
30938
|
+
inputs: [{ name: "vaults", type: "address[]" }],
|
|
30939
|
+
name: "getVaultPrices",
|
|
30940
|
+
outputs: [
|
|
30941
|
+
{
|
|
30942
|
+
components: [
|
|
30943
|
+
{ name: "asset", type: "address" },
|
|
30944
|
+
{ name: "unitOfAccount", type: "address" },
|
|
30945
|
+
{ name: "unitOfAccountDecimals", type: "uint8" },
|
|
30946
|
+
{ name: "amountOutMid", type: "uint256" },
|
|
30947
|
+
{ name: "queryFailure", type: "bool" }
|
|
30948
|
+
],
|
|
30949
|
+
name: "results",
|
|
30950
|
+
type: "tuple[]"
|
|
30951
|
+
}
|
|
30952
|
+
],
|
|
30953
|
+
stateMutability: "view",
|
|
30954
|
+
type: "function"
|
|
30955
|
+
}
|
|
30956
|
+
];
|
|
30957
|
+
|
|
30865
30958
|
// src/prices/oracle-prices/fetchers/euler.ts
|
|
30866
30959
|
var MAX_VIRTUAL_ADDRESS = 65535;
|
|
30867
30960
|
function isUsdUnitOfAccount(addr) {
|
|
30868
30961
|
const numeric = parseInt(addr, 16);
|
|
30869
30962
|
return numeric <= MAX_VIRTUAL_ADDRESS;
|
|
30870
30963
|
}
|
|
30964
|
+
var PRICE_LENS_ADDRESS = "0x6392892f3C57c658d2c748fc64c6fe57680E889F";
|
|
30965
|
+
var PRICE_LENS_CHAINS = [
|
|
30966
|
+
"1",
|
|
30967
|
+
// Ethereum
|
|
30968
|
+
"56",
|
|
30969
|
+
// BSC
|
|
30970
|
+
"130",
|
|
30971
|
+
// Unichain
|
|
30972
|
+
"143",
|
|
30973
|
+
// Monad
|
|
30974
|
+
"146",
|
|
30975
|
+
// Sonic
|
|
30976
|
+
"999",
|
|
30977
|
+
// HyperEVM
|
|
30978
|
+
"8453",
|
|
30979
|
+
// Base
|
|
30980
|
+
"9745",
|
|
30981
|
+
// Plasma
|
|
30982
|
+
"42161",
|
|
30983
|
+
// Arbitrum
|
|
30984
|
+
"43114",
|
|
30985
|
+
// Avalanche
|
|
30986
|
+
"59144",
|
|
30987
|
+
// Linea
|
|
30988
|
+
"80094"
|
|
30989
|
+
// Berachain
|
|
30990
|
+
];
|
|
30991
|
+
var eulerCombinedAbi = [...priceLensAbi, ...vaultLensAbi];
|
|
30871
30992
|
function getEulerV2Calls(chainId) {
|
|
30872
30993
|
if (!ENABLED_EULER_V2_CHAINS.includes(chainId)) return [];
|
|
30873
30994
|
const configs = eulerConfigs() ?? {};
|
|
30874
30995
|
const vaults = eulerVaults() ?? {};
|
|
30875
30996
|
const results = [];
|
|
30997
|
+
const usePriceLens = PRICE_LENS_CHAINS.includes(chainId);
|
|
30876
30998
|
for (const [lender, chainVaults] of Object.entries(vaults)) {
|
|
30877
30999
|
const vaultList = chainVaults[chainId] ?? [];
|
|
30878
31000
|
const config = configs[lender]?.[chainId];
|
|
@@ -30880,14 +31002,23 @@ function getEulerV2Calls(chainId) {
|
|
|
30880
31002
|
const calls = [];
|
|
30881
31003
|
const meta = [];
|
|
30882
31004
|
for (const entry of vaultList) {
|
|
30883
|
-
|
|
30884
|
-
|
|
30885
|
-
|
|
30886
|
-
|
|
30887
|
-
|
|
31005
|
+
if (usePriceLens) {
|
|
31006
|
+
calls.push({
|
|
31007
|
+
address: PRICE_LENS_ADDRESS,
|
|
31008
|
+
name: "getVaultPrice",
|
|
31009
|
+
params: [entry.vault]
|
|
31010
|
+
});
|
|
31011
|
+
} else {
|
|
31012
|
+
calls.push({
|
|
31013
|
+
address: config.vaultLens,
|
|
31014
|
+
name: "getVaultInfoFull",
|
|
31015
|
+
params: [entry.vault]
|
|
31016
|
+
});
|
|
31017
|
+
}
|
|
30888
31018
|
meta.push({
|
|
30889
31019
|
vault: entry.vault.toLowerCase(),
|
|
30890
|
-
lender
|
|
31020
|
+
lender,
|
|
31021
|
+
usePriceLens
|
|
30891
31022
|
});
|
|
30892
31023
|
}
|
|
30893
31024
|
if (calls.length > 0) {
|
|
@@ -30902,14 +31033,27 @@ function parseEulerV2Results(data, meta, context) {
|
|
|
30902
31033
|
const queryMeta = meta[index];
|
|
30903
31034
|
if (!queryMeta || !result) return;
|
|
30904
31035
|
try {
|
|
30905
|
-
|
|
30906
|
-
|
|
30907
|
-
|
|
31036
|
+
let amountOutMid;
|
|
31037
|
+
let unitOfAccountDecimals;
|
|
31038
|
+
let unitOfAccount;
|
|
31039
|
+
let asset;
|
|
31040
|
+
if (queryMeta.usePriceLens) {
|
|
31041
|
+
if (result.queryFailure) return;
|
|
31042
|
+
amountOutMid = BigInt(result.amountOutMid);
|
|
31043
|
+
unitOfAccountDecimals = BigInt(result.unitOfAccountDecimals);
|
|
31044
|
+
unitOfAccount = result.unitOfAccount.toLowerCase();
|
|
31045
|
+
asset = result.asset.toLowerCase();
|
|
31046
|
+
} else {
|
|
31047
|
+
const priceInfo = result.liabilityPriceInfo;
|
|
31048
|
+
if (!priceInfo || priceInfo.queryFailure) return;
|
|
31049
|
+
amountOutMid = BigInt(priceInfo.amountOutMid);
|
|
31050
|
+
unitOfAccountDecimals = BigInt(result.unitOfAccountDecimals);
|
|
31051
|
+
unitOfAccount = result.unitOfAccount.toLowerCase();
|
|
31052
|
+
asset = result.asset.toLowerCase();
|
|
31053
|
+
}
|
|
30908
31054
|
if (amountOutMid === 0n) return;
|
|
30909
|
-
const unitOfAccountDecimals = BigInt(result.unitOfAccountDecimals);
|
|
30910
31055
|
const priceInUoA = Number(amountOutMid) / Number(10n ** unitOfAccountDecimals);
|
|
30911
31056
|
if (isNaN(priceInUoA) || priceInUoA === 0) return;
|
|
30912
|
-
const unitOfAccount = result.unitOfAccount.toLowerCase();
|
|
30913
31057
|
let priceUSD;
|
|
30914
31058
|
if (isUsdUnitOfAccount(unitOfAccount)) {
|
|
30915
31059
|
priceUSD = priceInUoA;
|
|
@@ -30919,12 +31063,15 @@ function parseEulerV2Results(data, meta, context) {
|
|
|
30919
31063
|
priceUSD = priceInUoA * uoaUSD;
|
|
30920
31064
|
}
|
|
30921
31065
|
if (isNaN(priceUSD) || priceUSD === 0) return;
|
|
30922
|
-
const asset = result.asset.toLowerCase();
|
|
30923
31066
|
entries.push({
|
|
30924
31067
|
asset,
|
|
30925
31068
|
price: priceInUoA,
|
|
30926
31069
|
priceUSD,
|
|
30927
|
-
marketUid: createMarketUid(
|
|
31070
|
+
marketUid: createMarketUid(
|
|
31071
|
+
context.chainId,
|
|
31072
|
+
queryMeta.lender,
|
|
31073
|
+
queryMeta.vault
|
|
31074
|
+
)
|
|
30928
31075
|
});
|
|
30929
31076
|
} catch {
|
|
30930
31077
|
}
|
|
@@ -30932,7 +31079,7 @@ function parseEulerV2Results(data, meta, context) {
|
|
|
30932
31079
|
return entries;
|
|
30933
31080
|
}
|
|
30934
31081
|
function getEulerV2Abi() {
|
|
30935
|
-
return
|
|
31082
|
+
return eulerCombinedAbi;
|
|
30936
31083
|
}
|
|
30937
31084
|
var eulerV2Fetcher = {
|
|
30938
31085
|
getCalls: getEulerV2Calls,
|
|
@@ -31113,7 +31260,7 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
31113
31260
|
"eulerV2",
|
|
31114
31261
|
eulerResults,
|
|
31115
31262
|
eulerV2Fetcher.parse,
|
|
31116
|
-
|
|
31263
|
+
getEulerV2Abi()
|
|
31117
31264
|
);
|
|
31118
31265
|
const morphoGroup = buildGroup(
|
|
31119
31266
|
"morpho",
|
|
@@ -31130,7 +31277,7 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
31130
31277
|
morphoGroup
|
|
31131
31278
|
];
|
|
31132
31279
|
const totalCalls = allGroups.reduce((s, g) => s + g.calls.length, 0);
|
|
31133
|
-
if (totalCalls === 0) {
|
|
31280
|
+
if (totalCalls === 0 && !isActive("morpho")) {
|
|
31134
31281
|
const diag2 = {
|
|
31135
31282
|
chainId,
|
|
31136
31283
|
totalCalls: 0,
|
|
@@ -31196,6 +31343,9 @@ async function fetchOraclePrices(chainIds, rpcOverrides, lists = {}, retries = 3
|
|
|
31196
31343
|
),
|
|
31197
31344
|
morphoGqlPromise
|
|
31198
31345
|
]);
|
|
31346
|
+
if (morphoGqlEntries == null && isActive("morpho")) {
|
|
31347
|
+
console.warn(`[prices] chain ${chainId}: Morpho GraphQL returned null, falling back to on-chain (${morphoGroup.trackers.length} trackers)`);
|
|
31348
|
+
}
|
|
31199
31349
|
const morphoData = morphoGqlEntries != null ? { results: [], error: void 0 } : await executeGroup(
|
|
31200
31350
|
morphoGroup,
|
|
31201
31351
|
chainId,
|
|
@@ -32103,13 +32253,15 @@ async function fetchTokenMetadata(chain, addrs) {
|
|
|
32103
32253
|
});
|
|
32104
32254
|
return tokens;
|
|
32105
32255
|
}
|
|
32106
|
-
var BALANCE_FETCHER = "
|
|
32256
|
+
var BALANCE_FETCHER = "0xba1a8c699aCb7938e76B062673e00c9b56382310";
|
|
32107
32257
|
var BALANCE_FETCHER_SELECTOR = "0x30fb0985";
|
|
32108
32258
|
function encodeBalanceFetcherCalldata(accounts, tokens) {
|
|
32109
32259
|
if (accounts.length < 1 || tokens.length < 1) {
|
|
32110
32260
|
return "0x";
|
|
32111
32261
|
}
|
|
32112
|
-
const normalizedAccounts = accounts.map(
|
|
32262
|
+
const normalizedAccounts = accounts.map(
|
|
32263
|
+
(a) => a.toLowerCase()
|
|
32264
|
+
);
|
|
32113
32265
|
const normalizedTokens = tokens.map((t) => t.toLowerCase());
|
|
32114
32266
|
const header = encodePacked(
|
|
32115
32267
|
["uint16", "uint16"],
|
|
@@ -32183,7 +32335,10 @@ function prepareTokenBalanceRpcCalls(chainId, account, tokens, blockTag = "lates
|
|
|
32183
32335
|
const normalizedAccount = account.toLowerCase();
|
|
32184
32336
|
const normalizedTokens = tokens.map((t) => t.toLowerCase());
|
|
32185
32337
|
const tokensWithNative = [zeroAddress, ...normalizedTokens];
|
|
32186
|
-
const encodedCalldata = encodeBalanceFetcherCalldata(
|
|
32338
|
+
const encodedCalldata = encodeBalanceFetcherCalldata(
|
|
32339
|
+
[normalizedAccount],
|
|
32340
|
+
tokensWithNative
|
|
32341
|
+
);
|
|
32187
32342
|
const dataLength = (encodedCalldata.length - 2) / 2;
|
|
32188
32343
|
const paddedLength = Math.ceil(dataLength / 32) * 32;
|
|
32189
32344
|
const offsetHex = "0000000000000000000000000000000000000000000000000000000000000020";
|
|
@@ -32270,7 +32425,12 @@ async function rpcFetchWithRetry(rpcUrls, body, maxRetries2) {
|
|
|
32270
32425
|
}
|
|
32271
32426
|
async function fetchTokenBalances(chainId, account, tokens, options = {}) {
|
|
32272
32427
|
const { blockTag = "latest", rpcUrl, rpcUrls, maxRetries: maxRetries2 = 3 } = options;
|
|
32273
|
-
const prepared = prepareTokenBalanceRpcCalls(
|
|
32428
|
+
const prepared = prepareTokenBalanceRpcCalls(
|
|
32429
|
+
chainId,
|
|
32430
|
+
account,
|
|
32431
|
+
tokens,
|
|
32432
|
+
blockTag
|
|
32433
|
+
);
|
|
32274
32434
|
let urls;
|
|
32275
32435
|
if (rpcUrls?.length) {
|
|
32276
32436
|
urls = rpcUrls;
|