Skip to content
log(swap)

Fee machinery

The concept is that fees are a path statistic. This is what ships.

The C-pool accumulator

A claim is Li⋅ΔFL_i\cdot\Delta F over the active interval, computed O(1)O(1) by a Uniswap v3-style flipped per-tick accumulator: each tick stores fOutside, flipped on crossing, and a position carries an entry snapshot. A crossing costs one flip regardless of how many classes reference the tick.

The compounding identity survives intact: a quote injection is a floor translation Δξ=−f/L\Delta\xi = -f/L — the same additive shift for every active position, independent of LiL_i and ξi\xi_i — so ladder spacing and ordering are preserved.

Per-holder state is one slot per (holder, class) plus a settle-on-transfer hook. claim() pays a holder's accrued fees and leaves LL untouched, and a late depositor starts at zero claimable with no contribution to anyone's pot.

Where the pot sits — outside the curve, inside the share:

counts?
toward LL, price, liquidity, the floorno — the invariant reads the curve quote only
toward the shareyes — a share is a claim on the position plus accrued fees

That separation is the point: compounding would otherwise move the floor, and the whole reason classes are fungible with zero per-holder path state is that fees live outside share value.

The mint fee

Newly earning C-pool exposure pays key.mintFee times the increase in earning liquidity, in quote. The creator fixes this rate in the key. The current local contracts require 2 * swapFee <= mintFee <= 2%.

The fee goes to the protocol treasury when configured. Otherwise it is distributed through FF to pre-existing active liquidity before the new position's snapshot. With neither a treasury nor active liquidity to receive it, no fee is pulled. The minter receives full pro-rata shares.

Dormant and capped-out mints do not pay this fee. Edits receive credit for existing earning exposure and pay on the net increase. For example, a 2 bp mint fee on L=1000L=1000 costs 0.20 quote units, in addition to the position's required reserves.

FF includes swap income and any mint fees routed to active LPs. The displacement identity dF=ϕ∣dx∣dF=\phi\lvert dx\rvert describes swap segments; distributed mint fees add separate increments.

The swap-fee tax

C-pool swap income is credited before any payout tax. The market's policy sets swapFeeTax at initialization, bounded at 25% and fixed for that market. On a claim or burn, the taxed portion is reserved for the protocol when a treasury is configured. Fee views report the holder's net amount.

Fixed swap fees and variance measurements

Both pool types charge the fixed swapFee selected at creation. The current C-pool key has no alpha, kappa or phiMin fields. The variance statistic Σ\Sigma remains available for comparing fee income with realized LVR.

The matched gain describes a variance-based pricing model. The following estimator discussion records the earlier dynamic-fee design; it does not describe the fee charged by current contracts.

How the estimator samples

One observation per swap. A swap books its own total (Δx)2(\Delta x)^2 regardless of how many ticks it crossed. The swap is the economic event; ladder geometry must not price it.

That replaced per-segment sampling, which was wrong twice over. Variance is quadratic, so chopping one move into nn pieces gives ∑(u/n)2=u2/n\sum(u/n)^2 = u^2/n: an identical move of Δx=0.449\Delta x = 0.449 measured 1988 bp of fee crossing no ticks and 491 bp crossing four — a 4× swing from ladder density alone. And there was no time dimension at all: two swaps in one block and two a thousand blocks apart left byte-identical state, so a quiet hour decayed nothing.

Accumulated within a block, folded on the next. Swaps in the same block sum into a block total, which enters the EMA when a later block opens. Silent blocks decay it, one (1−α)(1-\alpha) factor each, bounded at 8 steps.

Note Σ\Sigma is a separate accumulator and still integrates per segment — it is total realized quadratic variation for the edge readout, not the fee kernel, and finer sampling is correct there.

Why the decay is α=12\alpha = \tfrac12

Not a tuning choice. By the swap law each swap executes at the log-midpoint of its own move, so the pool price is already an EMA of the external price with weight 12\tfrac12 per trade. Setting α=12\alpha = \tfrac12 makes the variance kernel that prices LVR track the same weighting the pool actually trades at, rather than measuring one thing and charging for another. It is the LVR-protection mechanism, not a smoothing parameter.

A slow α\alpha lags what it prices — undercharging through a volatility spike, exactly when LVR is worst, then overcharging long after the move is done — and it spreads one large trade's penalty across ∼1/α\sim 1/\alpha later traders (≈3 swaps at α=0.5\alpha = 0.5, ≈100 at 0.01).

Both ends are bounded

A floor of 1 bp (default 2 bp), because the estimator is cold in exactly the windows an attacker picks.

A cap of 25%. An arbitrageur closes a gap gg only when g>2ϕg > 2\phi, so ϕ\phi is the half-spread and the cap bounds the worst spread the pool will quote. Under α=12\alpha = \tfrac12 a one-block jump JJ quotes ≈0.443∣J∣\approx 0.443\lvert J\rvert next block, so the cap binds for one-block moves above ~56% — depegs and exploits, not routine flow — decaying by 2\sqrt2 per silent block.

In that earlier design, α\alpha, κ\kappa and ϕmin⁡\phi_{\min} were key fields. They are absent from the current fixed-fee key.

The F-pool ships fixed ϕ\phi with a computable kernel

ϕ\phi is constant, but Σ\Sigma accrues anyway — one slot, one add per touched leg — so the fee the kernel would quote and the edge F−12ΣF - \tfrac12\Sigma stay computable by anyone, on-chain, in a pool that has no fee accounting at all.