@continuumdao/ctm-mpc-defi 0.2.27 → 0.2.28

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.
Files changed (38) hide show
  1. package/dist/agent/catalog.cjs +681 -46
  2. package/dist/agent/catalog.cjs.map +1 -1
  3. package/dist/agent/catalog.d.ts +1209 -21
  4. package/dist/agent/catalog.js +668 -47
  5. package/dist/agent/catalog.js.map +1 -1
  6. package/dist/agent/skills/morpho/SKILL.md +38 -6
  7. package/dist/agent/skills/uniswap-v4/SKILL.md +15 -0
  8. package/dist/core/index.cjs +19 -0
  9. package/dist/core/index.cjs.map +1 -1
  10. package/dist/core/index.d.ts +8 -1
  11. package/dist/core/index.js +17 -1
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/index.cjs +363 -22
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +361 -23
  17. package/dist/index.js.map +1 -1
  18. package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
  19. package/dist/protocols/evm/aave-v4/index.js.map +1 -1
  20. package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
  21. package/dist/protocols/evm/euler-v2/index.js.map +1 -1
  22. package/dist/protocols/evm/maple/index.cjs.map +1 -1
  23. package/dist/protocols/evm/maple/index.js.map +1 -1
  24. package/dist/protocols/evm/morpho/index.cjs +1153 -142
  25. package/dist/protocols/evm/morpho/index.cjs.map +1 -1
  26. package/dist/protocols/evm/morpho/index.d.ts +314 -8
  27. package/dist/protocols/evm/morpho/index.js +1131 -144
  28. package/dist/protocols/evm/morpho/index.js.map +1 -1
  29. package/dist/protocols/evm/permit2/index.cjs.map +1 -1
  30. package/dist/protocols/evm/permit2/index.js.map +1 -1
  31. package/dist/protocols/evm/sky/index.cjs.map +1 -1
  32. package/dist/protocols/evm/sky/index.js.map +1 -1
  33. package/dist/protocols/evm/uniswap-v4/index.cjs +769 -23
  34. package/dist/protocols/evm/uniswap-v4/index.cjs.map +1 -1
  35. package/dist/protocols/evm/uniswap-v4/index.d.ts +248 -9
  36. package/dist/protocols/evm/uniswap-v4/index.js +742 -25
  37. package/dist/protocols/evm/uniswap-v4/index.js.map +1 -1
  38. package/package.json +2 -1
@@ -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 standard Uniswap V4 LP pools for a chain (ETH/USDC and other main pairs at common fee tiers). Returns presetId, token addresses, fee, tickSpacing, and computed poolReference (bytes32 pool id). Use presetId as poolPreset on lp_create_position.",
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: "uniswapV4ListStandardLpPools" },
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. Batches ERC-20 approve(s) + Position Manager tx from LP create response.",
3649
- prerequisites: ["ctm_uniswap_v4_lp_create_position output", "keyGenId + chainId + purposeText"],
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",
@@ -4601,6 +5183,9 @@ var skyProtocolModule = {
4601
5183
  ]
4602
5184
  };
4603
5185
  registerProtocolModule(skyProtocolModule);
5186
+
5187
+ // src/protocols/evm/aave-v4/api.ts
5188
+ init_defiProxy();
4604
5189
  var AAVE_V4_GRAPHQL_URL = "https://api.v4.aave.com/graphql";
4605
5190
  async function aaveV4Gql(query, variables) {
4606
5191
  const body = { query, variables: variables ?? {} };
@@ -5250,6 +5835,9 @@ var arcusProtocolModule = {
5250
5835
  ]
5251
5836
  };
5252
5837
  registerProtocolModule(arcusProtocolModule);
5838
+
5839
+ // src/protocols/evm/morpho/api.ts
5840
+ init_defiProxy();
5253
5841
  var MORPHO_GRAPHQL_URL = "https://api.morpho.org/graphql";
5254
5842
  async function morphoGql(query, variables) {
5255
5843
  const body = { query, variables: variables ?? {} };
@@ -5390,12 +5978,40 @@ async function ensureMorphoChainAssetCache(chainId) {
5390
5978
  modes.set(k, prev);
5391
5979
  }
5392
5980
  }
