Skip to main content
Get up and running with Stableswapper, the onchain liquidity program that enables fee-free, permissionless 1:1 swaps between USDC and custom stablecoins. In this quickstart, you will configure your environment, connect to the deployed contracts or program on devnet, approve USDC spending, and execute a swap into a custom stablecoin. Use the tabs below for EVM and Solana examples, and learn more about Custom Stablecoins.

Prerequisites

  • Node.js 18+ installed
  • A wallet with a private key for Base Sepolia
  • Base Sepolia ETH for gas fees (get from CDP Faucet)
  • Base Sepolia USDC tokens (get from CDP Faucet)
  • A custom stablecoin to swap with (this guide uses CBTUSD, a test token on Base Sepolia)
  • Basic familiarity with TypeScript
Don’t have a custom stablecoin yet? This quickstart uses CBTUSD, a test custom stablecoin already deployed on Base Sepolia for testing. For production with your own branded stablecoin, contact Coinbase about Custom Stablecoins issuance.

1. Create tsconfig.json

2. Install dependencies

3. Set environment variables

Never commit your private key to source control. Use environment variables or a secrets manager. For production, use CDP Non-custodial Wallets for secure key management.

4. Create your swap script

Now we’ll create a script that swaps 0.1 USDC for the custom stablecoin (CBTUSD). The script will:
  • Connect to the Stableswapper contract on Base Sepolia
  • Approve the contract to spend your USDC
  • Execute the swap with slippage protection
swap.ts

5. Run your swap

Running into issues? See the Troubleshooting guide for common errors and solutions.

Reference

Swap instruction parameters and accounts

Production Readiness

Helper functions, error handling, and best practices

Key Addresses

Program IDs and deployed addresses

Overview

Learn about Custom Stablecoins and use cases