Swap Overview
Execute token swaps directly on Solana DEXs through the Vybe API. Unlike aggregators that route through intermediary accounts, Vybe calls DEX programs directlyβresulting in smaller transactions, lower fees, and faster execution.
Why Choose Vybe for Swaps?
Swapping tokens is the most common operation in DeFi, but not all swap APIs are created equal. Most aggregators add unnecessary overhead that costs you SOL and slows down execution.
Vybe Router was built from the ground up to be lean and efficient:
- Direct DEX program calls (no intermediary accounts)
- Native fee handling (no extra instructions)
- Automatic protocol selection (finds the best pool)
- Fallback to aggregators when needed (Titan, Jupiter)
- Privy-optimized transactions that preserve compression
- Gasless mode for onboarding new users
The result? Your users get better execution, pay less in fees, and experience fewer failed transactions.
Value Proposition: Direct DEX calls. No middleman.
The Problem with Aggregators
Jupiter and Titan use a common pattern that creates significant overhead: they create temporary fee accounts for every swap.
The Hidden Cost
Every swap through an aggregator opens fee token accountsβone for the buy side and one for the sell side. Each account requires ~0.002 SOL in rent:
Traditional Aggregator Flow:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Your Wallet β [Fee Account A] β DEX β [Fee Account B] β Your Wallet
β β
~0.002 SOL ~0.002 SOL
(PERMANENTLY LOST) (PERMANENTLY LOST)
Extra instructions for:
β’ Creating fee accounts (buy side)
β’ Creating fee accounts (sell side)
β’ Transferring through temp accounts
β’ Extracting referral fees
The worst part? These 0.002 SOL rent costs are not reclaimable. Every swap permanently burns ~0.004 SOL in account rent, regardless of trade size.
Real Cost Example
| Swaps | Aggregator Fee Accounts | Lost to Rent |
|---|---|---|
| 1 | 2 accounts | 0.004 SOL |
| 10 | 20 accounts | 0.04 SOL |
| 100 | 200 accounts | 0.4 SOL |
| 1000 | 2000 accounts | 4 SOL |
For active traders and bots, this adds up to significant losses.
Additional overhead:
- Larger transaction size (more instructions)
- Slower execution (more accounts to create)
- More points of failure
The Vybe Solution
Vybe Router makes direct DEX calls with native fee transfersβno temporary accounts, no rent overhead:
Vybe Router Flow:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Your Wallet βββββββββββββ DEX βββββββββββββ Your Wallet
β
ββββ Fee Vault (direct transfer from swap tokens)
Minimal instructions:
β’ Setup ATAs if needed
β’ Transfer fee (from input OR output)
β’ Execute swap
Smart Fee Extraction
Instead of creating fee accounts, Vybe extracts fees directly from your swap tokens:
- Swapping SOL β Token? Fee comes from your SOL input (before swap)
- Swapping Token β SOL? Fee comes from SOL output (after swap)
- Token β Token? Fee from whichever side is vetted (SOL/USDC/USDT)
No accounts created. No rent lost. Just a simple token transfer to our fee vault.
Result:
- Smaller transaction size
- Zero rent overhead (saves 0.004 SOL per swap)
- Faster execution
- Fewer failure points
Head-to-Head Comparison
| Feature | Jupiter/Titan | Vybe Router |
|---|---|---|
| Fee accounts per swap | 2 (buy + sell side) | 0 |
| Rent overhead | ~0.004 SOL (NOT reclaimable) | None |
| Fee extraction | Creates temp accounts | Direct from swap tokens |
| Transaction size | Larger (account creation) | Smaller |
| DEX integration | Via aggregator layer | Direct program calls |
| Execution speed | Standard | Faster |
| Cost for 100 swaps | ~0.4 SOL in rent alone | 0 SOL rent |
| Privy support | Transaction size doubles | Size preserved (privy: true) |
| Gasless mode | Limited | Full support |
| Supported DEXs | Many | Raydium, Meteora, Pumpfun, Pumpswap, Sanctum, LaunchLab |
| Exotic routes | Yes | Falls back to aggregators |
The Complete Swap Flow
Building a swap with Vybe is a simple 5-step process:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β 1. GET QUOTE β See expected output, price impact β
β /trading/swap-quote β
β β
β 2. BUILD TX β Get unsigned transaction (base64) β
β POST /trading/swap β
β β
β 3. SIGN β User signs with wallet adapter β
β (client-side) β
β β
β 4. SUBMIT β Send raw transaction to Solana β
β connection.sendRawTransaction() β
β β
β 5. CONFIRM β Wait for confirmation β
β connection.confirmTransaction() β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Quick Start Example
# Step 1: Get a quote to see expected output
curl -X GET "https://api.vybenetwork.com/trading/swap-quote" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": 0.1,
"inputMint": "So11111111111111111111111111111111111111112",
"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
}'
# Step 2: Build the swap transaction
curl -X POST "https://api.vybenetwork.com/trading/swap" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"wallet": "YourWalletAddressHere",
"amount": 0.1,
"inputMint": "So11111111111111111111111111111111111111112",
"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"router": "vybe",
"slippage": 1
}'Choosing a Router
Vybe supports three router modes. Choose based on your needs:
| Router | Best For | Trade-off |
|---|---|---|
vybe | Maximum efficiency | Only works for supported protocols |
titan | Wide token coverage | Uses aggregator (more overhead) |
jupiter | Maximum coverage | Final fallback for exotic routes |
Smart Fallback
When using router: "vybe", if no direct route exists, the API automatically falls back:
vybe β titan β jupiter
To enforce direct integration only (no fallback), use:
{
"router": "vybe",
"vybeOnly": true
}Privy Embedded Wallet Support
Building with Privy embedded wallets? Vybe has you covered.
Privy requires transactions with placeholder blockhashes that get replaced during signing. The naive approach (deserialize β modify β reserialize) destroys Address Lookup Table compression, often doubling transaction size.
Vybe's privy: true mode solves this:
{
"wallet": "...",
"amount": 1,
"inputMint": "...",
"outputMint": "...",
"privy": true
}What happens:
- Transaction built with real blockhash (for validation)
- Transaction simulated to catch errors
- Blockhash bytes patched to placeholder (
1111...1111) - Privy replaces placeholder during signing
Result: Transaction stays at ~850 bytes instead of ballooning to ~1,800 bytes.
| Without Privy Mode | With Privy Mode |
|---|---|
| 850 bytes β 1,800 bytes | 850 bytes β 850 bytes |
| ALT compression lost | ALT compression preserved |
| Larger fees | Minimal fees |
See Privy Integration for full implementation details.
Common Use Cases
| Use Case | Implementation |
|---|---|
| Trading Bot | High-frequency swaps with minimal overhead |
| Wallet App | In-app swaps for users |
| Embedded Wallets | Privy-optimized transactions |
| DCA Bot | Scheduled recurring swaps |
| Arbitrage | Fast execution across pools |
| Portfolio Rebalancing | Multi-token swap sequences |
| Onboarding | Gasless swaps for new users |
In This Section
- Get Quote - Preview swap outcomes before execution
- Build Transaction - Create unsigned swap transactions
- Supported Protocols - All integrated DEXs and when to use each
- Slippage & Fees - Configure protection and understand fees
- Gasless Mode - Execute without holding SOL for gas
- Privy Integration - Embedded wallet support
Updated 4 days ago