raydium

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Raydium Protocol - Complete Integration Guide

Raydium Protocol 完整集成指南

The definitive guide for integrating Raydium - Solana's leading AMM and liquidity infrastructure powering DeFi since 2021.
本指南是在Solana上集成Raydium的权威参考,Raydium是Solana上领先的自动做市商(AMM)和流动性基础设施,自2021年起为DeFi生态提供支持。

What is Raydium?

什么是Raydium?

Raydium is a decentralized exchange on Solana providing:
  • Token Swapping - Fast, cheap swaps via smart routing across all pool types
  • Liquidity Provision - Earn trading fees and rewards by providing liquidity
  • Token Launches - LaunchLab for permissionless token launches with bonding curves
  • Perpetual Trading - Leverage trading on crypto assets
Raydium是Solana上的去中心化交易所,提供以下功能:
  • 代币兑换 - 通过智能路由在所有类型的流动性池之间实现快速、低成本的兑换
  • 流动性提供 - 通过提供流动性赚取交易手续费和奖励
  • 代币发行 - LaunchLab支持基于绑定曲线的无需许可代币发行
  • 永续合约交易 - 加密资产杠杆交易

Key Statistics

关键数据

  • Most widely integrated liquidity infrastructure on Solana
  • 35,000+ tokens launched via LaunchLab (2025)
  • Multiple pool types for different use cases
  • Solana上集成最广泛的流动性基础设施
  • 截至2025年,通过LaunchLab发行的代币超过35000种
  • 多种适用于不同场景的流动性池类型

Core Products

核心产品

Pool Types

流动性池类型

TypeDescriptionBest For
CLMMConcentrated Liquidity Market MakerProfessional LPs, stablecoin pairs, active management
CPMMConstant Product (x*y=k) with Token22New token launches, simple integrations
AMM V4Classic AMM + OpenBook CLOBExisting markets, hybrid liquidity
类型描述适用场景
CLMM集中流动性做市商专业流动性提供者、稳定币交易对、主动管理
CPMM基于Token22的恒定乘积做市商(x*y=k)新代币发行、简单集成场景
AMM V4经典AMM + OpenBook订单簿成熟市场、混合流动性场景

Additional Features

附加功能

  • LaunchLab - Permissionless token launches with bonding curves
  • Farms - Yield farming and staking rewards
  • Burn & Earn - Permanent liquidity locking
  • Trade API - HTTP API for swap routing
  • LaunchLab - 基于绑定曲线的无需许可代币发行
  • 流动性挖矿 - 收益挖矿和质押奖励
  • Burn & Earn - 永久锁定流动性
  • Trade API - 用于兑换路由的HTTP API

API Overview

API概述

1. SDK (TypeScript)

1. SDK(TypeScript)

Package:
@raydium-io/raydium-sdk-v2
For programmatic integration with full control over pools, positions, and transactions.
包名:
@raydium-io/raydium-sdk-v2
用于程序化集成,可全面控制流动性池、仓位和交易。

2. Trade API (HTTP)

2. Trade API(HTTP)

Base URL:
https://transaction-v1.raydium.io
For swap routing - get quotes and serialized transactions via HTTP.
基础URL:
https://transaction-v1.raydium.io
用于兑换路由——通过HTTP获取报价和序列化交易。

3. Data API

3. 数据API

Base URL:
https://api-v3.raydium.io
For pool data, token lists, farm info, and configurations.
基础URL:
https://api-v3.raydium.io
用于获取流动性池数据、代币列表、挖矿信息和配置。

Quick Start

快速开始

Installation

安装

bash
npm install @raydium-io/raydium-sdk-v2
bash
npm install @raydium-io/raydium-sdk-v2

or

or

yarn add @raydium-io/raydium-sdk-v2
undefined
yarn add @raydium-io/raydium-sdk-v2
undefined

Basic Setup

基础配置

typescript
import { Raydium } from '@raydium-io/raydium-sdk-v2';
import { Connection, Keypair } from '@solana/web3.js';
import bs58 from 'bs58';

// Setup connection and wallet
const connection = new Connection('https://api.mainnet-beta.solana.com');
const owner = Keypair.fromSecretKey(bs58.decode('YOUR_SECRET_KEY'));

// Initialize SDK
const raydium = await Raydium.load({
  connection,
  owner,
  cluster: 'mainnet',
  disableLoadToken: false, // Load token list
});

