Protocols / DEX
Raydium AMM
Raydium's original AMM (v4) on Solana, the constant-product pools that Raydium runs with the OpenBook order book. An agent can swap through a pool, add liquidity, and remove liquidity. Raydium's REST API lists pools, mints and prices.
On-chain + APISOLANA1 contractsWebsite · Docs
get_protocol({ "protocol": "raydium-amm" })Risks an agent should know
- Constant-product pools lose value to arbitrage when prices move, which is impermanent loss for liquidity providers.
- Low-liquidity pools have high price impact. Set minimum_amount_out on every swap.
- Anyone can create a pool for any token pair, including fake or scam tokens. Check the mint before swapping or providing liquidity.
- AMM v4 is the older Raydium program. Newer Raydium pool types (CPMM, CLMM) are separate programs and are not covered here.
- The program is upgradeable by its maintainers. Admin instructions are not for ordinary users.
What an agent can do
| swap | Swap one token for another in a Raydium AMM v4 pool GET the pool from /pools/info/mint (or /pools/info/ids), build SwapBaseInV2(amount_in, minimum_amount_out) with the pool's accounts (amm, vaults, authority, user token accounts), sign and send. Compute minimum_amount_out from the pool reserves and your slippage. |
| add-liquidity | Deposit two tokens into a pool and receive LP tokens Deposit(max_coin_amount, max_pc_amount, base_side, other_amount_min) at the current ratio; check the pool's LP mint and ratio first |
| remove-liquidity | Burn LP tokens for the two underlying tokens Withdraw(amount, min_coin_amount, min_pc_amount) |
| create-pool | Create a new AMM v4 pool for a market Initialize2 with the market id and the starting amounts. The pool needs an existing OpenBook market and a pool creation fee. |
Contracts
solana
| Contract | Address | Key functions | Try |
|---|---|---|---|
| Raydium AMM v4 program exchange | 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 source | writeSwapBaseInV2(amount_in: u64, minimum_amount_out: u64) writeSwapBaseOutV2(max_amount_in: u64, amount_out: u64) writeSwapBaseIn(amount_in: u64, minimum_amount_out: u64) writeSwapBaseOut(max_amount_in: u64, amount_out: u64) writeDeposit(max_coin_amount: u64, max_pc_amount: u64, base_side: u64, other_amount_min: Option<u64>) writeWithdraw(amount: u64, min_coin_amount: Option<u64>, min_pc_amount: Option<u64>) writeInitialize2(nonce: u8, open_time: u64, init_pc_amount: u64, init_coin_amount: u64) writeSetParams(param: u8, value: Option<u64>, fees: Option<Fees>) +2 more via get_protocol |
APIs
| Raydium API V3: main info auth: none | https://api-v3.raydium.io/main/info GET main statistics for the Raydium venues. |
| Raydium API V3: pools by id auth: none | https://api-v3.raydium.io/pools/info/ids GET pool info (mints, vaults, LP mint, fees, price, TVL) for one or more pool ids. Cached about 60 seconds. Use it to resolve the pool before building a swap or liquidity transaction. |
| Raydium API V3: pools by mint auth: none | https://api-v3.raydium.io/pools/info/mint GET pools that contain a mint, or a mint pair. pageSize is capped at 1000. Use it to find the pool for a token pair. |
| Raydium API V3: list pools (cursor paging) auth: none | https://api-v3.raydium.io/pools/info/list-v2 GET a paged list of pools with nextPageId cursor. size is capped at 1000. |
| Raydium API V3: token prices auth: none | https://api-v3.raydium.io/mint/price GET the price for one or more mints. |
Notes
Mainnet program id 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 is listed on the official raydium-amm README under Program Deployments (devnet id DRaya7Kj3aMWQSy19kSjvmuwq9docCHofyP9kanQGaav is left out). Instruction names come from the AmmInstruction enum in program/src/instruction.rs of the official repository. Individual pool, market and authority addresses are not included; get them from the API. Raydium's Swap transaction API and other products are not covered here.
Sources
- https://api.llama.fi/protocol/raydium-amm
- https://github.com/raydium-io/raydium-amm
- https://raw.githubusercontent.com/raydium-io/raydium-amm/master/program/src/lib.rs
- https://raw.githubusercontent.com/raydium-io/raydium-amm/master/program/src/instruction.rs
- https://docs.raydium.io/api-reference/api-v3/overview
- https://docs.raydium.io
- https://api.mainnet-beta.solana.com
Researched 2026-11-28. Addresses are copied from the official sources above; check them before moving large amounts.