Hashtag Web3 Logo

Arbitrage in DeFi Markets

A guide to understanding arbitrage in DeFi, a trading strategy that exploits price differences for the same asset across different exchanges to make a.

Arbitrage Opportunities in DeFi Markets Explained

DeFi arbitrage is a trade that captures a temporary difference between two prices for economically equivalent assets. A simple case is ETH priced lower in one ETH/USDC pool than in another. The trader buys ETH from the cheaper pool and sells it to the more expensive pool. Both trades change the pools' balances, pushing the first price up and the second down.

That description leaves out the part that determines whether a trade pays: the displayed price is not a guarantee. A real arbitrage must cover swap fees, the price movement caused by its own order, transaction fees, any borrowing fee, and the cost of winning a place in a block. Ethereum's MEV documentation calls DEX arbitrage the most familiar MEV opportunity and describes the two-leg trade as atomic when it is executed in one transaction. It is also highly competitive. Ethereum's MEV guide notes that searchers may bid away 90% or more of gross MEV in fees when many parties pursue the same opportunity.

This article is for readers who want to understand what arbitrage bots do, why a quoted gap is usually not profit, and how this activity affects ordinary swaps. It is not a promise that manual trading can compete with specialist searchers.

A price difference is only the starting signal

Prices differ because DeFi does not have one shared order book. Each automated market maker, or AMM, holds its own token reserves and executes swaps against its own curve. A large trade on one pool can move its quoted price immediately. Another pool may not see a trade until later. Liquidity can also be split among fee tiers, chains, and protocols, which leaves several local prices for the same asset.

Suppose a bot observes these quotes for a small ETH trade:

Pool Quoted ETH price
Pool A 3,000 USDC
Pool B 3,012 USDC

The visible spread is 12 USDC per ETH, or 0.4%. That is gross spread, not net profit. If each pool charges a 0.30% fee, paying both fees alone costs roughly 18 USDC on 3,000 USDC of notional. The trade is already negative before gas and price impact. Fee tiers and exact amounts matter more than a dashboard's rounded spot price.

The relevant calculation is:

net profit = sale proceeds
           - purchase cost
           - all swap fees
           - price impact on every swap
           - gas and inclusion payment
           - loan premium, if borrowed
           - any bridging, exchange, or inventory cost

For a same-chain atomic trade, the bot can encode a minimum acceptable final balance. If the swaps cannot repay the input and clear that minimum, the transaction reverts. A revert avoids taking the bad trade, but the sender still pays for gas consumed before the EVM stops. That distinction matters when a strategy submits many losing attempts.

The price being compared also needs to describe the same thing. A pool's marginal price is the price for the next tiny unit. A trader receives an average price over the entire order. Comparing a marginal quote in one pool with an execution quote in another creates an imaginary spread. Quotes for wrapped assets, yield-bearing tokens, or bridged versions can differ for a real reason, such as a redemption delay, a bridge risk, or a different claim on underlying assets. They are not automatically interchangeable arbitrage legs.

How AMMs create and remove the gap

An AMM does not match a buyer with a particular seller. It accepts input tokens and returns output tokens according to the pool's reserves and rules. In a constant-product AMM, the reserve relationship is often written as x * y = k. When a trader sends USDC in and takes ETH out, USDC reserves rise and ETH reserves fall. The next unit of ETH costs more.

Uniswap explains that its swaps execute against passive liquidity rather than a first-in-first-out order book. Each swap pays a fee to liquidity providers, and the amount of liquidity available near the current price determines the order's price impact. Its swap documentation describes price impact as the price change caused during execution, while slippage is a change that occurs while a submitted transaction waits to execute. They are related but separate costs.

The same mechanics give arbitrage its market function. If ETH is cheap in Pool A, an arbitrageur buys ETH there. That removes ETH and adds USDC, raising Pool A's price. Selling ETH into expensive Pool B adds ETH and removes USDC, lowering Pool B's price. The bot stops once the remaining price difference is no longer enough to pay all costs. It does not make every pool report the exact same number. It keeps differences within the range where a trade is no longer worth executing.

Concentrated-liquidity AMMs make the calculation less uniform. In Uniswap v3 and v4, liquidity providers can allocate capital inside chosen price ranges. Liquidity outside an active range is not used for swaps. The Uniswap concentrated-liquidity documentation says a position stops being active and stops earning fees when price leaves its range. A trade that crosses into a thin range can move the price much more than a quote based on the current tick suggests. Crossing initialized ticks also increases transaction cost.

