@vertigo-amm/vertigo-sdk
v2.0.6
Published
Official TypeScript SDK for the Vertigo AMM protocol on Solana
Readme
Vertigo SDK v2.0
✨ Features
- 🎯 Simple & Intuitive API - Get started in minutes with our high-level client
- 🔧 Modular Architecture - Use only what you need with tree-shakeable exports
- ⚡ High Performance - Optimized for speed with smart caching and batching
- 🔐 Type Safety - Full TypeScript support with comprehensive type definitions
- 📊 Real-time Data - Built-in API client for market data and analytics
- 🛠️ Developer Tools - Rich utilities for common blockchain operations
- 📱 Wallet Integration - Works seamlessly with all major Solana wallets
- 🔄 Auto-retry Logic - Robust error handling and automatic retries
📦 Installation
yarn add @vertigo-amm/vertigo-sdk
# or
npm install @vertigo-amm/vertigo-sdk
# or
bun install @vertigo-amm/vertigo-sdk🚀 Quick Start
Basic Usage (Read-Only)
import { Vertigo } from "@vertigo-amm/vertigo-sdk";
import { Connection } from "@solana/web3.js";
// Initialize SDK without wallet (read-only)
const vertigo = await Vertigo.load({
connection: new Connection("https://api.mainnet-beta.solana.com"),
network: "mainnet",
});
// Find pools for a token pair
const pools = await vertigo.pools.findPoolsByMints(SOL_MINT, USDC_MINT);
// Get swap quote
const quote = await vertigo.swap.getQuote({
inputMint: SOL_MINT,
outputMint: USDC_MINT,
amount: 1_000_000_000, // 1 SOL
slippageBps: 50,
});With Wallet (Full Features)
import { Vertigo } from "@vertigo-amm/vertigo-sdk";
import { Connection, Keypair } from "@solana/web3.js";
import * as anchor from "@coral-xyz/anchor";
// Initialize with wallet
const wallet = new anchor.Wallet(keypair);
const vertigo = await Vertigo.load({
connection: new Connection("https://api.mainnet-beta.solana.com"),
wallet,
network: "mainnet",
});
// Execute a swap
const result = await vertigo.swap.swap({
inputMint: SOL_MINT,
outputMint: USDC_MINT,
amount: 1_000_000_000,
options: {
slippageBps: 100,
priorityFee: "auto",
},
});
console.log(`Swap successful: ${result.signature}`);📚 Core Modules
🏊 Pool Client
Manage liquidity pools and fetch pool data:
// Create a new pool
const { poolAddress } = await vertigo.pools.createPool({
mintA: SOL_MINT,
mintB: TOKEN_MINT,
initialMarketCap: 10_000_000_000,
royaltiesBps: 250,
});
// Get pool information
const pool = await vertigo.pools.getPool(poolAddress);
// Get all pools
const pools = await vertigo.pools.getPools();
// Find pools by tokens
const pools = await vertigo.pools.findPoolsByMints(mintA, mintB);
// Get pool statistics
const stats = await vertigo.pools.getPoolStats(poolAddress);💱 Swap Client
Execute token swaps with advanced features:
// Get swap quote
const quote = await vertigo.swap.getQuote({
inputMint: SOL_MINT,
outputMint: USDC_MINT,
amount: 1_000_000_000,
slippageBps: 50,
});
// Simulate swap to check for errors
const simulation = await vertigo.swap.simulateSwap({
inputMint: SOL_MINT,
outputMint: USDC_MINT,
amount: 1_000_000_000,
});
// Execute swap
const result = await vertigo.swap.swap({
inputMint: SOL_MINT,
outputMint: USDC_MINT,
amount: 1_000_000_000,
options: {
slippageBps: 100,
wrapSol: true,
priorityFee: "auto",
},
});🏗️ Pool Authority Client
Advanced pool management for authorized users:
import { PoolAuthority } from "@vertigo-amm/vertigo-sdk";
// Initialize Pool Authority client
const poolAuth = await PoolAuthority.load({
connection,
wallet,
});
// Create pools with authority permissions
// Note: Token factory features are under development📊 API Client
Access market data and analytics:
// Get pool statistics
const stats = await vertigo.api.getPoolStats(poolAddress);
// Get trending pools
const trending = await vertigo.api.getTrendingPools("24h", 10);
// Get token information
const tokenInfo = await vertigo.api.getTokenInfo(mintAddress);
// Subscribe to pool updates
const unsubscribe = vertigo.api.subscribeToPool(poolAddress, {
onUpdate: (data) => console.log("Pool update:", data),
});🛠️ Utility Functions
The SDK includes rich utilities for common operations:
import {
formatTokenAmount,
parseTokenAmount,
getOrCreateATA,
estimatePriorityFee,
retry,
getExplorerUrl,
createTokenMetadata,
} from "@vertigo-amm/vertigo-sdk";
// Format token amounts
const formatted = formatTokenAmount(amount, decimals, 4);
// Parse user input
const amount = parseTokenAmount("1.5", 9);
// Get or create token accounts
const { address, instruction } = await getOrCreateATA(connection, mint, owner);
// Estimate network fees
const fee = await estimatePriorityFee(connection, 75);
// Retry with exponential backoff
const result = await retry(() => fetchData(), { maxRetries: 3 });
// Get explorer links
const url = getExplorerUrl(signature, "mainnet", "solscan");
// Create token metadata for token factories
const metadata = createTokenMetadata(
"My Token",
"MYTKN",
"https://example.com/metadata.json"
);🪙 Token Metadata Helper
When creating tokens with the factory programs, use the createTokenMetadata helper for validation:
import { createTokenMetadata } from "@vertigo-amm/vertigo-sdk";
// Create and validate token metadata
const metadata = createTokenMetadata(
"My Amazing Token", // name (max 32 characters)
"MAT", // symbol (max 10 characters, auto-uppercased)
"https://example.com/token-metadata.json" // URI to off-chain metadata
);
// Use with token factory launch params
const launchParams = {
token_config: metadata,
reference: new anchor.BN(Date.now() / 1000),
nonce: 0,
};The helper automatically:
- ✅ Validates name length (1-32 characters)
- ✅ Validates symbol length (1-10 characters)
- ✅ Trims whitespace from all fields
- ✅ Uppercases the symbol
- ✅ Ensures URI is provided
⚙️ Advanced Configuration
const vertigo = await Vertigo.load({
connection,
wallet,
network: "mainnet",
// Custom program addresses
programs: {
amm: customAmmAddress,
factory: customFactoryAddress,
},
// API configuration
apiUrl: "https://api.vertigo.so",
// Caching settings
cache: {
enabled: true,
ttl: 60000, // 1 minute
},
// Transaction settings
priority: {
autoFee: true,
baseFee: 1000,
maxFee: 1000000,
},
});🎯 Examples
Check out our test files for usage examples:
🧪 Running Tests
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run integration tests
npm run test:integration
# Run full devnet integration test
npm run test:full
# Run devnet tests with various options
npm run test:devnet
npm run test:devnet:verbose🔄 Migration from v1
If you're upgrading from SDK v1:
// Old (v1)
import { VertigoSDK } from "@vertigo-amm/vertigo-sdk";
const sdk = new VertigoSDK(provider);
// New (v2)
import { Vertigo } from "@vertigo-amm/vertigo-sdk";
const vertigo = await Vertigo.load({ connection, wallet });
// The old SDK is still available for backwards compatibility
import { VertigoSDK } from "@vertigo-amm/vertigo-sdk";🔗 Network Support
| Network | Status | RPC Endpoint | | -------- | ------------ | ----------------------------------- | | Mainnet | ✅ Supported | https://api.mainnet-beta.solana.com | | Devnet | ✅ Supported | https://api.devnet.solana.com | | Testnet | ✅ Supported | https://api.testnet.solana.com | | Localnet | ✅ Supported | http://localhost:8899 |
📖 Documentation
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
🐛 Support
- Discord: Join our community
- GitHub Issues: Report bugs
📄 License
MIT License - see LICENSE for details.
