@continuumdao/ctm-mpc-defi 0.2.19 → 0.2.22

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 (94) hide show
  1. package/dist/agent/catalog.cjs +303 -93
  2. package/dist/agent/catalog.cjs.map +1 -1
  3. package/dist/agent/catalog.d.ts +985 -709
  4. package/dist/agent/catalog.js +299 -94
  5. package/dist/agent/catalog.js.map +1 -1
  6. package/dist/agent/skills/hyperliquid/SKILL.md +24 -20
  7. package/dist/agent/skills/uniswap-v4/SKILL.md +58 -0
  8. package/dist/chains/evm/index.cjs +6 -2
  9. package/dist/chains/evm/index.cjs.map +1 -1
  10. package/dist/chains/evm/index.d.ts +4 -4
  11. package/dist/chains/evm/index.js +6 -2
  12. package/dist/chains/evm/index.js.map +1 -1
  13. package/dist/chains/near/index.d.ts +1 -1
  14. package/dist/chains/solana/index.d.ts +1 -1
  15. package/dist/core/index.cjs +95 -1
  16. package/dist/core/index.cjs.map +1 -1
  17. package/dist/core/index.d.ts +44 -4
  18. package/dist/core/index.js +91 -2
  19. package/dist/core/index.js.map +1 -1
  20. package/dist/{envelope-CpBUh9eP.d.ts → envelope-C_bfuKab.d.ts} +3 -1
  21. package/dist/index.cjs +96 -2
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.ts +5 -5
  24. package/dist/index.js +93 -4
  25. package/dist/index.js.map +1 -1
  26. package/dist/protocols/evm/aave-v4/index.cjs +6 -2
  27. package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
  28. package/dist/protocols/evm/aave-v4/index.d.ts +1 -1
  29. package/dist/protocols/evm/aave-v4/index.js +6 -2
  30. package/dist/protocols/evm/aave-v4/index.js.map +1 -1
  31. package/dist/protocols/evm/circle-cctp/index.cjs +6 -2
  32. package/dist/protocols/evm/circle-cctp/index.cjs.map +1 -1
  33. package/dist/protocols/evm/circle-cctp/index.d.ts +2 -2
  34. package/dist/protocols/evm/circle-cctp/index.js +6 -2
  35. package/dist/protocols/evm/circle-cctp/index.js.map +1 -1
  36. package/dist/protocols/evm/curve-dao/index.cjs +6 -2
  37. package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
  38. package/dist/protocols/evm/curve-dao/index.d.ts +2 -2
  39. package/dist/protocols/evm/curve-dao/index.js +6 -2
  40. package/dist/protocols/evm/curve-dao/index.js.map +1 -1
  41. package/dist/protocols/evm/ethena/index.cjs +6 -2
  42. package/dist/protocols/evm/ethena/index.cjs.map +1 -1
  43. package/dist/protocols/evm/ethena/index.d.ts +1 -1
  44. package/dist/protocols/evm/ethena/index.js +6 -2
  45. package/dist/protocols/evm/ethena/index.js.map +1 -1
  46. package/dist/protocols/evm/euler-v2/index.cjs +6 -2
  47. package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
  48. package/dist/protocols/evm/euler-v2/index.d.ts +1 -1
  49. package/dist/protocols/evm/euler-v2/index.js +6 -2
  50. package/dist/protocols/evm/euler-v2/index.js.map +1 -1
  51. package/dist/protocols/evm/gmx/index.cjs +54 -22
  52. package/dist/protocols/evm/gmx/index.cjs.map +1 -1
  53. package/dist/protocols/evm/gmx/index.d.ts +22 -8
  54. package/dist/protocols/evm/gmx/index.js +53 -23
  55. package/dist/protocols/evm/gmx/index.js.map +1 -1
  56. package/dist/protocols/evm/hyperliquid/index.cjs +467 -2
  57. package/dist/protocols/evm/hyperliquid/index.cjs.map +1 -1
  58. package/dist/protocols/evm/hyperliquid/index.d.ts +189 -3
  59. package/dist/protocols/evm/hyperliquid/index.js +447 -4
  60. package/dist/protocols/evm/hyperliquid/index.js.map +1 -1
  61. package/dist/protocols/evm/lido/index.cjs +6 -2
  62. package/dist/protocols/evm/lido/index.cjs.map +1 -1
  63. package/dist/protocols/evm/lido/index.d.ts +1 -1
  64. package/dist/protocols/evm/lido/index.js +6 -2
  65. package/dist/protocols/evm/lido/index.js.map +1 -1
  66. package/dist/protocols/evm/maple/index.cjs +6 -2
  67. package/dist/protocols/evm/maple/index.cjs.map +1 -1
  68. package/dist/protocols/evm/maple/index.d.ts +1 -1
  69. package/dist/protocols/evm/maple/index.js +6 -2
  70. package/dist/protocols/evm/maple/index.js.map +1 -1
  71. package/dist/protocols/evm/morpho/index.cjs +6 -2
  72. package/dist/protocols/evm/morpho/index.cjs.map +1 -1
  73. package/dist/protocols/evm/morpho/index.d.ts +1 -1
  74. package/dist/protocols/evm/morpho/index.js +6 -2
  75. package/dist/protocols/evm/morpho/index.js.map +1 -1
  76. package/dist/protocols/evm/permit2/index.cjs +206 -0
  77. package/dist/protocols/evm/permit2/index.cjs.map +1 -0
  78. package/dist/protocols/evm/permit2/index.d.ts +43 -0
  79. package/dist/protocols/evm/permit2/index.js +203 -0
  80. package/dist/protocols/evm/permit2/index.js.map +1 -0
  81. package/dist/protocols/evm/sky/index.cjs +6 -2
  82. package/dist/protocols/evm/sky/index.cjs.map +1 -1
  83. package/dist/protocols/evm/sky/index.d.ts +1 -1
  84. package/dist/protocols/evm/sky/index.js +6 -2
  85. package/dist/protocols/evm/sky/index.js.map +1 -1
  86. package/dist/protocols/evm/uniswap-v4/index.cjs +685 -2
  87. package/dist/protocols/evm/uniswap-v4/index.cjs.map +1 -1
  88. package/dist/protocols/evm/uniswap-v4/index.d.ts +180 -3
  89. package/dist/protocols/evm/uniswap-v4/index.js +663 -3
  90. package/dist/protocols/evm/uniswap-v4/index.js.map +1 -1
  91. package/dist/{registry-Bv5o37_w.d.ts → registry-DxDSPQ-p.d.ts} +1 -1
  92. package/dist/{types-BfjWdw1j.d.ts → types-PZrvtjv8.d.ts} +2 -0
  93. package/dist/{types-DUeNJLr9.d.ts → types-RZWOTm8c.d.ts} +1 -1
  94. package/package.json +8 -2
@@ -89,6 +89,41 @@ function isUniswapV4ChainSupported(chainId) {
89
89
  return typeof a === "string" && a.startsWith("0x");
90
90
  }
91
91
 
92
+ // src/core/defiProxy.ts
93
+ var aaveGraphqlProxyUrl;
94
+ var morphoGraphqlProxyUrl;
95
+ function getAaveGraphqlProxyUrl() {
96
+ return aaveGraphqlProxyUrl;
97
+ }
98
+ function getMorphoGraphqlProxyUrl() {
99
+ return morphoGraphqlProxyUrl;
100
+ }
101
+ async function postJsonViaOptionalProxy(args) {
102
+ const proxy = args.proxyUrl?.trim();
103
+ if (proxy) {
104
+ const r2 = await fetch(proxy, {
105
+ method: "POST",
106
+ headers: { "content-type": "application/json" },
107
+ body: JSON.stringify(args.proxyEnvelope ?? args.body)
108
+ });
109
+ if (!r2.ok) {
110
+ const t = await r2.text().catch(() => "");
111
+ throw new Error(t ? `Proxy HTTP ${r2.status}: ${t.slice(0, 200)}` : `Proxy HTTP ${r2.status}`);
112
+ }
113
+ return await r2.json();
114
+ }
115
+ const r = await fetch(args.directUrl, {
116
+ method: "POST",
117
+ headers: { "content-type": "application/json" },
118
+ body: JSON.stringify(args.body)
119
+ });
120
+ if (!r.ok) {
121
+ const t = await r.text().catch(() => "");
122
+ throw new Error(t ? `HTTP ${r.status}: ${t.slice(0, 200)}` : `HTTP ${r.status}`);
123
+ }
124
+ return await r.json();
125
+ }
126
+
92
127
  // src/protocols/evm/uniswap-v4/index.ts
