Index of every page on this site: llms.txt
All skills
Run it yourself

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".

Use this Skill: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/routing-dex-trades

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesexamples.md

≈2.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

DEX Aggregator Router Examples

Comprehensive usage examples for the DEX Aggregator Router.

Quick Start

Basic Quote

Get the best price across all aggregators:

python dex_router.py ETH USDC 1.0

Output:

Fetching quotes for 1.0 ETH → USDC...

Quote from 1inch
════════════════════════════════════════
Input:          1.0 ETH
Output:         2,543.22 USDC
Rate:           2,543.22 USDC/ETH
Price Impact:   0.05%
Gas Cost:       $11.25
Effective Rate: 2,531.97
Protocols:      Uniswap V3

Specify Chain

Route on Arbitrum for lower gas:

python dex_router.py ETH USDC 1.0 --chain arbitrum

JSON Output

Get machine-readable output:

python dex_router.py ETH USDC 1.0 --output json
{
  "source": "1inch",
  "input_token": "ETH",
  "output_token": "USDC",
  "input_amount": 1.0,
  "output_amount": 2543.22,
  "price": 2543.22,
  "price_impact": 0.05,
  "gas_cost_usd": 11.25,
  "effective_rate": 2531.97,
  "protocols": ["Uniswap V3"]
}

Compare Mode

Compare All Aggregators

See prices from all sources:

python dex_router.py ETH USDC 5.0 --compare

Output:

DEX Route Comparison
══════════════════════════════════════════════════════════════════════
 Rank  Source      Output        Rate       Gas    Score    Savings
──────────────────────────────────────────────────────────────────────
 #1    1inch       12,716.10    2,543.22   $11.25   94      +0.15%
 #2    0x          12,705.00    2,541.00   $12.00   89      +0.06%
 #3    Paraswap    12,699.20    2,539.84   $13.50   85      +0.00%
──────────────────────────────────────────────────────────────────────

Spread: 0.15%
Recommendation: Best route saves 0.15%. Worth optimizing.

Medium trade: Compare routes and consider multi-hop if savings exceed 0.3%.

CSV Export

Export comparison to spreadsheet:

python dex_router.py ETH USDC 5.0 --compare --output csv > comparison.csv
rank,source,output_amount,effective_rate,gas_cost_usd,score,savings_pct
1,1inch,12716.10,2543.22,11.25,94,0.15
2,0x,12705.00,2541.00,12.00,89,0.06
3,Paraswap,12699.20,2539.84,13.50,85,0.00

Split Order Mode

Analyze Large Trade Splitting

For trades >$10K, see optimal split:

python dex_router.py ETH USDC 50.0 --split

Output:

Split Order Recommendation
══════════════════════════════════════════════════════════════════════
 Venue       Allocation    Amount      Expected         Gas
──────────────────────────────────────────────────────────────────────
 1inch          55.0%      27.5 ETH    69,938.60       $11.25
 Paraswap       30.0%      15.0 ETH    38,097.60       $13.50
 0x             15.0%       7.5 ETH    19,057.50       $12.00
──────────────────────────────────────────────────────────────────────

Total Output:  127,093.70 USDC
Single Venue:  126,200.00 USDC
Improvement:   +0.71% ($893.70 extra)
Total Gas:     $36.75

Split order saves $856.95 (0.71% improvement after gas)

Small Trade (No Split)

For small trades, split isn't recommended:

python dex_router.py ETH USDC 0.5 --split

Output:

Single venue is optimal for this trade size.

MEV Risk Assessment

Check MEV Exposure

Assess sandwich attack risk:

python dex_router.py ETH USDC 20.0 --mev-check

Output:

╭──────────────────── MEV Risk Level ────────────────────╮
│ MEDIUM (Score: 52/100)                                 │
╰────────────────────────────────────────────────────────╯

Estimated Exposure: $127.50

Risk Factors
══════════════════════════════════════════════════════════════════════
 Factor              Score    Weight    Description
──────────────────────────────────────────────────────────────────────
 Trade Size            60      35%      $50,000 trade attracts MEV searchers
 Price Impact          30      25%      0.45% impact creates arbitrage opportunity
 Route Complexity      40      15%      2 DEX(s) in route increases surface area
 Token Volatility      30      15%      Volatile tokens enable larger sandwich
 Liquidity Depth       50      10%      Lower liquidity increases MEV opportunity
──────────────────────────────────────────────────────────────────────

Protection Options:
  • MEV Blocker (85% effective)
    RPC endpoint that routes to multiple builders
  • Private Transaction (80% effective)
    Send directly to block builders
  • Slippage Tightening (50% effective)
    Set tight slippage tolerance to reject sandwich

Recommendation: MEDIUM MEV RISK: Consider using MEV Blocker or tight slippage.
                Estimated exposure: $127.50

High-Value Trade MEV Check

python dex_router.py ETH USDC 100.0 --mev-check

Output includes stronger warnings and Flashbots recommendation.


Full Analysis Mode

Complete Trade Analysis

Run all analyses together:

python dex_router.py ETH USDC 25.0 --full

Output:

════════════════════════════════════════════════════════════════════════
COMPLETE DEX ANALYSIS
════════════════════════════════════════════════════════════════════════

--- ROUTE COMPARISON ---

[Full comparison table]

--- SPLIT ORDER ANALYSIS ---

[Split recommendations]

--- MEV RISK ASSESSMENT ---

[Risk assessment with protection options]

Full Analysis to JSON File

python dex_router.py ETH USDC 25.0 --full --output json > analysis.json

Advanced Usage

Custom Gas Price

Override gas price estimate:

python dex_router.py ETH USDC 10.0 --gas-price 50

Custom ETH Price

Use specific ETH price for calculations:

python dex_router.py ETH USDC 10.0 --eth-price 3000

Different Token Pairs

# Stablecoin swap
python dex_router.py USDC DAI 10000

# BTC to ETH
python dex_router.py WBTC ETH 1.0

# Low-cap token (use address)
python dex_router.py ETH 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 5.0

Disable Colors

For logging or piping:

python dex_router.py ETH USDC 1.0 --no-color

Pipeline Examples

Best Price Alert Script

#!/bin/bash
BEST_RATE=$(python dex_router.py ETH USDC 1.0 --output json | jq '.effective_rate')
echo "Current best rate: $BEST_RATE USDC/ETH"

if (( $(echo "$BEST_RATE > 2600" | bc -l) )); then
    echo "ALERT: Rate above 2600!"
fi

Batch Comparison

for amount in 1 5 10 50 100; do
    echo "=== $amount ETH ==="
    python dex_router.py ETH USDC $amount --compare --no-color
done

Log to File

python dex_router.py ETH USDC 10.0 --full --output json >> trades.jsonl

Demo Mode

When APIs are unavailable, use demo mode:

python dex_router.py --demo

This shows example output without making API calls.


Tons of Skills by Intent Solutions | jeremylongshore.com

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill provides trade routing and price discovery across major decentralized exchanges (DEXs). It follows secure practices such as using environment variables for API keys and restricted tool permissions. It retrieves data from well-known services like 1inch and 0x, but like all tools processing external API data, it carries a minor theoretical risk of indirect prompt injection.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: MEDIUM · 1 issue

Signed by skilld at 0d57af8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month
What it can do
Reads files Edits files Runs commands
version
1.26.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
[
  "crypto",
  "cost-optimization",
  "routing-dex"
]
All 6 allowed tools
ReadWriteEditGrepGlobBash(crypto:dex-*)
Other metadata
compatibility
Designed for Claude Code

README badge

README badge for jeremylongshore/tons-of-skills-marketplace/routing-dex-trades