LaunchLab TypeScript SDK
TypeScript SDK for interacting with LaunchLab bonding curves.
Getting started
This SDK offers tools and functions for interacting with LaunchLab bonding curves. It allows developers to effortlessly build platform config and bonding curves with custom settings and fee structures. SDK: https://github.com/raydium-io/raydium-sdk-V2/tree/master/src/raydium/launchpad Demo implementation: https://github.com/raydium-io/raydium-sdk-V2-demo/tree/master/src/launchpad CPI is also available: https://github.com/raydium-io/raydium-cpi/tree/master/programs/launch-cpi Mainnet program: LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj Devnet program: DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6
Installation
$ yarn add @raydium-io/raydium-sdk-v2
Initialization
import {
TxVersion,
DEV_LAUNCHPAD_PROGRAM,
printSimulate,
getPdaLaunchpadPoolId,
Curve,
PlatformConfig,
LAUNCHPAD_PROGRAM,
} from '@raydium-io/raydium-sdk-v2'
import { initSdk } from '../config'
import BN from 'bn.js'
import { PublicKey } from '@solana/web3.js'
import { NATIVE_MINT } from '@solana/spl-token'
import Decimal from 'decimal.js'
Walkthrough
App developers can create a platform config -eg. createPlatform.ts. -that allows them to define their fees on the bonding curves
feeRate
and set the distribution for revenue sharing post migration to a CP-Swap PoolmigrateCpLockNftScale
between the platformplatformScale
, the creatorcreatorScale
, and fees compounded in the poolburnScale
. Both the feeRate and platformScale parameters are expressed in bps * 100. You can also set a fee for creators using your platform withcreatorFeeRate.
NB: platformConfigs can only get updated once per epoch using the function updatePlatformConfig.Users can create tokens and a bonding curve using the function createLaunchpad - eg. createMint.ts -. Users can freely set token parameters and metadata, the supply, amount sold, and quote raised.
Users can buy and sell using the dedicated functions. The shareFeeRate, shareFeeReceiver third-party trade fees.
Once the threshold of
total_quote_fund_raising
is attained, its status changes to 1 (migrate), trading stops on the bonding curve, and the pool migrates to an AMM pool, or CP-swap pool, depending on its migrate type.
Platform parameters
These parameters are set once by the platform with createPlatormConfig, and can be updated once per epoch.
platformAdmin
,platformClaimFeeWallet
,platformLockNftWallet
, default to signer if not set.cpConfigId
determines the fee tier for the pool post bonding curves if migrating to a 'cpmm' pool. Config Ids for mainnet are available here: https://api-v3.raydium.io/main/cpmm-config The config Id for devnet isEsTevfacYXpuho5VBuzBjDZi8dtWidGnXoSYAr8krTvz
transferFeeExtensionAuth
public key receiving transferFee authorities (modify and claim) post graduation for launch using initializeWithToken2022.
creatorFeeRate
is the fee going to the token creator in bps *100. Example: 0.05% = 500. Max is 5,000.migrateCpLockNftScale
the distribution of the revenue sharing between creators, platform, and compounded in the pool in bps * 100, defined inplatformConfig
feeRate
fees charged by the platform on the bonding curves in bps * 100name
,web
,img
: your platform metadata readable on-chain
Token launch parameters
Parameters set per launch by the token deployers using initializeV2 or initializeWithToken2022 (to leverage transfer fees)
platformID
, pubkey from an existing platform.migrateType
==='amm'
or'cpmm'
determines if the bonding curves migrate to the AMMv4 or the Cpmm program. Only the Cpmm program allows for revenue sharing post-migration.supply
total amount of tokens minted, min = 10000000.totalSellA
total amount of tokens sold on the bonding curves, min = 20%.totalLockedAmount
total amount of token vesting, max = 30%. The amount of tokens provided on the pool at migration can be deduced from the two previous parameters; it needs to be ≥ 20% of the supply.decimals
number of decimals for the tokenA (base asset).cliffPeriod
is the number of seconds after migration before vesting starts.unlockPeriod
is the number of seconds for which locked tokens will be vesting. - NB:startTime
cannot be passed by users, the start time will be the migration block_stamp.totalFundRaisingB
is the total amount of quote tokens to raise on the bonding curve.amountB
(buyAmount)amount of tokenB spent alongside the curve initialization to buy tokenA.creatorFeeOn
, fees collected after graduation by the token deployer default to only token B.
Enforcing mint parameters set by platforms
Raydium Launchlab allows platforms to enforce mint parameters. If the initializeV2
instruction called by a deployer doesn't match platformCurveParamInstruction
, it will throw an error.
Configurable parameters include:
migrateType
,migrateCpmmFeeOn
,supply
,totalSellA
,totalFundRaisingB
,totalLockedAmount
,cliffPeriod
, andunlockPeriod
.You can update and remove launch configuration using these IXs https://github.com/raydium-io/raydium-sdk-V2/blob/874c80fd9cd367b5cb3b03151e5292fb65a13a74/src/raydium/launchpad/instrument.ts#L992
Setting params to null values disables checks for those fields. Unconfigured parameters are skipped at validation. eg. index1: supply = 10B and totalFundRaisingB = 85 SOL | index2: supply = 10B and totalFundRaisingB = 84 SOL | index3: supply = 20B and totalFundRaisingB = 85 SOL | index4: supply = 20B and totalFundRaisingB = null token creator input -> supply = 20B and totalFundRaisingB = 85sol ✅ index3 token creator -> supply = 20B and totalFundRaisingB = 90sol ✅ index4 token creator -> supply = 10B and totalFundRaisingB = 90sol ❌
You can save up to 25 parameter sets per configId (index can range from 0 to 254, Raydium doesn't enforce restriction). Parameter sets can be updated once per epoch. Please test thoroughly on devnet first.
Claiming Fees and vested tokens
Platform fees can be claimed by the platform owner using the ClaimPlatformFee function - demo. The function collects all pending fees from the bonding curves.
Creators/token deployers can claim all their fees using the claimCreatorFee ix - demo
Fees post-migration can be claimed by the creator and the platform using the cpmm function haverstLockLiquidity - demo. Either party receives a dedicated NFT representing their share of the trading fees for the locked principal and can claim independently of the other. Post-migration the additional creator fees for creators post-migration are claimed using Collect creator fees - demo
To enable vesting, the token creator must create vesting accounts for any number of accounts using the createVesting function - demo.
Recipients of vested tokens can claim their vested tokens at any time after the cliff using the claimVesting demo.
Last updated
Was this helpful?