// Access token data
const tokenList = raydium.token.tokenList;
const tokenMap = raydium.token.tokenMap;

// Access account data
const tokenAccounts = raydium.account.tokenAccounts;
typescript
import { Raydium } from '@raydium-io/raydium-sdk-v2';
import { Connection, Keypair } from '@solana/web3.js';
import bs58 from 'bs58';

// 配置连接和钱包
const connection = new Connection('https://api.mainnet-beta.solana.com');
const owner = Keypair.fromSecretKey(bs58.decode('YOUR_SECRET_KEY'));

// 初始化SDK
const raydium = await Raydium.load({
  connection,
  owner,
  cluster: 'mainnet',
  disableLoadToken: false, // 加载代币列表
});

// 获取代币数据
const tokenList = raydium.token.tokenList;
const tokenMap = raydium.token.tokenMap;

// 获取账户数据
const tokenAccounts = raydium.account.tokenAccounts;

Pool Types

流动性池类型

CLMM (Concentrated Liquidity)

CLMM(集中流动性)

Allows LPs to concentrate liquidity in specific price ranges for higher capital efficiency.
typescript
// Fetch CLMM pool
const poolId = 'POOL_ID_HERE';
const poolInfo = await raydium.clmm.getPoolInfoFromRpc(poolId);

// Or from API (mainnet only)
const poolData = await raydium.api.fetchPoolById({ ids: poolId });
允许流动性提供者将流动性集中在特定价格区间,提高资本效率。
typescript
// 获取CLMM池信息
const poolId = 'POOL_ID_HERE';
const poolInfo = await raydium.clmm.getPoolInfoFromRpc(poolId);

// 或通过API获取(仅主网)
const poolData = await raydium.api.fetchPoolById({ ids: poolId });

CPMM (Constant Product)

CPMM(恒定乘积)

Simplified AMM without OpenBook market requirement, supports Token22.
typescript
// Fetch CPMM pool
const cpmmPool = await raydium.cpmm.getPoolInfoFromRpc(poolId);
简化版AMM,无需依赖OpenBook订单簿,支持Token22标准。
typescript
// 获取CPMM池信息
const cpmmPool = await raydium.cpmm.getPoolInfoFromRpc(poolId);

AMM (Legacy)

AMM(经典版)

Classic AMM integrated with OpenBook central limit order book.
typescript
// Fetch AMM pool
const ammPool = await raydium.liquidity.getPoolInfoFromRpc({ poolId });
与OpenBook限价订单簿集成的经典AMM。
typescript
// 获取AMM池信息
const ammPool = await raydium.liquidity.getPoolInfoFromRpc({ poolId });

Core Operations

核心操作

Swap

代币兑换

typescript
import { CurveCalculator } from '@raydium-io/raydium-sdk-v2';

// Calculate swap
const { amountOut, fee } = CurveCalculator.swapBaseInput({
  poolInfo,
  amountIn: 1000000n, // lamports
  mintIn: inputMint,
  mintOut: outputMint,
});

// Execute CPMM swap
const { execute } = await raydium.cpmm.swap({
  poolInfo,
  inputAmount: 1000000n,
  inputMint,
  slippage: 0.01, // 1%
  txVersion: 'V0',
});

await execute({ sendAndConfirm: true });
typescript
import { CurveCalculator } from '@raydium-io/raydium-sdk-v2';

// 计算兑换结果
const { amountOut, fee } = CurveCalculator.swapBaseInput({
  poolInfo,
  amountIn: 1000000n, // lamports
  mintIn: inputMint,
  mintOut: outputMint,
});

// 执行CPMM兑换
const { execute } = await raydium.cpmm.swap({
  poolInfo,
  inputAmount: 1000000n,
  inputMint,
  slippage: 0.01, // 1%
  txVersion: 'V0',
});

await execute({ sendAndConfirm: true });

Add Liquidity

添加流动性

typescript
// CPMM deposit
const { execute } = await raydium.cpmm.addLiquidity({
  poolInfo,
  inputAmount: 1000000n,
  baseIn: true,
  slippage: 0.01,
});

await execute({ sendAndConfirm: true });
typescript
// CPMM存入流动性
const { execute } = await raydium.cpmm.addLiquidity({
  poolInfo,
  inputAmount: 1000000n,
  baseIn: true,
  slippage: 0.01,
});

await execute({ sendAndConfirm: true });

