Documentation Index
Fetch the complete documentation index at: https://mintlify.com/hummingbot/hummingbot/llms.txt
Use this file to discover all available pages before exploring further.
Overview
AMM Arbitrage exploits price differences between Automated Market Maker (AMM) decentralized exchanges and centralized order book exchanges. The strategy simultaneously executes trades on both venues when profitable opportunities arise.How It Works
- Monitor Prices: Continuously compares prices between AMM and CEX
- Calculate Profitability: Accounts for slippage, gas costs, and fees
- Execute Arbitrage: Simultaneously buys low on one venue and sells high on the other
- Profit from Spread: Captures the price difference minus all transaction costs
When to Use
Ideal Scenarios
- High volume AMM pools with price inefficiencies
- Low gas cost networks (BSC, Polygon, Arbitrum)
- Volatile markets with frequent mispricings
- Sufficient capital to absorb gas costs
Avoid When
- Ethereum mainnet with high gas (>100 gwei)
- Low liquidity AMM pools
- Pairs with high price impact
- Insufficient capital for gas costs
Core Configuration Parameters
Connector Setup
First exchange connector (CEX, AMM, or CLOB)Examples:
binance, uniswap_polygon, pancakeswapTrading pair on first connector in BASE-QUOTE formatExample:
ETH-USDTSecond exchange connectorExample:
uniswap_ethereum, quickswapTrading pair on second connectorExample:
WETH-USDCArbitrage Parameters
Order size in base assetExample:
0.1 for 0.1 ETH per arbitrageMinimum profit percentage required to execute arbitrage. Enter
1 for 1%.Example: 0.5 requires 0.5% profit after all costsRecommended:- Ethereum mainnet: >= 2%
- L2 networks: >= 0.5%
- BSC/Polygon: >= 0.3%
Slippage Management
Slippage buffer for connector_1 orders. Enter
1 for 1%.Default: 1.0 for AMMs, 0 for CEXExample: 2.0 adds 2% buffer to price for slippageSlippage buffer for connector_2 orders. Enter
1 for 1%.Automatically defaults to 1% for AMMs, 0% for CEX.Execution Mode
Whether to submit both orders simultaneously or sequentiallyOptions:
true: Submit both orders at once (faster but riskier)false: Wait for first order to fill before submitting second (safer)
Sequential execution reduces risk but may miss opportunities if price moves.
Asset Conversion
Use Hummingbot’s rate oracle for asset conversionRecommended for most use cases.
Fixed conversion rate between quote assets (when
rate_oracle_enabled=false)Example: 1.0 if both use USDT, or 0.9998 for USDT to USDCGas Configuration (for AMMs)
Symbol of token used to pay gas feesExamples:
ETH, MATIC, BNBEstimated gas cost in quote assetExample:
50 for $50 in gas per arbitrageThis is factored into profitability calculations. Update based on network conditions.
Example Configurations
CEX to AMM on L2
- Arbitrages between Binance and Uniswap on Polygon
- Uses 0.5 ETH per trade
- Requires 0.3% minimum profit
- Submits orders concurrently for speed
- Low gas costs on Polygon enable smaller spreads
AMM to AMM on Same Chain
- Higher
min_profitabilityfor Ethereum gas costs - Higher
gas_priceestimate for accurate profit calculation - Concurrent submission critical for speed
BSC Pancakeswap to Binance
- Lower gas costs allow tighter spreads
- Fixed conversion rate for stablecoins
- Sequential orders for better control
Strategy Logic Deep Dive
Profitability Calculation
The strategy performs comprehensive profitability analysis:Order Execution Modes
- Concurrent Execution
- Sequential Execution
- Submit order to connector_1
- Immediately submit order to connector_2
- Wait for both to fill
- Faster execution
- Less price risk
- Both orders may partially fill
- Higher failure risk
Gas Cost Optimization
Use L2 Networks
Use L2 Networks
Deploy on Polygon, Arbitrum, or Optimism for 100-1000x lower gas costs:
Batch Transactions
Batch Transactions
Some AMMs support batching. Check connector documentation for batching capabilities to reduce gas per trade.
Monitor Gas Prices
Monitor Gas Prices
Update
gas_price parameter based on current network conditions:Increase Order Size
Increase Order Size
Gas cost per trade is fixed, so larger orders improve percentage returns:
- 0.1 ETH @ 5000
- 1.0 ETH @ $50 gas = 0.1% cost
Tips for Success
Start Conservative
Start Conservative
Begin with higher
min_profitability (2-3%) and lower order_amount to test the strategy safely.Monitor Price Impact
Monitor Price Impact
Large orders on low-liquidity AMMs suffer from price impact. Check pool liquidity:
Account for Failed Transactions
Account for Failed Transactions
AMM transactions can fail due to slippage. Increase
slippage_buffer if experiencing failures:- Start: 1-2%
- If failures: increase to 3-5%
Balance Both Connectors
Balance Both Connectors
Maintain sufficient balances on both sides:
- Quote asset on buy side
- Base asset on sell side
- Gas token for AMM transactions
Risk Management
Risk Mitigation:- Gas Management: Use L2s or increase
min_profitabilityfor L1 - Slippage Protection: Set conservative
slippage_buffervalues - MEV Protection: Use private RPCs or MEV-protection services
- Inventory Control: Regular rebalancing between exchanges
Performance Optimization
Network Selection
| Network | Avg Gas Cost | Recommended min_profitability |
|---|---|---|
| Ethereum Mainnet | $50-200 | 2-5% |
| Polygon | $0.01-0.10 | 0.3-0.5% |
| Arbitrum | $0.10-1.00 | 0.5-1.0% |
| BSC | $0.10-0.50 | 0.3-0.8% |
Order Size Guidelines
Source Code Reference
Configuration:/source/hummingbot/strategy/amm_arb/amm_arb_config_map.py:55
Strategy Implementation: /source/hummingbot/strategy/amm_arb/amm_arb.py
Utils: /source/hummingbot/strategy/amm_arb/utils.py
Related Strategies
- Cross Exchange Market Making: Market making with hedging
- Spot Perpetual Arbitrage: Funding rate arbitrage