Skip to main content
Everything you need for production swaps.

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.
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 set minAmountOut to protect against fee rate changes between when you construct the transaction and when it executes.

Allowlist

The allowlist may be enabled for this pool. When active, only allowlisted addresses can execute swaps. Transactions from non-allowlisted addresses will fail. Contact your integration partner to be added to the allowlist.
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.
Approving MaxUint256 is convenient but gives the contract unlimited spending authority over that token. For production, consider approving exact amounts or using a reasonable upper bound.

Security considerations

  1. Verify the contract address before sending transactions — use the address from the Key Addresses page
  2. Double-check token addresses — confirm both input and output token addresses against the Key Addresses page
  3. Validate user inputs — sanitize and bounds-check all amounts and addresses
  1. Test on devnet/testnet first with small amounts
  2. Run integration tests covering success and failure cases
  3. Test edge cases like zero amounts, maximum amounts, and missing accounts or approvals
  1. Never assume success — always check transaction results
  2. Provide clear error messages to users
  3. Implement retry logic for network failures (but not for validation errors)
  1. Log transaction signatures/hashes for debugging and support
  2. Track failed transactions to identify patterns
  3. 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 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
See Key Addresses for all contract and token addresses.

Troubleshooting

Common errors and solutions

Examples

Code samples for common scenarios

Reference

Swap instruction parameters

Quickstart

Get up and running in 10 minutes