@continuumdao/ctm-mpc-defi 0.2.32 → 0.2.34
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/agent/catalog.cjs +117 -163
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.js +117 -163
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/skills/euler-v2/SKILL.md +1 -1
- package/dist/core/index.cjs +9 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.js +8 -1
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +9 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/aave-v4/index.js.map +1 -1
- package/dist/protocols/evm/euler-v2/index.cjs +301 -294
- package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
- package/dist/protocols/evm/euler-v2/index.d.ts +37 -4
- package/dist/protocols/evm/euler-v2/index.js +299 -296
- package/dist/protocols/evm/euler-v2/index.js.map +1 -1
- package/dist/protocols/evm/maple/index.cjs.map +1 -1
- package/dist/protocols/evm/maple/index.js.map +1 -1
- package/dist/protocols/evm/morpho/index.cjs.map +1 -1
- package/dist/protocols/evm/morpho/index.js.map +1 -1
- package/dist/protocols/evm/sky/index.cjs.map +1 -1
- package/dist/protocols/evm/sky/index.js.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.js.map +1 -1
- package/package.json +1 -1
package/dist/agent/catalog.js
CHANGED
|
@@ -21,9 +21,6 @@ var __export = (target, all) => {
|
|
|
21
21
|
function getAaveGraphqlProxyUrl() {
|
|
22
22
|
return aaveGraphqlProxyUrl;
|
|
23
23
|
}
|
|
24
|
-
function getEulerGraphqlProxyUrl() {
|
|
25
|
-
return eulerGraphqlProxyUrl;
|
|
26
|
-
}
|
|
27
24
|
function getMorphoGraphqlProxyUrl() {
|
|
28
25
|
return morphoGraphqlProxyUrl;
|
|
29
26
|
}
|
|
@@ -53,7 +50,7 @@ async function postJsonViaOptionalProxy(args) {
|
|
|
53
50
|
return await r.json();
|
|
54
51
|
}
|
|
55
52
|
async function getJsonViaOptionalProxy(args) {
|
|
56
|
-
const url = args.directUrl;
|
|
53
|
+
const url = args.proxyUrl?.trim() || args.directUrl;
|
|
57
54
|
const r = await fetch(url, { method: "GET", headers: { accept: "application/json" } });
|
|
58
55
|
if (!r.ok) {
|
|
59
56
|
const t = await r.text().catch(() => "");
|
|
@@ -61,7 +58,7 @@ async function getJsonViaOptionalProxy(args) {
|
|
|
61
58
|
}
|
|
62
59
|
return await r.json();
|
|
63
60
|
}
|
|
64
|
-
var aaveGraphqlProxyUrl,
|
|
61
|
+
var aaveGraphqlProxyUrl, morphoGraphqlProxyUrl;
|
|
65
62
|
var init_defiProxy = __esm({
|
|
66
63
|
"src/core/defiProxy.ts"() {
|
|
67
64
|
}
|
|
@@ -194,7 +191,8 @@ function midnightApiConfig() {
|
|
|
194
191
|
async function midnightGetJson(pathAndQuery) {
|
|
195
192
|
const path = pathAndQuery.startsWith("/") ? pathAndQuery : `/${pathAndQuery}`;
|
|
196
193
|
const directUrl = `${MORPHO_MIDNIGHT_REST_BASE}${path}`;
|
|
197
|
-
|
|
194
|
+
const proxyUrl = void 0;
|
|
195
|
+
return getJsonViaOptionalProxy({ directUrl, proxyUrl });
|
|
198
196
|
}
|
|
199
197
|
async function fetchMorphoMidnightBooks(args) {
|
|
200
198
|
const limit = args.limit == null ? void 0 : Math.min(Math.max(Math.floor(args.limit), 1), MORPHO_MIDNIGHT_BOOKS_MAX_LIMIT);
|
|
@@ -294,10 +292,10 @@ function morphoMidnightBookToMarketParams(book) {
|
|
|
294
292
|
async function fetchMorphoMidnightUserPositions(args) {
|
|
295
293
|
const user = args.user.trim();
|
|
296
294
|
if (!isAddress(user)) return [];
|
|
297
|
-
const
|
|
298
|
-
if (args.types)
|
|
299
|
-
if (args.activeOnly)
|
|
300
|
-
const q =
|
|
295
|
+
const qs2 = new URLSearchParams();
|
|
296
|
+
if (args.types) qs2.set("types", args.types);
|
|
297
|
+
if (args.activeOnly) qs2.set("active_only", "true");
|
|
298
|
+
const q = qs2.toString();
|
|
301
299
|
const path = `/users/${encodeURIComponent(getAddress(user))}/positions${q ? `?${q}` : ""}`;
|
|
302
300
|
const j = await midnightGetJson(path);
|
|
303
301
|
const rows = [];
|
|
@@ -320,10 +318,10 @@ async function fetchMorphoMidnightUserPositions(args) {
|
|
|
320
318
|
return rows;
|
|
321
319
|
}
|
|
322
320
|
async function fetchMorphoMidnightMakerOffers(args) {
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
if (args.chainId != null)
|
|
326
|
-
const j = await midnightGetJson(`/takeable-offers?${
|
|
321
|
+
const qs2 = new URLSearchParams();
|
|
322
|
+
qs2.set("maker", getAddress(args.maker));
|
|
323
|
+
if (args.chainId != null) qs2.set("chain_ids", String(args.chainId));
|
|
324
|
+
const j = await midnightGetJson(`/takeable-offers?${qs2}`);
|
|
327
325
|
const out = [];
|
|
328
326
|
for (const row of j.data ?? []) {
|
|
329
327
|
const o = row.offer;
|
|
@@ -7070,53 +7068,81 @@ var aaveV4ProtocolModule = {
|
|
|
7070
7068
|
]
|
|
7071
7069
|
};
|
|
7072
7070
|
registerProtocolModule(aaveV4ProtocolModule);
|
|
7071
|
+
|
|
7072
|
+
// src/protocols/evm/euler-v2/eulerV3Api.ts
|
|
7073
7073
|
init_defiProxy();
|
|
7074
|
-
var
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
const
|
|
7086
|
-
const
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7074
|
+
var EULER_V3_API_BASE = "https://v3.euler.finance";
|
|
7075
|
+
function qs(params) {
|
|
7076
|
+
const u = new URLSearchParams();
|
|
7077
|
+
for (const [k, v] of Object.entries(params)) {
|
|
7078
|
+
if (v == null) continue;
|
|
7079
|
+
u.set(k, String(v));
|
|
7080
|
+
}
|
|
7081
|
+
const s = u.toString();
|
|
7082
|
+
return s ? `?${s}` : "";
|
|
7083
|
+
}
|
|
7084
|
+
async function eulerV3Get(path, params = {}) {
|
|
7085
|
+
const rel = path.startsWith("/") ? path : `/${path}`;
|
|
7086
|
+
const query = qs(params);
|
|
7087
|
+
const directUrl = `${EULER_V3_API_BASE}${rel}${query}`;
|
|
7088
|
+
rel.replace(/^\/v3\/?/, "");
|
|
7089
|
+
const proxyUrl = void 0;
|
|
7090
|
+
return getJsonViaOptionalProxy({ directUrl, proxyUrl });
|
|
7091
|
+
}
|
|
7092
|
+
async function paginateV3Vaults(path, chainId, extra = {}) {
|
|
7093
|
+
const out = [];
|
|
7094
|
+
let offset = 0;
|
|
7095
|
+
const limit = 100;
|
|
7096
|
+
while (true) {
|
|
7097
|
+
const page = await eulerV3Get(path, {
|
|
7098
|
+
chainId,
|
|
7099
|
+
limit,
|
|
7100
|
+
offset,
|
|
7101
|
+
...extra
|
|
7102
|
+
});
|
|
7103
|
+
const rows = page.data ?? [];
|
|
7104
|
+
out.push(...rows);
|
|
7105
|
+
const total = typeof page.meta?.total === "number" ? page.meta.total : out.length;
|
|
7106
|
+
offset += rows.length;
|
|
7107
|
+
if (!rows.length || offset >= total) break;
|
|
7108
|
+
}
|
|
7109
|
+
return out;
|
|
7110
|
+
}
|
|
7111
|
+
async function fetchEulerV3EvkVaults(args) {
|
|
7112
|
+
return paginateV3Vaults("/v3/evk/vaults", args.chainId, args.asset ? { asset: args.asset } : {});
|
|
7113
|
+
}
|
|
7114
|
+
async function fetchEulerV3EarnVaults(args) {
|
|
7115
|
+
return paginateV3Vaults("/v3/earn/vaults", args.chainId, args.asset ? { asset: args.asset } : {});
|
|
7116
|
+
}
|
|
7117
|
+
async function fetchEulerV3ActiveChainIds() {
|
|
7118
|
+
const page = await eulerV3Get("/v3/chains");
|
|
7119
|
+
const ids = [];
|
|
7120
|
+
for (const row of page.data ?? []) {
|
|
7121
|
+
if (typeof row.id !== "number" || !Number.isFinite(row.id)) continue;
|
|
7122
|
+
if ((row.status ?? "active") !== "active") continue;
|
|
7123
|
+
ids.push(row.id);
|
|
7097
7124
|
}
|
|
7125
|
+
return ids.sort((a, b) => a - b);
|
|
7098
7126
|
}
|
|
7099
7127
|
|
|
7100
7128
|
// src/protocols/evm/euler-v2/eulerV2Subgraph.ts
|
|
7101
7129
|
var EULER_V2_GOLDSKY_SUBGRAPH_URL_BY_CHAIN_ID = {
|
|
7102
|
-
1: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-
|
|
7103
|
-
8453: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-
|
|
7104
|
-
1923: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-
|
|
7105
|
-
146: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-
|
|
7106
|
-
60808: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-
|
|
7107
|
-
80094: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-
|
|
7108
|
-
43114: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-
|
|
7109
|
-
42161: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-
|
|
7110
|
-
130: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
9745: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-v2-plasma/latest/gn",
|
|
7119
|
-
5e3: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-v2-mantle/latest/gn"
|
|
7130
|
+
1: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-simple-mainnet/latest/gn",
|
|
7131
|
+
8453: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-simple-base/latest/gn",
|
|
7132
|
+
1923: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-simple-swell/latest/gn",
|
|
7133
|
+
146: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-simple-sonic/latest/gn",
|
|
7134
|
+
60808: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-simple-bob/latest/gn",
|
|
7135
|
+
80094: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-simple-berachain/latest/gn",
|
|
7136
|
+
43114: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-simple-avalanche/latest/gn",
|
|
7137
|
+
42161: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-simple-arbitrum/latest/gn",
|
|
7138
|
+
130: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-simple-unichain/latest/gn",
|
|
7139
|
+
56: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-simple-bsc/latest/gn",
|
|
7140
|
+
999: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-simple-hyperevm/latest/gn",
|
|
7141
|
+
239: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-simple-tac/latest/gn",
|
|
7142
|
+
9745: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-simple-plasma/latest/gn",
|
|
7143
|
+
137: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-simple-polygon/latest/gn",
|
|
7144
|
+
59144: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-simple-linea/latest/gn",
|
|
7145
|
+
143: "https://api.goldsky.com/api/public/project_cm4iagnemt1wp01xn4gh1agft/subgraphs/euler-simple-monad/latest/gn"
|
|
7120
7146
|
};
|
|
7121
7147
|
var WRAPPED_NATIVE_FALLBACK = {
|
|
7122
7148
|
1: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
@@ -7124,6 +7150,10 @@ var WRAPPED_NATIVE_FALLBACK = {
|
|
|
7124
7150
|
56: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
|
|
7125
7151
|
100: "0xe91d153e0b41518a2ce8dd3d7944fa863463a97d",
|
|
7126
7152
|
130: "0x4200000000000000000000000000000000000006",
|
|
7153
|
+
137: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
|
|
7154
|
+
// Polygon: WPOL
|
|
7155
|
+
143: "0x3bd359C1119dA7Da1D913D1C4D2B7c461115433A",
|
|
7156
|
+
// Monad: WMON
|
|
7127
7157
|
146: "0x03980325872071166574bcd94670450917897468",
|
|
7128
7158
|
239: "0xB63B9f0eb4A6E6f191529D71d4D88cc8900Df2C9",
|
|
7129
7159
|
// TAC: WTAC (https://docs.tac.build/ecosystem/token-list)
|
|
@@ -7135,6 +7165,8 @@ var WRAPPED_NATIVE_FALLBACK = {
|
|
|
7135
7165
|
43114: "0xB31f66AA3C1e785363F0875A1B74D27b85FE0459",
|
|
7136
7166
|
5e3: "0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8",
|
|
7137
7167
|
// Mantle: WMNT
|
|
7168
|
+
59144: "0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f",
|
|
7169
|
+
// Linea: WETH
|
|
7138
7170
|
57073: "0x4200000000000000000000000000000000000006",
|
|
7139
7171
|
60808: "0x4200000000000000000000000000000000000006",
|
|
7140
7172
|
80094: "0x6969696969696969696969696969696969696969",
|
|
@@ -7148,9 +7180,6 @@ for (const id of Object.keys(EULER_V2_GOLDSKY_SUBGRAPH_URL_BY_CHAIN_ID).map(Numb
|
|
|
7148
7180
|
throw new Error(`eulerV2Subgraph: add WRAPPED_NATIVE_FALLBACK for Euler Goldsky chain ${id}`);
|
|
7149
7181
|
}
|
|
7150
7182
|
}
|
|
7151
|
-
function eulerV2GoldskyUrlForChain(chainId) {
|
|
7152
|
-
return EULER_V2_GOLDSKY_SUBGRAPH_URL_BY_CHAIN_ID[chainId];
|
|
7153
|
-
}
|
|
7154
7183
|
async function resolveEulerWrappedNativeToken(chainId) {
|
|
7155
7184
|
try {
|
|
7156
7185
|
const fromAave = await fetchAaveV4NativeWrappedToken(chainId);
|
|
@@ -7161,112 +7190,25 @@ async function resolveEulerWrappedNativeToken(chainId) {
|
|
|
7161
7190
|
if (fb && isAddress(fb)) return getAddress(fb);
|
|
7162
7191
|
return null;
|
|
7163
7192
|
}
|
|
7164
|
-
async function eulerSubgraphGql(endpoint, query, variables, chainId) {
|
|
7165
|
-
const body = { query, variables: variables ?? {} };
|
|
7166
|
-
const proxy = getEulerGraphqlProxyUrl();
|
|
7167
|
-
const j = await postJsonViaOptionalProxy({
|
|
7168
|
-
directUrl: endpoint,
|
|
7169
|
-
body,
|
|
7170
|
-
proxyUrl: proxy,
|
|
7171
|
-
proxyEnvelope: chainId != null ? { chainId, query, variables: variables ?? {} } : body
|
|
7172
|
-
});
|
|
7173
|
-
if (j.errors?.length) {
|
|
7174
|
-
throw new Error(j.errors.map((e) => e.message ?? "Unknown").join("; "));
|
|
7175
|
-
}
|
|
7176
|
-
if (j.data == null) throw new Error("Euler subgraph: empty response");
|
|
7177
|
-
return j.data;
|
|
7178
|
-
}
|
|
7179
|
-
async function eulerV2QueryGraphQl(chainId, query, variables) {
|
|
7180
|
-
const endpoint = eulerV2GoldskyUrlForChain(chainId);
|
|
7181
|
-
if (!endpoint) {
|
|
7182
|
-
throw new Error(`Euler v2 subgraph is not configured for chain ${chainId}`);
|
|
7183
|
-
}
|
|
7184
|
-
return eulerSubgraphGql(endpoint, query, variables, chainId);
|
|
7185
|
-
}
|
|
7186
7193
|
function normAssetAddr(raw) {
|
|
7187
7194
|
const s = (raw ?? "").trim();
|
|
7188
7195
|
if (!s || !isAddress(s)) return null;
|
|
7189
7196
|
return getAddress(s).toLowerCase();
|
|
7190
7197
|
}
|
|
7191
|
-
function
|
|
7192
|
-
|
|
7198
|
+
function v3VaultShowsBorrow(totalBorrows, explorableBorrow) {
|
|
7199
|
+
if (explorableBorrow === true) return true;
|
|
7193
7200
|
try {
|
|
7194
|
-
|
|
7201
|
+
return BigInt((totalBorrows ?? "0").trim() || "0") > 0n;
|
|
7195
7202
|
} catch {
|
|
7196
|
-
|
|
7197
|
-
}
|
|
7198
|
-
if (borrows > 0n) return true;
|
|
7199
|
-
const w = eulerSubgraphVaultCapToUnderlyingWei(borrowCap);
|
|
7200
|
-
if (w >= EULER_EVAULT_CAP_UNLIMITED_WEI - 3n) return true;
|
|
7201
|
-
return w > 0n;
|
|
7202
|
-
}
|
|
7203
|
-
var VAULT_PAGE = `
|
|
7204
|
-
query V($first: Int!, $skip: Int!) {
|
|
7205
|
-
eulerVaults(first: $first, skip: $skip) {
|
|
7206
|
-
asset
|
|
7207
|
-
borrowCap
|
|
7208
|
-
state { totalBorrows }
|
|
7209
|
-
}
|
|
7210
|
-
}
|
|
7211
|
-
`;
|
|
7212
|
-
var EARN_PAGE = `
|
|
7213
|
-
query E($first: Int!, $skip: Int!) {
|
|
7214
|
-
eulerEarnVaults(first: $first, skip: $skip) {
|
|
7215
|
-
asset
|
|
7216
|
-
}
|
|
7217
|
-
}
|
|
7218
|
-
`;
|
|
7219
|
-
async function paginateEulerVaultRows(chainId) {
|
|
7220
|
-
const out = [];
|
|
7221
|
-
let skip = 0;
|
|
7222
|
-
const first = 1e3;
|
|
7223
|
-
while (true) {
|
|
7224
|
-
const d = await eulerV2QueryGraphQl(chainId, VAULT_PAGE, { first, skip });
|
|
7225
|
-
const rows = d.eulerVaults ?? [];
|
|
7226
|
-
if (!rows.length) break;
|
|
7227
|
-
for (const r of rows) {
|
|
7228
|
-
const tb = (r.state?.totalBorrows ?? "0").toString();
|
|
7229
|
-
out.push({ asset: r.asset ?? null, borrowCap: r.borrowCap, totalBorrows: tb });
|
|
7230
|
-
}
|
|
7231
|
-
if (rows.length < first) break;
|
|
7232
|
-
skip += first;
|
|
7233
|
-
}
|
|
7234
|
-
return out;
|
|
7235
|
-
}
|
|
7236
|
-
async function paginateEulerEarnAssets(chainId) {
|
|
7237
|
-
const assets = [];
|
|
7238
|
-
let skip = 0;
|
|
7239
|
-
const first = 1e3;
|
|
7240
|
-
while (true) {
|
|
7241
|
-
const d = await eulerV2QueryGraphQl(
|
|
7242
|
-
chainId,
|
|
7243
|
-
EARN_PAGE,
|
|
7244
|
-
{
|
|
7245
|
-
first,
|
|
7246
|
-
skip
|
|
7247
|
-
}
|
|
7248
|
-
);
|
|
7249
|
-
const rows = d.eulerEarnVaults ?? [];
|
|
7250
|
-
if (!rows.length) break;
|
|
7251
|
-
for (const r of rows) {
|
|
7252
|
-
const a = normAssetAddr(r.asset ?? void 0);
|
|
7253
|
-
if (a) assets.push(a);
|
|
7254
|
-
}
|
|
7255
|
-
if (rows.length < first) break;
|
|
7256
|
-
skip += first;
|
|
7203
|
+
return false;
|
|
7257
7204
|
}
|
|
7258
|
-
return assets;
|
|
7259
7205
|
}
|
|
7260
7206
|
var eulerV2ChainAssetCache = /* @__PURE__ */ new Map();
|
|
7261
7207
|
async function fetchEulerV2ChainAssetCache(chainId) {
|
|
7262
|
-
const
|
|
7263
|
-
if (!endpoint) {
|
|
7264
|
-
return { nativeWrapped: null, modesByUnderlying: /* @__PURE__ */ new Map() };
|
|
7265
|
-
}
|
|
7266
|
-
const [nativeWrapped, vaultRows, earnAssets] = await Promise.all([
|
|
7208
|
+
const [nativeWrapped, evkVaults, earnVaults] = await Promise.all([
|
|
7267
7209
|
resolveEulerWrappedNativeToken(chainId),
|
|
7268
|
-
|
|
7269
|
-
|
|
7210
|
+
fetchEulerV3EvkVaults({ chainId }),
|
|
7211
|
+
fetchEulerV3EarnVaults({ chainId }).catch(() => [])
|
|
7270
7212
|
]);
|
|
7271
7213
|
const modes = /* @__PURE__ */ new Map();
|
|
7272
7214
|
const bump = (addr, patch) => {
|
|
@@ -7277,13 +7219,17 @@ async function fetchEulerV2ChainAssetCache(chainId) {
|
|
|
7277
7219
|
earn: cur.earn || !!patch.earn
|
|
7278
7220
|
});
|
|
7279
7221
|
};
|
|
7280
|
-
for (const
|
|
7281
|
-
|
|
7282
|
-
|
|
7222
|
+
for (const v of earnVaults) {
|
|
7223
|
+
const a = normAssetAddr(v.asset?.address ?? void 0);
|
|
7224
|
+
if (a) bump(a, { earn: true });
|
|
7225
|
+
}
|
|
7226
|
+
for (const v of evkVaults) {
|
|
7227
|
+
const a = normAssetAddr(v.asset?.address ?? void 0);
|
|
7283
7228
|
if (!a) continue;
|
|
7229
|
+
const vis = v.visibility;
|
|
7284
7230
|
bump(a, {
|
|
7285
|
-
lend:
|
|
7286
|
-
borrow:
|
|
7231
|
+
lend: vis?.explorableLend !== false,
|
|
7232
|
+
borrow: v3VaultShowsBorrow(v.totalBorrows, vis?.explorableBorrow)
|
|
7287
7233
|
});
|
|
7288
7234
|
}
|
|
7289
7235
|
return { nativeWrapped, modesByUnderlying: modes };
|
|
@@ -7301,10 +7247,18 @@ function ensureEulerV2ChainAssetCache(chainId) {
|
|
|
7301
7247
|
|
|
7302
7248
|
// src/protocols/evm/euler-v2/loadEulerV2SupportedChainIds.ts
|
|
7303
7249
|
var cached = null;
|
|
7304
|
-
function loadEulerV2SupportedChainIds() {
|
|
7305
|
-
if (cached) return
|
|
7250
|
+
async function loadEulerV2SupportedChainIds() {
|
|
7251
|
+
if (cached) return cached;
|
|
7252
|
+
try {
|
|
7253
|
+
const ids = await fetchEulerV3ActiveChainIds();
|
|
7254
|
+
if (ids.length) {
|
|
7255
|
+
cached = new Set(ids);
|
|
7256
|
+
return cached;
|
|
7257
|
+
}
|
|
7258
|
+
} catch {
|
|
7259
|
+
}
|
|
7306
7260
|
cached = new Set(Object.keys(EULER_V2_GOLDSKY_SUBGRAPH_URL_BY_CHAIN_ID).map((k) => Number(k)));
|
|
7307
|
-
return
|
|
7261
|
+
return cached;
|
|
7308
7262
|
}
|
|
7309
7263
|
|
|
7310
7264
|
// src/protocols/evm/euler-v2/index.ts
|
|
@@ -7352,8 +7306,8 @@ function buildGmxUrl(baseUrl, path, query) {
|
|
|
7352
7306
|
for (const [key, value] of Object.entries(query)) {
|
|
7353
7307
|
if (value !== void 0 && value !== null) params.set(key, String(value));
|
|
7354
7308
|
}
|
|
7355
|
-
const
|
|
7356
|
-
return
|
|
7309
|
+
const qs2 = params.toString();
|
|
7310
|
+
return qs2 ? `${base}${path}?${qs2}` : `${base}${path}`;
|
|
7357
7311
|
}
|
|
7358
7312
|
function bigintReplacer(_key, value) {
|
|
7359
7313
|
return typeof value === "bigint" ? value.toString() : value;
|
|
@@ -9531,7 +9485,7 @@ var PROTOCOL_SUPPORT_ADVISORS = {
|
|
|
9531
9485
|
return {
|
|
9532
9486
|
tokens,
|
|
9533
9487
|
nativeWrapped: cache.nativeWrapped ?? void 0,
|
|
9534
|
-
notes: "Euler EVK vault underlyings and Earn vault assets from the
|
|
9488
|
+
notes: "Euler EVK vault underlyings and Earn vault assets from the Euler V3 API. Use address as underlyingAddress for ctm_euler_v2_fetch_lend_vaults."
|
|
9535
9489
|
};
|
|
9536
9490
|
},
|
|
9537
9491
|
async isTokenSupported(chainId, address) {
|