Trade tokens (buy or sell)
Prepares a transaction to buy or sell tokens. Supports multiple trade types:
- Buy exact input: Spend specific USD amount
- Buy exact output: Receive specific token amount
- Sell exact input: Sell specific token amount
- Sell exact output: Receive specific USD amount
Automatically uses RobinSwap or UniswapV3 based on token graduation status.
Anti-Sniping & Initial Buy Fees:
- The first 6 seconds of trading (equivalent in blocks for each chain) has increased fees to prevent sniping
- Fees start at 80% and decrease linearly to 1% over the first 6 seconds worth of blocks
- This fee structure applies to all initial purchases, including the first buyer
- The quoter automatically includes these fees in all price quotes, so the amounts returned reflect the actual cost including anti-sniping fees
- After the initial 6-second window, normal trading fees apply
USD Rewards Attribution:
- Builder attribution: Set custom builder fees (in basis points) to earn USD rewards on transactions
- Token referral: Enable affiliate programs by specifying referral addresses for token trades
- USD rewards are processed in real-time on-chain with no third parties involved
- Token referrals have no additional cost to users - enabling affiliate programs onchain
Authorizations
JWT token or API key
Body
Blockchain identifier. Supported chains: solana, solana-devnet, arbitrum, base, base-sepolia, avalanche, op-bnb, bnb, bnb-testnet, ethereum, monad, unichain, unichain-testnet, abstract, polygon, zksync, zksync-testnet
solana, solana-devnet, arbitrum, base, base-sepolia, avalanche, op-bnb, bnb, bnb-testnet, ethereum, monad, unichain, unichain-testnet, abstract, polygon, zksync, zksync-testnet "base-sepolia"
buy, sell User wallet address (optional - if not provided, will use user's Privy wallet from user_wallets table)
^0x[a-fA-F0-9]{40}$"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
Builder attribution information (optional). Includes address and fee in bps.
Token referral address for attribution (optional - defaults to zero address). Used to attribute referral fees to a specific address.
^0x[a-fA-F0-9]{40}$"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
x > 0Token amount to buy (number for regular amounts, string for exact wei values at 100%)
x > 01000
Token amount to sell (number for regular amounts, string for exact wei values at 100%)
x > 01000
x > 0