Trading Bot Development for Arbitrum DEX: Strategies and MEV Protection

A trading bot on a decentralized exchange loses profit when competitors front-run its trades and liquidity drains away. We build such bots for Arbitrum turnkey: we select the strategy, close off trade front-running, and set up monitoring. Profit per trade becomes predictable, and downtime becomes manageable.

Blockchain Development Services

Frequently Asked Questions

Latest works

  • Development of a web application for FEEDME
    Development of a web application for FEEDME
    1359
  • Development of an online store for the company FURNORO
    Development of an online store for the company FURNORO
    1330
  • B2B Advance company logo design
    B2B Advance company logo design
    776
  • Development of a web application for Enviok
    Development of a web application for Enviok
    1077
  • AIDER company logo development
    AIDER company logo development
    1022
  • CRM development for Chasseurs
    CRM development for Chasseurs
    1113

Why a trading bot on Arbitrum loses profit in DEX

A bot that shows steady returns in tests often runs at a loss in a real Arbitrum pool — and it is not a strategy error. Time passes between signal and trade execution, during which price moves.

A trading bot in DEX on Arbitrum loses precisely on this gap, and the causes of losses break down into four measurable points.

First — transactions being front-run by third parties. An order for a split second enters the public queue of pending transactions, others see it and manage to place their trade ahead of it: the pool price shifts, and the bot executes at a worse price.

Second — slippage losses: when position volume is comparable to pool depth, each next order in the route takes liquidity at a higher price, and the projected return is eaten away already on entry into the position and on exit from it.

Third point — delay in reaction to price and connection breaks with the network.

If the node responds late, the quote at the moment of transaction signing is already stale, and after a channel break the bot returns to work with an open position and an outdated view of the balance.

Fourth — failed transactions: the execution condition changed between evaluation and sending, the trade does not go through, but its cost is charged, and resending without considering the new pool state produces duplicates and extra positions.

All four points are measured the same way — by the share of trades where the actual execution price differs from the expected one.

Below we break down how this is closed: by order routing logic, sending transactions bypassing the public queue, and strict slippage control on every trade.

Measurable result: profit per trade and resilience to failures

Count starts from measurement to implementation: median time from signal to order inclusion in a block, share of rejected trades per day, behavior when the node is unavailable, maximum drawdown on a single position.

The same metrics are taken after — at comparable market volatility, otherwise the comparison proves nothing.

Order execution speed on the Arbitrum network stops depending on a single route: the order goes to several liquidity sources, the fee is recalculated before sending, and a rejected transaction is reassembled at the current price.

The share of rejected trades falls due to retries and checking the pool state before signing — the log keeps only isolated cases with an analyzed cause.

Resilience to node failures rests on backup connections: the bot polls several independent sources, when data diverges it takes the value confirmed by the majority and switches without stopping the strategy.

Positions are saved to disk, so bot recovery time is measured in seconds, not manual sorting of open orders.

Risk control per trade is set by explicit limits: share of deposit per position, number of simultaneous entries, loss limit per session, and emergency stop when they are breached.

Here the metric is maximum drawdown: before implementation it was held back by an operator, after — by a rule that triggers before the operator.

All five values are visible in the metrics panel, so the result is confirmed by data, not by a feeling that the bot started working better.

Strategy options: arbitrage, market making, sniping

Strategy determines not only signal logic but also bot architecture: how it reads pool state, how it sends transactions, and where protections are placed. Arbitrage schemes in DEX live on price divergence, market making — on trade flow, sniping new pools — on entry speed. Below is a comparison by application conditions and by what each approach actually limits.

Option When it fits Limitations
Arbitrage between pools One pair trades in two pools or within the network and on an external venue with a persistent price divergence Profit is taken by whoever gets into the block first; private transaction sending and correct slippage calculation on both legs at once are needed
Market making A pool with predictable flow, the bot holds two-sided quotes and recalculates them by spread Risk of accumulating a one-sided position during a sharp move; position size limits and a pause during volatility are required
Sniping new pools Liquidity has just been added, price is not yet aligned with the market High competition for the first block, risk of tokens with selling disabled; strict gas control and a slippage limit

