kinetic-sdk
v2.1.0
Published
Kinetic SDK for Solana protocols
Readme
kinetic-sdk - Core SDK
The core Kinetic SDK for interacting with Solana DeFi protocols.
Overview
This package provides comprehensive TypeScript/JavaScript APIs for interacting with Kinetic's suite of DeFi protocols on Solana, including:
- CPMM (Constant Product Market Maker) - AMM pools for token swaps
- FBO (Frequent Batch Ordering) - MEV-resistant batch auctions
- Launchpad - Token launch and distribution platform
Features
🔌 Protocol Clients
- Type-safe Anchor program clients
- Automatic transaction building
- Error handling with user-friendly messages
- Support for all protocol operations
📊 Read Operations (No Wallet Required)
- Fetch pool data with reserves
- Calculate swap outputs and price impact
- Discover token prices via BFS algorithm
- Monitor pools in real-time
💱 Trading Operations
- Token swaps with slippage protection
- Add/remove liquidity
- Create new pools
- Claim fees and rewards
🧮 Advanced Calculations
- Pool math utilities (TVL, APY, price impact)
- Impermanent loss calculator
- LP token valuation
- Price discovery through pool graph
🎯 Developer Experience
- Full TypeScript support
- Comprehensive error handling
- Extensive examples
- Modular architecture
Directory Structure
src/
├── kinetic/
│ ├── cpmm/ # CPMM protocol implementation
│ │ ├── client.ts # Main CPMM client
│ │ ├── methods.ts # Protocol operations
│ │ ├── pool-fetcher.ts # Read-only pool data
│ │ ├── pool-math.ts # Calculation utilities
│ │ ├── price-calculator.ts # Price discovery
│ │ ├── enriched-pool.ts # Enhanced pool types
│ │ ├── errors.ts # Error handling
│ │ ├── constants/ # Network configurations
│ │ ├── idl/ # Contract IDL files
│ │ └── types/ # TypeScript types
│ ├── fbo/ # FBO protocol (coming soon)
│ └── launchpad/ # Launchpad protocol (coming soon)
├── common/ # Shared utilities
└── index.ts # Main exportsQuick Start
import { Connection } from '@solana/web3.js';
import {
fetchAllPoolsWithReserves,
PoolMath,
PriceCalculator
} from '@kinetic/sdk';
// No wallet needed for read operations!
const connection = new Connection('https://api.devnet.solana.com');
// Fetch all pools with reserves
const pools = await fetchAllPoolsWithReserves(connection);
// Calculate swap output
const swapResult = PoolMath.calculateSwapOutput(
amountIn,
pool.token0VaultReserve,
pool.token1VaultReserve,
pool.tradeFeeRate
);
// Discover token prices
const prices = PriceCalculator.fromPools(pools, seedPrices);Examples
See the examples directory for:
basic-usage.ts- Simple operations and common patternsadvanced-pool-usage.ts- Complex calculations and enriched data
Technical Details
Anchor Integration
Built on top of Anchor framework for type-safe program interactions with automatic IDL parsing and transaction building.
Network Support
- Mainnet-beta
- Devnet (default for development)
- Testnet
- Localnet
Dependencies
@solana/web3.js- Solana blockchain interaction@coral-xyz/anchor- Smart contract framework@solana/spl-token- SPL token operationsbn.js- Big number arithmetic
Contributing
This is the core protocol implementation. When adding new features:
- Implement in the appropriate protocol module
- Export from the module's index.ts
- Add to main index.ts exports
- Include examples demonstrating usage
- Update types as needed
License
Apache-2.0
