β
Always follow these checks and protections when using the SDK.
β
Always check pool status before trading
const poolState = await wendev.getPoolState(tokenMint);
if (poolState.status !== 0) {
throw new Error('Pool not in funding phase');
}
β
Use appropriate slippage tolerance
// High volume/volatile tokens: 2-5%
const slippage = 200; // 2%
// Low volume/stable tokens: 0.5-1%
const slippage = 50; // 0.5%
β
Handle transaction failures gracefully
try {
const signature = await connection.sendRawTransaction(tx.serialize());
await connection.confirmTransaction(signature, 'confirmed');
} catch (error) {
if (error.message.includes('ExceededSlippage')) {
console.error('Price moved too much. Try increasing slippage.');
} else {
console.error('Transaction failed:', error);
}
}
β
Calculate expected output before trading
β
Monitor fundraising progress
For Direct Integration
β
Recommended checks and practices when integrating directly with the program.
β
Always derive PDAs correctly - Wrong PDAs cause transaction failures
β
Verify account ownership - Ensure accounts belong to the correct program
β
Use idempotent ATA creation - Prevents failures if account exists
β
Validate pool state - Check status, reserves, and fees before constructing transactions
β
Test on devnet first - Always test with devnet before mainnet
β
Handle account size - Pool state is ~500 bytes, ensure sufficient rent
β
Use transaction simulation - Test transactions before sending
Security Considerations
π Security best practices to reduce risk of loss, frontrunning, and misconfiguration.
π Slippage Protection - Always set minAmountOut to prevent frontrunning
π Verify Token Mint - Check token mint matches expected value
π Check Pool Legitimacy - Verify pool creator and configuration
π Private Key Security - Never expose private keys in client-side code
β‘ Batch RPC Calls - Use getMultipleAccounts for multiple pool states
β‘ Use WebSockets - Subscribe to account changes instead of polling
β‘ Optimize Commitment Level - Use 'confirmed' for better speed vs. 'finalized'
β‘ Preflight Skip (Carefully) - Skip preflight for faster sends (only if validated)
Last updated