raydium

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Raydium DEX

Raydium DEX

Raydium is a high-volume DEX on Solana with AMM pools and CLMM (Concentrated Liquidity Market Maker) pools.
Raydium是Solana上的高交易量去中心化交易所(DEX),支持AMM资金池和CLMM(集中流动性做市商)资金池。

Commands

命令

Swaps

代币兑换

/ray swap <amount> <from> to <to>    Execute swap on Raydium
/ray quote <amount> <from> to <to>   Get quote without executing
/ray pools <token>                   List pools for token
/ray swap <amount> <from> to <to>    Execute swap on Raydium
/ray quote <amount> <from> to <to>   Get quote without executing
/ray pools <token>                   List pools for token

CLMM (Concentrated Liquidity)

CLMM(集中流动性)

/ray clmm positions                  List your CLMM positions
/ray clmm create <pool> <lower> <upper> <amount>   Open position
/ray clmm add <pool> <nft> <amount>  Add liquidity to position
/ray clmm remove <pool> <nft> [%]    Remove liquidity
/ray clmm close <pool> <nft>         Close position
/ray clmm harvest                    Harvest all rewards
/ray clmm positions                  List your CLMM positions
/ray clmm create <pool> <lower> <upper> <amount>   Open position
/ray clmm add <pool> <nft> <amount>  Add liquidity to position
/ray clmm remove <pool> <nft> [%]    Remove liquidity
/ray clmm close <pool> <nft>         Close position
/ray clmm harvest                    Harvest all rewards

AMM Liquidity

AMM流动性管理

/ray amm add <pool> <amountA> [amountB]   Add liquidity
/ray amm remove <pool> <lpAmount>         Remove liquidity
/ray amm add <pool> <amountA> [amountB]   Add liquidity
/ray amm remove <pool> <lpAmount>         Remove liquidity

Examples

示例

Swaps

代币兑换

/ray swap 1 SOL to USDC
/ray quote 100 USDC to RAY
/ray pools SOL
/ray swap 1 SOL to USDC
/ray quote 100 USDC to RAY
/ray pools SOL

CLMM Positions

CLMM仓位操作

/ray clmm positions                              # List all positions
/ray clmm create ABC123... 100 200 1000000000   # Open position with price range
/ray clmm add ABC123... NFT456... 500000000     # Add liquidity
/ray clmm remove ABC123... NFT456... 50         # Remove 50%
/ray clmm harvest                                # Harvest rewards
/ray clmm positions                              # List all positions
/ray clmm create ABC123... 100 200 1000000000   # Open position with price range
/ray clmm add ABC123... NFT456... 500000000     # Add liquidity
/ray clmm remove ABC123... NFT456... 50         # Remove 50%
/ray clmm harvest                                # Harvest rewards

Pool Types

资金池类型

TypeDescriptionFeatures
AMM (V4)Standard constant-product AMMSimple, high volume
CLMMConcentrated liquidityCapital efficient, earn fees in range
CPMMConstant product (newer)Lower fees
类型描述特性
AMM (V4)标准恒定乘积做市商操作简单、交易量高
CLMM集中流动性做市商资本效率高、在指定价格区间赚取手续费
CPMM恒定乘积做市商(新版)手续费更低

Tools Available

可用工具

Swap Tools

兑换工具

ToolDescription
raydium_swap
Execute swap via Raydium
raydium_quote
Get quote without executing
raydium_pools
List available pools
工具描述
raydium_swap
通过Raydium执行代币兑换
raydium_quote
获取兑换报价但不执行操作
raydium_pools
列出可用资金池

CLMM Tools

CLMM工具

ToolDescription
raydium_clmm_positions
List your CLMM positions
raydium_clmm_create_position
Open new concentrated liquidity position
raydium_clmm_increase_liquidity
Add liquidity to existing position
raydium_clmm_decrease_liquidity
Remove liquidity from position
raydium_clmm_close_position
Close an empty position
raydium_clmm_harvest
Harvest fees and rewards
raydium_clmm_swap
Swap directly on a specific CLMM pool
raydium_clmm_create_pool
Create new CLMM pool
raydium_clmm_configs
Get available fee tier configs
工具描述
raydium_clmm_positions
列出你的CLMM仓位
raydium_clmm_create_position
新建集中流动性仓位
raydium_clmm_increase_liquidity
为现有仓位增加流动性
raydium_clmm_decrease_liquidity
从仓位中移除流动性
raydium_clmm_close_position
清空并关闭仓位
raydium_clmm_harvest
收取手续费与奖励
raydium_clmm_swap
在指定CLMM资金池直接兑换
raydium_clmm_create_pool
新建CLMM资金池
raydium_clmm_configs
获取可用手续费层级配置

AMM Tools

AMM工具

ToolDescription
raydium_amm_add_liquidity
Add liquidity to AMM pool
raydium_amm_remove_liquidity
Remove liquidity from AMM pool
工具描述
raydium_amm_add_liquidity
为AMM资金池添加流动性
raydium_amm_remove_liquidity
从AMM资金池移除流动性

TypeScript API

TypeScript API

typescript
import {
  // Swaps
  executeRaydiumSwap,
  getRaydiumQuote,
  listRaydiumPools,

  // CLMM (Concentrated Liquidity)
  getClmmPositions,
  createClmmPosition,
  increaseClmmLiquidity,
  decreaseClmmLiquidity,
  closeClmmPosition,
  harvestClmmRewards,
  swapClmm,
  createClmmPool,
  getClmmConfigs,

  // AMM Liquidity
  addAmmLiquidity,
  removeAmmLiquidity,
} from 'clodds/solana/raydium';