5981
+ try {
5982
+ const { fetchMorphoMidnightBooks: fetchMorphoMidnightBooks2 } = await Promise.resolve().then(() => (init_midnightApi(), midnightApi_exports));
5983
+ const { MORPHO_MIDNIGHT_BOOKS_MAX_LIMIT: MORPHO_MIDNIGHT_BOOKS_MAX_LIMIT2 } = await Promise.resolve().then(() => (init_midnightConstants(), midnightConstants_exports));
5984
+ const { data: books } = await fetchMorphoMidnightBooks2({
5985
+ chainId,
5986
+ limit: MORPHO_MIDNIGHT_BOOKS_MAX_LIMIT2
5987
+ });
5988
+ for (const book of books) {
5989
+ const loanAddr = (book.loanToken ?? "").toString().trim();
5990
+ if (viem.isAddress(loanAddr)) {
5991
+ const k = viem.getAddress(loanAddr).toLowerCase();
5992
+ const prev = modes.get(k) ?? { earn: false, borrow: false, collateral: false };
5993
+ prev.borrow = true;
5994
+ modes.set(k, prev);
5995
+ }
5996
+ for (const c of book.collaterals ?? []) {
5997
+ const colAddr = (c.token ?? "").toString().trim();
5998
+ if (!viem.isAddress(colAddr)) continue;
5999
+ const k = viem.getAddress(colAddr).toLowerCase();
6000
+ const prev = modes.get(k) ?? { earn: false, borrow: false, collateral: false };
6001
+ prev.collateral = true;
6002
+ modes.set(k, prev);
6003
+ }
6004
+ }
6005
+ } catch {
6006
+ }
5393
6007
  const cache = { modesByUnderlying: modes, nativeWrapped: null };
5394
6008
  chainAssetCache.set(chainId, cache);
5395
6009
  return cache;
5396
6010
  }
5397
6011
 
5398
6012
  // src/protocols/evm/morpho/index.ts
6013
+ init_midnightConstants();
6014
+ init_midnightApi();
5399
6015
  var MORPHO_PROTOCOL_ID = "morpho";
5400
6016
  var morphoProtocolModule = {
5401
6017
  id: MORPHO_PROTOCOL_ID,
@@ -5415,7 +6031,12 @@ var morphoProtocolModule = {
5415
6031
  { id: "morpho.blue-repay", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "Repay Morpho Blue borrow", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
5416
6032
  { id: "morpho.blue-collateral-withdraw", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "Withdraw Morpho Blue collateral", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
5417
6033
  { id: "morpho.merkl-claim", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "Claim Morpho Merkl rewards", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
5418
- { id: "morpho.midnight-borrow", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "Morpho Midnight fixed-rate borrow (coming soon)", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} }
6034
+ { id: "morpho.fetch-midnight-books", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "List Morpho Midnight fixed-rate books", commonParams: [], params: {} },
6035
+ { id: "morpho.fetch-midnight-quote", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "Quote Morpho Midnight lend/borrow fill", commonParams: [], params: {} },
6036
+ { id: "morpho.fetch-midnight-positions", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "List Morpho Midnight user positions", commonParams: [], params: {} },
6037
+ { id: "morpho.midnight-lend", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "Morpho Midnight fixed-rate lend (take asks)", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
6038
+ { 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: {} },
6039
+ { id: "morpho.midnight-repay", protocolId: MORPHO_PROTOCOL_ID, chainCategory: "evm", description: "Morpho Midnight repay debt and withdraw collateral", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} }
5419
6040
  ]
5420
6041
  };
5421
6042
  registerProtocolModule(morphoProtocolModule);
@@ -5936,7 +6557,7 @@ var PROTOCOL_SUPPORT_ADVISORS = {
5936
6557
  }));
5937
6558
  return {
5938
6559
  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 and Blue market loan/collateral tokens from api.morpho.org."
6560
+ 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
6561
  };
5941
6562
  },
