swap-simulate
БесплатноБез исполняемых скриптовНе проверенThis skill should be used when the user asks to "simulate swap", "dry run swap", "test swap transaction", "check if swap would succeed", "simulate before…
от jiayaoqijia★ 81 звезда на GitHubОб этом скилле
KyberSwap Simulate Skill
Simulate (dry-run) a swap transaction using Foundry's cast call. This skill takes the output from swap-build and runs an eth_call against the target chain to verify the transaction would succeed — without signing, broadcasting, or spending gas.
Prerequisites
- Foundry installed:
castmust be available in PATH - Network access: Must be able to reach the chain's RPC endpoint
No wallet or private key is required. Simulation uses eth_call, which is a read-only operation.
Input
This skill requires the JSON output from swap-build:
{
"type": "kyberswap-swap",
"chain": "ethereum",
"tx": {
"to": "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
"data": "0x...",
"value": "1000000000000000000",
"gas": "250000"
},
"sender": "0x...",
"tokenIn": { "symbol": "ETH", "amount": "1" },
"tokenOut": { "symbol": "USDC", "amount": "2345.67" }
}
Workflow
Step 1: Validate Input
Ensure the user has provided or you have access to the swap output JSON containing:
tx.to— Router addresstx.data— Encoded calldatatx.value— Transaction value in wei (for native token swaps)tx.gas— Gas estimatechain— Chain to simulate onsender— Sender address
If any required field is missing or the JSON is not available, ask the user to run /swap-build first.
Step 2: Validate Router Address
Verify that tx.to matches the expected KyberSwap router address:
0x6131B5fae19EA4f9D964eAc0408E4408b66337b5
If the address does not match, display a prominent warning:
WARNING: The router address in this transaction (`{tx.to}`) does NOT match the
expected KyberSwap router (`0x6131B5fae19EA4f9D964eAc0408E4408b66337b5`).
This could indicate:
- The swap was built for a different protocol
- The build output was modified after generation
- A different router version is in use
Do you want to proceed with the simulation anyway? (yes/no)
Wait for explicit confirmation before continuing.
Step 3: Determine RPC URL
Use the appropriate RPC endpoint for the chain:
| Chain | RPC URL |
|---|---|
| ethereum | https://ethereum-rpc.publicnode.com |
| arbitrum | https://arb1.arbitrum.io/rpc |
| polygon | https://polygon-rpc.com |
| optimism | https://mainnet.optimism.io |
| base | https://mainnet.base.org |
| bsc | https://bsc-dataseed.binance.org |
| avalanche | https://api.avax.network/ext/bc/C/rpc |
| linea | https://rpc.linea.build |
| mantle | https://rpc.mantle.xyz |
| sonic | https://rpc.soniclabs.com |
| berachain | https://rpc.berachain.com |
| ronin | https://api.roninchain.com/rpc |
| unichain | https://rpc.unichain.org |
| hyperevm | https://rpc.hyperliquid.xyz/evm |
| plasma | https://plasma.drpc.org |
| etherlink | https://node.mainnet.etherlink.com |
| monad | https://rpc.monad.xyz |
| megaeth | https://rpc.megaeth.com |
Or the user can specify a custom RPC with --rpc-url.
Step 4: Run Simulation
Execute the cast call command to simulate the transaction:
cast call \
--rpc-url {RPC_URL} \
--from {sender} \
--value {tx.value} \
--gas-limit {tx.gas} \
{tx.to} \
{tx.data}
Example:
cast call \
--rpc-url https://ethereum-rpc.publicnode.com \
--from 0xAbc123...def456 \
--value 1000000000000000000 \
--gas-limit 250000 \
0x6131B5fae19EA4f9D964eAc0408E4408b66337b5 \
0x...calldata...
Step 5: Interpret Result
On success (cast returns data without error), present:
## Simulation Result: PASSED
| Field | Value |
|-------|-------|
| Status | Passed |
| Chain | {chain} |
| Router | `{tx.to}` |
| Sender | `{sender}` |
| Value | {tx.value} wei |
| Gas Limit | {tx.gas} |
| Return Data | `{returnData}` |
The transaction simulation succeeded. The swap is expected to execute
successfully on-chain with the current blockchain state.
### Next Steps
- **Execute the swap:** Run `/swap-execute` to broadcast the transaction
- **Act promptly:** Routes expire in ~30 seconds — execute soon after simulation
- **Note:** A passing simulation does not guarantee on-chain success (see Important Notes below)
On failure (cast returns an error or revert), decode the revert reason and provide actionable diagnosis:
## Simulation Result: FAILED
| Field | Value |
|-------|-------|
| Status | Reverted |
| Chain | {chain} |
| Router | `{tx.to}` |
| Sender | `{sender}` |
| Value | {tx.value} wei |
| Gas Limit | {tx.gas} |
| Revert Reason | {decoded revert reason} |
### Diagnosis
{See diagnosis table below}
### Recommended Action
{Specific fix based on the revert reason}
Common revert reasons and diagnoses:
| Revert Pattern | Diagnosis | Recommended Action |
|---|---|---|
TRANSFER_FROM_FAILED |
Router cannot pull input tokens from sender | Approve the router (0x6131B5fae19EA4f9D964eAc0408E4408b66337b5) to spend at least amountInWei of the inp |
Установить swap-simulate в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл swap-simulate?
This skill should be used when the user asks to "simulate swap", "dry run swap", "test swap transaction", "check if swap would succeed", "simulate before executing", "dry run the trade", "preview swap on-chain", or wants to verify a previously built swap transaction would succeed without actually sending it. Uses Foundry's `cast call` to run an eth_call simulation. Requires swap calldata from swap-build skill output.
Как установить скилл swap-simulate?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл swap-simulate запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic