routing-dex-trades
Route trades across multiple DEXs to find optimal prices with minimal slippage and gas costs. Use when comparing DEX prices, finding optimal swap routes, analyzing price impact, splitting large orders, or assessing MEV risk. Trigger with phrases like "find best swap", "compare DEX prices", "route trade", "optimal swap route", "split order", "DEX aggregator", "check slippage", or "MEV protection".
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 2.0k
- Forks
- 233
01 前言 Front Matter
- name
- routing-dex-trades
- author
- Jeremy Longshore <jeremy@intentsolutions.io>
- license
- MIT
- version
- 1.0.0
- description
- Route trades across multiple DEXs to find optimal prices with minimal slippage and gas costs. Use when comparing DEX prices, finding optimal swap routes, analyzing price impact, splitting large orders, or assessing MEV risk. Trigger with phrases like "find best swap", "compare DEX prices", "route trade", "optimal swap route", "split order", "DEX aggregator", "check slippage", or "MEV protection".
- allowed-tools
- Read, Write, Edit, Grep, Glob, Bash(crypto:dex-*)
02 资源文件 15
- 参考文档ARD.md21.2 KB
- 参考文档config/settings.yaml2.8 KB
- 许可证LICENSE1.0 KB
- 参考文档PRD.md8.0 KB
- 参考文档references/errors.md4.6 KB
- 参考文档references/examples.md8.4 KB
- 参考文档references/implementation.md1.3 KB
- 脚本scripts/dex_router.py9.8 KB
- 脚本scripts/formatters.py18.3 KB
- 脚本scripts/mev_assessor.py13.9 KB
- 脚本scripts/quote_fetcher.py16.4 KB
- 脚本scripts/route_optimizer.py10.8 KB
- 脚本scripts/split_calculator.py11.6 KB
- 参考文档SOURCE.md419 B
- 参考文档TRUST.auto.yaml2.2 KB
03 SKILL.md 正文
Routing DEX Trades
Overview
This skill provides optimal trade routing across decentralized exchanges by aggregating quotes from multiple sources (1inch, Paraswap, 0x), discovering multi-hop routes, calculating split orders for large trades, and assessing MEV risk. It helps traders execute at the best prices while minimizing slippage and gas costs.
Prerequisites
Before using this skill, ensure you have:
- Python 3.9+ with
httpx,pydantic, andrichpackages - Network access to aggregator APIs (1inch, Paraswap, 0x)
- Optional: API keys for 1inch and 0x (higher rate limits)
- Environment variables configured in
{baseDir}/config/settings.yaml - Understanding of DeFi trading concepts (slippage, price impact, MEV)
Instructions
Step 1: Configure API Access
- Copy settings template:
cp {baseDir}/config/settings.yaml.example {baseDir}/config/settings.yaml - Add optional API keys:
api_keys: oneinch: "your-1inch-api-key" # Optional, increases rate limits zerox: "your-0x-api-key" # Optional - Set preferred chain:
ethereum,arbitrum,polygon, oroptimism
Step 2: Quick Quote (Single Best Price)
Use Bash(crypto:dex-router) to get the best price across aggregators:
python {baseDir}/scripts/dex_router.py ETH USDC 1.0
This returns the single best route with price, gas cost, and effective rate.
Step 3: Compare All DEXs
For detailed comparison across all sources:
python {baseDir}/scripts/dex_router.py ETH USDC 5.0 --compare
Output includes quotes from each aggregator with:
- Output amount and rate
- Price impact percentage
- Gas cost in USD
- Effective rate (after gas)
Step 4: Analyze Routes (Multi-Hop Discovery)
For trades where multi-hop might be cheaper:
python {baseDir}/scripts/dex_router.py ETH USDC 10.0 --routes
Discovers and compares:
- Direct routes (single pool)
- Multi-hop routes (2-3 pools)
- Shows hop-by-hop breakdown with cumulative impact
Step 5: Split Large Orders
For whale-sized trades ($10K+), optimize across multiple DEXs:
python {baseDir}/scripts/dex_router.py ETH USDC 100.0 --split
Calculates optimal allocation:
Split Recommendation:
60% via Uniswap V3 (60 ETH → 152,589 USDC)
40% via Curve (40 ETH → 101,843 USDC)
─────────────────────────────────────────────
Total: 254,432 USDC (vs. 251,200 single-venue)
Improvement: +1.28% ($3,232 saved)
Step 6: MEV Risk Assessment
Check sandwich attack risk before executing:
python {baseDir}/scripts/dex_router.py ETH USDC 50.0 --mev-check
Returns risk score and recommendations:
- LOW: Safe to execute via public mempool
- MEDIUM: Consider private transaction
- HIGH: Use Flashbots Protect or CoW Swap
Step 7: Full Analysis
Combine all features for comprehensive analysis:
python {baseDir}/scripts/dex_router.py ETH USDC 25.0 --full --output json
See {baseDir}/references/examples.md for detailed output examples.
Output
The router provides:
Quick Quote Mode:
- Best price across aggregators
- Output amount and effective rate
- Gas cost estimate
- Recommended venue
Comparison Mode:
- All venues ranked by effective rate
- Price impact per venue
- Gas costs compared
- Liquidity depth indicators
Route Analysis:
- Direct vs. multi-hop comparison
- Hop-by-hop breakdown
- Cumulative price impact
- Gas cost per route type
Split Mode:
- Optimal allocation percentages
- Per-venue amounts
- Total vs. single-venue comparison
- Dollar savings estimate
MEV Assessment:
- Risk score (LOW/MEDIUM/HIGH)
- Exposure estimate
- Protection recommendations
- Alternative venues (CoW Swap, etc.)
Trade Size Recommendations
| Trade Size | Strategy | Notes |
|---|---|---|
| < $1K | Direct quote | Gas may exceed savings from optimization |
| $1K - $10K | Compare + routes | Multi-hop can save 0.1-0.5% |
| $10K - $100K | Split analysis | 2-3 way splits reduce impact |
| > $100K | Full + MEV + private TX | Consider OTC or algorithmic execution |
Error Handling
See {baseDir}/references/errors.md for comprehensive error handling.
Common issues:
- API Rate Limited: Wait 60s or use API key for higher limits
- Quote Expired: Refresh before execution; quotes valid ~30s
- No Route Found: Token may have low liquidity; try larger DEXs
- Network Timeout: Retry or check aggregator status
Examples
See {baseDir}/references/examples.md for detailed examples including:
- Basic ETH→USDC swap comparison
- Multi-hop route discovery
- Large order splitting
- MEV-protected execution paths
Resources
04 同仓库更多 Skills
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.
web-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use for complex artifacts requiring state management, routing, or shadcn/ui components - not for simple single-file HTML/JSX artifacts.
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
neuropixels-analysis
Neuropixels neural recording analysis. Load SpikeGLX/OpenEphys data, preprocess, motion correction, Kilosort4 spike sorting, quality metrics, Allen/IBL curation, AI-assisted visual analysis, for Neuropixels 1.0/2.0 extracellular electrophysiology. Use when working with neural recordings, spike sorting, extracellular electrophysiology, or when the user mentions Neuropixels, SpikeGLX, Open Ephys, Kilosort, quality metrics, or unit curation.
skill-creator
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
notebooklm
Use this skill to query your Google NotebookLM notebooks directly from Claude Code for source-grounded, citation-backed answers from Gemini. Browser automation, library management, persistent auth. Drastically reduced hallucinations through document-only responses.