@continuumdao/ctm-mpc-defi 0.2.1 → 0.2.3

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 (57) hide show
  1. package/dist/agent/catalog.cjs +96 -25
  2. package/dist/agent/catalog.cjs.map +1 -1
  3. package/dist/agent/catalog.d.ts +27 -1
  4. package/dist/agent/catalog.js +95 -26
  5. package/dist/agent/catalog.js.map +1 -1
  6. package/dist/agent/skills/curve-dao/SKILL.md +2 -1
  7. package/dist/chains/evm/index.cjs +54 -0
  8. package/dist/chains/evm/index.cjs.map +1 -1
  9. package/dist/chains/evm/index.d.ts +13 -1
  10. package/dist/chains/evm/index.js +52 -2
  11. package/dist/chains/evm/index.js.map +1 -1
  12. package/dist/core/index.cjs +64 -0
  13. package/dist/core/index.cjs.map +1 -1
  14. package/dist/core/index.d.ts +20 -1
  15. package/dist/core/index.js +56 -1
  16. package/dist/core/index.js.map +1 -1
  17. package/dist/index.cjs +165 -14
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +154 -16
  21. package/dist/index.js.map +1 -1
  22. package/dist/protocols/evm/aave-v4/index.cjs +766 -6
  23. package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
  24. package/dist/protocols/evm/aave-v4/index.d.ts +417 -1
  25. package/dist/protocols/evm/aave-v4/index.js +741 -8
  26. package/dist/protocols/evm/aave-v4/index.js.map +1 -1
  27. package/dist/protocols/evm/curve-dao/index.cjs +268 -21
  28. package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
  29. package/dist/protocols/evm/curve-dao/index.d.ts +74 -9
  30. package/dist/protocols/evm/curve-dao/index.js +262 -23
  31. package/dist/protocols/evm/curve-dao/index.js.map +1 -1
  32. package/dist/protocols/evm/ethena/index.cjs +104 -0
  33. package/dist/protocols/evm/ethena/index.cjs.map +1 -1
  34. package/dist/protocols/evm/ethena/index.d.ts +46 -1
  35. package/dist/protocols/evm/ethena/index.js +99 -1
  36. package/dist/protocols/evm/ethena/index.js.map +1 -1
  37. package/dist/protocols/evm/euler-v2/index.cjs +2334 -37
  38. package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
  39. package/dist/protocols/evm/euler-v2/index.d.ts +464 -1
  40. package/dist/protocols/evm/euler-v2/index.js +2286 -39
  41. package/dist/protocols/evm/euler-v2/index.js.map +1 -1
  42. package/dist/protocols/evm/lido/index.cjs +110 -0
  43. package/dist/protocols/evm/lido/index.cjs.map +1 -1
  44. package/dist/protocols/evm/lido/index.d.ts +33 -2
  45. package/dist/protocols/evm/lido/index.js +107 -2
  46. package/dist/protocols/evm/lido/index.js.map +1 -1
  47. package/dist/protocols/evm/maple/index.cjs +83 -0
  48. package/dist/protocols/evm/maple/index.cjs.map +1 -1
  49. package/dist/protocols/evm/maple/index.d.ts +22 -1
  50. package/dist/protocols/evm/maple/index.js +82 -1
  51. package/dist/protocols/evm/maple/index.js.map +1 -1
  52. package/dist/protocols/evm/sky/index.cjs +217 -0
  53. package/dist/protocols/evm/sky/index.cjs.map +1 -1
  54. package/dist/protocols/evm/sky/index.d.ts +56 -1
  55. package/dist/protocols/evm/sky/index.js +210 -2
  56. package/dist/protocols/evm/sky/index.js.map +1 -1
  57. package/package.json +3 -3
@@ -215,44 +215,64 @@ function swappableCurveGraphNodeKeys(adj) {
215
215
  }
216
216
 
217
217
  // src/protocols/evm/curve-dao/apiSession.ts
218
+ var CURVE_SESSION_CACHE_TTL_MS = 5 * 60 * 1e3;
219
+ var curveSessionCache = /* @__PURE__ */ new Map();
218
220
  async function fetchAllCurvePools(curve) {
219
221
  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
- ]);
222
+ const tasks = [];
223
+ for (const key of [
224
+ "factory",
225
+ "crvUSDFactory",
226
+ "EYWAFactory",
227
+ "cryptoFactory",
228
+ "twocryptoFactory",
229
+ "tricryptoFactory",
230
+ "stableNgFactory"
231
+ ]) {
232
+ const f = curve[key];
233
+ if (f?.fetchPools) {
234
+ tasks.push(run(f.fetchPools()));
235
+ }
236
+ }
237
+ await Promise.all(tasks);
229
238
  }
230
239
  async function loadFullCurveSessionForRpc(rpcUrl) {
231
240
  const url = (rpcUrl ?? "").trim();
232
- if (!url) return null;
241
+ if (!url) {
242
+ throw new Error("rpcUrl is required.");
243
+ }
244
+ const cached = curveSessionCache.get(url);
245
+ if (cached && cached.expiresAt > Date.now()) {
246
+ return cached.session;
247
+ }
233
248
  try {
234
249
  const { default: curve } = await import('@curvefi/api');
235
250
  await curve.init("JsonRpc", { url }, {});
236
251
  const wrapped = curve.getNetworkConstants().NATIVE_COIN?.wrappedAddress;
237
252
  if (!curve.hasRouter || !curve.hasRouter()) {
238
- return {
253
+ const session2 = {
239
254
  curve,
240
255
  adj: /* @__PURE__ */ new Map(),
241
256
  swappableNodeKeys: /* @__PURE__ */ new Set(),
242
257
  wrappedNative: wrapped
243
258
  };
259
+ curveSessionCache.set(url, { session: session2, expiresAt: Date.now() + CURVE_SESSION_CACHE_TTL_MS });
260
+ return session2;
244
261
  }
245
262
  await fetchAllCurvePools(curve);
246
263
  const adj = buildCurveLiquidityGraphFromApi(curve);
247
264
  addNativeWethBridge(adj, wrapped);
248
- return {
265
+ const session = {
249
266
  curve,
250
267
  adj,
251
268
  swappableNodeKeys: swappableCurveGraphNodeKeys(adj),
252
269
  wrappedNative: wrapped
253
270
  };
254
- } catch {
255
- return null;
271
+ curveSessionCache.set(url, { session, expiresAt: Date.now() + CURVE_SESSION_CACHE_TTL_MS });
272
+ return session;
273
+ } catch (e) {
274
+ const msg = e instanceof Error ? e.message : String(e);
275
+ throw new Error(`Curve session init failed for RPC: ${msg}`);
256
276
  }
257
277
  }
258
278
 
@@ -270,6 +290,19 @@ var curveDaoProtocolModule = {
270
290
  return token.kind === "native" || token.kind === "erc20";
271
291
  },
272
292
  actions: [
293
+ {
294
+ id: "curve-dao.quote",
295
+ protocolId: CURVE_DAO_PROTOCOL_ID,
296
+ chainCategory: "evm",
297
+ description: "Quote swap via Curve Router NG (getBestRouteAndOutput)",
298
+ commonParams: [],
299
+ params: {
300
+ chainId: { type: "number", required: true, description: "EVM chain id" },
301
+ tokenIn: { type: "address", required: true, description: "Token in or native placeholder" },
302
+ tokenOut: { type: "address", required: true, description: "Token out or native placeholder" },
303
+ amountHuman: { type: "string", required: true, description: "Human-readable input amount" }
304
+ }
305
+ },
273
306
  {
274
307
  id: "curve-dao.swap",
275
308
  protocolId: CURVE_DAO_PROTOCOL_ID,
@@ -490,6 +523,17 @@ var mcpUniswapV4BuildSwapMultisignInputSchema = evmMultisignCommonInputSchema.ex
490
523
  swapDeadlineUnix: zod.z.number().describe("Same deadline passed to create_swap"),
491
524
  slippagePercent: zod.z.number().optional().describe("Extra approve headroom for EXACT_OUTPUT")
492
525
  });
526
+ var mcpCurveDaoQuoteInputSchema = zod.z.object({
527
+ chainId: zod.z.number().int().positive().describe("EVM chain id (rpcUrl resolved from get_chain_registry rpcGateway)"),
528
+ 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"),
529
+ tokenIn: zod.z.string().min(1).describe("Input token address, or 0xeeee\u2026 / 0x0 / eth for native"),
530
+ tokenOut: zod.z.string().min(1).describe("Output token address or 0xeeee\u2026 native placeholder"),
531
+ amountHuman: zod.z.string().min(1).describe("Human-readable amount of tokenIn"),
532
+ tokenInDecimals: zod.z.number().int().min(0).max(18).optional().describe("Token-in decimals; omit to read on-chain (native uses 18)")
533
+ });
534
+ var mcpCurveDaoQuoteOutputSchema = jsonObjectSchema.describe(
535
+ "Curve router quote: { inputAmount, output, route, priceImpactPercent?, tokenInRouterId, tokenOutRouterId }"
536
+ );
493
537
  var mcpCurveDaoBuildSwapMultisignInputSchema = evmMultisignCommonInputSchema.extend({
494
538
  tokenIn: evmAddressSchema.describe("ERC-20 sold (native in uses WETH path in UI)"),
495
539
  tokenOut: zod.z.string().min(1).describe("Output token or 0xeeee\u2026 native placeholder"),
@@ -995,13 +1039,32 @@ var CORE_MCP_TOOL_DEFINITIONS = [
995
1039
  inputZod: mcpUniswapV4BuildSwapMultisignInputSchema,
996
1040
  outputZod: multisignOutputSchema
997
1041
  }),
1042
+ defineMcpTool({
1043
+ name: "ctm_curve_dao_quote",
1044
+ actionId: "curve-dao.quote",
1045
+ protocolId: "curve-dao",
1046
+ chainCategory: "evm",
1047
+ 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.",
1048
+ prerequisites: [
1049
+ "Chain must be supported by Curve (@curvefi/api network constants).",
1050
+ "Configure rpcGateway for chainId in get_chain_registry."
1051
+ ],
1052
+ followUp: ["ctm_curve_dao_build_swap_multisign"],
1053
+ handler: { importPath: "protocols/evm/curve-dao", exportName: "curveDaoQuote" },
1054
+ inputZod: mcpCurveDaoQuoteInputSchema,
1055
+ outputZod: mcpCurveDaoQuoteOutputSchema
1056
+ }),
998
1057
  defineMcpTool({
999
1058
  name: "ctm_curve_dao_build_swap_multisign",
1000
1059
  actionId: "curve-dao.swap",
1001
1060
  protocolId: "curve-dao",
1002
1061
  chainCategory: "evm",
1003
1062
  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.",
1004
- prerequisites: ["keyGen", "executorAddress", "tokenIn/tokenOut/amountHuman/slippage", "RPC URL"],
1063
+ prerequisites: [
1064
+ "ctm_curve_dao_quote (recommended) or known-good route",
1065
+ "keyGenId + chainId + purposeText",
1066
+ "tokenIn/tokenOut/amountHuman/slippagePercent"
1067
+ ],
1005
1068
  followUp: ["Sign messageToSign", "POST /multiSignRequest with clientSig and signedMessage"],
1006
1069
  handler: { importPath: "protocols/evm/curve-dao", exportName: "buildEvmMultisignBodyCurveDaoBatch" },
1007
1070
  inputZod: mcpCurveDaoBuildSwapMultisignInputSchema,
@@ -1226,6 +1289,18 @@ registerProtocolModule(ethenaProtocolModule);
1226
1289
  function isMapleSyrupSupportedChain(chainId) {
1227
1290
  return chainId === 1 || chainId === 11155111;
1228
1291
  }
1292
+ async function postJsonViaOptionalProxy(args) {
1293
+ const r = await fetch(args.directUrl, {
1294
+ method: "POST",
1295
+ headers: { "content-type": "application/json" },
1296
+ body: JSON.stringify(args.body)
1297
+ });
1298
+ if (!r.ok) {
1299
+ const t = await r.text().catch(() => "");
1300
+ throw new Error(t ? `HTTP ${r.status}: ${t.slice(0, 200)}` : `HTTP ${r.status}`);
1301
+ }
1302
+ return await r.json();
1303
+ }
1229
1304
 
1230
1305
  // src/protocols/evm/maple/index.ts
1231
1306
  var MAPLE_PROTOCOL_ID = "maple-syrup";
@@ -1274,16 +1349,10 @@ var skyProtocolModule = {
1274
1349
  registerProtocolModule(skyProtocolModule);
1275
1350
  var AAVE_V4_GRAPHQL_URL = "https://api.v4.aave.com/graphql";
1276
1351
  async function aaveV4Gql(query, variables) {
1277
- const r = await fetch(AAVE_V4_GRAPHQL_URL, {
1278
- method: "POST",
1279
- headers: { "content-type": "application/json" },
1280
- body: JSON.stringify({ query, variables: variables ?? {} })
1281
- });
1282
- if (!r.ok) {
1283
- const t = await r.text().catch(() => "");
1284
- throw new Error(t ? `Aave V4 API HTTP ${r.status}: ${t.slice(0, 200)}` : `Aave V4 API HTTP ${r.status}`);
1285
- }
1286
- const j = await r.json();
1352
+ const body = { query, variables: variables ?? {} };
1353
+ const j = await postJsonViaOptionalProxy({
1354
+ directUrl: AAVE_V4_GRAPHQL_URL,
1355
+ body});
1287
1356
  if (j.errors?.length) {
1288
1357
  const msg = j.errors.map((e) => e.message ?? "Unknown").join("; ");
1289
1358
  throw new Error(msg);
@@ -1719,6 +1788,8 @@ exports.mcpAaveV4DepositInputSchema = mcpAaveV4DepositInputSchema;
1719
1788
  exports.mcpAaveV4RepayInputSchema = mcpAaveV4RepayInputSchema;
1720
1789
  exports.mcpAaveV4WithdrawInputSchema = mcpAaveV4WithdrawInputSchema;
1721
1790
  exports.mcpCurveDaoBuildSwapMultisignInputSchema = mcpCurveDaoBuildSwapMultisignInputSchema;
1791
+ exports.mcpCurveDaoQuoteInputSchema = mcpCurveDaoQuoteInputSchema;
1792
+ exports.mcpCurveDaoQuoteOutputSchema = mcpCurveDaoQuoteOutputSchema;
1722
1793
  exports.mcpEthenaClaimInputSchema = mcpEthenaClaimInputSchema;
1723
1794
  exports.mcpEthenaCooldownInputSchema = mcpEthenaCooldownInputSchema;
1724
1795
  exports.mcpEthenaRedeemInputSchema = mcpEthenaRedeemInputSchema;