Skip to content
log(swap)

Numerics and verification

Solvency is the derivation, not a shadow

With no reserve shadow, the F-pool re-derives reserves from (L,xj)(L, x_j) on every read — so every token leg must move by that same derivation. Each swap out-leg and each mint pull is a difference of two reads, never an independently evaluated closed form.

The reason is not stylistic. Two exponential evaluations of the same quantity disagree by ~1 ulp, and the version that disagreed the wrong way shorted the pool monotonically under one-directional flow — until the last burn reverted. The tested invariant is that every share can always be burned.

The C-pool derives its reserve too

The C-pool stores xx and LaL_a and derives the base reserve R=Le−xR = L e^{-x} in wei. That conversion is a rounded quantity with a direction: floored where base leaves the pool, ceiled where base enters, the state itself never rounded. It is taken at ∣x∣|x| (one mulDiv of LL by e∣x∣e^{|x|} for x>0x>0), so it carries eighteen digits at every price. Read as e−xe^{-x} in WAD, the relative error grows as ex⋅10−18e^{x}\cdot 10^{-18}. That reaches the protocol's 10−610^{-6} bound at x≈27.6x \approx 27.6, the wei log-price of an 18-decimal quote against a 6-decimal base at parity.

The displacement a base amount buys is rounded for the pool in both directions: up for a buy (the buyer pays for at least the distance), down in magnitude for a sale (the mark never implies more base than was paid in). On a deep book one wei of log-price is R⋅10−18R\cdot 10^{-18} of base, so that rounding decides whether the shadow stays on the curve. A reserve under 10610^{6} wei is refused, so one wei of error is at most one part per million. The rules and the measurements are numerics §5–§6 and decisions 023 and 103.

Guardrails

Fee bounds as in Fee machinery.

Seeding is authority-only. Deployment is two transactions and nothing binds them, so an open seed lets anyone front-run the deployer and fix both LL and the mark.

Parameters are validated at creation, so a mis-parameterised market reverts at initialize rather than going live dead.

Manipulate-then-liquidate does not live in the swap path. The leverage extension gates liquidations on an oracle, and its satellite refuses to liquidate while pool price deviates from the oracle beyond a bound — so the manipulation blinds the mechanism it meant to exploit, and honest swaps are never refused. This is why the base fee can sit at its LVR-optimal level instead of doubling as a manipulation deterrent.

Quoting

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. previewSwapExactIn / previewSwapExactOut on the lens; quoteSwap on the managers.

Verification

More than 500 tests, including 25,600-call stateful invariant harnesses covering solvency, reserve tracking, pointer consistency, signed-ladder consistency, fee backing and backstop integrity. Each harness is probed for vacuity by fault injection.

14 Halmos symbolic proofs cover:

  • the tick bitmap — search soundness and completeness over the full index range;
  • the id packing — injectivity, over a 2642^{64} key space no fuzzer covers;
  • the id namespace — every position id carries the reserved bit, so no token claim can collide with one;
  • the delta bookkeeping.

The exponential swap math is SMT-intractable and is covered by symbolic re-derivation and fuzzing instead.

What is proven and what is assumed. The packing layer and the namespace bit are Halmos proofs over their full domains. The hashing layer is not an SMT theorem and is not claimed as one: the encode step is fixed-width and injective by construction, and the id keeps 255 bits of keccak, so cross-class collision reduces to 255-bit collision resistance — a cryptographic assumption.

The differential standard

The singleton was reached by porting a per-pool implementation, and the two are held to a differential standard: identical randomised operation sequences against both, with every state variable agreeing bit for bit after every operation.

The retired per-pool code is kept and never modified — only compared against — and its test suites still run. That is the point: the engine is identical, so those suites and the differential proof together are what make "the port changed packaging, not behaviour" a checked claim rather than an assertion.

Status

The protocol is pre-release: implemented and verified end to end against local deployments, not yet audited and not deployed to a public network.