Skip to main content

Overview

Monei integrates with Jupiter, Solana’s leading DEX aggregator, to provide the best swap rates across all Solana DEXs. Get optimal prices with minimal slippage. What you’ll learn:
  • Get swap quotes with Jupiter
  • Swap SOL to SPL tokens
  • Swap SPL tokens to SOL
  • Swap between SPL tokens
  • Understand slippage and price impact
  • Optimize swap routes

Swap Types

SOL → Token

Swap SOL to any SPL token (USDC, USDT, etc.)

Token → Token

Swap between any two SPL tokens

Token → SOL

Swap SPL tokens back to native SOL

Get Swap Quote

Always get a quote before swapping to see the exchange rate and estimated output.

SOL to Token Quote

import MoneiSDK from 'monei-sdk';

const monei = new MoneiSDK({
  apiKey: process.env.MONEI_API_KEY,
});

// Get quote for swapping 1 SOL to USDC
const quote = await monei.solanaExchange.getQuoteSolToToken({
  outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC mint
  amount: 1.0, // 1 SOL
});

console.log('Quote ID:', quote.quoteId);
console.log('Swap Mode:', quote.swapMode);
console.log('\nFrom:', quote.fromToken.symbol, '(SOL)');
console.log('To:', quote.toToken.symbol, '(USDC)');
console.log('\nInput Amount:', quote.amounts.inputAmount, 'SOL');
console.log('Output Amount:', quote.amounts.outputAmount, 'USDC');
console.log('Min Output:', quote.amounts.minOutputAmount, 'USDC (with slippage)');
console.log('\nExchange Rate:', quote.rates.rate, 'USDC per SOL');
console.log('Reverse Rate:', quote.rates.reverseRate, 'SOL per USDC');
console.log('USD Rate:', quote.rates.usdRate);
console.log('\nPrice Impact:', quote.priceImpact + '%');
console.log('Slippage Tolerance:', quote.slippageTolerance + '%');
console.log('\nGas Fee:', quote.fees.gasFee, 'SOL');
console.log('Total Fee:', quote.fees.totalFeeAmount, 'SOL');
console.log('\nRoute:', quote.route.hops, 'hops via', quote.route.dexes.join(', '));
console.log('Efficiency Score:', quote.route.efficiencyScore + '/100');
console.log('\nExpires in:', quote.expiresIn, 'seconds');
console.log('Executable:', quote.executable ? 'Yes' : 'No');
Response:
{
  "statusCode": 200,
  "message": "Quote retrieved successfully",
  "data": {
    "quoteId": "quote_abc123xyz",
    "swapMode": "ExactIn",
    "fromToken": {
      "address": "So11111111111111111111111111111111111111112",
      "symbol": "SOL",
      "decimals": 9,
      "name": "Solana",
      "logoUri": "https://..."
    },
    "toToken": {
      "address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      "symbol": "USDC",
      "decimals": 6,
      "name": "USD Coin"
    },
    "amounts": {
      "inputAmount": "1.0",
      "outputAmount": "100.50",
      "minOutputAmount": "99.99",
      "inputAmountRaw": "1000000000",
      "outputAmountRaw": "100500000"
    },
    "rates": {
      "rate": "100.50",
      "reverseRate": "0.00995",
      "usdRate": "100.50"
    },
    "fees": {
      "protocolFeePercent": "0.02",
      "protocolFeeAmount": "0.0002",
      "platformFeePercent": "0.02",
      "totalFeePercent": "0.04",
      "totalFeeAmount": "0.0004",
      "gasFee": "0.000005",
      "totalCost": "0.000405"
    },
    "route": {
      "hops": 2,
      "dexes": ["Raydium CLMM", "Orca"],
      "tokens": ["SOL", "USDT", "USDC"],
      "efficiencyScore": 98
    },
    "priceImpact": "0.05",
    "usdValues": {
      "inputValue": 100.50,
      "outputValue": 100.50,
      "netValue": 100.09
    },
    "slippageTolerance": "0.5",
    "expiryTimestamp": 1698765732,
    "expiresIn": 300,
    "estimatedSwapTime": 30,
    "network": "Solana Mainnet",
    "executable": true,
    "warnings": []
  }
}

Token to SOL Quote

// Get quote for swapping 100 USDC to SOL
const quote = await monei.solanaExchange.getQuoteTokenToSol({
  inputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
  amount: 100
});

console.log('Swap 100 USDC → SOL');
console.log('Output:', quote.amounts.outputAmount, 'SOL');
console.log('Min Output:', quote.amounts.minOutputAmount, 'SOL');
console.log('Rate:', quote.rates.rate, 'SOL per USDC');
console.log('Price Impact:', quote.priceImpact + '%');

Token to Token Quote

// Get quote for swapping USDC to USDT
const quote = await monei.solanaExchange.getQuoteTokenToToken({
  inputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
  outputMint: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB', // USDT
  amount: 100
});

