@continuumdao/ctm-mpc-defi 0.2.0 → 0.2.1

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 (100) hide show
  1. package/README.md +20 -78
  2. package/dist/agent/catalog.cjs +511 -4
  3. package/dist/agent/catalog.cjs.map +1 -1
  4. package/dist/agent/catalog.d.ts +140 -20
  5. package/dist/agent/catalog.js +501 -6
  6. package/dist/agent/catalog.js.map +1 -1
  7. package/dist/agent/skills/aave-v4/SKILL.md +43 -0
  8. package/dist/agent/skills/curve-dao/SKILL.md +12 -0
  9. package/dist/agent/skills/ethena/SKILL.md +10 -0
  10. package/dist/agent/skills/euler-v2/SKILL.md +10 -0
  11. package/dist/agent/skills/lido/SKILL.md +22 -0
  12. package/dist/agent/skills/maple-syrup/SKILL.md +10 -0
  13. package/dist/agent/skills/sky/SKILL.md +10 -0
  14. package/dist/agent/skills/uniswap-v4/SKILL.md +22 -0
  15. package/dist/chains/evm/index.cjs +27 -226
  16. package/dist/chains/evm/index.cjs.map +1 -1
  17. package/dist/chains/evm/index.d.ts +14 -26
  18. package/dist/chains/evm/index.js +21 -211
  19. package/dist/chains/evm/index.js.map +1 -1
  20. package/dist/chains/near/index.d.ts +1 -1
  21. package/dist/chains/solana/index.d.ts +1 -1
  22. package/dist/core/index.cjs +8 -110
  23. package/dist/core/index.cjs.map +1 -1
  24. package/dist/core/index.d.ts +5 -39
  25. package/dist/core/index.js +6 -100
  26. package/dist/core/index.js.map +1 -1
  27. package/dist/{envelope-CcE5Cz_q.d.ts → envelope-CpBUh9eP.d.ts} +1 -1
  28. package/dist/index.cjs +238 -1868
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.ts +7 -11
  31. package/dist/index.js +227 -1839
  32. package/dist/index.js.map +1 -1
  33. package/dist/protocols/evm/aave-v4/index.cjs +385 -662
  34. package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
  35. package/dist/protocols/evm/aave-v4/index.d.ts +1 -2
  36. package/dist/protocols/evm/aave-v4/index.js +385 -662
  37. package/dist/protocols/evm/aave-v4/index.js.map +1 -1
  38. package/dist/protocols/evm/curve-dao/index.cjs +24 -124
  39. package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
  40. package/dist/protocols/evm/curve-dao/index.d.ts +3 -4
  41. package/dist/protocols/evm/curve-dao/index.js +15 -115
  42. package/dist/protocols/evm/curve-dao/index.js.map +1 -1
  43. package/dist/protocols/evm/ethena/index.cjs +290 -402
  44. package/dist/protocols/evm/ethena/index.cjs.map +1 -1
  45. package/dist/protocols/evm/ethena/index.d.ts +1 -2
  46. package/dist/protocols/evm/ethena/index.js +291 -403
  47. package/dist/protocols/evm/ethena/index.js.map +1 -1
  48. package/dist/protocols/evm/euler-v2/index.cjs +485 -1163
  49. package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
  50. package/dist/protocols/evm/euler-v2/index.d.ts +1 -2
  51. package/dist/protocols/evm/euler-v2/index.js +486 -1164
  52. package/dist/protocols/evm/euler-v2/index.js.map +1 -1
  53. package/dist/protocols/evm/lido/index.cjs +241 -236
  54. package/dist/protocols/evm/lido/index.cjs.map +1 -1
  55. package/dist/protocols/evm/lido/index.d.ts +1 -2
  56. package/dist/protocols/evm/lido/index.js +242 -237
  57. package/dist/protocols/evm/lido/index.js.map +1 -1
  58. package/dist/protocols/evm/maple/index.cjs +310 -398
  59. package/dist/protocols/evm/maple/index.cjs.map +1 -1
  60. package/dist/protocols/evm/maple/index.d.ts +1 -2
  61. package/dist/protocols/evm/maple/index.js +311 -399
  62. package/dist/protocols/evm/maple/index.js.map +1 -1
  63. package/dist/protocols/evm/sky/index.cjs +238 -233
  64. package/dist/protocols/evm/sky/index.cjs.map +1 -1
  65. package/dist/protocols/evm/sky/index.d.ts +1 -2
  66. package/dist/protocols/evm/sky/index.js +236 -231
  67. package/dist/protocols/evm/sky/index.js.map +1 -1
  68. package/dist/protocols/evm/uniswap-v4/index.cjs +423 -658
  69. package/dist/protocols/evm/uniswap-v4/index.cjs.map +1 -1
  70. package/dist/protocols/evm/uniswap-v4/index.d.ts +3 -4
  71. package/dist/protocols/evm/uniswap-v4/index.js +422 -657
  72. package/dist/protocols/evm/uniswap-v4/index.js.map +1 -1
  73. package/dist/{registry-oMKlO_5z.d.ts → registry-Bv5o37_w.d.ts} +1 -1
  74. package/dist/{types-Ce2qNHai.d.cts → types-BfjWdw1j.d.ts} +3 -1
  75. package/dist/{types-5u863Fd9.d.ts → types-DUeNJLr9.d.ts} +1 -1
  76. package/package.json +7 -6
  77. package/dist/agent/catalog.d.cts +0 -939
  78. package/dist/chains/evm/index.d.cts +0 -64
  79. package/dist/chains/near/index.d.cts +0 -37
  80. package/dist/chains/solana/index.d.cts +0 -40
  81. package/dist/core/index.d.cts +0 -43
  82. package/dist/envelope-DYDPnrHZ.d.cts +0 -35
  83. package/dist/index.d.cts +0 -16
  84. package/dist/keygen-CfNp8yKJ.d.cts +0 -9
  85. package/dist/keygen-DsINazx8.d.ts +0 -9
  86. package/dist/nodeRead-BnmSaMGO.d.cts +0 -8
  87. package/dist/nodeRead-BnmSaMGO.d.ts +0 -8
  88. package/dist/protocols/evm/aave-v4/index.d.cts +0 -500
  89. package/dist/protocols/evm/curve-dao/index.d.cts +0 -147
  90. package/dist/protocols/evm/ethena/index.d.cts +0 -161
  91. package/dist/protocols/evm/euler-v2/index.d.cts +0 -317
  92. package/dist/protocols/evm/lido/index.d.cts +0 -120
  93. package/dist/protocols/evm/maple/index.d.cts +0 -109
  94. package/dist/protocols/evm/sky/index.d.cts +0 -218
  95. package/dist/protocols/evm/uniswap-v4/index.d.cts +0 -324
  96. package/dist/registry-BwZoE668.d.cts +0 -8
  97. package/dist/txParams-BC7ogvdR.d.cts +0 -19
  98. package/dist/txParams-BC7ogvdR.d.ts +0 -19
  99. package/dist/types-B8idm_gu.d.cts +0 -34
  100. package/dist/types-Ce2qNHai.d.ts +0 -57
