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

SwapsAggregator Fee AccountsLost to Rent
12 accounts0.004 SOL
1020 accounts0.04 SOL
100200 accounts0.4 SOL
10002000 accounts4 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

FeatureJupiter/TitanVybe Router
Fee accounts per swap2 (buy + sell side)0
Rent overhead~0.004 SOL (NOT reclaimable)None
Fee extractionCreates temp accountsDirect from swap tokens
Transaction sizeLarger (account creation)Smaller
DEX integrationVia aggregator layerDirect program calls
Execution speedStandardFaster
Cost for 100 swaps~0.4 SOL in rent alone0 SOL rent
Privy supportTransaction size doublesSize preserved (privy: true)
Gasless modeLimitedFull support
Supported DEXsManyRaydium, Meteora, Pumpfun, Pumpswap, Sanctum, LaunchLab
Exotic routesYesFalls 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:

RouterBest ForTrade-off
vybeMaximum efficiencyOnly works for supported protocols
titanWide token coverageUses aggregator (more overhead)
jupiterMaximum coverageFinal 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:

  1. Transaction built with real blockhash (for validation)
  2. Transaction simulated to catch errors
  3. Blockhash bytes patched to placeholder (1111...1111)
  4. Privy replaces placeholder during signing

Result: Transaction stays at ~850 bytes instead of ballooning to ~1,800 bytes.

Without Privy ModeWith Privy Mode
850 bytes β†’ 1,800 bytes850 bytes β†’ 850 bytes
ALT compression lostALT compression preserved
Larger feesMinimal fees

See Privy Integration for full implementation details.


Common Use Cases

Use CaseImplementation
Trading BotHigh-frequency swaps with minimal overhead
Wallet AppIn-app swaps for users
Embedded WalletsPrivy-optimized transactions
DCA BotScheduled recurring swaps
ArbitrageFast execution across pools
Portfolio RebalancingMulti-token swap sequences
OnboardingGasless swaps for new users

In This Section