MEV Protection

Protect your trades from sandwich attacks using Astralane MEV-protected submission.

MEV Protection

Solana transactions that include Jupiter swaps are vulnerable to sandwich attacks — a bot detects your pending swap, front-runs it to move the price, and back-runs to profit from the difference. This costs traders real money on every trade.

Lavarage integrates with Astralane to submit transactions through a MEV-protected gateway that prevents sandwich attacks.

How It Works

  1. Build the transaction with a tip — pass astralaneTipLamports when calling /positions/open or /positions/close
  2. Sign the transaction client-side with the user's wallet
  3. Submit via Astralane — send to POST /api/v1/bundle/submit instead of regular Solana RPC

The server fans out your transaction to multiple geo-distributed Astralane endpoints (NY, FR, SG, JP, AMS, LIM, LA) and returns the first success.

Step-by-Step: Open Position with MEV Protection

1. Get the recommended tip amount

GET /api/v1/bundle/tip

Response:

{ "tipLamports": 1200000 }

2. Build the transaction with the tip

POST /api/v1/positions/open
{
  "offerPublicKey": "7xS2gz2bTp3fwCC7knJvUWTEU9Tycczu6VhJYKgi1wdz",
  "userPublicKey": "YOUR_WALLET_ADDRESS",
  "collateralAmount": "1000000000",
  "leverage": 3,
  "side": "LONG",
  "slippageBps": 50,
  "astralaneTipLamports": 10000
}

The returned transaction automatically includes a transfer to the Astralane tip wallet.

3. Sign the transaction

Sign the returned transaction (base58-encoded VersionedTransaction) with the user's wallet. Decode from base58, sign, and re-encode to base64.

4. Submit via MEV-protected gateway

POST /api/v1/bundle/submit
{
  "transaction": "BASE64_ENCODED_SIGNED_TX",
  "mevProtect": true
}

Response:

{ "result": "5xYz...txSignature" }

Closing Positions with MEV Protection

Same flow — add astralaneTipLamports to the close request:

POST /api/v1/positions/close
{
  "positionAddress": "...",
  "userPublicKey": "...",
  "slippageBps": 50,
  "astralaneTipLamports": 10000
}

Sign and submit via /bundle/submit with mevProtect: true.

Partial Sell (Jito Bundle)

Partial sells use a Jito bundle (multiple transactions executed atomically) instead of a single MEV-protected transaction:

  1. POST /positions/partial-sell — returns splitTransaction + closeTransaction
  2. Build a tip transaction (SOL transfer to a Jito tip account)
  3. Sign all 3 transactions
  4. Submit as a bundle:
POST /api/v1/bundle
{
  "transactions": ["signedTipTx", "signedSplitTx", "signedCloseTx"]
}

Tip Amounts

EndpointDescription
GET /api/v1/bundle/tipReturns the current Jito tip floor (99th percentile x 1.2, cached 10s, minimum 1M lamports)

The tip is paid by the user as part of the transaction. Higher tips improve landing probability during network congestion. The minimum astralaneTipLamports is 10,000 lamports (0.00001 SOL).

When to Use MEV Protection

ScenarioRecommendation
Large trades (> $1K)Always use MEV protection
Small trades (< $100)Optional — tip cost may exceed MEV savings
High-volatility tokensRecommended — more attractive to sandwich bots
Stablecoin pairsLower risk — less profitable for bots

Without MEV Protection

If you don't pass astralaneTipLamports, the returned transaction has no tip instruction. Sign and submit directly to a Solana RPC endpoint as usual. This is simpler but leaves the transaction exposed to MEV.