DEX 单池执行价分析器(V2 AMM)
This is a CLI tool that analyzes real execution prices on Uniswap V2–like pools,
based directly on on-chain reserves.
Given a pool and a trade size, it shows:
- Mid price (reserve ratio)
- Buy execution price
- Sell execution price
- Slippage impact caused by AMM curves
This tool focuses on single-pool behavior,
not router-optimized or UI-level quotes.
这是一个 命令行工具(CLI),用于分析 Uniswap V2 / V2-like 池子中的
真实成交执行价,数据直接来自链上 getReserves()。
给定一个池子和交易规模(size),它可以计算:
- 中间价(mid,基于储备比例)
- 实际买入执行价
- 实际卖出执行价
- 由 AMM 曲线带来的滑点影响
本工具专注于 单一池子的真实行为,
不是 前端或聚合器的最优报价模拟。
DEX frontends and aggregators usually show optimized quotes:
- Multi-pool routing
- Order splitting
- Price smoothing
However, these optimizations often hide the raw behavior of a pool.
This tool exists to answer a simpler but fundamental question:
If I trade directly in this pool with size X,
what will actually happen?
DEX 前端和聚合器展示的通常是 优化后的报价:
- 多池路由
- 拆单
- 平滑价格曲线
但这些会 掩盖单个池子本身的真实承载能力。
这个工具只回答一个更基础的问题:
如果我真的在这个池子里,用 size = X 交易,
会发生什么?
- Base: the asset being traded (e.g. ETH, WBNB)
- Quote: the asset used to price the base (e.g. USDC, USDT)
- Price = quote / base
- Execution price ≠ UI price
Slippage is non-linear and grows rapidly as trade size increases.
- Base(基准资产):被交易的资产(如 ETH、WBNB)
- Quote(计价资产):用于定价的资产(如 USDC、USDT)
- 价格 = quote / base
- 执行价 ≠ 前端显示价
AMM 的滑点是 非线性的,交易规模越大,惩罚越明显。
- Supports Uniswap V2–like AMMs (Uniswap V2, PancakeSwap V2, Sushi V2, etc.)
- Reads on-chain data directly (
getReserves) - Computes buy / sell execution prices
- Automatically detects quote / base
- Stablecoins are preferred as quote
- Allows manual
--quoteoverride with strict validation - Clear and deterministic output
- 支持所有 V2 模式 AMM(Uniswap V2、PancakeSwap V2、Sushi 等)
- 直接读取链上数据(
getReserves) - 计算真实 买入 / 卖出执行价
- 自动识别 quote / base
- 若池子中包含稳定币,优先作为 quote
- 支持手动指定
--quote(严格校验,错误即退出) - 输出口径清晰、行为确定
- ❌ Not a trading bot
- ❌ Not an arbitrage system
- ❌ Not a Uniswap UI replacement
- ❌ Not a router / aggregator simulator
- ❌ Not MEV-aware
- ❌ 不是交易机器人
- ❌ 不是套利系统
- ❌ 不是 Uniswap 前端替代
- ❌ 不模拟聚合器路由
- ❌ 不涉及 MEV
go run ./cmd \
--rpc https://arb1.arbitrum.io/rpc \
--pair 0xF64Dfe17C8b87F012FCf50FbDA1D62bfA148366a \
--sizes 0.1,1,5Quote/Base selected: USDC/WETH
Pair: 0xF64Dfe17C8b87F012FCf50FbDA1D62bfA148366a
token0(quote)=USDC(6) 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 | token1(base)=WETH(18) 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
reserve0=40807956440 | reserve1=13951121552446518257
DEX(mid) USDC/WETH: 2925.066367
size=0.1 WETH | DEX buy/sell exec USDC/WETH: 2955.049420 / 2895.598120
size=1 WETH | DEX buy/sell exec USDC/WETH: 3160.401864 / 2721.782294
size=5 WETH | DEX buy/sell exec USDC/WETH: 4572.694991 / 2148.567353