3.2 KiB
3.2 KiB
04: Elliptic Concentrated Liquidity Pool (E-CLP)
Source
- Protocol: Gyroscope
- Files:
GyroECLPMath.sol(53KB),eclp_float.py,eclp_prec_implementation.py - Repos:
gyrostable/gyro-pools,balancer/balancer-v3-monorepo - Paper:
gyrostable/technical-papers/E-CLP/E-CLP Mathematics.pdf
Rationale for MYCO
The E-CLP is the most mathematically sophisticated AMM curve in production. It adds two degrees of freedom beyond the 2-CLP:
- Rotation (φ): Tilts the price curve, useful when the target price ratio isn't 1:1
- Stretching (λ): Controls how elongated the ellipse is — higher λ = more concentrated near the peg, like a flattened oval
For MYCO:
- The A-matrix transformation is the key abstraction that generalizes to N dimensions
- Rotation handles non-unit price targets (e.g., ETH/USDC at $3000)
- Stretching controls how much slippage increases as reserves deviate from target
- Production-tested on Balancer V3 with formal security review and technical paper
- The 5 parameters (α, β, c, s, λ) provide fine-grained curve shaping
Invariant
|A(v - \text{offset})|^2 = r^2
where:
v = (x, y)are reserve balances\text{offset} = (a, b)are virtual offsets (functions of $r$)Ais the 2×2 transformation matrix mapping ellipse → unit circleris the scalar invariant (liquidity parameter)
A-matrix:
A = \begin{pmatrix} c/\lambda & -s/\lambda \\ s & c \end{pmatrix}
5 Parameters:
| Param | Meaning | Range |
|---|---|---|
\alpha |
Lower price bound | (0, 1) typically |
\beta |
Upper price bound | (1, ∞) typically |
c |
\cos(-\phi) — rotation |
[0, 1] |
s |
\sin(-\phi) — rotation |
[0, 1] |
\lambda |
Stretching factor | [1, 10^8] |
Constraint: c^2 + s^2 = 1
Derived parameters (computed once, stored as immutables):
\tau(\alpha), \tau(\beta)— unit circle endpoints at 38-decimal precisionu, v, w, z— decomposition ofA \cdot \chi(center direction)d_{Sq}— error correction forc^2 + s^2
Swap Math
Given new x, solve for y on the ellipse via quadratic:
(A_{01}^2 + A_{11}^2) \cdot v^2 + 2(A_{00} A_{01} + A_{10} A_{11}) \cdot u \cdot v + (A_{00}^2 + A_{10}^2) \cdot u^2 = r^2
where u = x - a, v = y - b, solved with standard quadratic formula.
Properties
- Elliptical iso-invariant curves: Level sets are ellipses (not circles or hyperbolas)
- Concentrated + rotated: Liquidity concentrated along the ellipse's long axis
- Homogeneous degree 1:
r(k \cdot v) = k \cdot r(v)— compatible with BPT math - Degenerates to 2-CLP: When
\lambda = 1and\phi = 0, the ellipse becomes a circle
MYCO Application
The E-CLP is the 2-asset specialization of the full MYCO bonding surface. For any pair of reserve assets within the N-D surface, the local geometry is essentially an ellipse — the N-D surface is an N-D generalization of this.
The A-matrix pattern is the key insight: by encoding geometry as a linear transform, we can:
- Compute invariants efficiently (quadratic formula, not iterative)
- Parameterize curves with intuitive knobs (rotation, stretch)
- Generalize to N dimensions naturally (N×N matrix)
Implementation
See src/primitives/elliptical_clp.py