Skip to main content

Overview

Every DAMM v2 pool has a collectFeeMode that determines how trading fees flow to LPs. This is set at pool creation and cannot be changed.
ModeValueFee Token(s)Single-SidedPrice Range
BothToken0Token A + Token BAny
OnlyB1Token B onlyAny
Compounding2Token B (auto-reinvested)Full range only

BothToken (mode 0)

Fees accumulate in whichever token the LP provided. When a trader swaps A→B, the fee is taken in token A. When they swap B→A, the fee is taken in token B. LP fee claim: Separate claimPositionFee instruction. Both fee_a_pending and fee_b_pending on the position are claimable. Use when: You want LPs to accumulate fees in both tokens — typical for symmetric liquidity provision.

OnlyB (mode 1)

All fees are collected in token B (the quote token), regardless of swap direction. Fees for A→B swaps are still taken from the input (token A) but immediately converted to the quote token equivalent. LP fee claim: Only fee_b_pending accumulates. fee_a_pending is always 0. Use when: LPs prefer a single, predictable fee token. Common for one-sided launches where token A is the new token and token B is SOL/USDC.

Compounding (mode 2)

The most distinctive mode. A configurable percentage of each trade’s LP fee (compoundingFeeBps) is automatically reinvested back into the pool’s reserves as token B rather than being held for claiming. The remainder is still claimable.

How it works

Trading Fee (LP portion)
  ├── compoundingFeeBps / 10000 → added to pool token B reserves (grows pool liquidity)
  └── remainder → fee_b_pending (claimable by LP)
compoundingFeeBps is a u16 (0–10000). E.g., 5000 = 50% of LP fees compound, 50% claimable.

Constraints

  • Full range only — Compounding pools use MIN_SQRT_PRICE to MAX_SQRT_PRICE. Custom price ranges are not supported.
  • Balanced pools only — Both tokenAAmount and tokenBAmount must be > 0. One-sided deposits cause a DEAD_LIQUIDITY error.
  • compoundingFeeBps must be > 0 when collectFeeMode = 2 (InvalidCompoundingFeeBps error if zero).

Swap result fields

In compounding mode, the swap result exposes two separate fee fields:
FieldDescription
claimingFeePortion the LP can claim later
compoundingFeePortion reinvested into pool reserves
For non-compounding modes, compoundingFee = 0 and claimingFee = tradingFee.

Reading from events

The EvtSwap2 event emits collect_fee_mode on every swap, so you can filter events by mode to track fee behaviour.

Choosing a Mode

Use OnlyB (mode 1). Fees accumulate in your quote token (SOL/USDC), LPs get a clean single-token yield, and it works with one-sided deposits for a bootstrap launch.
Use BothToken (mode 0). LPs benefit from fee accumulation in the base token if it appreciates.
Use Compounding (mode 2). Pool depth increases with every trade. Best for mature, full-range pools with long-term LPs who prefer position growth over regular fee claims.