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:
- 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.
- Polar decomposition — We decompose reserves into two components: α (position along the equal-price axis) and w (orthogonal trading component).
- Ticks as spherical caps — Each tick cuts a cap off the sphere using a hyperplane constraint.
- Consolidation — Multiple ticks aggregate into a single interior sphere and a single boundary circle.
- Torus formation — The consolidated shape is a torus: the interior sphere swept around the boundary circle.
- 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:
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:
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.
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:
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:
Boundary ticks contribute an effective radius in the orthogonal subspace:
The combined shape is a torus — imagine taking the interior sphere and sweeping it around the boundary circle.
The Torus Invariant
The master equation that the contract verifies is:
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:
- Sphere AMM — Full derivation of the sphere invariant and instantaneous pricing
- Polar Decomposition — Why x = αv + w is the right move
- Ticks and Caps — Tick geometry and virtual reserves
- Consolidation — How multiple ticks collapse
- Torus Invariant — The master equation
- Capital Efficiency — The sales pitch, formalized