# Raydium LaunchLab Rust SDK
A Rust SDK for interacting with the **Raydium LaunchLab** program on Solana.
**Program ID:** `LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj`
## Features
- 🛒 **Buy/Sell** tokens on bonding curve pools
- 🚀 **Initialize** new launchpad pools
- 💰 **Claim fees** (creator, platform, protocol)
- 🔒 **Vesting** token management
- 🔄 **Migration** to AMM/CPSwap
## Installation
Add to your `Cargo.toml`:
```toml
[dependencies]
raydium-launchlab-sdk = { path = "../raydiumlaunchlab-rust-sdk" }
```
## Quick Start
### Buy Tokens
```rust
use raydium_launchlab::{instructions, pda, accounts::PoolState};
use solana_sdk::pubkey::Pubkey;
// Derive pool state PDA
let (pool_state, _) = pda::get_pool_state_pda(&base_mint, "e_mint);
// Fetch pool state
let pool_data = client.get_account_data(&pool_state)?;
let pool = PoolState::try_from_bytes(&pool_data)?;
// Build buy instruction
let buy_ix = instructions::buy_exact_in(
&payer,
&pool.global_config,
&pool.platform_config,
&pool_state,
&user_base_token,
&user_quote_token,
&base_vault,
"e_vault,
&base_mint,
"e_mint,
&token_program,
amount_in, // Amount of quote tokens to spend
minimum_amount_out, // Slippage protection
0, // Share fee rate (referral)
);
```
### Sell Tokens
```rust
let sell_ix = instructions::sell_exact_in(
&payer,
&pool.global_config,
&pool.platform_config,
&pool_state,
&user_base_token,
&user_quote_token,
&base_vault,
"e_vault,
&base_mint,
"e_mint,
&token_program,
amount_in, // Amount of base tokens to sell
minimum_amount_out, // Slippage protection
0, // Share fee rate
);
```
### Convenience Functions
```rust
// Auto-derive all accounts
let buy_ix = instructions::create_buy_instruction(
&payer,
&base_mint,
"e_mint,
&global_config,
&platform_config,
amount_in,
minimum_amount_out,
share_fee_rate,
false, // is_token_2022
);
```
## PDA Derivation
```rust
use raydium_launchlab::pda;
// Pool State
let (pool_state, _) = pda::get_pool_state_pda(&base_mint, "e_mint);
// Pool Vaults
let (base_vault, _) = pda::get_pool_vault_pda(&pool_state, &base_mint);
let (quote_vault, _) = pda::get_pool_vault_pda(&pool_state, "e_mint);
// Authority
let (authority, _) = pda::get_authority_pda();
// Global Config
let (global_config, _) = pda::get_global_config_pda("e_mint, curve_type, index);
// Platform Config
let (platform_config, _) = pda::get_platform_config_pda(&platform_admin);
// Vesting Record
let (vesting_record, _) = pda::get_vesting_record_pda(&pool_state, &beneficiary);
```
## Account Structures
### PoolState
```rust
use raydium_launchlab::accounts::PoolState;
let pool = PoolState::try_from_bytes(&data)?;
// Status checks
pool.is_funding(); // Pool accepting funds
pool.is_migrate(); // Waiting for migration
pool.is_trading(); // Migration complete
// Pool info
pool.get_current_price(); // Quote per base
pool.get_funding_progress(); // Percentage funded
// Token program detection
pool.is_base_token_2022(); // Base uses Token-2022
pool.is_quote_token_2022(); // Quote uses Token-2022
```
## Instructions
| `buy_exact_in` | Buy base tokens with specified quote amount |
| `buy_exact_out` | Buy specified amount of base tokens |
| `sell_exact_in` | Sell specified amount of base tokens |
| `sell_exact_out` | Sell to receive specified quote amount |
| `initialize` | Create new launchpad pool |
| `initialize_v2` | Create pool with AMM fee option |
| `claim_creator_fee` | Claim creator trading fees |
| `claim_platform_fee` | Claim platform fees |
| `claim_vested_token` | Claim vested tokens |
| `create_vesting_account` | Create vesting for beneficiary |
| `migrate_to_amm` | Migrate to Raydium AMM |
| `migrate_to_cpswap` | Migrate to CPSwap |
## Examples
Run the examples:
```bash
cargo run --example buy
cargo run --example sell
```
## License
MIT