Solana
Simulated route
$124.50 model
Example
Ethereum
Private bundle
$840.12 model
Example
BNB
Liquidation test
$45.20 model
Example
Base
Arbitrage test
$12.05 model
Example
Solana
Jito bundle
$310.00 model
Example
Polygon
Route check
$8.45 model
Example
Solana
Simulated route
$124.50 model
Example
Ethereum
Private bundle
$840.12 model
Example
BNB
Liquidation test
$45.20 model
Example
Base
Arbitrage test
$12.05 model
Example
Solana
Jito bundle
$310.00 model
Example
Polygon
Route check
$8.45 model
Example
TraderEvaluation 阶段⏱ 5 分钟阅读

Building Your First Atomic Arbitrage in 2026: Theory to First Fill

**Answer first** — An atomic arbitrage is a single transaction that buys an asset cheap on Pool A, sells it expensive on Pool B, and reverts entirely if the round-trip isn't profit

Atomic arbitrage flow showing two-pool price discrepancy captured in a single transaction
FR
FRB 团队MEV 专家
最近更新
#Arbitrage#MEV#Tutorial#Beginner#Engineering

Answer first — An atomic arbitrage is a single transaction that buys an asset cheap on Pool A, sells it expensive on Pool B, and reverts entirely if the round-trip isn't profitable. In 2026, the easiest first one to build is a two-pool ETH/USDC arb on Base or Arbitrum — same asset pair, different DEXes (Uniswap V3 vs Aerodrome / SushiSwap), small price drift after a large swap on one pool. This article walks through it: pool math, calldata, slippage, simulation, and what your first live fill should actually look like.

If you don't yet know What is MEV, start there.

What Makes an Arbitrage "Atomic"

Three properties:

  1. Single transaction. Buy and sell are in the same tx, not two sequential ones.
  2. Conditional execution. A require(profit > 0, ...) revert if profit doesn't materialize.
  3. Flash-borrowable. Capital can be borrowed and repaid within the tx.

The atomicity is what protects you from execution risk. If anything goes wrong mid-tx, the whole thing reverts and you pay only gas, not principal.

The Theory in 60 Seconds

Two pools price the same asset slightly differently. After a large swap on Pool A pushes its price away from market, Pool B is cheaper. You buy on B, sell on A, capture the spread.

For two AMM pools using constant-product (x * y = k):

Effective_price_A = (reserve_y_A / reserve_x_A) × (1 - fee_A)
Effective_price_B = (reserve_y_B / reserve_x_B) × (1 - fee_B)

If Effective_price_A > Effective_price_B + slippage_buffer, an arb exists.

The optimal trade size is the size that equalizes the two pools' marginal prices. There's a closed-form solution, but you can use binary search or borrow Foundry's helpers.

Choosing Your First Pair

Pick a pair with:

  • High volume on both pools. Low-volume = stale prices but no fill depth.
  • Same fee tier on both pools (e.g. 5bps Uniswap V3 vs 5bps Aerodrome). Different fee tiers complicate math.
  • Direct pair, not multi-hop. Save multi-hop for later.
  • Liquid base asset. ETH/USDC, ETH/USDT, USDC/USDT. Not exotic.

Recommended starter pair on Base: WETH/USDC. Two pools to compare:

  • Aerodrome stable pool (fee 1bps)
  • Uniswap V3 0.05% tier (fee 5bps)

These have hundreds of millions in TVL and predictable spread behavior.

The Tools

You need:

  1. A WSS endpoint to your target chain (e.g. Base WSS via Alchemy or self-hosted).
  2. Foundry installed locally for simulation.
  3. A test wallet funded with $50–100 of ETH for gas + working capital.
  4. ABI for both DEXes' router contracts.

This entire setup runs on a laptop. We're not in production yet.

Step 1: Watch Spread

Subscribe to swaps on both pools and compute spread on every block:

js

