Best practices
Token decimals
The program supports tokens with different decimal precision. Amounts are automatically normalized during swaps so equivalent values are preserved across different decimal precisions.- Solana
- Base (EVM)
Solana tokens typically use 6 to 9 decimals.
Slippage protection
Always setminAmountOut to protect against fee rate changes between when you construct the transaction and when it executes.
- Solana
- Base (EVM)
Allowlist
- Solana
- Base (EVM)
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 via
invoke_signed.ERC-20 approvals (Base only)
Before swapping on Base, the Stableswapper contract must be approved to transfer your input tokens. This is a standard ERC-20 requirement.Security considerations
Always verify addresses
Always verify addresses
- Verify the contract address before sending transactions — use the address from the Key Addresses page
- Double-check token addresses — confirm both input and output token addresses against the Key Addresses page
- Validate user inputs — sanitize and bounds-check all amounts and addresses
Test thoroughly
Test thoroughly
- Test on devnet/testnet first with small amounts
- Run integration tests covering success and failure cases
- Test edge cases like zero amounts, maximum amounts, and missing accounts or approvals
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/hashes 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:- Solana
- Base (EVM)
- User has sufficient input token balance
- 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