@continuumdao/ctm-mpc-defi 0.1.3 → 0.2.0

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 (68) hide show
  1. package/README.md +16 -1
  2. package/dist/agent/catalog.cjs +913 -142
  3. package/dist/agent/catalog.cjs.map +1 -1
  4. package/dist/agent/catalog.d.cts +834 -12
  5. package/dist/agent/catalog.d.ts +834 -12
  6. package/dist/agent/catalog.js +863 -143
  7. package/dist/agent/catalog.js.map +1 -1
  8. package/dist/chains/evm/index.cjs +13 -0
  9. package/dist/chains/evm/index.cjs.map +1 -1
  10. package/dist/chains/evm/index.d.cts +3 -1
  11. package/dist/chains/evm/index.d.ts +3 -1
  12. package/dist/chains/evm/index.js +13 -1
  13. package/dist/chains/evm/index.js.map +1 -1
  14. package/dist/core/index.cjs +76 -0
  15. package/dist/core/index.cjs.map +1 -1
  16. package/dist/core/index.d.cts +35 -2
  17. package/dist/core/index.d.ts +35 -2
  18. package/dist/core/index.js +70 -1
  19. package/dist/core/index.js.map +1 -1
  20. package/dist/index.cjs +934 -141
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +3 -2
  23. package/dist/index.d.ts +3 -2
  24. package/dist/index.js +927 -142
  25. package/dist/index.js.map +1 -1
  26. package/dist/protocols/evm/aave-v4/index.cjs +1987 -0
  27. package/dist/protocols/evm/aave-v4/index.cjs.map +1 -0
  28. package/dist/protocols/evm/aave-v4/index.d.cts +500 -0
  29. package/dist/protocols/evm/aave-v4/index.d.ts +500 -0
  30. package/dist/protocols/evm/aave-v4/index.js +1943 -0
  31. package/dist/protocols/evm/aave-v4/index.js.map +1 -0
  32. package/dist/protocols/evm/ethena/index.cjs +965 -0
  33. package/dist/protocols/evm/ethena/index.cjs.map +1 -0
  34. package/dist/protocols/evm/ethena/index.d.cts +161 -0
  35. package/dist/protocols/evm/ethena/index.d.ts +161 -0
  36. package/dist/protocols/evm/ethena/index.js +943 -0
  37. package/dist/protocols/evm/ethena/index.js.map +1 -0
  38. package/dist/protocols/evm/euler-v2/index.cjs +2263 -0
  39. package/dist/protocols/evm/euler-v2/index.cjs.map +1 -0
  40. package/dist/protocols/evm/euler-v2/index.d.cts +317 -0
  41. package/dist/protocols/evm/euler-v2/index.d.ts +317 -0
  42. package/dist/protocols/evm/euler-v2/index.js +2238 -0
  43. package/dist/protocols/evm/euler-v2/index.js.map +1 -0
  44. package/dist/protocols/evm/lido/index.cjs +834 -0
  45. package/dist/protocols/evm/lido/index.cjs.map +1 -0
  46. package/dist/protocols/evm/lido/index.d.cts +120 -0
  47. package/dist/protocols/evm/lido/index.d.ts +120 -0
  48. package/dist/protocols/evm/lido/index.js +809 -0
  49. package/dist/protocols/evm/lido/index.js.map +1 -0
  50. package/dist/protocols/evm/maple/index.cjs +707 -0
  51. package/dist/protocols/evm/maple/index.cjs.map +1 -0
  52. package/dist/protocols/evm/maple/index.d.cts +109 -0
  53. package/dist/protocols/evm/maple/index.d.ts +109 -0
  54. package/dist/protocols/evm/maple/index.js +693 -0
  55. package/dist/protocols/evm/maple/index.js.map +1 -0
  56. package/dist/protocols/evm/sky/index.cjs +1254 -0
  57. package/dist/protocols/evm/sky/index.cjs.map +1 -0
  58. package/dist/protocols/evm/sky/index.d.cts +218 -0
  59. package/dist/protocols/evm/sky/index.d.ts +218 -0
  60. package/dist/protocols/evm/sky/index.js +1229 -0
  61. package/dist/protocols/evm/sky/index.js.map +1 -0
  62. package/dist/protocols/evm/uniswap-v4/index.cjs +31 -11
  63. package/dist/protocols/evm/uniswap-v4/index.cjs.map +1 -1
  64. package/dist/protocols/evm/uniswap-v4/index.d.cts +2 -1
  65. package/dist/protocols/evm/uniswap-v4/index.d.ts +2 -1
  66. package/dist/protocols/evm/uniswap-v4/index.js +31 -11
  67. package/dist/protocols/evm/uniswap-v4/index.js.map +1 -1
  68. package/package.json +37 -3
@@ -1,4 +1,6 @@
1
- import 'viem';
1
+ import { getAddress } from 'viem';
2
+ import { zodToJsonSchema } from 'zod-to-json-schema';
3
+ import { z } from 'zod';
2
4
 
3
5
  // src/core/registry.ts
4
6
  var modules = [];
@@ -245,46 +247,606 @@ var MULTISIGN_OUTPUT_DOC = {
245
247
  }
246
248
  }
247
249
  };
