Liquidity Book Design
1. Reserve Pricing
- Price P = ΔY/ΔX
- Represents value of token X in terms of token Y
2. Bin Liquidity
Each bin has Liquidity (L), always measured in quote asset (Y). Liquidity is conserved as reserve composition changes.3. Bin Composition
- Composition factor c = % of liquidity in Y
- c ∈ [0,1]
- Bin fully described by (L, c)
Understanding the Composition FactorThe composition factor (c) tells you how the liquidity in a bin is split between the two tokens:
- When c = 0: The bin contains 100% X tokens and 0% Y tokens
- When c = 0.5: The bin contains 50% X tokens and 50% Y tokens
- When c = 1: The bin contains 0% X tokens and 100% Y tokens
4. Market Aggregation
All bins combine into the market curve:- Bins < market price → only Y
- Bins > market price → only X
- Market price = lowest-priced bin with X reserves
5. Market Making
LPs can:- Place liquidity around specific price bins
- Customize spreads and ranges
- Adjust bins independently
Liquidity LifeCycle
1. Add / Remove Liquidity
- Active bin → must match composition, else auto-swap (with fee)
- Inactive bin → add only X or Y (not both)
2. Swaps
- Within bin: only composition changes, not price
- If exhausted → move to next bin
3. Fees
- Base fee (fb) – depends on bin step
- Variable fee (fv) – based on volatility
- Protocol fee (fp) – protocol share
