Skip to main content
The cp-amm IDL exposes many instructions. Integrators can choose to either use the TypeScript SDK for transaction construction or build through CPI.

Pool Creation

Pool creation initializes the pool, vaults, first position, and Token-2022 position NFT. Pool PDAs sort mints in the seed list, but transaction builders should use the canonical token_a_mint and token_b_mint fields from pool state after creation.
When mint validation is not skipped, pass token badge remaining accounts at index 0 (token A) and index 1 (token B) for mints that are not permissionless-supported. initialize_pool and initialize_pool_with_dynamic_config skip those checks when the private config has CreatePoolWithoutMintValidation. initialize_customizable_pool always validates mints. Token-2022 wrapped SOL is still rejected.

Positions

The position NFT token account must hold exactly one NFT and match position.nft_mint. The NFT holder can sign every position instruction. A Token-2022 delegate can sign the instructions below when the matching bit in delegate_permission is set. Approve must use amount 0. A non-zero delegated_amount returns DelegatedAmountNonZero (6070). If an unrestricted bit and its ToOwner bit are both set, the unrestricted bit applies. Bits above these eight return InvalidPermission (6054). permission = 0 clears the bitmask and leaves the SPL delegate in place. claim_reward with skip_reward = 1 on a frozen reward vault requires ClaimReward. ClaimRewardToOwner is not enough, because that path clears the pending reward without paying it. close_position, split_position, and split_position2 reject a delegate. On the delegated instructions the signer account is named signer. The TypeScript SDK parameter is still owner. Pass positionNftAccount as the token account that currently holds the NFT.

Liquidity And Locks

Add and remove liquidity update pool rewards, position rewards, fees, reserves, and liquidity before transferring tokens.

Swaps

Swap Modes

swap2 accepts SwapMode: New integrations should prefer swap2 and SDK getQuote2 because they share exact-in, partial-fill, and exact-out semantics.

Fees And Rewards

Reward index 0 and 1 are the only supported reward slots. reward_per_token_stored, fee_a_per_liquidity, and fee_b_per_liquidity wrap when a growth step does not fit. A pending reward or fee above u64::MAX is clamped. add_liquidity, remove_liquidity, remove_all_liquidity, claim_reward, split_position, split_position2, fund_reward, withdraw_ineligible_reward, withdraw_dead_liquidity_reward, and swap stay available after that wrap. withdraw_dead_liquidity_reward and claim_protocol_fee2 wrap the dead-liquidity checkpoint quotient to a u64.

Config And Operator Instructions

permission is set at config creation and is immutable. There is no instruction to update Config.permission. Public configs (default pool_creator_authority) must use permission = 0. The only defined bit today is CreatePoolWithoutMintValidation (1 << 0). InvalidConfigPermission (6072) is returned when a public config is given a non-zero permission, or when permission bits are outside the defined ConfigPermission range.
Token-2022 wrapped SOL is rejected during mint validation even when CreatePoolWithoutMintValidation is set. Use the standard wrapped SOL mint.
claim_protocol_fee and zap_protocol_fee are removed. Use claim_protocol_fee2.