248
-
249
- // src/agent/mcpTools.ts
250
- function paramProperties(params, includeCommon = []) {
251
- const out = {};
252
- for (const k of includeCommon) {
253
- const d = EVM_COMMON_PARAM_DOCS[k];
254
- if (d) out[k] = { type: d.type, description: d.description };
255
- }
256
- for (const [k, d] of Object.entries(params)) {
257
- out[k] = { type: d.type, description: d.description };
258
- }
259
- return out;
260
- }
261
- function requiredKeys(params, includeCommon = []) {
262
- const req = [];
263
- for (const k of includeCommon) {
264
- if (EVM_COMMON_PARAM_DOCS[k]?.required) req.push(k);
265
- }
266
- for (const [k, d] of Object.entries(params)) {
267
- if (d.required) req.push(k);
268
- }
269
- return req;
270
- }
271
- var multisignOutputSchema = {
272
- type: "object",
273
- description: MULTISIGN_OUTPUT_DOC.description,
274
- properties: {
275
- bodyForSign: {
276
- type: "object",
277
- description: MULTISIGN_OUTPUT_DOC.fields.bodyForSign.description
250
+ 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.",
252
+ fields: {
253
+ nonce: {
254
+ type: "number",
255
+ description: "From GET /getPublicMgtKeyNonce (Ed25519) or GET /getNodeMgtKeyNonce (Ethereum NodeMgtKey)."
278
256
  },
279
- messageToSign: {
257
+ clientSig: {
258
+ type: "string",
259
+ description: "Management signature; empty string in the message to sign."
260
+ },
261
+ nodeKey: {
280
262
  type: "string",
281
- description: MULTISIGN_OUTPUT_DOC.fields.messageToSign.description
263
+ description: "Required. 128-hex MPC node id from GET /getNodeKey (no 0x prefix)."
282
264
  }
283
265
  },
284
- required: ["bodyForSign", "messageToSign"]
266
+ helpers: {
267
+ managementSigFields: "Base envelope with clientSig cleared.",
268
+ buildManagementPostBody: "Spread managementSigFields then endpoint fields.",
269
+ messageToSignManagementBody: "Canonical JSON string to sign.",
270
+ withManagementClientSig: "Attach signature to POST body.",
271
+ fetchNodeKey: "GET /getNodeKey via nodeFetchWithReadAuth.",
272
+ fetchManagementNonce: "GET nonce for Ed25519 or Ethereum management key."
273
+ }
285
274
  };
286
- var MCP_TOOL_DEFINITIONS = [
287
- {
275
+ function zodSchemaToMcpJsonSchema(schema) {
276
+ const raw = zodToJsonSchema(schema, {
277
+ target: "openApi3",
278
+ $refStrategy: "none"
279
+ });
280
+ if (raw.type === "object" || raw.type === "array" || raw.type === "string") {
281
+ const { $schema: _s, ...rest } = raw;
282
+ return rest;
283
+ }
284
+ const defs = raw.definitions;
285
+ if (defs) {
286
+ const first = Object.values(defs)[0];
287
+ if (first?.type) {
288
+ const { $schema: _s, ...rest } = first;
289
+ return rest;
290
+ }
291
+ }
292
+ return raw;
293
+ }
294
+ var evmAddressSchema = z.string().min(1).describe("EVM address (0x-prefixed, 40 hex nibbles)");
295
+ var keyGenSchema = z.object({
296
+ pubkeyhex: z.string().min(1).describe("MPC secp256k1 public key hex (required for multiSignRequest pubKey)"),
297
+ keylist: z.array(z.string()).optional().describe("Key list on the sign request"),
298
+ ClientKeys: z.record(z.string()).optional().describe("Optional client key map from keyGen")
299
+ }).describe(
300
+ "MPC key slice: { pubkeyhex, keylist?, ClientKeys? }. Used for pubKey/keyList on POST /multiSignRequest."
301
+ );
302
+ var chainDetailSchema = z.object({
303
+ legacy: z.boolean().optional(),
304
+ gasLimit: z.number().optional(),
305
+ gasMultiplier: z.number().optional(),
306
+ gasPrice: z.number().optional(),
307
+ baseFee: z.number().optional(),
308
+ priorityFee: z.number().optional(),
309
+ baseFeeMultiplier: z.number().optional()
310
+ }).passthrough().describe(
311
+ "Optional gas config: { legacy?, gasLimit?, gasMultiplier?, gasPrice?, baseFee?, priorityFee?, baseFeeMultiplier? }."
312
+ );
313
+ var evmMultisignCommonInputSchema = z.object({
314
+ keyGen: keyGenSchema,
315
+ purposeText: z.string().min(1).describe(
316
+ "Human-readable purpose for the sign request. Stored in bodyForSign.purpose (may be appended with an automatic batch suffix)."
317
+ ),
318
+ useCustomGas: z.boolean().describe(
319
+ "When true, apply chain gas settings from chainDetail / customGasChainDetails instead of raw RPC estimates only."
320
+ ),
321
+ chainId: z.number().int().positive().describe("EVM chain id (decimal). Becomes destinationChainID on the sign request."),
322
+ rpcUrl: z.string().min(1).describe("HTTPS JSON-RPC URL for gas estimation, nonce, and allowance reads."),
323
+ executorAddress: evmAddressSchema.describe(
324
+ "MPC wallet address (from keyGen ethereumaddress) \u2014 tx sender for estimates and approvals."
325
+ ),
326
+ chainDetail: chainDetailSchema,
327
+ customGasChainDetails: z.record(z.unknown()).optional().describe("Snapshot written to extraJSON.customGasChainDetails when useCustomGas is true.")
328
+ });
329
+ var multisignOutputSchema = z.object({
330
+ bodyForSign: z.record(z.unknown()).describe(
331
+ "POST body fields without clientSig: keyList, pubKey, msgHash, msgRaw, destinationChainID, purpose, extraJSON, proposalTxParams (batch), messageHashes/messageRawBatch when N>1 txs."
332
+ ),
333
+ messageToSign: z.string().describe("JSON.stringify(bodyForSign) \u2014 exact string to sign before adding clientSig.")
334
+ }).describe(
335
+ "Unsigned mpc-auth multiSignRequest payload. Sign messageToSign and POST { ...bodyForSign, clientSig, signedMessage } to /multiSignRequest."
336
+ );
337
+ var jsonObjectSchema = z.record(z.unknown());
338
+ var uniswapQuoteTradeTypeSchema = z.enum(["EXACT_INPUT", "EXACT_OUTPUT"]);
339
+ var mcpUniswapV4QuoteInputSchema = z.object({
340
+ type: uniswapQuoteTradeTypeSchema.describe("EXACT_INPUT or EXACT_OUTPUT"),
341
+ amount: z.string().min(1).describe("Amount in token-in base units (wei string for ERC-20)"),
342
+ tokenIn: z.string().min(1).describe("Input token; 0x0 for native ETH"),
343
+ tokenOut: z.string().min(1).describe("Output token address"),
344
+ chainId: z.union([z.number().int().positive(), z.string().min(1)]).describe("tokenInChainId / same-chain default"),
345
+ uniswapApiKey: z.string().min(1).describe("Uniswap Trade API x-api-key"),
346
+ swapper: evmAddressSchema.optional().describe("MPC executor; omit if keyGen + managementNodeUrl provided"),
347
+ slippage: z.union([z.number(), z.string()]).optional().describe("Slippage percent; omit for API auto slippage"),
348
+ keyGen: z.string().optional().describe("KeyGen id \u2014 resolves swapper via GET /getKeyGenResultById when swapper omitted"),
349
+ managementNodeUrl: z.string().min(1).optional().describe("MPC node base URL; required with keyGen when swapper is omitted"),
350
+ tokenInChainId: z.union([z.number(), z.string()]).optional(),
351
+ tokenOutChainId: z.union([z.number(), z.string()]).optional(),
352
+ permit2Disabled: z.boolean().optional(),
353
+ baseUrl: z.string().optional(),
354
+ universalRouterVersion: z.string().optional()
355
+ });
356
+ var mcpUniswapV4QuoteOutputSchema = jsonObjectSchema.describe(
357
+ "Full Uniswap POST /quote JSON (includes nested quote object with input/output amounts)."
358
+ );
359
+ var mcpUniswapV4CreateSwapInputSchema = z.object({
360
+ uniswapApiKey: z.string().min(1).describe("Uniswap Trade API key"),
361
+ fullQuoteFromPermit: jsonObjectSchema.describe("Full quote JSON from ctm_uniswap_v4_quote"),
362
+ swapTransactionDeadlineUnix: z.number().int().positive().optional().describe("On-chain deadline unix seconds; default ~30 min from now"),
363
+ useServerProxy: z.boolean().optional().describe("Set false in Node/agents; true only in browser via Next API route"),
364
+ baseUrl: z.string().optional(),
365
+ universalRouterVersion: z.string().optional()
366
+ });
367
+ var mcpUniswapV4CreateSwapOutputSchema = z.object({
368
+ swap: jsonObjectSchema.describe("Universal Router tx: { to, data, value, gasLimit? }"),
369
+ requestId: z.string().optional(),
370
+ gasFee: z.string().optional()
371
+ }).passthrough().describe("{ swap: TransactionRequest, requestId?, gasFee? }");
372
+ var swapTxRequestSchema = jsonObjectSchema.describe("swap field from create_swap response (to, data, value)");
373
+ var mcpUniswapV4BuildSwapMultisignInputSchema = evmMultisignCommonInputSchema.extend({
374
+ tokenIn: evmAddressSchema.describe("Token in; 0x0 for native ETH"),
375
+ swap: swapTxRequestSchema,
376
+ createSwapResponse: z.object({
377
+ swap: swapTxRequestSchema,
378
+ requestId: z.string().optional(),
379
+ gasFee: z.string().optional()
380
+ }).passthrough().describe("Full create_swap response"),
381
+ fullQuoteSnapshot: jsonObjectSchema.describe("Quote JSON used for the swap"),
382
+ swapDeadlineUnix: z.number().describe("Same deadline passed to create_swap"),
383
+ slippagePercent: z.number().optional().describe("Extra approve headroom for EXACT_OUTPUT")
384
+ });
385
+ var mcpCurveDaoBuildSwapMultisignInputSchema = evmMultisignCommonInputSchema.extend({
386
+ tokenIn: evmAddressSchema.describe("ERC-20 sold (native in uses WETH path in UI)"),
387
+ tokenOut: z.string().min(1).describe("Output token or 0xeeee\u2026 native placeholder"),
388
+ amountHuman: z.string().min(1).describe("Human-readable amount of tokenIn"),
389
+ slippagePercent: z.number().gt(0).lt(100).describe("Slippage 0\u2013100 exclusive")
390
+ });
391
+ function mcpMultisignInput(fields) {
392
+ return evmMultisignCommonInputSchema.extend(fields);
393
+ }
394
+ var mcpLidoSubmitInputSchema = mcpMultisignInput({
395
+ valueWei: z.string().min(1).describe("ETH to stake (wei decimal string)"),
396
+ referral: evmAddressSchema.optional()
397
+ });
398
+ var mcpLidoRequestWithdrawalsInputSchema = mcpMultisignInput({
399
+ stEthAmountsWei: z.array(z.string()).min(1).describe("stETH amounts per withdrawal request (wei strings)")
400
+ });
401
+ var mcpLidoClaimWithdrawalInputSchema = mcpMultisignInput({
402
+ requestId: z.union([z.string(), z.number()]).describe("Withdrawal queue request id")
403
+ });
404
+ var mcpLidoWrapStEthInputSchema = mcpMultisignInput({
405
+ stEthAmountWei: z.string().min(1)
406
+ });
407
+ var mcpLidoUnwrapWstEthInputSchema = mcpMultisignInput({
408
+ wstEthAmountWei: z.string().min(1)
409
+ });
410
+ var mcpEthenaStakeInputSchema = mcpMultisignInput({
411
+ usdeAmountHuman: z.string().min(1),
412
+ susdeVault: evmAddressSchema.optional()
413
+ });
414
+ var mcpEthenaRedeemInputSchema = mcpMultisignInput({
415
+ susdeSharesHuman: z.string().min(1),
416
+ susdeVault: evmAddressSchema.optional()
417
+ });
418
+ var mcpEthenaCooldownInputSchema = mcpMultisignInput({
419
+ susdeSharesHuman: z.string().min(1),
420
+ susdeVault: evmAddressSchema.optional()
421
+ });
422
+ var mcpEthenaClaimInputSchema = mcpMultisignInput({
423
+ susdeVault: evmAddressSchema.optional()
424
+ });
425
+ var mcpMapleDepositInputSchema = mcpMultisignInput({
426
+ syrupRouter: evmAddressSchema,
427
+ pool: evmAddressSchema,
428
+ asset: evmAddressSchema,
429
+ amountHuman: z.string().min(1),
430
+ authorizeSig: jsonObjectSchema.optional()
431
+ });
432
+ var mcpMapleRequestRedeemInputSchema = mcpMultisignInput({
433
+ pool: evmAddressSchema,
434
+ sharesHuman: z.string().min(1),
435
+ receiver: evmAddressSchema
436
+ });
437
+ var mcpSkyLockstakeStakeInputSchema = mcpMultisignInput({
438
+ skyAmountHuman: z.string().min(1),
439
+ usdsDrawHuman: z.string().optional(),
440
+ farmRef: z.string().optional()
441
+ });
442
+ var mcpSkyLockstakeDrawInputSchema = mcpMultisignInput({
443
+ usdsAmountHuman: z.string().min(1),
444
+ urnIndex: z.number().int().nonnegative()
445
+ });
446
+ var mcpSkyLockstakeWipeInputSchema = mcpMultisignInput({
447
+ usdsAmountHuman: z.string().min(1),
448
+ urnIndex: z.number().int().nonnegative()
449
+ });
450
+ var mcpSkyLockstakeCloseInputSchema = mcpMultisignInput({
451
+ urnIndex: z.number().int().nonnegative()
452
+ });
453
+ var mcpSkyLockstakeGetRewardInputSchema = mcpMultisignInput({
454
+ urnIndex: z.number().int().nonnegative()
455
+ });
456
+ var mcpSkySusdsDepositInputSchema = mcpMultisignInput({
457
+ usdsAmountHuman: z.string().min(1)
458
+ });
459
+ var mcpSkySusdsRedeemInputSchema = mcpMultisignInput({
460
+ sharesHuman: z.string().min(1)
461
+ });
462
+ var mcpAaveV4DepositInputSchema = mcpMultisignInput({
463
+ spoke: evmAddressSchema,
464
+ underlying: evmAddressSchema,
465
+ amountHuman: z.string().min(1),
466
+ marketId: z.string().min(1)
467
+ });
468
+ var mcpAaveV4WithdrawInputSchema = mcpMultisignInput({
469
+ spoke: evmAddressSchema,
470
+ underlying: evmAddressSchema,
471
+ amountHuman: z.string().min(1),
472
+ marketId: z.string().min(1)
473
+ });
474
+ var mcpAaveV4BorrowInputSchema = mcpMultisignInput({
475
+ spoke: evmAddressSchema,
476
+ underlying: evmAddressSchema,
477
+ amountHuman: z.string().min(1),
478
+ marketId: z.string().min(1)
479
+ });
480
+ var mcpAaveV4RepayInputSchema = mcpMultisignInput({
481
+ spoke: evmAddressSchema,
482
+ underlying: evmAddressSchema,
483
+ amountHuman: z.string().min(1),
484
+ marketId: z.string().min(1)
485
+ });
486
+ var mcpEulerV2IsolatedLendInputSchema = mcpMultisignInput({
487
+ vault: evmAddressSchema,
488
+ assetAmountHuman: z.string().min(1)
489
+ });
490
+ var mcpEulerV2IsolatedBorrowInputSchema = mcpMultisignInput({
491
+ vault: evmAddressSchema,
492
+ collateralAsset: evmAddressSchema,
493
+ borrowAsset: evmAddressSchema,
494
+ collateralAmountHuman: z.string().min(1),
495
+ loopBorrowWeis: z.array(z.string()).min(1)
496
+ });
497
+ var mcpEulerV2VaultWithdrawInputSchema = mcpMultisignInput({
498
+ vault: evmAddressSchema,
499
+ sharesHuman: z.string().min(1)
500
+ });
501
+ var mcpEulerV2BorrowRepayInputSchema = mcpMultisignInput({
502
+ vault: evmAddressSchema,
503
+ amountHuman: z.string().min(1)
504
+ });
505
+ var mcpEulerV2CollateralDepositInputSchema = mcpMultisignInput({
506
+ vault: evmAddressSchema,
507
+ collateralAsset: evmAddressSchema,
508
+ amountHuman: z.string().min(1)
509
+ });
510
+ var mcpEulerV2CollateralWithdrawInputSchema = mcpMultisignInput({
511
+ vault: evmAddressSchema,
512
+ collateralAsset: evmAddressSchema,
513
+ amountHuman: z.string().min(1)
514
+ });
515
+
516
+ // src/agent/mcpProtocolTools.ts
517
+ function defineProtocolMcpTool(def) {
518
+ return {
519
+ ...def,
520
+ outputZod: multisignOutputSchema,
521
+ inputSchema: zodSchemaToMcpJsonSchema(def.inputZod),
522
+ outputSchema: zodSchemaToMcpJsonSchema(multisignOutputSchema),
523
+ parseInput: (data) => def.inputZod.parse(data),
524
+ parseOutput: (data) => multisignOutputSchema.parse(data)
525
+ };
526
+ }
527
+ var MCP_PROTOCOL_TOOL_DEFINITIONS = [
528
+ defineProtocolMcpTool({
529
+ name: "ctm_lido_build_submit_multisign",
530
+ actionId: "lido.submit",
531
+ protocolId: "lido",
532
+ chainCategory: "evm",
533
+ description: "Build mpc-auth multiSignRequest for Lido ETH stake (submit).",
534
+ prerequisites: ["keyGen", "executorAddress", "RPC URL"],
535
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
536
+ handler: { importPath: "protocols/evm/lido", exportName: "buildEvmMultisignBodyLidoSubmit" },
537
+ inputZod: mcpLidoSubmitInputSchema
538
+ }),
539
+ defineProtocolMcpTool({
540
+ name: "ctm_lido_build_request_withdrawals_multisign",
541
+ actionId: "lido.request-withdrawals",
542
+ protocolId: "lido",
543
+ chainCategory: "evm",
544
+ description: "Build batch for Lido withdrawal queue (approve + requestWithdrawals).",
545
+ prerequisites: ["keyGen", "executorAddress", "RPC URL"],
546
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
547
+ handler: { importPath: "protocols/evm/lido", exportName: "buildEvmMultisignBodyLidoRequestWithdrawals" },
548
+ inputZod: mcpLidoRequestWithdrawalsInputSchema
549
+ }),
550
+ defineProtocolMcpTool({
551
+ name: "ctm_lido_build_claim_withdrawal_multisign",
552
+ actionId: "lido.claim-withdrawal",
553
+ protocolId: "lido",
554
+ chainCategory: "evm",
555
+ description: "Build tx for Lido claimWithdrawal.",
556
+ prerequisites: ["keyGen", "executorAddress", "RPC URL"],
557
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
558
+ handler: { importPath: "protocols/evm/lido", exportName: "buildEvmMultisignBodyLidoClaimWithdrawal" },
559
+ inputZod: mcpLidoClaimWithdrawalInputSchema
560
+ }),
561
+ defineProtocolMcpTool({
562
+ name: "ctm_lido_build_wrap_steth_multisign",
563
+ actionId: "lido.wrap-steth",
564
+ protocolId: "lido",
565
+ chainCategory: "evm",
566
+ description: "Build batch for wstETH wrap.",
567
+ prerequisites: ["keyGen", "executorAddress", "RPC URL"],
568
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
569
+ handler: { importPath: "protocols/evm/lido", exportName: "buildEvmMultisignBodyLidoWrapStEth" },
570
+ inputZod: mcpLidoWrapStEthInputSchema
571
+ }),
572
+ defineProtocolMcpTool({
573
+ name: "ctm_lido_build_unwrap_wsteth_multisign",
574
+ actionId: "lido.unwrap-wsteth",
575
+ protocolId: "lido",
576
+ chainCategory: "evm",
577
+ description: "Build tx for wstETH unwrap.",
578
+ prerequisites: ["keyGen", "executorAddress", "RPC URL"],
579
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
580
+ handler: { importPath: "protocols/evm/lido", exportName: "buildEvmMultisignBodyLidoUnwrapWstEth" },
581
+ inputZod: mcpLidoUnwrapWstEthInputSchema
582
+ }),
583
+ defineProtocolMcpTool({
584
+ name: "ctm_ethena_build_stake_multisign",
585
+ actionId: "ethena.stake-usde",
586
+ protocolId: "ethena",
587
+ chainCategory: "evm",
588
+ description: "Build batch: USDe approve + sUSDe deposit.",
589
+ prerequisites: ["keyGen", "executorAddress", "Ethereum mainnet RPC"],
590
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
591
+ handler: { importPath: "protocols/evm/ethena", exportName: "buildEvmMultisignBodyEthenaUsdeStakeToSusde" },
592
+ inputZod: mcpEthenaStakeInputSchema
593
+ }),
594
+ defineProtocolMcpTool({
595
+ name: "ctm_ethena_build_redeem_multisign",
596
+ actionId: "ethena.redeem-susde",
597
+ protocolId: "ethena",
598
+ chainCategory: "evm",
599
+ description: "Build sUSDe redeem when cooldown is off.",
600
+ prerequisites: ["keyGen", "executorAddress", "RPC URL"],
601
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
602
+ handler: { importPath: "protocols/evm/ethena", exportName: "buildEvmMultisignBodyEthenaSusdeRedeemToUsde" },
603
+ inputZod: mcpEthenaRedeemInputSchema
604
+ }),
605
+ defineProtocolMcpTool({
606
+ name: "ctm_ethena_build_cooldown_multisign",
607
+ actionId: "ethena.cooldown-shares",
608
+ protocolId: "ethena",
609
+ chainCategory: "evm",
610
+ description: "Build sUSDe cooldownShares batch step.",
611
+ prerequisites: ["keyGen", "executorAddress", "RPC URL"],
612
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
613
+ handler: { importPath: "protocols/evm/ethena", exportName: "buildEvmMultisignBodyEthenaSusdeCooldownShares" },
614
+ inputZod: mcpEthenaCooldownInputSchema
615
+ }),
616
+ defineProtocolMcpTool({
617
+ name: "ctm_ethena_build_claim_multisign",
618
+ actionId: "ethena.claim-unstake",
619
+ protocolId: "ethena",
620
+ chainCategory: "evm",
621
+ description: "Build unstake claim after cooldown.",
622
+ prerequisites: ["keyGen", "executorAddress", "RPC URL"],
623
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
624
+ handler: { importPath: "protocols/evm/ethena", exportName: "buildEvmMultisignBodyEthenaUnstakeClaim" },
625
+ inputZod: mcpEthenaClaimInputSchema
626
+ }),
627
+ defineProtocolMcpTool({
628
+ name: "ctm_maple_build_deposit_multisign",
629
+ actionId: "maple-syrup.deposit",
630
+ protocolId: "maple-syrup",
631
+ chainCategory: "evm",
632
+ description: "Build Maple Syrup router deposit batch.",
633
+ prerequisites: ["keyGen", "executorAddress", "router + pool addresses"],
634
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
635
+ handler: { importPath: "protocols/evm/maple", exportName: "buildEvmMultisignBodyMapleSyrupDeposit" },
636
+ inputZod: mcpMapleDepositInputSchema
637
+ }),
638
+ defineProtocolMcpTool({
639
+ name: "ctm_maple_build_request_redeem_multisign",
640
+ actionId: "maple-syrup.request-redeem",
641
+ protocolId: "maple-syrup",
642
+ chainCategory: "evm",
643
+ description: "Build Maple PoolV2 requestRedeem batch.",
644
+ prerequisites: ["keyGen", "executorAddress", "pool address"],
645
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
646
+ handler: { importPath: "protocols/evm/maple", exportName: "buildEvmMultisignBodyMaplePoolRequestRedeem" },
647
+ inputZod: mcpMapleRequestRedeemInputSchema
648
+ }),
649
+ defineProtocolMcpTool({
650
+ name: "ctm_sky_build_lockstake_stake_multisign",
651
+ actionId: "sky.lockstake-stake",
652
+ protocolId: "sky",
653
+ chainCategory: "evm",
654
+ description: "Build Sky Lockstake open/stake batch.",
655
+ prerequisites: ["keyGen", "executorAddress", "Ethereum mainnet RPC"],
656
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
657
+ handler: { importPath: "protocols/evm/sky", exportName: "buildSkyLockstakeStakePositionBatch" },
658
+ inputZod: mcpSkyLockstakeStakeInputSchema
659
+ }),
660
+ defineProtocolMcpTool({
661
+ name: "ctm_sky_build_lockstake_draw_multisign",
662
+ actionId: "sky.lockstake-draw",
663
+ protocolId: "sky",
664
+ chainCategory: "evm",
665
+ description: "Build Lockstake draw (borrow USDS).",
666
+ prerequisites: ["keyGen", "executorAddress", "open urn"],
667
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
668
+ handler: { importPath: "protocols/evm/sky", exportName: "buildSkyLockstakeDrawBatch" },
669
+ inputZod: mcpSkyLockstakeDrawInputSchema
670
+ }),
671
+ defineProtocolMcpTool({
672
+ name: "ctm_sky_build_lockstake_wipe_multisign",
673
+ actionId: "sky.lockstake-wipe",
674
+ protocolId: "sky",
675
+ chainCategory: "evm",
676
+ description: "Build Lockstake repay/wipe batch.",
677
+ prerequisites: ["keyGen", "executorAddress", "urn index"],
678
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
679
+ handler: { importPath: "protocols/evm/sky", exportName: "buildSkyLockstakeWipeBatch" },
680
+ inputZod: mcpSkyLockstakeWipeInputSchema
681
+ }),
682
+ defineProtocolMcpTool({
683
+ name: "ctm_sky_build_lockstake_close_multisign",
684
+ actionId: "sky.lockstake-close",
685
+ protocolId: "sky",
686
+ chainCategory: "evm",
687
+ description: "Build Lockstake close position batch.",
688
+ prerequisites: ["keyGen", "executorAddress", "urn index"],
689
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
690
+ handler: { importPath: "protocols/evm/sky", exportName: "buildSkyLockstakeCloseBatch" },
691
+ inputZod: mcpSkyLockstakeCloseInputSchema
692
+ }),
693
+ defineProtocolMcpTool({
694
+ name: "ctm_sky_build_lockstake_get_reward_multisign",
695
+ actionId: "sky.lockstake-get-reward",
696
+ protocolId: "sky",
697
+ chainCategory: "evm",
698
+ description: "Build Lockstake getReward batch.",
699
+ prerequisites: ["keyGen", "executorAddress", "urn index"],
700
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
701
+ handler: { importPath: "protocols/evm/sky", exportName: "buildSkyLockstakeGetRewardBatch" },
702
+ inputZod: mcpSkyLockstakeGetRewardInputSchema
703
+ }),
704
+ defineProtocolMcpTool({
705
+ name: "ctm_sky_build_susds_deposit_multisign",
706
+ actionId: "sky.susds-deposit",
707
+ protocolId: "sky",
708
+ chainCategory: "evm",
709
+ description: "Build USDS \u2192 sUSDS ERC-4626 deposit batch.",
710
+ prerequisites: ["keyGen", "executorAddress", "RPC URL"],
711
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
712
+ handler: { importPath: "protocols/evm/sky", exportName: "buildSkySusdsDepositFromUsdsBatch" },
713
+ inputZod: mcpSkySusdsDepositInputSchema
714
+ }),
715
+ defineProtocolMcpTool({
716
+ name: "ctm_sky_build_susds_redeem_multisign",
717
+ actionId: "sky.susds-redeem",
718
+ protocolId: "sky",
719
+ chainCategory: "evm",
720
+ description: "Build sUSDS redeem to USDS batch.",
721
+ prerequisites: ["keyGen", "executorAddress", "RPC URL"],
722
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
723
+ handler: { importPath: "protocols/evm/sky", exportName: "buildSkySusdsRedeemToUsdsBatch" },
724
+ inputZod: mcpSkySusdsRedeemInputSchema
725
+ }),
726
+ defineProtocolMcpTool({
727
+ name: "ctm_aave_v4_build_deposit_multisign",
728
+ actionId: "aave-v4.deposit",
729
+ protocolId: "aave-v4",
730
+ chainCategory: "evm",
731
+ description: "Build Aave v4 Spoke supply/deposit batch.",
732
+ prerequisites: ["keyGen", "executorAddress", "spoke + underlying"],
733
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
734
+ handler: { importPath: "protocols/evm/aave-v4", exportName: "buildEvmMultisignBodyAaveV4DepositBatch" },
735
+ inputZod: mcpAaveV4DepositInputSchema
736
+ }),
737
+ defineProtocolMcpTool({
738
+ name: "ctm_aave_v4_build_withdraw_multisign",
739
+ actionId: "aave-v4.withdraw",
740
+ protocolId: "aave-v4",
741
+ chainCategory: "evm",
742
+ description: "Build Aave v4 Spoke withdraw batch.",
743
+ prerequisites: ["keyGen", "executorAddress", "spoke + underlying"],
744
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
745
+ handler: { importPath: "protocols/evm/aave-v4", exportName: "buildEvmMultisignBodyAaveV4SpokeWithdraw" },
746
+ inputZod: mcpAaveV4WithdrawInputSchema
747
+ }),
748
+ defineProtocolMcpTool({
749
+ name: "ctm_aave_v4_build_borrow_multisign",
750
+ actionId: "aave-v4.borrow",
751
+ protocolId: "aave-v4",
752
+ chainCategory: "evm",
753
+ description: "Build Aave v4 Spoke borrow batch.",
754
+ prerequisites: ["keyGen", "executorAddress", "spoke + underlying"],
755
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
756
+ handler: { importPath: "protocols/evm/aave-v4", exportName: "buildEvmMultisignBodyAaveV4SpokeBorrow" },
757
+ inputZod: mcpAaveV4BorrowInputSchema
758
+ }),
759
+ defineProtocolMcpTool({
760
+ name: "ctm_aave_v4_build_repay_multisign",
761
+ actionId: "aave-v4.repay",
762
+ protocolId: "aave-v4",
763
+ chainCategory: "evm",
764
+ description: "Build Aave v4 Spoke repay batch.",
765
+ prerequisites: ["keyGen", "executorAddress", "spoke + underlying"],
766
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
767
+ handler: { importPath: "protocols/evm/aave-v4", exportName: "buildEvmMultisignBodyAaveV4SpokeRepay" },
768
+ inputZod: mcpAaveV4RepayInputSchema
769
+ }),
770
+ defineProtocolMcpTool({
771
+ name: "ctm_euler_v2_build_isolated_lend_multisign",
772
+ actionId: "euler-v2.isolated-lend",
773
+ protocolId: "euler-v2",
774
+ chainCategory: "evm",
775
+ description: "Build Euler v2 vault deposit/lend batch.",
776
+ prerequisites: ["keyGen", "executorAddress", "vault address"],
777
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
778
+ handler: { importPath: "protocols/evm/euler-v2", exportName: "buildEvmMultisignBodyEulerV2IsolatedLendDepositBatch" },
779
+ inputZod: mcpEulerV2IsolatedLendInputSchema
780
+ }),
781
+ defineProtocolMcpTool({
782
+ name: "ctm_euler_v2_build_isolated_borrow_multisign",
783
+ actionId: "euler-v2.isolated-borrow",
784
+ protocolId: "euler-v2",
785
+ chainCategory: "evm",
786
+ description: "Build Euler v2 isolated borrow loop batch.",
787
+ prerequisites: ["keyGen", "executorAddress", "vault + collateral"],
788
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
789
+ handler: { importPath: "protocols/evm/euler-v2", exportName: "buildEvmMultisignBodyEulerV2IsolatedBorrowBatch" },
790
+ inputZod: mcpEulerV2IsolatedBorrowInputSchema
791
+ }),
792
+ defineProtocolMcpTool({
793
+ name: "ctm_euler_v2_build_vault_withdraw_multisign",
794
+ actionId: "euler-v2.vault-withdraw",
795
+ protocolId: "euler-v2",
796
+ chainCategory: "evm",
797
+ description: "Build Euler v2 vault withdraw/redeem batch.",
798
+ prerequisites: ["keyGen", "executorAddress", "vault address"],
799
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
800
+ handler: { importPath: "protocols/evm/euler-v2", exportName: "buildEvmMultisignBodyEulerV2VaultWithdrawBatch" },
801
+ inputZod: mcpEulerV2VaultWithdrawInputSchema
802
+ }),
803
+ defineProtocolMcpTool({
804
+ name: "ctm_euler_v2_build_borrow_repay_multisign",
805
+ actionId: "euler-v2.borrow-repay",
806
+ protocolId: "euler-v2",
807
+ chainCategory: "evm",
808
+ description: "Build Euler v2 borrow repay batch.",
809
+ prerequisites: ["keyGen", "executorAddress", "vault address"],
810
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
811
+ handler: { importPath: "protocols/evm/euler-v2", exportName: "buildEvmMultisignBodyEulerV2BorrowRepayBatch" },
812
+ inputZod: mcpEulerV2BorrowRepayInputSchema
813
+ }),
814
+ defineProtocolMcpTool({
815
+ name: "ctm_euler_v2_build_collateral_deposit_multisign",
816
+ actionId: "euler-v2.collateral-deposit",
817
+ protocolId: "euler-v2",
818
+ chainCategory: "evm",
819
+ description: "Build Euler v2 borrow collateral deposit batch.",
820
+ prerequisites: ["keyGen", "executorAddress", "vault + collateral asset"],
821
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
822
+ handler: { importPath: "protocols/evm/euler-v2", exportName: "buildEvmMultisignBodyEulerV2BorrowCollateralDepositBatch" },
823
+ inputZod: mcpEulerV2CollateralDepositInputSchema
824
+ }),
825
+ defineProtocolMcpTool({
826
+ name: "ctm_euler_v2_build_collateral_withdraw_multisign",
827
+ actionId: "euler-v2.collateral-withdraw",
828
+ protocolId: "euler-v2",
829
+ chainCategory: "evm",
830
+ description: "Build Euler v2 borrow collateral withdraw batch.",
831
+ prerequisites: ["keyGen", "executorAddress", "vault + collateral asset"],
832
+ followUp: ["Sign messageToSign", "POST /multiSignRequest"],
833
+ handler: { importPath: "protocols/evm/euler-v2", exportName: "buildEvmMultisignBodyEulerV2BorrowCollateralWithdrawBatch" },
834
+ inputZod: mcpEulerV2CollateralWithdrawInputSchema
835
+ })
836
+ ];
837
+
838
+ // src/agent/mcpTools.ts
839
+ function defineMcpTool(def) {
840
+ return {
841
+ ...def,
842
+ inputSchema: zodSchemaToMcpJsonSchema(def.inputZod),
843
+ outputSchema: zodSchemaToMcpJsonSchema(def.outputZod),
844
+ parseInput: (data) => def.inputZod.parse(data),
845
+ parseOutput: (data) => def.outputZod.parse(data)
846
+ };
847
+ }
848
+ var CORE_MCP_TOOL_DEFINITIONS = [
849
+ defineMcpTool({
288
850
  name: "ctm_uniswap_v4_quote",
289
851
  actionId: "uniswap-v4.quote",
290
852
  protocolId: "uniswap-v4",
@@ -293,33 +855,10 @@ var MCP_TOOL_DEFINITIONS = [
293
855
  prerequisites: ["Chain must be supported by Uniswap V4 (Universal Router map)."],
294
856
  followUp: ["ctm_uniswap_v4_create_swap", "ctm_uniswap_v4_build_swap_multisign"],
295
857
  handler: { importPath: "protocols/evm/uniswap-v4", exportName: "uniswapTradeQuote" },
296
- inputSchema: {
297
- type: "object",
298
- properties: paramProperties({
299
- type: { type: "string", required: true, description: "EXACT_INPUT or EXACT_OUTPUT" },
300
- amount: { type: "string", required: true, description: "Amount in token-in base units (wei string for ERC-20)" },
301
- tokenIn: { type: "address", required: true, description: "Input token; 0x0 for native ETH" },
302
- tokenOut: { type: "address", required: true, description: "Output token address" },
303
- chainId: { type: "number", required: true, description: "tokenInChainId / same-chain default" },
304
- uniswapApiKey: { type: "string", required: true, description: "Uniswap Trade API x-api-key" },
305
- swapper: { type: "address", required: false, description: "MPC executor; omit if keyGen + managementNodeUrl provided" },
306
- slippage: { type: "number", required: false, description: "Slippage percent; omit for API auto slippage" }
307
- }),
308
- required: requiredKeys({
309
- type: { type: "string", required: true, description: "" },
310
- amount: { type: "string", required: true, description: "" },
311
- tokenIn: { type: "address", required: true, description: "" },
312
- tokenOut: { type: "address", required: true, description: "" },
313
- chainId: { type: "number", required: true, description: "" },
314
- uniswapApiKey: { type: "string", required: true, description: "" }
315
- })
316
- },
317
- outputSchema: {
318
- type: "object",
319
- description: "Full Uniswap POST /quote JSON (includes nested quote object with input/output amounts)."
320
- }
321
- },
322
- {
858
+ inputZod: mcpUniswapV4QuoteInputSchema,
859
+ outputZod: mcpUniswapV4QuoteOutputSchema
860
+ }),
861
+ defineMcpTool({
323
862
  name: "ctm_uniswap_v4_create_swap",
324
863
  actionId: "uniswap-v4.create-swap",
325
864
  protocolId: "uniswap-v4",
@@ -328,33 +867,10 @@ var MCP_TOOL_DEFINITIONS = [
328
867
  prerequisites: ["ctm_uniswap_v4_quote output (fullQuoteFromPermit)"],
329
868
  followUp: ["ctm_uniswap_v4_build_swap_multisign"],
330
869
  handler: { importPath: "protocols/evm/uniswap-v4", exportName: "uniswapCreateSwap" },
331
- inputSchema: {
332
- type: "object",
333
- properties: paramProperties({
334
- uniswapApiKey: { type: "string", required: true, description: "Uniswap Trade API key" },
335
- fullQuoteFromPermit: { type: "object", required: true, description: "Full quote JSON from ctm_uniswap_v4_quote" },
336
- swapTransactionDeadlineUnix: {
337
- type: "number",
338
- required: false,
339
- description: "On-chain deadline unix seconds; default ~30 min from now"
340
- },
341
- useServerProxy: {
342
- type: "boolean",
343
- required: false,
344
- description: "Set false in Node/agents; true only in browser via Next API route"
345
- }
346
- }),
347
- required: requiredKeys({
348
- uniswapApiKey: { type: "string", required: true, description: "" },
349
- fullQuoteFromPermit: { type: "object", required: true, description: "" }
350
- })
351
- },
352
- outputSchema: {
353
- type: "object",
354
- description: "{ swap: TransactionRequest, requestId?, gasFee? }"
355
- }
356
- },
357
- {
870
+ inputZod: mcpUniswapV4CreateSwapInputSchema,
871
+ outputZod: mcpUniswapV4CreateSwapOutputSchema
872
+ }),
873
+ defineMcpTool({
358
874
  name: "ctm_uniswap_v4_build_swap_multisign",
359
875
  actionId: "uniswap-v4.swap-exact-input",
360
876
  protocolId: "uniswap-v4",
@@ -366,79 +882,69 @@ var MCP_TOOL_DEFINITIONS = [
366
882
  "executorAddress matching MPC wallet",
367
883
  "RPC URL and chainDetail from node chain config"
368
884
  ],
369
- followUp: ["Sign messageToSign", "POST /multiSignRequest with clientSig"],
885
+ followUp: ["Sign messageToSign", "POST /multiSignRequest with clientSig and signedMessage"],
370
886
  handler: { importPath: "protocols/evm/uniswap-v4", exportName: "buildEvmMultisignBodyUniswapV4SkipPermit2Batch" },
371
- inputSchema: {
372
- type: "object",
373
- properties: paramProperties(
374
- {
375
- tokenIn: { type: "address", required: true, description: "Token in; 0x0 for native ETH" },
376
- swap: { type: "object", required: true, description: "swap field from create_swap response" },
377
- createSwapResponse: { type: "object", required: true, description: "Full create_swap response" },
378
- fullQuoteSnapshot: { type: "object", required: true, description: "Quote JSON used for the swap" },
379
- swapDeadlineUnix: { type: "number", required: true, description: "Same deadline passed to create_swap" },
380
- slippagePercent: { type: "number", required: false, description: "Extra approve headroom for EXACT_OUTPUT" }
381
- },
382
- ["keyGen", "purposeText", "useCustomGas", "chainId", "rpcUrl", "executorAddress", "chainDetail", "customGasChainDetails"]
383
- ),
384
- required: requiredKeys(
385
- {
386
- tokenIn: { type: "address", required: true, description: "" },
387
- swap: { type: "object", required: true, description: "" },
388
- createSwapResponse: { type: "object", required: true, description: "" },
389
- fullQuoteSnapshot: { type: "object", required: true, description: "" },
390
- swapDeadlineUnix: { type: "number", required: true, description: "" }
391
- },
392
- ["keyGen", "purposeText", "useCustomGas", "chainId", "rpcUrl", "executorAddress", "chainDetail"]
393
- )
394
- },
395
- outputSchema: multisignOutputSchema
396
- },
397
- {
887
+ inputZod: mcpUniswapV4BuildSwapMultisignInputSchema,
888
+ outputZod: multisignOutputSchema
889
+ }),
890
+ defineMcpTool({
398
891
  name: "ctm_curve_dao_build_swap_multisign",
399
892
  actionId: "curve-dao.swap",
400
893
  protocolId: "curve-dao",
401
894
  chainCategory: "evm",
402
895
  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.",
403
896
  prerequisites: ["keyGen", "executorAddress", "tokenIn/tokenOut/amountHuman/slippage", "RPC URL"],
404
- followUp: ["Sign messageToSign", "POST /multiSignRequest"],
897
+ followUp: ["Sign messageToSign", "POST /multiSignRequest with clientSig and signedMessage"],
405
898
  handler: { importPath: "protocols/evm/curve-dao", exportName: "buildEvmMultisignBodyCurveDaoBatch" },
406
- inputSchema: {
407
- type: "object",
408
- properties: paramProperties(
409
- {
410
- tokenIn: { type: "address", required: true, description: "ERC-20 sold (native in uses WETH path in UI)" },
411
- tokenOut: { type: "string", required: true, description: "Output token or 0xeeee\u2026 native placeholder" },
412
- amountHuman: { type: "string", required: true, description: "Human-readable amount of tokenIn" },
413
- slippagePercent: { type: "number", required: true, description: "Slippage 0\u2013100 exclusive" }
414
- },
415
- ["keyGen", "purposeText", "useCustomGas", "chainId", "rpcUrl", "executorAddress", "chainDetail", "customGasChainDetails"]
416
- ),
417
- required: requiredKeys(
418
- {
419
- tokenIn: { type: "address", required: true, description: "" },
420
- tokenOut: { type: "string", required: true, description: "" },
421
- amountHuman: { type: "string", required: true, description: "" },
422
- slippagePercent: { type: "number", required: true, description: "" }
423
- },
424
- ["keyGen", "purposeText", "useCustomGas", "chainId", "rpcUrl", "executorAddress", "chainDetail"]
425
- )
426
- },
427
- outputSchema: multisignOutputSchema
428
- }
899
+ inputZod: mcpCurveDaoBuildSwapMultisignInputSchema,
900
+ outputZod: multisignOutputSchema
901
+ })
902
+ ];
903
+ var MCP_TOOL_DEFINITIONS = [
904
+ ...CORE_MCP_TOOL_DEFINITIONS,
905
+ ...MCP_PROTOCOL_TOOL_DEFINITIONS
429
906
  ];
907
+ function buildToolSchemaMap(kind) {
908
+ const out = {};
909
+ for (const tool of MCP_TOOL_DEFINITIONS) {
910
+ out[tool.name] = kind === "input" ? tool.inputZod : tool.outputZod;
911
+ }
912
+ return out;
913
+ }
914
+ var MCP_TOOL_INPUT_SCHEMAS = buildToolSchemaMap("input");
915
+ var MCP_TOOL_OUTPUT_SCHEMAS = buildToolSchemaMap("output");
430
916
  function getMcpToolDefinitions() {
431
917
  return MCP_TOOL_DEFINITIONS;
432
918
  }
433
919
  function getMcpToolByName(name) {
434
920
  return MCP_TOOL_DEFINITIONS.find((t) => t.name === name);
435
921
  }
922
+ function getMcpToolInputSchema(name) {
923
+ const schema = MCP_TOOL_INPUT_SCHEMAS[name];
924
+ if (!schema) throw new Error(`Unknown MCP tool: ${name}`);
925
+ return schema;
926
+ }
927
+ function getMcpToolOutputSchema(name) {
928
+ const schema = MCP_TOOL_OUTPUT_SCHEMAS[name];
929
+ if (!schema) throw new Error(`Unknown MCP tool: ${name}`);
930
+ return schema;
931
+ }
932
+ function parseMcpToolInput(name, data) {
933
+ return getMcpToolInputSchema(name).parse(data);
934
+ }
935
+ function parseMcpToolOutput(name, data) {
936
+ return getMcpToolOutputSchema(name).parse(data);
937
+ }
436
938
  function getAgentCatalogForMcp() {
437
939
  return {
438
940
  tools: MCP_TOOL_DEFINITIONS,
439
941
  protocols: getProtocolModules(),
440
942
  commonParams: EVM_COMMON_PARAM_DOCS,
441
943
  multisignOutput: MULTISIGN_OUTPUT_DOC,
944
+ managementSig: MANAGEMENT_SIG_DOC,
945
+ /** Zod schemas for MCP tool I/O — source of truth for continuum-mcp-server validation. */
946
+ inputSchemas: MCP_TOOL_INPUT_SCHEMAS,
947
+ outputSchemas: MCP_TOOL_OUTPUT_SCHEMAS,
442
948
  workflow: {
443
949
  evmSwapTypical: [
444
950
  "1. Quote (protocol-specific API if needed)",
@@ -446,14 +952,222 @@ function getAgentCatalogForMcp() {
446
952
  "3. build_*_multisign \u2192 { bodyForSign, messageToSign }",
447
953
  "4. Sign messageToSign (MetaMask or Ed25519)",
448
954
  "5. POST /multiSignRequest with clientSig and signedMessage"
955
+ ],
956
+ managementPostTypical: [
957
+ "1. GET /getNodeKey \u2192 nodeKey (128 hex)",
958
+ "2. GET /getPublicMgtKeyNonce or /getNodeMgtKeyNonce \u2192 nonce",
959
+ "3. buildManagementPostBody(nonce, nodeKey, { \u2026endpoint fields })",
960
+ "4. messageToSignManagementBody(body) \u2192 sign \u2192 withManagementClientSig(body, sig)",
961
+ "5. POST management route with signed body"
449
962
  ]
450
963
  }
451
964
  };
452
965
  }
966
+ getAddress(
967
+ "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"
968
+ );
969
+ getAddress(
970
+ "0x7f39C581F595B853cBbF37C12FfeeA971C5a5bEa"
971
+ );
972
+ getAddress("0x889edC2eDab5f40e902b864aD4d7AdE8E412F9B1");
973
+ var LIDO_ETHEREUM_MAINNET_CHAIN_ID = 1;
974
+
975
+ // src/protocols/evm/lido/index.ts
976
+ var LIDO_PROTOCOL_ID = "lido";
977
+ var lidoProtocolModule = {
978
+ id: LIDO_PROTOCOL_ID,
979
+ chainCategory: "evm",
980
+ isChainSupported(ctx) {
981
+ if (ctx.chainCategory !== "evm") return false;
982
+ return Number(ctx.chainId) === LIDO_ETHEREUM_MAINNET_CHAIN_ID;
983
+ },
984
+ isTokenSupported(token) {
985
+ return token.category === "evm" && (token.kind === "native" || token.kind === "erc20");
986
+ },
987
+ actions: [
988
+ { id: "lido.submit", protocolId: LIDO_PROTOCOL_ID, chainCategory: "evm", description: "Stake ETH via Lido submit()", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: { valueWei: { type: "string", required: true, description: "ETH to stake (wei string)" } } },
989
+ { id: "lido.request-withdrawals", protocolId: LIDO_PROTOCOL_ID, chainCategory: "evm", description: "Queue stETH withdrawal", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
990
+ { id: "lido.claim-withdrawal", protocolId: LIDO_PROTOCOL_ID, chainCategory: "evm", description: "Claim finalized withdrawal", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
991
+ { id: "lido.wrap-steth", protocolId: LIDO_PROTOCOL_ID, chainCategory: "evm", description: "Wrap stETH to wstETH", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
992
+ { id: "lido.unwrap-wsteth", protocolId: LIDO_PROTOCOL_ID, chainCategory: "evm", description: "Unwrap wstETH to stETH", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} }
993
+ ]
994
+ };
995
+ registerProtocolModule(lidoProtocolModule);
996
+ var USDE_ETHEREUM_MAINNET = "0x4c9edd5852cd905f086c759e8383e09bff1e68b3";
997
+ var USDE_MOST_L2S = "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34";
998
+ var USDE_ZKSYNC_ERA = "0x39Fe7a0DACcE31Bd90418e3e659fb0b5f0B3Db0d";
999
+ var L2_SAME_ADDRESS_CHAIN_IDS = /* @__PURE__ */ new Set([
1000
+ 42161,
1001
+ // Arbitrum One
1002
+ 10,
1003
+ // Optimism
1004
+ 8453,
1005
+ // Base
1006
+ 56,
1007
+ // BNB Chain
1008
+ 59144,
1009
+ // Linea
1010
+ 5e3,
1011
+ // Mantle
1012
+ 81457,
1013
+ // Blast
1014
+ 169,
1015
+ // Manta Pacific
1016
+ 534352,
1017
+ // Scroll
1018
+ 252,
1019
+ // Fraxtal
1020
+ 34443,
1021
+ // Mode
1022
+ 196,
1023
+ // X Layer
1024
+ 1088,
1025
+ // Metis
1026
+ 80084,
1027
+ // Berachain
1028
+ 2222,
1029
+ // Kava
1030
+ 2818,
1031
+ // Morph
1032
+ 1923,
1033
+ // Swell
1034
+ 48900
1035
+ // Zircuit
1036
+ ]);
1037
+ function usdeTokenAddressOnEvmChain(chainId) {
1038
+ if (chainId === 1) return USDE_ETHEREUM_MAINNET;
1039
+ if (chainId === 324) return USDE_ZKSYNC_ERA;
1040
+ if (L2_SAME_ADDRESS_CHAIN_IDS.has(chainId)) return USDE_MOST_L2S;
1041
+ return null;
1042
+ }
1043
+ function isEvmChainInEthenaUsdeList(chainId) {
1044
+ return usdeTokenAddressOnEvmChain(chainId) != null;
1045
+ }
1046
+
1047
+ // src/protocols/evm/ethena/index.ts
1048
+ var ETHENA_PROTOCOL_ID = "ethena";
1049
+ var ethenaProtocolModule = {
1050
+ id: ETHENA_PROTOCOL_ID,
1051
+ chainCategory: "evm",
1052
+ isChainSupported(ctx) {
1053
+ if (ctx.chainCategory !== "evm") return false;
1054
+ const n = typeof ctx.chainId === "number" ? ctx.chainId : Number.parseInt(String(ctx.chainId), 10);
1055
+ return isEvmChainInEthenaUsdeList(n);
1056
+ },
1057
+ isTokenSupported(token) {
1058
+ return token.category === "evm" && token.kind === "erc20";
1059
+ },
1060
+ actions: [
1061
+ { id: "ethena.stake-usde", protocolId: ETHENA_PROTOCOL_ID, chainCategory: "evm", description: "Stake USDe \u2192 sUSDe", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: { amountHuman: { type: "string", required: true, description: "USDe amount" } } },
1062
+ { id: "ethena.redeem-susde", protocolId: ETHENA_PROTOCOL_ID, chainCategory: "evm", description: "Redeem sUSDe \u2192 USDe (no cooldown)", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
1063
+ { id: "ethena.cooldown-shares", protocolId: ETHENA_PROTOCOL_ID, chainCategory: "evm", description: "Start sUSDe cooldown", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
1064
+ { id: "ethena.claim-unstake", protocolId: ETHENA_PROTOCOL_ID, chainCategory: "evm", description: "Claim after cooldown", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} }
1065
+ ]
1066
+ };
1067
+ registerProtocolModule(ethenaProtocolModule);
1068
+
1069
+ // src/protocols/evm/maple/constants.ts
1070
+ function isMapleSyrupSupportedChain(chainId) {
1071
+ return chainId === 1 || chainId === 11155111;
1072
+ }
1073
+
1074
+ // src/protocols/evm/maple/index.ts
1075
+ var MAPLE_PROTOCOL_ID = "maple-syrup";
1076
+ var mapleProtocolModule = {
1077
+ id: MAPLE_PROTOCOL_ID,
1078
+ chainCategory: "evm",
1079
+ isChainSupported(ctx) {
1080
+ if (ctx.chainCategory !== "evm") return false;
1081
+ const n = typeof ctx.chainId === "number" ? ctx.chainId : Number.parseInt(String(ctx.chainId), 10);
1082
+ return isMapleSyrupSupportedChain(n);
1083
+ },
1084
+ isTokenSupported(token) {
1085
+ return token.category === "evm" && token.kind === "erc20";
1086
+ },
1087
+ actions: [
1088
+ { id: "maple-syrup.deposit", protocolId: MAPLE_PROTOCOL_ID, chainCategory: "evm", description: "Deposit into Maple Syrup pool", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
1089
+ { id: "maple-syrup.request-redeem", protocolId: MAPLE_PROTOCOL_ID, chainCategory: "evm", description: "Request redeem from pool", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} }
1090
+ ]
1091
+ };
1092
+ registerProtocolModule(mapleProtocolModule);
1093
+
1094
+ // src/protocols/evm/sky/mainnet.ts
1095
+ var SKY_ETHEREUM_MAINNET_CHAIN_ID = 1;
1096
+
1097
+ // src/protocols/evm/sky/index.ts
1098
+ var SKY_PROTOCOL_ID = "sky";
1099
+ var skyProtocolModule = {
1100
+ id: SKY_PROTOCOL_ID,
1101
+ chainCategory: "evm",
1102
+ isChainSupported(ctx) {
1103
+ if (ctx.chainCategory !== "evm") return false;
1104
+ return Number(ctx.chainId) === SKY_ETHEREUM_MAINNET_CHAIN_ID;
1105
+ },
1106
+ isTokenSupported(token) {
1107
+ return token.category === "evm" && token.kind === "erc20";
1108
+ },
1109
+ actions: [
1110
+ { id: "sky.lockstake-stake", protocolId: SKY_PROTOCOL_ID, chainCategory: "evm", description: "Open Lockstake position", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
1111
+ { id: "sky.lockstake-draw", protocolId: SKY_PROTOCOL_ID, chainCategory: "evm", description: "Borrow USDS from Lockstake", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
1112
+ { id: "sky.lockstake-wipe", protocolId: SKY_PROTOCOL_ID, chainCategory: "evm", description: "Repay Lockstake debt", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
1113
+ { id: "sky.lockstake-close", protocolId: SKY_PROTOCOL_ID, chainCategory: "evm", description: "Close Lockstake position", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
1114
+ { id: "sky.susds-deposit", protocolId: SKY_PROTOCOL_ID, chainCategory: "evm", description: "Deposit USDS into sUSDS vault", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
1115
+ { id: "sky.susds-redeem", protocolId: SKY_PROTOCOL_ID, chainCategory: "evm", description: "Redeem sUSDS to USDS", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} }
1116
+ ]
1117
+ };
1118
+ registerProtocolModule(skyProtocolModule);
1119
+
1120
+ // src/protocols/evm/aave-v4/index.ts
1121
+ var AAVE_V4_PROTOCOL_ID = "aave-v4";
1122
+ var aaveV4ProtocolModule = {
1123
+ id: AAVE_V4_PROTOCOL_ID,
1124
+ chainCategory: "evm",
1125
+ isChainSupported(ctx) {
1126
+ return ctx.chainCategory === "evm";
1127
+ },
1128
+ isTokenSupported(token) {
1129
+ return token.category === "evm" && (token.kind === "native" || token.kind === "erc20");
1130
+ },
1131
+ actions: [
1132
+ { id: "aave-v4.deposit", protocolId: AAVE_V4_PROTOCOL_ID, chainCategory: "evm", description: "Supply to Aave v4 Spoke", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
1133
+ { id: "aave-v4.withdraw", protocolId: AAVE_V4_PROTOCOL_ID, chainCategory: "evm", description: "Withdraw from Spoke", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
1134
+ { id: "aave-v4.borrow", protocolId: AAVE_V4_PROTOCOL_ID, chainCategory: "evm", description: "Borrow from Spoke", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
1135
+ { id: "aave-v4.repay", protocolId: AAVE_V4_PROTOCOL_ID, chainCategory: "evm", description: "Repay Spoke debt", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} }
1136
+ ]
1137
+ };
1138
+ registerProtocolModule(aaveV4ProtocolModule);
1139
+
1140
+ // src/protocols/evm/euler-v2/index.ts
1141
+ var EULER_V2_PROTOCOL_ID = "euler-v2";
1142
+ var eulerV2ProtocolModule = {
1143
+ id: EULER_V2_PROTOCOL_ID,
1144
+ chainCategory: "evm",
1145
+ isChainSupported(ctx) {
1146
+ return ctx.chainCategory === "evm";
1147
+ },
1148
+ isTokenSupported(token) {
1149
+ return token.category === "evm" && (token.kind === "native" || token.kind === "erc20");
1150
+ },
1151
+ actions: [
1152
+ { id: "euler-v2.isolated-lend", protocolId: EULER_V2_PROTOCOL_ID, chainCategory: "evm", description: "Deposit into Euler vault", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
1153
+ { id: "euler-v2.isolated-borrow", protocolId: EULER_V2_PROTOCOL_ID, chainCategory: "evm", description: "Borrow from Euler vault", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
1154
+ { id: "euler-v2.vault-withdraw", protocolId: EULER_V2_PROTOCOL_ID, chainCategory: "evm", description: "Withdraw from Euler vault", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
1155
+ { id: "euler-v2.borrow-repay", protocolId: EULER_V2_PROTOCOL_ID, chainCategory: "evm", description: "Repay Euler borrow", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
1156
+ { id: "euler-v2.collateral-deposit", protocolId: EULER_V2_PROTOCOL_ID, chainCategory: "evm", description: "Deposit borrow collateral", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
1157
+ { id: "euler-v2.collateral-withdraw", protocolId: EULER_V2_PROTOCOL_ID, chainCategory: "evm", description: "Withdraw borrow collateral", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} }
1158
+ ]
1159
+ };
1160
+ registerProtocolModule(eulerV2ProtocolModule);
453
1161
 
454
1162
  // src/agent/catalog.ts
455
1163
  registerProtocolModule(uniswapV4ProtocolModule);
456
1164
  registerProtocolModule(curveDaoProtocolModule);
1165
+ registerProtocolModule(lidoProtocolModule);
1166
+ registerProtocolModule(ethenaProtocolModule);
1167
+ registerProtocolModule(mapleProtocolModule);
1168
+ registerProtocolModule(skyProtocolModule);
1169
+ registerProtocolModule(aaveV4ProtocolModule);
1170
+ registerProtocolModule(eulerV2ProtocolModule);
457
1171
  function getAgentCatalog() {
458
1172
  return {
459
1173
  protocols: getProtocolModules(),
@@ -464,11 +1178,17 @@ function getAgentCatalog() {
464
1178
  },
465
1179
  uniswapV4: uniswapV4ProtocolModule,
466
1180
  curveDao: curveDaoProtocolModule,
1181
+ lido: lidoProtocolModule,
1182
+ ethena: ethenaProtocolModule,
1183
+ maple: mapleProtocolModule,
1184
+ sky: skyProtocolModule,
1185
+ aaveV4: aaveV4ProtocolModule,
1186
+ eulerV2: eulerV2ProtocolModule,
467
1187
  /** Prefer getAgentCatalogForMcp() or getMcpToolDefinitions() for MCP servers. */
468
1188
  mcp: getAgentCatalogForMcp()
469
1189
  };
470
1190
  }
471
1191
 
472
- export { EVM_COMMON_PARAM_DOCS, MCP_TOOL_DEFINITIONS, MULTISIGN_OUTPUT_DOC, getActionsByChainCategory, getAgentCatalog, getAgentCatalogForMcp, getMcpToolByName, getMcpToolDefinitions, getProtocolModules };
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 };
473
1193
  //# sourceMappingURL=catalog.js.map
474
1194
  //# sourceMappingURL=catalog.js.map