Create CLMM Pool

Ferra is a permissionless liquidity infrastructure where anyone can create a CLMM pool.

Overview

Create a new CLMM pool with initial liquidity in a single transaction. The SDK automatically handles coin type ordering according to protocol requirements.

Prerequisites

  • Valid sender address configured in SDK

  • Sufficient balance of both tokens

  • Token metadata (optional)

Quick Start

import { clmmMainnet, initFerraSDK } from '@ferra-labs/clmm'

// Initialize SDK
const sdk = initFerraSDK({
  ...clmmMainnet,
  network: 'beta',
  fullNodeUrl: 'https://...',
  wallet: '0x...'
})

// Create pool with initial liquidity
const params = {
  // Token types
  coinTypeA: '0x2::sui::SUI',
  coinTypeB: '0x...::usdc::USDC',
  
  // Pool parameters
  tick_spacing: 60,              // Tick spacing (1, 10, 60, 200)
  initialize_sqrt_price: '...',  // Initial price (sqrt format)
  uri: 'https://...',   // Pool uri
  
  // Liquidity position
  tick_lower: -1000,             // Lower price bound
  tick_upper: 1000,              // Upper price bound
  amount_a: '1000000000',        // Amount of token A (with decimals)
  amount_b: '1000000',           // Amount of token B (with decimals)
  fix_amount_a: true,            // Fix token A amount
  slippage: 0.05,
  // Optional metadata
  metadata_a: coinAMetadata,
  metadata_b: coinBMetadata
}

const tx = await sdk.Pool.createPoolTransactionPayloadslippage(params)
const result = await sdk.fullClient.signAndExecuteTransaction({
  transaction: tx,
  signer: keypair
})

Parameters

Parameter
Type
Description

coinTypeA

string

First token type

coinTypeB

string

Second token type

tick_spacing

number

Fee tier (2=0.01%, 10=0.05%, 20=0.1%, 60=0.5%, 200=1%, 220=5% )

initialize_sqrt_price

string

Initial sqrt price (X64 format)

uri

string

Pool description

tick_lower

number

Lower tick boundary

tick_upper

number

Upper tick boundary

amount_a

string

Amount of token A

amount_b

string

Amount of token B

fix_amount_a

boolean

If true, fix token A amount; else fix token B

metadata_a

CoinMetadata

Token A metadata (optional)

metadata_b

CoinMetadata

Token B metadata (optional)

Price Calculation

Calculate initial sqrt price:

import { TickMath } from '@ferra-labs/clmm'

// Convert price to sqrt price
const price = 1.5 // 1 tokenA = 1.5 tokenB
const sqrtPrice = TickMath.priceToSqrtPriceX64(
  price, 
  decimalsA, 
  decimalsB
)

Tick Spacing Guide

Tick Spacing
Fee

2

0.01%

10

0.05%

20

0.1%

60

0.5%

200

1%

220

5%

Error Handling

try {
  const tx = await sdk.Pool.createPoolTransactionPayload(params)
  // Execute transaction
} catch (error) {
  if (error.code === 'InvalidSendAddress') {
    // Set sender address
    sdk.senderAddress = '0x...'
  } else if (error.code === 'InsufficientBalance') {
    // Handle insufficient funds
  }
}

Important Notes

  • Coin types are automatically sorted according to protocol rules

  • The SDK handles coin selection from your wallet

  • Remaining coins are automatically returned to sender

  • Pool creation includes initial liquidity position (NFT)

Last updated