Math Overview

This section provides a bird's-eye view of the mathematical pipeline that powers Orbital AMM. Understanding this flow is essential before diving into the individual derivations.

The Pipeline

The math layer transforms raw token reserves into a geometric object that can be verified on-chain. Here's the complete pipeline:

  1. Reserves on a sphere — Token reserves x = (x₁, ..., xₙ) are constrained to live on the surface of an n-dimensional sphere centered at (r, r, ..., r) with radius r.
  2. Polar decomposition — We decompose reserves into two components: α (position along the equal-price axis) and w (orthogonal trading component).
  3. Ticks as spherical caps — Each tick cuts a cap off the sphere using a hyperplane constraint.
  4. Consolidation — Multiple ticks aggregate into a single interior sphere and a single boundary circle.
  5. Torus formation — The consolidated shape is a torus: the interior sphere swept around the boundary circle.
  6. Trade execution — Swaps are computed by solving the torus invariant for the new reserve state.

From Reserves to Sphere

The sphere invariant is the foundation:

∑ᵢ₌₁ⁿ (r − xᵢ)² = r²

This equation ensures that reserves always sum to a fixed "liquidity budget". When one token's reserve decreases (someone buys it), another's must increase. The sphere constraint is what makes this a zero-sum game.

Polar Decomposition

The key insight that makes O(1) verification possible is polar decomposition. We write reserves as:

x = αv + w

where v = (1/√n, ..., 1/√n) is the unit vector along the equal-price direction, α = (∑ᵢ xᵢ)/√n measures position along that direction, and w is orthogonal to v. The contract only needs to track ∑xᵢ and ∑xᵢ² to reconstruct the full state.

02 · Polar Decomposition
Reserves decomposed into α (equal-price axis) and w (orthogonal trading component).

Ticks and Caps

A tick is defined by parameters (r, k) where r is the sphere radius and k is the hyperplane offset. The tick boundary is where:

x · v = k

When reserves hit this boundary, the tick is exhausted and the pool transitions to the next tick. This is how concentrated liquidity works: each tick provides liquidity only within its price range.

Consolidation to Torus

When multiple ticks are active, they consolidate into a single geometric object. Interior ticks (where reserves haven't hit the boundary) sum their radii linearly:

r_int = ∑ rᵢ (for interior ticks)

Boundary ticks contribute an effective radius in the orthogonal subspace:

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

The combined shape is a torus — imagine taking the interior sphere and sweeping it around the boundary circle.

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

The Torus Invariant

The master equation that the contract verifies is:

r_int² = (α_int − r_int√n)² + (‖w‖ − s_bound)²

Given the pre-trade state (r_int, s_bound) and the proposed trade (Δx_in, Δx_out), the contract computes the post-trade state and checks that this equation holds. This is O(1) verification regardless of how many tokens or ticks are involved.

What Comes Next

The following pages derive each piece in detail: