Locking liquidity / collecting fees

Lock LP tokens permanently using the Burn & Earn program and collect your share of trading fees via a Fee Key NFT.


How it works

When you lock LP tokens:

  1. Your LP tokens are transferred to the Burn & Earn locker program — they cannot be withdrawn.

  2. You receive a Fee Key NFT that represents your locked position.

  3. The Fee Key NFT entitles you to claim trading fees that have accumulated in the pool.

How fee harvesting works under the hood

In a constant-product pool, fees aren't stored separately — they accumulate in the pool vaults, making each LP token worth more underlying tokens over time. The only way to extract that accrued value is to redeem (burn) LP tokens.

When you harvest from a locked position:

  1. Your locked position holds, say, 1000 LP tokens.

  2. Swaps occur, fees flow into the pool vaults, and each LP token appreciates in value.

  3. You call harvestLockLp with an lpFeeAmount (e.g. 5 LP).

  4. The locker program burns those 5 LP via a withdraw on the CPMM program.

  5. You receive the proportional share of token A + token B to your wallet.

  6. Your locked position now holds 995 LP tokens.

The LP balance does decrease with each harvest. However, the remaining 995 LP tokens are worth roughly what the original 1000 were before fees accumulated, because each LP token is now worth more. You are extracting the appreciation, not the principal.

The lpFeeAmount parameter controls how much LP to burn.


Locking LP tokens

Use raydium.cpmm.lockLp() to permanently lock LP tokens and receive a Fee Key NFT.

Lock parameters

Parameter
Type
Description

poolInfo

object

Pool info from API or RPC.

poolKeys

object

Pool keys. Required for devnet.

lpAmount

BN

Amount of LP tokens to lock, in smallest units.

withMetadata

boolean

If true, creates on-chain metadata for the Fee Key NFT.

programId

PublicKey

Locker program. Mainnet default is auto-resolved. Devnet: DEVNET_PROGRAM_ID.LOCK_CPMM_PROGRAM.

authProgram

PublicKey

Locker auth program. Devnet: DEVNET_PROGRAM_ID.LOCK_CPMM_AUTH.

txVersion

TxVersion

Transaction version.

circle-exclamation

Collecting fees from locked liquidity

Use raydium.cpmm.harvestLockLp() to claim accumulated trading fees from a locked LP position using the Fee Key NFT mint address.

Harvest parameters

Parameter
Type
Description

poolInfo

object

Pool info from API or RPC.

poolKeys

object

Pool keys. Required for devnet.

nftMint

PublicKey

Mint address of the Fee Key NFT received when locking.

lpFeeAmount

BN

Amount of LP tokens to burn from the locked position. This is how you extract accumulated fee value — see "How fee harvesting works" above.

closeWsol

boolean

Default true. Closes wSOL account and returns native SOL. Set false to keep wSOL.

txVersion

TxVersion

Transaction version.


Collecting creator fees

Creator fees are a separate per-swap fee paid to the pool creator. They are only available on pools created via the permissioned path (createPoolWithPermission), which requires a Permission PDA from the Raydium admin. Pools created with the standard createPool() have creator fees disabled at the program level — see Creating a pool for details.

If your pool was created with permission and the fee config includes a non-zero creator_fee_rate, you can collect the accumulated creator fees.

Single pool

Multiple pools at once

Last updated

Was this helpful?