Pair and pool selection is often more important than the strategy itself. We look at pool depth, fee size, number of active liquidity providers, and how much the price inside the pool deviates from the external one.

We calculate slippage limits not as a constant but as a function of order size to depth — in a thin pool, the first large trade eats all the profit.

MEV protection is built on top of any of the three schemes: a private sending channel, separation of signal and execution, cancellation of the order if the pool state changed before inclusion in a block.

Strategies are combined, but then complexity grows — each needs its own metrics and its own stop threshold.

Stages of work: scenario audit, scheme, launch, supervision

Development of a trading bot for DEX on Arbitrum starts with the scenario, not with code: what we consider profit, which pairs we work on, what position size we hold, and how we behave during slippage.

Below are the bot development stages, where each step is closed by a verifiable artifact, not a report of work done.

  1. Scenario analysis. We fix pools and pairs, entry and exit thresholds, per-trade and daily limits, behavior during a sharp price move.
  2. Scheme design. We separate flows: receiving prices, storing keys, sending transactions, position accounting. Separately — a backup path if the main network node is unavailable.
  3. Assembly. We isolate calculation, execution, and logging modules: failure of one does not stop the others.
  4. Testing on a test loop. A run on a copy of network state and on historical data — the divergence between projected and actual trade is visible before going to the main network.
  5. Calibration of MEV protection. We choose the transaction sending method, minimum output, and fee limit at which the trade remains profitable.
  6. Launch on small volume. For the first days the bot trades a fraction of the target position size: execution is checked on live blocks without full stake.
  7. Handover to supervision. We provide the trading stop regulation — at what accounting divergence, series of rejections, or price deviation the bot stops itself and who returns it to work.

Then comes maintenance: reconciliation of accounting with network history, analysis of deviations, and threshold adjustments based on actual data.

What we hand over: source code, schemes, keys, regulations

We hand over not a “working script on a server” but the full contour: code, network interaction scheme, access policies, and regulations by which the system can be developed by your team or given to another contractor without reverse engineering. Below each item is a separate artifact that remains with you.

  • Bot source code — a repository with change history, split into modules for route calculation, trade signing, and risk control; the build is reproduced on a clean environment with one command, without hidden dependencies.
  • Architecture scheme — how the bot reads pool state, where it makes a decision, where it signs, and where it sends a transaction to Arbitrum; external services, failure points, and trust boundaries are marked.
  • Key and permission management — roles are separated: the trade execution key is stored separately from the fund withdrawal key, limits and permissions are set at the policy level, not in code.
  • Observability and alerts — execution metrics, share of rejected and canceled transactions, status panel, and signals to an agreed channel when thresholds are breached; cases of unfavorable execution in the pool are logged separately.
  • Emergency stop instructions — a step-by-step procedure: how to stop trading, revoke permissions granted to the bot, withdraw funds, and who makes this decision.
  • Operations regulations — updating strategy parameters, key rotation, and incident analysis according to a pre-described scenario.

Case: how losses from transaction front-running were removed

A trading bot for pools on Arbitrum held a narrow spread and reset quotes every few blocks.

Orders went to the public mempool as a regular transaction, and part of the profit was taken by sandwich attacks: someone else’s bot inserted before and after our trade and shifted the execution price in its favor.

What it was before

In measurements before work started, the share of trades closed worse than the projected price held at about a quarter of the total. The same class of failures repeated daily: front-running, unfavorable execution, strategy recalculation on the fly.

Some positions had to be hedged with a reverse order, and during volatility the bot lost more than it earned on the spread.

What was changed

Order sending was moved to private delivery channels, where the transaction reaches the validator bypassing the public mempool. Large orders were split into parts with time spacing, and quote updates were tied to pool state, not to a fixed interval.

