Documentation Index
Fetch the complete documentation index at: https://docs.raydium.io/llms.txt
Use this file to discover all available pages before exploring further.
Raydium’s newer programs (CPMM, CLMM, Farm v6, LaunchLab) are written in Anchor — a Rust framework that builds on Solana’s native program model to provide account validation, error handling, and an IDL (interface description). AMM v4 and older farms predate Anchor. Understanding both paradigms helps you read the code, generate clients from the IDL, and debug unexpected errors.
Program deployment model
Every Solana program lives at aPubkey. The program’s bytecode is stored in an executable account owned by the BPF Upgradable Loader (BPFLoaderUpgradeab1e11111111111111111111111).
A program deployment comprises three accounts:
- Program account: small metadata account at the program’s ID. Owner: BPF Upgradable Loader.
- ProgramData account: holds the actual bytecode. Derived as
[program_id, "programdata"]. - Buffer account (transient): holds new bytecode during an upgrade. Discarded after the upgrade.
security/admin-and-multisig.
Verifying a deployed program
To confirm what’s on-chain matches what’s in the audit-approved source:Anchor: a framework on top of Solana
Raw Solana programs are Rust functions with this signature:- Auto-generates a deterministic 8-byte discriminator for each instruction and each account type.
- Validates account constraints (owner, seeds, writable, signer, mint-matches, token-program-matches) before your code runs.
- Generates an IDL — an interface description file that clients use to call the program.
- Ships with a Rust, TypeScript, and Python client-side library.
The 8-byte discriminator
Every Anchor account and every Anchor instruction starts with an 8-byte discriminator — the first 8 bytes of SHA-256 of a fixed string:getProgramAccounts that enumerate all accounts of a type.
Errors
Anchor programs define errors via#[error_code]:
reference/error-codes.
The IDL
An Anchor IDL (Interface Description Language) file is a JSON description of a program: its instructions, accounts, types, errors, and events. It’s the equivalent of an Ethereum ABI. Raydium publishes IDLs for all Anchor programs. Fetch live from on-chain:src/raydium/*/idl/*.json.
IDL structure
Generating a client from the IDL
Anchor’sanchor CLI generates TypeScript and Rust types:
When the IDL is your friend
If you want to build a custom integration that doesn’t go through Raydium SDK:- Fetch the IDL (live from on-chain or from SDK source).
- Look up the instruction you want (e.g.,
swap_base_input). - Construct the instruction data: 8-byte discriminator + encoded args.
- Pass accounts in the order the IDL specifies.
sdk-api/anchor-idl for worked examples.
Pre-Anchor programs: AMM v4 and Farm v3/v5
These programs predate Anchor. They use:- Manual instruction dispatch: a
u8tag ininstruction_datawith amatchstatement. - Manual account validation:
if accounts[0].owner != &expected_program { ... }. - Borsh-serialized instruction args: no discriminator, just
instruction_data[1..]. - Layout via
#[repr(C, packed)]: C-struct binary layout.
Program upgrade mechanics
Only the ProgramData’supgrade_authority can upgrade. Steps:
- Compile the new bytecode.
- Write it to a buffer account (
solana program write-buffer). - Submit an upgrade instruction:
BpfLoaderUpgradeable::Upgrade { buffer, program, authority }. - The runtime atomically replaces the program’s bytecode with the buffer’s contents.
security/admin-and-multisig.
Making a program immutable
An upgrade authority can be set toNone, at which point the program becomes permanently immutable. Raydium hasn’t done this for any product — the team retains the ability to push security fixes. Trade-off: users must trust the multisig + timelock process.
Programs and rent
Deploying a program consumes rent-exempt lamports:- A 50 KB program: ~0.35 SOL in rent.
- A 200 KB program: ~1.4 SOL in rent.
solana program close) returns the lamports. Raydium programs remain active and aren’t scheduled for closure.
Debugging Anchor programs
Log output
Anchor’smsg! macro writes to the transaction’s log. Simulate a transaction to see logs:
- Program invocation (
Program CPMMoo8... invoke [1]). msg!calls from program code.- Compute unit consumption (
consumed 137842 of 400000 compute units). - Program success or error.
Error codes
If an Anchor program throws, the log shows:SlippageExceeded). Cross-reference with the IDL’s errors array.
See reference/error-codes for Raydium’s full error table.
Account layout mismatches
If you pass the wrong account in the wrong slot, Anchor’s account-validation macros return errors like:ErrorCode enum); errors ≥6000 are the program’s custom codes.
Pointers
solana-fundamentals/account-model— how programs own accounts.solana-fundamentals/pdas-and-cpis— PDAs as Anchor declares them.sdk-api/anchor-idl— fetching and using Raydium’s IDLs.reference/program-addresses— program IDs.reference/error-codes— error code reference.security/admin-and-multisig— upgrade-authority controls.
- Anchor book.
- Solana program deployment.
- Raydium IDLs (published in SDK
src/raydium/*/idl/*.json).


