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.- Ethereum Virtual Machine
- Solana Virtual Machine
EVM tokens commonly use 6 decimals (USDC) or 18 decimals. The contract normalizes between them automatically.You can query a token’s decimals from the contract:
Slippage protection
Always setminAmountOut to protect against fee rate changes between when you construct the transaction and when it executes.
- Ethereum Virtual Machine
- Solana Virtual Machine
Allowlist
- Ethereum Virtual Machine
- Solana Virtual Machine
For smart contract integrations: The calling contract’s address (
msg.sender) must be allowlisted, not the EOA that initiated the outer transaction. You can check allowlist status before sending a transaction: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:- Ethereum Virtual Machine
- Solana Virtual Machine
- User has sufficient input token balance
- User has sufficient ETH for gas fees
- ERC-20 approval is set for the Stableswapper contract on the input token
- Both tokens are listed and swappable
- Swap feature is enabled
- Contract has sufficient output token liquidity (balance minus reserved amount)
- User address is allowlisted (if allowlist feature is enabled)
- Slippage tolerance accounts for current fee rate
- Contract address and token addresses match the Key Addresses page
What to read next
Troubleshooting
Common errors and solutions
Examples
Code samples for common scenarios
Reference
Swap instruction parameters
Quickstart
Get up and running in 10 minutes