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:
Your LP tokens are transferred to the Burn & Earn locker program — they cannot be withdrawn.
You receive a Fee Key NFT that represents your locked position.
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:
Your locked position holds, say, 1000 LP tokens.
Swaps occur, fees flow into the pool vaults, and each LP token appreciates in value.
You call
harvestLockLpwith anlpFeeAmount(e.g. 5 LP).The locker program burns those 5 LP via a withdraw on the CPMM program.
You receive the proportional share of token A + token B to your wallet.
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
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.
Locking is permanent. Once locked, LP tokens cannot be withdrawn. Only the trading fees can be collected via the Fee Key NFT.
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
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?