@@ -1,6 +1,9 @@
1
- import { getAddress } from 'viem';
1
+ import { getAddress, isAddress } from 'viem';
2
2
  import { zodToJsonSchema } from 'zod-to-json-schema';
3
3
  import { z } from 'zod';
4
+ import { readFileSync } from 'fs';
5
+ import { join, dirname } from 'path';
6
+ import { fileURLToPath } from 'url';
4
7
 
5
8
  // src/core/registry.ts
6
9
  var modules = [];
@@ -159,6 +162,96 @@ function isCurveApiChainSupported(chainId) {
159
162
  if (Number.isNaN(n) || n < 0) return false;
160
163
  return CURVE_FULL_NETWORK_CONSTANTS_CHAIN_IDS.has(n);
161
164
  }
165
+ var CURVE_NATIVE_PLACEHOLDER = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
166
+ var ETH_PLACEHOLDER = CURVE_NATIVE_PLACEHOLDER;
167
+ function normalizeAddr(a) {
168
+ return a.toLowerCase();
169
+ }
170
+ function addEdge(adj, a, b) {
171
+ if (a === b) return;
172
+ if (!adj.has(a)) adj.set(a, /* @__PURE__ */ new Set());
173
+ if (!adj.has(b)) adj.set(b, /* @__PURE__ */ new Set());
174
+ adj.get(a).add(b);
175
+ adj.get(b).add(a);
176
+ }
177
+ function buildCurveLiquidityGraphFromApi(curve) {
178
+ const adj = /* @__PURE__ */ new Map();
179
+ for (const id of curve.getPoolList()) {
180
+ try {
181
+ const pool = curve.getPool(id);
182
+ const w = (pool.wrappedCoinAddresses ?? []).map(normalizeAddr);
183
+ const u = (pool.underlyingCoinAddresses ?? []).map(normalizeAddr);
184
+ const all = [.../* @__PURE__ */ new Set([...w, ...u])];
185
+ for (let i = 0; i < all.length; i++) {
186
+ for (let j = i + 1; j < all.length; j++) {
187
+ addEdge(adj, all[i], all[j]);
188
+ }
189
+ }
190
+ } catch {
191
+ }
192
+ }
193
+ return adj;
194
+ }
195
+ function addNativeWethBridge(adj, wrappedNative) {
196
+ if (!wrappedNative) return;
197
+ const w = wrappedNative.toLowerCase();
198
+ const a = ETH_PLACEHOLDER;
199
+ const b = w;
200
+ if (a === b) return;
201
+ if (!adj.has(a)) adj.set(a, /* @__PURE__ */ new Set());
202
+ if (!adj.has(b)) adj.set(b, /* @__PURE__ */ new Set());
203
+ adj.get(a).add(b);
204
+ adj.get(b).add(a);
205
+ }
206
+ function swappableCurveGraphNodeKeys(adj) {
207
+ const out = /* @__PURE__ */ new Set();
208
+ for (const [k, neigh] of adj) {
209
+ if (neigh.size > 0) out.add(k);
210
+ }
211
+ return out;
212
+ }
213
+
214
+ // src/protocols/evm/curve-dao/apiSession.ts
215
+ async function fetchAllCurvePools(curve) {
216
+ const run = (p) => p.catch(() => void 0);
217
+ await Promise.all([
218
+ run(curve.factory.fetchPools()),
219
+ run(curve.crvUSDFactory.fetchPools()),
220
+ run(curve.EYWAFactory.fetchPools()),
221
+ run(curve.cryptoFactory.fetchPools()),
222
+ run(curve.twocryptoFactory.fetchPools()),
223
+ run(curve.tricryptoFactory.fetchPools()),
224
+ run(curve.stableNgFactory.fetchPools())
225
+ ]);
226
+ }
227
+ async function loadFullCurveSessionForRpc(rpcUrl) {
228
+ const url = (rpcUrl ?? "").trim();
229
+ if (!url) return null;
230
+ try {
231
+ const { default: curve } = await import('@curvefi/api');
232
+ await curve.init("JsonRpc", { url }, {});
233
+ const wrapped = curve.getNetworkConstants().NATIVE_COIN?.wrappedAddress;
234
+ if (!curve.hasRouter || !curve.hasRouter()) {
235
+ return {
236
+ curve,
237
+ adj: /* @__PURE__ */ new Map(),
238
+ swappableNodeKeys: /* @__PURE__ */ new Set(),
239
+ wrappedNative: wrapped
240
+ };
241
+ }
242
+ await fetchAllCurvePools(curve);
243
+ const adj = buildCurveLiquidityGraphFromApi(curve);
244
+ addNativeWethBridge(adj, wrapped);
245
+ return {
246
+ curve,
247
+ adj,
248
+ swappableNodeKeys: swappableCurveGraphNodeKeys(adj),
249
+ wrappedNative: wrapped
250
+ };
251
+ } catch {
252
+ return null;
253
+ }
254
+ }
162
255
 
