Create Pool

1. Create pool direct

For general pool creation, use the create_pool_v3 or create_pool_v2 function in the pool_creator module.

Note that the

Function params

  • config: the reference of clmm globalconfig object. you can see details at Global Config ID

  • pools: The indexer of all pools. Pools ID

  • tickSpacing: 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 (100)

    10

    0.0005 (500)

    20

    0.001 (1000)

    60

    0.0025 (2500)

    200

    0.01 (10000)

    220

    0.02 (20000)

  • initialize_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() in ts SDK.

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

  • tick_lower_idx: I32 type, it's represents the index of the lower tick boundary.

  • tick_upper_idx: I32 type, it's represents the index of the upper tick boundary.

  • The tick index must be an integer multiple of tickSpacing. If the provided parameter is not a multiple of tickSpacing, the contract will throw an error.

  • -443636 < tickLowerIndex < currentTickIndex<tickUpperIndex < 443636, 443636 is a constant, derived from the maximum range representable by the Q32.62 fixed-point number format.

  • Currently, creating a pool requires adding bidirectional liquidity.

  • coin_a: The coin A object to add liquidity.

  • coin_b: The coin B object to add liquidity.

  • metadata_a: The metadata object of coin a.(don't need in create_pool_v3)

  • metadata_b: The metadata object of coin b.(don't need in create_pool_v3)

  • fix_amount_a: When adding liquidity, you can select which coin amount to use as the fixed amount. If it's true, use coin a amount, others use coin b amount.

  • clock:clock: the sui clock object.

Types:

  • coinTypeA: the coin type address about coinA.

  • coinTypeB: the coin type address about coinB.

2. Register then create pool

In certain situations, coin issuers may wish to reclaim the ability to create pools. To accommodate this, the protocol implements a PoolCreationCap mechanism for coin issuers. Here's how it works:

Prerequisites:

  • You must hold the TreasuryCap of the coin

  • The TreasuryCap must not be frozen

  • Only one PoolCreationCap can be minted per coin

Steps to create a restricted pool:

  1. Mint a PoolCreationCap using your coin's TreasuryCap

  2. Register a pool by specifying: Quote coin and Tick spacing.

  3. Create a pool by PoolCreationCap.

The protocol controls which quote coins and tick_spacing values are permitted for pool registration. Currently, only pools with the SUI-200 can be registered.

Last updated