Creating a pool
Method
SDK method
Who can call
Creator fees
Fetching fee configurations
const feeConfigs = await raydium.api.getCpmmConfigs()Creating a pool
import {
CREATE_CPMM_POOL_PROGRAM,
CREATE_CPMM_POOL_FEE_ACC,
DEVNET_PROGRAM_ID,
getCpmmPdaAmmConfigId,
TxVersion,
} from '@raydium-io/raydium-sdk-v2'
import BN from 'bn.js'
import { initSdk } from '../config'
const createPool = async () => {
const raydium = await initSdk({ loadToken: true })
const mintA = await raydium.token.getTokenInfo('So11111111111111111111111111111111111111112')
const mintB = await raydium.token.getTokenInfo('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
/**
* You can also provide mint info directly instead of fetching:
* {
* address: '4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R',
* programId: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA',
* decimals: 6,
* }
*/
const feeConfigs = await raydium.api.getCpmmConfigs()
// On devnet, re-derive config IDs from the devnet program
if (raydium.cluster === 'devnet') {
feeConfigs.forEach((config) => {
config.id = getCpmmPdaAmmConfigId(
DEVNET_PROGRAM_ID.CREATE_CPMM_POOL_PROGRAM,
config.index
).publicKey.toBase58()
})
}
const { execute, extInfo } = await raydium.cpmm.createPool({
programId: CREATE_CPMM_POOL_PROGRAM,
// devnet: DEVNET_PROGRAM_ID.CREATE_CPMM_POOL_PROGRAM
poolFeeAccount: CREATE_CPMM_POOL_FEE_ACC,
// devnet: DEVNET_PROGRAM_ID.CREATE_CPMM_POOL_FEE_ACC
mintA,
mintB,
mintAAmount: new BN(1_000_000),
mintBAmount: new BN(1_000_000),
startTime: new BN(0),
feeConfig: feeConfigs[0],
associatedOnly: false,
ownerInfo: {
useSOLBalance: true,
},
txVersion: TxVersion.V0,
// optional: set up priority fee here
// computeBudgetConfig: {
// units: 600000,
// microLamports: 46591500,
// },
})
const { txId } = await execute({ sendAndConfirm: true })
console.log('pool created', {
txId: `https://explorer.solana.com/tx/${txId}`,
poolId: extInfo.address.poolId.toBase58(),
})
}
createPool()Parameters
Parameter
Type
Description
Return value
Field
Description
Creating a pool with permission (creator fees)
Additional parameters (vs. permissionless)
Parameter
Type
Description
FeeOn enum
FeeOn enumValue
Behavior
Key differences from permissionless
Last updated
Was this helpful?