Turbos
  • 📖About Turbos
    • Getting Started
    • About Turbos Finance
    • Why Sui Network
  • 📽️Products
    • Concentrated Liquidity AMM
      • Fee Tier for Token Pairs
      • Oracle
    • Automated Rebalance Vault
      • Step-by-Step Guide
      • Referral Program
    • TurboStar
    • TurbosBoost
  • 💡Protocol Concepts
    • About Concentrated Liquidity
    • Fee Tiers
    • Glossary
  • 🪙Tokenomics
    • TURBOS
    • Token Utility
    • Emission Distribution
  • ⚙️Others
    • Roadmap
    • Audits
    • Brand kit
    • Risks
    • Token Address
  • Developer Docs
    • Dev Overview
    • via SDK
      • Get Started
      • Initialize SDK
      • Clmm
        • getConfig
        • getFeesConfig
        • getPools
        • getPool
        • createPool
        • createAndAddLiquidity
        • increaseLiquidity
        • decreaseLiquidity
        • removeLiquidityAndBurn
        • preSwap
        • swap
        • collect Fees
        • collect Rewards
        • Fee
        • Liquidity and coin amounts calculation
        • APR calculation
      • Vault
        • createAndDepositVault
        • depositVault
        • withdrawVault
        • withdrawAllVault
        • collectClmmRewardDirectReturnVault
        • closeVault
        • computeTokenWithdrawVaultSwapResult
        • getVaultBalanceAmount
        • getMyVaults
  • Turbos Fun
    • Base
    • Create Pool
    • Calculate Token Amount
    • Buy
    • Sell
  • 📱Socials
    • Official website
    • Twitter
    • Discord
    • Medium
    • Zealy
  • Tutorials
    • Supported Wallets
      • SafePal Wallet
    • Move tutorial
    • Sui tutorial
Powered by GitBook
On this page
  • Signature
  • Params
  • Examples
  1. Developer Docs
  2. via SDK
  3. Clmm

createPool

To create a clmm pool with some initial liquidity to be added

Signature

createPool(options: CreatePoolOptions): Promise<Transaction>

Params

interface CreatePoolOptions {
  // From sdk.contract.getFees()
  fee: Contract.Fee;
  // Coin type such as 0x2::sui::SUI
  coinTypeA: string;
  // Coin type such as 0x2::sui::SUI
  coinTypeB: string;
  // Amount of coin A
  amountA: string | number;
  // Amount of coin B
  amountB: string | number;
  // Represents the index of the lower tick boundary
  tickLower: number;
  // Represents the index of the upper tick boundary
  tickUpper: number;
  // Initial price
  sqrtPrice: string;
  // Creator wallet address
  address: string;
  // Acceptable wasted amount percentage. Range: [0, 100)
  slippage: string | number;
  // Expires timeout(ms), defaults 60_000
  deadline?: number;
  // Custom transaction handler
  txb?: Transaction;
}

fee

fee will affect price precision. Now mainnet exist some different type fee type, they correspond to different fee rates and tick_spacing.

