@continuumdao/ctm-mpc-defi 0.2.55 → 0.2.57

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 (61) hide show
  1. package/dist/agent/catalog.cjs +692 -310
  2. package/dist/agent/catalog.cjs.map +1 -1
  3. package/dist/agent/catalog.d.ts +279 -99
  4. package/dist/agent/catalog.js +687 -312
  5. package/dist/agent/catalog.js.map +1 -1
  6. package/dist/agent/skills/aave-v4/SKILL.md +26 -3
  7. package/dist/agent/skills/aerodrome/SKILL.md +3 -1
  8. package/dist/agent/skills/circle-cctp/SKILL.md +5 -4
  9. package/dist/agent/skills/continuum-dao-marketplace/SKILL.md +4 -4
  10. package/dist/agent/skills/curve-dao/SKILL.md +2 -2
  11. package/dist/agent/skills/uniswap-v4/SKILL.md +2 -2
  12. package/dist/index.cjs +165 -19
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.js +166 -20
  15. package/dist/index.js.map +1 -1
  16. package/dist/protocols/evm/aave-v4/index.cjs +198 -15
  17. package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
  18. package/dist/protocols/evm/aave-v4/index.d.ts +62 -7
  19. package/dist/protocols/evm/aave-v4/index.js +189 -16
  20. package/dist/protocols/evm/aave-v4/index.js.map +1 -1
  21. package/dist/protocols/evm/aerodrome/index.cjs +152 -63
  22. package/dist/protocols/evm/aerodrome/index.cjs.map +1 -1
  23. package/dist/protocols/evm/aerodrome/index.d.ts +30 -58
  24. package/dist/protocols/evm/aerodrome/index.js +151 -64
  25. package/dist/protocols/evm/aerodrome/index.js.map +1 -1
  26. package/dist/protocols/evm/circle-cctp/index.cjs +77 -19
  27. package/dist/protocols/evm/circle-cctp/index.cjs.map +1 -1
  28. package/dist/protocols/evm/circle-cctp/index.d.ts +53 -3
  29. package/dist/protocols/evm/circle-cctp/index.js +76 -20
  30. package/dist/protocols/evm/circle-cctp/index.js.map +1 -1
  31. package/dist/protocols/evm/compound-v3/index.cjs +115 -2
  32. package/dist/protocols/evm/compound-v3/index.cjs.map +1 -1
  33. package/dist/protocols/evm/compound-v3/index.js +116 -3
  34. package/dist/protocols/evm/compound-v3/index.js.map +1 -1
  35. package/dist/protocols/evm/continuum-dao/index.cjs +288 -32
  36. package/dist/protocols/evm/continuum-dao/index.cjs.map +1 -1
  37. package/dist/protocols/evm/continuum-dao/index.d.ts +14 -1
  38. package/dist/protocols/evm/continuum-dao/index.js +287 -33
  39. package/dist/protocols/evm/continuum-dao/index.js.map +1 -1
  40. package/dist/protocols/evm/curve-dao/index.cjs +120 -5
  41. package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
  42. package/dist/protocols/evm/curve-dao/index.js +120 -5
  43. package/dist/protocols/evm/curve-dao/index.js.map +1 -1
  44. package/dist/protocols/evm/euler-v2/index.cjs +121 -6
  45. package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
  46. package/dist/protocols/evm/euler-v2/index.js +121 -6
  47. package/dist/protocols/evm/euler-v2/index.js.map +1 -1
  48. package/dist/protocols/evm/morpho/index.cjs +129 -57
  49. package/dist/protocols/evm/morpho/index.cjs.map +1 -1
  50. package/dist/protocols/evm/morpho/index.d.ts +2 -1
  51. package/dist/protocols/evm/morpho/index.js +129 -58
  52. package/dist/protocols/evm/morpho/index.js.map +1 -1
  53. package/dist/protocols/evm/pendle/index.cjs +129 -10
  54. package/dist/protocols/evm/pendle/index.cjs.map +1 -1
  55. package/dist/protocols/evm/pendle/index.js +129 -10
  56. package/dist/protocols/evm/pendle/index.js.map +1 -1
  57. package/dist/protocols/evm/uniswap-v4/index.cjs +164 -17
  58. package/dist/protocols/evm/uniswap-v4/index.cjs.map +1 -1
  59. package/dist/protocols/evm/uniswap-v4/index.js +165 -18
  60. package/dist/protocols/evm/uniswap-v4/index.js.map +1 -1
  61. package/package.json +1 -1