Create Pool

创建流动性池

typescript
// Create CPMM pool
const { execute } = await raydium.cpmm.createPool({
  mintA,
  mintB,
  mintAAmount: 1000000n,
  mintBAmount: 1000000n,
  startTime: new BN(0),
  feeConfig, // from API
  txVersion: 'V0',
});

const { txId } = await execute({ sendAndConfirm: true });
typescript
// 创建CPMM池
const { execute } = await raydium.cpmm.createPool({
  mintA,
  mintB,
  mintAAmount: 1000000n,
  mintBAmount: 1000000n,
  startTime: new BN(0),
  feeConfig, // 从API获取
  txVersion: 'V0',
});

const { txId } = await execute({ sendAndConfirm: true });

Program IDs

程序ID

ProgramMainnetDevnet
AMM
675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8
DRaya7Kj3aMWQSy19kSjvmuwq9docCHofyP9kanQGaav
CLMM
CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK
devi51mZmdwUJGU9hjN27vEz64Gps7uUefqxg27EAtH
CPMM
CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C
CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW
程序主网测试网
AMM
675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8
DRaya7Kj3aMWQSy19kSjvmuwq9docCHofyP9kanQGaav
CLMM
CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK
devi51mZmdwUJGU9hjN27vEz64Gps7uUefqxg27EAtH
CPMM
CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C
CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW

API Endpoints

API端点

typescript
// Mainnet API
const API_URL = 'https://api-v3.raydium.io';

// Devnet API
const DEVNET_API = 'https://api-v3.raydium.io/main/';

// Common endpoints
const endpoints = {
  tokenList: '/mint/list',
  poolList: '/pools/info/list',
  poolById: '/pools/info/ids',
  farmList: '/farms/info/list',
  clmmConfigs: '/clmm/configs',
};
typescript
// 主网API
const API_URL = 'https://api-v3.raydium.io';

// 测试网API
const DEVNET_API = 'https://api-v3.raydium.io/main/';

// 常用端点
const endpoints = {
  tokenList: '/mint/list',
  poolList: '/pools/info/list',
  poolById: '/pools/info/ids',
  farmList: '/farms/info/list',
  clmmConfigs: '/clmm/configs',
};

Transaction Options

交易选项

typescript
const { execute } = await raydium.cpmm.swap({
  poolInfo,
  inputAmount,
  inputMint,
  slippage: 0.01,
  txVersion: 'V0', // or 'LEGACY'
  computeBudgetConfig: {
    units: 600000,
    microLamports: 100000, // priority fee
  },
});

// Execute with options
const { txId } = await execute({
  sendAndConfirm: true,
  skipPreflight: true,
});

console.log(`https://solscan.io/tx/${txId}`);
typescript
const { execute } = await raydium.cpmm.swap({
  poolInfo,
  inputAmount,
  inputMint,
  slippage: 0.01,
  txVersion: 'V0', // 或 'LEGACY'
  computeBudgetConfig: {
    units: 600000,
    microLamports: 100000, // 优先级手续费
  },
});

// 带选项执行交易
const { txId } = await execute({
  sendAndConfirm: true,
  skipPreflight: true,
});

console.log(`https://solscan.io/tx/${txId}`);

Key Features

核心功能对比

FeatureCLMMCPMMAMM
Concentrated LiquidityYesNoNo
Token22 SupportLimitedYesNo
OpenBook RequiredNoNoYes
Custom Price RangesYesNoNo
LP NFT PositionsYesNoNo
功能CLMMCPMMAMM
集中流动性
Token22支持有限支持
需要OpenBook
自定义价格区间
LP NFT仓位

LaunchLab (New)

LaunchLab(新版)

LaunchLab simplifies token launches on Solana with customizable bonding curves:
typescript
// Create token with bonding curve via LaunchLab
const { execute } = await raydium.launchLab.createToken({
  name: "My Token",
  symbol: "MTK",
  uri: "https://arweave.net/metadata.json",
  initialSupply: 1_000_000_000n,
  bondingCurve: "linear", // or "exponential"
  graduationThreshold: 85_000_000_000n, // 85 SOL
  txVersion: "V0",
});