console.log('Swap 100 USDC → USDT');
console.log('Output:', quote.amounts.outputAmount, 'USDT');
console.log('Rate:', quote.rates.rate);
console.log('Price Impact:', quote.priceImpact + '%');

Execute Swap

Swap SOL to Token

// Swap 1 SOL to USDC
const swap = await monei.solanaExchange.swapSolToToken({
  outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
  amount: 1.0,
  slippageBps: 50 // 0.5% slippage (optional)
});

console.log('Transaction Signature:', swap.signature);
console.log('Transaction URL:', swap.txUrl);
console.log('View on Solscan:', `https://solscan.io/tx/${swap.signature}`);

// Wait for confirmation
await monei.solana.waitForConfirmation(swap.signature);
console.log('Swap completed!');
Response:
{
  "statusCode": 200,
  "message": "Swap executed successfully",
  "data": {
    "signature": "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnTPLgTLpjvS3yJG3TBhVLiYt5mMXe4EH7zJ2VSkQfpYjG",
    "txUrl": "https://solscan.io/tx/5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnTPLgTLpjvS3yJG3TBhVLiYt5mMXe4EH7zJ2VSkQfpYjG"
  }
}

Swap Token to Token

// Swap 100 USDC to USDT
const swap = await monei.solanaExchange.swapTokenToToken({
  inputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
  outputMint: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB', // USDT
  amount: 100,
  slippageBps: 50
});

console.log('Swap completed!');
console.log('Signature:', swap.signature);

Swap Token to SOL

// Swap 100 USDC to SOL
const swap = await monei.solanaExchange.swapTokenToSol({
  inputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
  amount: 100,
  slippageBps: 50
});

console.log('Swap completed!');
console.log('Signature:', swap.signature);

Understanding Quote Details

Key Quote Fields

FieldDescription
quoteIdUnique ID for this quote (valid for ~5 minutes)
swapModeExactIn (specify input) or ExactOut (specify output)
amounts.outputAmountExpected output amount
amounts.minOutputAmountMinimum output after slippage
rates.rateExchange rate (1 input = X output)
rates.reverseRateReverse rate (1 output = Y input)
priceImpactHow much this trade affects market price
fees.gasFeeEstimated gas cost in SOL
route.hopsNumber of swaps in the route
route.dexesDEXs used for routing
route.efficiencyScoreRoute quality score (1-100)
slippageToleranceAllowed slippage percentage
expiresInSeconds until quote expires

Slippage (in Basis Points)

Slippage is specified in basis points (bps):
  • 1 bps = 0.01%
  • 50 bps = 0.5%
  • 100 bps = 1.0%
Slippage (bps)PercentageUse Case
100.1%Stablecoin swaps (USDC ↔ USDT)
500.5%Normal volatility
1001.0%Higher volatility
3003.0%Very volatile or low liquidity
// Calculate slippage in basis points
function toBps(percent) {
  return percent * 100;
}

console.log('0.5%:', toBps(0.5), 'bps'); // 50 bps
console.log('1.0%:', toBps(1.0), 'bps'); // 100 bps
console.log('3.0%:', toBps(3.0), 'bps'); // 300 bps

// Use custom slippage
const swap = await monei.solanaExchange.swapSolToToken({
  outputMint: usdcMint,
  amount: 1.0,
  slippageBps: toBps(1.0) // 1% slippage = 100 bps
});

Price Impact

Price impact shows how much your trade will move the market price:
Price ImpactInterpretationAction
< 0.1%NegligibleSafe to proceed
0.1% - 1%LowGood trade
1% - 3%ModerateAcceptable
3% - 5%HighConsider splitting
> 5%Very highSplit into smaller trades
// Check price impact before swapping
const quote = await monei.solanaExchange.getQuoteSolToToken({
  outputMint: tokenMint,
  amount: 10.0
});

const priceImpact = parseFloat(quote.priceImpact);

if (priceImpact > 5) {
  console.log('⚠️ WARNING: Very high price impact!');
  console.log('Price Impact:', priceImpact + '%');
  console.log('Consider splitting into smaller trades');
} else if (priceImpact > 3) {
  console.log('⚠️ High price impact:', priceImpact + '%');
} else if (priceImpact > 1) {
  console.log('ℹ️ Moderate price impact:', priceImpact + '%');
} else {
  console.log('✓ Low price impact:', priceImpact + '%');
  console.log('Safe to proceed');
}

Route Optimization

Monei finds the best route across multiple DEXs:

Supported DEXs

  • Raydium
  • Orca
  • Meteora
  • Phoenix
  • Lifinity
  • Openbook
  • And 20+ more

Route Example

Input: 1 SOL
Route: SOL → USDT (Raydium) → USDC (Orca)
Hops: 2
Output: 100.50 USDC
Efficiency: 98/100
// Analyze swap route
const quote = await monei.solanaExchange.getQuoteSolToToken({
  outputMint: usdcMint,
  amount: 1.0
});

