Create CLMM Pool
Everyone can create Cetus CLMM pools directly.
1. Create a CLMM Pool with Initial Liquidity
Use sdk.Pool.createPoolTransactionPayload() to create a pool.
Function Parameters
Required Parameters
tick_spacing: Affects price precision. Different tick spacing values correspond to different fee rates:Tick SpacingFee Rate2
0.0001
4
0.0002
6
0.0003
8
0.0004
10
0.0005
20
0.001
30
0.0015
40
0.002
60
0.0025
80
0.003
100
0.004
120
0.006
160
0.008
200
0.01
220
0.02
260
0.04
initialize_sqrt_price: For computational convenience, we use fixed-point numbers to represent square root prices. UseTickMath.priceToSqrtPriceX64()to transform price to sqrtPrice.coin_type_a: The coin type address for coin A.coin_type_b: The coin type address for coin B.amount_a: The amount of coin A to add as liquidity.amount_b: The amount of coin B to add as liquidity.fix_amount_a: Boolean value - true means fixed coin A amount, false means fixed coin B amount.tick_lower: The index of the lower tick boundary.tick_upper: The index of the upper tick boundary.metadata_a: The coin metadata ID of coin A.metadata_b: The coin metadata ID of coin B.
Optional Parameters
uri: The icon of the pool (can be null).
Determining Coin Type A and B
Complete the Coin Type: Ensure the coin type is complete before comparing.
Character-by-Character Comparison: Compare the characters of both coin type addresses.
ASCII Value Comparison: When encountering differing characters, compare their ASCII values. The coin with the larger ASCII value becomes "coin A".
Examples:
Example 1:
coin_type_a:
0x6864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUScoin_type_b:
0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI
Example 2:
coin_type_a:
0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDCcoin_type_b:
0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN
Important Notes
The tick index must be an integer multiple of tickSpacing.
Range:
-443636 < tick_lower_index < current_tick_index < tick_upper_index < 443636Currently, creating a pool requires adding bidirectional liquidity.
Example Code
2. Create a CLMM Pool with Initial Liquidity by directly inputting the price range
Use sdk.Pool.createPoolWithPricePayload() to create a pool.
Function Parameters
Required Parameters
tick_spacing: Affects price precision and fee rate (see table above)current_price: The initial price of the poolcoin_amount: The amount of coins to add as liquidityfix_amount_a: Boolean value - true means fixed coin A amount, false means fixed coin B amountadd_mode_params: Configuration for price range:For custom range:
{ is_full_range: false, min_price: string, max_price: string }For full range:
{ is_full_range: true }
coin_decimals_a: Number of decimal places for coin Acoin_decimals_b: Number of decimal places for coin Bprice_base_coin: Base coin for price calculation ('coin_a' or 'coin_b')slippage: Maximum acceptable slippage (e.g., 0.05 for 5%)
Two Ways to Create Pool
Create Pool with Position Return Use
sdk.Pool.createPoolWithPriceReturnPositionPayload()to create a pool and get the position ID and remaining coins.
Create Pool Directly Use
sdk.Pool.createPoolWithPricePayload()for a simpler pool creation without position management.
Important Notes
The price range must be valid and within acceptable bounds
For custom ranges, ensure min_price < current_price < max_price
The tick spacing determines the fee rate and price precision
Slippage protection is important to prevent significant price impact
Consider the decimal places of both coins when calculating amounts
Last updated