To integrate , this TypeScript SDK provides a set of tools and methods to interact with the program. It simplifies common operations like creating pools, managing positions, adding/removing liquidity, swapping tokens, and claiming rewards.
Program Repo on Github:
TypeScript SDK on Github:
Program ID (mainnet-beta): cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG
Program ID (devnet): cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG
1. Install dependencies and initialize instance
1.1 Install
pnpm install @meteora-ag/cp-amm-sdk
# or
yarn add @meteora-ag/cp-amm-sdk
1.2 Initialization
import { Connection } from "@solana/web3.js";
import { CpAmm } from "@meteora-ag/cp-amm-sdk";
// Initialize a connection to the Solana network
const connection = new Connection("https://api.mainnet-beta.solana.com");
// Create a new instance of the CpAmm SDK
const cpAmm = new CpAmm(connection);
1.3 Test
pnpm install
pnpm test
1.4 Faucets
2. Core Functions and Use Cases
createPool
Creates a new standard pool according to a predefined configuration.
interface CreatePoolParams {
payer: PublicKey; // The wallet paying for the transaction
creator: PublicKey; // The creator of the pool
config: PublicKey; // The configuration account for the pool
positionNft: PublicKey; // The mint for the initial position NFT
tokenAMint: PublicKey; // The mint address for token A
tokenBMint: PublicKey; // The mint address for token B
activationPoint: BN; // 0: slot, 1: timestamp
tokenAAmount: BN; // Initial amount of token A to deposit
tokenBAmount: BN; // Initial amount of token B to deposit
minSqrtPrice: BN; // Minimum sqrt price (typically MIN_SQRT_PRICE)
maxSqrtPrice: BN; // Maximum sqrt price (typically MAX_SQRT_PRICE)
tokenADecimal: number; // Decimal places for token A
tokenBDecimal: number; // Decimal places for token B
tokenAProgram: PublicKey; // Token program for token A
tokenBProgram: PublicKey; // Token program for token B
}
Returns
A transaction builder (TxBuilder) that can be used to build, sign, and send the transaction.
Example
const createPoolTx = await cpAmm.createPool({
payer: wallet.publicKey,
creator: wallet.publicKey,
config: configAddress,
positionNft: positionNftMint,
tokenAMint: usdcMint,
tokenBMint: solMint,
activationPoint: new BN(Date.now()),
tokenAAmount: new BN(1_000_000_000), // 1,000 USDC with 6 decimals
tokenBAmount: new BN(5_000_000_000), // 5 SOL with 9 decimals
minSqrtPrice: MIN_SQRT_PRICE,
maxSqrtPrice: MAX_SQRT_PRICE,
tokenADecimal: 6,
tokenBDecimal: 9,
tokenAProgram: TOKEN_PROGRAM_ID,
tokenBProgram: TOKEN_PROGRAM_ID
});
const tx = await createPoolTx.transaction();
const Function = await wallet.sendTransaction(tx, connection);
Notes
Both token amounts must be greater than zero
If using native SOL, it will be automatically wrapped to wSOL
The config parameter should be a valid configuration account
Pool creation automatically creates an initial position
createCustomPool
Creates a customizable pool with specific fee parameters, reward settings, and activation conditions.
interface InitializeCustomizeablePoolParams {
payer: PublicKey; // The wallet paying for the transaction
creator: PublicKey; // The creator of the pool
positionNft: PublicKey; // The mint for the initial position NFT
tokenAMint: PublicKey; // The mint address for token A
tokenBMint: PublicKey; // The mint address for token B
tokenAAmount: BN; // Initial amount of token A to deposit
tokenBAmount: BN; // Initial amount of token B to deposit
minSqrtPrice: BN; // Minimum sqrt price
maxSqrtPrice: BN; // Maximum sqrt price
tokenADecimal: number; // Decimal places for token A
tokenBDecimal: number; // Decimal places for token B
poolFees: PoolFees; // Fee configuration
hasAlphaVault: boolean; // Whether the pool has an alpha vault
collectFeeMode: number; // How fees are collected (0: normal, 1: alpha)
activationPoint: BN; // The slot or timestamp for activation
activationType: number; // 0: slot, 1: timestamp
tokenAProgram: PublicKey; // Token program for token A
tokenBProgram: PublicKey; // Token program for token B
}
interface PoolFees {
baseFee: {
feeSchedulerMode: number; // 0: Linear, 1: Exponential
cliffFeeNumerator: number;
numberOfPeriod: number;
reductionFactor: number;
periodFrequency: number;
};
partnerFee?: {
partnerAddress: PublicKey;
partnerFeeNumerator: number;
};
dynamicFee?: {
initialized: boolean;
volatilityAccumulator?: number;
binStep?: number;
variableFeeControl?: {
maxFeeNumerator: number;
minFeeNumerator: number;
volatilityThreshold: number;
feeDamper: number;
};
};
}
interface CreatePositionParams {
owner: PublicKey; // The owner of the position
payer: PublicKey; // The wallet paying for the transaction
pool: PublicKey; // The pool to create a position in
positionNft: PublicKey; // The mint for the position NFT
}
Returns
A transaction builder (TxBuilder) that can be used to build, sign, and send the transaction.
interface GetQuoteParams {
inAmount: BN; // The amount of input token to swap
inputTokenMint: PublicKey; // The mint of the input token
slippage: number; // Slippage tolerance in percentage (e.g., 0.5 for 0.5%)
poolState: PoolState; // The state of the pool
}
Returns
An object containing:
swapInAmount: The input amount
swapOutAmount: The expected output amount
minSwapOutAmount: The minimum output amount accounting for slippage
totalFee: The total fee to be paid
priceImpact: The price impact of the swap as a percentage
interface GetDepositQuoteParams {
inAmount: BN; // The amount of input token
isTokenA: boolean; // Whether the input token is token A
minSqrtPrice: BN; // Minimum sqrt price
maxSqrtPrice: BN; // Maximum sqrt price
sqrtPrice: BN; // Current sqrt price
inputTokenInfo?: {
mint: Mint,
currentEpoch: number
}; // Token info for Token2022 transfer fee calculations
outputTokenInfo?: {
mint: Mint,
currentEpoch: number
}; // Token info for Token2022 transfer fee calculations
}
Returns
An object containing:
actualInputAmount: The actual input amount (after transfer fees)
consumedInputAmount: The full input amount including transfer fees
liquidityDelta: The amount of liquidity that will be added
outputAmount: The calculated amount of the other token to be paired
interface GetWithdrawQuoteParams {
liquidityDelta: BN; // The amount of liquidity to withdraw
sqrtPrice: BN; // Current sqrt price
maxSqrtPrice: BN; // Maximum sqrt price
minSqrtPrice: BN; // Minimum sqrt price
inputTokenInfo?: {
mint: Mint,
currentEpoch: number
}; // Token info for Token2022 transfer fee calculations
outputTokenInfo?: {
mint: Mint,
currentEpoch: number
}; // Token info for Token2022 transfer fee calculations
}
Returns
An object containing:
liquidityDelta: The amount of liquidity being removed
outAmountA: The calculated amount of token A to receive
outAmountB: The calculated amount of token B to receive
interface LiquidityDeltaParams {
maxAmountTokenA: BN; // Maximum amount of token A to use
maxAmountTokenB: BN; // Maximum amount of token B to use
sqrtMaxPrice: BN; // Maximum sqrt price for the range
sqrtMinPrice: BN; // Minimum sqrt price for the range
sqrtPrice: BN; // Current sqrt price
}
Returns
A BN representing the liquidity delta in Q64 format.
This function is used before adding liquidity to calculate the appropriate liquidity delta
The function returns the minimum liquidity that can be added based on both token amounts
The result is in Q64 fixed-point notation
swap
Executes a token swap in the pool.
Function
async swap(params: SwapParams): TxBuilder
Parameters
interface SwapParams {
payer: PublicKey; // The wallet paying for the transaction
pool: PublicKey; // Address of the pool to swap in
inputTokenMint: PublicKey; // Mint of the input token
outputTokenMint: PublicKey; // Mint of the output token
amountIn: BN; // Amount of input token to swap
minimumAmountOut: BN; // Minimum amount of output token (slippage protection)
tokenAVault: PublicKey; // Pool's token A vault
tokenBVault: PublicKey; // Pool's token B vault
tokenAMint: PublicKey; // Pool's token A mint
tokenBMint: PublicKey; // Pool's token B mint
tokenAProgram: PublicKey; // Token program for token A
tokenBProgram: PublicKey; // Token program for token B
referralTokenAccount?: PublicKey; // Optional referral account for fees
}
Returns
A transaction builder (TxBuilder) that can be used to build, sign, and send the transaction.
interface AddLiquidityParams {
owner: PublicKey; // The owner of the position
pool: PublicKey; // The pool address
position: PublicKey; // The position address
positionNftMint: PublicKey; // The position NFT mint
liquidityDeltaQ64: BN; // The amount of liquidity to add in Q64 format
maxAmountTokenA: BN; // Maximum amount of token A to use
maxAmountTokenB: BN; // Maximum amount of token B to use
tokenAAmountThreshold: BN; // Minimum acceptable token A amount (slippage protection)
tokenBAmountThreshold: BN; // Minimum acceptable token B amount (slippage protection)
tokenAMint: PublicKey; // The mint of token A
tokenBMint: PublicKey; // The mint of token B
tokenAVault: PublicKey; // The pool's token A vault
tokenBVault: PublicKey; // The pool's token B vault
tokenAProgram: PublicKey; // Token program for token A
tokenBProgram: PublicKey; // Token program for token B
}
Returns
A transaction builder (TxBuilder) that can be used to build, sign, and send the transaction.
Example
// Calculate liquidity delta first
const liquidityDelta = await cpAmm.getLiquidityDelta({
maxAmountTokenA: new BN(1_000_000_000), // 1,000 USDC
maxAmountTokenB: new BN(5_000_000_000), // 5 SOL
sqrtPrice: poolState.sqrtPrice,
sqrtMinPrice: MIN_SQRT_PRICE,
sqrtMaxPrice: MAX_SQRT_PRICE
});
// Add liquidity
const addLiquidityTx = await cpAmm.addLiquidity({
owner: wallet.publicKey,
pool: poolAddress,
position: positionAddress,
positionNftMint: positionNftMint,
liquidityDeltaQ64: liquidityDelta,
maxAmountTokenA: new BN(1_000_000_000),
maxAmountTokenB: new BN(5_000_000_000),
tokenAAmountThreshold: new BN(0),
tokenBAmountThreshold: new BN(0),
tokenAMint: poolState.tokenAMint,
tokenBMint: poolState.tokenBMint,
tokenAVault: poolState.tokenAVault,
tokenBVault: poolState.tokenBVault,
tokenAProgram: TOKEN_PROGRAM_ID,
tokenBProgram: TOKEN_PROGRAM_ID
});
const tx = await addLiquidityTx.transaction();
const Function = await wallet.sendTransaction(tx, connection);
Notes
Calculate the liquidity delta first using getLiquidityDelta
The SDK handles wrapping/unwrapping of SOL automatically
Token accounts are created automatically if they don't exist
Set appropriate thresholds to protect against slippage
interface RemoveLiquidityParams {
owner: PublicKey; // The owner of the position
pool: PublicKey; // The pool address
position: PublicKey; // The position address
positionNftMint: PublicKey; // The position NFT mint
liquidityDeltaQ64: BN; // The amount of liquidity to remove in Q64 format
tokenAAmountThreshold: BN; // Minimum acceptable token A amount (slippage protection)
tokenBAmountThreshold: BN; // Minimum acceptable token B amount (slippage protection)
tokenAMint: PublicKey; // The mint of token A
tokenBMint: PublicKey; // The mint of token B
tokenAVault: PublicKey; // The pool's token A vault
tokenBVault: PublicKey; // The pool's token B vault
tokenAProgram: PublicKey; // Token program for token A
tokenBProgram: PublicKey; // Token program for token B
}
Returns
A transaction builder (TxBuilder) that can be used to build, sign, and send the transaction.
Example
// Get position state to determine available liquidity
const positionState = await cpAmm.fetchPositionState(positionAddress);
// Remove half of the available liquidity
const liquidityToRemove = positionState.liquidity.div(new BN(2));
const removeLiquidityTx = await cpAmm.removeLiquidity({
owner: wallet.publicKey,
pool: poolAddress,
position: positionAddress,
positionNftMint: positionNftMint,
liquidityDeltaQ64: liquidityToRemove,
tokenAAmountThreshold: new BN(0), // Set appropriate thresholds for slippage protection
tokenBAmountThreshold: new BN(0),
tokenAMint: poolState.tokenAMint,
tokenBMint: poolState.tokenBMint,
tokenAVault: poolState.tokenAVault,
tokenBVault: poolState.tokenBVault,
tokenAProgram: TOKEN_PROGRAM_ID,
tokenBProgram: TOKEN_PROGRAM_ID
});
const tx = await removeLiquidityTx.transaction();
const Function = await wallet.sendTransaction(tx, connection);
Notes
You can only remove unlocked liquidity
The SDK handles wrapping/unwrapping of SOL automatically
Token accounts are created automatically if they don't exist
Set appropriate thresholds to protect against slippage
interface RemoveAllLiquidityParams {
owner: PublicKey; // The owner of the position
pool: PublicKey; // The pool address
position: PublicKey; // The position address
positionNftAccount: PublicKey; // The ata account of position nft
tokenAAmountThreshold: BN; // Minimum acceptable token A amount (slippage protection)
tokenBAmountThreshold: BN; // Minimum acceptable token B amount (slippage protection)
tokenAMint: PublicKey; // The mint of token A
tokenBMint: PublicKey; // The mint of token B
tokenAVault: PublicKey; // The pool's token A vault
tokenBVault: PublicKey; // The pool's token B vault
tokenAProgram: PublicKey; // Token program for token A
tokenBProgram: PublicKey; // Token program for token B
vestings?: Array<{account: PublicKey}>; // Optional vesting accounts to refresh if position has vesting lock
}
Returns
A transaction builder (TxBuilder) that can be used to build, sign, and send the transaction.
interface RemoveAllLiquidityAndClosePositionParams {
owner: PublicKey; // The owner of the position
position: PublicKey; // The position address
positionNftAccount: PublicKey; // The position NFT account
positionState: PositionState; // The current position state
poolState: PoolState; // The current pool state
tokenAAmountThreshold: BN; // Minimum acceptable token A amount (slippage protection)
tokenBAmountThreshold: BN; // Minimum acceptable token B amount (slippage protection)
currentPoint: BN; // Current timestamp or slot number for vesting calculations
vestings?: Array<{account: PublicKey, vestingState: VestingState}>; // Optional vesting accounts
}
Returns
A transaction builder (TxBuilder) that can be used to build, sign, and send the transaction.
Example
const poolState = await cpAmm.fetchPoolState(poolAddress);
const positionState = await cpAmm.fetchPositionState(positionAddress);
// Check if position is locked
if (cpAmm.isLockedPosition(positionState)) {
console.error("Cannot close a locked position");
return;
}
// Build transaction to remove all liquidity and close position
const tx = await cpAmm.removeAllLiquidityAndClosePosition({
owner: wallet.publicKey,
position: positionAddress,
positionNftAccount: positionNftAccount,
positionState: positionState,
poolState: poolState,
tokenAAmountThreshold: new BN(0),
tokenBAmountThreshold: new BN(0)
});
Notes
This combines multiple operations in a single transaction:
Claims any accumulated fees
Removes all liquidity
Closes the position and returns the rent
The position must be completely unlocked
The function will throw an error if the position has any locked liquidity
This is more gas-efficient than doing these operations separately
If there are vesting schedules, they must be refreshed before closing the position
mergePosition
Merges liquidity from one position into another in a single transaction.
interface MergePositionParams {
owner: PublicKey; // The owner of both positions
positionA: PublicKey; // Target position to merge into
positionB: PublicKey; // Source position to merge from
positionBState: PositionState; // State of the source position
poolState: PoolState; // State of the pool
positionANftAccount: PublicKey; // ata account of target position NFT
positionBNftAccount: PublicKey; // ata account of source position NFT
tokenAAmountAddLiquidityThreshold: BN; // Minimum token A amount for add liquidity
tokenBAmountAddLiquidityThreshold: BN; // Minimum token B amount for add liquidity
tokenAAmountRemoveLiquidityThreshold: BN; // Minimum token A amount for remove liquidity
tokenBAmountRemoveLiquidityThreshold: BN; // Minimum token B amount for remove liquidity
currentPoint: BN; // Current timestamp or slot number for vesting calculations
positionBVestings?: Array<{account: PublicKey, vestingState: VestingState}>; // Optional vesting accounts for position B
}
Returns
A transaction builder (TxBuilder) that can be used to build, sign, and send the transaction.
Example
const poolState = await cpAmm.fetchPoolState(poolAddress);
const positionAState = await cpAmm.fetchPositionState(positionAAddress); // Target position
const positionBState = await cpAmm.fetchPositionState(positionBAddress); // Source position to merge from
// Check if position is locked
if (cpAmm.isLockedPosition(positionBState)) {
console.error("Cannot merge a locked position");
return;
}
// Build transaction to merge positions
const tx = await cpAmm.mergePosition({
owner: wallet.publicKey,
positionA: positionAAddress,
positionB: positionBAddress,
positionBState: positionBState,
poolState: poolState,
positionANftAccount: positionANftAccount,
positionBNftAccount: positionBNftAccount,
tokenAAmountAddLiquidityThreshold: new BN(U64_MAX),
tokenBAmountAddLiquidityThreshold: new BN(u64_MAX),
tokenAAmountRemoveLiquidityThreshold: new BN(0),
tokenBAmountRemoveLiquidityThreshold: new BN(0)
});
Notes
This function combines multiple operations:
Claims any accumulated fees from the source position
Removes all liquidity from the source position
Adds the liquidity to the target position
Closes the source position
Both positions must be owned by the same wallet
The source position must be completely unlocked
This is more gas-efficient than performing these operations separately
Set appropriate thresholds to protect against slippage for both add and remove operations
lockPosition
Locks a position with a vesting schedule for gradual unlocking over time.
interface LockPositionParams {
owner: PublicKey; // The owner of the position
pool: PublicKey; // The pool address
payer: PublicKey; // The payer for the transaction
vestingAccount: PublicKey; // The vesting account to create
position: PublicKey; // The position address
positionNftMint: PublicKey; // The position NFT mint
cliffPoint: BN; // The slot or timestamp for the cliff
periodFrequency: BN; // Frequency of unlock periods
cliffUnlockLiquidity: BN; // Liquidity to unlock at cliff
liquidityPerPeriod: BN; // Liquidity to unlock per period
numberOfPeriod: number; // Number of unlock periods
}
Returns
A transaction builder (TxBuilder) that can be used to build, sign, and send the transaction.
Example
const lockPositionTx = await cpAmm.lockPosition({
owner: wallet.publicKey,
pool: poolAddress,
payer: wallet.publicKey,
vestingAccount: vestingAccountAddress, // Generated keypair
position: positionAddress,
positionNftMint: positionNftMint,
cliffPoint: new BN(Date.now() + 30 * 24 * 60 * 60 * 1000), // 30 days cliff
periodFrequency: new BN(7 * 24 * 60 * 60), // 7 days per period
cliffUnlockLiquidity: new BN(0), // No liquidity at cliff
liquidityPerPeriod: new BN("1000000000000000"), // Amount in Q64 format
numberOfPeriod: 52 // 52 periods (1 year with weekly unlocks)
});
const tx = await lockPositionTx.transaction();
const Function = await wallet.sendTransaction(tx, connection);
Notes
The vesting schedule is enforced on-chain
Locked liquidity cannot be removed until it's unlocked according to the schedule
The vestingAccount should be a new keypair
The cliffPoint and periodFrequency are in the same units as the pool's activation type
permanentLockPosition
Permanently locks a portion of a position's liquidity (cannot be unlocked).
interface PermanentLockParams {
owner: PublicKey; // The owner of the position
position: PublicKey; // The position address
positionNftMint: PublicKey; // The position NFT mint
pool: PublicKey; // The pool address
unlockedLiquidity: BN; // Amount of liquidity to permanently lock
}
Returns
A transaction builder (TxBuilder) that can be used to build, sign, and send the transaction.
interface RefreshVestingParams {
owner: PublicKey; // The owner of the position
position: PublicKey; // The position address
positionNftMint: PublicKey; // The position NFT mint
pool: PublicKey; // The pool address
vestings: PublicKey[]; // Array of vesting accounts to refresh
}
Returns
A transaction builder (TxBuilder) that can be used to build, sign, and send the transaction.
interface ClaimPositionFeeParams {
owner: PublicKey; // The owner of the position
pool: PublicKey; // The pool address
position: PublicKey; // The position address
nftPositionMint: PublicKey; // The position NFT mint
tokenAVault: PublicKey; // The pool's token A vault
tokenBVault: PublicKey; // The pool's token B vault
tokenAMint: PublicKey; // The mint of token A
tokenBMint: PublicKey; // The mint of token B
tokenAProgram: PublicKey; // Token program for token A
tokenBProgram: PublicKey; // Token program for token B
}
Returns
A transaction builder (TxBuilder) that can be used to build, sign, and send the transaction.
interface ClaimPartnerFeeParams {
partner: PublicKey; // The partner address
pool: PublicKey; // The pool address
maxAmountA: BN; // Maximum amount of token A to claim
maxAmountB: BN; // Maximum amount of token B to claim
}
Returns
A transaction builder (TxBuilder) that can be used to build, sign, and send the transaction.
Example
const claimPartnerFeeTx = await cpAmm.claimPartnerFee({
partner: partnerWallet.publicKey,
pool: poolAddress,
maxAmountA: new B
interface ClaimRewardParams {
user: PublicKey; // The user claiming rewards
position: PublicKey; // The position address
positionNftAccount: PublicKey; // The position NFT account
rewardIndex: number; // Index of the reward to claim
poolState: PoolState; // The current pool state
positionState: PositionState; // The current position state
}
Returns
A transaction builder (TxBuilder) that can be used to build, sign, and send the transaction.
interface ClosePositionParams {
owner: PublicKey; // The owner of the position
pool: PublicKey; // The pool address
position: PublicKey; // The position address
positionNftMint: PublicKey; // The position NFT mint
positionNftAccount: PublicKey; // The position NFT account
}
Returns
A transaction builder (TxBuilder) that can be used to build, sign, and send the transaction.
Example
const positionState = await cpAmm.fetchPositionState(positionAddress);
// Check if position has no liquidity
if (!positionState.unlockedLiquidity.isZero() || !positionState.vestedLiquidity.isZero() || !positionState.permanentLockedLiquidity.isZero()) {
console.error("Position still has liquidity");
return;
}
const closePositionTx = await cpAmm.closePosition({
owner: wallet.publicKey,
pool: positionState.pool,
position: positionAddress,
positionNftMint: positionState.nftMint,
positionNftAccount: positionNftAccount
});
Notes
Position must have zero liquidity before closing
Use removeAllLiquidity first if the position still has liquidity
Closing a position returns the rent to the owner
This function only closes the position account, not the NFT
For a full cleanup, use removeAllLiquidityAndClosePosition instead
const userPoolPositions = await cpAmm.getUserPositionByPool(poolAddress, wallet.publicKey);
console.log(`User has ${userPoolPositions.length} positions in this pool`);
interface PreparePoolCreationParams {
tokenAAmount: BN; // Initial amount of token A to deposit
tokenBAmount: BN; // Initial amount of token B to deposit
minSqrtPrice: BN; // Minimum sqrt price
maxSqrtPrice: BN; // Maximum sqrt price
tokenAInfo?: any; // Token info for Token2022 transfer fee calculations
tokenBInfo?: any; // Token info for Token2022 transfer fee calculations
}
Returns
An object containing:
initSqrtPrice: The initial sqrt price in Q64 format
liquidityDelta: The initial liquidity in Q64 format
Example
const { initSqrtPrice, liquidityDelta } = cpAmm.preparePoolCreationParams({
tokenAAmount: new BN(1_000_000_000), // 1,000 USDC with 6 decimals
tokenBAmount: new BN(5_000_000_000), // 5 SOL with 9 decimals
minSqrtPrice: MIN_SQRT_PRICE,
maxSqrtPrice: MAX_SQRT_PRICE
});
console.log(`Initial sqrt price: ${initSqrtPrice.toString()}`);
console.log(`Initial liquidity: ${liquidityDelta.toString()}`);
Notes
This function calculates the correct initial price and liquidity based on the token amounts
Both token amounts must be greater than zero
The function handles Token2022 transfer fees if token info is provided
isVestingComplete
Checks if a vesting schedule is ready for full release.
Function
function isVestingComplete(vestingData: VestingState, currentPoint: BN): boolean
Parameters
vestingData: The vesting account state data
currentPoint: Current timestamp or slot number
Returns
Boolean indicating whether the vesting schedule is complete and all liquidity can be released.
Example
const vestings = await cpAmm.getAllVestingsByPosition(positionAddress);
if (vestings.length > 0) {
const isComplete = isVestingComplete(vestings[0].account, new BN(Date.now()));
if (isComplete) {
console.log("Vesting schedule is complete, all liquidity can be released");
} else {
console.log("Vesting schedule is still active");
}
}
Notes
This function checks if the current point (timestamp or slot) has passed the end of the vesting schedule
The end point is calculated as: cliffPoint + (periodFrequency * numberOfPeriods)
Returns true if currentPoint >= endPoint, false otherwise
Useful to determine if a position can be fully unlocked
getTotalLockedLiquidity
Gets the total amount of liquidity in the vesting schedule.
Function
function getTotalLockedLiquidity(vestingData: VestingState): BN