const { txId } = await execute({ sendAndConfirm: true });
LaunchLab通过可自定义的绑定曲线简化Solana上的代币发行:
typescript
// 通过LaunchLab创建带绑定曲线的代币
const { execute } = await raydium.launchLab.createToken({
  name: "My Token",
  symbol: "MTK",
  uri: "https://arweave.net/metadata.json",
  initialSupply: 1_000_000_000n,
  bondingCurve: "linear", // 或 "exponential"
  graduationThreshold: 85_000_000_000n, // 85 SOL
  txVersion: "V0",
});

const { txId } = await execute({ sendAndConfirm: true });

Bonding Curve Migration

绑定曲线迁移

Tokens automatically migrate to AMM pools once they hit the graduation threshold (default: 85 SOL). Creators earn 10% of trading fees post-migration.
当代币达到毕业阈值(默认:85 SOL)时,会自动迁移到AMM池。创作者在迁移后可赚取10%的交易手续费。

Key Milestones (2025)

2025年关键里程碑

  • 35,000+ tokens launched via LaunchLab
  • Orb Explorer launched for on-chain analytics
  • 通过LaunchLab发行的代币超过35000种
  • 推出Orb Explorer用于链上分析

V3 Protocol (Coming)

V3协议(即将推出)

Raydium V3 introduces a hybrid liquidity model combining:
  • AMM pools with OpenBook's decentralized order book
  • Access to 40% more liquidity across Solana DeFi
  • Enhanced capital efficiency for LPs
Raydium V3引入混合流动性模型,结合:
  • AMM池与OpenBook去中心化订单簿
  • 可访问Solana DeFi生态中40%以上的流动性
  • 为流动性提供者提升资本效率

Resources

资源

Skill Structure

文档结构

raydium/
├── SKILL.md                      # This file - complete integration guide
├── resources/
│   ├── sdk-api-reference.md      # Complete SDK API
│   ├── trade-api.md              # HTTP Trade API reference
│   ├── program-ids.md            # All program addresses
│   ├── pool-types.md             # Pool type comparison
│   ├── launchlab.md              # LaunchLab documentation
│   └── github-repos.md           # GitHub repositories reference
├── examples/
│   ├── swap/README.md            # Token swap examples
│   ├── clmm-pool/README.md       # CLMM pool creation
│   ├── clmm-position/README.md   # CLMM position management
│   ├── cpmm-pool/README.md       # CPMM pool operations
│   ├── liquidity/README.md       # Liquidity management
│   ├── farming/README.md         # Farming and staking
│   └── launchlab/README.md       # LaunchLab token launches
├── templates/
│   └── raydium-setup.ts          # SDK setup template
└── docs/
    ├── clmm-guide.md             # CLMM deep dive
    └── troubleshooting.md        # Common issues
raydium/
├── SKILL.md                      # 本文档 - 完整集成指南
├── resources/
│   ├── sdk-api-reference.md      # 完整SDK API参考
│   ├── trade-api.md              # HTTP Trade API参考
│   ├── program-ids.md            # 所有程序地址
│   ├── pool-types.md             # 流动性池类型对比
│   ├── launchlab.md              # LaunchLab文档
│   └── github-repos.md           # GitHub仓库参考
├── examples/
│   ├── swap/README.md            # 代币兑换示例
│   ├── clmm-pool/README.md       # CLMM池创建示例
│   ├── clmm-position/README.md   # CLMM仓位管理示例
│   ├── cpmm-pool/README.md       # CPMM池操作示例
│   ├── liquidity/README.md       # 流动性管理示例
│   ├── farming/README.md         # 流动性挖矿与质押示例
│   └── launchlab/README.md       # LaunchLab代币发行示例
├── templates/
│   └── raydium-setup.ts          # SDK配置模板
└── docs/
    ├── clmm-guide.md             # CLMM深度解析
    └── troubleshooting.md        # 常见问题排查

GitHub Repositories

GitHub仓库

RepositoryDescription
raydium-sdk-V2TypeScript SDK
raydium-sdk-V2-demoSDK examples
raydium-clmmCLMM program (Rust)
raydium-cp-swapCPMM program (Rust)
raydium-ammAMM V4 program (Rust)
raydium-cpiCPI integration examples
raydium-idlIDL definitions
仓库描述
raydium-sdk-V2TypeScript SDK
raydium-sdk-V2-demoSDK示例代码
raydium-clmmCLMM程序(Rust)
raydium-cp-swapCPMM程序(Rust)
raydium-ammAMM V4程序(Rust)
raydium-cpiCPI集成示例
raydium-idlIDL定义