Skip to content
log(swap)

Swapper

Consumes liquidity. One action, one screen.

inputmeaning
amount inhow much you are sending
minimum outslippage tolerance

Select a market and check its fee before quoting. A swap does not require choosing LP boundaries.

// C-pool: one base, one quote
router.swapExactIn(key, baseIn, amountIn, minOut, recipient, deadline);
router.swapExactOut(key, baseOut, amountOut, maxIn, recipient, deadline);
router.swapExactInPath(hops, amountIn, minOut, recipient, deadline);   // multi-hop
 
// F-pool: n bases, one quote — and base↔base directly
router.swapExactIn(poolId, kind, j, k, amountIn, minOut, to, deadline);

Quote first through the lens (previewSwapExactIn / previewSwapExactOut) and set the bound from it. Quotes run the real swap path and revert with the result, so they are exact — including the pending per-block variance fold — and need no funded balances.

What it costs

Two components, both visible before signing.

For an uncapped curve segment, average execution differs from the starting price by approximately half the log price move, with a convexity correction. Formally pˉ/p=g(u)=u/(1−e−u)\bar p/p = g(u) = u/(1-e^{-u}); at a 1% move (u=0.01u = 0.01) the price impact is 1.005% and the average fill lands 50.08 bp above spot.

The swap fee is fixed at market creation in both pool types. C-pool fees are charged in quote; F-pool fees can accrue in the input asset. A direct F-pool base-to-base swap charges both legs. Check the selected market's swapFee; a variance-based fee is a model calculation, not the charged rate.

Price impact does not depend on price

Δx=ΔQL\Delta x = \frac{\Delta Q}{L}

exactly, with no pp on either side. A quote-denominated trade moves log-price by ΔQ/L\Delta Q/L wherever price sits, so:

  • moving the price 1% costs ≈0.00995 L\approx 0.00995\,L of quote;
  • one basis point of impact costs 10−4L10^{-4}L.

LL is therefore a bp-per-dollar liquidity quote that stays true at every price. In Uniswap v2, by contrast, quote input is linear in p\sqrt p, so liquidity silently rescales as price moves.

Exact-out costs the same as exact-in

Every one of the four directions — exactIn quote, exactOut base, exactIn base, exactOut quote — solves in one exp or one log. On curves without a closed-form inverse the exact-out directions require iteration; here they do not. See the four exact cases.

The only constraint is on exactOut base: the base leg cannot be drained. That is the R=0R = 0 asymptote restated as a swap bound.

Multi-hop pays two transfers

Every market of one shape lives in one contract, and the flash-accounting lock spans all of them. A route through several markets accrues deltas per token, so intermediate tokens net to zero and never move: a three-hop route pays two transfers, at its endpoints. See Settlement.

Base-to-base in an F-pool is direct

In a basket, swapping base jj for base kk executes at ΔQ=0\Delta Q = 0 — one log1p, one expm1 — and crosses no ticks, because holding the index fixed leaves every class's drawdown unchanged. It works in a pool that has never held quote.

Both legs pay the fee, 2ϕ2\phi in total, because both assets were repriced. That makes fees route-invariant: base → quote → base costs the same as the direct hop, so there is no routing game to play.

Parking inventory

A market maker can leave a positive delta inside the manager as a token claim — an ERC-6909 IOU on tokens held there — rather than taking it out. Because the manager is a singleton, one parked balance serves every market at once.