Version banner.
- SDK:
@raydium-io/raydium-sdk-v2@0.2.42-alpha - Cluster: Solana
mainnet-beta - Program ID: see
reference/program-addresses - Last verified: 2026-04
package.json. The bonding-curve interface has evolved between minor releases.Setup
Demos here mirror files inraydium-sdk-V2-demo/src/launchpad. Bootstrap follows the demo repo’s config.ts.template:
Create a launch
Source:src/launchpad/createMint.ts (and createBonkMintApi.ts for the API-driven Bonk variant)
initialKis the scale factor for the quadratic curve. Tune it to target a specific opening CPMM price at graduation. Seeproducts/launchlab/bonding-curvefor the derivation.- The SDK handles creating the base mint, the metadata PDA, and both vaults in a single transaction. It may exceed 1232 bytes if the metadata URI is long; in that case the SDK splits into two transactions.
- After
Initialize, the launch is not tradable untilopenTime. SetopenTimea minute or two ahead to give front-runners less chance to grab the first buy.
Fetch launch state
getLaunchById returns the decoded LaunchState plus the computed “progress toward graduation” fraction as a Decimal.
Buy — exact quote in
Source:src/launchpad/buy.ts
computeBuyBase mirrors the on-chain Newton solver (quadratic curve) or the closed-form CPMM-inverse (curve_type 1). Use it to populate the “You receive” UI field.
Buy — exact base out
ExceededSlippage if the curve has moved enough that the quote requirement now exceeds maximumQuoteIn.
Sell
Source:src/launchpad/sell.ts
base_sold by baseIn returns quote_out equal to the integrated area under the curve between base_sold − baseIn and base_sold, minus the sell fee.
Auto-graduate on the threshold-crossing buy
The SDK chains aGraduate instruction inside the buy* transaction when it detects the post-buy state will cross the threshold:
Graduate is permissionless, anyone (including an MEV bot) can race to land the first Graduate after the threshold is crossed — typically seconds later, not minutes. The first-lander just pays the rent for the CPMM pool accounts; they get no other benefit.
Manual Graduate
If autoGraduate was off or the threshold-crossing transaction failed, you can fire the graduation separately:
NotAtThreshold if quote_reserve_real < quote_reserve_target at submission time. Retry-safe — a second Graduate attempt after success reverts with NotActive.
Collect creator fees
Source:src/launchpad/claimCreatorFee.ts (single mint) and collectAllCreatorFees.ts (batched)
Track a launch through its lifecycle
Putting it together, a monitoring script might look like:Rust CPI
Calling LaunchLab from your own Anchor program is rare (most launch integrations are TS-side only). If you do, the program ships an Anchor crateraydium_launchlab with cpi::accounts::Buy, cpi::accounts::Sell, etc. — pattern mirrors the CPMM / CLMM CPI examples. See sdk-api/rust-cpi for a generalized template once this site is populated.
Pitfalls
- Fee-split arithmetic off-by-one. If
total_shareis not exactlylp_share + creator_share + protocol_share,Initializereverts withInvalidFeeShares. SettotalShareequal to the sum. - Using a non-allowed quote mint.
launch_config.allowed_quote_mintsis a fixed list; passing any other mint reverts. Check withraydium.launchpad.getConfig()first. - Metadata size. Long
uristrings push the Metaplex CPI over the budget. Keepuriunder ~200 chars — most CDN-hosted JSON metadata fits easily. - Graduation race. Automated bots monitor
quote_reserve_realand front-runGraduatewithin a slot or two of the threshold crossing. This is benign — it only costs them rent — but it means your UI should treatstatustransitions as fast events.
Where to go next
products/launchlab/bonding-curve— curve math.products/cpmm/code-demos— what to do with the resulting pool.user-flows/launch-token-launchlab— the end-to-end launch-a-token guide, including off-chain steps.
- Raydium SDK v2
- Raydium LaunchLab program source

