> ## Documentation Index
> Fetch the complete documentation index at: https://docs.meteora.ag/llms.txt
> Use this file to discover all available pages before exploring further.

# DAMM v2 Compounding Liquidity

> Learn how DAMM v2 compounding liquidity reinvests a share of LP fees into full-range pool reserves.

DAMM v2 compounding liquidity is a pool mode where a share of LP fees is automatically reinvested back into the pool. Instead of every LP fee waiting to be claimed and manually compounded back, the pool can use part of those fees to grow reserves and deepen liquidity over time.

This is useful for long-term pools where LPs want liquidity growth, fewer manual fee actions, and a simpler full-range market design.

## How It Works

Compounding liquidity uses `Compounding` collect fee mode. In this mode:

* The pool behaves like a full-range constant-product AMM.
* Fees are collected in token B.
* A configurable share of the LP fee is added back into the pool's token B reserves.
* The remaining LP fee stays claimable by position owners.

```math theme={"system"}
\text{LP Fee} = \text{Compounding Fee} + \text{Claimable Fee}
```

The compounding share is controlled by `compounding_fee_bps`, in basis points.

| `compounding_fee_bps` | Product Meaning                                       |
| --------------------- | ----------------------------------------------------- |
| `2500`                | 25% of LP fees compound, 75% remain claimable         |
| `5000`                | 50% of LP fees compound, 50% remain claimable         |
| `10000`               | 100% of LP fees compound, no LP fee remains claimable |

<Note>
  `compounding_fee_bps` must be greater than `0` and at most `10000` for compounding pools. It must be `0` for `BothToken` and `OnlyB` pools.
</Note>

## Full-Range by Design

Compounding pools do not use custom concentrated price ranges. The program stores their range as `0` to `u128::MAX` and prices them from reserves:

```math theme={"system"}
\text{token A reserves} \times \text{token B reserves} = k
```

This makes the pool easier to reason about: reserves grow as compounded fees are added back, and LPs benefit proportionally through their position liquidity.

## Initial Liquidity

Compounding pools have one special initialization rule: the requested initial liquidity must be greater than `DEAD_LIQUIDITY`, which is `100 << 64`. DAMM v2 subtracts this dead liquidity from the first position's liquidity while keeping it in the pool's total liquidity.

<Info>
  The dead-liquidity rule prevents the pool from starting at a fragile zero-liquidity edge. It also means the first position receives slightly less liquidity than the raw initialization liquidity.
</Info>

The initial token amounts are derived from the requested liquidity and initial square-root price:

```math theme={"system"}
\text{token A} = \left\lceil \frac{L}{\sqrt{P}} \right\rceil
```

```math theme={"system"}
\text{token B} = \left\lceil \frac{L \times \sqrt{P}}{2^{128}} \right\rceil
```

The initial square-root price still must be inside DAMM v2's global price limits, even though the compounding pool itself has no custom range.

## What LPs Experience

In a non-compounding pool, LP fees accumulate as claimable balances on the position. In a compounding pool, the LP fee is split after the protocol fee is removed:

* **Compounded portion**: added to pool reserves, increasing pool depth.
* **Claimable portion**: remains pending on the LP position and can be claimed later.

This lets a pool balance two goals: grow liquidity over time and still provide claimable fee income.

## Why Token B Matters

In compounding mode, fees are always handled in token B. For an A-to-B swap, the fee is taken from token B output. For a B-to-A swap, the fee is taken from token B input. Token B is commonly the quote token, such as SOL or USDC.

## Product Benefits

<CardGroup cols={2}>
  <Card title="Automatic Reserve Growth" icon="arrows-rotate" iconType="solid">
    A share of LP fees goes directly back into the pool, increasing liquidity without a separate reinvest action.
  </Card>

  <Card title="Simpler Full-Range Liquidity" icon="infinity" iconType="solid">
    The pool follows the familiar constant-product model instead of a custom price range.
  </Card>

  <Card title="Flexible Fee Split" icon="scissors" iconType="solid">
    Pool creators can choose how much LP fee compounds and how much remains claimable.
  </Card>

  <Card title="Long-Term LP Alignment" icon="handshake" iconType="solid">
    LPs benefit from deeper pool reserves while still owning their position through an NFT.
  </Card>
</CardGroup>

## Best Use Cases

<AccordionGroup>
  <Accordion title="Mature Trading Pairs">
    Established markets can use compounding liquidity to grow depth as trading activity generates fees.
  </Accordion>

  <Accordion title="Passive LP Strategies">
    LPs who prefer fewer manual actions can let part of their fee income automatically support the pool.
  </Accordion>

  <Accordion title="Treasury or Protocol-Owned Liquidity">
    Projects can use compounding to reinforce long-term liquidity depth while keeping fee behavior transparent on-chain.
  </Accordion>
</AccordionGroup>

## When Not to Use It

Use concentrated liquidity instead if the pool needs a custom minimum and maximum price range. Compounding liquidity is intentionally full-range, so it is not the right fit for a tightly targeted launch range.
