Stochastic.Finance Docs

Last updated 12 September 2026

Dynamic swap fee

SF Swap does not charge a fixed 30 basis points. Its fee starts at a 2% floor and climbs with the distance between the pool's price and the model's price, up to a 100% cap.

This is the single biggest departure from Uniswap V2, and it exists because options are not spot.

The problem it solves

A constant-product pool prices its assets purely from its own reserves. That works for two assets whose relative value drifts slowly. An option is different:

  • its fair value decays deterministically as expiry approaches, every block;
  • it reprices violently when spot moves, far more than spot itself does;
  • it has a hard end date, so there is no mean reversion to wait for.

A pool of option tokens is therefore always somewhat stale, and a fixed low fee hands that staleness to whoever is fastest. Worse, near the boundaries the curve itself becomes exploitable: an option approaching zero value can be minted cheaply in quantity and swapped into a pool, where the constant-product formula — for which a small absolute price change near zero is an enormous relative one — pays out a disproportionate amount of USDC. The pool ends up full of near-worthless options and empty of cash.

The protocol answers this twice:

  1. Structurally, with the zero shift: no option leg's value can approach zero, so the degenerate region of the curve is never reached.
  2. Economically, with the dynamic fee: the further a trade pushes the pool from fair value, the more it costs.

The formula

On every swap the router computes the model price from the closed-form pricer and compares it with the pool's implied price. With

$$r = \frac{P_{model}}{P_{pool}}$$

the fee is

$$F = f \cdot X + (1 - X), \qquad X = \frac{A}{r} \, e^{-(\ln r - 0.5)^2}$$

where \(f = 0.02\) is the flat floor and \(A = e^{0.25}\) is a normalisation chosen so that \(X = 1\) exactly at \(r = 1\), giving \(F = f\) when the pool agrees with the model. Because \(F\) is a convex combination of \(f\) and 1, it is guaranteed to land in \([f, 1]\), and it is clamped at 1 for safety.

The \(1/r\) factor together with the \(-0.5\) offset inside the square makes the curve symmetric in log price: a pool trading at twice fair value and one trading at half fair value are penalised identically.

Dynamic fee as a function of the model-to-pool price ratio

What it costs in practice

\(P_{model}/P_{pool}\) Fee Reading
1.0 2.00% Pool at fair value — the floor
1.1 or 0.9 2.9% / 3.1% Minor drift, barely penalised
1.2 or 0.8 5.2% / 6.8% Normal drift between trades
1.5 or 0.67 ~16.9% Meaningful divergence
2.0 or 0.5 39.4% Pool badly mispriced
3.0 70.7% Deep divergence
5.0 or 0.2 92.7% Approaching the cap
10 or 0.1 99.5% Effectively closed

The shape is the point. Ordinary arbitrage, the kind that keeps the pool honest, pays close to the floor and remains profitable. Predatory extraction at extreme divergence pays nearly everything it would have taken.

A high fee is a circuit breaker, not revenue

The fee is retained in the pool. It is not taken by the protocol, not sent to a treasury, and not shared with anyone. It accrues to liquidity providers as compensation for exactly the impairment the divergent trade is causing them. The protocol's own revenue comes solely from the exercise fee.

Mechanics

Charged in USDC, always. Liquidity providers are compensated in the asset they care about, so the fee is taken on the stablecoin side in both directions. Buying an option pulls the fee on top of the USDC you specified; selling one nets it out of your proceeds.

Bounded by you. Because the fee depends on conditions at execution, swapStableOnTrade takes a maxStableAllowed cap. If the live fee would push your total spend past it, the swap reverts and nothing moves. At the cap the total can reach roughly double your input, so 2 × amountStable accepts any fee the curve can produce.

Continuous and monotone. The charged amount rises smoothly with divergence all the way to the cap — there is no discontinuity where an attacker could find a cheap window.

Next

© Stochastic Finance Protocol — All Rights Reserved