Welcome to BONKswap AMM Integration
Welcome to the BONKswap AMM Integration SDK! This comprehensive TypeScript SDK provides everything you need to integrate with BONKswap's Automated Market Maker (AMM) protocol on Solana.
What is BONKswap AMM?
BONKswap AMM is a decentralized automated market maker built on Solana that enables efficient token swaps with minimal price impact and competitive fees. The protocol supports:
- Liquidity Pools: Automated market making for token pairs
- Fee Structure: LP fees, buyback fees, project fees, and referrer fees
- Price Impact Protection: Built-in mechanisms to minimize price impact
- Permissionless Trading: Anyone can swap tokens without intermediaries
SDK Features
The BONKswap AMM Integration SDK provides:
🔍 Quote Generation
- Get accurate swap quotes with fee calculations
- Price impact analysis
- Liquidity checks
- Support for both exact input and exact output swaps
🔄 Swap Execution
- Generate transaction instructions for swaps
- Complete transaction building and signing
- Support for all BONKswap pools
- Automatic account derivation
📊 Pool Analytics
- Real-time pool state monitoring
- Reserve analysis
- Fee structure breakdown
- Price calculations
🛠 Developer Tools
- TypeScript-first design
- Comprehensive error handling
- Production-ready integration patterns
Quick Start
The BONKswap AMM Integration SDK is available as a GitHub repository. To use it in your project:
Option 1: Clone the Repository
# Clone the SDK repository
git clone git@github.com:BonkLabs/bonkswap-amm-integration.git
# Or use HTTPS
git clone https://github.com/BonkLabs/bonkswap-amm-integration.git
Option 2: Copy the SDK files
# Copy the SDK files to your project
cp -r bonkswap-amm-integration/amm.ts your-project/src/
cp -r bonkswap-amm-integration/idl/ your-project/src/
Option 3: Use as a local dependency
# In your project's package.json, add:
{
"dependencies": {
"bonkswap-amm-integration": "file:../bonkswap-amm-integration"
}
}
Option 4: Direct import (if in same workspace)
import { Connection, PublicKey } from "@solana/web3.js";
import { BN } from "@coral-xyz/anchor";
import BONKSwapAMM, { QuoteParams } from "./bonkswap-amm-integration/amm";
// Initialize connection
const connection = new Connection("https://api.mainnet-beta.solana.com");
// Get pool account info
const poolAddress = new PublicKey("GBmzQL7BTKwSV9Qg7h5iXQad1q61xwMSzMpdbBkCyo2p");
const accountInfo = await connection.getAccountInfo(poolAddress);
// Initialize AMM
const amm = new BONKSwapAMM(poolAddress, accountInfo);
// Get quote
const quoteParams: QuoteParams = {
sourceMint: amm.pool.tokenX,
destinationMint: amm.pool.tokenY,
amount: new BN(1000 * 1e5), // 1000 BONK tokens
swapMode: "ExactIn"
};
const quote = amm.getQuote(quoteParams);
console.log("Output amount:", quote.outAmount.toString());
console.log("Fee amount:", quote.feeAmount.toString());
console.log("Price impact:", quote.priceImpactPct + "%");
Supported Token Pairs
The SDK supports all BONKswap pools, including:
- BONK/SOL - Main trading pair
- BONK/USDC - Stablecoin pair
- SOL/USDC - Major Solana pair
- Custom Pools - Any pool created on BONKswap
Key Concepts
Pool State
- Reserves: Current token amounts in the pool
- Price: Current exchange rate between tokens
- Fees: LP, buyback, project, and referrer fees
- Liquidity: Total liquidity available for trading
Quote System
- Exact Input: Specify input amount, get output amount
- Exact Output: Specify output amount, get input amount
- Price Impact: How much your trade affects the price
- Fee Calculation: Automatic fee computation
Swap Execution
- Transaction Building: Generate Solana transaction instructions
- Account Derivation: Automatic account address calculation
- Error Handling: Comprehensive error checking and validation
- Gas Optimization: Efficient transaction construction
Next Steps
Ready to integrate? Start with the Getting Started guide to set up your development environment and make your first swap!