SDK
Quick Start
Fetch live state, preview a buy, build the instructions, and assemble an unsigned transaction.
SDK
From connection to first buy
The shortest useful workflow is: load the curve state, preview the trade, build the instruction array, then assemble the unsigned transaction you want the wallet to sign.
import { DumpsterClient } from '@dumpster-cash/dumpster-sdk';
import { Connection, PublicKey } from '@solana/web3.js';
import BN from 'bn.js';
const connection = new Connection('https://rpc.gorbagana.com');
const client = new DumpsterClient(connection);
const mint = new PublicKey('...');
const user = new PublicKey('...');
const gorAmount = new BN(1_000_000_000);
const state = await client.accounts.fetchCurveTradeState(mint, user);
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,
amount: preview.amountOutTokens,
gorAmount,
slippage: 1,
});
const tx = await client.tx.buildTransaction(instructions, {
feePayer: user,
computeUnits: 300_000,
});What this does
- loads the global config, fee config, curve account, and user ATA state in one call
- previews the buy with the same fee schedule and reserves the builder will use
- builds the instruction array for a curve buy
- assembles an unsigned transaction with a compute budget
Convenience path
If you do not want to wire the state bundle yourself, use the AutoResolve builder:
const instructions = await client.curve.buildBuyExactOutAutoResolve({
connection,
mint,
user,
amount: preview.amountOutTokens,
gorAmount,
slippage: 1,
});The explicit path is better when you are already holding fresh state in memory. The AutoResolve path is better for short scripts and simpler integrations.