Markdown
Version v2.0 of my arbitrage detector for Uniswap V3 and Aerodrome on Base (WETH/USDC) is now out, tagged and released in rdin777/base_bot.
The goal of v2.0 was to make local runs faster, keep terminal output readable during live observation and screen recordings, and separate cheap prefiltering from expensive on-chain quote verification.
- Full walkthrough (2m03s): Base DEX Arbitrage Detector v2.0: QuoterV2, Compact CLI & JSONL Analytics
- Shorts recap (0m46s): Base DEX Arbitrage Bot v2.0: PREFILTER vs QuoterV2 ($1k vs $5k)
What Changed in v2.0
In runV2.ts and the surrounding evaluation/logging pipeline (detectorLoop.ts, arbitrageEvaluator.ts, opportunityLogger.ts, analyzeJsonl.ts), I focused on four practical improvements:
-
Compact single-line CLI (
--compact): Formats each evaluation into one line (#tick | UNI->AERO | PREFILTER/QUOTED | netUsd (bps) | impact | latency) so live runs and demos stay clean. -
Configurable CLI flags: Added
--trade-size <usd>,--interval <ms>, and--force-quote(which setsquoterTriggerSpreadBpsandminNetProfitUsdto-10_000so you can force liveQuoterV2calls and JSONL writes even when spread is negative). -
Two-stage evaluation (
PREFILTER→QUOTED): Runs a fast local check first before calling on-chainQuoterV2on candidates that pass trigger thresholds. -
JSONL persistence & log summary (
analyzeJsonl.ts): Appends structured records to./logs/arb_<size>.jsonland computes window bounds, net/gross averages and percentiles, per-direction impact stats, and malformed-line counts.
Running the Benchmarks on Base (WETH/USDC)
package.json includes helper scripts for quick checks and log analysis:
bash
npm run check
npm run demo:1k
npm run demo:5k
npm run demo:1k -- --force-quote
npm run analyze:1k
1. Fast PREFILTER at $1,000 (npm run demo:1k)
Running tsx runV2.ts --compact --trade-size 1000 in PREFILTER mode evaluates ticks in 0–4ms without triggering heavy QuoterV2 RPC calls on every cycle:
Direction: UNI->AERO
Latency: 0–4ms
Impact: 0 / 59 bps
Net PnL: around -$3.75 to -$3.84 (-38 bps) at observed spreads
2. Scaling Trade Size to $5,000 (npm run demo:5k)
Increasing --trade-size to 5000 shows how liquidity depth on the second leg changes the math even before any on-chain quote call:
Direction: UNI->AERO
Latency: 0–4ms
Impact: 0 / 171 bps (second-leg impact jumps from 59 bps to 171 bps)
Net PnL: around -$75.70 to -$75.76 (-151 to -152 bps)
3. On-Chain QuoterV2 & JSONL Analysis (--force-quote + analyze:1k)
Passing --force-quote forces the detector through the QUOTED path using on-chain QuoterV2 and writes records to ./logs/arb_1000.jsonl:
Latency: 445–537ms (e.g., 520ms, 446ms, 455ms, 537ms across a 4-record test run)
Impact: 5 / 59 bps (measured 5 bps leg-1 impact from QuoterV2, 59 bps leg-2 constant-product impact)
Net PnL: -3.74$ (-37 bps), gross average -3.66$
Log check (analyzeJsonl.ts): 4 records processed, 0 bad lines, UNI_TO_AERO average leg-1 impact 5.0 bps (p95=5 bps) and leg-2 impact 59.0 bps (p95=59 bps)
Takeaways & Next Steps
Keep hot loops cheap: A 0–4ms local prefilter avoids spending ~450–530ms per tick on QuoterV2 when spreads or size impact already rule out profitability.
Size changes everything: Going from $1,000 to $5,000 on WETH/USDC pushed second-leg impact from 59 bps to 171 bps, turning a minor negative spread into a ~$75 drag.
Log early, analyze systematically: Writing JSONL events and summarizing them with analyzeJsonl.ts makes it straightforward to compare runs without manually eyeballing scrollback.
The repository, README.md updates, and v2.0 release are available at github.com/rdin777/base_bot. As always, this is an experimental research tool—not financial or execution advice.
Tags: #defi, #web3, #typescript, #ethereum
Top comments (0)