Sphere AMM
The sphere invariant is the foundation of Orbital AMM. This page provides a complete derivation of why reserves must live on a sphere, how the center and radius are determined, and how instantaneous prices are computed.
Deriving the Invariant
We start with a simple requirement: the AMM must preserve a conserved quantity that represents "total liquidity". For a two-token pool, Uniswap uses the product invariant xy = k. For n tokens, we need a different approach.
Consider n tokens with reserves x = (x₁, x₂, ..., xₙ). We want an invariant that:
- Is symmetric in all tokens (no token is special)
- Allows any token to be depleted to zero
- Has a bounded state space (reserves can't go to infinity)
- Gives well-defined prices at every point
The sphere invariant satisfies all four:
Expanding this:
nr² − 2r∑ᵢxᵢ + ∑ᵢxᵢ² = r²
∑ᵢxᵢ² − 2r∑ᵢxᵢ + (n−1)r² = 0
Center and Radius
The sphere is centered at c = (r, r, ..., r). Why? Because the center must be equidistant from all axes — if one coordinate were different, that token would be "special", violating symmetry.
The sphere passes through (0, r, r, ..., r) — the single-token-depegged state. Plugging in:
This confirms the radius is r. The radius controls total liquidity: larger r means more capital is required to move prices.
No-Arbitrage Constraint
Reserves must satisfy xᵢ ≤ r for all i. Why? If xᵢ > r, then (r − xᵢ)² > r², which would make the sum exceed r² (since all other terms are non-negative). Geometrically, the reserve point would be outside the sphere.
This gives us a natural price bound: as xᵢ → r, the price of token i goes to infinity. No arbitrage ensures reserves stay within the sphere.
Instantaneous Pricing
The price of token j in terms of token i is the ratio of their marginal changes. We derive it using implicit differentiation.
Start with the invariant:
Differentiate with respect to xᵢ:
Along the invariant surface, dF = 0, so:
−2(r − xᵢ)dxᵢ − 2(r − xⱼ)dxⱼ = 0 (for a trade between i and j)
dxⱼ/dxᵢ = −(r − xᵢ)/(r − xⱼ)
The instantaneous price is:
At the equal-price point (where all reserves are equal), this simplifies to 1. As xᵢ → r (token i is depleted), the price goes to infinity.
The Equal-Price Point
The equal-price point is where all tokens have the same marginal value. On the sphere, this is where the normal vector is parallel to (1, 1, ..., 1).
Solving for this point gives:
For n = 5, this is q ≈ 0.553r. At this point, all tokens trade at parity.
Geometric Interpretation
Think of the sphere as a "liquidity surface". Trades move the reserve point along this surface. The path taken depends on the trade direction:
- Buying token i (removing xᵢ) moves the point toward the xᵢ = r boundary
- Selling token i (adding xᵢ) moves the point away from the boundary
The sphere constraint ensures that every trade has a unique, well-defined outcome. There's no ambiguity about "which way" the point moves.
Note: The sphere invariant alone describes a uniform liquidity pool. Concentrated liquidity comes from restricting trades to subsets of the sphere via ticks, which we cover in Ticks and Caps.