js
const aero = new ethers.Contract(AERO_POOL, AERO_ABI, provider);
const uni  = new ethers.Contract(UNI_POOL, UNI_ABI, provider);

provider.on('block', async (n) => {
  const [r0a, r1a] = await aero.getReserves();
  const [r0u, r1u] = await uni.getReserves();
  // ... compute price each side, then spread
});

Watch for an hour. Most blocks: spread <1bp. Some blocks (after large swaps): spread 5–30bp. Note the frequency of profitable spreads.

Step 2: Profitability Threshold

Define "profitable" precisely. For a $5,000 working size:

gross_profit = trade_size × spread_bps / 10000
gas_cost     = gas_units × gas_price (in USD)
slippage     = trade_size × your_slippage_buffer
fees_paid    = trade_size × (fee_A + fee_B)
net_profit   = gross_profit − gas_cost − slippage − fees_paid

On Base, gas for a 2-pool arb tx is ~250–400k gas units. At typical 2026 gas price of ~0.001 gwei, that's $0.04–$0.10. Cheap.

For a $5,000 trade with 8bp spread:

  • Gross: $4.00
  • Gas: $0.08
  • Slippage buffer: $1.50 (3bp)
  • Fees: $3.00 (paid via pool slippage already)
  • Net: ~$2.40

That's a thin margin. Filter for spreads > 10bp on a $5k trade as your minimum.

Step 3: Calldata Construction

Two-pool arb calldata structure:

1. Approve router_B (if not pre-approved) - skip in production with infinite approvals
2. swap on router_B: USDC → WETH
3. swap on router_A: WETH → USDC
4. require(usdc_out > usdc_in + min_profit, "unprofitable")

For simplicity, use a dispatcher contract that does all four in one call. FRB Agent ships one (verified on every chain), or write your own minimal contract.

Minimal Solidity:

solidity
function executeArb(
    bytes calldata buyCalldata,
    bytes calldata sellCalldata,
    address tokenOut,
    uint256 minProfit
) external {
    uint256 startBalance = IERC20(tokenOut).balanceOf(address(this));
    (bool ok1, ) = router_B.call(buyCalldata);
    require(ok1, "buy failed");
    (bool ok2, ) = router_A.call(sellCalldata);
    require(ok2, "sell failed");
    uint256 endBalance = IERC20(tokenOut).balanceOf(address(this));
    require(endBalance >= startBalance + minProfit, "no profit");
}

Real implementations are harder (handle native ETH, multiple routers, callbacks for V3 pools). Treat the above as illustrative.

Step 4: Simulate Every Attempt

Before submitting, simulate the tx on a forked chain:

bash
anvil --fork-url $RPC_URL --fork-block-number latest
cast send --private-key $TEST_KEY $DISPATCHER \
    "executeArb(bytes,bytes,address,uint256)" \
    $BUY_CALLDATA $SELL_CALLDATA $WETH 1000000

If simulation succeeds with profit > min_profit, you're cleared to send. Skipping simulation is the #1 cause of reverts in beginner bots.

Step 5: Submit

For Base, submit to the public mempool (no PBS in 2026 yet on most L2s). Use a moderate priority fee to land in the next block:

js

js
const tx = await wallet.sendTransaction({
  to: DISPATCHER,
  data: dispatchCalldata,
  gasLimit: 500000,
  maxFeePerGas: ethers.parseUnits('0.0015', 'gwei'),
  maxPriorityFeePerGas: ethers.parseUnits('0.0005', 'gwei')
});
const receipt = await tx.wait();
console.log('Status:', receipt.status, 'Gas used:', receipt.gasUsed);

If receipt.status === 1, you landed it. Look at receipt.logs for the actual profit captured.

Step 6: Measure What Happened

Your first 20 attempts will mostly:

  • Revert (missed by another arber): 50–70%
  • Land but underwhelm vs simulation: 15–25%
  • Land profitably: 10–25%

That's normal. The ratio improves as you tune (lower latency, better signal filtering, smarter sizing).

