raydium
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRaydium 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 tokenCLMM (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 rewardsAMM 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 liquidityExamples
示例
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 SOLCLMM 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 rewardsPool Types
资金池类型
| Type | Description | Features |
|---|---|---|
| AMM (V4) | Standard constant-product AMM | Simple, high volume |
| CLMM | Concentrated liquidity | Capital efficient, earn fees in range |
| CPMM | Constant product (newer) | Lower fees |
| 类型 | 描述 | 特性 |
|---|---|---|
| AMM (V4) | 标准恒定乘积做市商 | 操作简单、交易量高 |
| CLMM | 集中流动性做市商 | 资本效率高、在指定价格区间赚取手续费 |
| CPMM | 恒定乘积做市商(新版) | 手续费更低 |
Tools Available
可用工具
Swap Tools
兑换工具
| Tool | Description |
|---|---|
| Execute swap via Raydium |
| Get quote without executing |
| List available pools |
| 工具 | 描述 |
|---|---|
| 通过Raydium执行代币兑换 |
| 获取兑换报价但不执行操作 |
| 列出可用资金池 |
CLMM Tools
CLMM工具
| Tool | Description |
|---|---|
| List your CLMM positions |
| Open new concentrated liquidity position |
| Add liquidity to existing position |
| Remove liquidity from position |
| Close an empty position |
| Harvest fees and rewards |
| Swap directly on a specific CLMM pool |
| Create new CLMM pool |
| Get available fee tier configs |
| 工具 | 描述 |
|---|---|
| 列出你的CLMM仓位 |
| 新建集中流动性仓位 |
| 为现有仓位增加流动性 |
| 从仓位中移除流动性 |
| 清空并关闭仓位 |
| 收取手续费与奖励 |
| 在指定CLMM资金池直接兑换 |
| 新建CLMM资金池 |
| 获取可用手续费层级配置 |
AMM Tools
AMM工具
| Tool | Description |
|---|---|
| Add liquidity to AMM pool |
| Remove liquidity from AMM pool |
| 工具 | 描述 |
|---|---|
| 为AMM资金池添加流动性 |
| 从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 # optionalbash
SOLANA_PRIVATE_KEY=<base58 or JSON array>
SOLANA_RPC_URL=https://api.mainnet-beta.solana.com # optionalCLMM Position Management
CLMM仓位管理
Opening a Position
开仓步骤
- Choose a pool (e.g., SOL-USDC)
- Set price range (lower, upper)
- Deposit tokens - you'll provide both tokens proportionally
- 选择资金池(如SOL-USDC)
- 设置价格区间(下限、上限)
- 存入代币 - 你需要按比例存入两种代币
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
价格区间策略
| Strategy | Range | Risk/Reward |
|---|---|---|
| Wide range | 50% - 200% of current | Lower fees, less IL |
| Narrow range | 95% - 105% | Higher fees, more IL risk |
| Full range | 0 - infinity | Like standard AMM |
| 策略 | 区间范围 | 风险/收益 |
|---|---|---|
| 宽区间 | 当前价格的50% - 200% | 手续费收入较低,无常损失(IL)风险小 |
| 窄区间 | 当前价格的95% - 105% | 手续费收入较高,无常损失(IL)风险大 |
| 全区间 | 0 - 无穷大 | 与标准AMM机制一致 |