@continuumdao/ctm-mpc-defi 0.2.27 → 0.2.29
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 +737 -66
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.d.ts +1209 -21
- package/dist/agent/catalog.js +724 -67
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/skills/ethena/SKILL.md +1 -1
- package/dist/agent/skills/lido/SKILL.md +4 -1
- package/dist/agent/skills/morpho/SKILL.md +38 -6
- package/dist/agent/skills/uniswap-v4/SKILL.md +15 -0
- package/dist/core/index.cjs +19 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +8 -1
- package/dist/core/index.js +17 -1
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +363 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +361 -23
- 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/ethena/index.cjs +41 -4
- package/dist/protocols/evm/ethena/index.cjs.map +1 -1
- package/dist/protocols/evm/ethena/index.d.ts +12 -2
- package/dist/protocols/evm/ethena/index.js +38 -5
- package/dist/protocols/evm/ethena/index.js.map +1 -1
- package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
- package/dist/protocols/evm/euler-v2/index.js.map +1 -1
- package/dist/protocols/evm/lido/index.cjs +66 -1
- package/dist/protocols/evm/lido/index.cjs.map +1 -1
- package/dist/protocols/evm/lido/index.d.ts +11 -1
- package/dist/protocols/evm/lido/index.js +60 -2
- package/dist/protocols/evm/lido/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 +1153 -142
- package/dist/protocols/evm/morpho/index.cjs.map +1 -1
- package/dist/protocols/evm/morpho/index.d.ts +314 -8
- package/dist/protocols/evm/morpho/index.js +1131 -144
- package/dist/protocols/evm/morpho/index.js.map +1 -1
- package/dist/protocols/evm/permit2/index.cjs.map +1 -1
- package/dist/protocols/evm/permit2/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 +769 -23
- package/dist/protocols/evm/uniswap-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.d.ts +248 -9
- package/dist/protocols/evm/uniswap-v4/index.js +742 -25
- package/dist/protocols/evm/uniswap-v4/index.js.map +1 -1
- package/package.json +2 -1
package/dist/agent/catalog.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var viem = require('viem');
|
|
4
|
+
var api = require('@morpho-org/midnight-sdk/api');
|
|
4
5
|
var zodToJsonSchema = require('zod-to-json-schema');
|
|
5
6
|
var zod = require('zod');
|
|
6
7
|
var module$1 = require('module');
|
|
@@ -9,10 +10,62 @@ var fs = require('fs');
|
|
|
9
10
|
var path = require('path');
|
|
10
11
|
|
|
11
12
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
12
14
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
15
|
var __esm = (fn, res) => function __init() {
|
|
14
16
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
15
17
|
};
|
|
18
|
+
var __export = (target, all) => {
|
|
19
|
+
for (var name in all)
|
|
20
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// src/core/defiProxy.ts
|
|
24
|
+
function getAaveGraphqlProxyUrl() {
|
|
25
|
+
return aaveGraphqlProxyUrl;
|
|
26
|
+
}
|
|
27
|
+
function getMorphoGraphqlProxyUrl() {
|
|
28
|
+
return morphoGraphqlProxyUrl;
|
|
29
|
+
}
|
|
30
|
+
async function postJsonViaOptionalProxy(args) {
|
|
31
|
+
const proxy = args.proxyUrl?.trim();
|
|
32
|
+
if (proxy) {
|
|
33
|
+
const r2 = await fetch(proxy, {
|
|
34
|
+
method: "POST",
|
|
35
|
+
headers: { "content-type": "application/json" },
|
|
36
|
+
body: JSON.stringify(args.proxyEnvelope ?? args.body)
|
|
37
|
+
});
|
|
38
|
+
if (!r2.ok) {
|
|
39
|
+
const t = await r2.text().catch(() => "");
|
|
40
|
+
throw new Error(t ? `Proxy HTTP ${r2.status}: ${t.slice(0, 200)}` : `Proxy HTTP ${r2.status}`);
|
|
41
|
+
}
|
|
42
|
+
return await r2.json();
|
|
43
|
+
}
|
|
44
|
+
const r = await fetch(args.directUrl, {
|
|
45
|
+
method: "POST",
|
|
46
|
+
headers: { "content-type": "application/json" },
|
|
47
|
+
body: JSON.stringify(args.body)
|
|
48
|
+
});
|
|
49
|
+
if (!r.ok) {
|
|
50
|
+
const t = await r.text().catch(() => "");
|
|
51
|
+
throw new Error(t ? `HTTP ${r.status}: ${t.slice(0, 200)}` : `HTTP ${r.status}`);
|
|
52
|
+
}
|
|
53
|
+
return await r.json();
|
|
54
|
+
}
|
|
55
|
+
async function getJsonViaOptionalProxy(args) {
|
|
56
|
+
const url = args.directUrl;
|
|
57
|
+
const r = await fetch(url, { method: "GET", headers: { accept: "application/json" } });
|
|
58
|
+
if (!r.ok) {
|
|
59
|
+
const t = await r.text().catch(() => "");
|
|
60
|
+
throw new Error(t ? `HTTP ${r.status}: ${t.slice(0, 200)}` : `HTTP ${r.status}`);
|
|
61
|
+
}
|
|
62
|
+
return await r.json();
|
|
63
|
+
}
|
|
64
|
+
var aaveGraphqlProxyUrl, morphoGraphqlProxyUrl;
|
|
65
|
+
var init_defiProxy = __esm({
|
|
66
|
+
"src/core/defiProxy.ts"() {
|
|
67
|
+
}
|
|
68
|
+
});
|
|
16
69
|
|
|
17
70
|
// src/protocols/evm/arcus/support.ts
|
|
18
71
|
function isArcusChainSupported(chainId) {
|
|
@@ -39,6 +92,225 @@ var init_api = __esm({
|
|
|
39
92
|
}
|
|
40
93
|
});
|
|
41
94
|
|
|
95
|
+
// src/protocols/evm/morpho/midnightConstants.ts
|
|
96
|
+
var midnightConstants_exports = {};
|
|
97
|
+
__export(midnightConstants_exports, {
|
|
98
|
+
MORPHO_MIDNIGHT_ADDRESSES: () => MORPHO_MIDNIGHT_ADDRESSES,
|
|
99
|
+
MORPHO_MIDNIGHT_AUTHORIZE_FALLBACK_GAS: () => MORPHO_MIDNIGHT_AUTHORIZE_FALLBACK_GAS,
|
|
100
|
+
MORPHO_MIDNIGHT_BASE_CHAIN_ID: () => MORPHO_MIDNIGHT_BASE_CHAIN_ID,
|
|
101
|
+
MORPHO_MIDNIGHT_BOOKS_MAX_LIMIT: () => MORPHO_MIDNIGHT_BOOKS_MAX_LIMIT,
|
|
102
|
+
MORPHO_MIDNIGHT_BORROW_FALLBACK_GAS: () => MORPHO_MIDNIGHT_BORROW_FALLBACK_GAS,
|
|
103
|
+
MORPHO_MIDNIGHT_DEFAULT_DEADLINE_SECONDS: () => MORPHO_MIDNIGHT_DEFAULT_DEADLINE_SECONDS,
|
|
104
|
+
MORPHO_MIDNIGHT_DEFAULT_SLIPPAGE_PCT: () => MORPHO_MIDNIGHT_DEFAULT_SLIPPAGE_PCT,
|
|
105
|
+
MORPHO_MIDNIGHT_ERC20_APPROVE_FALLBACK: () => MORPHO_MIDNIGHT_ERC20_APPROVE_FALLBACK,
|
|
106
|
+
MORPHO_MIDNIGHT_LEND_FALLBACK_GAS: () => MORPHO_MIDNIGHT_LEND_FALLBACK_GAS,
|
|
107
|
+
MORPHO_MIDNIGHT_REPAY_FALLBACK_GAS: () => MORPHO_MIDNIGHT_REPAY_FALLBACK_GAS,
|
|
108
|
+
MORPHO_MIDNIGHT_REST_BASE: () => MORPHO_MIDNIGHT_REST_BASE,
|
|
109
|
+
MORPHO_MIDNIGHT_WETH_DEPOSIT_FALLBACK: () => MORPHO_MIDNIGHT_WETH_DEPOSIT_FALLBACK,
|
|
110
|
+
TOKEN_PERMIT_NONE: () => TOKEN_PERMIT_NONE,
|
|
111
|
+
morphoMidnightAddressesForChain: () => morphoMidnightAddressesForChain
|
|
112
|
+
});
|
|
113
|
+
function morphoMidnightAddressesForChain(chainId) {
|
|
114
|
+
return MORPHO_MIDNIGHT_ADDRESSES[chainId] ?? null;
|
|
115
|
+
}
|
|
116
|
+
var MORPHO_MIDNIGHT_REST_BASE, MORPHO_MIDNIGHT_BOOKS_MAX_LIMIT, MORPHO_MIDNIGHT_DEFAULT_SLIPPAGE_PCT, MORPHO_MIDNIGHT_DEFAULT_DEADLINE_SECONDS, MORPHO_MIDNIGHT_BASE_CHAIN_ID, MORPHO_MIDNIGHT_ADDRESSES, TOKEN_PERMIT_NONE, MORPHO_MIDNIGHT_LEND_FALLBACK_GAS, MORPHO_MIDNIGHT_BORROW_FALLBACK_GAS, MORPHO_MIDNIGHT_REPAY_FALLBACK_GAS, MORPHO_MIDNIGHT_AUTHORIZE_FALLBACK_GAS, MORPHO_MIDNIGHT_ERC20_APPROVE_FALLBACK, MORPHO_MIDNIGHT_WETH_DEPOSIT_FALLBACK;
|
|
117
|
+
var init_midnightConstants = __esm({
|
|
118
|
+
"src/protocols/evm/morpho/midnightConstants.ts"() {
|
|
119
|
+
MORPHO_MIDNIGHT_REST_BASE = "https://api.morpho.org/v0/midnight";
|
|
120
|
+
MORPHO_MIDNIGHT_BOOKS_MAX_LIMIT = 20;
|
|
121
|
+
MORPHO_MIDNIGHT_DEFAULT_SLIPPAGE_PCT = "0.5";
|
|
122
|
+
MORPHO_MIDNIGHT_DEFAULT_DEADLINE_SECONDS = 3600;
|
|
123
|
+
MORPHO_MIDNIGHT_BASE_CHAIN_ID = 8453;
|
|
124
|
+
MORPHO_MIDNIGHT_ADDRESSES = {
|
|
125
|
+
[MORPHO_MIDNIGHT_BASE_CHAIN_ID]: {
|
|
126
|
+
midnight: "0xadedd8ab6de832766fedf0fac4992e5c4d3ea18a",
|
|
127
|
+
bundles: "0x6688dEc8878f43905e11B3C6Bc025E098133144f"
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
TOKEN_PERMIT_NONE = { kind: 0, data: "0x" };
|
|
131
|
+
MORPHO_MIDNIGHT_LEND_FALLBACK_GAS = 2500000n;
|
|
132
|
+
MORPHO_MIDNIGHT_BORROW_FALLBACK_GAS = 3000000n;
|
|
133
|
+
MORPHO_MIDNIGHT_REPAY_FALLBACK_GAS = 2200000n;
|
|
134
|
+
MORPHO_MIDNIGHT_AUTHORIZE_FALLBACK_GAS = 80000n;
|
|
135
|
+
MORPHO_MIDNIGHT_ERC20_APPROVE_FALLBACK = 100000n;
|
|
136
|
+
MORPHO_MIDNIGHT_WETH_DEPOSIT_FALLBACK = 120000n;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// src/protocols/evm/morpho/midnightApi.ts
|
|
141
|
+
var midnightApi_exports = {};
|
|
142
|
+
__export(midnightApi_exports, {
|
|
143
|
+
fetchMorphoMidnightBook: () => fetchMorphoMidnightBook,
|
|
144
|
+
fetchMorphoMidnightBookQuote: () => fetchMorphoMidnightBookQuote,
|
|
145
|
+
fetchMorphoMidnightBooks: () => fetchMorphoMidnightBooks,
|
|
146
|
+
fetchMorphoMidnightMarketById: () => fetchMorphoMidnightMarketById,
|
|
147
|
+
fetchMorphoMidnightUserMarketPosition: () => fetchMorphoMidnightUserMarketPosition,
|
|
148
|
+
fetchMorphoMidnightUserPositions: () => fetchMorphoMidnightUserPositions,
|
|
149
|
+
morphoMidnightApiBaseUrl: () => morphoMidnightApiBaseUrl,
|
|
150
|
+
morphoMidnightBookToMarketParams: () => morphoMidnightBookToMarketParams,
|
|
151
|
+
morphoMidnightMarketToParams: () => morphoMidnightMarketToParams
|
|
152
|
+
});
|
|
153
|
+
function morphoMidnightApiBaseUrl() {
|
|
154
|
+
return MORPHO_MIDNIGHT_REST_BASE;
|
|
155
|
+
}
|
|
156
|
+
function midnightApiConfig() {
|
|
157
|
+
return { baseUrl: morphoMidnightApiBaseUrl() };
|
|
158
|
+
}
|
|
159
|
+
async function midnightGetJson(pathAndQuery) {
|
|
160
|
+
const path = pathAndQuery.startsWith("/") ? pathAndQuery : `/${pathAndQuery}`;
|
|
161
|
+
const directUrl = `${MORPHO_MIDNIGHT_REST_BASE}${path}`;
|
|
162
|
+
return getJsonViaOptionalProxy({ directUrl});
|
|
163
|
+
}
|
|
164
|
+
async function fetchMorphoMidnightBooks(args) {
|
|
165
|
+
const limit = args.limit == null ? void 0 : Math.min(Math.max(Math.floor(args.limit), 1), MORPHO_MIDNIGHT_BOOKS_MAX_LIMIT);
|
|
166
|
+
const result = await api.MidnightApi.fetchBooks({
|
|
167
|
+
...midnightApiConfig(),
|
|
168
|
+
chainIds: [args.chainId],
|
|
169
|
+
loanTokens: args.loanTokens?.filter((a) => viem.isAddress(a)).map((a) => viem.getAddress(a)),
|
|
170
|
+
collateralTokens: args.collateralTokens?.filter((a) => viem.isAddress(a)).map((a) => viem.getAddress(a)),
|
|
171
|
+
sort: args.sort ? [args.sort] : ["maturity"],
|
|
172
|
+
limit,
|
|
173
|
+
cursor: args.cursor
|
|
174
|
+
});
|
|
175
|
+
return { data: [...result.data], cursor: result.cursor ?? null };
|
|
176
|
+
}
|
|
177
|
+
async function fetchMorphoMidnightBook(marketId) {
|
|
178
|
+
const id = marketId.trim();
|
|
179
|
+
if (!id) return null;
|
|
180
|
+
try {
|
|
181
|
+
const result = await api.MidnightApi.fetchBook({
|
|
182
|
+
...midnightApiConfig(),
|
|
183
|
+
marketId: id
|
|
184
|
+
});
|
|
185
|
+
return result.data;
|
|
186
|
+
} catch {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
async function fetchMorphoMidnightBookQuote(args) {
|
|
191
|
+
const quote = await api.MidnightApi.fetchBookQuote({
|
|
192
|
+
...midnightApiConfig(),
|
|
193
|
+
marketId: args.marketId.trim(),
|
|
194
|
+
side: args.side,
|
|
195
|
+
assets: args.assets,
|
|
196
|
+
slippage: args.slippage?.trim() || "0.5"
|
|
197
|
+
});
|
|
198
|
+
return quote.data;
|
|
199
|
+
}
|
|
200
|
+
async function fetchMorphoMidnightMarketById(marketId) {
|
|
201
|
+
const id = marketId.trim();
|
|
202
|
+
if (!id) return null;
|
|
203
|
+
const j = await midnightGetJson(`/markets/${encodeURIComponent(id)}`);
|
|
204
|
+
const d = j.data;
|
|
205
|
+
if (!d?.market_id || !d.loan_token || !viem.isAddress(d.loan_token)) return null;
|
|
206
|
+
const midnight = d.midnight && viem.isAddress(d.midnight) ? viem.getAddress(d.midnight) : "0x0000000000000000000000000000000000000000";
|
|
207
|
+
const collaterals = (d.collaterals ?? []).filter((c) => c.token && viem.isAddress(c.token) && c.oracle && viem.isAddress(c.oracle)).map((c) => ({
|
|
208
|
+
token: viem.getAddress(c.token),
|
|
209
|
+
lltv: String(c.lltv ?? "0"),
|
|
210
|
+
liquidationCursor: String(c.liquidation_cursor ?? "0"),
|
|
211
|
+
oracle: viem.getAddress(c.oracle)
|
|
212
|
+
}));
|
|
213
|
+
return {
|
|
214
|
+
chainId: Number(d.chain_id ?? 0),
|
|
215
|
+
marketId: d.market_id,
|
|
216
|
+
midnight,
|
|
217
|
+
loanToken: viem.getAddress(d.loan_token),
|
|
218
|
+
maturity: Number(d.maturity ?? 0),
|
|
219
|
+
rcfThreshold: String(d.rcf_threshold ?? "0"),
|
|
220
|
+
enterGate: d.enter_gate && viem.isAddress(d.enter_gate) ? viem.getAddress(d.enter_gate) : viem.getAddress("0x0000000000000000000000000000000000000000"),
|
|
221
|
+
liquidatorGate: d.liquidator_gate && viem.isAddress(d.liquidator_gate) ? viem.getAddress(d.liquidator_gate) : viem.getAddress("0x0000000000000000000000000000000000000000"),
|
|
222
|
+
collaterals
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function morphoMidnightMarketToParams(row) {
|
|
226
|
+
return {
|
|
227
|
+
chainId: BigInt(row.chainId),
|
|
228
|
+
midnight: row.midnight,
|
|
229
|
+
loanToken: row.loanToken,
|
|
230
|
+
collateralParams: row.collaterals.map((c) => ({
|
|
231
|
+
token: c.token,
|
|
232
|
+
lltv: BigInt(c.lltv),
|
|
233
|
+
liquidationCursor: BigInt(c.liquidationCursor),
|
|
234
|
+
oracle: c.oracle
|
|
235
|
+
})),
|
|
236
|
+
maturity: BigInt(row.maturity),
|
|
237
|
+
rcfThreshold: BigInt(row.rcfThreshold),
|
|
238
|
+
enterGate: row.enterGate,
|
|
239
|
+
liquidatorGate: row.liquidatorGate
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
function morphoMidnightBookToMarketParams(book) {
|
|
243
|
+
return {
|
|
244
|
+
chainId: BigInt(book.chainId),
|
|
245
|
+
midnight: viem.getAddress(book.midnight),
|
|
246
|
+
loanToken: viem.getAddress(book.loanToken),
|
|
247
|
+
collateralParams: book.collaterals.map((c) => ({
|
|
248
|
+
token: viem.getAddress(c.token),
|
|
249
|
+
lltv: BigInt(c.lltv),
|
|
250
|
+
liquidationCursor: BigInt(c.liquidationCursor),
|
|
251
|
+
oracle: viem.getAddress(c.oracle)
|
|
252
|
+
})),
|
|
253
|
+
maturity: BigInt(book.maturity),
|
|
254
|
+
rcfThreshold: BigInt(book.rcfThreshold),
|
|
255
|
+
enterGate: viem.getAddress(book.enterGate),
|
|
256
|
+
liquidatorGate: viem.getAddress(book.liquidatorGate)
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
async function fetchMorphoMidnightUserPositions(args) {
|
|
260
|
+
const user = args.user.trim();
|
|
261
|
+
if (!viem.isAddress(user)) return [];
|
|
262
|
+
const qs = new URLSearchParams();
|
|
263
|
+
if (args.types) qs.set("types", args.types);
|
|
264
|
+
if (args.activeOnly) qs.set("active_only", "true");
|
|
265
|
+
const q = qs.toString();
|
|
266
|
+
const path = `/users/${encodeURIComponent(viem.getAddress(user))}/positions${q ? `?${q}` : ""}`;
|
|
267
|
+
const j = await midnightGetJson(path);
|
|
268
|
+
const rows = [];
|
|
269
|
+
for (const p of j.data ?? []) {
|
|
270
|
+
if (!p.market_id) continue;
|
|
271
|
+
rows.push({
|
|
272
|
+
marketId: p.market_id,
|
|
273
|
+
type: p.type ?? "lend",
|
|
274
|
+
credit: String(p.credit ?? "0"),
|
|
275
|
+
debt: String(p.debt ?? "0"),
|
|
276
|
+
pendingFee: String(p.pending_fee ?? "0"),
|
|
277
|
+
lossFactor: String(p.loss_factor ?? "0"),
|
|
278
|
+
costBasis: p.cost_basis ?? null,
|
|
279
|
+
effectiveRateWad: p.effective_rate_wad ?? null,
|
|
280
|
+
maturity: p.maturity != null ? Number(p.maturity) : null,
|
|
281
|
+
loanToken: p.loan_token && viem.isAddress(p.loan_token) ? viem.getAddress(p.loan_token) : null,
|
|
282
|
+
collaterals: (p.collaterals ?? []).filter((c) => c.token && viem.isAddress(c.token)).map((c) => ({ token: viem.getAddress(c.token), amount: String(c.amount ?? "0") }))
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
return rows;
|
|
286
|
+
}
|
|
287
|
+
async function fetchMorphoMidnightUserMarketPosition(args) {
|
|
288
|
+
const marketId = args.marketId.trim();
|
|
289
|
+
const user = args.user.trim();
|
|
290
|
+
if (!marketId || !viem.isAddress(user)) return null;
|
|
291
|
+
const path = `/markets/${encodeURIComponent(marketId)}/users/${encodeURIComponent(viem.getAddress(user))}/position`;
|
|
292
|
+
const j = await midnightGetJson(path);
|
|
293
|
+
const p = j.data;
|
|
294
|
+
if (!p) return null;
|
|
295
|
+
return {
|
|
296
|
+
marketId,
|
|
297
|
+
type: p.type ?? "borrow",
|
|
298
|
+
credit: String(p.credit ?? "0"),
|
|
299
|
+
debt: String(p.debt ?? "0"),
|
|
300
|
+
pendingFee: String(p.pending_fee ?? "0"),
|
|
301
|
+
lossFactor: String(p.loss_factor ?? "0"),
|
|
302
|
+
maturity: p.maturity != null ? Number(p.maturity) : null,
|
|
303
|
+
loanToken: p.loan_token && viem.isAddress(p.loan_token) ? viem.getAddress(p.loan_token) : null,
|
|
304
|
+
collaterals: (p.collaterals ?? []).filter((c) => c.token && viem.isAddress(c.token)).map((c) => ({ token: viem.getAddress(c.token), amount: String(c.amount ?? "0") }))
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
var init_midnightApi = __esm({
|
|
308
|
+
"src/protocols/evm/morpho/midnightApi.ts"() {
|
|
309
|
+
init_defiProxy();
|
|
310
|
+
init_midnightConstants();
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
|
|
42
314
|
// src/core/registry.ts
|
|
43
315
|
var modules = [];
|
|
44
316
|
function registerProtocolModule(mod) {
|
|
@@ -121,41 +393,6 @@ function isUniswapV4ChainSupported(chainId) {
|
|
|
121
393
|
return typeof a === "string" && a.startsWith("0x");
|
|
122
394
|
}
|
|
123
395
|
|
|
124
|
-
// src/core/defiProxy.ts
|
|
125
|
-
var aaveGraphqlProxyUrl;
|
|
126
|
-
var morphoGraphqlProxyUrl;
|
|
127
|
-
function getAaveGraphqlProxyUrl() {
|
|
128
|
-
return aaveGraphqlProxyUrl;
|
|
129
|
-
}
|
|
130
|
-
function getMorphoGraphqlProxyUrl() {
|
|
131
|
-
return morphoGraphqlProxyUrl;
|
|
132
|
-
}
|
|
133
|
-
async function postJsonViaOptionalProxy(args) {
|
|
134
|
-
const proxy = args.proxyUrl?.trim();
|
|
135
|
-
if (proxy) {
|
|
136
|
-
const r2 = await fetch(proxy, {
|
|
137
|
-
method: "POST",
|
|
138
|
-
headers: { "content-type": "application/json" },
|
|
139
|
-
body: JSON.stringify(args.proxyEnvelope ?? args.body)
|
|
140
|
-
});
|
|
141
|
-
if (!r2.ok) {
|
|
142
|
-
const t = await r2.text().catch(() => "");
|
|
143
|
-
throw new Error(t ? `Proxy HTTP ${r2.status}: ${t.slice(0, 200)}` : `Proxy HTTP ${r2.status}`);
|
|
144
|
-
}
|
|
145
|
-
return await r2.json();
|
|
146
|
-
}
|
|
147
|
-
const r = await fetch(args.directUrl, {
|
|
148
|
-
method: "POST",
|
|
149
|
-
headers: { "content-type": "application/json" },
|
|
150
|
-
body: JSON.stringify(args.body)
|
|
151
|
-
});
|
|
152
|
-
if (!r.ok) {
|
|
153
|
-
const t = await r.text().catch(() => "");
|
|
154
|
-
throw new Error(t ? `HTTP ${r.status}: ${t.slice(0, 200)}` : `HTTP ${r.status}`);
|
|
155
|
-
}
|
|
156
|
-
return await r.json();
|
|
157
|
-
}
|
|
158
|
-
|
|
159
396
|
// src/protocols/evm/uniswap-v4/index.ts
|
|
160
397
|
var UNISWAP_V4_PROTOCOL_ID = "uniswap-v4";
|
|
161
398
|
var uniswapV4ProtocolModule = {
|
|
@@ -1135,11 +1372,15 @@ var mcpUniswapV4LpCreatePositionInputSchema = zod.z.preprocess(
|
|
|
1135
1372
|
);
|
|
1136
1373
|
var mcpUniswapV4LpListPoolsInputSchema = zod.z.object({
|
|
1137
1374
|
chainId: agentEvmChainIdSchema,
|
|
1138
|
-
pair: zod.z.string().optional().describe("Optional filter, e.g. eth-usdc or ETH/USDC")
|
|
1375
|
+
pair: zod.z.string().optional().describe("Optional filter, e.g. eth-usdc or ETH/USDC"),
|
|
1376
|
+
permissioned: agentOptionalBooleanSchema().describe(
|
|
1377
|
+
"When true, list Permissioned Position Manager pools (adapter currency + PermissionedHooks)"
|
|
1378
|
+
)
|
|
1139
1379
|
});
|
|
1140
1380
|
var mcpUniswapV4LpListPoolsOutputSchema = zod.z.object({
|
|
1141
1381
|
chainId: zod.z.number().int().positive(),
|
|
1142
1382
|
chainLabel: zod.z.string(),
|
|
1383
|
+
positionManagerKind: zod.z.enum(["standard", "permissioned"]).optional(),
|
|
1143
1384
|
pools: zod.z.array(
|
|
1144
1385
|
zod.z.object({
|
|
1145
1386
|
presetId: zod.z.string(),
|
|
@@ -1155,7 +1396,12 @@ var mcpUniswapV4LpListPoolsOutputSchema = zod.z.object({
|
|
|
1155
1396
|
poolReference: zod.z.string(),
|
|
1156
1397
|
hooks: evmAddressSchema,
|
|
1157
1398
|
nativeWrapped: evmAddressSchema.optional(),
|
|
1158
|
-
usesNativeEth: zod.z.boolean()
|
|
1399
|
+
usesNativeEth: zod.z.boolean(),
|
|
1400
|
+
positionManagerKind: zod.z.enum(["standard", "permissioned"]).optional(),
|
|
1401
|
+
positionManager: evmAddressSchema.optional(),
|
|
1402
|
+
adapterAddress: evmAddressSchema.optional(),
|
|
1403
|
+
underlyingPermissionedToken: evmAddressSchema.optional(),
|
|
1404
|
+
issuer: zod.z.string().optional()
|
|
1159
1405
|
})
|
|
1160
1406
|
),
|
|
1161
1407
|
notes: zod.z.string()
|
|
@@ -1237,7 +1483,9 @@ var mcpUniswapV4RegisterPositionFromMintTxOutputSchema = zod.z.object({
|
|
|
1237
1483
|
var lpBuildCommonSchema = {
|
|
1238
1484
|
lpResponse: jsonObjectSchema.describe("Full LP API response (create/increase/decrease/claim)"),
|
|
1239
1485
|
nativeWrapped: evmAddressSchema.optional(),
|
|
1240
|
-
poolReference: zod.z.string().optional()
|
|
1486
|
+
poolReference: zod.z.string().optional(),
|
|
1487
|
+
positionManagerKind: zod.z.enum(["standard", "permissioned"]).optional().describe("permissioned \u2192 Permit2 approve path + Permissioned Position Manager"),
|
|
1488
|
+
usePermit2Approvals: agentOptionalBooleanSchema()
|
|
1241
1489
|
};
|
|
1242
1490
|
var mcpUniswapV4BuildMintLiquidityMultisignInputSchema = withMultisignKeySourceRefine(
|
|
1243
1491
|
zod.z.preprocess(preprocessUniswapBuildLpInput, evmMultisignCommonInputSchema.extend(lpBuildCommonSchema))
|
|
@@ -1331,6 +1579,61 @@ var mcpUniswapV4FetchOhlcvOutputSchema = zod.z.object({
|
|
|
1331
1579
|
fetchedAtMs: zod.z.number(),
|
|
1332
1580
|
warnings: zod.z.array(zod.z.string()).optional()
|
|
1333
1581
|
}).strict();
|
|
1582
|
+
var mcpUniswapV4CheckPermissionsInputSchema = zod.z.object({
|
|
1583
|
+
walletAddress: evmAddressSchema.optional(),
|
|
1584
|
+
keyGen: zod.z.string().optional().describe("Resolves wallet via GET /getKeyGenResultById when walletAddress omitted"),
|
|
1585
|
+
managementNodeUrl: zod.z.string().optional(),
|
|
1586
|
+
tokens: zod.z.array(zod.z.string().min(1)).min(1).max(2).describe("Up to two token addresses"),
|
|
1587
|
+
chainId: agentEvmChainIdSchema,
|
|
1588
|
+
uniswapApiKey: zod.z.string().min(1),
|
|
1589
|
+
baseUrl: zod.z.string().optional()
|
|
1590
|
+
});
|
|
1591
|
+
var mcpUniswapV4CheckPermissionsOutputSchema = zod.z.object({
|
|
1592
|
+
requestId: zod.z.string().optional(),
|
|
1593
|
+
results: zod.z.array(
|
|
1594
|
+
zod.z.object({
|
|
1595
|
+
token: evmAddressSchema,
|
|
1596
|
+
isPermissioned: zod.z.boolean(),
|
|
1597
|
+
isAllowlisted: zod.z.boolean(),
|
|
1598
|
+
adapterTokenAddress: evmAddressSchema.optional(),
|
|
1599
|
+
kycUrl: zod.z.string().optional(),
|
|
1600
|
+
issuer: zod.z.string().optional()
|
|
1601
|
+
})
|
|
1602
|
+
),
|
|
1603
|
+
anyPermissioned: zod.z.boolean(),
|
|
1604
|
+
allAllowlisted: zod.z.boolean(),
|
|
1605
|
+
requiresUniversalRouterV22: zod.z.boolean()
|
|
1606
|
+
});
|
|
1607
|
+
var mcpUniswapV4KycApplyLinkInputSchema = zod.z.object({
|
|
1608
|
+
walletAddress: evmAddressSchema,
|
|
1609
|
+
chainId: agentEvmChainIdSchema,
|
|
1610
|
+
kycUrl: zod.z.string().min(1),
|
|
1611
|
+
issuer: zod.z.string().optional(),
|
|
1612
|
+
token: evmAddressSchema.optional(),
|
|
1613
|
+
adapterTokenAddress: evmAddressSchema.optional()
|
|
1614
|
+
});
|
|
1615
|
+
var mcpUniswapV4KycApplyLinkOutputSchema = zod.z.object({
|
|
1616
|
+
walletAddress: evmAddressSchema,
|
|
1617
|
+
chainId: zod.z.number().int(),
|
|
1618
|
+
issuer: zod.z.string().optional(),
|
|
1619
|
+
kycUrl: zod.z.string(),
|
|
1620
|
+
applyUrl: zod.z.string(),
|
|
1621
|
+
token: evmAddressSchema.optional(),
|
|
1622
|
+
adapterTokenAddress: evmAddressSchema.optional()
|
|
1623
|
+
});
|
|
1624
|
+
var mcpUniswapV4BuildAllowlistFinalizeMultisignInputSchema = withMultisignKeySourceRefine(
|
|
1625
|
+
zod.z.preprocess(
|
|
1626
|
+
preprocessUniswapBuildSwapInput,
|
|
1627
|
+
evmMultisignCommonInputSchema.extend({
|
|
1628
|
+
to: evmAddressSchema.describe("Allowlist contract from issuer onboard API"),
|
|
1629
|
+
data: zod.z.string().min(1).describe("ABI-encoded calldata (encodedTransaction)"),
|
|
1630
|
+
valueWei: zod.z.union([zod.z.string(), zod.z.number()]).optional(),
|
|
1631
|
+
issuer: zod.z.string().optional(),
|
|
1632
|
+
entityId: zod.z.union([zod.z.string(), zod.z.number()]).optional(),
|
|
1633
|
+
tokenAddress: evmAddressSchema.optional()
|
|
1634
|
+
})
|
|
1635
|
+
)
|
|
1636
|
+
);
|
|
1334
1637
|
var mcpCurveDaoQuoteInputSchema = zod.z.object({
|
|
1335
1638
|
chainId: agentEvmChainIdSchema.describe("EVM chain id (rpcUrl resolved from get_chain_registry rpcGateway)"),
|
|
1336
1639
|
rpcUrl: zod.z.string().min(1).optional().describe("JSON-RPC URL; continuum-mcp-server injects from chain registry \u2014 do not pass a public RPC URL"),
|
|
@@ -1501,6 +1804,116 @@ var mcpMorphoFetchBlueMarketsOutputSchema = zod.z.object({
|
|
|
1501
1804
|
})
|
|
1502
1805
|
)
|
|
1503
1806
|
});
|
|
1807
|
+
function preprocessMorphoMidnightLendInput(raw) {
|
|
1808
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
1809
|
+
const o = { ...raw };
|
|
1810
|
+
const purposeText = String(o.purposeText ?? o.purpose ?? "").trim();
|
|
1811
|
+
if (!purposeText) {
|
|
1812
|
+
const amt = String(o.amountHuman ?? "").trim();
|
|
1813
|
+
if (amt) o.purposeText = `Morpho Midnight lend ${amt}`;
|
|
1814
|
+
}
|
|
1815
|
+
return o;
|
|
1816
|
+
}
|
|
1817
|
+
function preprocessMorphoMidnightBorrowInput(raw) {
|
|
1818
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
1819
|
+
const o = { ...raw };
|
|
1820
|
+
if (o.collateralTokenAddress != null && o.collateralToken == null) {
|
|
1821
|
+
o.collateralToken = o.collateralTokenAddress;
|
|
1822
|
+
}
|
|
1823
|
+
if (o.loanTokenAddress != null && o.loanToken == null) {
|
|
1824
|
+
o.loanToken = o.loanTokenAddress;
|
|
1825
|
+
}
|
|
1826
|
+
if (o.borrowAmountHuman == null && o.amountHuman != null) {
|
|
1827
|
+
o.borrowAmountHuman = o.amountHuman;
|
|
1828
|
+
}
|
|
1829
|
+
const purposeText = String(o.purposeText ?? o.purpose ?? "").trim();
|
|
1830
|
+
if (!purposeText) {
|
|
1831
|
+
const amt = String(o.borrowAmountHuman ?? o.amountHuman ?? "").trim();
|
|
1832
|
+
if (amt) o.purposeText = `Morpho Midnight borrow ${amt}`;
|
|
1833
|
+
}
|
|
1834
|
+
return o;
|
|
1835
|
+
}
|
|
1836
|
+
function preprocessMorphoMidnightRepayInput(raw) {
|
|
1837
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
1838
|
+
const o = { ...raw };
|
|
1839
|
+
const purposeText = String(o.purposeText ?? o.purpose ?? "").trim();
|
|
1840
|
+
if (!purposeText) o.purposeText = "Morpho Midnight repay";
|
|
1841
|
+
return o;
|
|
1842
|
+
}
|
|
1843
|
+
var mcpMorphoFetchMidnightBooksInputSchema = zod.z.object({
|
|
1844
|
+
chainId: agentEvmChainIdSchema,
|
|
1845
|
+
loan: zod.z.string().trim().min(1).optional().describe("Loan token address filter."),
|
|
1846
|
+
collateral: zod.z.string().trim().min(1).optional().describe("Collateral token address filter."),
|
|
1847
|
+
query: zod.z.string().trim().min(1).optional().describe("Filter on marketId or addresses."),
|
|
1848
|
+
side: zod.z.enum(["bids", "asks", "either"]).optional().describe("Require bid depth (borrow) or ask depth (lend)."),
|
|
1849
|
+
limit: agentCoercedOptionalIntSchema(zod.z.number().int().min(1).max(200))
|
|
1850
|
+
});
|
|
1851
|
+
var mcpMorphoFetchMidnightBooksOutputSchema = zod.z.object({
|
|
1852
|
+
books: zod.z.array(
|
|
1853
|
+
zod.z.object({
|
|
1854
|
+
marketId: zod.z.string().describe("Pass to Midnight quote / lend / borrow / repay tools"),
|
|
1855
|
+
chainId: zod.z.number().int(),
|
|
1856
|
+
midnightAddress: zod.z.string(),
|
|
1857
|
+
loanTokenAddress: zod.z.string(),
|
|
1858
|
+
maturity: zod.z.number(),
|
|
1859
|
+
maturityIso: zod.z.string(),
|
|
1860
|
+
collateralTokenAddresses: zod.z.array(zod.z.string()),
|
|
1861
|
+
primaryCollateralTokenAddress: zod.z.string().nullable(),
|
|
1862
|
+
primaryCollateralLltv: zod.z.string().nullable(),
|
|
1863
|
+
bestAskPriceWad: zod.z.string().nullable(),
|
|
1864
|
+
bestBidPriceWad: zod.z.string().nullable(),
|
|
1865
|
+
bestAskAssets: zod.z.string().nullable(),
|
|
1866
|
+
bestBidAssets: zod.z.string().nullable(),
|
|
1867
|
+
lendApr: zod.z.string(),
|
|
1868
|
+
borrowApr: zod.z.string(),
|
|
1869
|
+
lendAprNumeric: zod.z.number().nullable(),
|
|
1870
|
+
borrowAprNumeric: zod.z.number().nullable(),
|
|
1871
|
+
marketLabel: zod.z.string()
|
|
1872
|
+
})
|
|
1873
|
+
)
|
|
1874
|
+
});
|
|
1875
|
+
var mcpMorphoFetchMidnightQuoteInputSchema = zod.z.object({
|
|
1876
|
+
marketId: zod.z.string().min(1).describe("marketId from ctm_morpho_fetch_midnight_books"),
|
|
1877
|
+
side: zod.z.enum(["asks", "bids"]).describe("asks = lend; bids = borrow"),
|
|
1878
|
+
assets: zod.z.string().min(1).describe("Target loan-token amount in raw units (wei/base units), e.g. 10000000 for 10 USDC."),
|
|
1879
|
+
slippagePct: zod.z.string().optional().describe('Slippage percent string, default "0.5".')
|
|
1880
|
+
});
|
|
1881
|
+
var mcpMorphoFetchMidnightQuoteOutputSchema = zod.z.object({
|
|
1882
|
+
marketId: zod.z.string(),
|
|
1883
|
+
side: zod.z.enum(["asks", "bids"]),
|
|
1884
|
+
averageBestPriceWad: zod.z.string(),
|
|
1885
|
+
averageWorstPriceWad: zod.z.string(),
|
|
1886
|
+
availableAssets: zod.z.string(),
|
|
1887
|
+
availableUnits: zod.z.string(),
|
|
1888
|
+
impliedApr: zod.z.string(),
|
|
1889
|
+
impliedAprNumeric: zod.z.number().nullable(),
|
|
1890
|
+
maturity: zod.z.number().nullable(),
|
|
1891
|
+
takeableOfferCount: zod.z.number().int()
|
|
1892
|
+
});
|
|
1893
|
+
var mcpMorphoFetchMidnightPositionsInputSchema = zod.z.object({
|
|
1894
|
+
user: zod.z.string().min(1).describe("User EVM address"),
|
|
1895
|
+
types: zod.z.enum(["lend", "borrow", "collateral_only"]).optional(),
|
|
1896
|
+
activeOnly: zod.z.boolean().optional()
|
|
1897
|
+
});
|
|
1898
|
+
var mcpMorphoFetchMidnightPositionsOutputSchema = zod.z.object({
|
|
1899
|
+
positions: zod.z.array(
|
|
1900
|
+
zod.z.object({
|
|
1901
|
+
marketId: zod.z.string(),
|
|
1902
|
+
type: zod.z.string(),
|
|
1903
|
+
credit: zod.z.string(),
|
|
1904
|
+
debt: zod.z.string(),
|
|
1905
|
+
pendingFee: zod.z.string(),
|
|
1906
|
+
repayAssets: zod.z.string(),
|
|
1907
|
+
maturity: zod.z.number().nullable(),
|
|
1908
|
+
maturityIso: zod.z.string(),
|
|
1909
|
+
loanTokenAddress: zod.z.string().nullable(),
|
|
1910
|
+
collateralTokenAddresses: zod.z.array(zod.z.string()),
|
|
1911
|
+
collateralAmounts: zod.z.array(zod.z.object({ token: zod.z.string(), amount: zod.z.string() })),
|
|
1912
|
+
effectiveRate: zod.z.string(),
|
|
1913
|
+
costBasis: zod.z.string().nullable()
|
|
1914
|
+
})
|
|
1915
|
+
)
|
|
1916
|
+
});
|
|
1504
1917
|
var mcpServerCommonInputSchema = zod.z.object({
|
|
1505
1918
|
keyGenId: zod.z.string().min(1).describe("KeyGen id from fetch_key_gen_result / node preferred KeyGen"),
|
|
1506
1919
|
chainId: zod.z.number().int().positive().describe("EVM chain id; RPC and gas config resolved from chain registry"),
|
|
@@ -1524,7 +1937,9 @@ var MCP_NON_SUBMIT_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
|
1524
1937
|
"ctm_uniswap_v4_quote",
|
|
1525
1938
|
"ctm_uniswap_v4_create_swap",
|
|
1526
1939
|
"ctm_uniswap_v4_limit_order_quote",
|
|
1527
|
-
"ctm_uniswap_v4_fetch_limit_orders"
|
|
1940
|
+
"ctm_uniswap_v4_fetch_limit_orders",
|
|
1941
|
+
"ctm_uniswap_v4_check_permissions",
|
|
1942
|
+
"ctm_uniswap_v4_kyc_apply_link"
|
|
1528
1943
|
]);
|
|
1529
1944
|
|
|
1530
1945
|
// src/agent/schemas/protocols.ts
|
|
@@ -1849,6 +2264,47 @@ var mcpMorphoMerklClaimInputSchema = mcpMultisignInput({
|
|
|
1849
2264
|
distributor: evmAddressSchema.optional(),
|
|
1850
2265
|
valueWei: zod.z.string().optional()
|
|
1851
2266
|
});
|
|
2267
|
+
var mcpMorphoMidnightLendInputSchema = withMultisignKeySourceRefine(
|
|
2268
|
+
zod.z.preprocess(
|
|
2269
|
+
preprocessMorphoMidnightLendInput,
|
|
2270
|
+
evmMultisignCommonInputSchema.extend({
|
|
2271
|
+
marketId: zod.z.string().min(1).describe("marketId from ctm_morpho_fetch_midnight_books"),
|
|
2272
|
+
amountHuman: zod.z.string().min(1).describe("Loan-token amount to lend (human units)"),
|
|
2273
|
+
loanToken: evmAddressSchema.optional().describe("loanTokenAddress from fetch row"),
|
|
2274
|
+
slippagePct: zod.z.string().optional().describe("Default 0.5"),
|
|
2275
|
+
marketLabel: zod.z.string().optional(),
|
|
2276
|
+
isNativeIn: agentOptionalBooleanSchema()
|
|
2277
|
+
})
|
|
2278
|
+
)
|
|
2279
|
+
);
|
|
2280
|
+
var mcpMorphoMidnightBorrowInputSchema = withMultisignKeySourceRefine(
|
|
2281
|
+
zod.z.preprocess(
|
|
2282
|
+
preprocessMorphoMidnightBorrowInput,
|
|
2283
|
+
evmMultisignCommonInputSchema.extend({
|
|
2284
|
+
marketId: zod.z.string().min(1).describe("marketId from ctm_morpho_fetch_midnight_books"),
|
|
2285
|
+
borrowAmountHuman: zod.z.string().min(1).describe("Loan-token amount to borrow"),
|
|
2286
|
+
collateralAmountHuman: zod.z.string().min(1).describe("Collateral to supply in the same tx"),
|
|
2287
|
+
collateralToken: evmAddressSchema.describe("primaryCollateralTokenAddress from fetch row"),
|
|
2288
|
+
loanToken: evmAddressSchema.optional(),
|
|
2289
|
+
collateralIndex: agentCoercedOptionalIntSchema(zod.z.number().int().min(0).max(127)),
|
|
2290
|
+
slippagePct: zod.z.string().optional(),
|
|
2291
|
+
marketLabel: zod.z.string().optional(),
|
|
2292
|
+
isNativeIn: agentOptionalBooleanSchema()
|
|
2293
|
+
})
|
|
2294
|
+
)
|
|
2295
|
+
);
|
|
2296
|
+
var mcpMorphoMidnightRepayInputSchema = withMultisignKeySourceRefine(
|
|
2297
|
+
zod.z.preprocess(
|
|
2298
|
+
preprocessMorphoMidnightRepayInput,
|
|
2299
|
+
evmMultisignCommonInputSchema.extend({
|
|
2300
|
+
marketId: zod.z.string().min(1).describe("marketId from ctm_morpho_fetch_midnight_positions"),
|
|
2301
|
+
repayAmountHuman: zod.z.string().optional().describe("Optional; default debt+fee+buffer"),
|
|
2302
|
+
loanToken: evmAddressSchema.optional(),
|
|
2303
|
+
withdrawAllCollateral: agentOptionalBooleanSchema(),
|
|
2304
|
+
marketLabel: zod.z.string().optional()
|
|
2305
|
+
})
|
|
2306
|
+
)
|
|
2307
|
+
);
|
|
1852
2308
|
var mcpEulerV2FetchLendVaultsInputSchema = zod.z.object({
|
|
1853
2309
|
chainId: agentEvmChainIdSchema,
|
|
1854
2310
|
underlyingAddress: evmAddressSchema.describe(
|
|
@@ -3145,6 +3601,43 @@ var MCP_PROTOCOL_TOOL_DEFINITIONS = [
|
|
|
3145
3601
|
handler: { importPath: "protocols/evm/morpho", exportName: "buildEvmMultisignBodyMorphoMerklDistributorClaim" },
|
|
3146
3602
|
inputZod: mcpMorphoMerklClaimInputSchema
|
|
3147
3603
|
}),
|
|
3604
|
+
defineProtocolMcpTool({
|
|
3605
|
+
name: "ctm_morpho_build_midnight_lend_multisign",
|
|
3606
|
+
actionId: "morpho.midnight-lend",
|
|
3607
|
+
protocolId: "morpho",
|
|
3608
|
+
chainCategory: "evm",
|
|
3609
|
+
description: "Build Morpho Midnight fixed-rate lend batch (approve + authorize bundles + take asks via MidnightBundles).",
|
|
3610
|
+
prerequisites: ["keyGenId", "chainId", "marketId from ctm_morpho_fetch_midnight_books", "amountHuman"],
|
|
3611
|
+
handler: { importPath: "protocols/evm/morpho", exportName: "buildEvmMultisignBodyMorphoMidnightLendBatch" },
|
|
3612
|
+
inputZod: mcpMorphoMidnightLendInputSchema
|
|
3613
|
+
}),
|
|
3614
|
+
defineProtocolMcpTool({
|
|
3615
|
+
name: "ctm_morpho_build_midnight_borrow_multisign",
|
|
3616
|
+
actionId: "morpho.midnight-borrow",
|
|
3617
|
+
protocolId: "morpho",
|
|
3618
|
+
chainCategory: "evm",
|
|
3619
|
+
description: "Build Morpho Midnight fixed-rate borrow batch (approve collateral + authorize + supply collateral and take bids).",
|
|
3620
|
+
prerequisites: [
|
|
3621
|
+
"keyGenId",
|
|
3622
|
+
"chainId",
|
|
3623
|
+
"marketId",
|
|
3624
|
+
"borrowAmountHuman",
|
|
3625
|
+
"collateralAmountHuman",
|
|
3626
|
+
"collateralToken"
|
|
3627
|
+
],
|
|
3628
|
+
handler: { importPath: "protocols/evm/morpho", exportName: "buildEvmMultisignBodyMorphoMidnightBorrowBatch" },
|
|
3629
|
+
inputZod: mcpMorphoMidnightBorrowInputSchema
|
|
3630
|
+
}),
|
|
3631
|
+
defineProtocolMcpTool({
|
|
3632
|
+
name: "ctm_morpho_build_midnight_repay_multisign",
|
|
3633
|
+
actionId: "morpho.midnight-repay",
|
|
3634
|
+
protocolId: "morpho",
|
|
3635
|
+
chainCategory: "evm",
|
|
3636
|
+
description: "Build Morpho Midnight repay + withdraw collateral batch (full exit at/after maturity).",
|
|
3637
|
+
prerequisites: ["keyGenId", "chainId", "marketId from ctm_morpho_fetch_midnight_positions"],
|
|
3638
|
+
handler: { importPath: "protocols/evm/morpho", exportName: "buildEvmMultisignBodyMorphoMidnightRepayBatch" },
|
|
3639
|
+
inputZod: mcpMorphoMidnightRepayInputSchema
|
|
3640
|
+
}),
|
|
3148
3641
|
defineProtocolMcpTool({
|
|
3149
3642
|
name: "ctm_gmx_build_increase_multisign",
|
|
3150
3643
|
actionId: "gmx.increase",
|
|
@@ -3596,15 +4089,60 @@ var CORE_MCP_TOOL_DEFINITIONS = [
|
|
|
3596
4089
|
inputZod: mcpUniswapV4FetchLimitOrdersInputSchema,
|
|
3597
4090
|
outputZod: mcpUniswapV4FetchLimitOrdersOutputSchema
|
|
3598
4091
|
}),
|
|
4092
|
+
defineMcpTool({
|
|
4093
|
+
name: "ctm_uniswap_v4_check_permissions",
|
|
4094
|
+
actionId: "uniswap-v4.check-permissions",
|
|
4095
|
+
protocolId: "uniswap-v4",
|
|
4096
|
+
chainCategory: "evm",
|
|
4097
|
+
description: "Check Uniswap Trade API POST /v1/permissions for up to two tokens. Returns isPermissioned, isAllowlisted, kycUrl, issuer, and whether UR 2.2.0 is required. Call before swap/LP submit on tokenized pools.",
|
|
4098
|
+
prerequisites: ["UNISWAP_API_KEY", "walletAddress or keyGenId", "tokens[]", "chainId"],
|
|
4099
|
+
followUp: [
|
|
4100
|
+
"ctm_uniswap_v4_kyc_apply_link",
|
|
4101
|
+
"ctm_uniswap_v4_quote",
|
|
4102
|
+
"ctm_uniswap_v4_build_allowlist_finalize_multisign"
|
|
4103
|
+
],
|
|
4104
|
+
handler: { importPath: "protocols/evm/uniswap-v4", exportName: "uniswapV4CheckPermissionsMcp" },
|
|
4105
|
+
inputZod: mcpUniswapV4CheckPermissionsInputSchema,
|
|
4106
|
+
outputZod: mcpUniswapV4CheckPermissionsOutputSchema
|
|
4107
|
+
}),
|
|
4108
|
+
defineMcpTool({
|
|
4109
|
+
name: "ctm_uniswap_v4_kyc_apply_link",
|
|
4110
|
+
actionId: "uniswap-v4.kyc-apply-link",
|
|
4111
|
+
protocolId: "uniswap-v4",
|
|
4112
|
+
chainCategory: "evm",
|
|
4113
|
+
description: "Build an issuer KYC apply URL with KeyGen wallet / chain / token query params (no sign request). Use when check_permissions returns isAllowlisted=false and kycUrl.",
|
|
4114
|
+
prerequisites: ["walletAddress", "chainId", "kycUrl from check_permissions"],
|
|
4115
|
+
followUp: ["ctm_uniswap_v4_check_permissions"],
|
|
4116
|
+
handler: { importPath: "protocols/evm/uniswap-v4", exportName: "uniswapV4KycApplyLinkMcp" },
|
|
4117
|
+
inputZod: mcpUniswapV4KycApplyLinkInputSchema,
|
|
4118
|
+
outputZod: mcpUniswapV4KycApplyLinkOutputSchema
|
|
4119
|
+
}),
|
|
4120
|
+
defineMultisignSubmitMcpTool({
|
|
4121
|
+
name: "ctm_uniswap_v4_build_allowlist_finalize_multisign",
|
|
4122
|
+
actionId: "uniswap-v4.allowlist-finalize",
|
|
4123
|
+
protocolId: "uniswap-v4",
|
|
4124
|
+
chainCategory: "evm",
|
|
4125
|
+
description: "Create and submit mpc-auth multiSignRequest to broadcast issuer-prepared allowlist calldata (e.g. Superstate setUserPermissionForInstrument). Requires partner onboard API {to, data}. No PII \u2014 KYC stays at issuer kycUrl.",
|
|
4126
|
+
prerequisites: [
|
|
4127
|
+
"Issuer onboard/add-allowlist response with to + encodedTransaction",
|
|
4128
|
+
"keyGenId + chainId + purposeText"
|
|
4129
|
+
],
|
|
4130
|
+
followUp: ["ctm_uniswap_v4_check_permissions", ...MCP_MULTISIGN_SUBMIT_FOLLOW_UP],
|
|
4131
|
+
handler: {
|
|
4132
|
+
importPath: "protocols/evm/uniswap-v4",
|
|
4133
|
+
exportName: "buildEvmMultisignBodyUniswapV4PermissionedAllowlistFinalize"
|
|
4134
|
+
},
|
|
4135
|
+
inputZod: mcpUniswapV4BuildAllowlistFinalizeMultisignInputSchema
|
|
4136
|
+
}),
|
|
3599
4137
|
defineMcpTool({
|
|
3600
4138
|
name: "ctm_uniswap_v4_list_lp_pools",
|
|
3601
4139
|
actionId: "uniswap-v4.lp-list-pools",
|
|
3602
4140
|
protocolId: "uniswap-v4",
|
|
3603
4141
|
chainCategory: "evm",
|
|
3604
|
-
description: "List
|
|
4142
|
+
description: "List Uniswap V4 LP pools for a chain. Default: standard no-hook ETH/USDC presets. Set permissioned=true for Permissioned Position Manager catalog (adapter currency + PermissionedHooks). Returns presetId, poolReference, hooks.",
|
|
3605
4143
|
prerequisites: ["chainId"],
|
|
3606
|
-
followUp: ["ctm_uniswap_v4_lp_create_position", "ctm_uniswap_v4_fetch_ohlcv"],
|
|
3607
|
-
handler: { importPath: "protocols/evm/uniswap-v4", exportName: "
|
|
4144
|
+
followUp: ["ctm_uniswap_v4_lp_create_position", "ctm_uniswap_v4_fetch_ohlcv", "ctm_uniswap_v4_check_permissions"],
|
|
4145
|
+
handler: { importPath: "protocols/evm/uniswap-v4", exportName: "uniswapV4ListLpPools" },
|
|
3608
4146
|
inputZod: mcpUniswapV4LpListPoolsInputSchema,
|
|
3609
4147
|
outputZod: mcpUniswapV4LpListPoolsOutputSchema
|
|
3610
4148
|
}),
|
|
@@ -3645,8 +4183,12 @@ var CORE_MCP_TOOL_DEFINITIONS = [
|
|
|
3645
4183
|
actionId: "uniswap-v4.mint-liquidity",
|
|
3646
4184
|
protocolId: "uniswap-v4",
|
|
3647
4185
|
chainCategory: "evm",
|
|
3648
|
-
description: "Create and submit mpc-auth multiSignRequest for minting a Uniswap V4 LP position.
|
|
3649
|
-
prerequisites: [
|
|
4186
|
+
description: "Create and submit mpc-auth multiSignRequest for minting a Uniswap V4 LP position. Standard: ERC-20 approve + Position Manager. Permissioned (positionManagerKind=permissioned): ERC-20\u2192Permit2 + Permit2\u2192PermPosM + mint. Requires LIQUIDITY_ALLOWED.",
|
|
4187
|
+
prerequisites: [
|
|
4188
|
+
"ctm_uniswap_v4_lp_create_position output",
|
|
4189
|
+
"keyGenId + chainId + purposeText",
|
|
4190
|
+
"For permissioned: check_permissions with LIQUIDITY allowlist"
|
|
4191
|
+
],
|
|
3650
4192
|
followUp: [
|
|
3651
4193
|
...MCP_MULTISIGN_SUBMIT_FOLLOW_UP,
|
|
3652
4194
|
"After broadcast: ctm_uniswap_v4_register_position_from_mint_tx (mint tx hash)"
|
|
@@ -4215,6 +4757,46 @@ var CORE_MCP_TOOL_DEFINITIONS = [
|
|
|
4215
4757
|
inputZod: mcpMorphoFetchBlueMarketsInputSchema,
|
|
4216
4758
|
outputZod: mcpMorphoFetchBlueMarketsOutputSchema
|
|
4217
4759
|
}),
|
|
4760
|
+
defineMcpTool({
|
|
4761
|
+
name: "ctm_morpho_fetch_midnight_books",
|
|
4762
|
+
actionId: "morpho.fetch-midnight-books",
|
|
4763
|
+
protocolId: "morpho",
|
|
4764
|
+
chainCategory: "evm",
|
|
4765
|
+
description: "Morpho Midnight fixed-rate books (order books). Filter by loan/collateral; returns marketId, maturity, and implied lend/borrow APR for Midnight multisign tools.",
|
|
4766
|
+
prerequisites: ["chainId"],
|
|
4767
|
+
followUp: [
|
|
4768
|
+
"ctm_morpho_fetch_midnight_quote",
|
|
4769
|
+
"ctm_morpho_build_midnight_lend_multisign",
|
|
4770
|
+
"ctm_morpho_build_midnight_borrow_multisign"
|
|
4771
|
+
],
|
|
4772
|
+
handler: { importPath: "protocols/evm/morpho", exportName: "morphoFetchMidnightBooksSummary" },
|
|
4773
|
+
inputZod: mcpMorphoFetchMidnightBooksInputSchema,
|
|
4774
|
+
outputZod: mcpMorphoFetchMidnightBooksOutputSchema
|
|
4775
|
+
}),
|
|
4776
|
+
defineMcpTool({
|
|
4777
|
+
name: "ctm_morpho_fetch_midnight_quote",
|
|
4778
|
+
actionId: "morpho.fetch-midnight-quote",
|
|
4779
|
+
protocolId: "morpho",
|
|
4780
|
+
chainCategory: "evm",
|
|
4781
|
+
description: "Quote a Morpho Midnight book fill. side asks = lend, bids = borrow. assets is raw loan-token units.",
|
|
4782
|
+
prerequisites: ["marketId from ctm_morpho_fetch_midnight_books", "assets raw amount"],
|
|
4783
|
+
followUp: ["ctm_morpho_build_midnight_lend_multisign", "ctm_morpho_build_midnight_borrow_multisign"],
|
|
4784
|
+
handler: { importPath: "protocols/evm/morpho", exportName: "morphoFetchMidnightQuoteSummary" },
|
|
4785
|
+
inputZod: mcpMorphoFetchMidnightQuoteInputSchema,
|
|
4786
|
+
outputZod: mcpMorphoFetchMidnightQuoteOutputSchema
|
|
4787
|
+
}),
|
|
4788
|
+
defineMcpTool({
|
|
4789
|
+
name: "ctm_morpho_fetch_midnight_positions",
|
|
4790
|
+
actionId: "morpho.fetch-midnight-positions",
|
|
4791
|
+
protocolId: "morpho",
|
|
4792
|
+
chainCategory: "evm",
|
|
4793
|
+
description: "Morpho Midnight positions for a user (lend/borrow). Use marketId for repay.",
|
|
4794
|
+
prerequisites: ["user address"],
|
|
4795
|
+
followUp: ["ctm_morpho_build_midnight_repay_multisign"],
|
|
4796
|
+
handler: { importPath: "protocols/evm/morpho", exportName: "morphoFetchMidnightPositionsSummary" },
|
|
4797
|
+
inputZod: mcpMorphoFetchMidnightPositionsInputSchema,
|
|
4798
|
+
outputZod: mcpMorphoFetchMidnightPositionsOutputSchema
|
|
4799
|
+
}),
|
|
4218
4800
|
defineMcpTool({
|
|
4219
4801
|
name: "ctm_euler_v2_fetch_lend_vaults",
|
|
4220
4802
|
actionId: "euler-v2.fetch-lend-vaults",
|
|
@@ -4406,14 +4988,22 @@ function getAgentCatalogForMcp() {
|
|
|
4406
4988
|
}
|
|
4407
4989
|
};
|
|
4408
4990
|
}
|
|
4409
|
-
viem.getAddress(
|
|
4991
|
+
var LIDO_STETH_CONTRACT_MAINNET = viem.getAddress(
|
|
4410
4992
|
"0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"
|
|
4411
4993
|
);
|
|
4412
|
-
viem.getAddress(
|
|
4994
|
+
var LIDO_WSTETH_CONTRACT_MAINNET = viem.getAddress(
|
|
4413
4995
|
"0x7f39C581F595B853cBbF37C12FfeeA971C5a5bEa"
|
|
4414
4996
|
);
|
|
4415
4997
|
viem.getAddress("0x889edC2eDab5f40e902b864aD4d7AdE8E412F9B1");
|
|
4416
4998
|
var LIDO_ETHEREUM_MAINNET_CHAIN_ID = 1;
|
|
4999
|
+
var LIDO_ROBINHOOD_CHAIN_ID = 4663;
|
|
5000
|
+
var LIDO_WSTETH_ROBINHOOD = viem.getAddress("0x2dC99af320BC317c567f24eE95811dcbd5983DfD");
|
|
5001
|
+
function listLidoSupportedChainIds() {
|
|
5002
|
+
return [LIDO_ETHEREUM_MAINNET_CHAIN_ID, LIDO_ROBINHOOD_CHAIN_ID];
|
|
5003
|
+
}
|
|
5004
|
+
function isLidoSupportedChainId(chainId) {
|
|
5005
|
+
return chainId === LIDO_ETHEREUM_MAINNET_CHAIN_ID || chainId === LIDO_ROBINHOOD_CHAIN_ID;
|
|
5006
|
+
}
|
|
4417
5007
|
|
|
4418
5008
|
// src/protocols/evm/lido/index.ts
|
|
4419
5009
|
var LIDO_PROTOCOL_ID = "lido";
|
|
@@ -4422,7 +5012,7 @@ var lidoProtocolModule = {
|
|
|
4422
5012
|
chainCategory: "evm",
|
|
4423
5013
|
isChainSupported(ctx) {
|
|
4424
5014
|
if (ctx.chainCategory !== "evm") return false;
|
|
4425
|
-
return Number(ctx.chainId)
|
|
5015
|
+
return isLidoSupportedChainId(Number(ctx.chainId));
|
|
4426
5016
|
},
|
|
4427
5017
|
isTokenSupported(token) {
|
|
4428
5018
|
return token.category === "evm" && (token.kind === "native" || token.kind === "erc20");
|
|
@@ -4439,7 +5029,9 @@ registerProtocolModule(lidoProtocolModule);
|
|
|
4439
5029
|
var USDE_ETHEREUM_MAINNET = "0x4c9edd5852cd905f086c759e8383e09bff1e68b3";
|
|
4440
5030
|
var SUSDE_ETHEREUM_MAINNET = "0x9d39a5de30e57443bff2a8307a4256c8797a3497";
|
|
4441
5031
|
var USDE_MOST_L2S = "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34";
|
|
5032
|
+
var SUSDE_MOST_L2S = "0x211Cc4DD073734dA055fbF44a2b4667d5E5fE5d2";
|
|
4442
5033
|
var USDE_ZKSYNC_ERA = "0x39Fe7a0DACcE31Bd90418e3e659fb0b5f0B3Db0d";
|
|
5034
|
+
var SUSDE_ZKSYNC_ERA = "0xAD17Da2f6Ac76746EF261E835C50b2651ce36DA8";
|
|
4443
5035
|
var L2_SAME_ADDRESS_CHAIN_IDS = /* @__PURE__ */ new Set([
|
|
4444
5036
|
42161,
|
|
4445
5037
|
// Arbitrum One
|
|
@@ -4475,8 +5067,10 @@ var L2_SAME_ADDRESS_CHAIN_IDS = /* @__PURE__ */ new Set([
|
|
|
4475
5067
|
// Morph
|
|
4476
5068
|
1923,
|
|
4477
5069
|
// Swell
|
|
4478
|
-
48900
|
|
5070
|
+
48900,
|
|
4479
5071
|
// Zircuit
|
|
5072
|
+
4663
|
|
5073
|
+
// Robinhood Chain
|
|
4480
5074
|
]);
|
|
4481
5075
|
var FALLBACK_NAME_BY_ID = {
|
|
4482
5076
|
1: "Ethereum",
|
|
@@ -4498,6 +5092,7 @@ var FALLBACK_NAME_BY_ID = {
|
|
|
4498
5092
|
2818: "Morph",
|
|
4499
5093
|
1923: "Swell",
|
|
4500
5094
|
48900: "Zircuit",
|
|
5095
|
+
4663: "Robinhood Chain",
|
|
4501
5096
|
324: "ZKSync Era"
|
|
4502
5097
|
};
|
|
4503
5098
|
function usdeTokenAddressOnEvmChain(chainId) {
|
|
@@ -4508,17 +5103,28 @@ function usdeTokenAddressOnEvmChain(chainId) {
|
|
|
4508
5103
|
}
|
|
4509
5104
|
function listEthenaUsdeEvmNetworkRows() {
|
|
4510
5105
|
const rows = [
|
|
4511
|
-
{
|
|
5106
|
+
{
|
|
5107
|
+
chainId: 1,
|
|
5108
|
+
label: FALLBACK_NAME_BY_ID[1],
|
|
5109
|
+
usde: USDE_ETHEREUM_MAINNET,
|
|
5110
|
+
susde: SUSDE_ETHEREUM_MAINNET
|
|
5111
|
+
}
|
|
4512
5112
|
];
|
|
4513
5113
|
const l2 = [...L2_SAME_ADDRESS_CHAIN_IDS].sort((a, b) => a - b);
|
|
4514
5114
|
for (const id of l2) {
|
|
4515
5115
|
rows.push({
|
|
4516
5116
|
chainId: id,
|
|
4517
5117
|
label: FALLBACK_NAME_BY_ID[id] ?? `Chain ${id}`,
|
|
4518
|
-
usde: USDE_MOST_L2S
|
|
5118
|
+
usde: USDE_MOST_L2S,
|
|
5119
|
+
susde: SUSDE_MOST_L2S
|
|
4519
5120
|
});
|
|
4520
5121
|
}
|
|
4521
|
-
rows.push({
|
|
5122
|
+
rows.push({
|
|
5123
|
+
chainId: 324,
|
|
5124
|
+
label: FALLBACK_NAME_BY_ID[324],
|
|
5125
|
+
usde: USDE_ZKSYNC_ERA,
|
|
5126
|
+
susde: SUSDE_ZKSYNC_ERA
|
|
5127
|
+
});
|
|
4522
5128
|
return rows.sort((a, b) => {
|
|
4523
5129
|
if (a.chainId === 1) return -1;
|
|
4524
5130
|
if (b.chainId === 1) return 1;
|
|
@@ -4601,6 +5207,9 @@ var skyProtocolModule = {
|
|
|
4601
5207
|
]
|
|
4602
5208
|
};
|
|
4603
5209
|
registerProtocolModule(skyProtocolModule);
|
|
5210
|
+
|
|
5211
|
+
// src/protocols/evm/aave-v4/api.ts
|
|
5212
|
+
init_defiProxy();
|
|
4604
5213
|
var AAVE_V4_GRAPHQL_URL = "https://api.v4.aave.com/graphql";
|
|
4605
5214
|
async function aaveV4Gql(query, variables) {
|
|
4606
5215
|
const body = { query, variables: variables ?? {} };
|
|
@@ -5250,6 +5859,9 @@ var arcusProtocolModule = {
|
|
|
5250
5859
|
]
|
|
5251
5860
|
};
|
|
5252
5861
|
registerProtocolModule(arcusProtocolModule);
|
|
5862
|
+
|
|
5863
|
+
// src/protocols/evm/morpho/api.ts
|
|
5864
|
+
init_defiProxy();
|
|
5253
5865
|
var MORPHO_GRAPHQL_URL = "https://api.morpho.org/graphql";
|
|
5254
5866
|
async function morphoGql(query, variables) {
|
|
5255
5867
|
const body = { query, variables: variables ?? {} };
|
|
@@ -5390,12 +6002,40 @@ async function ensureMorphoChainAssetCache(chainId) {
|
|
|
5390
6002
|
modes.set(k, prev);
|
|
5391
6003
|
}
|
|
5392
6004
|
}
|
|
6005
|
+
try {
|
|
6006
|
+
const { fetchMorphoMidnightBooks: fetchMorphoMidnightBooks2 } = await Promise.resolve().then(() => (init_midnightApi(), midnightApi_exports));
|
|
6007
|
+
const { MORPHO_MIDNIGHT_BOOKS_MAX_LIMIT: MORPHO_MIDNIGHT_BOOKS_MAX_LIMIT2 } = await Promise.resolve().then(() => (init_midnightConstants(), midnightConstants_exports));
|
|
6008
|
+
const { data: books } = await fetchMorphoMidnightBooks2({
|
|
6009
|
+
chainId,
|
|
6010
|
+
limit: MORPHO_MIDNIGHT_BOOKS_MAX_LIMIT2
|
|
6011
|
+
});
|
|
6012
|
+
for (const book of books) {
|
|
6013
|
+
const loanAddr = (book.loanToken ?? "").toString().trim();
|
|
6014
|
+
if (viem.isAddress(loanAddr)) {
|
|
6015
|
+
const k = viem.getAddress(loanAddr).toLowerCase();
|
|
6016
|
+
const prev = modes.get(k) ?? { earn: false, borrow: false, collateral: false };
|
|
6017
|
+
prev.borrow = true;
|
|
6018
|
+
modes.set(k, prev);
|
|
6019
|
+
}
|
|
6020
|
+
for (const c of book.collaterals ?? []) {
|
|
6021
|
+
const colAddr = (c.token ?? "").toString().trim();
|
|
6022
|
+
if (!viem.isAddress(colAddr)) continue;
|
|
6023
|
+
const k = viem.getAddress(colAddr).toLowerCase();
|
|
6024
|
+
const prev = modes.get(k) ?? { earn: false, borrow: false, collateral: false };
|
|
6025
|
+
prev.collateral = true;
|
|
6026
|
+
modes.set(k, prev);
|
|
6027
|
+
}
|
|
6028
|
+
}
|
|
6029
|
+
} catch {
|
|
6030
|
+
}
|
|
5393
6031
|
const cache = { modesByUnderlying: modes, nativeWrapped: null };
|
|
5394
6032
|
chainAssetCache.set(chainId, cache);
|
|
5395
6033
|
return cache;
|
|
5396
6034
|
}
|
|
5397
6035
|
|
|
5398
6036
|
// src/protocols/evm/morpho/index.ts
|
|
6037
|
+
init_midnightConstants();
|
|
6038
|
+
init_midnightApi();
|
|
5399
6039
|
var MORPHO_PROTOCOL_ID = "morpho";
|
|
5400
6040
|
var morphoProtocolModule = {
|
|
5401
6041
|
id: MORPHO_PROTOCOL_ID,
|
|
@@ -5415,7 +6055,12 @@ var morphoProtocolModule = {
|
|
|
5415
6055
|
{ id: "morpho.blue-repay", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "Repay Morpho Blue borrow", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
|
|
5416
6056
|
{ id: "morpho.blue-collateral-withdraw", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "Withdraw Morpho Blue collateral", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
|
|
5417
6057
|
{ id: "morpho.merkl-claim", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "Claim Morpho Merkl rewards", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
|
|
5418
|
-
{ id: "morpho.midnight-
|
|
6058
|
+
{ id: "morpho.fetch-midnight-books", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "List Morpho Midnight fixed-rate books", commonParams: [], params: {} },
|
|
6059
|
+
{ id: "morpho.fetch-midnight-quote", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "Quote Morpho Midnight lend/borrow fill", commonParams: [], params: {} },
|
|
6060
|
+
{ id: "morpho.fetch-midnight-positions", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "List Morpho Midnight user positions", commonParams: [], params: {} },
|
|
6061
|
+
{ id: "morpho.midnight-lend", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "Morpho Midnight fixed-rate lend (take asks)", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
|
|
6062
|
+
{ id: "morpho.midnight-borrow", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "Morpho Midnight fixed-rate borrow (supply collateral + take bids)", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
|
|
6063
|
+
{ id: "morpho.midnight-repay", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "Morpho Midnight repay debt and withdraw collateral", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} }
|
|
5419
6064
|
]
|
|
5420
6065
|
};
|
|
5421
6066
|
registerProtocolModule(morphoProtocolModule);
|
|
@@ -5882,17 +6527,26 @@ var PROTOCOL_SUPPORT_ADVISORS = {
|
|
|
5882
6527
|
}),
|
|
5883
6528
|
lido: advisor("lido", "mainnet_only", {
|
|
5884
6529
|
async supportedChainIds() {
|
|
5885
|
-
return
|
|
6530
|
+
return listLidoSupportedChainIds();
|
|
5886
6531
|
},
|
|
5887
|
-
async supportedTokens() {
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
6532
|
+
async supportedTokens(chainId) {
|
|
6533
|
+
if (chainId === LIDO_ETHEREUM_MAINNET_CHAIN_ID) {
|
|
6534
|
+
return {
|
|
6535
|
+
tokens: [
|
|
6536
|
+
{ address: "0x0000000000000000000000000000000000000000", symbol: "ETH", roles: ["native", "stake"] },
|
|
6537
|
+
{ address: LIDO_STETH_CONTRACT_MAINNET, symbol: "stETH", roles: ["erc20"] },
|
|
6538
|
+
{ address: LIDO_WSTETH_CONTRACT_MAINNET, symbol: "wstETH", roles: ["erc20"] }
|
|
6539
|
+
],
|
|
6540
|
+
notes: "Lido staking, withdrawals, and wrap/unwrap are Ethereum mainnet only."
|
|
6541
|
+
};
|
|
6542
|
+
}
|
|
6543
|
+
if (chainId === LIDO_ROBINHOOD_CHAIN_ID) {
|
|
6544
|
+
return {
|
|
6545
|
+
tokens: [{ address: LIDO_WSTETH_ROBINHOOD, symbol: "wstETH", roles: ["erc20"] }],
|
|
6546
|
+
notes: "Bridged wstETH on Robinhood Chain (CCIP). Stake/withdraw/wrap MCP tools remain mainnet-only."
|
|
6547
|
+
};
|
|
6548
|
+
}
|
|
6549
|
+
return { tokens: [] };
|
|
5896
6550
|
}
|
|
5897
6551
|
}),
|
|
5898
6552
|
ethena: advisor("ethena", "minting_contract", {
|
|
@@ -5906,14 +6560,17 @@ var PROTOCOL_SUPPORT_ADVISORS = {
|
|
|
5906
6560
|
{ address: USDE_ETHEREUM_MAINNET, symbol: "USDe", roles: ["stake"] },
|
|
5907
6561
|
{ address: SUSDE_ETHEREUM_MAINNET, symbol: "sUSDe", roles: ["vault"] }
|
|
5908
6562
|
],
|
|
5909
|
-
notes: "Ethena stake/redeem UI actions are mainnet-only; USDe
|
|
6563
|
+
notes: "Ethena stake/redeem UI actions are mainnet-only; USDe/sUSDe exist on other chains for transfers."
|
|
5910
6564
|
};
|
|
5911
6565
|
}
|
|
5912
6566
|
if (isEvmChainInEthenaUsdeList(chainId)) {
|
|
5913
6567
|
const row = listEthenaUsdeEvmNetworkRows().find((r) => r.chainId === chainId);
|
|
5914
6568
|
return {
|
|
5915
|
-
tokens: row ? [
|
|
5916
|
-
|
|
6569
|
+
tokens: row ? [
|
|
6570
|
+
{ address: row.usde, symbol: "USDe", roles: ["erc20"] },
|
|
6571
|
+
{ address: row.susde, symbol: "sUSDe", roles: ["erc20"] }
|
|
6572
|
+
] : [],
|
|
6573
|
+
notes: "USDe/sUSDe on L2 (incl. Robinhood Chain); staking MCP tools target mainnet only."
|
|
5917
6574
|
};
|
|
5918
6575
|
}
|
|
5919
6576
|
return { tokens: [] };
|
|
@@ -5936,7 +6593,7 @@ var PROTOCOL_SUPPORT_ADVISORS = {
|
|
|
5936
6593
|
}));
|
|
5937
6594
|
return {
|
|
5938
6595
|
tokens,
|
|
5939
|
-
notes: chainId === ROBINHOOD_CHAIN_ID ? 'Morpho vault assets on Robinhood Chain. Robinhood Earn USDG yield uses Steakhouse USDG (steakUSDG) \u2014 query "robinhood earn" or robinhoodEarn: true on deposit multisign; not Arcus collateral.' : "Morpho vault assets
|
|
6596
|
+
notes: chainId === ROBINHOOD_CHAIN_ID ? 'Morpho vault assets on Robinhood Chain. Robinhood Earn USDG yield uses Steakhouse USDG (steakUSDG) \u2014 query "robinhood earn" or robinhoodEarn: true on deposit multisign; not Arcus collateral.' : "Morpho vault assets, Blue market loan/collateral tokens, and Midnight book loan/collateral tokens from api.morpho.org."
|
|
5940
6597
|
};
|
|
5941
6598
|
},
|
|
5942
6599
|
async isTokenSupported(chainId, address) {
|
|
@@ -6259,7 +6916,16 @@ exports.mcpMorphoFetchBlueMarketsInputSchema = mcpMorphoFetchBlueMarketsInputSch
|
|
|
6259
6916
|
exports.mcpMorphoFetchBlueMarketsOutputSchema = mcpMorphoFetchBlueMarketsOutputSchema;
|
|
6260
6917
|
exports.mcpMorphoFetchEarnVaultsInputSchema = mcpMorphoFetchEarnVaultsInputSchema;
|
|
6261
6918
|
exports.mcpMorphoFetchEarnVaultsOutputSchema = mcpMorphoFetchEarnVaultsOutputSchema;
|
|
6919
|
+
exports.mcpMorphoFetchMidnightBooksInputSchema = mcpMorphoFetchMidnightBooksInputSchema;
|
|
6920
|
+
exports.mcpMorphoFetchMidnightBooksOutputSchema = mcpMorphoFetchMidnightBooksOutputSchema;
|
|
6921
|
+
exports.mcpMorphoFetchMidnightPositionsInputSchema = mcpMorphoFetchMidnightPositionsInputSchema;
|
|
6922
|
+
exports.mcpMorphoFetchMidnightPositionsOutputSchema = mcpMorphoFetchMidnightPositionsOutputSchema;
|
|
6923
|
+
exports.mcpMorphoFetchMidnightQuoteInputSchema = mcpMorphoFetchMidnightQuoteInputSchema;
|
|
6924
|
+
exports.mcpMorphoFetchMidnightQuoteOutputSchema = mcpMorphoFetchMidnightQuoteOutputSchema;
|
|
6262
6925
|
exports.mcpMorphoMerklClaimInputSchema = mcpMorphoMerklClaimInputSchema;
|
|
6926
|
+
exports.mcpMorphoMidnightBorrowInputSchema = mcpMorphoMidnightBorrowInputSchema;
|
|
6927
|
+
exports.mcpMorphoMidnightLendInputSchema = mcpMorphoMidnightLendInputSchema;
|
|
6928
|
+
exports.mcpMorphoMidnightRepayInputSchema = mcpMorphoMidnightRepayInputSchema;
|
|
6263
6929
|
exports.mcpMorphoVaultDepositInputSchema = mcpMorphoVaultDepositInputSchema;
|
|
6264
6930
|
exports.mcpMorphoVaultWithdrawInputSchema = mcpMorphoVaultWithdrawInputSchema;
|
|
6265
6931
|
exports.mcpMultisignInput = mcpMultisignInput;
|
|
@@ -6275,18 +6941,23 @@ exports.mcpSkyLockstakeStakeInputSchema = mcpSkyLockstakeStakeInputSchema;
|
|
|
6275
6941
|
exports.mcpSkyLockstakeWipeInputSchema = mcpSkyLockstakeWipeInputSchema;
|
|
6276
6942
|
exports.mcpSkySusdsDepositInputSchema = mcpSkySusdsDepositInputSchema;
|
|
6277
6943
|
exports.mcpSkySusdsRedeemInputSchema = mcpSkySusdsRedeemInputSchema;
|
|
6944
|
+
exports.mcpUniswapV4BuildAllowlistFinalizeMultisignInputSchema = mcpUniswapV4BuildAllowlistFinalizeMultisignInputSchema;
|
|
6278
6945
|
exports.mcpUniswapV4BuildCollectFeesMultisignInputSchema = mcpUniswapV4BuildCollectFeesMultisignInputSchema;
|
|
6279
6946
|
exports.mcpUniswapV4BuildDecreaseLiquidityMultisignInputSchema = mcpUniswapV4BuildDecreaseLiquidityMultisignInputSchema;
|
|
6280
6947
|
exports.mcpUniswapV4BuildIncreaseLiquidityMultisignInputSchema = mcpUniswapV4BuildIncreaseLiquidityMultisignInputSchema;
|
|
6281
6948
|
exports.mcpUniswapV4BuildLimitOrderMultisignInputSchema = mcpUniswapV4BuildLimitOrderMultisignInputSchema;
|
|
6282
6949
|
exports.mcpUniswapV4BuildMintLiquidityMultisignInputSchema = mcpUniswapV4BuildMintLiquidityMultisignInputSchema;
|
|
6283
6950
|
exports.mcpUniswapV4BuildSwapMultisignInputSchema = mcpUniswapV4BuildSwapMultisignInputSchema;
|
|
6951
|
+
exports.mcpUniswapV4CheckPermissionsInputSchema = mcpUniswapV4CheckPermissionsInputSchema;
|
|
6952
|
+
exports.mcpUniswapV4CheckPermissionsOutputSchema = mcpUniswapV4CheckPermissionsOutputSchema;
|
|
6284
6953
|
exports.mcpUniswapV4CreateSwapInputSchema = mcpUniswapV4CreateSwapInputSchema;
|
|
6285
6954
|
exports.mcpUniswapV4CreateSwapOutputSchema = mcpUniswapV4CreateSwapOutputSchema;
|
|
6286
6955
|
exports.mcpUniswapV4FetchLimitOrdersInputSchema = mcpUniswapV4FetchLimitOrdersInputSchema;
|
|
6287
6956
|
exports.mcpUniswapV4FetchLimitOrdersOutputSchema = mcpUniswapV4FetchLimitOrdersOutputSchema;
|
|
6288
6957
|
exports.mcpUniswapV4FetchOhlcvInputSchema = mcpUniswapV4FetchOhlcvInputSchema;
|
|
6289
6958
|
exports.mcpUniswapV4FetchOhlcvOutputSchema = mcpUniswapV4FetchOhlcvOutputSchema;
|
|
6959
|
+
exports.mcpUniswapV4KycApplyLinkInputSchema = mcpUniswapV4KycApplyLinkInputSchema;
|
|
6960
|
+
exports.mcpUniswapV4KycApplyLinkOutputSchema = mcpUniswapV4KycApplyLinkOutputSchema;
|
|
6290
6961
|
exports.mcpUniswapV4LimitOrderQuoteInputSchema = mcpUniswapV4LimitOrderQuoteInputSchema;
|
|
6291
6962
|
exports.mcpUniswapV4LimitOrderQuoteOutputSchema = mcpUniswapV4LimitOrderQuoteOutputSchema;
|
|
6292
6963
|
exports.mcpUniswapV4LpClaimInputSchema = mcpUniswapV4LpClaimInputSchema;
|