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
This is the plain launch flow.
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
This is the combined launch-and-buy flow.
import { Keypair } from '@solana/web3.js';
import BN from 'bn.js';
const mint = Keypair.generate();
const instructions = await client.curve.buildCreateAndBuyAutoResolve({
connection,
mint: mint.publicKey,
name: 'Dumpster',
symbol: 'DUMP',
uri: 'https://example.com/metadata.json',
creator: wallet.publicKey,
user: wallet.publicKey,
amount: new BN(50_000_000_000),
gorAmount: new BN(1_000_000_000),
slippage: 1,
});This returns the launch instruction, the user's ATA creation if needed, and the first buy.
Buy on the curve
The explicit path is best when you want one fetched state bundle for both previewing and instruction building.
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,
});
const instructions = await client.curve.buildBuyExactOut({
global: state.global,
bondingCurve: state.bondingCurve,
associatedUserAccountInfo: state.associatedUserAccountInfo ?? null,
mint,
user: wallet.publicKey,
amount: preview.amountOutTokens,
gorAmount,
slippage: 1,
});If you want the shorter convenience path:
const instructions = await client.curve.buildBuyExactOutAutoResolve({
connection,
mint,
user: wallet.publicKey,
amount: preview.amountOutTokens,
gorAmount,
slippage: 1,
});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.fetchMigrationState(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
Once the curve is complete and migration is enabled, anyone can trigger the move into DumpsterSwap.
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.