93
128
  var UNISWAP_V4_PROTOCOL_ID = "uniswap-v4";
94
129
  var uniswapV4ProtocolModule = {
@@ -559,6 +594,15 @@ var agentEvmChainIdSchema = zod.z.preprocess(
559
594
  (val) => parseAgentEvmChainId(val),
560
595
  zod.z.number().int().positive().describe("EVM chain id (decimal, e.g. 8453 for Base \u2014 not 0x8453).")
561
596
  );
597
+ var agentCoercedIntSchema = (schema) => zod.z.coerce.number().pipe(schema);
598
+ var agentCoercedOptionalIntSchema = (schema) => zod.z.preprocess(
599
+ (val) => val === void 0 || val === null || val === "" ? void 0 : val,
600
+ zod.z.coerce.number().pipe(schema).optional()
601
+ );
602
+ var agentCoercedOptionalNumberSchema = (schema) => zod.z.preprocess(
603
+ (val) => val === void 0 || val === null || val === "" ? void 0 : val,
604
+ zod.z.coerce.number().pipe(schema).optional()
605
+ );
562
606
 
563
607
  // src/agent/schemas/common.ts
564
608
  var evmAddressSchema = zod.z.string().min(1).describe("EVM address (0x-prefixed, 40 hex nibbles)");
@@ -571,12 +615,12 @@ var keyGenSchema = zod.z.object({
571
615
  );
572
616
  var chainDetailSchema = zod.z.object({
573
617
  legacy: zod.z.boolean().optional(),
574
- gasLimit: zod.z.number().optional(),
575
- gasMultiplier: zod.z.number().optional(),
576
- gasPrice: zod.z.number().optional(),
577
- baseFee: zod.z.number().optional(),
578
- priorityFee: zod.z.number().optional(),
579
- baseFeeMultiplier: zod.z.number().optional()
618
+ gasLimit: agentCoercedOptionalNumberSchema(zod.z.number()),
619
+ gasMultiplier: agentCoercedOptionalNumberSchema(zod.z.number()),
620
+ gasPrice: agentCoercedOptionalNumberSchema(zod.z.number()),
621
+ baseFee: agentCoercedOptionalNumberSchema(zod.z.number()),
622
+ priorityFee: agentCoercedOptionalNumberSchema(zod.z.number()),
623
+ baseFeeMultiplier: agentCoercedOptionalNumberSchema(zod.z.number())
580
624
  }).passthrough().describe(
581
625
  "Optional gas config: { legacy?, gasLimit?, gasMultiplier?, gasPrice?, baseFee?, priorityFee?, baseFeeMultiplier? }."
582
626
  );
@@ -595,7 +639,10 @@ var evmMultisignCommonInputSchema = zod.z.object({
595
639
  rpcUrl: zod.z.string().min(1).optional().describe("Server-filled from chain registry when keyGenId is set. Agents must not pass rpcUrl."),
596
640
  executorAddress: evmAddressSchema.optional().describe("Server-filled MPC wallet from keyGenId. Agents must not pass executorAddress."),
597
641
  chainDetail: chainDetailSchema.optional().describe("Server-filled gas row from chain registry when keyGenId is set."),
598
- customGasChainDetails: zod.z.record(zod.z.unknown()).optional().describe("Snapshot written to extraJSON.customGasChainDetails when useCustomGas is true.")
642
+ customGasChainDetails: zod.z.record(zod.z.unknown()).optional().describe("Snapshot written to extraJSON.customGasChainDetails when useCustomGas is true."),
643
+ expiryDate: zod.z.number().int().positive().optional().describe(
644
+ "Optional Unix seconds (UTC) when the MPC sign request expires. Uniswap V4, GMX, Hyperliquid, and Curve DAO default to 30 minutes when omitted; other protocols use the node default (7 days)."
645
+ )
599
646
  });
600
647
  function withMultisignKeySourceRefine(schema) {
601
648
  return schema.refine(
@@ -916,7 +963,9 @@ var mcpUniswapV4QuoteOutputSchema = jsonObjectSchema.describe(
916
963
  var mcpUniswapV4CreateSwapInputSchema = zod.z.object({
917
964
  uniswapApiKey: zod.z.string().min(1).describe("Uniswap Trade API key"),
918
965
  fullQuoteFromPermit: jsonObjectSchema.describe("Full quote JSON from ctm_uniswap_v4_quote"),
919
- swapTransactionDeadlineUnix: zod.z.number().int().positive().optional().describe("On-chain deadline unix seconds; default ~30 min from now"),
966
+ swapTransactionDeadlineUnix: agentCoercedOptionalIntSchema(
967
+ zod.z.number().int().positive()
968
+ ).describe("On-chain deadline unix seconds; default ~30 min from now"),
920
969
  useServerProxy: zod.z.boolean().optional().describe("Set false in Node/agents; true only in browser via Next API route"),
921
970
  baseUrl: zod.z.string().optional(),
922
971
  universalRouterVersion: zod.z.string().optional()
@@ -939,8 +988,8 @@ var mcpUniswapV4BuildSwapMultisignInputSchema = withMultisignKeySourceRefine(
939
988
  gasFee: zod.z.string().optional()
940
989
  }).passthrough().describe("Full create_swap response"),
941
990
  fullQuoteSnapshot: jsonObjectSchema.describe("Quote JSON used for the swap"),
942
- swapDeadlineUnix: zod.z.number().describe("Same deadline passed to create_swap"),
943
- slippagePercent: zod.z.number().optional().describe("Extra approve headroom for EXACT_OUTPUT")
991
+ swapDeadlineUnix: agentCoercedIntSchema(zod.z.number()).describe("Same deadline passed to create_swap"),
992
+ slippagePercent: agentCoercedOptionalNumberSchema(zod.z.number()).describe("Extra approve headroom for EXACT_OUTPUT")
944
993
  })
945
994
  )
946
995
  );
@@ -952,8 +1001,8 @@ var lpExistingPoolSchema = zod.z.object({
952
1001
  var lpNewPoolSchema = zod.z.object({
953
1002
  token0Address: evmAddressSchema,
954
1003
  token1Address: evmAddressSchema,
955
- fee: zod.z.number().int().nonnegative(),
956
- tickSpacing: zod.z.number().int().positive(),
1004
+ fee: agentCoercedIntSchema(zod.z.number().int().nonnegative()),
1005
+ tickSpacing: agentCoercedIntSchema(zod.z.number().int().positive()),
957
1006
  hooks: evmAddressSchema.optional(),
958
1007
  initialPrice: zod.z.string().min(1).describe("sqrtRatioX96 string for new pool")
959
1008
  });
@@ -966,14 +1015,14 @@ var lpPriceBoundsSchema = zod.z.object({
966
1015
  maxPrice: zod.z.string().min(1)
967
1016
  });
968
1017
  var lpTickBoundsSchema = zod.z.object({
969
- tickLower: zod.z.number().int(),
970
- tickUpper: zod.z.number().int()
1018
+ tickLower: agentCoercedIntSchema(zod.z.number().int()),
1019
+ tickUpper: agentCoercedIntSchema(zod.z.number().int())
971
1020
  });
972
1021
  var lpCommonApiInputSchema = zod.z.object({
973
1022
  uniswapApiKey: zod.z.string().min(1),
974
1023
  walletAddress: evmAddressSchema.optional(),
975
1024
  chainId: agentEvmChainIdSchema,
976
- slippageTolerance: zod.z.number().optional(),
1025
+ slippageTolerance: agentCoercedOptionalNumberSchema(zod.z.number()),
977
1026
  simulateTransaction: agentOptionalBooleanSchema(),
978
1027
  baseUrl: zod.z.string().optional(),
979
1028
  keyGen: zod.z.string().optional(),
@@ -1034,7 +1083,7 @@ var mcpUniswapV4LpDecreaseInputSchema = zod.z.preprocess(
1034
1083
  token0Address: evmAddressSchema,
1035
1084
  token1Address: evmAddressSchema,
1036
1085
  nftTokenId: zod.z.union([zod.z.string(), zod.z.number()]).describe("tokenId from lp_list_positions"),
1037
- liquidityPercentageToDecrease: zod.z.number().int().min(1).max(100)
1086
+ liquidityPercentageToDecrease: agentCoercedIntSchema(zod.z.number().int().min(1).max(100))
1038
1087
  })
1039
1088
  );
1040
1089
  var mcpUniswapV4LpDecreaseOutputSchema = jsonObjectSchema;
@@ -1126,6 +1175,66 @@ var mcpUniswapV4BuildCollectFeesMultisignInputSchema = withMultisignKeySourceRef
1126
1175
  })
1127
1176
  )
1128
1177
  );
