Home › Basics › How DEX Arbitrage Works: Pools, Prices and Execution
How DEX Arbitrage Works: Pools, Prices and Execution
DEX arbitrage works by trading the same token pair through two or more liquidity pools whose prices disagree. You buy where the token is cheap, sell where it is expensive, and keep the difference if it exceeds gas and pool fees. On Ethereum this is usually done inside one atomic transaction.
How a pool sets its price
Most decentralised exchanges on Ethereum are automated market makers. A pool holds reserves of two tokens, and the price is implied by the ratio between them. In a constant-product pool such as Uniswap V2, the rule is that reserve A multiplied by reserve B stays constant across trades (ignoring fees). Buying token A removes some of it from the pool and adds token B, which pushes A’s price up.
Two consequences matter for arbitrage. First, price impact grows with trade size, so a large trade gets a worse average price than a small one. Second, a pool has no knowledge of other pools. It only reacts to trades against itself, which is why gaps open up. The Uniswap V2 documentation explains the formula and notes that arbitrageurs are what keep pool prices aligned with the wider market.
Why pools drift apart
| Cause | What happens | Arbitrage consequence |
|---|---|---|
| Large swap in one pool | That pool’s price moves, others do not | Gap between the pool and its peers |
| Different fee tiers | The same pair has pools at 0.05%, 0.3% and 1% on V3 | Prices settle at different levels inside the fee band |
| New liquidity or withdrawals | Reserve ratios change | Temporary mispricing |
| Centralised exchange moves first | On-chain pools lag the order-book price | CEX to DEX gap, see CEX versus DEX arbitrage |
| Different pool design | Curve stable pools price differently from constant-product pools | Persistent small differences |
Fees are a point people forget. Because each swap pays a fee, two pools can disagree slightly without any profit being available. The gap has to exceed the sum of the fees on both legs before there is anything to capture.
Key takeaway: a price difference only becomes an opportunity when it is larger than two pool fees, slippage and gas combined.
Building the route
A simple route has two legs. Say pool X prices token T cheaper than pool Y. The bot buys T in X using ETH or a stablecoin, then sells T in Y for the same asset and ends with more than it started. More complex routes chain three or more pools, which is the triangular arbitrage pattern, or route through stable pools on Curve or weighted pools on Balancer.
The bot needs to solve two problems. One is finding the route with the best expected output among many candidates. The other is choosing trade size. Because price impact is nonlinear, profit as a function of size rises and then falls, so the best size sits at a point where the marginal gain equals the marginal cost. Good bots calculate this analytically or by simulation rather than guessing.
Atomicity: why one transaction matters
The key property that makes on-chain arbitrage workable is that both legs can run inside a single transaction. A smart contract performs the buy and the sell, then checks that the final balance is higher than the starting balance. If not, it reverts and nothing is exchanged, apart from the gas already consumed. This removes the risk of getting only one leg filled.
The same property is what allows flash loans. A contract can borrow, trade and repay in the same transaction, and if repayment would fail the whole transaction reverts. CryptoMEV Bot describes this model on its flash loan arbitrage page, stating that borrowing, both trades and repayment execute together and that a failed trade reverts, costing only the gas fee. That is the vendor’s description, and it accurately reflects how atomic execution is supposed to behave.
What must go right
For a profitable trade, five things have to line up:
- The gap is real and large enough. After fees and impact it must still be positive.
- The state has not changed. Between detection and inclusion, other transactions in the same block may move the pools.
- Gas is priced correctly. Too low and the transaction waits or is outbid. Too high and the margin vanishes.
- The transaction is ordered well. Your trade must land before a competitor takes the same gap, which is where private routing matters, see Flashbots Protect and arbitrage.
- The tokens behave. Fee-on-transfer tokens, rebasing tokens and malicious contracts can break the accounting.
Tools that automate these steps combine scanning, simulation and submission. The CryptoMEV Bot Ethereum page lists multi-DEX scanning, pre-trade simulation, a gas-aware profit check and Flashbots routing as its core features. Those are descriptions of the product’s design, not evidence of returns.
A numeric walk-through
Use round, illustrative numbers rather than real market data. Suppose pool X lets you convert 10 ETH into 10,000 units of a token, while pool Y would pay 10,150 units’ worth of ETH-equivalent value when you sell them back, a 1.5 percent gap. Each leg pays a 0.3 percent pool fee, so fees alone take about 0.6 percent. Price impact on a trade that size in a mid-sized pool might take a further slice, and gas has to be paid on top. What looked like 1.5 percent shrinks to something much smaller, and on a quiet, thin pool it can turn negative.
Run the same example with a gap of 0.4 percent and the answer is clear without any further maths: it cannot cover two 0.3 percent fees. This is why a bot’s first filter is a quick fee-adjusted check, applied before any expensive simulation. The numbers above are for illustration only. Real pool depth, fee tier and gas price change every block, so always compute with live values.
A few design choices follow from this arithmetic:
- Prefer pools in the lowest sensible fee tier for the pair, since fee is paid on both legs.
- Cap trade size by pool depth, not by your balance.
- Reject routes whose profit is positive only under optimistic gas assumptions.
- Re-simulate immediately before sending, because pool reserves may have moved since the first calculation.
For product-level context, CryptoMEV Bot’s DeFi arbitrage bot page sits in the same family as its Ethereum page, and comparing the two is a quick way to see how a vendor describes broader versus chain-specific tooling. Verify any specifics on the pages themselves, since features and pricing can change.
Practical limits
Even a well-built system faces limits. Liquidity is finite, so each opportunity supports only a certain size. Competitors run the same logic and the same public data. And gaps that are visible on a dashboard for several seconds are usually not profitable, because anything that persists that long has probably been judged unprofitable by faster players. The honest framing is in whether Ethereum arbitrage is still profitable. If you are new to the vocabulary, what Ethereum arbitrage is covers the basics, and Uniswap and Sushiswap price differences shows where specific gaps come from.
If you want to understand the cost side more concretely, the worked example in gas fees and arbitrage profit is the next stop.
Summary
DEX arbitrage exploits the fact that pools price independently. A bot detects a gap, sizes the trade, simulates it, and executes both legs atomically so that a failure simply reverts. The mechanism is sound. The profitability depends on fees, speed and competition, so verify claims and check current protocol rules before committing capital. This is not financial advice.
Frequently asked questions
How does DEX arbitrage work?
A trader or bot buys a token from the pool that prices it lower and sells it into the pool that prices it higher, usually in one atomic transaction, keeping the difference after fees and gas.
Why do prices differ between DEXs?
Each pool sets price from its own reserves. A trade in one pool moves only that pool’s price until someone trades the gap away.
What is a constant-product pool?
A pool where the product of the two token reserves stays constant after each trade, as in Uniswap V2. Larger trades move the price more.
Can DEX arbitrage be done without capital?
It can be done with borrowed funds via flash loans, but gas must still be paid in ETH.
Sources
- Uniswap Docs – Uniswap V2 how it works – https://docs.uniswap.org/contracts/v2/concepts/protocol-overview/how-uniswap-works
- Uniswap Docs – Fees (V3) – https://docs.uniswap.org/concepts/protocol/fees