The protection logic was moved into a separate layer — the strategy stopped depending on exactly how the order is executed.

After the migration, the share of unfavorable executions fell from 24% to 3%, and the spread between projected and actual trade price shrank by about three times.

The failure class “front-running and sandwich” stopped repeating: during the observation period, not a single case of someone else’s bot inserting into our trade was recorded.

The client confirms that strategy returns became predictable over a span of several weeks, instead of jumping from week to week.

What to do if the bot is already running and losing to front-running?

A bot loses to front-running when its order enters the public pool and becomes visible to other strategies: they raise the price before execution or take liquidity first.

Diagnostics start with three metrics — share of trades canceled due to price divergence, gap between projected and actual execution price, and time from signal to inclusion in a block.

If the gap grows together with network load, the problem is not in strategy logic, but in how the order reaches the block.

The first thing to strengthen is the delivery layer. Instead of the public pool, the order goes to private sending channels that pass it directly to block builders; in Arbitrum, such a layer is available from several infrastructure providers.

Two or three independent channels are configured with balancing between them: if one stops accepting orders, the bot continues working through the backup instead of stopping.

Execution priority is set separately for each strategy — so that fast entry does not crowd out arbitrage in the same block.

The core does not need to be rewritten. Calculation modules, risk assessment, and work with liquidity pools remain as they are — what changes is order transport and priority rules.

This is an upgrade of an existing bot, not a new build: proven strategies, accumulated execution statistics, and established limits are preserved.

We measure the result on the same metrics: share of orders executed at a price no worse than projected, time to inclusion in a block, share of rejections during peak network load. It is these, not the return of an individual trade, that show front-running has been closed.

Technical doubts: liquidity, fees, downtime

Before starting, the same five questions are usually asked — not about strategy, but about bot behavior when fees rise, a key is isolated, or a process falls exactly at the moment of a trade. Below are substantive answers.

How does the bot behave when network fees rise?

Before sending, the fee forecast is checked against the expected spread: if gas cost eats the profit, the order does not go. At activity peaks, the strategy does not turn from profitable into loss-making in fact.

Where are keys stored and who has access to them?

Signing is moved to an isolated process: the private key does not leave it and does not get into logs or configuration files. Trading logic passes only trade parameters — the bot’s permissions do not give access to funds.

What happens after a failure or restart?

Position state and unclosed orders are recorded before sending the transaction, so after restart the bot reconciles its journal with the on-chain balance and does not duplicate trades. Open positions are brought to the target state or closed by a predefined rule.

How do you limit slippage?

The transaction parameters include a hard slippage limit: at a worse price the trade is canceled, not executed. Volume is distributed across several pools, so a liquidity drop in one does not skew the execution price.

What protects against front-running transactions in the queue?

Sending goes through a private channel to the block builder, where the transaction is not visible until inclusion in a block. Additionally, we limit order lifetime so that a stalled order does not execute under unfavorable conditions.

Let's discuss the task: we will return with an estimate and launch plan

To return with an estimate and launch plan, not general wording, we need your trading scenario in measurable form. Below are the inputs from the client that we use to calculate the scope of work, name timelines, and the order of stages.

We build a bot for DEX on Arbitrum around three things: strategy logic, trade execution, and MEV protection. That is why data collection also starts with the strategy, not the code.

  • trading pairs and pools where work is planned, with an assessment of current liquidity;
  • entry and exit logic: which event we consider a signal, how often we check market state;
  • risk constraints: maximum position size, allowable slippage, behavior during a sharp price move;
  • operating mode: calculation and signals only, or automatic trade execution;
  • protection requirements: private transaction sending, fee limits, cancellation of stuck operations;
  • access: wallet address for execution, hardware signer or keys, infrastructure permissions;
  • expected load: how many trades per day and how many pools simultaneously in operation.

When the picture comes together, we split the work into stages and name the timeline and result check point for each — from strategy prototype on historical data to launch with monitoring. Describe the task in this scope, and we will return with an estimate and launch plan.