1178
+ var uniswapV4OhlcvIntervalSchema = zod.z.enum([
1179
+ "1m",
1180
+ "5m",
1181
+ "15m",
1182
+ "30m",
1183
+ "1h",
1184
+ "2h",
1185
+ "4h",
1186
+ "6h",
1187
+ "8h",
1188
+ "12h",
1189
+ "1d",
1190
+ "2d",
1191
+ "3d",
1192
+ "1w",
1193
+ "1M"
1194
+ ]);
1195
+ var uniswapV4OhlcvCandleSchema = zod.z.object({
1196
+ timestampMs: zod.z.number(),
1197
+ open: zod.z.string(),
1198
+ high: zod.z.string(),
1199
+ low: zod.z.string(),
1200
+ close: zod.z.string(),
1201
+ volume: zod.z.string().optional()
1202
+ });
1203
+ var uniswapV4ExistingPoolOhlcvSchema = zod.z.object({
1204
+ token0Address: evmAddressSchema,
1205
+ token1Address: evmAddressSchema,
1206
+ poolReference: zod.z.string().min(1).optional(),
1207
+ fee: agentCoercedOptionalIntSchema(zod.z.number().int().nonnegative()).optional(),
1208
+ tickSpacing: agentCoercedOptionalIntSchema(zod.z.number().int().positive()).optional(),
1209
+ hooks: evmAddressSchema.optional()
1210
+ });
1211
+ var mcpUniswapV4FetchOhlcvInputSchema = zod.z.object({
1212
+ chainId: agentEvmChainIdSchema,
1213
+ interval: uniswapV4OhlcvIntervalSchema.optional().describe("Default 1h. Sub-hour uses swaps; \u22651h uses subgraph."),
1214
+ poolPreset: zod.z.string().optional().describe("presetId from ctm_uniswap_v4_list_lp_pools"),
1215
+ poolReference: zod.z.string().optional().describe("bytes32 pool id"),
1216
+ existingPool: uniswapV4ExistingPoolOhlcvSchema.optional(),
1217
+ quoteToken: zod.z.enum(["token0", "token1"]).optional().describe("Default token0 per token1 (subgraph native)"),
1218
+ lookbackDays: agentCoercedOptionalIntSchema(zod.z.number().int().positive().max(365)),
1219
+ lookbackHours: agentCoercedOptionalIntSchema(zod.z.number().int().positive().max(365 * 24)),
1220
+ startTimeMs: agentCoercedOptionalIntSchema(zod.z.number().int().positive()),
1221
+ endTimeMs: agentCoercedOptionalIntSchema(zod.z.number().int().positive())
1222
+ }).strict();
1223
+ var mcpUniswapV4FetchOhlcvOutputSchema = zod.z.object({
1224
+ symbol: zod.z.string(),
1225
+ timeframe: uniswapV4OhlcvIntervalSchema,
1226
+ chainId: agentEvmChainIdSchema,
1227
+ poolReference: zod.z.string(),
1228
+ dataSource: zod.z.enum(["subgraph_native", "subgraph_aggregate", "swaps"]),
1229
+ baseSubgraphEntity: zod.z.enum(["hourly", "daily"]).optional(),
1230
+ priceQuote: zod.z.enum(["token0PerToken1", "token1PerToken0"]),
1231
+ startTimeMs: zod.z.number().int().positive().optional(),
1232
+ endTimeMs: zod.z.number().int().positive().optional(),
1233
+ candleCount: zod.z.number().int().nonnegative(),
1234
+ candles: zod.z.array(uniswapV4OhlcvCandleSchema),
1235
+ fetchedAtMs: zod.z.number(),
1236
+ warnings: zod.z.array(zod.z.string()).optional()
1237
+ }).strict();
1129
1238
  var mcpCurveDaoQuoteInputSchema = zod.z.object({
1130
1239
  chainId: agentEvmChainIdSchema.describe("EVM chain id (rpcUrl resolved from get_chain_registry rpcGateway)"),
1131
1240
  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"),
@@ -1197,7 +1306,7 @@ var mcpMorphoFetchEarnVaultsInputSchema = zod.z.object({
1197
1306
  chainId: agentEvmChainIdSchema,
1198
1307
  underlying: zod.z.string().trim().min(1).optional().describe("Deposit asset symbol (e.g. USDC) or ERC-20 address. Omit to search all listed vaults on the chain."),
1199
1308
  query: zod.z.string().trim().min(1).optional().describe("Case-insensitive filter on vault name, symbol, address, or underlying symbol (e.g. Steakhouse, bbqUSDC)."),
1200
- limit: zod.z.number().int().min(1).max(200).optional().describe("Max rows (default 50).")
1309
+ limit: agentCoercedOptionalIntSchema(zod.z.number().int().min(1).max(200)).describe("Max rows (default 50).")
1201
1310
  });
1202
1311
  var mcpMorphoFetchEarnVaultsOutputSchema = zod.z.object({
1203
1312
  vaults: zod.z.array(
@@ -1225,7 +1334,7 @@ var mcpMorphoFetchBlueMarketsInputSchema = zod.z.object({
1225
1334
  collateral: zod.z.string().trim().min(1).optional().describe("Collateral asset symbol or address (e.g. WETH, cbETH)."),
1226
1335
  loan: zod.z.string().trim().min(1).optional().describe("Loan asset symbol or address (e.g. USDC)."),
1227
1336
  query: zod.z.string().trim().min(1).optional().describe("Filter on market label, symbols, or marketId."),
1228
- limit: zod.z.number().int().min(1).max(200).optional()
1337
+ limit: agentCoercedOptionalIntSchema(zod.z.number().int().min(1).max(200))
1229
1338
  });
1230
1339
  var mcpMorphoFetchBlueMarketsOutputSchema = zod.z.object({
1231
1340
  markets: zod.z.array(
@@ -1322,17 +1431,17 @@ var mcpSkyLockstakeStakeInputSchema = mcpMultisignInput({
1322
1431
  });
1323
1432
  var mcpSkyLockstakeDrawInputSchema = mcpMultisignInput({
1324
1433
  usdsAmountHuman: zod.z.string().min(1),
1325
- urnIndex: zod.z.number().int().nonnegative()
1434
+ urnIndex: agentCoercedIntSchema(zod.z.number().int().nonnegative())
1326
1435
  });
1327
1436
  var mcpSkyLockstakeWipeInputSchema = mcpMultisignInput({
1328
1437
  usdsAmountHuman: zod.z.string().min(1),
1329
- urnIndex: zod.z.number().int().nonnegative()
1438
+ urnIndex: agentCoercedIntSchema(zod.z.number().int().nonnegative())
1330
1439
  });
1331
1440
  var mcpSkyLockstakeCloseInputSchema = mcpMultisignInput({
1332
- urnIndex: zod.z.number().int().nonnegative()
1441
+ urnIndex: agentCoercedIntSchema(zod.z.number().int().nonnegative())
1333
1442
  });
1334
1443
  var mcpSkyLockstakeGetRewardInputSchema = mcpMultisignInput({
1335
- urnIndex: zod.z.number().int().nonnegative()
1444
+ urnIndex: agentCoercedIntSchema(zod.z.number().int().nonnegative())
1336
1445
  });
1337
1446
  var mcpSkySusdsDepositInputSchema = mcpMultisignInput({
1338
1447
  usdsAmountHuman: zod.z.string().min(1)
@@ -1504,7 +1613,7 @@ var mcpMorphoBlueRepayInputSchema = withMultisignKeySourceRefine(
1504
1613
  var mcpMorphoBlueCollateralWithdrawInputSchema = mcpMultisignInput({
1505
1614
  marketId: zod.z.string().min(1),
1506
1615
  amountHuman: zod.z.string().min(1),
1507
- collateralDecimals: zod.z.number().int().min(0).max(36).optional()
1616
+ collateralDecimals: agentCoercedOptionalIntSchema(zod.z.number().int().min(0).max(36))
1508
1617
  });
1509
1618
  var mcpMorphoMerklClaimInputSchema = mcpMultisignInput({
1510
1619
  claimData: zod.z.string().min(1).describe("Hex calldata for Merkl Distributor.claim from Merkl API."),
@@ -1516,7 +1625,7 @@ var mcpEulerV2FetchLendVaultsInputSchema = zod.z.object({
1516
1625
  underlyingAddress: evmAddressSchema.describe(
1517
1626
  "Underlying asset address from get_defi_protocol_supported_tokens."
1518
1627
  ),
1519
- limit: zod.z.number().int().min(1).max(100).optional().describe("Max vault rows (default 30).")
1628
+ limit: agentCoercedOptionalIntSchema(zod.z.number().int().min(1).max(100)).describe("Max vault rows (default 30).")
1520
1629
  });
1521
1630
  var mcpEulerV2FetchLendVaultsOutputSchema = zod.z.object({
1522
1631
  vaults: zod.z.array(
@@ -1599,8 +1708,9 @@ var mcpGmxIncreaseInputSchema = mcpGmxMultisignInput(
1599
1708
  collateralToken: zod.z.string().min(1),
1600
1709
  collateralAmountHuman: zod.z.string().min(1),
1601
1710
  triggerPriceUsdHuman: zod.z.string().optional(),
1602
- slippageBps: zod.z.number().int().nonnegative().optional(),
1603
- executionFeeBufferBps: zod.z.number().int().nonnegative().optional()
1711
+ patternFailureUsdHuman: zod.z.string().optional(),
1712
+ slippageBps: agentCoercedOptionalIntSchema(zod.z.number().int().nonnegative()),
1713
+ executionFeeBufferBps: agentCoercedOptionalIntSchema(zod.z.number().int().nonnegative())
1604
1714
  },
1605
1715
  preprocessGmxIncreaseInput
1606
1716
  );
@@ -1614,8 +1724,8 @@ var mcpGmxDecreaseInputSchema = mcpGmxMultisignInput(
1614
1724
  receiveToken: zod.z.string().optional(),
1615
1725
  triggerPriceUsdHuman: zod.z.string().optional(),
1616
1726
  keepLeverage: agentOptionalBooleanSchema(),
1617
- slippageBps: zod.z.number().int().nonnegative().optional(),
1618
- executionFeeBufferBps: zod.z.number().int().nonnegative().optional()
1727
+ slippageBps: agentCoercedOptionalIntSchema(zod.z.number().int().nonnegative()),
1728
+ executionFeeBufferBps: agentCoercedOptionalIntSchema(zod.z.number().int().nonnegative())
1619
1729
  },
1620
1730
  preprocessGmxDecreaseInput
1621
1731
  );
@@ -1627,7 +1737,7 @@ var mcpGmxGmDepositInputSchema = mcpGmxMultisignInput(
1627
1737
  marketSymbol: zod.z.string().min(1).describe("symbol from ctm_gmx_fetch_gm_markets"),
1628
1738
  collateralToken: zod.z.string().min(1).describe("longTokenSymbol or shortTokenSymbol from GM market row"),
1629
1739
  collateralAmountHuman: zod.z.string().min(1),
1630
- executionFeeBufferBps: zod.z.number().int().nonnegative().optional(),
1740
+ executionFeeBufferBps: agentCoercedOptionalIntSchema(zod.z.number().int().nonnegative()),
1631
1741
  isNativeIn: agentOptionalBooleanSchema(),
1632
1742
  nativeWrapped: evmAddressSchema.optional()
1633
1743
  },
@@ -1637,19 +1747,19 @@ var mcpGmxGmWithdrawInputSchema = mcpGmxMultisignInput(
1637
1747
  {
1638
1748
  marketSymbol: zod.z.string().min(1).describe("symbol from ctm_gmx_fetch_gm_markets"),
1639
1749
  gmAmountHuman: zod.z.string().min(1),
1640
- gmDecimals: zod.z.number().int().nonnegative().optional(),
1641
- executionFeeBufferBps: zod.z.number().int().nonnegative().optional(),
1750
+ gmDecimals: agentCoercedOptionalIntSchema(zod.z.number().int().nonnegative()),
1751
+ executionFeeBufferBps: agentCoercedOptionalIntSchema(zod.z.number().int().nonnegative()),
1642
1752
  isNativeOut: agentOptionalBooleanSchema()
1643
1753
  },
1644
1754
  preprocessGmxGmBuildInput
1645
1755
  );
1646
1756
  var mcpGmxStakeGmxInputSchema = mcpGmxMultisignInput({
1647
1757
  amountHuman: zod.z.string().min(1),
1648
- gmxDecimals: zod.z.number().int().nonnegative().optional()
1758
+ gmxDecimals: agentCoercedOptionalIntSchema(zod.z.number().int().nonnegative())
1649
1759
  });
1650
1760
  var mcpGmxUnstakeGmxInputSchema = mcpGmxMultisignInput({
1651
1761
  amountHuman: zod.z.string().min(1),
1652
- gmxDecimals: zod.z.number().int().nonnegative().optional()
1762
+ gmxDecimals: agentCoercedOptionalIntSchema(zod.z.number().int().nonnegative())
1653
1763
  });
1654
1764
  var mcpGmxFetchGmMarketsInputSchema = gmxFetchChainInputSchema;
1655
1765
  var mcpGmxGmMarketApyRowSchema = zod.z.object({
@@ -1714,12 +1824,16 @@ var mcpGmxFetchOhlcvInputSchema = zod.z.object({
1714
1824
  chainId: agentEvmChainIdSchema,
1715
1825
  symbol: zod.z.string().min(1),
1716
1826
  timeframe: gmxOhlcvTimeframeSchema.optional(),
1717
- limit: zod.z.number().int().positive().max(500).optional(),
1827
+ limit: agentCoercedOptionalIntSchema(zod.z.number().int().positive().max(500)),
1718
1828
  sort: zod.z.enum(["asc", "desc"]).optional()
1719
1829
  });
1720
1830
  var mcpGmxFetchOhlcvOutputSchema = zod.z.object({
1721
1831
  symbol: zod.z.string(),
1722
1832
  timeframe: gmxOhlcvTimeframeSchema,
1833
+ chainId: agentEvmChainIdSchema,
1834
+ startTimeMs: zod.z.number().int().positive().optional(),
1835
+ endTimeMs: zod.z.number().int().positive().optional(),
1836
+ candleCount: zod.z.number().int().nonnegative(),
1723
1837
  candles: zod.z.array(gmxOhlcvCandleSchema)
1724
1838
  });
1725
1839
  function mcpHyperliquidMultisignInput(fields, preprocess) {
@@ -1745,7 +1859,7 @@ var hyperliquidOhlcvIntervalSchema = zod.z.enum([
1745
1859
  "1M"
1746
1860
  ]);
1747
1861
  var hyperliquidFetchChainInputSchema = zod.z.object({
1748
- chainId: agentEvmChainIdSchema
1862
+ chainId: zod.z.coerce.number().int().positive().default(999).describe("Hyperliquid EVM chain id (999 mainnet, 998 testnet).")
1749
1863
  });
1750
1864
  var hyperliquidPositionRowSchema = zod.z.object({
1751
1865
  key: zod.z.string(),
@@ -1796,7 +1910,7 @@ var mcpHyperliquidFetchMarketsOutputSchema = zod.z.object({
1796
1910
  var mcpHyperliquidSearchMarketsInputSchema = hyperliquidFetchChainInputSchema.extend({
1797
1911
  query: zod.z.string().min(1),
1798
1912
  dex: zod.z.string().optional(),
1799
- limit: zod.z.number().int().positive().max(50).optional()
1913
+ limit: agentCoercedOptionalIntSchema(zod.z.number().int().positive().max(50))
1800
1914
  });
1801
1915
  var mcpHyperliquidSearchMarketsOutputSchema = zod.z.object({
1802
1916
  matches: zod.z.array(
@@ -1855,7 +1969,7 @@ var mcpHyperliquidFetchMarketSnapshotInputSchema = hyperliquidFetchChainInputSch
1855
1969
  coin: zod.z.string().min(1),
1856
1970
  interval: hyperliquidOhlcvIntervalSchema.optional(),
1857
1971
  dex: zod.z.string().optional(),
1858
- candleLimit: zod.z.number().int().positive().max(200).optional()
1972
+ candleLimit: agentCoercedOptionalIntSchema(zod.z.number().int().positive().max(200))
1859
1973
  });
1860
1974
  var hyperliquidOhlcvCandleSchema = zod.z.object({
1861
1975
  timestampMs: zod.z.number(),
@@ -1892,10 +2006,10 @@ var mcpHyperliquidFetchOhlcvInputSchema = hyperliquidFetchChainInputSchema.exten
1892
2006
  coin: zod.z.string().min(1),
1893
2007
  interval: hyperliquidOhlcvIntervalSchema.optional(),
1894
2008
  dex: zod.z.string().optional(),
1895
- lookbackDays: zod.z.number().positive().max(90).optional(),
1896
- lookbackHours: zod.z.number().positive().max(90 * 24).optional(),
1897
- startTimeMs: zod.z.number().int().positive().optional(),
1898
- endTimeMs: zod.z.number().int().positive().optional()
2009
+ lookbackDays: agentCoercedOptionalIntSchema(zod.z.number().int().positive().max(90)),
2010
+ lookbackHours: agentCoercedOptionalIntSchema(zod.z.number().int().positive().max(90 * 24)),
2011
+ startTimeMs: agentCoercedOptionalIntSchema(zod.z.number().int().positive()),
2012
+ endTimeMs: agentCoercedOptionalIntSchema(zod.z.number().int().positive())
1899
2013
  });
1900
2014
  var mcpHyperliquidFetchOhlcvOutputSchema = zod.z.object({
1901
2015
  ohlcv: zod.z.object({
@@ -1992,7 +2106,7 @@ var mcpHyperliquidCloseInputSchema = mcpHyperliquidMultisignInput(
1992
2106
  var mcpHyperliquidCancelInputSchema = mcpHyperliquidMultisignInput(
1993
2107
  {
1994
2108
  coin: zod.z.string().min(1),
1995
- oid: zod.z.number().int().positive().describe("oid from fetch_open_orders"),
2109
+ oid: agentCoercedIntSchema(zod.z.number().int().positive()).describe("oid from fetch_open_orders"),
1996
2110
  marketKind: zod.z.enum(["perp", "spot"]).optional(),
1997
2111
  dex: zod.z.string().optional()
1998
2112
  },
@@ -2002,6 +2116,13 @@ var mcpHyperliquidUsdTransferInputSchema = mcpHyperliquidMultisignInput({
2002
2116
  usdHuman: zod.z.string().min(1),
2003
2117
  toPerp: agentBooleanSchema()
2004
2118
  });
2119
+ var mcpHyperliquidBridgeDepositInputSchema = mcpHyperliquidMultisignInput({
2120
+ usdHuman: zod.z.string().min(1).describe("USDC amount (minimum 5)")
2121
+ });
2122
+ var mcpHyperliquidBridgeWithdrawInputSchema = mcpHyperliquidMultisignInput({
2123
+ usdHuman: zod.z.string().min(1),
2124
+ destination: evmAddressSchema.optional().describe("Arbitrum recipient; defaults to executor")
2125
+ });
2005
2126
  var mcpHyperliquidVaultDepositInputSchema = mcpHyperliquidMultisignInput(
2006
2127
  {
2007
2128
  vaultAddress: evmAddressSchema.describe("vaultAddress from fetch_vaults"),
@@ -2034,6 +2155,16 @@ var mcpHyperliquidUndelegateInputSchema = mcpHyperliquidMultisignInput(
2034
2155
  },
2035
2156
  preprocessHyperliquidUndelegateInput
2036
2157
  );
2158
+ var mcpHyperliquidUpdateLeverageInputSchema = mcpHyperliquidMultisignInput(
2159
+ {
2160
+ coin: zod.z.string().min(1).describe("coin from fetch_markets, search_markets, or open_context"),
2161
+ leverage: agentCoercedIntSchema(zod.z.number().int().positive()).describe("Target leverage (1..maxLeverage from market row)"),
2162
+ isCross: agentBooleanSchema().optional().describe("true = cross margin (default); false = isolated margin for this market"),
2163
+ marketKind: zod.z.enum(["perp", "spot"]).optional().describe("perp (default)"),
2164
+ dex: zod.z.string().optional().describe("HIP-3 dex when applicable")
2165
+ },
2166
+ preprocessHyperliquidCoinInput
2167
+ );
2037
2168
  var mcpCctpFeeFieldsSchema = zod.z.object({
2038
2169
  feeTierUsed: zod.z.enum(["low", "med", "high"]),
2039
2170
  maxFee: zod.z.string().describe("Selected tier max fee in USDC base units (6 decimals)"),
@@ -2084,7 +2215,7 @@ var mcpCctpFetchUsdcBalanceOutputSchema = jsonObjectSchema.describe(
2084
2215
  );
2085
2216
  var mcpCctpFetchTransferStatusInputSchema = zod.z.object({
2086
2217
  sourceChainId: agentEvmChainIdSchema.describe("Source chain where burn was executed"),
2087
- sourceDomain: zod.z.number().int().min(0).describe("CCTP domain id of source chain"),
2218
+ sourceDomain: agentCoercedIntSchema(zod.z.number().int().min(0)).describe("CCTP domain id of source chain"),
2088
2219
  burnTxHash: zod.z.string().min(1).describe("Burn transaction hash (0x-prefixed or raw)")
2089
2220
  });
2090
2221
  var mcpCctpFetchTransferStatusOutputSchema = jsonObjectSchema.describe(
@@ -2095,7 +2226,7 @@ var mcpCctpBuildBurnMultisignInputSchema = mcpMultisignInput({
2095
2226
  transferAmountHuman: zod.z.string().min(1).describe("Human USDC amount recipient receives"),
2096
2227
  mintRecipient: evmAddressSchema.optional().describe("Recipient on destination chain; defaults to MPC executor address"),
2097
2228
  feeTier: zod.z.enum(["low", "med", "high"]).optional(),
2098
- minFinalityThreshold: zod.z.number().int().positive().optional(),
2229
+ minFinalityThreshold: agentCoercedOptionalIntSchema(zod.z.number().int().positive()),
2099
2230
  feeSnapshot: jsonObjectSchema.optional().describe("Optional output from ctm_cctp_fetch_burn_fees")
2100
2231
  });
2101
2232
 
@@ -2593,6 +2724,32 @@ var MCP_PROTOCOL_TOOL_DEFINITIONS = [
2593
2724
  },
2594
2725
  inputZod: mcpHyperliquidUsdTransferInputSchema
2595
2726
  }),
2727
+ defineProtocolMcpTool({
2728
+ name: "ctm_hyperliquid_build_bridge_deposit_multisign",
2729
+ actionId: "hyperliquid.bridgeDeposit",
2730
+ protocolId: "hyperliquid",
2731
+ chainCategory: "evm",
2732
+ description: "Create and submit mpc-auth multiSignRequest to deposit USDC from Arbitrum to Hyperliquid via Bridge2 (ERC20 transfer). chainId must be Arbitrum One (42161) or Arbitrum Sepolia (421614). Minimum 5 USDC.",
2733
+ prerequisites: ["keyGen", "executorAddress", "Arbitrum USDC balance", "usdHuman (min 5)"],
2734
+ handler: {
2735
+ importPath: "protocols/evm/hyperliquid",
2736
+ exportName: "buildEvmMultisignBodyHyperliquidBridgeDepositBatch"
2737
+ },
2738
+ inputZod: mcpHyperliquidBridgeDepositInputSchema
2739
+ }),
2740
+ defineProtocolMcpTool({
2741
+ name: "ctm_hyperliquid_build_bridge_withdraw_multisign",
2742
+ actionId: "hyperliquid.bridgeWithdraw",
2743
+ protocolId: "hyperliquid",
2744
+ chainCategory: "evm",
2745
+ description: "Create and submit mpc-auth multiSignRequest to withdraw USDC from Hyperliquid to Arbitrum via withdraw3 (EIP-712, delivered to /exchange). chainId 999 or 998. ~1 USDC bridge fee on Hyperliquid.",
2746
+ prerequisites: ["keyGen", "executorAddress", "Hyperliquid withdrawable balance", "usdHuman"],
2747
+ handler: {
2748
+ importPath: "protocols/evm/hyperliquid",
2749
+ exportName: "buildHyperliquidBridgeWithdrawMultisign"
2750
+ },
2751
+ inputZod: mcpHyperliquidBridgeWithdrawInputSchema
2752
+ }),
2596
2753
  defineProtocolMcpTool({
2597
2754
  name: "ctm_hyperliquid_build_vault_deposit_multisign",
2598
2755
  actionId: "hyperliquid.vaultDeposit",
@@ -2653,6 +2810,27 @@ var MCP_PROTOCOL_TOOL_DEFINITIONS = [
2653
2810
  handler: { importPath: "protocols/evm/hyperliquid", exportName: "buildEvmMultisignBodyHyperliquidUndelegateBatch" },
2654
2811
  inputZod: mcpHyperliquidUndelegateInputSchema
2655
2812
  }),
2813
+ defineProtocolMcpTool({
2814
+ name: "ctm_hyperliquid_build_update_leverage_multisign",
2815
+ actionId: "hyperliquid.updateLeverage",
2816
+ protocolId: "hyperliquid",
2817
+ chainCategory: "evm",
2818
+ description: "Set per-market leverage (cross or isolated) on Hyperliquid via L1 /exchange EIP-712 signing \u2014 not CoreWriter, no EVM gas at propose/trigger.",
2819
+ prerequisites: [
2820
+ "keyGenId",
2821
+ "chainId 999 or 998",
2822
+ "coin",
2823
+ "leverage <= maxLeverage from fetch_markets or open_context",
2824
+ "ctm_hyperliquid_fetch_open_context for current leverageLabel"
2825
+ ],
2826
+ followUp: [
2827
+ "sign_request_agree",
2828
+ "trigger_sign_result",
2829
+ "broadcast_sign_result"
2830
+ ],
2831
+ handler: { importPath: "protocols/evm/hyperliquid", exportName: "buildHyperliquidUpdateLeverageMultisign" },
2832
+ inputZod: mcpHyperliquidUpdateLeverageInputSchema
2833
+ }),
2656
2834
  defineProtocolMcpTool({
2657
2835
  name: "ctm_cctp_build_burn_multisign",
2658
2836
  actionId: "circle-cctp.burn-forward",
@@ -2750,11 +2928,27 @@ var CORE_MCP_TOOL_DEFINITIONS = [
2750
2928
  chainCategory: "evm",
2751
2929
  description: "List standard Uniswap V4 LP pools for a chain (ETH/USDC and other main pairs at common fee tiers). Returns presetId, token addresses, fee, tickSpacing, and computed poolReference (bytes32 pool id). Use presetId as poolPreset on lp_create_position.",
2752
2930
  prerequisites: ["chainId"],
2753
- followUp: ["ctm_uniswap_v4_lp_create_position"],
2931
+ followUp: ["ctm_uniswap_v4_lp_create_position", "ctm_uniswap_v4_fetch_ohlcv"],
2754
2932
  handler: { importPath: "protocols/evm/uniswap-v4", exportName: "uniswapV4ListStandardLpPools" },
2755
2933
  inputZod: mcpUniswapV4LpListPoolsInputSchema,
2756
2934
  outputZod: mcpUniswapV4LpListPoolsOutputSchema
2757
2935
  }),
2936
+ defineMcpTool({
2937
+ name: "ctm_uniswap_v4_fetch_ohlcv",
2938
+ actionId: "uniswap-v4.fetch-ohlcv",
2939
+ protocolId: "uniswap-v4",
2940
+ chainCategory: "evm",
2941
+ description: "Pool OHLCV from Uniswap V4 subgraph: native 1h/1d, aggregated multiples (4h/1w/etc.), or swap bucketing for sub-hour (15m). Read-only; does not use Trade API key. Optional THE_GRAPH_API_KEY env for gateway rate limits.",
2942
+ prerequisites: [
2943
+ "chainId with pinned v4 subgraph",
2944
+ "poolPreset or poolReference or existingPool",
2945
+ "interval + lookbackDays or lookbackHours or startTimeMs"
2946
+ ],
2947
+ followUp: ["ctm_uniswap_v4_list_lp_pools", "continuum__prepare_chart_from_rows"],
2948
+ handler: { importPath: "protocols/evm/uniswap-v4", exportName: "uniswapV4FetchOhlcv" },
2949
+ inputZod: mcpUniswapV4FetchOhlcvInputSchema,
2950
+ outputZod: mcpUniswapV4FetchOhlcvOutputSchema
2951
+ }),
2758
2952
  defineMcpTool({
2759
2953
  name: "ctm_uniswap_v4_lp_create_position",
2760
2954
  actionId: "uniswap-v4.lp-create",
@@ -3041,7 +3235,7 @@ var CORE_MCP_TOOL_DEFINITIONS = [
3041
3235
  chainCategory: "evm",
3042
3236
  description: "List Hyperliquid perp markets (native + all HIP-3 dexes when dex omitted). Each market has coin name, maxLeverage, szDecimals, and optional dex (e.g. xyz for xyz:AAPL). chainId 999 mainnet or 998 testnet.",
3043
3237
  prerequisites: ["chainId 999 or 998"],
3044
- followUp: ["ctm_hyperliquid_fetch_open_context", "ctm_hyperliquid_build_limit_order_multisign"],
3238
+ followUp: ["ctm_hyperliquid_fetch_open_context", "ctm_hyperliquid_build_limit_order_multisign", "ctm_hyperliquid_build_update_leverage_multisign"],
3045
3239
  handler: { importPath: "protocols/evm/hyperliquid", exportName: "hyperliquidFetchMarketsSummary" },
3046
3240
  inputZod: mcpHyperliquidFetchMarketsInputSchema,
3047
3241
  outputZod: mcpHyperliquidFetchMarketsOutputSchema
@@ -3053,7 +3247,7 @@ var CORE_MCP_TOOL_DEFINITIONS = [
3053
3247
  chainCategory: "evm",
3054
3248
  description: "Search Hyperliquid perp markets across all dexes by ticker (AAPL, BTC), display name, or keyword (Apple, tesla). Case-insensitive. Returns canonical coin names (e.g. xyz:AAPL).",
3055
3249
  prerequisites: ["chainId 999 or 998", "query"],
3056
- followUp: ["ctm_hyperliquid_fetch_open_context", "ctm_hyperliquid_build_limit_order_multisign"],
3250
+ followUp: ["ctm_hyperliquid_fetch_open_context", "ctm_hyperliquid_build_limit_order_multisign", "ctm_hyperliquid_build_update_leverage_multisign"],
3057
3251
  handler: { importPath: "protocols/evm/hyperliquid", exportName: "hyperliquidSearchMarketsSummary" },
3058
3252
  inputZod: mcpHyperliquidSearchMarketsInputSchema,
3059
3253
  outputZod: mcpHyperliquidSearchMarketsOutputSchema
@@ -3065,7 +3259,7 @@ var CORE_MCP_TOOL_DEFINITIONS = [
3065
3259
  chainCategory: "evm",
3066
3260
  description: "Per-market trading context: account value, withdrawable, margin used, leverage setting, mark price, available buy/sell size. Resolves ticker/name (AAPL, Apple) across dexes.",
3067
3261
  prerequisites: ["chainId", "executorAddress", "coin from fetch_markets"],
3068
- followUp: ["ctm_hyperliquid_build_limit_order_multisign"],
3262
+ followUp: ["ctm_hyperliquid_build_limit_order_multisign", "ctm_hyperliquid_build_update_leverage_multisign"],
3069
3263
  handler: { importPath: "protocols/evm/hyperliquid", exportName: "hyperliquidFetchOpenContextSummary" },
3070
3264
  inputZod: mcpHyperliquidFetchOpenContextInputSchema,
3071
3265
  outputZod: mcpHyperliquidFetchOpenContextOutputSchema
@@ -3101,7 +3295,7 @@ var CORE_MCP_TOOL_DEFINITIONS = [
3101
3295
  chainCategory: "evm",
3102
3296
  description: "Live mark/mid price plus recent OHLCV candles for a Hyperliquid perp. Uses metaAndAssetCtxs for live prices (not stale candle close). Default interval 15m, 48 bars. Throws if live price unavailable.",
3103
3297
  prerequisites: ["chainId", "coin"],
3104
- followUp: ["ctm_hyperliquid_fetch_open_context", "ctm_hyperliquid_build_limit_order_multisign"],
3298
+ followUp: ["ctm_hyperliquid_fetch_open_context", "ctm_hyperliquid_build_limit_order_multisign", "ctm_hyperliquid_build_update_leverage_multisign"],
3105
3299
  handler: { importPath: "protocols/evm/hyperliquid", exportName: "hyperliquidFetchMarketSnapshotSummary" },
3106
3300
  inputZod: mcpHyperliquidFetchMarketSnapshotInputSchema,
3107
3301
  outputZod: mcpHyperliquidFetchMarketSnapshotOutputSchema
@@ -3111,7 +3305,7 @@ var CORE_MCP_TOOL_DEFINITIONS = [
3111
3305
  actionId: "hyperliquid.fetch-ohlcv",
3112
3306
  protocolId: "hyperliquid",
3113
3307
  chainCategory: "evm",
3114
- description: "OHLCV candle history for a Hyperliquid perp over an explicit lookback or time range. Requests only the needed window from Hyperliquid (e.g. lookbackDays: 7, interval: 15m \u2192 ~672 bars). Max 2000 bars \u2014 use coarser interval for longer history. Resolves ticker/name across dexes.",
3308
+ description: 'OHLCV candle history for a Hyperliquid perp over an explicit lookback or time range. Set lookbackDays to match the operator request exactly (e.g. "last 7 days" \u2192 lookbackDays: 7, interval: 1h \u2192 ~169 bars). Max 2000 bars \u2014 use coarser interval for longer history. Resolves ticker/name across dexes.',
3115
3309
  prerequisites: ["chainId 999 or 998", "coin", "lookbackDays or lookbackHours or startTimeMs"],
3116
3310
  followUp: ["ctm_hyperliquid_fetch_market_snapshot", "continuum__prepare_chart_from_rows", "ctm_hyperliquid_build_limit_order_multisign"],
3117
3311
  handler: { importPath: "protocols/evm/hyperliquid", exportName: "hyperliquidFetchOhlcvSummary" },
@@ -3495,41 +3689,6 @@ function isMapleSyrupSupportedChain(chainId) {
3495
3689
  return chainId === 1 || chainId === 11155111;
3496
3690
  }
3497
3691
 
3498
- // src/core/defiProxy.ts
3499
- var aaveGraphqlProxyUrl;
3500
- var morphoGraphqlProxyUrl;
3501
- function getAaveGraphqlProxyUrl() {
3502
- return aaveGraphqlProxyUrl;
3503
- }
3504
- function getMorphoGraphqlProxyUrl() {
3505
- return morphoGraphqlProxyUrl;
3506
- }
3507
- async function postJsonViaOptionalProxy(args) {
3508
- const proxy = args.proxyUrl?.trim();
3509
- if (proxy) {
3510
- const r2 = await fetch(proxy, {
3511
- method: "POST",
3512
- headers: { "content-type": "application/json" },
3513
- body: JSON.stringify(args.proxyEnvelope ?? args.body)
3514
- });
3515
- if (!r2.ok) {
3516
- const t = await r2.text().catch(() => "");
3517
- throw new Error(t ? `Proxy HTTP ${r2.status}: ${t.slice(0, 200)}` : `Proxy HTTP ${r2.status}`);
3518
- }
3519
- return await r2.json();
3520
- }
3521
- const r = await fetch(args.directUrl, {
3522
- method: "POST",
3523
- headers: { "content-type": "application/json" },
3524
- body: JSON.stringify(args.body)
3525
- });
3526
- if (!r.ok) {
3527
- const t = await r.text().catch(() => "");
3528
- throw new Error(t ? `HTTP ${r.status}: ${t.slice(0, 200)}` : `HTTP ${r.status}`);
3529
- }
3530
- return await r.json();
3531
- }
3532
-
3533
3692
  // src/protocols/evm/maple/index.ts
3534
3693
  var MAPLE_PROTOCOL_ID = "maple-syrup";
3535
3694
  var mapleProtocolModule = {
@@ -3699,11 +3858,15 @@ function isGmxChainSupported(chainId) {
3699
3858
  }
3700
3859
  var require2 = module$1.createRequire(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))));
3701
3860
  var { GmxApiSdk } = require2("@gmx-io/sdk/v2");
3861
+ var { getApiUrl, getApiFallbackUrls } = require2("@gmx-io/sdk/configs/api");
3702
3862
  var GMX_HTTP_TIMEOUT_MS = 3e4;
3703
- var GMX_API_BASE_URLS = {
3704
- 42161: ["https://arbitrum.gmxapi.io", "https://arbitrum.gmxapi.ai"],
3705
- 43114: ["https://avalanche.gmxapi.io", "https://avalanche.gmxapi.ai"]
3706
- };
3863
+ function gmxResolvedApiBaseUrls(chainId) {
3864
+ const primary = getApiUrl(chainId);
3865
+ if (!primary) {
3866
+ throw new Error(`GMX API URLs are not configured for chain ${chainId}.`);
3867
+ }
3868
+ return [primary, ...getApiFallbackUrls(chainId)];
3869
+ }
3707
3870
  function buildGmxUrl(baseUrl, path, query) {
3708
3871
  const base = baseUrl.replace(/\/$/, "");
3709
3872
  if (!query) return `${base}${path}`;
@@ -3768,10 +3931,7 @@ async function gmxHttpPostJson(baseUrl, path, body, opts) {
3768
3931
  }
3769
3932
  }
3770
3933
  function createIoFirstGmxHttpApi(chainId) {
3771
- const urls = GMX_API_BASE_URLS[chainId];
3772
- if (!urls) {
3773
- throw new Error(`GMX API URLs are not configured for chain ${chainId}.`);
3774
- }
3934
+ const urls = gmxResolvedApiBaseUrls(chainId);
3775
3935
  async function withIoFirstFallback(fn) {
3776
3936
  let lastError;
3777
3937
  for (const baseUrl of urls) {
@@ -4042,6 +4202,40 @@ var hyperliquidProtocolModule = {
4042
4202
  validator: { type: "string", required: true, description: "Validator address" }
4043
4203
  }
4044
4204
  },
4205
+ {
4206
+ id: "hyperliquid.bridgeDeposit",
4207
+ protocolId: HYPERLIQUID_PROTOCOL_ID,
4208
+ chainCategory: "evm",
4209
+ description: "Deposit USDC from Arbitrum to Hyperliquid via Bridge2 (ERC20 transfer)",
4210
+ commonParams: ["keyGen", "purposeText", "useCustomGas"],
4211
+ params: {
4212
+ usdHuman: { type: "string", required: true, description: "USDC amount (min 5)" }
4213
+ }
4214
+ },
4215
+ {
4216
+ id: "hyperliquid.bridgeWithdraw",
4217
+ protocolId: HYPERLIQUID_PROTOCOL_ID,
4218
+ chainCategory: "evm",
4219
+ description: "Withdraw USDC from Hyperliquid to Arbitrum via withdraw3 (EIP-712 /exchange)",
4220
+ commonParams: ["keyGen", "purposeText"],
4221
+ params: {
4222
+ usdHuman: { type: "string", required: true, description: "USDC amount" },
4223
+ destination: { type: "string", required: false, description: "Arbitrum recipient (defaults to executor)" }
4224
+ }
4225
+ },
4226
+ {
4227
+ id: "hyperliquid.updateLeverage",
4228
+ protocolId: HYPERLIQUID_PROTOCOL_ID,
4229
+ chainCategory: "evm",
4230
+ description: "Update per-market cross/isolated leverage via Hyperliquid L1 /exchange (EIP-712)",
4231
+ commonParams: ["keyGen", "purposeText"],
4232
+ params: {
4233
+ coin: { type: "string", required: true, description: "Market coin e.g. BTC" },
4234
+ leverage: { type: "number", required: true, description: "New leverage (1..market max)" },
4235
+ isCross: { type: "boolean", required: false, description: "true for cross (default), false for isolated" },
4236
+ marketKind: { type: "string", required: false, description: "perp (default) or spot" }
4237
+ }
4238
+ },
4045
4239
  {
4046
4240
  id: "hyperliquid.undelegate",
4047
4241
  protocolId: HYPERLIQUID_PROTOCOL_ID,
@@ -4723,6 +4917,17 @@ var PROTOCOL_SUPPORT_ADVISORS = {
4723
4917
  return false;
4724
4918
  }
4725
4919
  }
4920
+ }),
4921
+ hyperliquid: advisor("hyperliquid", "api_underlyings", {
4922
+ async supportedChainIds() {
4923
+ return [...HYPERLIQUID_SUPPORTED_CHAIN_IDS];
4924
+ },
4925
+ async supportedTokens() {
4926
+ return {
4927
+ tokens: [],
4928
+ notes: "Hyperliquid perp coins from fetch_markets; chainId 999 mainnet or 998 testnet for HyperEVM multisign."
4929
+ };
4930
+ }
4726
4931
  })
4727
4932
  };
4728
4933
  function getProtocolSupportAdvisor(protocolId) {
@@ -4841,6 +5046,8 @@ exports.mcpGmxIncreaseInputSchema = mcpGmxIncreaseInputSchema;
4841
5046
  exports.mcpGmxMultisignOutputSchema = mcpServerSubmitOutputSchema;
4842
5047
  exports.mcpGmxStakeGmxInputSchema = mcpGmxStakeGmxInputSchema;
4843
5048
  exports.mcpGmxUnstakeGmxInputSchema = mcpGmxUnstakeGmxInputSchema;
5049
+ exports.mcpHyperliquidBridgeDepositInputSchema = mcpHyperliquidBridgeDepositInputSchema;
5050
+ exports.mcpHyperliquidBridgeWithdrawInputSchema = mcpHyperliquidBridgeWithdrawInputSchema;
4844
5051
  exports.mcpHyperliquidCancelInputSchema = mcpHyperliquidCancelInputSchema;
4845
5052
  exports.mcpHyperliquidCloseInputSchema = mcpHyperliquidCloseInputSchema;
4846
5053
  exports.mcpHyperliquidDelegateInputSchema = mcpHyperliquidDelegateInputSchema;
@@ -4872,6 +5079,7 @@ exports.mcpHyperliquidSearchMarketsOutputSchema = mcpHyperliquidSearchMarketsOut
4872
5079
  exports.mcpHyperliquidStakeInputSchema = mcpHyperliquidStakeInputSchema;
4873
5080
  exports.mcpHyperliquidUndelegateInputSchema = mcpHyperliquidUndelegateInputSchema;
4874
5081
  exports.mcpHyperliquidUnstakeInputSchema = mcpHyperliquidUnstakeInputSchema;
5082
+ exports.mcpHyperliquidUpdateLeverageInputSchema = mcpHyperliquidUpdateLeverageInputSchema;
4875
5083
  exports.mcpHyperliquidUsdTransferInputSchema = mcpHyperliquidUsdTransferInputSchema;
4876
5084
  exports.mcpHyperliquidVaultDepositInputSchema = mcpHyperliquidVaultDepositInputSchema;
4877
5085
  exports.mcpHyperliquidVaultWithdrawInputSchema = mcpHyperliquidVaultWithdrawInputSchema;
@@ -4913,6 +5121,8 @@ exports.mcpUniswapV4BuildMintLiquidityMultisignInputSchema = mcpUniswapV4BuildMi
4913
5121
  exports.mcpUniswapV4BuildSwapMultisignInputSchema = mcpUniswapV4BuildSwapMultisignInputSchema;
4914
5122
  exports.mcpUniswapV4CreateSwapInputSchema = mcpUniswapV4CreateSwapInputSchema;
4915
5123
  exports.mcpUniswapV4CreateSwapOutputSchema = mcpUniswapV4CreateSwapOutputSchema;
5124
+ exports.mcpUniswapV4FetchOhlcvInputSchema = mcpUniswapV4FetchOhlcvInputSchema;
5125
+ exports.mcpUniswapV4FetchOhlcvOutputSchema = mcpUniswapV4FetchOhlcvOutputSchema;
4916
5126
  exports.mcpUniswapV4LpClaimInputSchema = mcpUniswapV4LpClaimInputSchema;
4917
5127
  exports.mcpUniswapV4LpClaimOutputSchema = mcpUniswapV4LpClaimOutputSchema;
4918
5128
  exports.mcpUniswapV4LpCreatePositionInputSchema = mcpUniswapV4LpCreatePositionInputSchema;