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