What to log:

  • Spread observed at decision time
  • Spread observed at landing time
  • Predicted profit vs realized profit
  • Gas used vs estimated
  • Why each revert happened (Foundry traces help)

Step 7: Tighten the Loop

After 100 attempts, you'll see patterns:

  • Spreads above some threshold land more reliably
  • Certain hours have higher arb frequency
  • Specific competitors are faster than you in certain windows

Use the patterns to filter what you submit. Submitting fewer, higher-quality attempts beats spraying.

Common First-Bot Bugs

  • Approval missing: contract reverts on first call. Add infinite approval in deploy script.
  • Wrong pool fee tier: math says profit, real swap says loss because the math used 5bp pool but called 30bp pool.
  • Stale reserves: read reserves at block N, submit at block N+1 — state drifted. Re-read inside the contract or use callback-based pricing.
  • Slippage cap too tight: trades that would be slightly profitable revert. Calibrate to actual realized vs simulated.
  • Token decimals: USDC has 6, WETH has 18. Off-by-12 in math is a common bug.

What's Next After Two-Pool

Once two-pool arb runs cleanly:

  1. Three-pool triangular arb: USDC → WETH → DAI → USDC.
  2. Multi-DEX with pathfinding: dynamically pick which two of N pools to use.
  3. JIT liquidity: provide and pull LP around an incoming swap.
  4. Cross-chain arb: requires bridge cost modelling (advanced).

The skill stack compounds: pool math → calldata → simulation → latency → bidding. Two-pool atomic is the foundation.

FAQ

Do I have to write the smart contract myself?

For learning, yes. For production, FRB Agent ships verified dispatcher contracts on every supported chain. Use the built-ins in production; write your own in dev to understand them.

Why are most attempts unprofitable?

You're competing with bots that have lower latency, better signal filtering, and pre-approved liquidity. Beginners get the leftover spreads. That's fine — there are leftovers worth catching.

How much capital should I start with for arb?

$2k–5k. Below that, gas-to-capital is hostile. Above that, you can scale once tuned.

Is this strategy sandwich attack?

No. Two-pool arb between DEXes doesn't extract from a user's swap — it equalizes prices across pools. It's protocol-positive.

Can I run this on Ethereum L1 instead?

Technically yes, economically painful as a beginner. L1 gas of $10–50 per attempt eats most spreads at <$50k trade size. Start on L2.


This is an engineering tutorial. Deploy capital only after running on testnet or with paper-trade mode. Not financial advice.

阅读后的下一步

启动 FRB 控制台

连接您的钱包,通过 6 位 PIN 码配对节点客户端,然后分配上述合约。

需要安装程序?

下载并验证 FRB

获取最新安装程序,将 SHA‑256 与 Releases 对比,然后按照安全启动清单操作。

查看 Releases 和 SHA‑256
分享𝕏 推特in LinkedInf Facebook

相关文章

延伸阅读与工具

讨论

暂无笔记。添加第一条观察,或在以下平台与团队分享链接 X (@MCFRB).

留下笔记
笔记仅存储在您的本地浏览器中。

掌控脉动

扩展您的执行能力

通过探索完整的 FRB 工具包来最大化您的优势。从机构级遥测到随时可导出的策略脚本。

CTA

安装 FRB 代理

下载经过验证的 Windows 版本并检查 SHA-256。

CTA

阅读快速入门文档

与运营和合规团队分享 15 分钟的设置流程。

CTA

启动控制面板

配对节点客户端并实时监控 Ops Pulse。

准备进化了吗?

迈出下一步

无论您是在验证终端安全,还是在启动您的第一个交易包,FRB 之旅都从这里开始。

推荐

安装 FRB 代理

安全的 Windows 版本,通过 SHA-256 验证以确保最高完整性。

推荐

阅读快速入门文档

15 分钟掌握设置流程:从钱包配对到第一个交易包。

推荐

启动控制面板

实时监控您的 Ops Pulse 并管理交易路由。