微算力 · API 导航与自营网关
API 接入 EN
未登录登录
🔄

多笔兑换一键执行,安全可控

Uniswap Batch Swap · v0.1.0
效率 安全 A 级 作者 wpank 公开目录收录
下载 1.4k 安装 0 收藏 3.4k 浏览 12
原始页面

简介

批量执行多笔代币兑换,每笔独立安全验证,支持自动化组合交易策略与再平衡操作

原始描述

Execute multiple token swaps in sequence. Use when user wants to rebalance, swap into multiple tokens, or execute a multi-step trading plan. Each swap goes through full safety validation independently.

中文使用说明 来自收录源

核心用法

Batch Swap 是一项用于顺序执行多笔代币兑换的自动化技能,适用于投资组合再平衡、多目标代币购买或复杂分步交易计划。用户可通过自然语言指令(如"将 USDC 换成 WETH 和 WBTC")或明确参数列表触发。

工作流程包含四个阶段:

  1. 解析与确认:提取所有兑换对(tokenIn/tokenOut/amount),解析代币符号
  2. 预检风控:调用 check_safety_status 和 get_agent_balance 验证总支出在日内限额内、余额充足
  3. 顺序执行:为每笔兑换启动 trade-executor 子代理,完成后更新余额,支持 stopOnFailure 中断机制
  4. 汇总报告:生成结构化交易清单,包含每笔兑换的输入/输出金额、交易哈希及总 Gas 成本

显著优点

  • 原子化安全验证:每笔兑换独立通过完整安全检查,非批量通过,降低单点风险
  • 灵活中断策略:stopOnFailure 参数允许用户选择"一次失败即终止"或"跳过继续"模式
  • 自动化余额追踪:执行过程中实时更新可用余额,防止后续兑换因余额不足失败
  • 结构化输出:最终报告清晰呈现多笔交易的整体成功率、费用聚合与失败定位

潜在局限

  • 顺序执行效率:非并行处理,多笔兑换总耗时为各笔之和,高频场景可能产生机会成本
  • Gas 成本叠加:每笔独立上链,多笔交易 Gas 费不可合并优化
  • 滑点累积风险:市场波动期间,多笔顺序执行可能遭遇连续不利滑点
  • 单链限制:当前仅支持单链批量操作,跨链组合需拆分调用

适合人群

  • 希望一键完成投资组合再平衡的 DeFi 用户
  • 需要执行"购买 A、B、C 三种代币"类多目标交易计划的交易者
  • 追求操作自动化但不愿牺牲单笔安全验证的保守型用户

常规风险

风险类型 说明
部分失败风险 中途某笔失败可能导致组合策略不完整,需人工介入补单
限额超限 批量总金额可能触及单日风控上限,触发 SAFETY_AGGREGATE_LIMIT
余额估算误差 预检后、执行前的余额变动(如 Gas 消耗)可能导致后续兑换余额不足
MEV 风险 多笔交易顺序公开,可能成为 MEV 套利目标

建议用户在大额批量操作前,先以小额测试 stopOnFailure 行为是否符合预期。

技能正文


description: >- Execute multiple token swaps in sequence. Use when user wants to rebalance, swap into multiple tokens, or execute a multi-step trading plan. Each swap goes through full safety validation independently. allowed-tools: >- Read, Glob, Grep, Task(subagent_type:trade-executor), mcp__uniswap__check_safety_status, mcp__uniswap__get_agent_balance model: opus

Batch Swap

Execute multiple token swaps in sequence with independent safety validation per swap.

Activation

Use this skill when the user says any of:

  • "Swap X for Y and Z"
  • "Rebalance to 50% ETH 50% USDC"
  • "Buy 3 different tokens"
  • "Execute these swaps: ..."

Input Extraction

Parameter Required Default Source
swaps Yes — List of {tokenIn, tokenOut, amount}
chain No ethereum Default chain for all swaps
stopOnFailure No true Whether to halt on first failure

Workflow

  1. Parse all swaps from the user's message. Confirm token symbols resolve.

  2. Pre-flight check: Verify total spending within daily limits and sufficient balance for all swaps using check_safety_status and get_agent_balance.

  3. Sequential execution: For each swap:

    • Launch Task(subagent_type:trade-executor) with swap parameters
    • Wait for confirmation before starting next swap
    • Update running balance between swaps
    • If stopOnFailure=true and swap fails, halt remaining swaps
  4. Report summary:

Batch Swap Complete (3/3 succeeded)

  #  Swap              Amount In    Amount Out   Tx
  1  USDC → WETH      1,000 USDC   0.307 WETH   0xABC...
  2  USDC → WBTC      1,000 USDC   0.015 WBTC   0xDEF...
  3  USDC → UNI       1,000 USDC   142.3 UNI    0xGHI...

  Total gas: $1.26

Error Handling

Error User Message Suggested Action
BATCH_PARTIAL_FAILURE "Swap #N failed. Remaining halted." Review failed swap, re-run remaining
INSUFFICIENT_BALANCE "Insufficient balance for full batch." Reduce amounts
SAFETY_AGGREGATE_LIMIT "Total batch exceeds daily limit." Reduce total batch size

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

token-swapbatch-transactionportfolio-rebalancinguniswapdefi-automationtrade-execution

同类 Skill