Create Pool

1. Create pool

Just create one clmmpool, without adding any initial liquidity.

Function input params

  • tick_spacing: tick spacing will affect price precision. Now mainnet exist some different type tick_spacing, they correspond to different fee rates.

    tick spacing
    fee rate

    2

    0.0001

    10

    0.0005

    60

    0.0025

    200

    0.01

  • initialize_sqrt_price: for computational convenience, we use fixed-point numbers to represent square root prices. Use the provided by the SDK transformation price to sqrtPrice: TickMath.priceToSqrtPriceX64().

  • uri: the icon of pool, it's allows null.

  • metadata_a: the metadata address about tokenA.

  • metadata_b: the metadata address about tokenB.

Example

 const token0 = currTokenConfig.USDC
 const token1 = currTokenConfig.USDT
 const tick_spacing = 60
 const initialize_sqrt_price = TickMath.tickIndexToSqrtPriceX64(TickMath.priceToTickIndex(d(1.1), token0.decimals, token1.decimals))

// Define pool creation parameters
 const params : CreatePoolParams = {
      tick_spacing,
      uri: '',
      initialize_sqrt_price: initialize_sqrt_price.toString(),
      metadata_a: token1.metadata,
      metadata_b: token0.metadata
    }

 const payload = sdk.Pool.createPoolPaylod(params)
 const respone = await executeTransaction([payload], sdk, key, false)

2. Create pool and add liquidity

Create one clmmpool and add some initial liquidity simultaneously. (Recommended)

Function input params

  • tick_lower: Represents the index of the lower tick boundary.

  • tick_upper: Represents the index of the upper tick boundary.

  • amount_a: the amount about Token A, which used to add liquidity.

  • amount_b: the amount about Token B, which used to add liquidity. Notice: amount a and b was calculated by ClmmPoolUtil.estLiquidityAndcoinAmountFromOneAmounts(), it will affected by selected tick interval、amount about one fixed Token(TokenA or TokenB)、current sqrt price of pool and allowed price slippage. You can see the usage in the next example.

  • fix_amount_a: true means fixed TokenA amount, false means fixed TokenB amount.

Example

Last updated