Stablecoin pools use different curves because their assets are intended to trade near the same value. They may offer low impact near the peg and increasingly poor prices as an imbalance grows. An apparent USDC/USDT discount can therefore be a signal that the pool has absorbed a real redemption or credit concern. An arbitrage bot still needs the price to recover enough to cover fees. The AMM does not know whether a peg will return.

What an atomic arbitrage transaction does

Most on-chain DEX arbitrage is a sequence of contract calls within one transaction. The trader may start with USDC, swap USDC for ETH in Pool A, swap that ETH for USDC in Pool B, then check that the ending USDC balance exceeds the starting amount and required costs. Contracts can route across several pools and tokens, but every intermediate amount must be simulated with the actual pool state.

Atomicity is the protection. Ethereum either applies all state changes from the transaction or reverts them together. A bot does not end the block holding ETH from the first swap if the second swap fails. That makes the two-pool same-chain case different from buying on a centralized exchange, withdrawing, bridging, and later selling elsewhere. The latter has transfer delays, custody constraints, and price exposure between legs. It may be called arbitrage, but it is not riskless in the atomic sense.

Arbitrage can also be triangular. A route might be USDC to WETH, WETH to DAI, then DAI to USDC. The product of the executable exchange rates must exceed one after every fee and price impact. It is not enough for each pair's screen price to look favorable. A router or searcher calculates the output for the exact input size at each hop because the first swap changes the reserves used by the next route only when they share a pool.

Protocols often expose execution limits for this reason. Uniswap integrations use amountOutMinimum for an exact-input swap, amountInMaximum for an exact-output swap, and a deadline. Uniswap's documentation states that a swap reverts when it cannot meet those limits. Arbitrage contracts use equivalent checks around the whole route. A safe-looking minimum that is too loose can turn a moved market into a loss. A very strict minimum can cause frequent reverts and repeated gas costs.

Flash loans change capital needs, not the economics

A flash loan lends assets without prior collateral only if the borrowed amount plus its fee is available before the transaction ends. It does not provide free money or remove the need for liquidity. It supplies temporary purchasing power for an arbitrage that already has a profitable route.

In Aave v3's documented flow, the pool transfers assets to the receiver contract, calls the receiver's executeOperation(), and then pulls the principal plus premium at the end. If the repayment conditions are not met, the transaction reverts. Aave's flash-loan documentation lists arbitrage as an application and says its initial total premium is 0.05%, subject to governance updates. That premium belongs in the net-profit calculation. It can eliminate a narrow spread by itself.

Flash loans have useful boundaries. The requested reserve must have sufficient enabled liquidity. The receiving contract must work correctly with the lending protocol and every DEX it calls. The entire route must fit within gas and block execution limits. A failed transaction still costs the originator gas. A bug in the receiver contract, a bad token approval, or an incorrect assumption about a token's transfer behavior can make execution fail before the final check.

They also concentrate competition. If a route is profitable only because it can trade a large amount, any other searcher can borrow the same sort of capital and compete for the same state change. Capital access is not the scarce advantage. Accurate simulation, low-latency data, efficient transaction construction, and access to block-building channels are closer to it.

MEV determines who executes first

MEV is value available from including, excluding, or reordering transactions in a block beyond standard rewards and gas fees. Searchers monitor chain state and pending activity, find candidate routes, and submit transactions or bundles. Block builders decide transaction ordering in the blocks they construct, while validators select block payloads under common Ethereum block-building arrangements.

A public transaction can expose an opportunity to competitors before it lands. Ethereum's MEV guide describes generalized frontrunners that copy a profitable transaction, substitute their own address, simulate it, and submit it with a higher gas price. That is why many searchers avoid broadcasting their arbitrage transaction to the public mempool. Private submission reduces some copying risk but does not guarantee inclusion or a profit.

Flashbots bundles are ordered groups of one or more transactions submitted to block builders for a target block. A bundle can include a user's pending transaction and the searcher's own transaction. A searcher may use a bundle to place a trade immediately after the state change that opens the price gap. Bundles can fail to land because another builder does not receive them, a different bid is higher, the target state changes, or the bundle is invalid for the targeted block.

