Initialize Pool
Creates a new liquidity pool on the CoolDEX.
Instruction
Parameters
nonce
u8
Nonce for PDAs
open_time
u64
Timestamp when the pool opens for trading
init_pc_amount
u64
Initial amount of quote token (typically SOL)
init_coin_amount
u64
Initial amount of base token
burn_bp
u16
Portion of fees allocated to burning (in basis points)
fee_numerator
u16
Fee numerator for the pool
Account Setup
1
Token program
SPL Token program
TOKEN_PROGRAM_ID
2
Associated token account program
ATA program
ASSOCIATED_TOKEN_PROGRAM_ID
3
System program
System program
SystemProgram.programId
4
Rent sysvar
Rent program
SYSVAR_RENT_PUBKEY
5
AMM info
AMM account
coolDexSeed("amm_associated_seed")
6
AMM authority
AMM authority PDA
[Buffer.from("amm authority")]
7
AMM LP mint
LP token mint
coolDexSeed("lp_mint_associated_seed")
8
AMM coin mint
Coin token mint
Provided by user
9
AMM PC mint
Quote token mint (SOL)
NATIVE_MINT
10
AMM coin vault
Coin token vault
coolDexSeed("coin_vault_associated_seed")
11
AMM PC vault
Quote token (SOL) vault
coolDexSeed("pc_vault_associated_seed")
12
AMM config
AMM configuration account
[Buffer.from("amm_config_account_seed")]
13
Create fee destination
Platform fee account
Fixed address
14
Market info
Market account
Provided by user
15
User wallet
Transaction signer
User's wallet
16
User token coin
User's coin token account
getAssociatedTokenAddress(coinMint, userWallet, false)
17
User token PC
User's quote token (SOL) account
getAssociatedTokenAddress(NATIVE_MINT, userWallet, false)
18
User token LP
User's LP token account
getAssociatedTokenAddress(lpMint, userWallet, false)
Function Logic
Verifies the AMM config account is valid
Verifies the signer is the SC Bonding Curve deployer
Checks that the coin mint is not SOL (native mint)
Checks that the PC mint is SOL (native mint)
Creates target orders account
Creates LP mint account with the same decimals as the coin token
Creates coin vault and PC vault accounts
Creates AMM account
Creates user's associated token account for LP tokens
Transfers initial coin and PC amounts from user to the vaults
Calculates initial liquidity based on the geometric mean of both deposits
Mints LP tokens to the user
Initializes the AMM with specified parameters
Sets the initial pool state and parameters
Notes
Only the SC Bonding Curve deployer can initialize pools
The PC (quote) token must be the native SOL token
The coin (base) token cannot be the native SOL token
Initial LP tokens are minted to the user wallet minus a minimum amount kept in the pool
The pool status is determined by the open_time parameter:
If open_time > current time: WaitingTrade status
Otherwise: SwapOnly status
Helper Function for Computing CoolDEX Addresses
Example Usage
Last updated