@1delta/margin-fetcher 0.0.65 → 0.0.67
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
|
@@ -10715,15 +10715,9 @@ var buildMorphoUserCallWithLens = (chainId, account, lender, marketsToQuery) =>
|
|
|
10715
10715
|
// src/lending/morpho/constants/markets.ts
|
|
10716
10716
|
var MORPHO_MARKETS = {
|
|
10717
10717
|
[Chain.HYPEREVM]: [
|
|
10718
|
-
"0xf9f0473b23ebeb82c83078f0f0f77f27ac534c9fb227cb4366e6057b6163ffbf",
|
|
10719
|
-
"0xb5b215bd2771f5ed73125bf6a02e7b743fadc423dfbb095ad59df047c50d3e81",
|
|
10720
|
-
"0x64e7db7f042812d4335947a7cdf6af1093d29478aff5f1ccd93cc67f8aadfddc",
|
|
10721
|
-
"0xc0a3063a0a7755b7d58642e9a6d3be1c05bc974665ef7d3b158784348d4e17c5",
|
|
10722
|
-
"0x78f6b57d825ef01a5dc496ad1f426a6375c685047d07a30cd07ac5107ffc7976",
|
|
10723
|
-
"0xd2e8f6fd195556222d7a0314d4fb93fdf84ae920faaebba6dbcf584ac865e1f5",
|
|
10724
|
-
"0xd5c5b5db889eb5d4f4026b9704cddffbc1356732a37c2b543330c10756ae7a18",
|
|
10725
|
-
"0xfdece686f16877984325c7a1c192e0f18862bae3829d000a1a62b5bc2b31d4ef",
|
|
10726
10718
|
"0x076689a210adf3fdaa54e8ed452615ed641ba0d985f95e1376c3df3017d62878",
|
|
10719
|
+
"0x09ed416b38a29e077383da5ae4200523e54e33ecff6e148c2590969a9852513f",
|
|
10720
|
+
"0x0a2e456ebd22ed68ae1d5c6b2de70bc514337ac588a7a4b0e28f546662144036",
|
|
10727
10721
|
"0x0bb2900086fe38fa9633c664e1f955eb8dcf66a81174967e83dee867e083a105",
|
|
10728
10722
|
"0x0ecf5be1fadf4bec3f79ce196f02a327b507b34d230c0f033f4970b1b510119c",
|
|
10729
10723
|
"0x15f505f8dda26a523f7490ad0322f3ed4f325a54fd50832bc65e4bd75e3dca54",
|
|
@@ -10731,38 +10725,26 @@ var MORPHO_MARKETS = {
|
|
|
10731
10725
|
"0x19e47d37453628ebf0fd18766ce6fee1b08ea46752a5da83ca0bfecb270d07e8",
|
|
10732
10726
|
"0x1c6b87ae1b97071ef444eedcba9f5a92cfe974edbbcaa1946644fc7ab0e283af",
|
|
10733
10727
|
"0x1da89208e6cb5173e97a83461853b8400de4f7c37542cf010a10579a5f7ca451",
|
|
10734
|
-
"0x292f0a3ddfb642fbaadf258ebcccf9e4b0048a9dc5af93036288502bde1a71b1",
|
|
10735
|
-
"0xace279b5c6eff0a1ce7287249369fa6f4d3d32225e1629b04ef308e0eb568fb0",
|
|
10736
|
-
"0x96c7abf76aed53d50b2cc84e2ed17846e0d1c4cc28236d95b6eb3b12dcc86909",
|
|
10737
|
-
"0x5fe3ac84f3a2c4e3102c3e6e9accb1ec90c30f6ee87ab1fcafc197b8addeb94c",
|
|
10738
|
-
"0x707dddc200e95dc984feb185abf1321cabec8486dca5a9a96fb5202184106e54",
|
|
10739
|
-
"0x87272614b7a2022c31ddd7bba8eb21d5ab40a6bcbea671264d59dc732053721d",
|
|
10740
|
-
"0xe9a9bb9ed3cc53f4ee9da4eea0370c2c566873d5de807e16559a99907c9ae227",
|
|
10741
|
-
"0xb39e45107152f02502c001a46e2d3513f429d2363323cdaffbc55a951a69b998",
|
|
10742
|
-
"0x1f79fe1822f6bfe7a70f8e7e5e768efd0c3f10db52af97c2f14e4b71e3130e70",
|
|
10743
|
-
"0xe500760b79e397869927a5275d64987325faae43326daf6be5a560184e30a521",
|
|
10744
|
-
"0x86d7bc359391486de8cd1204da45c53d6ada60ab9764450dc691e1775b2e8d69",
|
|
10745
|
-
"0x920244a8682a53b17fe15597b63abdaa3aecec44e070379c5e43897fb9f42a2b",
|
|
10746
|
-
"0xd4fd53f612eaf411a1acea053cfa28cbfeea683273c4133bf115b47a20130305",
|
|
10747
|
-
"0x1df0d0ebcdc52069692452cb9a3e5cf6c017b237378141eaf08a05ce17205ed6",
|
|
10748
|
-
"0x888679b2af61343a4c7c0da0639fc5ca5fc5727e246371c4425e4d634c09e1f6",
|
|
10749
|
-
"0xe0a1de770a9a72a083087fe1745c998426aaea984ddf155ea3d5fbba5b759713",
|
|
10750
10728
|
"0x1df0d0ebcdc52069692452cb9a3e5cf6c017b237378141eaf08a05ce17205ed6",
|
|
10751
10729
|
"0x216bd19960f140177a4a3fb9cf258edcbadb1f5d54740fc944503bff4a00e65e",
|
|
10752
10730
|
"0x2acd218c67daa94dd2f92e81f477ffc9f8507319f0f2d698eae5ed631ae14039",
|
|
10753
10731
|
"0x2b62c4153d81d5b5a233d1d2b7ef899d3fca4076d458e215ff3a00176b415b0d",
|
|
10754
10732
|
"0x31aaa663d718e83ea15326ec110c4bcf5e123585d0b6c4d0ad61a50c4aa65b1e",
|
|
10755
10733
|
"0x33c935bb0699b737d9cbd4274b5936a9004eee03ccfa70e266ff7c1513fd4808",
|
|
10734
|
+
"0x45af9c72aa97978e143a646498c8922058b7c6f18b6f7b05d7316c8cf7ab942f",
|
|
10756
10735
|
"0x5031ac4543f8232df889e5eb24389f8cf9520366f21dc62240017cb3bc6ecc59",
|
|
10757
10736
|
"0x53bf81793c2cc384c19a3bc9b032467e179a390a9225cd9542742ac10f539cc2",
|
|
10758
10737
|
"0x5ecb7a25d51c870ec57f810c880e3e20743e56d0524575b7b8934a778aaec1af",
|
|
10759
10738
|
"0x5ef35fe4418a6bcfcc70fe32efce30074f22e9a782f81d432c1e537ddbda11e2",
|
|
10760
10739
|
"0x64e7db7f042812d4335947a7cdf6af1093d29478aff5f1ccd93cc67f8aadfddc",
|
|
10761
10740
|
"0x65f2a559764859a559d8c39604cf665942bab7d10dfaa1b82e914c9d351038d4",
|
|
10741
|
+
"0x6eb4ce92dc1d89abd40f9634249ec28e8ab4e3f9bef0ab47ea784773c140d4ef",
|
|
10762
10742
|
"0x707dddc200e95dc984feb185abf1321cabec8486dca5a9a96fb5202184106e54",
|
|
10743
|
+
"0x725d0f4c005c0a521ea5005bb4730845ff0d4cc76b40a618103b103cddd1f951",
|
|
10763
10744
|
"0x7268244d330f1462f77ded7a14e2f868893e86e76e8b8eaa869405d588aff6ce",
|
|
10764
10745
|
"0x78f6b57d825ef01a5dc496ad1f426a6375c685047d07a30cd07ac5107ffc7976",
|
|
10765
10746
|
"0x83bab0d612f592d0f145b2ec82fd730144dfb3d72c8fc838b27555558e49c496",
|
|
10747
|
+
"0x888679b2af61343a4c7c0da0639fc5ca5fc5727e246371c4425e4d634c09e1f6",
|
|
10766
10748
|
"0x8eb8cfe3b1ac8f653608ae09fb099263fa2fe25d4a59305c309937292c2aeee9",
|
|
10767
10749
|
"0x964e7d1db11bdf32262c71274c297dcdb4710d73acb814f04fdca8b0c7cdf028",
|
|
10768
10750
|
"0x9e28003bb5c29c1df3552e99b04d656fadf1aedaf81256637dcc51d91cf6c639",
|
|
@@ -10775,14 +10757,43 @@ var MORPHO_MARKETS = {
|
|
|
10775
10757
|
"0xbc15a1782163f4be46c23ac61f5da50fed96ad40293f86a5ce0501ce4a246b32",
|
|
10776
10758
|
"0xc5526286d537c890fdd879d17d80c4a22dc7196c1e1fff0dd6c853692a759c62",
|
|
10777
10759
|
"0xc59a3f8a3918d89ebef44ee1dcda435719f543cfd3f37ead7e74852ea5931581",
|
|
10760
|
+
"0xd13b1bad542045a8dc729fa0ffcc4f538b9771592c2666e1f09667dcf85804fc",
|
|
10778
10761
|
"0xd173e9d80aeacac486b46a9a849ecb386cec260cc7dd5be0db3505a0f9f93fb5",
|
|
10762
|
+
"0xd2e8f6fd195556222d7a0314d4fb93fdf84ae920faaebba6dbcf584ac865e1f5",
|
|
10763
|
+
"0xd5a9fba2309a0b85972a96f2cc45f9784e786d712944d8fc0b31a6d9cb4f21d3",
|
|
10764
|
+
"0xd5c5b5db889eb5d4f4026b9704cddffbc1356732a37c2b543330c10756ae7a18",
|
|
10779
10765
|
"0xdb2cf3ad3ef91c9bb673bf35744e7141bc2950b27a75c8d11b0ead9f6742d927",
|
|
10780
10766
|
"0xe0ede98b4425285a9c93d51f8ba27d9a09bc0033874e4a883d3f29d41f9f2e4a",
|
|
10781
10767
|
"0xe41ace68f2de7be8e47185b51ddc23d4a58aac4ce9f8cc5f9384fe26f2104ec8",
|
|
10768
|
+
"0xe7aa046832007a975d4619260d221229e99cc27da2e6ef162881202b4cd2349b",
|
|
10769
|
+
"0xe9a9bb9ed3cc53f4ee9da4eea0370c2c566873d5de807e16559a99907c9ae227",
|
|
10782
10770
|
"0xebeabb17bd69d4b8ed6929a821d69478b564f4cc604d0995944c9da8b5cb3f04",
|
|
10783
10771
|
"0xed00791e29eb08c9bc0d8b389fe1f00084699baf2a785ba2a42e915706b17b82",
|
|
10784
10772
|
"0xf25db2433ae650155eae04ebd8b3795d19bfcb318d22926a8a5e746e8028e0a8",
|
|
10785
|
-
"
|
|
10773
|
+
"0xf9f0473b23ebeb82c83078f0f0f77f27ac534c9fb227cb4366e6057b6163ffbf",
|
|
10774
|
+
"0xfbe436e9aa361487f0c3e4ff94c88aea72887a4482c6b8bcfec60a8584cdb05e",
|
|
10775
|
+
"0xfdece686f16877984325c7a1c192e0f18862bae3829d000a1a62b5bc2b31d4ef",
|
|
10776
|
+
"0xb1977ea63bed73a2b1259889cd6c846e1fa869aa3236f86938588b4b3bd68b7d",
|
|
10777
|
+
"0xae019cf2bf3d650ab4037986405c80ebb83fec18fb120c71bf8889d327caef0f",
|
|
10778
|
+
"0xfea758e88403739fee1113b26623f43d3c37b51dc1e1e8231b78b23d1404e439",
|
|
10779
|
+
"0xb5b215bd2771f5ed73125bf6a02e7b743fadc423dfbb095ad59df047c50d3e81",
|
|
10780
|
+
"0xc0a3063a0a7755b7d58642e9a6d3be1c05bc974665ef7d3b158784348d4e17c5",
|
|
10781
|
+
"0x292f0a3ddfb642fbaadf258ebcccf9e4b0048a9dc5af93036288502bde1a71b1",
|
|
10782
|
+
"0x96c7abf76aed53d50b2cc84e2ed17846e0d1c4cc28236d95b6eb3b12dcc86909",
|
|
10783
|
+
"0x5fe3ac84f3a2c4e3102c3e6e9accb1ec90c30f6ee87ab1fcafc197b8addeb94c",
|
|
10784
|
+
"0x87272614b7a2022c31ddd7bba8eb21d5ab40a6bcbea671264d59dc732053721d",
|
|
10785
|
+
"0xb39e45107152f02502c001a46e2d3513f429d2363323cdaffbc55a951a69b998",
|
|
10786
|
+
"0x1f79fe1822f6bfe7a70f8e7e5e768efd0c3f10db52af97c2f14e4b71e3130e70",
|
|
10787
|
+
"0xe500760b79e397869927a5275d64987325faae43326daf6be5a560184e30a521",
|
|
10788
|
+
"0x86d7bc359391486de8cd1204da45c53d6ada60ab9764450dc691e1775b2e8d69",
|
|
10789
|
+
"0x920244a8682a53b17fe15597b63abdaa3aecec44e070379c5e43897fb9f42a2b",
|
|
10790
|
+
"0xd4fd53f612eaf411a1acea053cfa28cbfeea683273c4133bf115b47a20130305",
|
|
10791
|
+
"0xe0a1de770a9a72a083087fe1745c998426aaea984ddf155ea3d5fbba5b759713",
|
|
10792
|
+
"0x41afe1000213f119a3d8a6cd2f9fc0b564a58f948514e4cc246f6293bbed3409",
|
|
10793
|
+
"0x583e3beb5d64b419c68083555bb7bbcc018ec392289742d5535c3916041c2f5e",
|
|
10794
|
+
"0x1f97b6313f322ddb58a7db22896fcd588dae009c5f67e8441a00613b990950eb",
|
|
10795
|
+
"0xbb72791441e499bb05931b2629964114cc97f197897128efc276a76a10d73ac6",
|
|
10796
|
+
"0x4ec715887ec2b7470a7e33f7cb0035677db3e8882a680cc09053b8ad53f47154"
|
|
10786
10797
|
],
|
|
10787
10798
|
[Chain.OP_MAINNET]: [
|
|
10788
10799
|
"0x173b66359f0741b1c7f1963075cd271c739b6dc73b658e108a54ce6febeb279b",
|
|
@@ -19982,121 +19993,65 @@ var getChainLinkKeys = (chainId) => {
|
|
|
19982
19993
|
|
|
19983
19994
|
// src/prices/pendle/fetchPendlePrices.ts
|
|
19984
19995
|
var PENDLE_API_BASE = "https://api-v2.pendle.finance/core";
|
|
19985
|
-
var MARKETS_ENDPOINT =
|
|
19986
|
-
var PRICES_ENDPOINT = (
|
|
19987
|
-
var
|
|
19988
|
-
// '1', Disabled for now
|
|
19989
|
-
"42161",
|
|
19990
|
-
"10",
|
|
19991
|
-
"56",
|
|
19992
|
-
"8453",
|
|
19993
|
-
"5000",
|
|
19994
|
-
"146",
|
|
19995
|
-
"80094"
|
|
19996
|
-
];
|
|
19997
|
-
var marketsCache = null;
|
|
19996
|
+
var MARKETS_ENDPOINT = `${PENDLE_API_BASE}/v1/markets/all`;
|
|
19997
|
+
var PRICES_ENDPOINT = (types) => `${PENDLE_API_BASE}/v1/prices/assets${types ? `?type=${types.join(",")}` : ""}`;
|
|
19998
|
+
var marketsCache = {};
|
|
19998
19999
|
var marketsCacheTimestamp = 0;
|
|
19999
20000
|
var MARKETS_CACHE_TTL = 5 * 60 * 1e3;
|
|
20000
|
-
async function fetchMarketsForChain(chainId) {
|
|
20001
|
-
try {
|
|
20002
|
-
const response = await fetch(MARKETS_ENDPOINT(chainId));
|
|
20003
|
-
const data = await response.json();
|
|
20004
|
-
return data.markets || [];
|
|
20005
|
-
} catch (error) {
|
|
20006
|
-
console.error(`Error fetching markets for chain ${chainId}:`, error);
|
|
20007
|
-
return [];
|
|
20008
|
-
}
|
|
20009
|
-
}
|
|
20010
20001
|
async function fetchPendleMarkets() {
|
|
20011
|
-
|
|
20012
|
-
if (marketsCache && now - marketsCacheTimestamp < MARKETS_CACHE_TTL) {
|
|
20002
|
+
if (Object.keys(marketsCache).length && marketsCacheTimestamp > Date.now() - MARKETS_CACHE_TTL) {
|
|
20013
20003
|
return marketsCache;
|
|
20014
20004
|
}
|
|
20015
20005
|
try {
|
|
20016
|
-
const
|
|
20017
|
-
|
|
20018
|
-
|
|
20019
|
-
const chainMarkets = fetchMarketsForChain(chainId);
|
|
20020
|
-
promises.push(chainMarkets);
|
|
20006
|
+
const response = await fetch(MARKETS_ENDPOINT);
|
|
20007
|
+
if (!response.ok) {
|
|
20008
|
+
throw new Error(`Failed to fetch all markets data: ${response.status}`);
|
|
20021
20009
|
}
|
|
20022
|
-
const
|
|
20023
|
-
|
|
20024
|
-
|
|
20025
|
-
|
|
20026
|
-
|
|
20027
|
-
|
|
20010
|
+
const data = await response.json();
|
|
20011
|
+
const marketsByChain = {};
|
|
20012
|
+
if (data.markets) {
|
|
20013
|
+
for (const market of data.markets) {
|
|
20014
|
+
const chainId = market.chainId.toString();
|
|
20015
|
+
if (!marketsByChain[chainId]) {
|
|
20016
|
+
marketsByChain[chainId] = [];
|
|
20017
|
+
}
|
|
20018
|
+
marketsByChain[chainId].push(market);
|
|
20019
|
+
}
|
|
20020
|
+
}
|
|
20021
|
+
marketsCache = marketsByChain;
|
|
20022
|
+
marketsCacheTimestamp = Date.now();
|
|
20023
|
+
return marketsByChain;
|
|
20028
20024
|
} catch (error) {
|
|
20029
|
-
console.error("Error fetching
|
|
20030
|
-
return
|
|
20025
|
+
console.error("Error fetching all markets data:", error);
|
|
20026
|
+
return {};
|
|
20031
20027
|
}
|
|
20032
20028
|
}
|
|
20033
|
-
async function
|
|
20029
|
+
async function fetchPendlePricesForAllChain(lists = {}, assetType = ["YT", "PT"]) {
|
|
20034
20030
|
try {
|
|
20035
|
-
const
|
|
20036
|
-
|
|
20037
|
-
|
|
20038
|
-
|
|
20039
|
-
const
|
|
20040
|
-
|
|
20041
|
-
|
|
20042
|
-
|
|
20043
|
-
|
|
20044
|
-
return allPrices;
|
|
20031
|
+
const response = await fetch(PRICES_ENDPOINT(assetType));
|
|
20032
|
+
const data = await response.json();
|
|
20033
|
+
let prices = {};
|
|
20034
|
+
Object.entries(data.prices).forEach(([key, val]) => {
|
|
20035
|
+
const [chainId, address] = key.split("-");
|
|
20036
|
+
const assetKey = lists[chainId]?.list?.[address.toLowerCase()]?.assetGroup ?? key;
|
|
20037
|
+
prices[assetKey] = val;
|
|
20038
|
+
});
|
|
20039
|
+
return prices;
|
|
20045
20040
|
} catch (error) {
|
|
20046
|
-
console.error(`Error fetching
|
|
20041
|
+
console.error(`Error fetching prices pendle prices:`, error);
|
|
20047
20042
|
return {};
|
|
20048
20043
|
}
|
|
20049
20044
|
}
|
|
20050
|
-
function
|
|
20051
|
-
const tokensByChain = {};
|
|
20052
|
-
markets.forEach((market) => {
|
|
20053
|
-
const chain = market.pt?.split("-")[0];
|
|
20054
|
-
if (chain && !tokensByChain[chain]) {
|
|
20055
|
-
tokensByChain[chain] = { pt: [], yt: [], sy: [] };
|
|
20056
|
-
}
|
|
20057
|
-
if (market.pt && chain) {
|
|
20058
|
-
const address = market.pt.split("-")[1];
|
|
20059
|
-
if (address && !tokensByChain[chain].pt.includes(address)) {
|
|
20060
|
-
tokensByChain[chain].pt.push(address);
|
|
20061
|
-
}
|
|
20062
|
-
}
|
|
20063
|
-
if (market.yt && chain) {
|
|
20064
|
-
const address = market.yt.split("-")[1];
|
|
20065
|
-
if (address && !tokensByChain[chain].yt.includes(address)) {
|
|
20066
|
-
tokensByChain[chain].yt.push(address);
|
|
20067
|
-
}
|
|
20068
|
-
}
|
|
20069
|
-
if (market.sy && chain) {
|
|
20070
|
-
const address = market.sy.split("-")[1];
|
|
20071
|
-
if (address && !tokensByChain[chain].sy.includes(address)) {
|
|
20072
|
-
tokensByChain[chain].sy.push(address);
|
|
20073
|
-
}
|
|
20074
|
-
}
|
|
20075
|
-
});
|
|
20076
|
-
return tokensByChain;
|
|
20077
|
-
}
|
|
20078
|
-
async function fetchPendlePrices() {
|
|
20045
|
+
async function fetchPendlePrices(lists = {}) {
|
|
20079
20046
|
try {
|
|
20080
20047
|
const marketsResponse = await fetchPendleMarkets();
|
|
20081
|
-
if (!marketsResponse.
|
|
20048
|
+
if (!Object.keys(marketsResponse).length) {
|
|
20082
20049
|
return {};
|
|
20083
20050
|
}
|
|
20084
|
-
const
|
|
20085
|
-
|
|
20051
|
+
const allPrices = await fetchPendlePricesForAllChain(lists);
|
|
20052
|
+
return Object.fromEntries(
|
|
20053
|
+
Object.entries(allPrices).filter(([, price]) => !!price)
|
|
20086
20054
|
);
|
|
20087
|
-
const allPrices = {};
|
|
20088
|
-
for (const chainId of SUPPORTED_CHAINS) {
|
|
20089
|
-
if (tokensByChain[chainId]) {
|
|
20090
|
-
const chainPrices = await fetchPendlePricesForChain(chainId, "YT");
|
|
20091
|
-
Object.entries(chainPrices).forEach(([address, price]) => {
|
|
20092
|
-
if (price !== 0) {
|
|
20093
|
-
const prefixedAddress = `${chainId}-${address}`;
|
|
20094
|
-
allPrices[prefixedAddress] = price;
|
|
20095
|
-
}
|
|
20096
|
-
});
|
|
20097
|
-
}
|
|
20098
|
-
}
|
|
20099
|
-
return allPrices;
|
|
20100
20055
|
} catch (error) {
|
|
20101
20056
|
console.error("Error in fetchPendlePrices:", error);
|
|
20102
20057
|
return {};
|
|
@@ -20270,7 +20225,7 @@ var fetchMainPrices = async (chainIds, rpcOverrides, lists = {}) => {
|
|
|
20270
20225
|
}
|
|
20271
20226
|
};
|
|
20272
20227
|
});
|
|
20273
|
-
const otherDataPromises = [fetchDefillamaData(), fetchPendlePrices()];
|
|
20228
|
+
const otherDataPromises = [fetchDefillamaData(), fetchPendlePrices(lists)];
|
|
20274
20229
|
const [chainResults, ...otherResults] = await Promise.all([
|
|
20275
20230
|
Promise.all(multicallPromises),
|
|
20276
20231
|
...otherDataPromises
|
|
@@ -20327,7 +20282,7 @@ var fetchMainPrices = async (chainIds, rpcOverrides, lists = {}) => {
|
|
|
20327
20282
|
...rwaData
|
|
20328
20283
|
};
|
|
20329
20284
|
}
|
|
20330
|
-
allPrices = { ...
|
|
20285
|
+
allPrices = { ...otherResults[0], ...allPrices, ...otherResults[1] };
|
|
20331
20286
|
for (const {
|
|
20332
20287
|
chainId,
|
|
20333
20288
|
result,
|