Best practices
Token decimals
The program supports tokens with 6 to 9 decimals. Amounts are automatically normalized during swaps so equivalent values are preserved across different decimal precisions.Slippage protection
Always setmin_amount_out to protect against fee rate changes between when you construct the transaction and when it executes.
Address whitelist
For smart contract integrations via CPI (Cross-Program Invocation): The PDA address (not its token accounts) must be whitelisted. Ensure the PDA has sufficient SOL to cover potential account creation fees when calling viainvoke_signed.
Security considerations
Always verify addresses
Always verify addresses
- Verify the Program ID before sending transactions — use the address from the Key Addresses page
- Double-check token mint addresses — confirm both
fromMintandtoMintagainst the Key Addresses page - Validate user inputs — sanitize and bounds-check all amounts and addresses
Test thoroughly
Test thoroughly
- Test on devnet first with small amounts
- Run integration tests covering success and failure cases
- Test edge cases like zero amounts, maximum amounts, and missing accounts
Handle failures gracefully
Handle failures gracefully
- Never assume success — always check transaction results
- Provide clear error messages to users
- Implement retry logic for network failures (but not for validation errors)
Monitor transactions
Monitor transactions
- Log transaction signatures for debugging and support
- Track failed transactions to identify patterns
- Monitor pool liquidity to warn users before failures
Pre-flight checklist
Before sending a swap on mainnet, verify:- User has sufficient input token balance
- User has sufficient SOL for transaction fees (0.000005 SOL typical, plus ~0.002 SOL if creating a new token account)
- Destination token account exists, or ATA creation is prepended to the transaction
- Pool has sufficient liquidity for the swap amount
- User wallet is whitelisted (if whitelist is enabled)
- Slippage tolerance accounts for current fee rate
- Program ID and mint addresses match the Key Addresses page