Triangular Arbitrage on DEXs: How to Spot and Execute Profitable Trades
Step‑by‑step walkthrough of triangular arbitrage using Uniswap and OasisDEX (Eth2DAI) pair examples, with calculators and risk warnings.
Step‑by‑step walkthrough of triangular arbitrage using Uniswap and OasisDEX (Eth2DAI) pair examples, with calculators and risk warnings.
Triangular Arbitrage on Decentralized Exchanges: How to Spot and Execute Profitable Trades
Published: June 2026
---
Table of Contents
1. [Introduction to Triangular Arbitrage on DEXs](#introduction)
2. [Fundamental Concepts: Tokens, Pools, and Price Curves](#fundamentals)
3. [Why Triangular Arbitrage Exists on Uniswap and OasisDEX](#why‑exists)
4. [Step‑by‑Step Walkthrough: From Quote to Settlement](#walkthrough)
5. [Risk Management, Slippage, and Transaction Costs](#risk‑management)
6. [Analytical Tools, Calculators, and Real‑Time Data Sources](#tools)
7. [Putting It All Together: A Complete Example](#example)
8. [Conclusion and the Role of Specialized Scanners]
9. [Frequently Asked Questions](#faq)
---
Introduction to Triangular Arbitrage on DEXs <a name="introduction"></a>
Triangular arbitrage is a classic market‑efficiency test that exploits temporary price mismatches among three related assets. In the context of decentralized exchanges (DEXs) such as Uniswap V3 and OasisDEX, the practice has grown from a theoretical curiosity to a scalable, algorithm‑driven strategy.
A triangular arbitrage cycle on a DEX involves three trades that start and end with the same token. The three trades are typically executed in rapid succession, often within a single transaction (atomic execution). If the product of the three exchange rates exceeds one after accounting for fees, the trader captures a profit measured in the starting token.
Why does this opportunity appear? Liquidity on DEXs is supplied by automated market makers (AMMs). Each pool maintains a constant‑product invariant (or a more advanced curve such as the Uniswap V3 “concentrated liquidity” formula). When traders interact with a pool, the price curve shifts. Because each pool is independent, the relative price of Token A versus Token B in Pool 1 can diverge from the price implied by Pool 2 (Token B ↔ Token C) and Pool 3 (Token C ↔ Token A).
The following sections dissect this phenomenon, provide a concrete methodology for spotting arbitrage, and illustrate execution on the popular Uniswap and OasisDEX pairs ETH ↔ DAI and ETH ↔ USDC (the “Eth2DAI” route).
---
Fundamental Concepts: Tokens, Pools, and Price Curves <a name="fundamentals"></a>
1. Tokens and Their Representations
| Symbol | Common Name | Typical Use Case | Typical Decimals |
|--------|-------------|------------------|------------------|
| ETH | Ethereum | Base layer asset, gas, store of value | 18 |
| DAI | Dai Stablecoin | USD‑pegged collateralized debt position | 18 |
| USDC | USD Coin | USD‑pegged fiat‑backed token | 6 |
Understanding the decimal placement of each token is critical when constructing a calculator. A mis‑aligned decimal factor will produce erroneous profit estimates.
2. Liquidity Pools and Invariant Functions
- Constant‑Product AMM (Uniswap V2): x * y = k where x and y are reserves.
- Concentrated Liquidity (Uniswap V3): ∫_{priceL}^{priceU} L * p^{-1} dp = k where liquidity L is allocated within a price range [priceL, priceU].
- Hybrid Curve (OasisDEX): Implements a piecewise linear function that mimics a constant‑product curve near the equilibrium but softens friction for small trades.
Each formulation yields a marginal price that changes with trade size. The marginal price for a swap of Δx of token X into token Y is:
\[
P_{X\rightarrow Y}(\Delta x) = \frac{y_{reserve}}{x_{reserve} + \Delta x} \times (1 - \text{fee})
\]
where the fee for most DEXs is 0.30 % (Uniswap V2/V3) or 0.15 % (OasisDEX).
3. Transaction Costs on Ethereum
| Cost Component | Approximate Value (June 2026) |
|----------------|------------------------------|
| Base gas per transaction | 21,000 gas |
| Uniswap V3 swap (single pool) | 50,000 – 80,000 gas |
| Three‑pool triangular arbitrage (atomic) | 150,000 – 210,000 gas |
| Gas price (average) | 35 gwei |
| ETH price (USD) | $1,850 |
The monetary gas cost equals gas × gas price × ETH price. For a 180,000‑gas transaction at 35 gwei, the cost is roughly $11.5. This expense must be subtracted from any gross profit to determine net profitability.
---
Why Triangular Arbitrage Exists on Uniswap and OasisDEX <a name="why-exists"></a>
1. Independent Liquidity Providers
Liquidity providers (LPs) on each pool choose their own capital allocation and fee tier. Uniswap V3 allows providers to concentrate liquidity within a narrow price band, while OasisDEX uses a more uniform distribution. These divergent strategies lead to distinct price surfaces for the same token pair.
2. Asynchronous Price Updates
DEXs operate on a mempool model where every trade is settled in its own block. When a large market order hits the ETH‑DAI pool on Uniswap, the price shift is reflected immediately in that pool’s state. However, the ETH‑USDC pool on OasisDEX may still reflect the prior block’s price because the transaction ordering is not synchronized. This lag creates a temporary arbitrage window that can be captured within a single block if the trades are bundled atomically.
3. Fee Tier Differentiation
Uniswap V3 features multiple fee tiers (0.05 %, 0.30 %, 1.00 %). A trader may prefer a low‑fee tier for high‑volume swaps, but that tier often has less liquidity, leading to higher price impact for a given trade size. OasisDEX applies a flat 0.15 % fee, but its fee is applied to the aggregated trade volume. The combination of different fee structures creates a price spread that can be exploited.
4. Market Momentum and Oracles
On‑chain price oracles such as Chainlink aggregate data from multiple DEXs. If an oracle lags behind the actual pool state, external bots may place orders based on stale data, inadvertently widening the triangle price gap.
---
Step‑by‑Step Walkthrough: From Quote to Settlement <a name="walkthrough"></a>
1. Identify the Token Triangle
For the purpose of this guide, we will work with the triangle ETH → DAI → USDC → ETH. The three pools involved are:
| Pool | AMM Type | Fee |
|------|----------|-----|
| Uniswap V3 ETH/DAI (0.05 % tier) | Concentrated Liquidity | 0.05 % |
| OasisDEX DAI/USDC | Hybrid Curve | 0.15 % |
| Uniswap V3 ETH/USDC (0.30 % tier) | Concentrated Liquidity | 0.30 % |
2. Pull Real‑Time Reserve Data
Use a public RPC endpoint (e.g., Alchemy or Infura) and the eth_call JSON‑RPC method to query the pool contracts. For Uniswap V3, the slot0() function returns the current sqrt price; for OasisDEX, the getReserves() function returns raw token balances.
Example (pseudo‑code):
`js
const ethDaiPool = new ethers.Contract(UNISWAP_V3_ETH_DAI, UNISWAP_V3_ABI, provider);
const ethDaiSqrtPrice = await ethDaiPool.slot0(); // returns Q64.96 format
`
Convert the sqrt price to a decimal rate:
\[
\text{Rate}_{ETH\rightarrow DAI} = \left(\frac{\text{sqrtPrice}}{2^{96}}\right)^2
\]
Perform the same conversion for the other two pools.
3. Compute the Implied Cross‑Rate
The triangular arbitrage condition is:
\[
\text{Rate}_{ETH\rightarrow DAI} \times \text{Rate}_{DAI\rightarrow USDC} \times \text{Rate}_{USDC\rightarrow ETH} > 1 + \text{TotalFeeFactor}
\]
where
\[
\text{TotalFeeFactor} = 1 - (1 - f_{1})(1 - f_{2})(1 - f_{3})
\]
and \(f_{i}\) denotes each pool’s fee (expressed as a decimal).
If the left‑hand side exceeds the right‑hand side, the triangle is profitable before gas.
4. Size the Trade
Maximum profitable size is limited by:
- Liquidity depth – Large trades move the price curve; profit diminishes as the trade size grows.
- Gas budget – The larger the trade, the higher the required gas due to more complex calldata.
A common approach is to solve for ΔETH that satisfies:
\[
\text{Profit}(\Delta ETH) = \Delta ETH \times \Big( \text{ProductRate}(\Delta ETH) - 1 \Big) - \text{GasCost}
\]
Because the product rate is a decreasing function of ΔETH (price impact), numerical methods such as Newton‑Raphson are employed to locate the optimum.
5. Build an Atomic Transaction
Leverage the multicall or router contract offered by Uniswap V3 to bundle the three swaps. The transaction must include:
1. swapExactETHForTokens (ETH → DAI).
2. swapExactTokensForTokens (DAI → USDC).
3. swapExactTokensForETH (USDC → ETH).
All three calls are placed in a single execute function that reverts if any sub‑swap fails, guaranteeing that the trader either captures the full profit or experiences no net change.
6. Submit the Transaction
Sign the transaction with a hot wallet or a hardware wallet that supports the EIP‑1559 fee market. Set the maxPriorityFeePerGas slightly above the average to increase inclusion probability. Once the transaction is mined, verify the receipt:
- Confirm that the final ETH balance is greater than the initial balance.
- Record the effective gas price and compare to the projected cost.
---
Risk Management, Slippage, and Transaction Costs <a name="risk-management"></a>
1. Slippage Protection
Even though the transaction is atomic, each swap may experience slippage due to other concurrent arbitrage bots. To mitigate this risk, set a maximum acceptable slippage for each sub‑swap (e.g., 0.2 %). Most router contracts accept a deadline and a minimumAmountOut parameter.
2. Front‑Running and Sandwich Attacks
An adversarial bot may see the pending arbitrage transaction in the mempool and try to front‑run it by submitting a higher‑gas transaction that consumes a portion of the pool’s liquidity. The arbitrageperp then experiences reduced profit or even a loss. Counter‑measures include:
- Using a private transaction relay (e.g., Flashbots) to hide the transaction from the public mempool.
- Randomizing the start time of the arbitrage loop to avoid predictable patterns.
3. Gas Price Volatility
Ethereum’s gas market can spike dramatically during network congestion (e.g., during major NFT drops or popular DeFi events). When gas prices exceed the estimated profit margin, the trade becomes unprofitable. Include a gas price ceiling in your algorithm: abort the trade if the real‑time gas price surpasses a threshold derived from
ArbitrageRadar PRO on the App Store · arbitrageradarpro.com
Related guides
- Automated Triangular Arbitrage Trading: Tools and Strategies
- Best Exchanges for Triangular Arbitrage in Crypto (2026)
- Best Triangular Arbitrage Calculators and Tools for 2026
- Best Triangular Arbitrage Calculators and Tools in 2026
- Best Triangular Arbitrage Calculators and Tools
- Build Your Own Crypto Triangular Arbitrage Tool with Python and Binance API
All guides · Coins · Exchanges