[
  {
    objectId: '0x49dcf28ac3b5480e65bee812ad2d6e60108ab8037d5a815c3c11bbe7bc47c270',
    type: '0x2e8c645bcd20436b6178d17dd7093dfd8ce097bc360414ca25d24f94e78eb18e::fee10bps::FEE10BPS',
    fee: 10,
    tickSpacing: 1
    //fee rate 0.00001
  },
  {
    objectId: '0x18136d55969b970330e6991e0deaa713fca99f4e526152c10d5592a01d45f857',
    type: '0x91bfbc386a41afcfd9b2533058d7e915a1d3829089cc268ff4333d54d6339ca1::fee100bps::FEE100BPS',
    fee: 100,
    tickSpacing: 2
    //fee rate 0.0001
  },
  {
    objectId: '0xdfcd1043f54fef3aa649eccd4d0b2b09a3da6c87a8a62736467b686268869365',
    type: '0x91bfbc386a41afcfd9b2533058d7e915a1d3829089cc268ff4333d54d6339ca1::fee500bps::FEE500BPS',
    fee: 500,
    tickSpacing: 10
    //fee rate 0.0005
  },
  {
    objectId: '0x5121798d1ac50ee8d5c3213c69d4955814318901070ac06a8accfba39fb30198',
    type: '0xb924dd4ca619fdb3199f9e96129328da0bb7df1f57054dcc765debb360282726::fee2000bps::FEE2000BPS',
    fee: 2000,
    tickSpacing: 40
    //fee rate 0.002
  },
  {
    objectId: '0x0dfa811ff9d86f7680f212a78b2dd886f10916383d80accf287612a0df3906a0',
    type: '0xb924dd4ca619fdb3199f9e96129328da0bb7df1f57054dcc765debb360282726::fee2500bps::FEE2500BPS',
    fee: 2500,
    tickSpacing: 50
    //fee rate 0.0025
  },
  {
    objectId: '0x6bc433c8604f58272155d0c65327ae0b316f63869e5de3846f70aef4625d8c46',
    type: '0x91bfbc386a41afcfd9b2533058d7e915a1d3829089cc268ff4333d54d6339ca1::fee3000bps::FEE3000BPS',
    fee: 3000,
    tickSpacing: 60
    //fee rate 0.003
  },
  {
    objectId: '0xd30c41ec4b4d0eb9b30b0b898c53f81cd53a9eb0f75b5d3273584cd874b2d4c4',
    type: '0x91bfbc386a41afcfd9b2533058d7e915a1d3829089cc268ff4333d54d6339ca1::fee10000bps::FEE10000BPS',
    fee: 10000,
    tickSpacing: 200
    //fee rate 0.01
  },
  {
    objectId: '0x9724fd1e579956dcaabe97399a374c7726cb96eabea2dec53a5509c41f2c1573',
    type: '0xb924dd4ca619fdb3199f9e96129328da0bb7df1f57054dcc765debb360282726::fee20000bps::FEE20000BPS',
    fee: 20000,
    tickSpacing: 220
    //fee rate 0.02
  }
]

coinTypeA

Is a base token, such as turbos, wal

coinTypeB

is a quote token, It is recommended to use highly liquid token, such as sui, usdc, and usdt as quote tokens, which is conducive to the display and calculation of prices.

amountA

the amount about coin A, which used to add liquidity.

amountB

the amount about coin B, which used to add liquidity.

tickLower

Represents the index of the lower tick boundary.

tickUpper

Represents the index of the upper tick boundary.

The tick index must satisfy the condition: -443636 < tickLowerIndex < currentTickIndex < tickUpperIndex < 443636, where 443636 is a constant derived from the maximum range of the Q32.62 fixed-point number format. Additionally, the tick index should be an integer multiple of tickSpacing. If not, the contract will trigger an error.

Examples

    const turbosSdk = new TurbosSdk(Network.testnet, {
      url: 'https://fullnode.testnet.sui.io',
    });
    const signer = turbosSdk.account.getKeypairFromMnemonics("your mnemonic");
    const tickSpacing = 200;
    const coinTypeA =
      '0x541826891e877178df82f2df2996599618a259e719ef54a8e1969211c609cd21::turbos::TURBOS';
    const coinTypeB = '0x2::sui::SUI';
    const coinADecimals = 9;
    const coinBDecimals = 9;
    const fee = await turbosSdk.contract.getFee(tickSpacing);
    const sqrtPrice = turbosSdk.math
      .priceToSqrtPriceX64(0.01, coinADecimals, coinBDecimals)
      .toString();
    // 0.0001 - 10000 price range
    const tickLower = turbosSdk.math.priceToInitializableTickIndex(
      0.0001,
      coinADecimals,
      coinBDecimals,
      tickSpacing,
    );
    const tickUpper = turbosSdk.math.priceToInitializableTickIndex(
      10000,
      coinADecimals,
      coinBDecimals,
      tickSpacing,
    );
    console.log(tickLower, tickUpper);
    // initial liquidity
    const amountA = 1 * 10 ** coinADecimals;
    const amounts = turbosSdk.pool.estimateAmountsFromOneAmount({
      sqrtPrice,
      tickLower,
      tickUpper,
      amount: amountA.toString(),
      isAmountA: true,
    });
    const txb = await turbosSdk.pool.createPool({
      fee,
      coinTypeA,
      coinTypeB,
      sqrtPrice,
      tickLower,
      tickUpper,
      address: signer.toSuiAddress(),
      amountA: amounts[0],
      amountB: amounts[1],
      slippage: 3,
      deadline: Date.now() + 60 * 60 * 1000,
    });
    txb.setSender(signer.toSuiAddress());
    const result = await turbosSdk.provider.signAndExecuteTransaction({
      transaction: txb,
      signer,
    });
    console.log(result);
PreviousgetPoolNextcreateAndAddLiquidity

Last updated 1 day ago