Cetus CLMM SDK Guide
Overview
This Skill provides comprehensive guidance for using the Cetus CLMM (Concentrated Liquidity Market Maker) TypeScript SDK. The SDK enables developers to interact with Cetus Protocol's CLMM on the Sui blockchain, including liquidity management, pool operations, swaps, and reward collection.
Getting Started
See Getting Started Guide for installation, configuration, and basic setup.
Core Modules
Liquidity Management
Add, remove, and manage liquidity positions:
- Add liquidity: Deposit tokens into existing positions
- Remove liquidity: Withdraw tokens from positions
- Open Position: Create new liquidity positions
- Close Position: Remove and collect from positions
- Detailed guide
Pool Operations
Create and interact with CLMM pools:
- Create CLMM Pool: Initialize new trading pools
- Getting CLMM Pools: Query and list available pools
- Gets ticks: Fetch tick data for price ranges
- Detailed guide
Swap Operations
Execute token swaps with optimized pricing:
- Pre Swap: Calculate swap outcomes before execution
- Swap: Execute token exchanges
- Price impact & fees: Calculate trading costs
- Detailed guide
Rewards Management
Collect and manage liquidity provider rewards:
- Collect rewards: Claim accumulated rewards
- Gets Pool Position Rewards: Query reward amounts for positions
- Detailed guide
Math Utilities
CLMM calculation tools from @cetusprotocol/common-sdk:
- Price conversions: Convert between price, sqrt price, and tick index
- Liquidity calculations: Compute liquidity amounts and token requirements
- Tick math: Work with tick indices and ranges
- Detailed guide
Examples
- End-to-end Liquidity Management - Complete workflow for adding and managing liquidity
- Complete Swap Flow - Full swap execution with pre-calculation
- Reward Collection Workflow - Claiming and managing rewards
Best Practices
SDK Initialization
Always initialize the SDK with appropriate network configuration:
import CetusClmmSDK from '@cetusprotocol/sui-clmm-sdk'
// For mainnet use
const sdk = CetusClmmSDK.createSDK({ env: 'mainnet' })
// For testnet use
const sdk = CetusClmmSDK.createSDK({ env: 'testnet' })
Error Handling
Wrap SDK calls in try-catch blocks and handle common errors:
- Network connectivity issues
- Insufficient balance errors
- Transaction validation failures
- Position/pool not found errors
Performance Considerations
- Cache pool and position data when possible
- Batch related operations when appropriate
- Monitor gas estimates before transaction submission
Security
- Never expose private keys in code
- Validate all user inputs and parameters
- Use appropriate slippage protection
- Review transaction payloads before signing
Troubleshooting
Common Issues
SDK initialization fails
- Verify network connectivity
- Check RPC endpoint availability
- Ensure proper package installation
Transactions fail
- Check account balance and gas fees
- Verify position/pool exists and is accessible
- Review error messages for specific issues
Price calculations incorrect
- Confirm decimal precision settings
- Verify tick spacing matches pool configuration
- Check current pool state and liquidity
Debugging Tips
- Enable debug logging in SDK configuration
- Test with small amounts first
- Use testnet for development and testing
- Consult the Cetus documentation for updates