5942
6563
  async isTokenSupported(chainId, address) {
@@ -6259,7 +6880,16 @@ exports.mcpMorphoFetchBlueMarketsInputSchema = mcpMorphoFetchBlueMarketsInputSch
6259
6880
  exports.mcpMorphoFetchBlueMarketsOutputSchema = mcpMorphoFetchBlueMarketsOutputSchema;
6260
6881
  exports.mcpMorphoFetchEarnVaultsInputSchema = mcpMorphoFetchEarnVaultsInputSchema;
6261
6882
  exports.mcpMorphoFetchEarnVaultsOutputSchema = mcpMorphoFetchEarnVaultsOutputSchema;
6883
+ exports.mcpMorphoFetchMidnightBooksInputSchema = mcpMorphoFetchMidnightBooksInputSchema;
6884
+ exports.mcpMorphoFetchMidnightBooksOutputSchema = mcpMorphoFetchMidnightBooksOutputSchema;
6885
+ exports.mcpMorphoFetchMidnightPositionsInputSchema = mcpMorphoFetchMidnightPositionsInputSchema;
6886
+ exports.mcpMorphoFetchMidnightPositionsOutputSchema = mcpMorphoFetchMidnightPositionsOutputSchema;
6887
+ exports.mcpMorphoFetchMidnightQuoteInputSchema = mcpMorphoFetchMidnightQuoteInputSchema;
6888
+ exports.mcpMorphoFetchMidnightQuoteOutputSchema = mcpMorphoFetchMidnightQuoteOutputSchema;
6262
6889
  exports.mcpMorphoMerklClaimInputSchema = mcpMorphoMerklClaimInputSchema;
6890
+ exports.mcpMorphoMidnightBorrowInputSchema = mcpMorphoMidnightBorrowInputSchema;
6891
+ exports.mcpMorphoMidnightLendInputSchema = mcpMorphoMidnightLendInputSchema;
6892
+ exports.mcpMorphoMidnightRepayInputSchema = mcpMorphoMidnightRepayInputSchema;
6263
6893
  exports.mcpMorphoVaultDepositInputSchema = mcpMorphoVaultDepositInputSchema;
6264
6894
  exports.mcpMorphoVaultWithdrawInputSchema = mcpMorphoVaultWithdrawInputSchema;
6265
6895
  exports.mcpMultisignInput = mcpMultisignInput;
@@ -6275,18 +6905,23 @@ exports.mcpSkyLockstakeStakeInputSchema = mcpSkyLockstakeStakeInputSchema;
6275
6905
  exports.mcpSkyLockstakeWipeInputSchema = mcpSkyLockstakeWipeInputSchema;
6276
6906
  exports.mcpSkySusdsDepositInputSchema = mcpSkySusdsDepositInputSchema;
6277
6907
  exports.mcpSkySusdsRedeemInputSchema = mcpSkySusdsRedeemInputSchema;
6908
+ exports.mcpUniswapV4BuildAllowlistFinalizeMultisignInputSchema = mcpUniswapV4BuildAllowlistFinalizeMultisignInputSchema;
6278
6909
  exports.mcpUniswapV4BuildCollectFeesMultisignInputSchema = mcpUniswapV4BuildCollectFeesMultisignInputSchema;
6279
6910
  exports.mcpUniswapV4BuildDecreaseLiquidityMultisignInputSchema = mcpUniswapV4BuildDecreaseLiquidityMultisignInputSchema;
6280
6911
  exports.mcpUniswapV4BuildIncreaseLiquidityMultisignInputSchema = mcpUniswapV4BuildIncreaseLiquidityMultisignInputSchema;
6281
6912
  exports.mcpUniswapV4BuildLimitOrderMultisignInputSchema = mcpUniswapV4BuildLimitOrderMultisignInputSchema;
6282
6913
  exports.mcpUniswapV4BuildMintLiquidityMultisignInputSchema = mcpUniswapV4BuildMintLiquidityMultisignInputSchema;
6283
6914
  exports.mcpUniswapV4BuildSwapMultisignInputSchema = mcpUniswapV4BuildSwapMultisignInputSchema;
6915
+ exports.mcpUniswapV4CheckPermissionsInputSchema = mcpUniswapV4CheckPermissionsInputSchema;
6916
+ exports.mcpUniswapV4CheckPermissionsOutputSchema = mcpUniswapV4CheckPermissionsOutputSchema;
6284
6917
  exports.mcpUniswapV4CreateSwapInputSchema = mcpUniswapV4CreateSwapInputSchema;
6285
6918
  exports.mcpUniswapV4CreateSwapOutputSchema = mcpUniswapV4CreateSwapOutputSchema;
6286
6919
  exports.mcpUniswapV4FetchLimitOrdersInputSchema = mcpUniswapV4FetchLimitOrdersInputSchema;
6287
6920
  exports.mcpUniswapV4FetchLimitOrdersOutputSchema = mcpUniswapV4FetchLimitOrdersOutputSchema;
6288
6921
  exports.mcpUniswapV4FetchOhlcvInputSchema = mcpUniswapV4FetchOhlcvInputSchema;
6289
6922
  exports.mcpUniswapV4FetchOhlcvOutputSchema = mcpUniswapV4FetchOhlcvOutputSchema;
6923
+ exports.mcpUniswapV4KycApplyLinkInputSchema = mcpUniswapV4KycApplyLinkInputSchema;
6924
+ exports.mcpUniswapV4KycApplyLinkOutputSchema = mcpUniswapV4KycApplyLinkOutputSchema;
6290
6925
  exports.mcpUniswapV4LimitOrderQuoteInputSchema = mcpUniswapV4LimitOrderQuoteInputSchema;
6291
6926
  exports.mcpUniswapV4LimitOrderQuoteOutputSchema = mcpUniswapV4LimitOrderQuoteOutputSchema;
6292
6927
  exports.mcpUniswapV4LpClaimInputSchema = mcpUniswapV4LpClaimInputSchema;