Skip to content

Uniswap V3 API

Protocol-specific classes for Uniswap V3 — the concentrated-liquidity AMM with sqrt-price arithmetic and tick-spaced positions. These live in uniswappy and are imported into DeFiPy’s namespace at install time.

When working through DeFiPy’s Core API, you typically don’t touch these classes directly — Join, Swap, etc., dispatch to them. You’ll reach for them when constructing a V3 pool from scratch with a specific tick range and fee tier, when inspecting tick-level state, or when extending the library.

ClassModulePurpose
UniswapV3Factoryuniswappy.cpt.factoryDeploys V3 pools. factory.deploy(exchg_data) returns a fresh V3 exchange.
UniswapV3Exchangeuniswappy.cpt.exchgThe V3 pool — sqrt-price, tick bitmap, fee accumulators (feeGrowthGlobal0X128 / feeGrowthGlobal1X128), and per-position state.
UniswapV3ExchangeDatauniswappy.cpt.exchgConfiguration: token pair, fee tier (in pips), tick spacing, address.
ModulePurpose
uniswappy.utils.tools.v3.UniV3UtilsCore tick math ported from the on-chain contract — getMinTick, getMaxTick, sqrt-price/tick conversion.
uniswappy.utils.tools.v3.UniV3HelperHigher-level helpers — quote() for non-mutating swap projection (note: hard-codes 30 bps; see backlog).
uniswappy.utils.tools.v3.TickMathDirect port of the on-chain TickMath library; financial-grade precision.
ModulePurpose
uniswappy.analytics.riskUniswapImpLoss — handles V3 IL math via concentrated-range adjustments.

V3 pools store the fee tier on pool.fee as pips (millionths):

Tierpool.feeCommon use
0.01%100Stable-stable pairs
0.05%500Stablecoin / blue-chip
0.3%3000Standard pairs
1%10000Exotic / illiquid

To convert to a multiplier: 1 - pool.fee / 1_000_000.

  • collected_fee0 / collected_fee1 update synchronously during Swap().apply(). Reading CheckPoolHealth after a swap reflects the updated values immediately.
  • No per-swap fee history. V3 has the running accumulator (feeGrowthGlobal*X128) but no fee0_arr / fee1_arr — rate-window metrics that V2 supports return None on V3.
  • UniV3Helper.quote hard-codes the 30-bps fee regardless of pool.fee. For 0.01%, 0.05%, or 1% pools the helper diverges from real-pool output. Tracked in the cleanup backlog; affects LPQuote(include_fee=True) reads on non-30-bps V3 pools.