DumpsterDumpster Docs
SDK

Bonding Curve

Launch tokens, trade the curve, migrate completed curves, and collect creator fees.

SDK

Curve-side workflows

The curve side of the SDK covers token creation, launch-and-buy flows, curve buys and sells, creator fee collection, and migration into DumpsterSwap.

import { DumpsterClient } from '@dumpster-cash/dumpster-sdk';

const client = new DumpsterClient(connection);

Create a token

Build the create-only instruction; a first buy is optional. Building an instruction does not validate the stored launch configuration. The program applies the launch checks when the transaction executes.

import { Keypair } from '@solana/web3.js';

const mint = Keypair.generate();

const ix = await client.curve.buildCreate({
  mint: mint.publicKey,
  name: 'Dumpster',
  symbol: 'DUMP',
  uri: 'https://example.com/metadata.json',
  creator: wallet.publicKey,
  user: wallet.publicKey,
});

The mint keypair still needs to sign when you send the transaction.

Launch and buy in one transaction

Preview from a paired configuration read and the intended creator, then build both instructions from that snapshot.

import { Keypair } from '@solana/web3.js';
import BN from 'bn.js';
import { newBondingCurve } from '@dumpster-cash/dumpster-sdk';

const mint = Keypair.generate();
const { global, feeConfig } = await client.accounts.fetchCurveConfig();
const preview = client.preview.curveBuy({
  feeConfig,
  bondingCurve: newBondingCurve(global, wallet.publicKey),
  amountInGor: new BN(1_000_000_000),
});
if (preview.amountOutTokens.isZero()) throw new Error('Budget buys no tokens');

const instructions = await client.curve.buildCreateAndBuy({
  global,
  mint: mint.publicKey,
  name: 'Dumpster',
  symbol: 'DUMP',
  uri: 'https://example.com/metadata.json',
  creator: wallet.publicKey,
  user: wallet.publicKey,
  amount: preview.amountOutTokens,
  gorAmount: preview.amountInGor,
  slippage: 1,
});

This returns the launch instruction, the user's ATA creation if needed, and the first buy.

The unsigned instructions do not guarantee execution success. If a requested initial buy cannot produce tokens, show an error instead of launching without that buy. The combined flow uses the same on-chain creation checks as create-only.

Buy on the curve

The explicit path is best when you want one fetched state bundle for both previewing and instruction building.

Buy, sell and combined launch/buy builders use curve fee selection. Missing active recipients cause a setup error; a decoded account or successful price preview is not enough.

import BN from 'bn.js';

const gorAmount = new BN(1_000_000_000);
const state = await client.accounts.fetchCurveTradeState(mint, wallet.publicKey);

const preview = client.preview.curveBuy({
  feeConfig: state.feeConfig,
  bondingCurve: state.bondingCurve,
  amountInGor: gorAmount,
});

if (preview.amountOutTokens.isZero()) throw new Error('Budget buys no tokens');

const instructions = await client.curve.buildBuyExactOut({
  global: state.global,
  bondingCurve: state.bondingCurve,
  associatedUserAccountInfo: state.associatedUserAccountInfo ?? null,
  mint,
  user: wallet.publicKey,
  amount: preview.amountOutTokens,
  gorAmount: preview.amountInGor,
  slippage: 1,
});

If you want the shorter convenience path:

const instructions = await client.curve.buildBuyExactOutAutoResolve({
  connection,
  mint,
  user: wallet.publicKey,
  amount: preview.amountOutTokens,
  gorAmount: preview.amountInGor,
  slippage: 1,
});

Use actual quoted spend for either builder, not the budget entered before inventory/rounding. Percentage slippage can allow spending above that quote; network fees and account deposits are separate.

Sell on the curve

Preview first, then feed the output bounds into the builder.

import BN from 'bn.js';

const amountInTokens = new BN(25_000_000_000);
const state = await client.accounts.fetchCurveTradeState(mint);

const preview = client.preview.curveSell({
  feeConfig: state.feeConfig,
  bondingCurve: state.bondingCurve,
  amountInTokens,
});

const instructions = await client.curve.buildSellExactIn({
  global: state.global,
  bondingCurve: state.bondingCurve,
  mint,
  user: wallet.publicKey,
  amount: amountInTokens,
  gorAmount: preview.amountOutGorNet,
  slippage: 1,
});

Migrate a completed curve

Anyone can trigger migration when it is enabled and a completed, unsettled curve passes the program's checks. Use migration state to distinguish settlement without a pool from an established migration. Completion alone does not guarantee readiness.

Migration requires the primary global.feeRecipient, not the optional-first trading selection. Since SDK 2.0.1, buildMigrateAutoResolve supplies that primary recipient. On SDK 2.0.0, use buildMigrate with the primary recipient explicitly when optional recipients differ. Recipient selection alone does not establish the other migration requirements.

const { instruction, swapCreatorLpKeypair } = await client.curve.buildMigrateAutoResolve({
  connection,
  mint,
  user: wallet.publicKey,
});

The migration flow returns an extra LP-account keypair. That keypair must sign alongside the user.

Collect creator fees

Curve-side creator fees are collected with:

const ix = await client.curve.buildClaimCreatorFees({
  creator: wallet.publicKey,
});

After migration, creator-fee collection moves to the AMM-side path.

On this page