@pumpsui/factory-sdk
v1.2.0
Published
Official TypeScript SDK for creating, providing liquidity, and swapping on PumpSui AMM pools on the Sui Blockchain
Maintainers
Readme
@pumpsui/factory-sdk
Official TypeScript SDK for programmatic AMM liquidity pool creation, liquidity management, token swapping, and on-chain state querying on PumpSui (Sui Blockchain).
📦 Installation
npm install @pumpsui/factory-sdk @mysten/sui
# or
pnpm add @pumpsui/factory-sdk @mysten/sui
# or
yarn add @pumpsui/factory-sdk @mysten/sui⚡ Quick Start
import { SuiClient } from '@mysten/sui/client';
import { PumpSuiFactorySDK, parseSUI } from '@pumpsui/factory-sdk';
// 1. Initialize client and SDK
const client = new SuiClient({ url: 'https://fullnode.mainnet.sui.io:443' });
const sdk = new PumpSuiFactorySDK(client, 'MAINNET');
// 2. Build Create Pool PTB (Atomically splits SUI from gas & handles canonical Move sorting)
const createPoolTx = sdk.createPoolTransaction({
tokenAType: '0x2::sui::SUI',
tokenBType: '0xYOUR_TOKEN_PACKAGE::my_coin::MY_COIN',
tokenAAmount: parseSUI(100), // 100 SUI seed liquidity
tokenBAmount: 1_000_000_000_000n, // 1M tokens
senderAddress: '0xYourWalletAddress',
coinB: '0xCoinObjectIdForTokenB', // Or array of coin IDs to merge
});
// 3. Query on-chain pool info
const poolInfo = await sdk.getPoolInfo('0xPoolSharedObjectId');
console.log('Reserves:', poolInfo.reserveA, poolInfo.reserveB);
// 4. Calculate exact swap output (x * y = k formula with 1.5% fee)
const output = sdk.calculateSwapOutput(
parseSUI(10), // 10 SUI in
poolInfo.reserveA,
poolInfo.reserveB
);
console.log('Estimated Output:', output);🛠️ API Reference
PumpSuiFactorySDK
Constructor
constructor(client: SuiClient, options?: SDKConfigOptions | 'MAINNET' | 'TESTNET')PTB Generator Methods
| Method | Parameters | Return | Description |
| :--- | :--- | :--- | :--- |
| createPoolTransaction | PoolCreationParams | Transaction | Initializes new AMM pair with initial liquidity and protocol fee. |
| addLiquidityTransaction | AddLiquidityParams | Transaction | Deposits dual assets into existing pool, minting proportional LP tokens. Free protocol fees. |
| removeLiquidityTransaction | RemoveLiquidityParams | Transaction | Burns LP tokens and returns underlying reserves to caller. |
| burnLiquidityLockTransaction| BurnLiquidityLockParams | Transaction | Irrevocably burns/locks LP tokens into the pool for permanent rug-proof liquidity. |
| swapTransaction | SwapParams | Transaction | Swaps tokens with slippage protection (minAmountOut), deadline, and optional referral rewards. |
On-Chain Query Methods
| Method | Parameters | Return | Description |
| :--- | :--- | :--- | :--- |
| getPoolInfo | poolId: string | Promise<PoolInfo \| null> | Fetches reserves, LP supply, locked LP, fees, and volume metrics. |
| getPoolByPair | tokenA: string, tokenB: string | Promise<string \| null> | Resolves the shared pool object ID for a given token pair. |
🧮 Mathematical Engine & Utilities
import {
calculateSwapOutput,
quoteOptimalLiquidity,
estimateLPMinted,
calculatePriceImpact,
sortTokenTypes,
parseSUI,
formatSUI
} from '@pumpsui/factory-sdk';
// Calculate output after 1.5% fee
const tokenOut = calculateSwapOutput(amountIn, reserveIn, reserveOut);
// Calculate optimal token B for balanced deposit
const optimalB = quoteOptimalLiquidity(amountA, reserveA, reserveB);
// Sort canonical Move token pair
const [sortedA, sortedB] = sortTokenTypes(tokenA, tokenB);
// Convert units
const mist = parseSUI(2.5); // 2500000000n
const display = formatSUI(mist); // "2.50"🌐 On-Chain Configuration
Sui Mainnet (Verified V3)
- Package ID:
0xd7aabe644acc2ef74377f7a0113189691dc7d031074bd4ec01af1023dc4c0686 - Factory Object (Shared):
0xd8e9d4dfae7b2caa0c03b029772c74c3a9a9822d81b8ca773bbac063ec328b4e - Clock Object:
0x6 - Fee Collector:
0x97d85ec54cc44892e8d0a34204ee080c60db55d2b9997e460b9c223791983b79
📖 Complete Documentation
Official developer portal and interactive guides:
📄 License
MIT © PumpSui
