> For the complete documentation index, see [llms.txt](https://docs.crystal.exchange/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.crystal.exchange/liquidity/amm-liquidity-lp.md).

# AMM Liquidity (LP)

Provide passive liquidity to a Crystal market's built-in constant-product pool and earn the pool's swap fee on every trade routed through it.

Every Crystal market has an orderbook and, when enabled, an AMM pool. The pool is a Uniswap V2-style constant-product pool (x · y = k) holding the market's quote and base assets. It lives inside the market contract, not in a separate pool contract, so a single taker order can fill against both the orderbook and the pool in one transaction.

Unlike a vault, nobody operates the pool. The curve sets the price and fills trades automatically.

### How It Works

|                 | Orderbook                   | AMM pool                             |
| --------------- | --------------------------- | ------------------------------------ |
| Who quotes      | Makers placing limit orders | The constant-product curve           |
| Liquidity shape | Discrete price levels       | Continuous across all prices         |
| Provider action | Place and manage orders     | Deposit once, hold LP tokens         |
| Provider earns  | Maker rebate on fills       | 0.25% of every swap through the pool |

### 1. How Trades Route

A taker order walks the book one price level at a time. Before filling each level, the engine checks whether the pool offers a better price. If it does, the trade swaps through the pool just until the pool's price reaches that level, then fills the level, then moves on. The pool's price is compared to orderbook prices after adjusting for the maker rebate, so the comparison is on equal footing.

The result is that the pool fills the gaps between orderbook levels and absorbs volume when the book is thin. Takers always get the better of the two sources at every step.

Limit orders cannot be placed inside the pool's spread. A bid above the pool's ask price or an ask below the pool's bid price is rejected. This keeps the pool at or inside the best bid and ask at all times.

### 2. Add Liquidity

Deposit both assets at the pool's current reserve ratio. You specify the maximum of each asset you are willing to add; the pool takes the matching amount at the current ratio and leaves the rest in your wallet. Set minimum amounts to protect against the ratio moving before your transaction lands.

You receive LP tokens proportional to your share of the reserves. If your deposit is 10% of the pool after adding, you hold 10% of the LP supply.

The first deposit into an empty pool sets the initial price. The pool rejects a first deposit whose implied price would cross the existing orderbook. A fixed 100,000 units of LP tokens from the first deposit are permanently burned, matching the Uniswap V2 minimum-liquidity rule.

Deposits are rejected while the pool is disabled for that market.

### 3. LP Tokens

LP tokens are standard ERC20 tokens with symbol CRY-V2, issued by the market contract itself. They are transferable. Whoever holds them can redeem them.

Your position's value is your share of the reserves. Because swap fees stay in the reserves, the value of one LP token in underlying assets rises with every swap through the pool.

### 4. Remove Liquidity

Burn LP tokens and receive your proportional share of both reserves. Set minimum amounts for slippage protection.

One constraint: a withdrawal cannot leave the pool's price crossing the orderbook. If it would, the pool keeps back just enough of one asset to hold its price at the best bid or ask and pays you the remainder. If that holdback exceeds your share, the transaction reverts. Rebalance the book or wait for it to move before retrying.

There is no lockup. You can withdraw in the same block you deposited.

### 5. Fees

Every swap through the pool pays 0.25% of the input, which stays in the reserves and accrues to LP holders. The protocol takes no cut of this fee.

Takers additionally pay the market's standard taker fee on the whole trade, including any portion filled by the pool. That fee goes to the protocol, referrers, and on launchpad markets the token creator. It does not go to LPs.

### 6. Launchpad Markets

When a launchpad token graduates, its bonding-curve proceeds are seeded into the new market's pool as the initial liquidity. Graduated markets trade like any other: orderbook plus pool.

### 7. Risks

* **Impermanent loss.** The pool rebalances toward the losing asset as price moves. If price moves a lot in either direction, holding the two assets would have been worth more than the LP position.
* **Adverse selection.** The pool fills whenever it is the cheapest liquidity available. It is the first to trade against informed flow.
* **Withdrawal holdback.** If the book has moved past the pool's price, part of your withdrawal may be retained or the withdrawal may revert until conditions change.

Pool reserves are full-range. There is no concentrated liquidity or price range selection.