@@ -228,6 +228,12 @@ function cctpSupportedRoutes(network) {
228
228
  }
229
229
 
230
230
  // src/protocols/evm/circle-cctp/fees.ts
231
+ function cctpProtocolFeeBaseUnits(transferAmount, minimumFeeBps) {
232
+ if (transferAmount <= 0n || !Number.isFinite(minimumFeeBps) || minimumFeeBps <= 0) return 0n;
233
+ const scaledBps = BigInt(Math.round(minimumFeeBps * 100));
234
+ if (scaledBps <= 0n) return 0n;
235
+ return transferAmount * scaledBps / 1000000n;
236
+ }
231
237
  function pickForwardFeeTier(row, tier) {
232
238
  const forwardFee = row.forwardFee;
233
239
  if (forwardFee && typeof forwardFee === "object") {
@@ -236,11 +242,25 @@ function pickForwardFeeTier(row, tier) {
236
242
  if (v != null) return BigInt(String(v));
237
243
  }
238
244
  const maxFee = row.maximumFee ?? row.maxFee ?? row.forwardFee;
239
- if (maxFee != null) return BigInt(String(maxFee));
245
+ if (maxFee != null && typeof maxFee !== "object") return BigInt(String(maxFee));
240
246
  throw new Error("Iris fee response missing forwardFee tiers.");
241
247
  }
248
+ function feeRows(json) {
249
+ if (Array.isArray(json)) return json.filter((row) => row && typeof row === "object");
250
+ if (json && typeof json === "object") {
251
+ const data = json.data;
252
+ if (Array.isArray(data)) return data.filter((row) => row && typeof row === "object");
253
+ return [json];
254
+ }
255
+ return [];
256
+ }
257
+ function selectCctpIrisFeeRow(rows, finalityThreshold) {
258
+ const match = rows.find((row) => Number(row.finalityThreshold) === finalityThreshold);
259
+ return match ?? rows[0] ?? {};
260
+ }
242
261
  async function fetchCctpBurnFees(args) {
243
262
  const tier = args.feeTier ?? "med";
263
+ const finalityThreshold = args.minFinalityThreshold ?? CCTP_DEFAULT_MIN_FINALITY_THRESHOLD;
244
264
  const base = irisApiBaseForChainId(args.sourceChainId);
245
265
  const url = `${base}/v2/burn/USDC/fees/${args.sourceDomain}/${args.destDomain}?forward=true`;
246
266
  const res = await fetch(url, { headers: { Accept: "application/json" } });
@@ -248,20 +268,28 @@ async function fetchCctpBurnFees(args) {
248
268
  const text = await res.text().catch(() => "");
249
269
  throw new Error(`Iris fee quote failed (${res.status}): ${text.slice(0, 200)}`);
250
270
  }
251
- const json = await res.json();
252
- const rows = Array.isArray(json) ? json : Array.isArray(json.data) ? json.data : [json];
253
- const row = rows[0] ?? {};
271
+ const row = selectCctpIrisFeeRow(feeRows(await res.json()), finalityThreshold);
254
272
  const low = pickForwardFeeTier(row, "low");
255
273
  const med = pickForwardFeeTier(row, "med");
256
274
  const high = pickForwardFeeTier(row, "high");
257
- const maxFee = tier === "low" ? low : tier === "high" ? high : med;
275
+ const minimumFeeRaw = row.minimumFee;
276
+ const minimumFeeBps = typeof minimumFeeRaw === "number" ? minimumFeeRaw : Number(minimumFeeRaw ?? 0);
277
+ const transferAmount = args.transferAmount ?? 0n;
278
+ const protocolFee = cctpProtocolFeeBaseUnits(transferAmount, minimumFeeBps);
279
+ const forwardForTier = tier === "low" ? low : tier === "high" ? high : med;
258
280
  return {
259
281
  sourceDomain: args.sourceDomain,
260
282
  destDomain: args.destDomain,
261
- maxFee,
283
+ finalityThreshold: Number(row.finalityThreshold ?? finalityThreshold),
284
+ minimumFeeBps: Number.isFinite(minimumFeeBps) ? minimumFeeBps : 0,
285
+ protocolFee,
286
+ maxFee: forwardForTier + protocolFee,
262
287
  forwardFeeLow: low,
263
288
  forwardFeeMed: med,
264
289
  forwardFeeHigh: high,
290
+ maxFeeLow: low + protocolFee,
291
+ maxFeeMed: med + protocolFee,
292
+ maxFeeHigh: high + protocolFee,
265
293
  feeTierUsed: tier
266
294
  };
267
295
  }
@@ -625,6 +653,8 @@ async function buildEvmMultisignBodyCctpBurnBatch(args) {
625
653
  const executor = viem.getAddress(args.executorAddress);
626
654
  const mintRecipient = viem.getAddress(args.mintRecipient ?? executor);
627
655
  const minFinality = args.minFinalityThreshold ?? CCTP_DEFAULT_MIN_FINALITY_THRESHOLD;
656
+ const transferAmountForFee = viem.parseUnits(args.transferAmountHuman.trim(), CCTP_USDC_DECIMALS);
657
+ if (transferAmountForFee <= 0n) throw new Error("Transfer amount must be greater than zero.");
628
658
  let maxFee = args.maxFee;
629
659
  let proposalMaxFee = args.proposalMaxFee ?? maxFee;
630
660
  if (maxFee == null) {
@@ -632,7 +662,9 @@ async function buildEvmMultisignBodyCctpBurnBatch(args) {
632
662
  sourceChainId: args.sourceChainId,
633
663
  sourceDomain: src.domain,
634
664
  destDomain: dst.domain,
635
- feeTier: args.feeTier
665
+ feeTier: args.feeTier,
666
+ transferAmount: transferAmountForFee,
667
+ minFinalityThreshold: minFinality
636
668
  });
637
669
  maxFee = fees.maxFee;
638
670
  proposalMaxFee = fees.maxFee;
@@ -722,11 +754,22 @@ async function buildEvmMultisignBodyCctpBurnBatch(args) {
722
754
  return result;
723
755
  }
724
756
  async function buildEvmMultisignBodyCctpBurnBatchFromMcp(args) {
725
- let maxFee;
726
- let proposalMaxFee;
757
+ const src = cctpChainConfig(args.chainId);
758
+ const dst = cctpChainConfig(args.destChainId);
759
+ if (!src || !dst) throw new Error("Unsupported CCTP source or destination chain.");
760
+ const transferAmount = viem.parseUnits(args.transferAmountHuman.trim(), CCTP_USDC_DECIMALS);
761
+ const fees = await fetchCctpBurnFees({
762
+ sourceChainId: args.chainId,
763
+ sourceDomain: src.domain,
764
+ destDomain: dst.domain,
765
+ feeTier: args.feeTier,
766
+ transferAmount,
767
+ minFinalityThreshold: args.minFinalityThreshold
768
+ });
769
+ let maxFee = fees.maxFee;
727
770
  if (args.feeSnapshot?.maxFee != null) {
728
- maxFee = BigInt(String(args.feeSnapshot.maxFee));
729
- proposalMaxFee = maxFee;
771
+ const snapshotMaxFee = BigInt(String(args.feeSnapshot.maxFee));
772
+ if (snapshotMaxFee > maxFee) maxFee = snapshotMaxFee;
730
773
  }
731
774
  return buildEvmMultisignBodyCctpBurnBatch({
732
775
  keyGen: args.keyGen,
@@ -741,7 +784,7 @@ async function buildEvmMultisignBodyCctpBurnBatchFromMcp(args) {
741
784
  executorAddress: args.executorAddress,
742
785
  purposeText: args.purposeText,
743
786
  maxFee,
744
- proposalMaxFee,
787
+ proposalMaxFee: maxFee,
745
788
  feeTier: args.feeTier,
746
789
  minFinalityThreshold: args.minFinalityThreshold
747
790
  });
@@ -855,14 +898,15 @@ function buildCctpMcpFeeFields(args) {
855
898
  const forwardFeeLowHuman = formatCctpUsdcHuman(fees.forwardFeeLow);
856
899
  const forwardFeeMedHuman = formatCctpUsdcHuman(fees.forwardFeeMed);
857
900
  const forwardFeeHighHuman = formatCctpUsdcHuman(fees.forwardFeeHigh);
901
+ const protocolFeeHuman = formatCctpUsdcHuman(fees.protocolFee);
858
902
  let totalBurn;
859
903
  let totalBurnHuman;
860
- if (transferAmount != null) {
904
+ if (transferAmount != null && transferAmount > 0n) {
861
905
  totalBurn = transferAmount + fees.maxFee;
862
906
  totalBurnHuman = formatCctpUsdcHuman(totalBurn);
863
907
  }
864
- const recipientPart = transferAmountHuman != null ? ` Recipient receives ${transferAmountHuman} USDC; wallet burns ${totalBurnHuman} USDC total (transfer + max fee).` : "";
865
- const feeSummary = `Forwarding Service max fee (${fees.feeTierUsed} tier): ${maxFeeHuman} USDC.${recipientPart} Fee tiers \u2014 low: ${forwardFeeLowHuman}, med: ${forwardFeeMedHuman}, high: ${forwardFeeHighHuman} USDC. Fees refresh again at Get Sig.`;
908
+ const recipientPart = transferAmountHuman != null && totalBurnHuman != null ? ` Recipient receives ${transferAmountHuman} USDC; wallet burns ${totalBurnHuman} USDC total (transfer + max fee).` : " Pass transferAmountHuman so maxFee includes the fast-transfer protocol fee.";
909
+ const feeSummary = `CCTP max fee (${fees.feeTierUsed} tier): ${maxFeeHuman} USDC = forwarding ${formatCctpUsdcHuman(fees.feeTierUsed === "low" ? fees.forwardFeeLow : fees.feeTierUsed === "high" ? fees.forwardFeeHigh : fees.forwardFeeMed)} + protocol ${protocolFeeHuman} (${fees.minimumFeeBps} bps, finality ${fees.finalityThreshold}).${recipientPart} Combined tiers \u2014 low: ${formatCctpUsdcHuman(fees.maxFeeLow)}, med: ${formatCctpUsdcHuman(fees.maxFeeMed)}, high: ${formatCctpUsdcHuman(fees.maxFeeHigh)} USDC. Fees refresh again at Get Sig.`;
866
910
  return {
867
911
  feeTierUsed: fees.feeTierUsed,
868
912
  maxFee: fees.maxFee.toString(),
@@ -873,6 +917,16 @@ function buildCctpMcpFeeFields(args) {
873
917
  forwardFeeMedHuman,
874
918
  forwardFeeHigh: fees.forwardFeeHigh.toString(),
875
919
  forwardFeeHighHuman,
920
+ maxFeeLow: fees.maxFeeLow.toString(),
921
+ maxFeeLowHuman: formatCctpUsdcHuman(fees.maxFeeLow),
922
+ maxFeeMed: fees.maxFeeMed.toString(),
923
+ maxFeeMedHuman: formatCctpUsdcHuman(fees.maxFeeMed),
924
+ maxFeeHigh: fees.maxFeeHigh.toString(),
925
+ maxFeeHighHuman: formatCctpUsdcHuman(fees.maxFeeHigh),
926
+ minimumFeeBps: fees.minimumFeeBps,
927
+ protocolFee: fees.protocolFee.toString(),
928
+ protocolFeeHuman,
929
+ finalityThreshold: fees.finalityThreshold,
876
930
  ...transferAmount != null ? { transferAmount: transferAmount.toString() } : {},
877
931
  ...transferAmountHuman != null ? { transferAmountHuman } : {},
878
932
  ...totalBurn != null ? { totalBurn: totalBurn.toString() } : {},
@@ -970,14 +1024,16 @@ async function cctpFetchBurnFeesForRoute(args) {
970
1024
  if (!src || !dst) throw new Error("Unsupported source or destination chain for CCTP.");
971
1025
  if (src.network !== dst.network) throw new Error("Source and destination must be on the same network (mainnet or testnet).");
972
1026
  if (src.chainId === dst.chainId) throw new Error("Source and destination must differ.");
1027
+ const transferHuman = args.transferAmountHuman?.trim();
1028
+ const transferAmount = transferHuman ? viem.parseUnits(transferHuman, CCTP_USDC_DECIMALS) : void 0;
973
1029
  const fees = await fetchCctpBurnFees({
974
1030
  sourceChainId: args.sourceChainId,
975
1031
  sourceDomain: src.domain,
976
1032
  destDomain: dst.domain,
977
- feeTier: args.feeTier
1033
+ feeTier: args.feeTier,
1034
+ transferAmount,
1035
+ minFinalityThreshold: args.minFinalityThreshold
978
1036
  });
979
- const transferHuman = args.transferAmountHuman?.trim();
980
- const transferAmount = transferHuman ? viem.parseUnits(transferHuman, CCTP_USDC_DECIMALS) : void 0;
981
1037
  const feeFields = buildCctpMcpFeeFields({
982
1038
  fees,
983
1039
  transferAmount,
@@ -1022,7 +1078,7 @@ var circleCctpProtocolModule = {
1022
1078
  id: "circle-cctp.fetch-fees",
1023
1079
  protocolId: CIRCLE_CCTP_PROTOCOL_ID,
1024
1080
  chainCategory: "evm",
1025
- description: "Quote Iris Forwarding Service burn fees for a route",
1081
+ description: "Quote Iris forwarding fee plus fast-transfer protocol fee for a route",
1026
1082
  commonParams: [],
1027
1083
  params: {
1028
1084
  sourceChainId: { type: "number", required: true, description: "Source EIP-155 chain id" },
@@ -1071,6 +1127,7 @@ exports.cctpFetchSupportedRoutes = cctpFetchSupportedRoutes;
1071
1127
  exports.cctpFetchTransferStatus = cctpFetchTransferStatus;
1072
1128
  exports.cctpFetchUsdcBalance = cctpFetchUsdcBalance;
1073
1129
  exports.cctpMintRecipientAddressFromExtra = cctpMintRecipientAddressFromExtra;
1130
+ exports.cctpProtocolFeeBaseUnits = cctpProtocolFeeBaseUnits;
1074
1131
  exports.cctpSupportedRoutes = cctpSupportedRoutes;
1075
1132
  exports.chainIdToDomain = chainIdToDomain;
1076
1133
  exports.circleCctpProtocolModule = circleCctpProtocolModule;
@@ -1087,5 +1144,6 @@ exports.parseCctpBurnExtraJSON = parseCctpBurnExtraJSON;
1087
1144
  exports.parseCctpEvmChainId = parseCctpEvmChainId;
1088
1145
  exports.rebuildCctpBurnCalldataAtGetSig = rebuildCctpBurnCalldataAtGetSig;
1089
1146
  exports.resolveCctpBatchStepGasFromSignRequest = resolveCctpBatchStepGasFromSignRequest;
1147
+ exports.selectCctpIrisFeeRow = selectCctpIrisFeeRow;
1090
1148
  //# sourceMappingURL=index.cjs.map
1091
1149
  //# sourceMappingURL=index.cjs.map