jeremylongshore/tons-of-skills-marketplace / plugins/crypto/dex-aggregator-router/skills/routing-dex-trades
routing-dex-trades
VerifiedRoute 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".
| File | Kind | Size |
|---|---|---|
| ARD.md | markdown | 21.4 KB |
| PRD.md | markdown | 8.0 KB |
| SKILL.md | skill md | 4.4 KB |
| config/settings.yaml | config | 2.8 KB |
| references/errors.md | markdown | 4.7 KB |
| references/examples.md | markdown | 8.5 KB |
| references/implementation.md | markdown | 3.2 KB |
| scripts/dex_router.py | script | 9.7 KB |
| scripts/formatters.py | script | 18.9 KB |
| scripts/mev_assessor.py | script | 13.7 KB |
| scripts/quote_fetcher.py | script | 16.3 KB |
| scripts/route_optimizer.py | script | 10.5 KB |
| scripts/split_calculator.py | script | 11.4 KB |
references/implementation.md
View on GitHub# Implementation Details
## 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 price impact |
| > $100K | Full + MEV + private TX | Consider OTC or algorithmic execution |
## Split Order Optimization
For large trades ($10K+), the router calculates optimal allocation across venues:
```
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)
```
The optimization algorithm:
1. Queries each venue for the full trade amount to measure price impact curves
2. Uses gradient descent to find the allocation that minimizes total slippage
3. Accounts for gas costs of multiple transactions (splitting adds ~$5-15 per venue)
4. Only recommends splitting when savings exceed additional gas overhead
## Output Mode Details
**Quick Quote Mode:**
- Best price across aggregators, output amount, effective rate, gas estimate, recommended venue
**Comparison Mode (`--compare`):**
- All venues ranked by effective rate (price minus gas)
- Price impact percentage per venue
- Gas costs compared in USD
- Liquidity depth indicators (shallow/moderate/deep)
**Route Analysis (`--routes`):**
- Direct vs. multi-hop comparison
- Hop-by-hop breakdown with intermediate tokens
- Cumulative price impact at each hop
- Gas cost per route type
**Split Mode (`--split`):**
- Optimal allocation percentages across venues
- Per-venue output amounts
- Total vs. single-venue comparison
- Dollar savings estimate
**MEV Assessment (`--mev-check`):**
- Risk score: LOW/MEDIUM/HIGH
- Estimated sandwich attack exposure in USD
- Protection recommendations (Flashbots Protect, CoW Swap, private mempool)
- Alternative MEV-resistant venues
## MEV Risk Scoring
The MEV check analyzes:
- **Token pair popularity**: High-volume pairs attract more MEV bots
- **Trade size relative to pool**: Larger trades = more profitable to sandwich
- **Current mempool activity**: Active searcher presence
- **Slippage tolerance**: Higher tolerance = more extractable value
Risk levels:
- **LOW** (score 0-30): Safe to execute via public mempool
- **MEDIUM** (score 31-70): Consider private transaction relay
- **HIGH** (score 71-100): Use Flashbots Protect or CoW Swap batch auctions
## API Configuration
Edit `${CLAUDE_SKILL_DIR}/config/settings.yaml`:
```yaml
api_keys:
oneinch: "your-1inch-api-key" # Optional, increases rate limits
zerox: "your-0x-api-key" # Optional
chain: ethereum # Default: ethereum, arbitrum, polygon, optimism
aggregators:
- name: 1inch
enabled: true
timeout: 10
- name: paraswap
enabled: true
timeout: 10
- name: zerox
enabled: true
timeout: 10
```
---
*[Tons of Skills](https://tonsofskills.com) by [Intent Solutions](https://intentsolutions.io) | [jeremylongshore.com](https://jeremylongshore.com)*
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |