@continuumdao/ctm-mpc-defi 0.2.0 → 0.2.2

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 +563 -5
  3. package/dist/agent/catalog.cjs.map +1 -1
  4. package/dist/agent/catalog.d.ts +166 -20
  5. package/dist/agent/catalog.js +551 -7
  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 +13 -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 +79 -224
  16. package/dist/chains/evm/index.cjs.map +1 -1
  17. package/dist/chains/evm/index.d.ts +26 -26
  18. package/dist/chains/evm/index.js +69 -209
  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 +68 -106
  23. package/dist/core/index.cjs.map +1 -1
  24. package/dist/core/index.d.ts +21 -36
  25. package/dist/core/index.js +57 -96
  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 +356 -1855
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.ts +7 -11
  31. package/dist/index.js +332 -1826
  32. package/dist/index.js.map +1 -1
  33. package/dist/protocols/evm/aave-v4/index.cjs +1152 -669
  34. package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
  35. package/dist/protocols/evm/aave-v4/index.d.ts +418 -3
  36. package/dist/protocols/evm/aave-v4/index.js +1126 -670
  37. package/dist/protocols/evm/aave-v4/index.js.map +1 -1
  38. package/dist/protocols/evm/curve-dao/index.cjs +257 -131
  39. package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
  40. package/dist/protocols/evm/curve-dao/index.d.ts +69 -5
  41. package/dist/protocols/evm/curve-dao/index.js +242 -124
  42. package/dist/protocols/evm/curve-dao/index.js.map +1 -1
  43. package/dist/protocols/evm/ethena/index.cjs +394 -402
  44. package/dist/protocols/evm/ethena/index.cjs.map +1 -1
  45. package/dist/protocols/evm/ethena/index.d.ts +47 -3
  46. package/dist/protocols/evm/ethena/index.js +390 -404
  47. package/dist/protocols/evm/ethena/index.js.map +1 -1
  48. package/dist/protocols/evm/euler-v2/index.cjs +2810 -1191
  49. package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
  50. package/dist/protocols/evm/euler-v2/index.d.ts +465 -3
  51. package/dist/protocols/evm/euler-v2/index.js +2761 -1192
  52. package/dist/protocols/evm/euler-v2/index.js.map +1 -1
  53. package/dist/protocols/evm/lido/index.cjs +351 -236
  54. package/dist/protocols/evm/lido/index.cjs.map +1 -1
  55. package/dist/protocols/evm/lido/index.d.ts +34 -4
  56. package/dist/protocols/evm/lido/index.js +348 -238
  57. package/dist/protocols/evm/lido/index.js.map +1 -1
  58. package/dist/protocols/evm/maple/index.cjs +390 -395
  59. package/dist/protocols/evm/maple/index.cjs.map +1 -1
  60. package/dist/protocols/evm/maple/index.d.ts +23 -3
  61. package/dist/protocols/evm/maple/index.js +390 -397
  62. package/dist/protocols/evm/maple/index.js.map +1 -1
  63. package/dist/protocols/evm/sky/index.cjs +454 -232
  64. package/dist/protocols/evm/sky/index.cjs.map +1 -1
  65. package/dist/protocols/evm/sky/index.d.ts +57 -3
  66. package/dist/protocols/evm/sky/index.js +444 -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
@@ -3,7 +3,11 @@
3
3
  var viem = require('viem');
4
4
  var zodToJsonSchema = require('zod-to-json-schema');
5
5
  var zod = require('zod');
6
+ var fs = require('fs');
7
+ var path = require('path');
8
+ var url = require('url');
6
9
 
10
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
7
11
  // src/core/registry.ts
8
12
  var modules = [];
9
13
  function registerProtocolModule(mod) {
@@ -161,6 +165,96 @@ function isCurveApiChainSupported(chainId) {
161
165
  if (Number.isNaN(n) || n < 0) return false;
162
166
  return CURVE_FULL_NETWORK_CONSTANTS_CHAIN_IDS.has(n);
163
167
  }
168
+ var CURVE_NATIVE_PLACEHOLDER = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
169
+ var ETH_PLACEHOLDER = CURVE_NATIVE_PLACEHOLDER;
170
+ function normalizeAddr(a) {
171
+ return a.toLowerCase();
172
+ }
173
+ function addEdge(adj, a, b) {
174
+ if (a === b) return;
175
+ if (!adj.has(a)) adj.set(a, /* @__PURE__ */ new Set());
176
+ if (!adj.has(b)) adj.set(b, /* @__PURE__ */ new Set());
177
+ adj.get(a).add(b);
178
+ adj.get(b).add(a);
179
+ }
180
+ function buildCurveLiquidityGraphFromApi(curve) {
181
+ const adj = /* @__PURE__ */ new Map();
182
+ for (const id of curve.getPoolList()) {
183
+ try {
184
+ const pool = curve.getPool(id);
185
+ const w = (pool.wrappedCoinAddresses ?? []).map(normalizeAddr);
186
+ const u = (pool.underlyingCoinAddresses ?? []).map(normalizeAddr);
187
+ const all = [.../* @__PURE__ */ new Set([...w, ...u])];
188
+ for (let i = 0; i < all.length; i++) {
189
+ for (let j = i + 1; j < all.length; j++) {
190
+ addEdge(adj, all[i], all[j]);
191
+ }
192
+ }
193
+ } catch {
194
+ }
195
+ }
196
+ return adj;
197
+ }
198
+ function addNativeWethBridge(adj, wrappedNative) {
199
+ if (!wrappedNative) return;
200
+ const w = wrappedNative.toLowerCase();
201
+ const a = ETH_PLACEHOLDER;
202
+ const b = w;
203
+ if (a === b) return;
204
+ if (!adj.has(a)) adj.set(a, /* @__PURE__ */ new Set());
205
+ if (!adj.has(b)) adj.set(b, /* @__PURE__ */ new Set());
206
+ adj.get(a).add(b);
207
+ adj.get(b).add(a);
208
+ }
209
+ function swappableCurveGraphNodeKeys(adj) {
210
+ const out = /* @__PURE__ */ new Set();
211
+ for (const [k, neigh] of adj) {
212
+ if (neigh.size > 0) out.add(k);
213
+ }
214
+ return out;
215
+ }
216
+
217
+ // src/protocols/evm/curve-dao/apiSession.ts
218
+ async function fetchAllCurvePools(curve) {
219
+ const run = (p) => p.catch(() => void 0);
220
+ await Promise.all([
221
+ run(curve.factory.fetchPools()),
222
+ run(curve.crvUSDFactory.fetchPools()),
223
+ run(curve.EYWAFactory.fetchPools()),
224
+ run(curve.cryptoFactory.fetchPools()),
225
+ run(curve.twocryptoFactory.fetchPools()),
226
+ run(curve.tricryptoFactory.fetchPools()),
227
+ run(curve.stableNgFactory.fetchPools())
228
+ ]);
229
+ }
230
+ async function loadFullCurveSessionForRpc(rpcUrl) {
231
+ const url = (rpcUrl ?? "").trim();
232
+ if (!url) return null;
233
+ try {
234
+ const { default: curve } = await import('@curvefi/api');
235
+ await curve.init("JsonRpc", { url }, {});
236
+ const wrapped = curve.getNetworkConstants().NATIVE_COIN?.wrappedAddress;
237
+ if (!curve.hasRouter || !curve.hasRouter()) {
238
+ return {
239
+ curve,
240
+ adj: /* @__PURE__ */ new Map(),
241
+ swappableNodeKeys: /* @__PURE__ */ new Set(),
242
+ wrappedNative: wrapped
243
+ };
244
+ }
245
+ await fetchAllCurvePools(curve);
246
+ const adj = buildCurveLiquidityGraphFromApi(curve);
247
+ addNativeWethBridge(adj, wrapped);
248
+ return {
249
+ curve,
250
+ adj,
251
+ swappableNodeKeys: swappableCurveGraphNodeKeys(adj),
252
+ wrappedNative: wrapped
253
+ };
254
+ } catch {
255
+ return null;
256
+ }
257
+ }
164
258
 
165
259
  // src/protocols/evm/curve-dao/index.ts
166
260
  var CURVE_DAO_PROTOCOL_ID = "curve-dao";
@@ -176,6 +270,19 @@ var curveDaoProtocolModule = {
176
270
  return token.kind === "native" || token.kind === "erc20";
177
271
  },
178
272
  actions: [
273
+ {
274
+ id: "curve-dao.quote",
275
+ protocolId: CURVE_DAO_PROTOCOL_ID,
276
+ chainCategory: "evm",
277
+ description: "Quote swap via Curve Router NG (getBestRouteAndOutput)",
278
+ commonParams: [],
279
+ params: {
280
+ chainId: { type: "number", required: true, description: "EVM chain id" },
281
+ tokenIn: { type: "address", required: true, description: "Token in or native placeholder" },
282
+ tokenOut: { type: "address", required: true, description: "Token out or native placeholder" },
283
+ amountHuman: { type: "string", required: true, description: "Human-readable input amount" }
284
+ }
285
+ },
179
286
  {
180
287
  id: "curve-dao.swap",
181
288
  protocolId: CURVE_DAO_PROTOCOL_ID,
@@ -250,7 +357,14 @@ var MULTISIGN_OUTPUT_DOC = {
250
357
  }
251
358
  };
252
359
  var MANAGEMENT_SIG_DOC = {
253
- 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.",
360
+ 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.",
361
+ exceptions: {
362
+ configUpdateImplement: "POST /configUpdateImplement: include nodeKey + plannedYaml + signedMessage (opaque configUpdateImplement|<sha256> line). Sign the opaque line bytes, not the JSON body.",
363
+ postMSQTTKey: "POST /postMSQTTKey: include nodeKey + caCertPem + clientSig. Sign caCertPem PEM bytes directly (use buildPostMqttKeyBody).",
364
+ addManagementKey: "POST /addManagementKey / removeManagementKey (EIP-191): may still use signedMessage equal to the canonical JSON string for dual-mode Ethereum signing.",
365
+ agentLlmConfig: "POST /agentLlmConfig / agentLlmApiKey: sign canonical JSON with action + clientSig cleared; POST body has nonce, clientSig, nodeKey, endpoint fields \u2014 no signedMessage field.",
366
+ multiSignRequest: "POST /multiSignRequest (client key, not management): POST { ...bodyForSign, clientSig, signedMessage: messageToSign }."
367
+ },
254
368
  fields: {
255
369
  nonce: {
256
370
  type: "number",
@@ -268,10 +382,15 @@ var MANAGEMENT_SIG_DOC = {
268
382
  helpers: {
269
383
  managementSigFields: "Base envelope with clientSig cleared.",
270
384
  buildManagementPostBody: "Spread managementSigFields then endpoint fields.",
385
+ buildPostMqttKeyBody: "POST /postMSQTTKey unsigned body (sign PEM directly).",
386
+ buildPostPreferredKeyGenBody: "POST /postPreferredKeyGen unsigned body.",
387
+ buildConfigUpdateImplementPostBody: "POST /configUpdateImplement with opaque signedMessage line.",
388
+ buildSignRequestAgreeUnsignedBody: "POST /signRequestAgree unsigned body with nodeKey.",
271
389
  messageToSignManagementBody: "Canonical JSON string to sign.",
272
390
  withManagementClientSig: "Attach signature to POST body.",
273
391
  fetchNodeKey: "GET /getNodeKey via nodeFetchWithReadAuth.",
274
- fetchManagementNonce: "GET nonce for Ed25519 or Ethereum management key."
392
+ fetchManagementNonce: "GET nonce for Ed25519 or Ethereum management key.",
393
+ fetchPreferredKeyGen: "GET /getPreferredKeyGen for agent default KeyGen."
275
394
  }
276
395
  };
277
396
  function zodSchemaToMcpJsonSchema(schema) {
@@ -384,6 +503,17 @@ var mcpUniswapV4BuildSwapMultisignInputSchema = evmMultisignCommonInputSchema.ex
384
503
  swapDeadlineUnix: zod.z.number().describe("Same deadline passed to create_swap"),
385
504
  slippagePercent: zod.z.number().optional().describe("Extra approve headroom for EXACT_OUTPUT")
386
505
  });
506
+ var mcpCurveDaoQuoteInputSchema = zod.z.object({
507
+ chainId: zod.z.number().int().positive().describe("EVM chain id (rpcUrl resolved from get_chain_registry rpcGateway)"),
508
+ 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"),
509
+ tokenIn: zod.z.string().min(1).describe("Input token address, or 0xeeee\u2026 / 0x0 / eth for native"),
510
+ tokenOut: zod.z.string().min(1).describe("Output token address or 0xeeee\u2026 native placeholder"),
511
+ amountHuman: zod.z.string().min(1).describe("Human-readable amount of tokenIn"),
512
+ tokenInDecimals: zod.z.number().int().min(0).max(18).optional().describe("Token-in decimals; omit to read on-chain (native uses 18)")
513
+ });
514
+ var mcpCurveDaoQuoteOutputSchema = jsonObjectSchema.describe(
515
+ "Curve router quote: { inputAmount, output, route, priceImpactPercent?, tokenInRouterId, tokenOutRouterId }"
516
+ );
387
517
  var mcpCurveDaoBuildSwapMultisignInputSchema = evmMultisignCommonInputSchema.extend({
388
518
  tokenIn: evmAddressSchema.describe("ERC-20 sold (native in uses WETH path in UI)"),
389
519
  tokenOut: zod.z.string().min(1).describe("Output token or 0xeeee\u2026 native placeholder"),
@@ -799,7 +929,7 @@ var MCP_PROTOCOL_TOOL_DEFINITIONS = [
799
929
  description: "Build Euler v2 vault withdraw/redeem batch.",
800
930
  prerequisites: ["keyGen", "executorAddress", "vault address"],
801
931
  followUp: ["Sign messageToSign", "POST /multiSignRequest"],
802
- handler: { importPath: "protocols/evm/euler-v2", exportName: "buildEvmMultisignBodyEulerV2VaultWithdrawBatch" },
932
+ handler: { importPath: "protocols/evm/euler-v2", exportName: "buildEvmMultisignBodyEulerV2VaultWithdraw" },
803
933
  inputZod: mcpEulerV2VaultWithdrawInputSchema
804
934
  }),
805
935
  defineProtocolMcpTool({
@@ -889,13 +1019,32 @@ var CORE_MCP_TOOL_DEFINITIONS = [
889
1019
  inputZod: mcpUniswapV4BuildSwapMultisignInputSchema,
890
1020
  outputZod: multisignOutputSchema
891
1021
  }),
1022
+ defineMcpTool({
1023
+ name: "ctm_curve_dao_quote",
1024
+ actionId: "curve-dao.quote",
1025
+ protocolId: "curve-dao",
1026
+ chainCategory: "evm",
1027
+ description: "Fetch a Curve Router NG quote via @curvefi/api getBestRouteAndOutput. Returns output amount, route, and optional priceImpactPercent. Does NOT create a sign request \u2014 call ctm_curve_dao_build_swap_multisign after quoting. Pass chainId only; rpcUrl is resolved from get_chain_registry rpcGateway.",
1028
+ prerequisites: [
1029
+ "Chain must be supported by Curve (@curvefi/api network constants).",
1030
+ "Configure rpcGateway for chainId in get_chain_registry."
1031
+ ],
1032
+ followUp: ["ctm_curve_dao_build_swap_multisign"],
1033
+ handler: { importPath: "protocols/evm/curve-dao", exportName: "curveDaoQuote" },
1034
+ inputZod: mcpCurveDaoQuoteInputSchema,
1035
+ outputZod: mcpCurveDaoQuoteOutputSchema
1036
+ }),
892
1037
  defineMcpTool({
893
1038
  name: "ctm_curve_dao_build_swap_multisign",
894
1039
  actionId: "curve-dao.swap",
895
1040
  protocolId: "curve-dao",
896
1041
  chainCategory: "evm",
897
1042
  description: "Build mpc-auth multiSignRequest for a Curve Router NG swap via @curvefi/api populateSwap. Optionally batches ERC-20 approve txs when allowance is insufficient, then exchange. Requires JSON-RPC and Curve-supported chain.",
898
- prerequisites: ["keyGen", "executorAddress", "tokenIn/tokenOut/amountHuman/slippage", "RPC URL"],
1043
+ prerequisites: [
1044
+ "ctm_curve_dao_quote (recommended) or known-good route",
1045
+ "keyGenId + chainId + purposeText",
1046
+ "tokenIn/tokenOut/amountHuman/slippagePercent"
1047
+ ],
899
1048
  followUp: ["Sign messageToSign", "POST /multiSignRequest with clientSig and signedMessage"],
900
1049
  handler: { importPath: "protocols/evm/curve-dao", exportName: "buildEvmMultisignBodyCurveDaoBatch" },
901
1050
  inputZod: mcpCurveDaoBuildSwapMultisignInputSchema,
@@ -960,7 +1109,13 @@ function getAgentCatalogForMcp() {
960
1109
  "2. GET /getPublicMgtKeyNonce or /getNodeMgtKeyNonce \u2192 nonce",
961
1110
  "3. buildManagementPostBody(nonce, nodeKey, { \u2026endpoint fields })",
962
1111
  "4. messageToSignManagementBody(body) \u2192 sign \u2192 withManagementClientSig(body, sig)",
963
- "5. POST management route with signed body"
1112
+ "5. POST management route with signed body (no signedMessage field except configUpdateImplement opaque line)"
1113
+ ],
1114
+ agentMultisignTypical: [
1115
+ "1. load_defi_protocol for the target protocol",
1116
+ "2. get_defi_protocol_supported_chains / get_token_registry to pick chainId and tokens",
1117
+ "3. MCP build_* tool with keyGenId + chainId \u2192 { requestId }",
1118
+ "4. Base MCP: wait_for_sign_request_ready \u2192 sign_request_agree \u2192 trigger_sign_result \u2192 broadcast_sign_result"
964
1119
  ]
965
1120
  }
966
1121
  };
@@ -996,6 +1151,7 @@ var lidoProtocolModule = {
996
1151
  };
997
1152
  registerProtocolModule(lidoProtocolModule);
998
1153
  var USDE_ETHEREUM_MAINNET = "0x4c9edd5852cd905f086c759e8383e09bff1e68b3";
1154
+ var SUSDE_ETHEREUM_MAINNET = "0x9d39a5de30e57443bff2a8307a4256c8797a3497";
999
1155
  var USDE_MOST_L2S = "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34";
1000
1156
  var USDE_ZKSYNC_ERA = "0x39Fe7a0DACcE31Bd90418e3e659fb0b5f0B3Db0d";
1001
1157
  var L2_SAME_ADDRESS_CHAIN_IDS = /* @__PURE__ */ new Set([
@@ -1036,12 +1192,53 @@ var L2_SAME_ADDRESS_CHAIN_IDS = /* @__PURE__ */ new Set([
1036
1192
  48900
1037
1193
  // Zircuit
1038
1194
  ]);
1195
+ var FALLBACK_NAME_BY_ID = {
1196
+ 1: "Ethereum",
1197
+ 42161: "Arbitrum One",
1198
+ 10: "Optimism",
1199
+ 8453: "Base",
1200
+ 56: "BNB Chain",
1201
+ 59144: "Linea",
1202
+ 5e3: "Mantle",
1203
+ 81457: "Blast",
1204
+ 169: "Manta Pacific",
1205
+ 534352: "Scroll",
1206
+ 252: "Fraxtal",
1207
+ 34443: "Mode",
1208
+ 196: "X Layer",
1209
+ 1088: "Metis",
1210
+ 80084: "Berachain",
1211
+ 2222: "Kava",
1212
+ 2818: "Morph",
1213
+ 1923: "Swell",
1214
+ 48900: "Zircuit",
1215
+ 324: "ZKSync Era"
1216
+ };
1039
1217
  function usdeTokenAddressOnEvmChain(chainId) {
1040
1218
  if (chainId === 1) return USDE_ETHEREUM_MAINNET;
1041
1219
  if (chainId === 324) return USDE_ZKSYNC_ERA;
1042
1220
  if (L2_SAME_ADDRESS_CHAIN_IDS.has(chainId)) return USDE_MOST_L2S;
1043
1221
  return null;
1044
1222
  }
1223
+ function listEthenaUsdeEvmNetworkRows() {
1224
+ const rows = [
1225
+ { chainId: 1, label: FALLBACK_NAME_BY_ID[1], usde: USDE_ETHEREUM_MAINNET }
1226
+ ];
1227
+ const l2 = [...L2_SAME_ADDRESS_CHAIN_IDS].sort((a, b) => a - b);
1228
+ for (const id of l2) {
1229
+ rows.push({
1230
+ chainId: id,
1231
+ label: FALLBACK_NAME_BY_ID[id] ?? `Chain ${id}`,
1232
+ usde: USDE_MOST_L2S
1233
+ });
1234
+ }
1235
+ rows.push({ chainId: 324, label: FALLBACK_NAME_BY_ID[324], usde: USDE_ZKSYNC_ERA });
1236
+ return rows.sort((a, b) => {
1237
+ if (a.chainId === 1) return -1;
1238
+ if (b.chainId === 1) return 1;
1239
+ return a.chainId - b.chainId;
1240
+ });
1241
+ }
1045
1242
  function isEvmChainInEthenaUsdeList(chainId) {
1046
1243
  return usdeTokenAddressOnEvmChain(chainId) != null;
1047
1244
  }
@@ -1072,6 +1269,18 @@ registerProtocolModule(ethenaProtocolModule);
1072
1269
  function isMapleSyrupSupportedChain(chainId) {
1073
1270
  return chainId === 1 || chainId === 11155111;
1074
1271
  }
1272
+ async function postJsonViaOptionalProxy(args) {
1273
+ const r = await fetch(args.directUrl, {
1274
+ method: "POST",
1275
+ headers: { "content-type": "application/json" },
1276
+ body: JSON.stringify(args.body)
1277
+ });
1278
+ if (!r.ok) {
1279
+ const t = await r.text().catch(() => "");
1280
+ throw new Error(t ? `HTTP ${r.status}: ${t.slice(0, 200)}` : `HTTP ${r.status}`);
1281
+ }
1282
+ return await r.json();
1283
+ }
1075
1284
 
1076
1285
  // src/protocols/evm/maple/index.ts
1077
1286
  var MAPLE_PROTOCOL_ID = "maple-syrup";
@@ -1118,6 +1327,77 @@ var skyProtocolModule = {
1118
1327
  ]
1119
1328
  };
1120
1329
  registerProtocolModule(skyProtocolModule);
1330
+ var AAVE_V4_GRAPHQL_URL = "https://api.v4.aave.com/graphql";
1331
+ async function aaveV4Gql(query, variables) {
1332
+ const body = { query, variables: variables ?? {} };
1333
+ const j = await postJsonViaOptionalProxy({
1334
+ directUrl: AAVE_V4_GRAPHQL_URL,
1335
+ body});
1336
+ if (j.errors?.length) {
1337
+ const msg = j.errors.map((e) => e.message ?? "Unknown").join("; ");
1338
+ throw new Error(msg);
1339
+ }
1340
+ if (j.data == null) {
1341
+ throw new Error("Aave V4 API: empty response");
1342
+ }
1343
+ return j.data;
1344
+ }
1345
+ async function fetchAaveV4Chains() {
1346
+ const d = await aaveV4Gql(`
1347
+ query C($c: ChainsRequest!) { chains(request: $c) { chainId name nativeWrappedToken } }
1348
+ `, { c: { query: { filter: "ALL" } } });
1349
+ return d.chains ?? [];
1350
+ }
1351
+ async function loadAaveV4SupportedChainIdsFromV4Api() {
1352
+ const rows = await fetchAaveV4Chains();
1353
+ const s = /* @__PURE__ */ new Set();
1354
+ for (const c of rows) s.add(c.chainId);
1355
+ return s;
1356
+ }
1357
+ var RESERVES_ADDRESS_FRAGMENT = `
1358
+ asset { underlying { address } }
1359
+ `;
1360
+ async function fetchAaveV4NativeWrappedToken(chainId) {
1361
+ const all = await fetchAaveV4Chains();
1362
+ const c = all.find((x) => x.chainId === chainId);
1363
+ const t = (c?.nativeWrappedToken ?? "").trim();
1364
+ if (t && viem.isAddress(t)) return viem.getAddress(t);
1365
+ return null;
1366
+ }
1367
+ async function fetchAaveV4SupportedUnderlyingAddressSet(chainId) {
1368
+ const d = await aaveV4Gql(
1369
+ `
1370
+ query A($r: ReservesRequest!) { reserves(request: $r) { ${RESERVES_ADDRESS_FRAGMENT} } }
1371
+ `,
1372
+ {
1373
+ r: {
1374
+ query: { chainIds: [chainId] },
1375
+ filter: "ALL",
1376
+ orderBy: { supplyApy: "DESC" }
1377
+ }
1378
+ }
1379
+ );
1380
+ const s = /* @__PURE__ */ new Set();
1381
+ for (const r of d.reserves ?? []) {
1382
+ const a = (r.asset?.underlying?.address ?? "").trim();
1383
+ if (a && viem.isAddress(a)) s.add(a.toLowerCase());
1384
+ }
1385
+ return s;
1386
+ }
1387
+ var aaveV4ChainTokenCache = /* @__PURE__ */ new Map();
1388
+ function ensureAaveV4ChainTokenCache(chainId) {
1389
+ const hit = aaveV4ChainTokenCache.get(chainId);
1390
+ if (hit) return hit;
1391
+ const p = (async () => {
1392
+ const [nativeWrapped, supportedUnderlying] = await Promise.all([
1393
+ fetchAaveV4NativeWrappedToken(chainId),
1394
+ fetchAaveV4SupportedUnderlyingAddressSet(chainId)
1395
+ ]);
1396
+ return { supportedUnderlying, nativeWrapped };
1397
+ })();
1398
+ aaveV4ChainTokenCache.set(chainId, p);
1399
+ return p;
1400
+ }
1121
1401
 
1122
1402
  // src/protocols/evm/aave-v4/index.ts
1123
1403
  var AAVE_V4_PROTOCOL_ID = "aave-v4";
@@ -1160,6 +1440,271 @@ var eulerV2ProtocolModule = {
1160
1440
  ]
1161
1441
  };
1162
1442
  registerProtocolModule(eulerV2ProtocolModule);
1443
+ var skillsDir = path.join(path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('catalog.cjs', document.baseURI).href)))), "skills");
1444
+ var SKILL_PROTOCOL_IDS = [
1445
+ "aave-v4",
1446
+ "lido",
1447
+ "uniswap-v4",
1448
+ "curve-dao",
1449
+ "ethena",
1450
+ "euler-v2",
1451
+ "maple-syrup",
1452
+ "sky"
1453
+ ];
1454
+ function getToolsForProtocol(protocolId) {
1455
+ return MCP_TOOL_DEFINITIONS.filter((t) => t.protocolId === protocolId);
1456
+ }
1457
+ function getProtocolSkill(protocolId) {
1458
+ if (!SKILL_PROTOCOL_IDS.includes(protocolId)) {
1459
+ return void 0;
1460
+ }
1461
+ try {
1462
+ return fs.readFileSync(path.join(skillsDir, protocolId, "SKILL.md"), "utf8");
1463
+ } catch {
1464
+ return void 0;
1465
+ }
1466
+ }
1467
+ function listProtocolsWithSkills() {
1468
+ return [...SKILL_PROTOCOL_IDS];
1469
+ }
1470
+ function getProtocolDiscoverySummary(protocolId) {
1471
+ const mod = getProtocolModules().find((p) => p.id === protocolId);
1472
+ if (!mod) return void 0;
1473
+ return {
1474
+ protocolId: mod.id,
1475
+ chainCategory: mod.chainCategory,
1476
+ actions: mod.actions.map((a) => ({ id: a.id, description: a.description })),
1477
+ tools: getToolsForProtocol(protocolId).map((t) => ({
1478
+ name: t.name,
1479
+ actionId: t.actionId,
1480
+ description: t.description,
1481
+ prerequisites: t.prerequisites,
1482
+ followUp: t.followUp
1483
+ }))
1484
+ };
1485
+ }
1486
+ var EULER_V2_SUBGRAPH_CHAIN_IDS = [
1487
+ 1,
1488
+ 8453,
1489
+ 42161,
1490
+ 10,
1491
+ 137,
1492
+ 56,
1493
+ 43114,
1494
+ 100,
1495
+ 59144,
1496
+ 146,
1497
+ 1923,
1498
+ 130
1499
+ ];
1500
+ function advisor(protocolId, tokenFilter, impl) {
1501
+ return { protocolId, tokenFilter, ...impl };
1502
+ }
1503
+ var PROTOCOL_SUPPORT_ADVISORS = {
1504
+ "aave-v4": advisor("aave-v4", "api_underlyings", {
1505
+ async supportedChainIds() {
1506
+ const set = await loadAaveV4SupportedChainIdsFromV4Api();
1507
+ return [...set].sort((a, b) => a - b);
1508
+ },
1509
+ async supportedTokens(chainId) {
1510
+ const cache = await ensureAaveV4ChainTokenCache(chainId);
1511
+ const tokens = [...cache.supportedUnderlying].map((address) => ({
1512
+ address,
1513
+ roles: ["underlying"]
1514
+ }));
1515
+ if (cache.nativeWrapped) {
1516
+ tokens.unshift({
1517
+ address: cache.nativeWrapped,
1518
+ symbol: "WETH",
1519
+ roles: ["native_wrapped"]
1520
+ });
1521
+ }
1522
+ return {
1523
+ tokens,
1524
+ nativeWrapped: cache.nativeWrapped ?? void 0,
1525
+ notes: "Native ETH deposits use wrapped native token address from Aave v4 API."
1526
+ };
1527
+ },
1528
+ async isTokenSupported(chainId, address) {
1529
+ const cache = await ensureAaveV4ChainTokenCache(chainId);
1530
+ let normalized;
1531
+ try {
1532
+ normalized = viem.getAddress(address).toLowerCase();
1533
+ } catch {
1534
+ return false;
1535
+ }
1536
+ if (cache.nativeWrapped && viem.getAddress(cache.nativeWrapped).toLowerCase() === normalized) {
1537
+ return true;
1538
+ }
1539
+ return cache.supportedUnderlying.has(normalized);
1540
+ }
1541
+ }),
1542
+ "uniswap-v4": advisor("uniswap-v4", "any_erc20_on_chain", {
1543
+ async supportedChainIds() {
1544
+ const ids = [];
1545
+ for (const id of [
1546
+ 1,
1547
+ 5,
1548
+ 11155111,
1549
+ 137,
1550
+ 80001,
1551
+ 10,
1552
+ 420,
1553
+ 42161,
1554
+ 421613,
1555
+ 42220,
1556
+ 44787,
1557
+ 56,
1558
+ 43114,
1559
+ 84531,
1560
+ 8453,
1561
+ 81457,
1562
+ 7777777,
1563
+ 324,
1564
+ 480,
1565
+ 1301,
1566
+ 130,
1567
+ 10143,
1568
+ 84532,
1569
+ 1868,
1570
+ 143,
1571
+ 59144,
1572
+ 4217,
1573
+ 196
1574
+ ]) {
1575
+ if (isUniswapV4ChainSupported(id)) ids.push(id);
1576
+ }
1577
+ return ids;
1578
+ },
1579
+ async supportedTokens() {
1580
+ return {
1581
+ tokens: [],
1582
+ 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."
1583
+ };
1584
+ }
1585
+ }),
1586
+ "curve-dao": advisor("curve-dao", "pool_graph", {
1587
+ async supportedChainIds() {
1588
+ return [1, 10, 56, 100, 137, 146, 196, 250, 252, 324, 999, 1284, 2222, 5e3, 8453, 42161, 42220, 43114, 1313161554];
1589
+ },
1590
+ async supportedTokens(chainId, ctx) {
1591
+ if (!isCurveApiChainSupported(chainId)) {
1592
+ return { tokens: [], notes: "Chain not supported by Curve SDK network constants." };
1593
+ }
1594
+ const rpcUrl = ctx?.rpcUrl?.trim();
1595
+ if (!rpcUrl) {
1596
+ return {
1597
+ tokens: [],
1598
+ notes: "Provide rpcUrl (from get_chain_registry) to load Curve pool graph token list."
1599
+ };
1600
+ }
1601
+ const session = await loadFullCurveSessionForRpc(rpcUrl);
1602
+ if (!session?.swappableNodeKeys?.size) {
1603
+ return { tokens: [], notes: "Curve session returned no swappable tokens for this RPC." };
1604
+ }
1605
+ return {
1606
+ tokens: [...session.swappableNodeKeys].map((key) => {
1607
+ const address = key.startsWith("0x") ? key : key.split(":")[0] ?? key;
1608
+ return { address, roles: ["swappable"] };
1609
+ })
1610
+ };
1611
+ }
1612
+ }),
1613
+ lido: advisor("lido", "mainnet_only", {
1614
+ async supportedChainIds() {
1615
+ return [LIDO_ETHEREUM_MAINNET_CHAIN_ID];
1616
+ },
1617
+ async supportedTokens() {
1618
+ return {
1619
+ tokens: [
1620
+ { address: "0x0000000000000000000000000000000000000000", symbol: "ETH", roles: ["native", "stake"] },
1621
+ { address: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84", symbol: "stETH", roles: ["erc20"] },
1622
+ { address: "0x7f39C581F595B853cBbF37C12FfeeA971C5a5bEa", symbol: "wstETH", roles: ["erc20"] }
1623
+ ],
1624
+ notes: "Lido staking and withdrawals are Ethereum mainnet only."
1625
+ };
1626
+ }
1627
+ }),
1628
+ ethena: advisor("ethena", "minting_contract", {
1629
+ async supportedChainIds() {
1630
+ return listEthenaUsdeEvmNetworkRows().map((r) => r.chainId);
1631
+ },
1632
+ async supportedTokens(chainId) {
1633
+ if (chainId === 1) {
1634
+ return {
1635
+ tokens: [
1636
+ { address: USDE_ETHEREUM_MAINNET, symbol: "USDe", roles: ["stake"] },
1637
+ { address: SUSDE_ETHEREUM_MAINNET, symbol: "sUSDe", roles: ["vault"] }
1638
+ ],
1639
+ notes: "Ethena stake/redeem UI actions are mainnet-only; USDe exists on other chains for transfers."
1640
+ };
1641
+ }
1642
+ if (isEvmChainInEthenaUsdeList(chainId)) {
1643
+ const row = listEthenaUsdeEvmNetworkRows().find((r) => r.chainId === chainId);
1644
+ return {
1645
+ tokens: row ? [{ address: row.usde, symbol: "USDe", roles: ["erc20"] }] : [],
1646
+ notes: "USDe on L2; staking MCP tools target mainnet only."
1647
+ };
1648
+ }
1649
+ return { tokens: [] };
1650
+ }
1651
+ }),
1652
+ "euler-v2": advisor("euler-v2", "subgraph_vaults", {
1653
+ async supportedChainIds() {
1654
+ return [...EULER_V2_SUBGRAPH_CHAIN_IDS];
1655
+ },
1656
+ async supportedTokens() {
1657
+ return {
1658
+ tokens: [],
1659
+ notes: "Euler vault/collateral assets vary by chain. Pass vault and asset addresses from Euler app or subgraph."
1660
+ };
1661
+ }
1662
+ }),
1663
+ [MAPLE_PROTOCOL_ID]: advisor(MAPLE_PROTOCOL_ID, "fixed_addresses", {
1664
+ async supportedChainIds() {
1665
+ return [1, 11155111];
1666
+ },
1667
+ async supportedTokens() {
1668
+ return {
1669
+ tokens: [],
1670
+ notes: "Maple Syrup pools are discovered via GraphQL; pass syrupRouter, pool, and asset from Maple UI."
1671
+ };
1672
+ }
1673
+ }),
1674
+ [SKY_PROTOCOL_ID]: advisor(SKY_PROTOCOL_ID, "fixed_addresses", {
1675
+ async supportedChainIds() {
1676
+ return [1];
1677
+ },
1678
+ async supportedTokens() {
1679
+ return {
1680
+ tokens: [],
1681
+ notes: "Sky Lockstake and sUSDS use fixed mainnet contract addresses in protocol builders."
1682
+ };
1683
+ }
1684
+ })
1685
+ };
1686
+ function getProtocolSupportAdvisor(protocolId) {
1687
+ return PROTOCOL_SUPPORT_ADVISORS[protocolId];
1688
+ }
1689
+ function listProtocolSupportAdvisorIds() {
1690
+ return Object.keys(PROTOCOL_SUPPORT_ADVISORS);
1691
+ }
1692
+ var mcpServerCommonInputSchema = zod.z.object({
1693
+ keyGenId: zod.z.string().min(1).describe("KeyGen id from fetch_key_gen_result / node preferred KeyGen"),
1694
+ chainId: zod.z.number().int().positive().describe("EVM chain id; RPC and gas config resolved from chain registry"),
1695
+ purposeText: zod.z.string().min(1).describe("Human-readable purpose for the sign request"),
1696
+ useCustomGas: zod.z.boolean().optional().describe("Apply chain gas settings from registry when true")
1697
+ });
1698
+ function mcpServerMultisignInput(fields) {
1699
+ return mcpServerCommonInputSchema.extend(fields);
1700
+ }
1701
+ var mcpServerSubmitOutputSchema = zod.z.object({
1702
+ requestId: zod.z.string().min(1)
1703
+ }).describe("mpc-auth multiSignRequest id; continue with trigger_sign_result / broadcast_sign_result");
1704
+ var MCP_NON_SUBMIT_TOOL_NAMES = /* @__PURE__ */ new Set([
1705
+ "ctm_uniswap_v4_quote",
1706
+ "ctm_uniswap_v4_create_swap"
1707
+ ]);
1163
1708
 
1164
1709
  // src/agent/catalog.ts
1165
1710
  registerProtocolModule(uniswapV4ProtocolModule);
@@ -1193,10 +1738,12 @@ function getAgentCatalog() {
1193
1738
 
1194
1739
  exports.EVM_COMMON_PARAM_DOCS = EVM_COMMON_PARAM_DOCS;
1195
1740
  exports.MANAGEMENT_SIG_DOC = MANAGEMENT_SIG_DOC;
1741
+ exports.MCP_NON_SUBMIT_TOOL_NAMES = MCP_NON_SUBMIT_TOOL_NAMES;
1196
1742
  exports.MCP_TOOL_DEFINITIONS = MCP_TOOL_DEFINITIONS;
1197
1743
  exports.MCP_TOOL_INPUT_SCHEMAS = MCP_TOOL_INPUT_SCHEMAS;
1198
1744
  exports.MCP_TOOL_OUTPUT_SCHEMAS = MCP_TOOL_OUTPUT_SCHEMAS;
1199
1745
  exports.MULTISIGN_OUTPUT_DOC = MULTISIGN_OUTPUT_DOC;
1746
+ exports.PROTOCOL_SUPPORT_ADVISORS = PROTOCOL_SUPPORT_ADVISORS;
1200
1747
  exports.chainDetailSchema = chainDetailSchema;
1201
1748
  exports.evmAddressSchema = evmAddressSchema;
1202
1749
  exports.evmMultisignCommonInputSchema = evmMultisignCommonInputSchema;
@@ -1207,14 +1754,22 @@ exports.getMcpToolByName = getMcpToolByName;
1207
1754
  exports.getMcpToolDefinitions = getMcpToolDefinitions;
1208
1755
  exports.getMcpToolInputSchema = getMcpToolInputSchema;
1209
1756
  exports.getMcpToolOutputSchema = getMcpToolOutputSchema;
1757
+ exports.getProtocolDiscoverySummary = getProtocolDiscoverySummary;
1210
1758
  exports.getProtocolModules = getProtocolModules;
1759
+ exports.getProtocolSkill = getProtocolSkill;
1760
+ exports.getProtocolSupportAdvisor = getProtocolSupportAdvisor;
1761
+ exports.getToolsForProtocol = getToolsForProtocol;
1211
1762
  exports.jsonObjectSchema = jsonObjectSchema;
1212
1763
  exports.keyGenSchema = keyGenSchema;
1764
+ exports.listProtocolSupportAdvisorIds = listProtocolSupportAdvisorIds;
1765
+ exports.listProtocolsWithSkills = listProtocolsWithSkills;
1213
1766
  exports.mcpAaveV4BorrowInputSchema = mcpAaveV4BorrowInputSchema;
1214
1767
  exports.mcpAaveV4DepositInputSchema = mcpAaveV4DepositInputSchema;
1215
1768
  exports.mcpAaveV4RepayInputSchema = mcpAaveV4RepayInputSchema;
1216
1769
  exports.mcpAaveV4WithdrawInputSchema = mcpAaveV4WithdrawInputSchema;
1217
1770
  exports.mcpCurveDaoBuildSwapMultisignInputSchema = mcpCurveDaoBuildSwapMultisignInputSchema;
1771
+ exports.mcpCurveDaoQuoteInputSchema = mcpCurveDaoQuoteInputSchema;
1772
+ exports.mcpCurveDaoQuoteOutputSchema = mcpCurveDaoQuoteOutputSchema;
1218
1773
  exports.mcpEthenaClaimInputSchema = mcpEthenaClaimInputSchema;
1219
1774
  exports.mcpEthenaCooldownInputSchema = mcpEthenaCooldownInputSchema;
1220
1775
  exports.mcpEthenaRedeemInputSchema = mcpEthenaRedeemInputSchema;
@@ -1234,6 +1789,9 @@ exports.mcpMapleDepositInputSchema = mcpMapleDepositInputSchema;
1234
1789
  exports.mcpMapleRequestRedeemInputSchema = mcpMapleRequestRedeemInputSchema;
1235
1790
  exports.mcpMultisignInput = mcpMultisignInput;
1236
1791
  exports.mcpMultisignOutputSchema = multisignOutputSchema;
1792
+ exports.mcpServerCommonInputSchema = mcpServerCommonInputSchema;
1793
+ exports.mcpServerMultisignInput = mcpServerMultisignInput;
1794
+ exports.mcpServerSubmitOutputSchema = mcpServerSubmitOutputSchema;
1237
1795
  exports.mcpSkyLockstakeCloseInputSchema = mcpSkyLockstakeCloseInputSchema;
1238
1796
  exports.mcpSkyLockstakeDrawInputSchema = mcpSkyLockstakeDrawInputSchema;
1239
1797
  exports.mcpSkyLockstakeGetRewardInputSchema = mcpSkyLockstakeGetRewardInputSchema;