// Execute swap
const swap = await executeRaydiumSwap(connection, keypair, {
  inputMint: 'So11111111111111111111111111111111111111112',
  outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
  amount: '1000000000', // 1 SOL in lamports
  slippageBps: 50,
});

// Open CLMM position
const position = await createClmmPosition(connection, keypair, {
  poolId: 'POOL_ID_HERE',
  priceLower: 100,
  priceUpper: 200,
  baseAmount: '1000000000', // 1 SOL
  slippage: 0.01,
});
console.log(`Position NFT: ${position.nftMint}`);

// List positions
const positions = await getClmmPositions(connection, keypair);
for (const pos of positions) {
  console.log(`Pool: ${pos.poolId}, Liquidity: ${pos.liquidity}`);
}

// Add liquidity to position
await increaseClmmLiquidity(connection, keypair, {
  poolId: 'POOL_ID_HERE',
  positionNftMint: 'NFT_MINT_HERE',
  amountA: '500000000', // 0.5 SOL
});

// Harvest rewards
const rewards = await harvestClmmRewards(connection, keypair);
console.log(`Harvested: ${rewards.signatures.length} transactions`);

// AMM: Add liquidity
await addAmmLiquidity(connection, keypair, {
  poolId: 'AMM_POOL_ID',
  amountA: '1000000000',
  fixedSide: 'a',
  slippage: 0.01,
});

// AMM: Remove liquidity
await removeAmmLiquidity(connection, keypair, {
  poolId: 'AMM_POOL_ID',
  lpAmount: '1000000', // LP tokens to burn
  slippage: 0.1,
});
typescript
import {
  // Swaps
  executeRaydiumSwap,
  getRaydiumQuote,
  listRaydiumPools,

  // CLMM (Concentrated Liquidity)
  getClmmPositions,
  createClmmPosition,
  increaseClmmLiquidity,
  decreaseClmmLiquidity,
  closeClmmPosition,
  harvestClmmRewards,
  swapClmm,
  createClmmPool,
  getClmmConfigs,

  // AMM Liquidity
  addAmmLiquidity,
  removeAmmLiquidity,
} from 'clodds/solana/raydium';

// Execute swap
const swap = await executeRaydiumSwap(connection, keypair, {
  inputMint: 'So11111111111111111111111111111111111111112',
  outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
  amount: '1000000000', // 1 SOL in lamports
  slippageBps: 50,
});

// Open CLMM position
const position = await createClmmPosition(connection, keypair, {
  poolId: 'POOL_ID_HERE',
  priceLower: 100,
  priceUpper: 200,
  baseAmount: '1000000000', // 1 SOL
  slippage: 0.01,
});
console.log(`Position NFT: ${position.nftMint}`);

// List positions
const positions = await getClmmPositions(connection, keypair);
for (const pos of positions) {
  console.log(`Pool: ${pos.poolId}, Liquidity: ${pos.liquidity}`);
}

// Add liquidity to position
await increaseClmmLiquidity(connection, keypair, {
  poolId: 'POOL_ID_HERE',
  positionNftMint: 'NFT_MINT_HERE',
  amountA: '500000000', // 0.5 SOL
});

// Harvest rewards
const rewards = await harvestClmmRewards(connection, keypair);
console.log(`Harvested: ${rewards.signatures.length} transactions`);

// AMM: Add liquidity
await addAmmLiquidity(connection, keypair, {
  poolId: 'AMM_POOL_ID',
  amountA: '1000000000',
  fixedSide: 'a',
  slippage: 0.01,
});

// AMM: Remove liquidity
await removeAmmLiquidity(connection, keypair, {
  poolId: 'AMM_POOL_ID',
  lpAmount: '1000000', // LP tokens to burn
  slippage: 0.1,
});

Environment Variables

环境变量

bash
SOLANA_PRIVATE_KEY=<base58 or JSON array>
SOLANA_RPC_URL=https://api.mainnet-beta.solana.com  # optional
bash
SOLANA_PRIVATE_KEY=<base58 or JSON array>
SOLANA_RPC_URL=https://api.mainnet-beta.solana.com  # optional

CLMM Position Management

CLMM仓位管理

Opening a Position

开仓步骤

  1. Choose a pool (e.g., SOL-USDC)
  2. Set price range (lower, upper)
  3. Deposit tokens - you'll provide both tokens proportionally
  1. 选择资金池(如SOL-USDC)
  2. 设置价格区间(下限、上限)
  3. 存入代币 - 你需要按比例存入两种代币

Managing Positions

仓位管理操作

  • Add liquidity: Deposit more tokens to existing position
  • Remove liquidity: Withdraw tokens (partial or full)
  • Harvest: Collect trading fees earned
  • Close: Close position after removing all liquidity
  • 增加流动性:向现有仓位存入更多代币
  • 移除流动性:提取部分或全部代币
  • 收取奖励:收取赚取的交易手续费
  • 平仓:移除所有流动性后关闭仓位

Price Range Strategy

价格区间策略

StrategyRangeRisk/Reward
Wide range50% - 200% of currentLower fees, less IL
Narrow range95% - 105%Higher fees, more IL risk
Full range0 - infinityLike standard AMM
策略区间范围风险/收益
宽区间当前价格的50% - 200%手续费收入较低,无常损失(IL)风险小
窄区间当前价格的95% - 105%手续费收入较高,无常损失(IL)风险大
全区间0 - 无穷大与标准AMM机制一致