DEV Community

TateLyman
TateLyman

Posted on

Jito MEV Protection on Solana: Why Your Trades Are Getting Sandwiched

If you're trading on Solana without MEV protection, you're probably losing money to sandwich attacks.

What's a Sandwich Attack?

A bot sees your pending swap transaction, puts a buy order before yours (raising the price), lets your trade execute at the inflated price, then immediately sells after you. The bot profits; you get a worse price.

On Solana, this happens in milliseconds.

How Jito Fixes It

Jito is a modified Solana validator client that lets you submit transaction bundles directly to the block producer, skipping the public mempool.

const { JitoJsonRpcClient } = require('jito-js-rpc');
const jito = new JitoJsonRpcClient('https://mainnet.block-engine.jito.wtf/api/v1');

// Add a Jito tip to your transaction
const tipIx = SystemProgram.transfer({
  fromPubkey: userWallet,
  toPubkey: new PublicKey('96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5'),
  lamports: 10000, // 0.00001 SOL tip
});

// Submit as bundle
await jito.sendBundle([serializedTransaction]);
Enter fullscreen mode Exit fullscreen mode

Key points:

  • Tip amount: 10,000-100,000 lamports (0.00001-0.0001 SOL). Higher = faster inclusion.
  • No public mempool: Bots can't see your transaction before it's included.
  • Atomic: Either the whole bundle executes or nothing does.

Real Impact

Without Jito, a 1 SOL swap on a low-liquidity token can lose 2-5% to sandwich attacks. That's 0.02-0.05 SOL per trade in hidden costs — more than most trading fees.

Implementation

I use Jito on every trade in @solscanitbot — a free Solana trading bot on Telegram. The bot handles Jito bundling automatically so users never think about MEV.

Want to implement Jito in your own bot? The full source code includes Jito integration.

Top comments (0)