$npx -y skills add hummingbot/skills --skill find-arbitrage-oppsFind arbitrage opportunities across exchanges by comparing prices for fungible token pairs like BTC/WBTC and USDT/USDC.
| 1 | # find-arbitrage-opps |
| 2 | |
| 3 | Find arbitrage opportunities across all Hummingbot-connected exchanges by comparing prices for a trading pair, accounting for fungible tokens (e.g., BTC = WBTC, USDT = USDC). |
| 4 | |
| 5 | ## Prerequisites |
| 6 | |
| 7 | Hummingbot API must be running with exchange connectors configured: |
| 8 | |
| 9 | ```bash |
| 10 | bash <(curl -s https://raw.githubusercontent.com/hummingbot/skills/main/skills/lp-agent/scripts/check_prerequisites.sh) |
| 11 | ``` |
| 12 | |
| 13 | ## DEX Support |
| 14 | |
| 15 | By default the script queries CEX connectors via the Hummingbot API. Add `--dex` to also fetch prices from: |
| 16 | |
| 17 | | DEX | Chain | Default Network | |
| 18 | |-----|-------|-----------------| |
| 19 | | **Jupiter** | Solana | `mainnet-beta` | |
| 20 | | **Uniswap** | Ethereum | `mainnet` | |
| 21 | | **PancakeSwap** | Ethereum (BSC) | `bsc` | |
| 22 | |
| 23 | DEX prices are fetched directly via the Hummingbot Gateway. Make sure Gateway is running on `http://localhost:15888` (or set `GATEWAY_URL`). |
| 24 | |
| 25 | > ⚠️ **BTC markets** are only available to Australian residents on some exchanges. A warning is printed automatically when BTC/WBTC/cbBTC is included in the search. |
| 26 | |
| 27 | ## Workflow |
| 28 | |
| 29 | ### Step 1: Define Token Mappings |
| 30 | |
| 31 | User specifies the base and quote tokens, including fungible equivalents: |
| 32 | |
| 33 | - **Base tokens**: BTC, WBTC, cbBTC (all represent Bitcoin) |
| 34 | - **Quote tokens**: USDT, USDC, USD (all represent USD) |
| 35 | |
| 36 | ### Step 2: Find Arbitrage Opportunities |
| 37 | |
| 38 | ```bash |
| 39 | # Basic - CEX only |
| 40 | python scripts/find_arb_opps.py --base BTC --quote USDT |
| 41 | |
| 42 | # Include fungible tokens |
| 43 | python scripts/find_arb_opps.py --base BTC,WBTC --quote USDT,USDC |
| 44 | |
| 45 | # Include DEX prices (Jupiter + Uniswap via Gateway) |
| 46 | python scripts/find_arb_opps.py --base SOL --quote USDC --dex |
| 47 | python scripts/find_arb_opps.py --base ETH,WETH --quote USDT,USDC --dex |
| 48 | |
| 49 | # Minimum spread filter |
| 50 | python scripts/find_arb_opps.py --base SOL --quote USDC --dex --min-spread 0.1 |
| 51 | |
| 52 | # Filter to specific CEX connectors |
| 53 | python scripts/find_arb_opps.py --base BTC --quote USDT --connectors binance,kraken,coinbase |
| 54 | ``` |
| 55 | |
| 56 | ### Step 3: Analyze Results |
| 57 | |
| 58 | The script outputs: |
| 59 | - Prices from each CEX and DEX source |
| 60 | - Best bid/ask across all sources |
| 61 | - Arbitrage spread (buy low, sell high) |
| 62 | - Recommended pairs for arbitrage |
| 63 | |
| 64 | ## Script Options |
| 65 | |
| 66 | ```bash |
| 67 | python scripts/find_arb_opps.py --help |
| 68 | ``` |
| 69 | |
| 70 | | Option | Description | |
| 71 | |--------|-------------| |
| 72 | | `--base` | Base token(s), comma-separated (e.g., BTC,WBTC) | |
| 73 | | `--quote` | Quote token(s), comma-separated (e.g., USDT,USDC) | |
| 74 | | `--connectors` | Filter to specific CEX connectors (optional) | |
| 75 | | `--dex` | Include DEX prices via Gateway (Jupiter + Uniswap) | |
| 76 | | `--min-spread` | Minimum spread % to show (default: 0.0) | |
| 77 | | `--json` | Output as JSON | |
| 78 | |
| 79 | ## Output Example |
| 80 | |
| 81 | ``` |
| 82 | ============================================================ |
| 83 | SOL / USDC Arbitrage Scanner |
| 84 | DEX: Jupiter (Solana mainnet-beta), Uniswap (Ethereum mainnet) |
| 85 | ============================================================ |
| 86 | |
| 87 | Lowest: binance $132.4500 |
| 88 | Highest: jupiter (DEX) $132.8900 |
| 89 | Spread: 0.332% ($0.4400) |
| 90 | Sources: 5 prices from 5 sources |
| 91 | |
| 92 | Top Arbitrage Opportunities: |
| 93 | -------------------------------------------------------- |
| 94 | 1. Buy binance @ $132.4500 |
| 95 | Sell jupiter (DEX) @ $132.8900 |
| 96 | Profit: 0.332% ($0.4400) |
| 97 | ``` |
| 98 | |
| 99 | ## Environment Variables |
| 100 | |
| 101 | ```bash |
| 102 | export HUMMINGBOT_API_URL=http://localhost:8000 |
| 103 | export API_USER=admin |
| 104 | export API_PASS=admin |
| 105 | export GATEWAY_URL=http://localhost:15888 # for DEX prices |
| 106 | ``` |
| 107 | |
| 108 | Scripts check for `.env` in: `./hummingbot-api/.env` → `~/.hummingbot/.env` → `.env` |
| 109 | |
| 110 | ## Requirements |
| 111 | |
| 112 | - Hummingbot API running (for CEX prices) |
| 113 | - Gateway running (for DEX prices with `--dex` flag) |
| 114 | - Exchange connectors configured with API keys |