const tokenAMint = new PublicKey("...");
const tokenBMint = new PublicKey("...");
const tokenADecimals = 6;
const tokenBDecimals = 6;
const tokenAAmount = new BN(1_000_000).mul(
new BN(10).pow(new BN(tokenADecimals)),
);
const tokenBAmount = new BN(1_000_000).mul(
new BN(10).pow(new BN(tokenBDecimals)),
);
const initSqrtPrice = getSqrtPriceFromPrice("1", tokenADecimals, tokenBDecimals);
const liquidityDelta = cpAmm.getLiquidityDelta({
maxAmountTokenA: tokenAAmount,
maxAmountTokenB: tokenBAmount,
sqrtPrice: initSqrtPrice,
sqrtMinPrice: MIN_SQRT_PRICE,
sqrtMaxPrice: MAX_SQRT_PRICE,
collectFeeMode: CollectFeeMode.BothToken,
});
const baseFee = getBaseFeeParams(
{
baseFeeMode: BaseFeeMode.FeeTimeSchedulerExponential,
feeTimeSchedulerParam: {
startingFeeBps: 5000,
endingFeeBps: 25,
numberOfPeriod: 60,
totalDuration: 3600,
},
},
tokenBDecimals,
ActivationType.Timestamp,
);
const poolFees: PoolFeesParams = {
baseFee,
compoundingFeeBps: 0,
padding: 0,
dynamicFee: getDynamicFeeParams(25),
};
const positionNft = Keypair.generate();
const {
tx,
pool: newPool,
position: initialPosition,
} = await cpAmm.createCustomPool({
payer: user.publicKey,
creator: user.publicKey,
positionNft: positionNft.publicKey,
tokenAMint,
tokenBMint,
tokenAAmount,
tokenBAmount,
sqrtMinPrice: MIN_SQRT_PRICE,
sqrtMaxPrice: MAX_SQRT_PRICE,
liquidityDelta,
initSqrtPrice,
poolFees,
hasAlphaVault: false,
activationType: ActivationType.Timestamp,
collectFeeMode: CollectFeeMode.BothToken,
activationPoint: null,
tokenAProgram: TOKEN_PROGRAM_ID,
tokenBProgram: TOKEN_PROGRAM_ID,
isLockLiquidity: false,
});
await sendAndConfirmTransaction(connection, tx, [user, positionNft]);
console.log({
pool: newPool.toBase58(),
position: initialPosition.toBase58(),
});