Skip to main content
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
Pin the SDK version in your package.json. The bonding-curve interface has evolved between minor releases.

Setup

Demos here mirror files in raydium-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)
Notes:
  • initialK is the scale factor for the quadratic curve. Tune it to target a specific opening CPMM price at graduation. See products/launchlab/bonding-curve for 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 until openTime. Set openTime a 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

Useful for “buy exactly X tokens” UIs. Rejects with ExceededSlippage if the curve has moved enough that the quote requirement now exceeds maximumQuoteIn.

Sell

Source: src/launchpad/sell.ts
The curve’s sell path is symmetric to the buy path: reducing 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 a Graduate instruction inside the buy* transaction when it detects the post-buy state will cross the threshold:
Because 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:
Reverts with 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)
Transfers the accrued creator-fee-counter quote amount to the creator’s ATA on the quote mint. Callable pre- or post-graduation; use it periodically rather than waiting for a huge balance to accumulate.

Track a launch through its lifecycle

Putting it together, a monitoring script might look like:

Watch configs and pools over gRPC

Source: src/grpc/launchpadPoolInfo.ts Subscribes to the LaunchLab program over Yellowstone gRPC and logs every GlobalConfig and PoolState update with each mint’s token program. Two datasize filters on one accounts subscription separate the two account types, so a single stream covers both. The demo is the shortest correct reference for classifying a launch’s mints, which the Token-2022 quote-mint release makes necessary:
  • Pools are classified straight from PoolState.token_program_flag, decoding bit0 for the base mint and bit1 for the quote mint with no mint fetch at all. Testing the whole byte against 0 — which was sufficient while quote mints were legacy-only — misreads a legacy base mint as Token-2022 whenever the quote mint is Token-2022.
  • Configs cannot be classified that way: a GlobalConfig stores its quote mint’s address and no program flag, so the demo reads the mint account’s owner once and caches it per mint.
It also cross-checks the two against each other, which is a useful assertion to keep in your own indexer. Note that create versus update is inferred from the demo’s own caches, seeded at startup from getProgramAccounts; with that seeding disabled, read “create” as “first seen on this stream”. gRPC access is not part of the public RPC surface — see the demo repo’s src/grpc/README.md.

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 crate raydium_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_share is not exactly lp_share + creator_share + protocol_share, Initialize reverts with InvalidFeeShares. Set totalShare equal to the sum.
  • Using a non-allowed quote mint. launch_config.allowed_quote_mints is a fixed list; passing any other mint reverts. Check with raydium.launchpad.getConfig() first.
  • Metadata size. Long uri strings push the Metaplex CPI over the budget. Keep uri under ~200 chars — most CDN-hosted JSON metadata fits easily.
  • Graduation race. Automated bots monitor quote_reserve_real and front-run Graduate within a slot or two of the threshold crossing. This is benign — it only costs them rent — but it means your UI should treat status transitions as fast events.

Where to go next

Sources: