DEX Trading Bot Development (Uniswap, PancakeSwap)

We develop trading bots for DEX — systems that seek and execute arbitrage opportunities in milliseconds. Our bots compete at the highest level: a 100-millisecond delay costs money, the mempool is a battlefield, and flawed logic can lead to a sandwich attack. We use our own node, Flashbots, and optim

Blockchain Development Services

Frequently Asked Questions

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1450
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1309
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    1004
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1270
  • image_logo-advance_0.webp
    B2B Advance company logo design
    719
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    1011

We develop trading bots for DEX — systems that seek and execute arbitrage opportunities in milliseconds. Our bots compete at the highest level: a 100-millisecond delay costs money, the mempool is a battlefield, and flawed logic can lead to a sandwich attack. We use our own node, Flashbots, and optimized Uniswap V3 contracts. This article breaks down the architecture of three types of bots (arbitrage, sniper, market-making), the technical implementation using viem/ethers.js, and how to protect against MEV.

Three Types of DEX Bots

Bot Type Goal Complexity Risks
Arbitrage Profit from price discrepancies between DEXs High (MEV competition) Sandwich attacks, high latency
Sniper Buy tokens at pool creation Medium Honeypot, rugpull
Market Making Earn on spread through AMM LP Medium Impermanent loss, volatility

Get a consultation for your project — we will develop a bot tailored to your strategy.

How DEX Bots Work

Arbitrage Bot

Finds price discrepancies between DEXs and extracts profit. Example: ETH is $2000 on Uniswap V3 and $2003 on Curve — buy on Uniswap, sell on Curve, $3 profit minus gas. On mainnet, ETH/USDC arbitrage is a crowded niche with fierce competition. More realistic niches: new tokens in the first hours of trading (low competition), multi-hop routes through 3+ pools, L2 networks (fewer competitors, cheaper gas), exotic pairs on less popular DEXs.

Sniper Bot (New Listing)

Monitors the creation of new pools on Uniswap (PoolCreated event in Factory) or addition of liquidity to a new pool. Upon detection, instantly buys the token anticipating a price discovery pump. Technically: WebSocket connection to Ethereum node, listening to pending transactions in mempool and PoolCreated events. On detection — build and send transaction with high gas priority fee. Risks: honeypot tokens, rugpull, MEV competition. Basic protections: simulate sell transaction before buying, verify contract on verified source code, check distribution supply.

Market Making Bot

Places bid/ask orders around the mid-price, earning on the spread. On Uniswap V3, this is implemented through managing range positions — the bot opens a narrow range position and rebalances when price exits the range. The Uniswap V3 SDK provides all tools: calculate optimal range via tickToPrice, simulate fees earned via Pool.computeSwapStep.

How to Protect Against Sandwich Attacks

Your transactions are visible in the mempool and can be attacked: a bot sees your $10K purchase, inserts its own purchase before and sale after. Protections:

  • Private RPC: Flashbots Protect, MEV Blocker — transactions don't enter the public mempool
  • Tight slippage: 0.1–0.3% for liquid pairs makes sandwich unprofitable
  • TWAP execution: split large order into parts

Average savings on fees via private mempool is up to 30%.

Why a Custom Node is Critical for Speed

Provider Latency Cost Applicability
Infura 50–200 ms Free/paid Prototypes
Alchemy 30–150 ms Paid Medium projects
Custom node (Erigon) 1–5 ms High (server) Competitive trading

For competitive arbitrage, a custom node is mandatory. We also use eth_feeHistory for gas estimation and Flashbots for atomic bundles. Reducing latency by 95% gives an edge in the race for profit.

How to Launch a Basic Arbitrage Bot: Step-by-Step

  1. Choose strategy and target pairs (e.g., ETH/USDC on Uniswap V3)
  2. Set up RPC provider: custom node or Alchemy
  3. Deploy smart contracts (if custom logic required)
  4. Run Node.js script with viem/ethers.js
  5. Set up monitoring via Telegram bot and Grafana
Typical mistakes when developing a DEX bot - Using Quoter V2 on-chain instead of mathematical calculation (slow) - No sandwich protection (slippage > 0.5%) - Operating without tests on testnet before mainnet - Incorrect gas fee configuration (missed block)

