Buying / selling a token

Buy and sell tokens on LaunchLab bonding curves


Once a token is launched, users can buy and sell on the bonding curve until the fundraising goal is reached. This section covers how to integrate trading functionality.

How bonding curve trading works

LaunchLab uses bonding curves to determine token prices based on supply and demand:

  • Buying increases the price — each purchase moves the price up along the curve

  • Selling decreases the price — each sale moves the price down along the curve

  • Price discovery — early buyers get lower prices, creating incentive for early participation

Trading continues until totalFundRaisingB worth of quote tokens have been collected, at which point the pool migrates to a Raydium AMM.

Buying tokens

Use buyToken() to purchase tokens with quote tokens (e.g., SOL).

  import { TxVersion } from '@raydium-io/raydium-sdk-v2'
  import { initSdk } from './config'
  import { PublicKey } from '@solana/web3.js'
  import BN from 'bn.js'

  const buyTokens = async () => {
    const raydium = await initSdk()

    const { execute, extInfo } = await raydium.launchpad.buyToken({
      mintA: new PublicKey('token-mint-address'),
      buyAmount: new BN(1_000_000_000),  // 1 SOL in lamports
      slippage: new BN(100),             // 1% slippage
      txVersion: TxVersion.V0,
    })

    console.log('Expected tokens:', extInfo.decimalOutAmount.toString())

    const { txId } = await execute({ sendAndConfirm: true })
    console.log('Transaction:', txId)
  }

Buy parameters

Parameter
Type
Required
Description

mintA

PublicKey

Yes

The token mint to buy.

mintAProgram

PublicKey

No

Token program (SPL or Token-2022). SDK detects if omitted.

buyAmount

BN

Yes

Amount of quote tokens to spend (e.g., lamports for SOL).

poolInfo

object

No

Pool state data. SDK fetches if omitted.

configInfo

object

No

Global config data. SDK fetches if omitted.

platformFeeRate

BN

No

Platform's fee rate. SDK fetches if omitted.

slippage

BN

No

Maximum slippage in bps (100 = 1%). Default: 100.

minMintAAmount

BN

No

Minimum tokens to receive. SDK calculates if omitted.

Buying exact token amount

Use buyTokenExactOut() to specify exactly how many tokens you want to receive.

Selling tokens

Use sellToken() to sell tokens back for quote tokens.

Sell parameters

Parameter
Type
Required
Description

mintA

PublicKey

Yes

The token mint to sell.

sellAmount

BN

Yes

Amount of tokens to sell.

poolInfo

object

No

Pool state data. SDK fetches if omitted.

slippage

BN

No

Maximum slippage in bps (100 = 1%). Default: 100.

minAmountB

BN

No

Minimum quote tokens to receive. SDK calculates if omitted.

Selling for exact quote amount

Use sellTokenExactOut() to specify exactly how many quote tokens you want to receive.

Advanced: Calculating quotes

Use the Curve utility to calculate expected outputs before executing trades (e.g. displaying expected amounts in the UI).

Available quote methods

Method
Description

Curve.buyExactIn()

Calculate tokens received for a given quote token input

Curve.buyExactOut()

Calculate quote tokens needed for a specific token output

Curve.sellExactIn()

Calculate quote tokens received for a given token input

Curve.sellExactOut()

Calculate tokens needed to receive a specific quote token output

Referral fees

Integrators can earn referral fees by passing shareFeeRate and shareFeeReceiver parameters.

circle-info

shareFeeRate cannot exceed maxShareFeeRate from the global config. Referral fees are paid in the quote token (e.g., SOL) and transferred directly to the shareFeeReceiver wallet.

Checking pool status

Before trading, verify the pool is still in trading status:

Last updated

Was this helpful?