Consolidation

When multiple ticks are active, they don't remain separate — they consolidate into a single geometric object. Understanding consolidation is key to understanding how the torus invariant emerges.

04 · Consolidation to Torus
Multiple ticks collapse into a single torus: interior sphere swept around boundary circle.

Interior Consolidation

For ticks that are in the interior state (reserves haven't hit the boundary), consolidation is simple:

r_int = ∑ᵢ rᵢ

The radii sum linearly. This makes intuitive sense: if you have two overlapping liquidity zones, their total liquidity is the sum of individual liquidities.

The consolidated interior sphere is centered at (r_int, ..., r_int) with radius r_int.

Boundary Consolidation

For ticks at the boundary, consolidation is more complex. Each boundary tick contributes an "effective radius" in the orthogonal subspace:

s_bound = ∑ᵢ √(rᵢ² − (kᵢ − rᵢ√n)²)

Derivation:

  1. At the boundary, the tick's sphere is cut by the hyperplane x · v = kᵢ
  2. The intersection is an (n−2)-sphere with radius √(rᵢ² − dᵢ²)
  3. where dᵢ = (kᵢ − rᵢ√n) is the distance from the sphere center to the hyperplane
  4. These (n−2)-spheres stack in the orthogonal subspace, summing their radii

The Torus Formation

The consolidated shape is a torus — specifically, an (n−1)-dimensional torus formed by sweeping the interior sphere around the boundary circle.

Think of it this way:

  • The interior sphere has radius r_int
  • The boundary circle has radius s_bound
  • The torus is the set of points at distance r_int from the boundary circle

In 3D, this is the familiar donut shape. In higher dimensions, it's the analogous object.

Consolidated State

After consolidation, the pool state is described by three values:

  • r_int — Interior radius (sum of interior tick radii)
  • s_bound — Boundary effective radius (sum of boundary contributions)
  • k_bound — The boundary hyperplane offset (from the outermost tick)

These three values fully characterize the torus. The contract stores them in global state.

Re-consolidation on Crossing

When a trade causes a tick to cross from interior to boundary (or vice versa), the consolidated state must be recomputed:

  1. Remove the crossing tick's contribution from r_int or s_bound
  2. Flip its state (interior ↔ boundary)
  3. Add its contribution to the other sum
  4. Update k_bound if the crossing tick is now the outermost boundary

This is the swap_with_crossings method in the contract — the most complex operation because it requires updating multiple state values atomically.

Implementation note: The SDK computes which ticks will cross before submitting the swap. The contract verifies each crossing claim rather than computing it from scratch.