Technical Implementation

Working with Uniswap V3

Uniswap V3 is the most common DEX for bots. Key contracts:

  • UniswapV3Factory — pool creation
  • SwapRouter02 — swap execution (V3 + backward compatible V2)
  • Quoter V2 — off-chain quotes without gas
  • UniversalRouter — universal router (supports V2, V3, and other protocols)
import { ethers } from "ethers"; import { Pool, Route, Trade, SwapRouter } from "@uniswap/v3-sdk"; import { CurrencyAmount, TradeType, Percent } from "@uniswap/sdk-core"; const quoter = new ethers.Contract(QUOTER_V2_ADDRESS, QuoterV2ABI, provider); const amountOut = await quoter.callStatic.quoteExactInputSingle({ tokenIn: WETH_ADDRESS, tokenOut: USDC_ADDRESS, fee: 3000, amountIn: ethers.utils.parseEther("1"), sqrtPriceLimitX96: 0 }); 

For production, we replace callStatic quotes with our own mathematical calculation using on-chain state — faster and independent of Quoter availability. We use the Uniswap V3 whitepaper as the basis for gas optimization.

Speed: How to Hit the Right Block

Latency is money. Optimization levels: RPC level: Infura/Alchemy add 50–200 ms latency. Custom Ethereum node (geth or erigon) — 1–5 ms.

Mempool monitoring: via eth_subscribe("newPendingTransactions") we get hashes of pending transactions. Flashbots Protect API provides access to private mempool.

Gas strategy: EIP-1559 transactions. maxFeePerGas must be sufficient for block inclusion. For urgent transactions — maxPriorityFeePerGas above current block median.

Bundle via Flashbots: for arb transactions needing atomic inclusion — Flashbots MEV-Boost. Protection from frontrunning.

Protecting Your Own Bot from MEV

We use private RPC, tight slippage, and TWAP execution. Additionally, we audit smart contracts for reentrancy and oracle manipulation.

PancakeSwap and Multi-Chain

PancakeSwap V3 (BNB Chain) — similar architecture to Uniswap V3, same SDK concepts. BNB Chain: block every 3 seconds (faster than Ethereum), cheaper gas. PancakeSwap also on Ethereum and Arbitrum. Multi-chain bot works with multiple RPC providers. viem is preferred over ethers.js for TypeScript projects — better typing, treeshaking, built-in multicall.

import { createPublicClient, http } from "viem"; import { mainnet, bsc, arbitrum } from "viem/chains"; const clients = { ethereum: createPublicClient({ chain: mainnet, transport: http(ETH_RPC) }), bsc: createPublicClient({ chain: bsc, transport: http(BSC_RPC) }), arbitrum: createPublicClient({ chain: arbitrum, transport: http(ARB_RPC) }) }; 

Stack and Infrastructure

TypeScript + viem/ethers.js. Node.js worker threads for parallel processing. Redis for pool state caching. PostgreSQL for trade history and PnL. Deploy on VPS with low latency to Ethereum nodes (Hetzner Frankfurt, AWS eu-west). PM2 for process management + Telegram alerts.

What Is Included in the Work

  • Architectural diagram of component interaction
  • Source code with comments (TypeScript/viem)
  • Deployment on your VPS or cloud
  • Monitoring setup (Telegram alerts, Grafana)
  • Operations and recovery documentation
  • Training of your specialist (1 hour online)

Time Estimates

Basic arbitrage bot for one DEX pair — 3–5 days. With multi-DEX routing, mempool monitoring, and Flashbots integration — 1–2 weeks. Sniper bot with sell simulation — 3–5 days. Market-making bot with Uniswap V3 LP management — 1–1.5 weeks. The cost is calculated individually after strategy audit.

Our Experience and Guarantees

We are a team of 5 senior developers with a combined 7+ years in Solidity and blockchain infrastructure. We have launched 15+ trading systems for clients from the USA and EU. We work with Ethereum, BNB Chain, Arbitrum, Optimism, Polygon. Contact us — we will evaluate your project and offer the optimal solution. Order bot development turnkey with guaranteed results.