@continuumdao/ctm-mpc-defi 0.2.13 → 0.2.17
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.
- package/dist/agent/catalog.cjs +1149 -287
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.d.ts +1655 -306
- package/dist/agent/catalog.js +1144 -288
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/skills/_shared/multisign-mcp-gas.md +7 -4
- package/dist/agent/skills/circle-cctp/SKILL.md +63 -0
- package/dist/chains/evm/index.cjs +75 -0
- package/dist/chains/evm/index.cjs.map +1 -1
- package/dist/chains/evm/index.d.ts +31 -1
- package/dist/chains/evm/index.js +73 -2
- package/dist/chains/evm/index.js.map +1 -1
- package/dist/index.cjs +140 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +138 -34
- package/dist/index.js.map +1 -1
- package/dist/protocols/evm/circle-cctp/index.cjs +1067 -0
- package/dist/protocols/evm/circle-cctp/index.cjs.map +1 -0
- package/dist/protocols/evm/circle-cctp/index.d.ts +281 -0
- package/dist/protocols/evm/circle-cctp/index.js +1026 -0
- package/dist/protocols/evm/circle-cctp/index.js.map +1 -0
- package/dist/protocols/evm/euler-v2/index.cjs +29 -2
- package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
- package/dist/protocols/evm/euler-v2/index.d.ts +23 -1
- package/dist/protocols/evm/euler-v2/index.js +29 -3
- package/dist/protocols/evm/euler-v2/index.js.map +1 -1
- package/dist/protocols/evm/gmx/index.cjs +42 -8
- package/dist/protocols/evm/gmx/index.cjs.map +1 -1
- package/dist/protocols/evm/gmx/index.d.ts +20 -4
- package/dist/protocols/evm/gmx/index.js +42 -9
- package/dist/protocols/evm/gmx/index.js.map +1 -1
- package/dist/protocols/evm/maple/index.cjs +9 -1
- package/dist/protocols/evm/maple/index.cjs.map +1 -1
- package/dist/protocols/evm/maple/index.d.ts +2 -1
- package/dist/protocols/evm/maple/index.js +9 -1
- package/dist/protocols/evm/maple/index.js.map +1 -1
- package/dist/protocols/evm/morpho/index.cjs +56 -0
- package/dist/protocols/evm/morpho/index.cjs.map +1 -1
- package/dist/protocols/evm/morpho/index.d.ts +28 -1
- package/dist/protocols/evm/morpho/index.js +56 -1
- package/dist/protocols/evm/morpho/index.js.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.cjs +98 -26
- package/dist/protocols/evm/uniswap-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.js +99 -27
- package/dist/protocols/evm/uniswap-v4/index.js.map +1 -1
- package/package.json +6 -1
|
@@ -500,6 +500,45 @@ function formatUniswapQuoteForDisplay(res, args) {
|
|
|
500
500
|
if (requestId) lines.push(`Request: ${requestId}`);
|
|
501
501
|
return { title: "Quote received", lines, rawJson };
|
|
502
502
|
}
|
|
503
|
+
var erc20AllowanceAbi = viem.parseAbi([
|
|
504
|
+
"function allowance(address owner, address spender) view returns (uint256)",
|
|
505
|
+
"function decimals() view returns (uint8)"
|
|
506
|
+
]);
|
|
507
|
+
var erc20ApproveAbi = viem.parseAbi(["function approve(address spender, uint256 amount) returns (bool)"]);
|
|
508
|
+
async function buildConditionalErc20ApproveSteps(args) {
|
|
509
|
+
if (args.amountWei <= 0n) return [];
|
|
510
|
+
const token = viem.getAddress(args.token);
|
|
511
|
+
const spender = viem.getAddress(args.spender);
|
|
512
|
+
const owner = viem.getAddress(args.owner);
|
|
513
|
+
const fallback = args.fallbackGas ?? 100000n;
|
|
514
|
+
const allowance = await args.publicClient.readContract({
|
|
515
|
+
address: token,
|
|
516
|
+
abi: erc20AllowanceAbi,
|
|
517
|
+
functionName: "allowance",
|
|
518
|
+
args: [owner, spender]
|
|
519
|
+
});
|
|
520
|
+
if (allowance >= args.amountWei) return [];
|
|
521
|
+
const steps = [];
|
|
522
|
+
if (allowance > 0n) {
|
|
523
|
+
steps.push({
|
|
524
|
+
to: token,
|
|
525
|
+
data: viem.encodeFunctionData({ abi: erc20ApproveAbi, functionName: "approve", args: [spender, 0n] }),
|
|
526
|
+
value: 0n,
|
|
527
|
+
fallbackGas: fallback
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
steps.push({
|
|
531
|
+
to: token,
|
|
532
|
+
data: viem.encodeFunctionData({
|
|
533
|
+
abi: erc20ApproveAbi,
|
|
534
|
+
functionName: "approve",
|
|
535
|
+
args: [spender, args.amountWei]
|
|
536
|
+
}),
|
|
537
|
+
value: 0n,
|
|
538
|
+
fallbackGas: fallback
|
|
539
|
+
});
|
|
540
|
+
return steps;
|
|
541
|
+
}
|
|
503
542
|
|
|
504
543
|
// src/core/purpose.ts
|
|
505
544
|
function mergePurposeText(purposeText, purposeSuffix) {
|
|
@@ -1187,10 +1226,23 @@ async function buildEvmMultisignBodyUniswapV4SkipPermit2Batch(args) {
|
|
|
1187
1226
|
if (expiration48 > MAX_UINT48) expiration48 = MAX_UINT48;
|
|
1188
1227
|
}
|
|
1189
1228
|
const erc20ApproveSpender = usePermit2Triple ? PERMIT2_ADDRESS : toRouter;
|
|
1190
|
-
const
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1229
|
+
const executor = viem.getAddress(args.executorAddress);
|
|
1230
|
+
const publicClient = viem.createPublicClient({
|
|
1231
|
+
chain: viem.defineChain({
|
|
1232
|
+
id: args.chainId,
|
|
1233
|
+
name: `uniswap-swap-${args.chainId}`,
|
|
1234
|
+
nativeCurrency: { decimals: 18, name: "Ether", symbol: "ETH" },
|
|
1235
|
+
rpcUrls: { default: { http: [args.rpcUrl] } }
|
|
1236
|
+
}),
|
|
1237
|
+
transport: viem.http(args.rpcUrl)
|
|
1238
|
+
});
|
|
1239
|
+
const erc20ApproveSteps = await buildConditionalErc20ApproveSteps({
|
|
1240
|
+
publicClient,
|
|
1241
|
+
token: tokenIn,
|
|
1242
|
+
spender: erc20ApproveSpender,
|
|
1243
|
+
owner: executor,
|
|
1244
|
+
amountWei: approveAmountWei,
|
|
1245
|
+
fallbackGas: 100000n
|
|
1194
1246
|
});
|
|
1195
1247
|
const valueWei = (() => {
|
|
1196
1248
|
const v = args.swap.value;
|
|
@@ -1202,13 +1254,16 @@ async function buildEvmMultisignBodyUniswapV4SkipPermit2Batch(args) {
|
|
|
1202
1254
|
}
|
|
1203
1255
|
})();
|
|
1204
1256
|
const swapRecord = args.swap;
|
|
1205
|
-
const swapMsgIndex = usePermit2Triple ?
|
|
1257
|
+
const swapMsgIndex = usePermit2Triple ? erc20ApproveSteps.length + 1 : erc20ApproveSteps.length;
|
|
1206
1258
|
let gasBuildSource = "rpcEstimate";
|
|
1207
1259
|
let estimateGasError;
|
|
1208
1260
|
let swapBaseGasUnits = DEFAULT_UNIVERSAL_ROUTER_GAS_FALLBACK;
|
|
1209
|
-
const steps =
|
|
1210
|
-
|
|
1211
|
-
|
|
1261
|
+
const steps = erc20ApproveSteps.map((s) => ({
|
|
1262
|
+
to: s.to,
|
|
1263
|
+
data: s.data,
|
|
1264
|
+
value: s.value,
|
|
1265
|
+
fallbackGas: s.fallbackGas
|
|
1266
|
+
}));
|
|
1212
1267
|
if (usePermit2Triple) {
|
|
1213
1268
|
const permit2ApproveData = viem.encodeFunctionData({
|
|
1214
1269
|
abi: permit2ApproveRouterAbi,
|
|
@@ -1225,8 +1280,9 @@ async function buildEvmMultisignBodyUniswapV4SkipPermit2Batch(args) {
|
|
|
1225
1280
|
fallbackGas: DEFAULT_UNIVERSAL_ROUTER_GAS_FALLBACK
|
|
1226
1281
|
});
|
|
1227
1282
|
const swapStepIndex = steps.length - 1;
|
|
1228
|
-
const approveMsgRawNo0x =
|
|
1229
|
-
const
|
|
1283
|
+
const approveMsgRawNo0x = erc20ApproveSteps.length > 0 && erc20ApproveSteps[erc20ApproveSteps.length - 1].data.startsWith("0x") ? erc20ApproveSteps[erc20ApproveSteps.length - 1].data.slice(2) : dataHex.startsWith("0x") ? dataHex.slice(2) : dataHex;
|
|
1284
|
+
const approveCount = erc20ApproveSteps.length;
|
|
1285
|
+
const purposeSuffix = usePermit2Triple ? `Uniswap V4: ${approveCount > 0 ? "3" : "2"}-tx batch (classic allowance) \u2014 ERC-20 approve allowance hub when needed, hub approve(Universal Router), swap.` : approveCount > 0 ? "Uniswap V4: 2-tx batch (classic allowance, dispatcher) \u2014 ERC-20 approve swap.to when needed, then swap." : "Uniswap V4: 1-tx batch \u2014 swap only (ERC-20 allowance already sufficient).";
|
|
1230
1286
|
const buildSwapAudit = () => ({
|
|
1231
1287
|
skipPermit2Batch: true,
|
|
1232
1288
|
approvalPath: usePermit2Triple ? "permit2_triple" : "dispatcher",
|
|
@@ -1303,18 +1359,18 @@ async function buildEvmMultisignBodyUniswapV4SkipPermit2Batch(args) {
|
|
|
1303
1359
|
firstMsgRawNo0x: approveMsgRawNo0x,
|
|
1304
1360
|
destinationAddress: tokenIn,
|
|
1305
1361
|
payableValueWei: valueWei > 0n ? valueWei : void 0,
|
|
1306
|
-
estimateGasForStep: async ({ step, index, publicClient, executor }) => {
|
|
1362
|
+
estimateGasForStep: async ({ step, index, publicClient: publicClient2, executor: executor2 }) => {
|
|
1307
1363
|
if (index !== swapStepIndex) {
|
|
1308
|
-
return
|
|
1364
|
+
return publicClient2.estimateGas({
|
|
1309
1365
|
to: step.to,
|
|
1310
1366
|
data: step.data,
|
|
1311
1367
|
value: step.value,
|
|
1312
|
-
account:
|
|
1368
|
+
account: executor2
|
|
1313
1369
|
});
|
|
1314
1370
|
}
|
|
1315
1371
|
const r = await estimateUniswapRouterSwapGas({
|
|
1316
|
-
publicClient,
|
|
1317
|
-
executor,
|
|
1372
|
+
publicClient: publicClient2,
|
|
1373
|
+
executor: executor2,
|
|
1318
1374
|
to: toRouter,
|
|
1319
1375
|
data: dataHex,
|
|
1320
1376
|
value: valueWei,
|
|
@@ -2199,7 +2255,7 @@ function isNativeUniswapLpTokenAddress(token) {
|
|
|
2199
2255
|
|
|
2200
2256
|
// src/protocols/evm/uniswap-v4/liquidityMultisign.ts
|
|
2201
2257
|
var wethDepositAbi = viem.parseAbi(["function deposit() payable"]);
|
|
2202
|
-
var
|
|
2258
|
+
var erc20AllowanceAbi2 = viem.parseAbi([
|
|
2203
2259
|
"function allowance(address owner, address spender) view returns (uint256)",
|
|
2204
2260
|
"function decimals() view returns (uint8)"
|
|
2205
2261
|
]);
|
|
@@ -2309,7 +2365,7 @@ async function resolveApproveTargets(args) {
|
|
|
2309
2365
|
}
|
|
2310
2366
|
const allowance = await args.publicClient.readContract({
|
|
2311
2367
|
address: row.token,
|
|
2312
|
-
abi:
|
|
2368
|
+
abi: erc20AllowanceAbi2,
|
|
2313
2369
|
functionName: "allowance",
|
|
2314
2370
|
args: [args.executor, args.spender]
|
|
2315
2371
|
});
|
|
@@ -2351,16 +2407,32 @@ async function buildEvmMultisignBodyUniswapV4LiquidityBatchInternal(args) {
|
|
|
2351
2407
|
value: target.amount,
|
|
2352
2408
|
fallbackGas: UNISWAP_V4_LP_WETH_DEPOSIT_FALLBACK
|
|
2353
2409
|
});
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
args: [spender, target.amount]
|
|
2360
|
-
}),
|
|
2361
|
-
value: 0n,
|
|
2362
|
-
fallbackGas: UNISWAP_V4_LP_ERC20_APPROVE_FALLBACK
|
|
2410
|
+
const wethAllowance = await publicClient.readContract({
|
|
2411
|
+
address: target.token,
|
|
2412
|
+
abi: erc20AllowanceAbi2,
|
|
2413
|
+
functionName: "allowance",
|
|
2414
|
+
args: [executor, spender]
|
|
2363
2415
|
});
|
|
2416
|
+
if (wethAllowance < target.amount) {
|
|
2417
|
+
if (wethAllowance > 0n) {
|
|
2418
|
+
steps.push({
|
|
2419
|
+
to: target.token,
|
|
2420
|
+
data: viem.encodeFunctionData({ abi: viem.erc20Abi, functionName: "approve", args: [spender, 0n] }),
|
|
2421
|
+
value: 0n,
|
|
2422
|
+
fallbackGas: UNISWAP_V4_LP_ERC20_APPROVE_FALLBACK
|
|
2423
|
+
});
|
|
2424
|
+
}
|
|
2425
|
+
steps.push({
|
|
2426
|
+
to: target.token,
|
|
2427
|
+
data: viem.encodeFunctionData({
|
|
2428
|
+
abi: viem.erc20Abi,
|
|
2429
|
+
functionName: "approve",
|
|
2430
|
+
args: [spender, target.amount]
|
|
2431
|
+
}),
|
|
2432
|
+
value: 0n,
|
|
2433
|
+
fallbackGas: UNISWAP_V4_LP_ERC20_APPROVE_FALLBACK
|
|
2434
|
+
});
|
|
2435
|
+
}
|
|
2364
2436
|
} else {
|
|
2365
2437
|
steps.push({
|
|
2366
2438
|
to: target.token,
|