How V2 Works
V2 pools use the constant product formula, the same model pioneered by Uniswap V2. Each pool holds reserves of exactly two tokens and maintains the invariant: Where:x= reserve of token Ay= reserve of token Bk= constant (increases only from fees)
Price Determination
The price of token A in terms of token B is simply the ratio of reserves: When a trader swaps token A for token B, they deposit A and withdraw B. The new reserves must still satisfyx * y = k (after fees), which naturally adjusts the price.
Swap Mechanics
For a swap ofdx amount of token A into the pool:
- The input amount minus the 0.3% fee is added to reserve A
- The output amount
dyis calculated such that the invariant holds:
dy:
Price Impact
Larger trades relative to pool reserves cause greater price movement. This is called price impact and is inherent to the constant product curve — the price moves along a hyperbola. For a trade of sizedx against reserve x:
A trade that equals 1% of the reserve causes roughly 1% price impact.
Liquidity Provision
LPs deposit both tokens in proportion to the current reserves. In return, they receive LP tokens representing their share of the pool. When adding liquidity:- If the pool exists: tokens must be deposited at the current price ratio
- If the pool is new: the first depositor sets the initial price