DEX arbitrage and sandwiching should not be treated as the same thing. Cross-pool arbitrage reacts to a price difference that already exists. Sandwiching observes a user's pending swap, trades before it to worsen the user's price, and reverses the trade after the user. Ethereum's MEV overview says sandwich victims face increased slippage and worse execution. An arbitrage transaction can follow a user swap and bring a pool back toward other market prices without sandwiching that user. The exact ordering and route decide the effect.

Competition has a direct cost. Searchers can bid higher priority fees or pay builders through bundle economics to obtain inclusion. A transaction with a large gross spread can therefore produce no economic profit for its sender even if it executes successfully. The value may instead go to the block producer through the winning bid. Searchers also spend money on node infrastructure, simulation, data feeds, development, and failed attempts. None appears in an AMM quote.

Fees, slippage, and trade size

An arbitrage order changes the price that it is trying to capture. The larger the input, the more gross spread it may capture at first, but the more it moves both pools. There is usually an optimal size where the marginal revenue from one more unit equals the marginal cost from fees and price impact. Going beyond that size turns the final units into a loss.

Consider a route where buying one ETH costs 3,000 USDC before fees and selling it returns 3,020 USDC before fees. The apparent gross profit is 20 USDC. A 0.30% fee on the buy costs 9 USDC. A 0.30% fee on the sale costs about 9.06 USDC. Before gas, the remaining amount is about 1.94 USDC. Any material price impact, flash-loan premium, or inclusion cost removes it. The same route might work for a smaller size, fail for one ETH, and work again only after a later price move.

Slippage tolerance is not a prediction that the price will move by that amount. It is the worst execution a transaction is willing to accept while pending. A 5% tolerance gives a much larger range in which a swap can execute than a 0.5% tolerance. For an ordinary user, that extra room can make a sandwich attack more profitable. For an arbitrage contract, it can allow a route to complete after its modeled edge has disappeared. The right bound comes from the route's measured profitability, not a universal percentage.

Gas has two parts in this context: gas used and the price paid per gas. Multi-hop routes, tick crossings, loan calls, and token approvals use more gas than a simple transfer. The price per gas rises when searchers and ordinary users compete for inclusion. Ethereum's gas documentation explains that a reverted contract call still uses gas for computation that occurred before the revert. A bot must estimate this loss across unsuccessful attempts, not only deduct the gas from its rare winning trade.

Limits and failure cases

The easy mental model says arbitrage is risk-free because an unprofitable atomic route reverts. The narrower statement is accurate: atomic execution can prevent inventory loss on a correctly written same-chain route. It does not remove operational, contract, or economic risk.

  • State can change between simulation and inclusion. Another searcher may consume the opportunity first. The losing transaction can revert and pay gas, or execute within overly permissive limits.
  • Pool data can be stale or incomplete. Quotes based on a subgraph, an indexer, or a slow RPC endpoint may not match the chain state that the transaction executes against.
  • Token behavior can break assumptions. Transfer-fee tokens, rebasing tokens, paused contracts, blacklists, and nonstandard ERC-20 return behavior can cause received amounts to differ from a route model.
  • A protocol contract can contain a vulnerability, be upgraded, be paused by its governance process, or interact badly with a custom integration. An atomic revert helps only when the failure occurs inside the same transaction and the contracts enforce the expected checks.
  • A private relay or builder is not a certainty of privacy or inclusion. The route can be outbid, omitted, simulated by another party, or invalidated by a changed target block.
  • Cross-chain and centralized-exchange routes are exposed to transfer, bridge, withdrawal, and settlement delays. The asset price can move before the second leg completes. A bridge's wrapped token may also trade at a discount that reflects its own risk.

For liquidity providers, arbitrage is a trade-off rather than a free service. It brings a pool's price closer to other markets, but the pool is the counterparty selling an asset after an external price rise or buying it after a fall. The arbitrageur earns the difference after costs; liquidity providers bear the inventory change while receiving swap fees. The Uniswap documentation describes how a concentrated position can end up entirely in one asset when price leaves its range. Fees may or may not compensate for that inventory result.

For ordinary swappers, the practical distinction is execution quality. Deep liquidity, a sensible minimum-output setting, and a short deadline limit how much a transaction can be harmed while pending. No setting guarantees a fill. If the price moves beyond the stated limit, a protected swap should revert rather than accept a worse trade. That protection can still cost gas, which is the remaining price of declining a changed market.

Looking for a Web3 Job?

Explore thousands of verified blockchain, DeFi, and crypto roles on the #1 Web3 job board.

Related Reading

Explore more guides and career playbooks