Back to Integration
SDK API Reference

TypeScript SDK Reference

Comprehensive method signatures, parameter interfaces, and architectural patterns for PumpSuiFactorySDK built on top of @mysten/sui.

Package Installation

npm install @pumpsui/token-creator-sdk @mysten/suiNPM / Bun / PNPM

End-to-End Implementation Sample

sdk-quickstart.ts
TypeScript
import { PumpSuiFactorySDK, parseSUI } from '@pumpsui/token-creator-sdk';
import { SuiClient } from '@mysten/sui/client';

// 1. Initialize SuiClient and PumpSuiFactorySDK
const client = new SuiClient({ url: 'https://fullnode.mainnet.sui.io:443' });
const sdk = new PumpSuiFactorySDK(client, 'MAINNET');

// 2. Build Create Pool PTB
const txb = await sdk.createPoolTransaction({
  tokenAType: '0x2::sui::SUI',
  tokenBType: '0x3568478d...::my_token::MY_TOKEN',
  tokenAAmount: parseSUI(100),          // 100 SUI seed liquidity
  tokenBAmount: 1_000_000_000_000n,      // 1,000,000 tokens
  senderAddress: '0xYourWalletAddress',
});

// 3. Query on-chain pool reserves
const poolInfo = await sdk.getPoolInfo('0xPoolSharedObjectId');
console.log('Reserves:', poolInfo.reserveA, poolInfo.reserveB);

// 4. Calculate exact swap output (x*y=k formula with 0.3% fee)
const tokenOut = sdk.calculateSwapOutput(
  parseSUI(10), // 10 SUI in
  poolInfo.reserveA,
  poolInfo.reserveB
);
console.log('Estimated Output:', tokenOut);

PumpSuiFactorySDK Core Methods

createPoolTransaction(params: CreatePoolParams)Promise<Transaction>

Assembles a Programmable Transaction Block (PTB) initializing a new AMM pair with seed liquidity and paying the 0.8 SUI protocol creation fee.

Parameters
tokenAType(string)Canonical Move type identifier of Coin A
tokenBType(string)Canonical Move type identifier of Coin B
tokenAAmount(bigint)Raw integer amount in smallest token unit (MIST)
tokenBAmount(bigint)Raw integer amount for Coin B
senderAddress(string)Sui address that will receive the minted LP tokens
addLiquidityTransaction(params: AddLiquidityParams)Promise<Transaction>

Generates a PTB depositing dual assets into an existing pool and minting proportional LP<A, B> certificates. Zero protocol fees.

Parameters
poolId(string)Target pool shared object ID
tokenAAmount(bigint)Desired deposit amount for Coin A
tokenBAmountMax(bigint)Maximum Coin B to match current pool ratio
senderAddress(string)LP token recipient
removeLiquidityTransaction(params: RemoveLiquidityParams)Promise<Transaction>

Generates a PTB burning an LP coin object and returning the underlying Token A and Token B reserves directly to the owner.

Parameters
poolId(string)Pool shared object ID
lpCoinId(string)LP token coin object ID to burn
amount(bigint)Quantity of LP tokens to burn
senderAddress(string)Recipient of extracted token reserves
getPoolInfo(poolId: string)Promise<PoolInfo>

Fetches real-time on-chain reserves, LP total supply, fee configurations, and cumulative trading volume.

Parameters
poolId(string)Sui Object ID of the target shared liquidity pool
calculateSwapOutput(amountIn, reserveIn, reserveOut)bigint

Pure mathematical helper estimating output tokens received given input amount and current pool reserves using standard constant-product AMM mechanics (0.3% fee deduction).

Parameters
amountIn(bigint)Input token amount in raw integer units
reserveIn(bigint)Pool reserve for input token
reserveOut(bigint)Pool reserve for output token

Mathematical & Sui PTB Utilities

sortTokenTypes(typeA, typeB)

Returns canonical [tokenA, tokenB] ordered alphabetically for Sui Move constraints.

parseSUI(amount: number | string)

Converts whole SUI value into exact 9-decimal MIST bigint (e.g. 1.5 -> 1500000000n).

formatSUI(mist: bigint)

Converts raw MIST bigint into human-readable formatted SUI string with localized decimal points.

splitCoinsForFee(txb, amount)

Helper that extracts required protocol fees from the gas coin in a single atomic instruction.