console.log('Swap Route Analysis:');
console.log('==================');
console.log('Hops:', quote.route.hops);
console.log('Path:', quote.route.tokens.join(' → '));
console.log('DEXs:', quote.route.dexes.join(', '));
console.log('Efficiency Score:', quote.route.efficiencyScore + '/100');
console.log('\nInput:', quote.amounts.inputAmount, quote.fromToken.symbol);
console.log('Output:', quote.amounts.outputAmount, quote.toToken.symbol);
console.log('Rate:', quote.rates.rate);

// High efficiency routes are better
if (quote.route.efficiencyScore >= 95) {
  console.log('\n✓ Excellent route!');
} else if (quote.route.efficiencyScore >= 85) {
  console.log('\n✓ Good route');
} else {
  console.log('\n⚠️ Suboptimal route - low liquidity?');
}

Common Token Pairs

// SOL to USDC
const swap = await monei.solanaExchange.swapSolToToken({
  outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
  amount: 1.0,
  slippageBps: 50
});

// USDC to SOL
const reverseSwap = await monei.solanaExchange.swapTokenToSol({
  inputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
  amount: 100,
  slippageBps: 50
});

Swap Fees

Solana swaps have extremely low fees compared to EVM:
ComponentCostDescription
Gas Fee0.000005 SOL ($0.0005)Transaction fee
Protocol Fee0.02% - 0.04%Jupiter/DEX fees
Price ImpactVariableDepends on liquidity
Total Cost Example:
Swap: 1 SOL → USDC
- Gas Fee: 0.000005 SOL ($0.0005)
- Protocol Fee: 0.02% = 0.0002 SOL ($0.02)
- Total: ~0.0002 SOL ($0.02)
// Calculate total swap cost
const quote = await monei.solanaExchange.getQuoteSolToToken({
  outputMint: usdcMint,
  amount: 1.0
});

console.log('Swap Cost Breakdown:');
console.log('===================');
console.log('Gas Fee:', quote.fees.gasFee, 'SOL');
console.log('Protocol Fee:', quote.fees.protocolFeePercent + '%');
console.log('Protocol Fee Amount:', quote.fees.protocolFeeAmount, 'SOL');
console.log('Platform Fee:', quote.fees.platformFeePercent + '%');
console.log('Total Fee:', quote.fees.totalFeeAmount, 'SOL');
console.log('Total Cost:', quote.fees.totalCost, 'SOL');
console.log('\nNet Output:', quote.usdValues.netValue, 'USD');

Best Practices

Always Get Quote

Get fresh quote before each swap (quotes expire in ~5 min)

Check Price Impact

Avoid swaps with price impact > 5%

Set Appropriate Slippage

Use low slippage for stablecoins, higher for volatile tokens

Monitor Route Efficiency

Choose routes with efficiency score > 90

Split Large Trades

Break up trades with high price impact

Keep SOL for Fees

Maintain minimum 0.01 SOL for gas

Troubleshooting

Error: Slippage tolerance exceededCause: Price moved more than allowed slippageSolution:
  • Increase slippage tolerance
  • Get fresh quote
  • Split into smaller trades
  • Wait for less volatile market
// Increase slippage
const swap = await monei.solanaExchange.swapSolToToken({
  outputMint: tokenMint,
  amount: 1.0,
  slippageBps: 100 // Increase from 50 to 100 bps (1%)
});
Error: Not enough liquiditySolutions:
  • Reduce swap amount
  • Try different token pair
  • Use more liquid tokens (USDC/USDT)
  • Check quote route efficiency
const quote = await monei.solanaExchange.getQuoteSolToToken({
  outputMint: tokenMint,
  amount: 1.0
});

if (quote.route.efficiencyScore < 80) {
  console.log('Low liquidity detected');
  console.log('Consider reducing amount or using different token');
}
Error: Quote ID invalid or expiredCause: Quotes expire after ~5 minutesSolution:
  • Get fresh quote immediately before swapping
  • Don’t reuse old quotes
  • Execute swap right after getting quote
Error: Not enough SOL for transactionSolution:
  • Keep minimum 0.01 SOL for fees
  • Account for gas + protocol fees
  • Don’t swap all your SOL
// Check SOL balance before swap
const balance = await monei.solana.getBalance();
const minReserve = 0.01; // Keep for fees

if (parseFloat(balance.balance) < minReserve) {
  console.log('Need to keep SOL for fees');
}
Warning: Price impact > 5%Recommendations:
  • Split into 2-3 smaller swaps
  • Wait for better liquidity
  • Use different DEX route
  • Consider limit orders

Next Steps

Wallet Operations

Manage your Solana wallet

Transactions

Learn about Solana transactions

EVM Swaps

Compare with EVM token swaps

Networks

Explore supported networks