DeFi DEX

Uniswap Setup Guide

Time: 15 minutes | Difficulty: Advanced | Market: DeFi DEX Mode: Full automation | API: Smart contract interaction + Subgraph API | Docs: docs.uniswap.org

This guide wires a Uniswap trading bot to the Uniswap V3 smart contracts using the botwir3 runtime. Configure a wallet, connect to on-chain liquidity pools, and run automated DeFi swap strategies locally.


Before you start

Verify that automated operation is permitted under Uniswap's current terms of service before deploying. Uniswap is a permissionless protocol — interaction is through smart contracts on Ethereum (and other supported chains). botwir3 provides tools for building structured automation. The user is responsible for compliance with all applicable regulations.

Uniswap Terms of Service | Last verified: May 2026

What you need

  • An Ethereum wallet with ETH for gas and tokens to trade
  • A private key or keystore file for the wallet (stored locally — never shared)
  • The botwir3 runtime downloaded and unzipped
  • A strategy config file from the builder
  • An RPC endpoint (Infura, Alchemy, or a self-hosted node)

Step 1: Configure wallet credentials

Uniswap is a permissionless protocol. There are no API keys — the bot interacts with smart contracts using a wallet private key.

🔒 Security. The wallet private key controls all funds in the wallet. Use a dedicated wallet for bot trading with only the funds allocated to the strategy. The private key is stored in a local config file and is not transmitted to botwir3 or any third party.

Permissions required: N/A — permissionless protocol. The wallet signs transactions directly. Permissions to disable: N/A. Limit exposure by using a dedicated wallet with limited funds.

Step 2: Configure the adapter

Create adapter.json in the bot directory:

{
  "adapter": "uniswap",
  "credentials": {
    "private_key": "paste-wallet-private-key-here",
    "rpc_url": "https://mainnet.infura.io/v3/paste-project-id-here"
  },
  "trading_pair": "WETH/USDC",
  "chain": "ethereum",
  "slippage_tolerance": 0.5,
  "environment": "live",
  "rate_limit_ms": 5000
}

Common trading pairs: WETH/USDC, WETH/USDT, WBTC/WETH, UNI/WETH.

chain: Uniswap V3 is deployed on Ethereum, Polygon, Arbitrum, Optimism, and Base. Set the chain and RPC URL accordingly.

slippage_tolerance: Maximum acceptable price impact as a percentage. 0.5 = 0.5%. Transactions that exceed this tolerance revert on-chain.

API keys (RPC endpoint credentials) are stored in a local config file on the machine running the bot. They are not transmitted to botwir3 or any third party. botwir3 never sees, stores, or has access to wallet credentials.

Step 3: Test the connection

botwir3 test --adapter uniswap

Expected output:

[botwir3] Adapter: uniswap
[botwir3] Connection: OK (Ethereum mainnet via Infura)
[botwir3] Wallet: 0x1234...abcd
[botwir3] Chain: ethereum
[botwir3] Rate limit: gas-limited (block time ~12s)

Step 4: Start the bot

botwir3 start --config my-strategy.json

The runtime loads the strategy, computes the spec hash, connects to the Uniswap smart contracts via the configured RPC endpoint, and begins evaluating signals. The gate function compares proposed actions against the configured spec. The user is responsible for monitoring the bot and verifying execution outcomes.

Rate limits and considerations

ComponentLimitNotes
RPC endpointProvider-dependentInfura free tier: 100,000 requests/day. Alchemy: similar.
Transaction throughput~12 seconds/block (Ethereum)One transaction per block per wallet nonce.
Gas costsVariableEach swap costs gas. Gas prices fluctuate with network congestion.
Subgraph APIRate-limitedUsed for historical pool data and analytics.

MEV protection. Uniswap swaps on Ethereum mainnet are visible in the mempool before execution. Bots and MEV searchers can front-run or sandwich transactions. MEV protection services (Flashbots Protect, MEV Blocker) route transactions through private mempools to reduce this exposure. The user is responsible for configuring MEV protection if desired.

Common Uniswap bot configurations include arbitrage between on-chain pools and centralized exchanges, liquidity provision management (rebalancing LP positions), and token pair momentum strategies. Gas costs are a significant factor — strategies with high trade frequency require careful gas budgeting. All actions and decisions are recorded in the local ledger.

Troubleshooting

ErrorCauseFix
CONNECTION_REFUSEDRPC endpoint unreachable or invalid project IDVerify rpc_url in adapter config. Check Infura/Alchemy dashboard for status.
INSUFFICIENT_FUNDSWallet balance too low for trade + gasFund the wallet with additional ETH (for gas) and trading tokens
TRANSACTION_REVERTEDSlippage exceeded tolerance, or token approval missingIncrease slippage_tolerance or approve the token for the Uniswap router contract
NONCE_TOO_LOWPending transaction conflictWait for pending transactions to confirm, or manually set nonce
MANDATE_INTEGRITY_VIOLATIONConfig file modified while bot is runningStop the bot, verify config, restart

Related guides


One bot. $129. No subscription. No $749/mo platform. → Build for Uniswap


Build your Uniswap bot

botwir3 compiler

1 Platform

2 Objective