Create pool CLMM Cetus

Usage

// Create pool clmm
const form: ICreateTokenForm = {
  coinTypeA:
    "0x92aad4e078dded45773628adc3a9977d546b178bdadabcae351ce1818c5bb1fb::sc::SC",
  coinTypeB: "0x2::sui::SUI",
  initializePrice: 1,
  tickSpacing: 10,
  inputTokenAmount: 1,
  isTokenAInput: true,
  slippage: 0.07,
};

const result = await agent.createPoolCetusCLMM(form);

Parameters

ParameterTypeRequiredDescription
coinTypeAstringYesAddress or symbol of the first token
coinTypeBstringYesAddress or symbol of the second token
initializePricenumberYesInitial price for the token pair
tickSpacingnumberYesThe spacing between ticks in the liquidity pool
inputTokenAmountnumberYesAmount of tokens to be provided as input
isTokenAInputbooleanYestrue means fixed coinA amount, false means fixed coinB amount
slippagenumberYesMaximum allowable slippage (e.g., 0.07 for 7%)

Example Prompts

Natural Language Prompts

"Create a Cetus CLMM pool with the following parameters:
coinTypeA: 0x92aad4e078dded45773628adc3a9977d546b178bdadabcae351ce1818c5bb1fb::sc::SC
coinTypeB: 0x2::sui::SUI
Initialize Price: 1
Tick Spacing: 10
Input Token Amount: 1
Is Token A Input: true
Slippage: 0.07"

LangChain Tool Prompts

{
 coinTypeA:
   "0x92aad4e078dded45773628adc3a9977d546b178bdadabcae351ce1818c5bb1fb::sc::SC",
 coinTypeB: "0x2::sui::SUI",
 initializePrice: 1,
 tickSpacing: 10,
 inputTokenAmount: 1,
 isTokenAInput: true,
 slippage: 0.07,
}

Example Implementation

import { SuiAgentKit, ICreateTokenForm } from "@getnimbus/sui-agent-kit";

async function unStake(agent: SuiAgentKit) {
  try {
    const form: ICreateTokenForm = {
      coinTypeA:
        "0x92aad4e078dded45773628adc3a9977d546b178bdadabcae351ce1818c5bb1fb::sc::SC",
      coinTypeB: "0x2::sui::SUI",
      initializePrice: 1,
      tickSpacing: 10,
      inputTokenAmount: 1,
      isTokenAInput: true,
      slippage: 0.07,
    };

    const result = await agent.createPoolCetusCLMM(form);
    console.log("Create pool result:", result);
  } catch (error) {
    console.error("Create pool failed:", error);
  }
}

Implementation Details

  • Initialize the sqrt price and current tick index based on initializePrice
  • Build the tick range
  • Estimate liquidity and token amounts from a single input
  • Calculate the required amounts of Token A and Token B
  • Once all parameters are set, prepare the transaction payload
  • Sign and execute the transactionn

Response Format

// Successful response
{
  tx_hash: "DHGKz1EZDnDHbiRC2P3dZd7xuLnfGdncDaBvaExyTAfM",
  tx_status: "success",
}

// Error response
{
  tx_hash: "DHGKz1EZDnDHbiRC2P3dZd7xuLnfGdncDaBvaExyTAfM",
  tx_status: "failed",
}

Error Handling

try {
  // Create pool clmm
  const form: ICreateTokenForm = {
    coinTypeA:
      "0x92aad4e078dded45773628adc3a9977d546b178bdadabcae351ce1818c5bb1fb::sc::SC",
    coinTypeB: "0x2::sui::SUI",
    initializePrice: 1,
    tickSpacing: 10,
    inputTokenAmount: 1,
    isTokenAInput: true,
    slippage: 0.07,
  };
  
  const result = await agent.createPoolCetusCLMM(form);
} catch (error) {
  if (error.message.includes("Insufficient balance")) {
    // Handle insufficient balance
  } else {
    // Handle other transaction failures
  }
}

Best Practices

  1. Balance Verification
  • Account for transaction fees
  1. Transaction Management
  • Monitor transaction status
  • Implement proper error handling
  • Use appropriate commitment levels
  1. Security
  • Verify transaction details
  • Double-check amounts
  • Keep private keys secure
  1. User Experience
  • Show transaction progress
  • Display staking rewards
  • get_holding: Check token balances