163
256
  // src/protocols/evm/curve-dao/index.ts
164
257
  var CURVE_DAO_PROTOCOL_ID = "curve-dao";
@@ -248,7 +341,14 @@ var MULTISIGN_OUTPUT_DOC = {
248
341
  }
249
342
  };
250
343
  var MANAGEMENT_SIG_DOC = {
251
- description: "Management POST bodies embed NodeMgtKeySig: { nonce, clientSig, nodeKey }. Sign JSON with clientSig cleared; POST with clientSig set to the Ed25519 128-hex or EIP-191 signature. Legacy Nonce/Sig/sig field names are not accepted.",
344
+ description: "Management POST bodies embed NodeMgtKeySig: { nonce, clientSig, nodeKey }. Sign JSON with clientSig cleared via messageToSignManagementBody; POST with withManagementClientSig(body, sig). Do not put signedMessage in the JSON body for standard management routes. Legacy Nonce/Sig/sig field names are not accepted.",
345
+ exceptions: {
346
+ configUpdateImplement: "POST /configUpdateImplement: include nodeKey + plannedYaml + signedMessage (opaque configUpdateImplement|<sha256> line). Sign the opaque line bytes, not the JSON body.",
347
+ postMSQTTKey: "POST /postMSQTTKey: include nodeKey + caCertPem + clientSig. Sign caCertPem PEM bytes directly (use buildPostMqttKeyBody).",
348
+ addManagementKey: "POST /addManagementKey / removeManagementKey (EIP-191): may still use signedMessage equal to the canonical JSON string for dual-mode Ethereum signing.",
349
+ agentLlmConfig: "POST /agentLlmConfig / agentLlmApiKey: sign canonical JSON with action + clientSig cleared; POST body has nonce, clientSig, nodeKey, endpoint fields \u2014 no signedMessage field.",
350
+ multiSignRequest: "POST /multiSignRequest (client key, not management): POST { ...bodyForSign, clientSig, signedMessage: messageToSign }."
351
+ },
252
352
  fields: {
253
353
  nonce: {
254
354
  type: "number",
@@ -266,10 +366,15 @@ var MANAGEMENT_SIG_DOC = {
266
366
  helpers: {
267
367
  managementSigFields: "Base envelope with clientSig cleared.",
268
368
  buildManagementPostBody: "Spread managementSigFields then endpoint fields.",
369
+ buildPostMqttKeyBody: "POST /postMSQTTKey unsigned body (sign PEM directly).",
370
+ buildPostPreferredKeyGenBody: "POST /postPreferredKeyGen unsigned body.",
371
+ buildConfigUpdateImplementPostBody: "POST /configUpdateImplement with opaque signedMessage line.",
372
+ buildSignRequestAgreeUnsignedBody: "POST /signRequestAgree unsigned body with nodeKey.",
269
373
  messageToSignManagementBody: "Canonical JSON string to sign.",
270
374
  withManagementClientSig: "Attach signature to POST body.",
271
375
  fetchNodeKey: "GET /getNodeKey via nodeFetchWithReadAuth.",
272
- fetchManagementNonce: "GET nonce for Ed25519 or Ethereum management key."
376
+ fetchManagementNonce: "GET nonce for Ed25519 or Ethereum management key.",
377
+ fetchPreferredKeyGen: "GET /getPreferredKeyGen for agent default KeyGen."
273
378
  }
274
379
  };
275
380
  function zodSchemaToMcpJsonSchema(schema) {
@@ -797,7 +902,7 @@ var MCP_PROTOCOL_TOOL_DEFINITIONS = [
797
902
  description: "Build Euler v2 vault withdraw/redeem batch.",
798
903
  prerequisites: ["keyGen", "executorAddress", "vault address"],
799
904
  followUp: ["Sign messageToSign", "POST /multiSignRequest"],
800
- handler: { importPath: "protocols/evm/euler-v2", exportName: "buildEvmMultisignBodyEulerV2VaultWithdrawBatch" },
905
+ handler: { importPath: "protocols/evm/euler-v2", exportName: "buildEvmMultisignBodyEulerV2VaultWithdraw" },
801
906
  inputZod: mcpEulerV2VaultWithdrawInputSchema
802
907
  }),
803
908
  defineProtocolMcpTool({
@@ -958,7 +1063,13 @@ function getAgentCatalogForMcp() {
958
1063
  "2. GET /getPublicMgtKeyNonce or /getNodeMgtKeyNonce \u2192 nonce",
959
1064
  "3. buildManagementPostBody(nonce, nodeKey, { \u2026endpoint fields })",
960
1065
  "4. messageToSignManagementBody(body) \u2192 sign \u2192 withManagementClientSig(body, sig)",
961
- "5. POST management route with signed body"
1066
+ "5. POST management route with signed body (no signedMessage field except configUpdateImplement opaque line)"
1067
+ ],
1068
+ agentMultisignTypical: [
1069
+ "1. load_defi_protocol for the target protocol",
1070
+ "2. get_defi_protocol_supported_chains / get_token_registry to pick chainId and tokens",
1071
+ "3. MCP build_* tool with keyGenId + chainId \u2192 { requestId }",
1072
+ "4. Base MCP: wait_for_sign_request_ready \u2192 sign_request_agree \u2192 trigger_sign_result \u2192 broadcast_sign_result"
962
1073
  ]
963
1074
  }
964
1075
  };
@@ -994,6 +1105,7 @@ var lidoProtocolModule = {
994
1105
  };
995
1106
  registerProtocolModule(lidoProtocolModule);
996
1107
  var USDE_ETHEREUM_MAINNET = "0x4c9edd5852cd905f086c759e8383e09bff1e68b3";
1108
+ var SUSDE_ETHEREUM_MAINNET = "0x9d39a5de30e57443bff2a8307a4256c8797a3497";
997
1109
  var USDE_MOST_L2S = "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34";
998
1110
  var USDE_ZKSYNC_ERA = "0x39Fe7a0DACcE31Bd90418e3e659fb0b5f0B3Db0d";
999
1111
  var L2_SAME_ADDRESS_CHAIN_IDS = /* @__PURE__ */ new Set([
@@ -1034,12 +1146,53 @@ var L2_SAME_ADDRESS_CHAIN_IDS = /* @__PURE__ */ new Set([
1034
1146
  48900
1035
1147
  // Zircuit
1036
1148
  ]);
1149
+ var FALLBACK_NAME_BY_ID = {
1150
+ 1: "Ethereum",
1151
+ 42161: "Arbitrum One",
1152
+ 10: "Optimism",
1153
+ 8453: "Base",
1154
+ 56: "BNB Chain",
1155
+ 59144: "Linea",
1156
+ 5e3: "Mantle",
1157
+ 81457: "Blast",
1158
+ 169: "Manta Pacific",
1159
+ 534352: "Scroll",
1160
+ 252: "Fraxtal",
1161
+ 34443: "Mode",
1162
+ 196: "X Layer",
1163
+ 1088: "Metis",
1164
+ 80084: "Berachain",
1165
+ 2222: "Kava",
1166
+ 2818: "Morph",
1167
+ 1923: "Swell",
1168
+ 48900: "Zircuit",
1169
+ 324: "ZKSync Era"
1170
+ };
1037
1171
  function usdeTokenAddressOnEvmChain(chainId) {
1038
1172
  if (chainId === 1) return USDE_ETHEREUM_MAINNET;
1039
1173
  if (chainId === 324) return USDE_ZKSYNC_ERA;
1040
1174
  if (L2_SAME_ADDRESS_CHAIN_IDS.has(chainId)) return USDE_MOST_L2S;
1041
1175
  return null;
1042
1176
  }
1177
+ function listEthenaUsdeEvmNetworkRows() {
1178
+ const rows = [
1179
+ { chainId: 1, label: FALLBACK_NAME_BY_ID[1], usde: USDE_ETHEREUM_MAINNET }
1180
+ ];
1181
+ const l2 = [...L2_SAME_ADDRESS_CHAIN_IDS].sort((a, b) => a - b);
1182
+ for (const id of l2) {
1183
+ rows.push({
1184
+ chainId: id,
1185
+ label: FALLBACK_NAME_BY_ID[id] ?? `Chain ${id}`,
1186
+ usde: USDE_MOST_L2S
1187
+ });
1188
+ }
1189
+ rows.push({ chainId: 324, label: FALLBACK_NAME_BY_ID[324], usde: USDE_ZKSYNC_ERA });
1190
+ return rows.sort((a, b) => {
1191
+ if (a.chainId === 1) return -1;
1192
+ if (b.chainId === 1) return 1;
1193
+ return a.chainId - b.chainId;
1194
+ });
1195
+ }
1043
1196
  function isEvmChainInEthenaUsdeList(chainId) {
1044
1197
  return usdeTokenAddressOnEvmChain(chainId) != null;
1045
1198
  }
@@ -1116,6 +1269,83 @@ var skyProtocolModule = {
1116
1269
  ]
1117
1270
  };
1118
1271
  registerProtocolModule(skyProtocolModule);
1272
+ var AAVE_V4_GRAPHQL_URL = "https://api.v4.aave.com/graphql";
1273
+ async function aaveV4Gql(query, variables) {
1274
+ const r = await fetch(AAVE_V4_GRAPHQL_URL, {
1275
+ method: "POST",
1276
+ headers: { "content-type": "application/json" },
1277
+ body: JSON.stringify({ query, variables: variables ?? {} })
1278
+ });
1279
+ if (!r.ok) {
1280
+ const t = await r.text().catch(() => "");
1281
+ throw new Error(t ? `Aave V4 API HTTP ${r.status}: ${t.slice(0, 200)}` : `Aave V4 API HTTP ${r.status}`);
1282
+ }
1283
+ const j = await r.json();
1284
+ if (j.errors?.length) {
1285
+ const msg = j.errors.map((e) => e.message ?? "Unknown").join("; ");
1286
+ throw new Error(msg);
1287
+ }
1288
+ if (j.data == null) {
1289
+ throw new Error("Aave V4 API: empty response");
1290
+ }
1291
+ return j.data;
1292
+ }
1293
+ async function fetchAaveV4Chains() {
1294
+ const d = await aaveV4Gql(`
1295
+ query C($c: ChainsRequest!) { chains(request: $c) { chainId name nativeWrappedToken } }
1296
+ `, { c: { query: { filter: "ALL" } } });
1297
+ return d.chains ?? [];
1298
+ }
1299
+ async function loadAaveV4SupportedChainIdsFromV4Api() {
1300
+ const rows = await fetchAaveV4Chains();
1301
+ const s = /* @__PURE__ */ new Set();
1302
+ for (const c of rows) s.add(c.chainId);
1303
+ return s;
1304
+ }
1305
+ var RESERVES_ADDRESS_FRAGMENT = `
1306
+ asset { underlying { address } }
1307
+ `;
1308
+ async function fetchAaveV4NativeWrappedToken(chainId) {
1309
+ const all = await fetchAaveV4Chains();
1310
+ const c = all.find((x) => x.chainId === chainId);
1311
+ const t = (c?.nativeWrappedToken ?? "").trim();
1312
+ if (t && isAddress(t)) return getAddress(t);
1313
+ return null;
1314
+ }
1315
+ async function fetchAaveV4SupportedUnderlyingAddressSet(chainId) {
1316
+ const d = await aaveV4Gql(
1317
+ `
1318
+ query A($r: ReservesRequest!) { reserves(request: $r) { ${RESERVES_ADDRESS_FRAGMENT} } }
1319
+ `,
1320
+ {
1321
+ r: {
1322
+ query: { chainIds: [chainId] },
1323
+ filter: "ALL",
1324
+ orderBy: { supplyApy: "DESC" }
1325
+ }
1326
+ }
1327
+ );
1328
+ const s = /* @__PURE__ */ new Set();
1329
+ for (const r of d.reserves ?? []) {
1330
+ const a = (r.asset?.underlying?.address ?? "").trim();
1331
+ if (a && isAddress(a)) s.add(a.toLowerCase());
1332
+ }
1333
+ return s;
1334
+ }
1335
+ var aaveV4ChainTokenCache = /* @__PURE__ */ new Map();
1336
+ function ensureAaveV4ChainTokenCache(chainId) {
1337
+ const hit = aaveV4ChainTokenCache.get(chainId);
1338
+ if (hit) return hit;
1339
+ const p = (async () => {
1340
+ const [nativeWrapped, supportedUnderlying] = await Promise.all([
1341
+ fetchAaveV4NativeWrappedToken(chainId),
1342
+ fetchAaveV4SupportedUnderlyingAddressSet(chainId)
1343
+ ]);
1344
+ return { supportedUnderlying, nativeWrapped };
1345
+ })();
1346
+ aaveV4ChainTokenCache.set(chainId, p);
1347
+ return p;
1348
+ }
1119
1349
 
1120
1350
  // src/protocols/evm/aave-v4/index.ts
1121
1351
  var AAVE_V4_PROTOCOL_ID = "aave-v4";
@@ -1158,6 +1388,271 @@ var eulerV2ProtocolModule = {
1158
1388
  ]
1159
1389
  };
1160
1390
  registerProtocolModule(eulerV2ProtocolModule);
1391
+ var skillsDir = join(dirname(fileURLToPath(import.meta.url)), "skills");
1392
+ var SKILL_PROTOCOL_IDS = [
1393
+ "aave-v4",
1394
+ "lido",
1395
+ "uniswap-v4",
1396
+ "curve-dao",
1397
+ "ethena",
1398
+ "euler-v2",
1399
+ "maple-syrup",
1400
+ "sky"
1401
+ ];
1402
+ function getToolsForProtocol(protocolId) {
1403
+ return MCP_TOOL_DEFINITIONS.filter((t) => t.protocolId === protocolId);
1404
+ }
1405
+ function getProtocolSkill(protocolId) {
1406
+ if (!SKILL_PROTOCOL_IDS.includes(protocolId)) {
1407
+ return void 0;
1408
+ }
1409
+ try {
1410
+ return readFileSync(join(skillsDir, protocolId, "SKILL.md"), "utf8");
1411
+ } catch {
1412
+ return void 0;
1413
+ }
1414
+ }
1415
+ function listProtocolsWithSkills() {
1416
+ return [...SKILL_PROTOCOL_IDS];
1417
+ }
1418
+ function getProtocolDiscoverySummary(protocolId) {
1419
+ const mod = getProtocolModules().find((p) => p.id === protocolId);
1420
+ if (!mod) return void 0;
1421
+ return {
1422
+ protocolId: mod.id,
1423
+ chainCategory: mod.chainCategory,
1424
+ actions: mod.actions.map((a) => ({ id: a.id, description: a.description })),
1425
+ tools: getToolsForProtocol(protocolId).map((t) => ({
1426
+ name: t.name,
1427
+ actionId: t.actionId,
1428
+ description: t.description,
1429
+ prerequisites: t.prerequisites,
1430
+ followUp: t.followUp
1431
+ }))
1432
+ };
1433
+ }
1434
+ var EULER_V2_SUBGRAPH_CHAIN_IDS = [
1435
+ 1,
1436
+ 8453,
1437
+ 42161,
1438
+ 10,
1439
+ 137,
1440
+ 56,
1441
+ 43114,
1442
+ 100,
1443
+ 59144,
1444
+ 146,
1445
+ 1923,
1446
+ 130
1447
+ ];
1448
+ function advisor(protocolId, tokenFilter, impl) {
1449
+ return { protocolId, tokenFilter, ...impl };
1450
+ }
1451
+ var PROTOCOL_SUPPORT_ADVISORS = {
1452
+ "aave-v4": advisor("aave-v4", "api_underlyings", {
1453
+ async supportedChainIds() {
1454
+ const set = await loadAaveV4SupportedChainIdsFromV4Api();
1455
+ return [...set].sort((a, b) => a - b);
1456
+ },
1457
+ async supportedTokens(chainId) {
1458
+ const cache = await ensureAaveV4ChainTokenCache(chainId);
1459
+ const tokens = [...cache.supportedUnderlying].map((address) => ({
1460
+ address,
1461
+ roles: ["underlying"]
1462
+ }));
1463
+ if (cache.nativeWrapped) {
1464
+ tokens.unshift({
1465
+ address: cache.nativeWrapped,
1466
+ symbol: "WETH",
1467
+ roles: ["native_wrapped"]
1468
+ });
1469
+ }
1470
+ return {
1471
+ tokens,
1472
+ nativeWrapped: cache.nativeWrapped ?? void 0,
1473
+ notes: "Native ETH deposits use wrapped native token address from Aave v4 API."
1474
+ };
1475
+ },
1476
+ async isTokenSupported(chainId, address) {
1477
+ const cache = await ensureAaveV4ChainTokenCache(chainId);
1478
+ let normalized;
1479
+ try {
1480
+ normalized = getAddress(address).toLowerCase();
1481
+ } catch {
1482
+ return false;
1483
+ }
1484
+ if (cache.nativeWrapped && getAddress(cache.nativeWrapped).toLowerCase() === normalized) {
1485
+ return true;
1486
+ }
1487
+ return cache.supportedUnderlying.has(normalized);
1488
+ }
1489
+ }),
1490
+ "uniswap-v4": advisor("uniswap-v4", "any_erc20_on_chain", {
1491
+ async supportedChainIds() {
1492
+ const ids = [];
1493
+ for (const id of [
1494
+ 1,
1495
+ 5,
1496
+ 11155111,
1497
+ 137,
1498
+ 80001,
1499
+ 10,
1500
+ 420,
1501
+ 42161,
1502
+ 421613,
1503
+ 42220,
1504
+ 44787,
1505
+ 56,
1506
+ 43114,
1507
+ 84531,
1508
+ 8453,
1509
+ 81457,
1510
+ 7777777,
1511
+ 324,
1512
+ 480,
1513
+ 1301,
1514
+ 130,
1515
+ 10143,
1516
+ 84532,
1517
+ 1868,
1518
+ 143,
1519
+ 59144,
1520
+ 4217,
1521
+ 196
1522
+ ]) {
1523
+ if (isUniswapV4ChainSupported(id)) ids.push(id);
1524
+ }
1525
+ return ids;
1526
+ },
1527
+ async supportedTokens() {
1528
+ return {
1529
+ tokens: [],
1530
+ notes: "Any ERC-20 or native token on a supported chain may be used. Resolve addresses via get_token_registry; tokenOut may be any address."
1531
+ };
1532
+ }
1533
+ }),
1534
+ "curve-dao": advisor("curve-dao", "pool_graph", {
1535
+ async supportedChainIds() {
1536
+ return [1, 10, 56, 100, 137, 146, 196, 250, 252, 324, 999, 1284, 2222, 5e3, 8453, 42161, 42220, 43114, 1313161554];
1537
+ },
1538
+ async supportedTokens(chainId, ctx) {
1539
+ if (!isCurveApiChainSupported(chainId)) {
1540
+ return { tokens: [], notes: "Chain not supported by Curve SDK network constants." };
1541
+ }
1542
+ const rpcUrl = ctx?.rpcUrl?.trim();
1543
+ if (!rpcUrl) {
1544
+ return {
1545
+ tokens: [],
1546
+ notes: "Provide rpcUrl (from get_chain_registry) to load Curve pool graph token list."
1547
+ };
1548
+ }
1549
+ const session = await loadFullCurveSessionForRpc(rpcUrl);
1550
+ if (!session?.swappableNodeKeys?.size) {
1551
+ return { tokens: [], notes: "Curve session returned no swappable tokens for this RPC." };
1552
+ }
1553
+ return {
1554
+ tokens: [...session.swappableNodeKeys].map((key) => {
1555
+ const address = key.startsWith("0x") ? key : key.split(":")[0] ?? key;
1556
+ return { address, roles: ["swappable"] };
1557
+ })
1558
+ };
1559
+ }
1560
+ }),
1561
+ lido: advisor("lido", "mainnet_only", {
1562
+ async supportedChainIds() {
1563
+ return [LIDO_ETHEREUM_MAINNET_CHAIN_ID];
1564
+ },
1565
+ async supportedTokens() {
1566
+ return {
1567
+ tokens: [
1568
+ { address: "0x0000000000000000000000000000000000000000", symbol: "ETH", roles: ["native", "stake"] },
1569
+ { address: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84", symbol: "stETH", roles: ["erc20"] },
1570
+ { address: "0x7f39C581F595B853cBbF37C12FfeeA971C5a5bEa", symbol: "wstETH", roles: ["erc20"] }
1571
+ ],
1572
+ notes: "Lido staking and withdrawals are Ethereum mainnet only."
1573
+ };
1574
+ }
1575
+ }),
1576
+ ethena: advisor("ethena", "minting_contract", {
1577
+ async supportedChainIds() {
1578
+ return listEthenaUsdeEvmNetworkRows().map((r) => r.chainId);
1579
+ },
1580
+ async supportedTokens(chainId) {
1581
+ if (chainId === 1) {
1582
+ return {
1583
+ tokens: [
1584
+ { address: USDE_ETHEREUM_MAINNET, symbol: "USDe", roles: ["stake"] },
1585
+ { address: SUSDE_ETHEREUM_MAINNET, symbol: "sUSDe", roles: ["vault"] }
1586
+ ],
1587
+ notes: "Ethena stake/redeem UI actions are mainnet-only; USDe exists on other chains for transfers."
1588
+ };
1589
+ }
1590
+ if (isEvmChainInEthenaUsdeList(chainId)) {
1591
+ const row = listEthenaUsdeEvmNetworkRows().find((r) => r.chainId === chainId);
1592
+ return {
1593
+ tokens: row ? [{ address: row.usde, symbol: "USDe", roles: ["erc20"] }] : [],
1594
+ notes: "USDe on L2; staking MCP tools target mainnet only."
1595
+ };
1596
+ }
1597
+ return { tokens: [] };
1598
+ }
1599
+ }),
1600
+ "euler-v2": advisor("euler-v2", "subgraph_vaults", {
1601
+ async supportedChainIds() {
1602
+ return [...EULER_V2_SUBGRAPH_CHAIN_IDS];
1603
+ },
1604
+ async supportedTokens() {
1605
+ return {
1606
+ tokens: [],
1607
+ notes: "Euler vault/collateral assets vary by chain. Pass vault and asset addresses from Euler app or subgraph."
1608
+ };
1609
+ }
1610
+ }),
1611
+ [MAPLE_PROTOCOL_ID]: advisor(MAPLE_PROTOCOL_ID, "fixed_addresses", {
1612
+ async supportedChainIds() {
1613
+ return [1, 11155111];
1614
+ },
1615
+ async supportedTokens() {
1616
+ return {
1617
+ tokens: [],
1618
+ notes: "Maple Syrup pools are discovered via GraphQL; pass syrupRouter, pool, and asset from Maple UI."
1619
+ };
1620
+ }
1621
+ }),
1622
+ [SKY_PROTOCOL_ID]: advisor(SKY_PROTOCOL_ID, "fixed_addresses", {
1623
+ async supportedChainIds() {
1624
+ return [1];
1625
+ },
1626
+ async supportedTokens() {
1627
+ return {
1628
+ tokens: [],
1629
+ notes: "Sky Lockstake and sUSDS use fixed mainnet contract addresses in protocol builders."
1630
+ };
1631
+ }
1632
+ })
1633
+ };
1634
+ function getProtocolSupportAdvisor(protocolId) {
1635
+ return PROTOCOL_SUPPORT_ADVISORS[protocolId];
1636
+ }
1637
+ function listProtocolSupportAdvisorIds() {
1638
+ return Object.keys(PROTOCOL_SUPPORT_ADVISORS);
1639
+ }
1640
+ var mcpServerCommonInputSchema = z.object({
1641
+ keyGenId: z.string().min(1).describe("KeyGen id from fetch_key_gen_result / node preferred KeyGen"),
1642
+ chainId: z.number().int().positive().describe("EVM chain id; RPC and gas config resolved from chain registry"),
1643
+ purposeText: z.string().min(1).describe("Human-readable purpose for the sign request"),
1644
+ useCustomGas: z.boolean().optional().describe("Apply chain gas settings from registry when true")
1645
+ });
1646
+ function mcpServerMultisignInput(fields) {
1647
+ return mcpServerCommonInputSchema.extend(fields);
1648
+ }
1649
+ var mcpServerSubmitOutputSchema = z.object({
1650
+ requestId: z.string().min(1)
1651
+ }).describe("mpc-auth multiSignRequest id; continue with trigger_sign_result / broadcast_sign_result");
1652
+ var MCP_NON_SUBMIT_TOOL_NAMES = /* @__PURE__ */ new Set([
1653
+ "ctm_uniswap_v4_quote",
1654
+ "ctm_uniswap_v4_create_swap"
1655
+ ]);
1161
1656
 
1162
1657
  // src/agent/catalog.ts
1163
1658
  registerProtocolModule(uniswapV4ProtocolModule);
@@ -1189,6 +1684,6 @@ function getAgentCatalog() {
1189
1684
  };
1190
1685
  }
1191
1686
 
1192
- export { EVM_COMMON_PARAM_DOCS, MANAGEMENT_SIG_DOC, MCP_TOOL_DEFINITIONS, MCP_TOOL_INPUT_SCHEMAS, MCP_TOOL_OUTPUT_SCHEMAS, MULTISIGN_OUTPUT_DOC, chainDetailSchema, evmAddressSchema, evmMultisignCommonInputSchema, getActionsByChainCategory, getAgentCatalog, getAgentCatalogForMcp, getMcpToolByName, getMcpToolDefinitions, getMcpToolInputSchema, getMcpToolOutputSchema, getProtocolModules, jsonObjectSchema, keyGenSchema, mcpAaveV4BorrowInputSchema, mcpAaveV4DepositInputSchema, mcpAaveV4RepayInputSchema, mcpAaveV4WithdrawInputSchema, mcpCurveDaoBuildSwapMultisignInputSchema, mcpEthenaClaimInputSchema, mcpEthenaCooldownInputSchema, mcpEthenaRedeemInputSchema, mcpEthenaStakeInputSchema, mcpEulerV2BorrowRepayInputSchema, mcpEulerV2CollateralDepositInputSchema, mcpEulerV2CollateralWithdrawInputSchema, mcpEulerV2IsolatedBorrowInputSchema, mcpEulerV2IsolatedLendInputSchema, mcpEulerV2VaultWithdrawInputSchema, mcpLidoClaimWithdrawalInputSchema, mcpLidoRequestWithdrawalsInputSchema, mcpLidoSubmitInputSchema, mcpLidoUnwrapWstEthInputSchema, mcpLidoWrapStEthInputSchema, mcpMapleDepositInputSchema, mcpMapleRequestRedeemInputSchema, mcpMultisignInput, multisignOutputSchema as mcpMultisignOutputSchema, mcpSkyLockstakeCloseInputSchema, mcpSkyLockstakeDrawInputSchema, mcpSkyLockstakeGetRewardInputSchema, mcpSkyLockstakeStakeInputSchema, mcpSkyLockstakeWipeInputSchema, mcpSkySusdsDepositInputSchema, mcpSkySusdsRedeemInputSchema, mcpUniswapV4BuildSwapMultisignInputSchema, mcpUniswapV4CreateSwapInputSchema, mcpUniswapV4CreateSwapOutputSchema, mcpUniswapV4QuoteInputSchema, mcpUniswapV4QuoteOutputSchema, multisignOutputSchema, parseMcpToolInput, parseMcpToolOutput, uniswapQuoteTradeTypeSchema, zodSchemaToMcpJsonSchema };
1687
+ export { EVM_COMMON_PARAM_DOCS, MANAGEMENT_SIG_DOC, MCP_NON_SUBMIT_TOOL_NAMES, MCP_TOOL_DEFINITIONS, MCP_TOOL_INPUT_SCHEMAS, MCP_TOOL_OUTPUT_SCHEMAS, MULTISIGN_OUTPUT_DOC, PROTOCOL_SUPPORT_ADVISORS, chainDetailSchema, evmAddressSchema, evmMultisignCommonInputSchema, getActionsByChainCategory, getAgentCatalog, getAgentCatalogForMcp, getMcpToolByName, getMcpToolDefinitions, getMcpToolInputSchema, getMcpToolOutputSchema, getProtocolDiscoverySummary, getProtocolModules, getProtocolSkill, getProtocolSupportAdvisor, getToolsForProtocol, jsonObjectSchema, keyGenSchema, listProtocolSupportAdvisorIds, listProtocolsWithSkills, mcpAaveV4BorrowInputSchema, mcpAaveV4DepositInputSchema, mcpAaveV4RepayInputSchema, mcpAaveV4WithdrawInputSchema, mcpCurveDaoBuildSwapMultisignInputSchema, mcpEthenaClaimInputSchema, mcpEthenaCooldownInputSchema, mcpEthenaRedeemInputSchema, mcpEthenaStakeInputSchema, mcpEulerV2BorrowRepayInputSchema, mcpEulerV2CollateralDepositInputSchema, mcpEulerV2CollateralWithdrawInputSchema, mcpEulerV2IsolatedBorrowInputSchema, mcpEulerV2IsolatedLendInputSchema, mcpEulerV2VaultWithdrawInputSchema, mcpLidoClaimWithdrawalInputSchema, mcpLidoRequestWithdrawalsInputSchema, mcpLidoSubmitInputSchema, mcpLidoUnwrapWstEthInputSchema, mcpLidoWrapStEthInputSchema, mcpMapleDepositInputSchema, mcpMapleRequestRedeemInputSchema, mcpMultisignInput, multisignOutputSchema as mcpMultisignOutputSchema, mcpServerCommonInputSchema, mcpServerMultisignInput, mcpServerSubmitOutputSchema, mcpSkyLockstakeCloseInputSchema, mcpSkyLockstakeDrawInputSchema, mcpSkyLockstakeGetRewardInputSchema, mcpSkyLockstakeStakeInputSchema, mcpSkyLockstakeWipeInputSchema, mcpSkySusdsDepositInputSchema, mcpSkySusdsRedeemInputSchema, mcpUniswapV4BuildSwapMultisignInputSchema, mcpUniswapV4CreateSwapInputSchema, mcpUniswapV4CreateSwapOutputSchema, mcpUniswapV4QuoteInputSchema, mcpUniswapV4QuoteOutputSchema, multisignOutputSchema, parseMcpToolInput, parseMcpToolOutput, uniswapQuoteTradeTypeSchema, zodSchemaToMcpJsonSchema };
1193
1688
  //# sourceMappingURL=catalog.js.map
1194
1689
  //# sourceMappingURL=catalog.js.map