मुख्य सामग्री पर जाएँ
Skillpedia
सिक्योरिटी6.5k · #14009

contracts-mev-sandwich

यह क्या करती है

यह स्किल sandwich हमलों का वर्णन करती है, जहाँ कोई पीड़ित के swap के आसपास ट्रेड लगाकर कीमत की हलचल से मुनाफ़ा कमाता है। यह DeFi डेवलपर्स और उन ट्रेडर्स के लिए है जो अपने swaps सुरक्षित रखना चाहते हैं।

कब इस्तेमाल करें

  • ✓जब आप एक्सचेंज फ़्रंट एंड बना रहे हों और यूज़र के लिए slippage जोखिम घटाना चाहते हों।
  • ✓जब कोई ट्रेडर समझना चाहता है कि swap को बदतर कीमत क्यों मिली।
  • ✓जब प्रोटोकॉल टीम transaction routing और private submission विकल्पों की समीक्षा करती है।

Skill का लिंक

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/contracts/mev-sandwich/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/contracts/mev-sandwich/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे एक्सचेंज पर मेरे swap को उम्मीद से बदतर कीमत क्यों मिली, और आगे के swaps को मैं कैसे सुरक्षित रख सकता हूँ?”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट सरल शब्दों में समझाता है कि sandwich कैसे काम करता है, slippage सेटिंग जाँचता है, और ऐसी सेटिंग व routing विकल्प सुझाता है जो जोखिम कम करें।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

MEV Sandwich Attack

You observe a victim's DEX swap in the mempool. Sandwich it: buy the same token before the victim (pushing price up), let the victim swap at a worse price, then sell after them.

Detect a sandwichable swap

# Stream pending transactions
from web3 import Web3
w3 = Web3(Web3.HTTPProvider("https://eth.merkle.io"))
# Or: subscribe to alchemy/blocknative streams

# Filter for Uniswap V2 swapExactTokensForTokens or V3 exactInputSingle
# Look at the swap amount + slippage tolerance (deadline + minAmountOut)
# Sandwichable when: swap_amount * slippage > sandwich_gas_cost * 2

Math: profitable when victim's slippage tolerance exceeds your gas cost. Typical threshold for ETH/USDC swaps: victim swap >$10k with >1% slippage.

Construct the sandwich bundle

// Bundle: 3 tx in same block, in order
// 1. attacker_tx_1: swap baseToken -> token (push price UP)
// 2. victim_tx:     swap baseToken -> token (worse price now)
// 3. attacker_tx_2: swap token -> baseToken (sell back at higher price)
// Flashbots bundle (Ethereum mainnet — others have similar private RPCs)
const ethers = require("ethers");
const { FlashbotsBundleProvider } = require("@flashbots/ethers-provider-bundle");

const provider = new ethers.providers.JsonRpcProvider(process.env.RPC);
const wallet = new ethers.Wallet(process.env.PK, provider);
const fb = await FlashbotsBundleProvider.create(provider, wallet, "https://relay.flashbots.net");

const blockNumber = await provider.getBlockNumber();
const bundle = [
  { signer: wallet, transaction: attackerTx1 },  // front-run
  { signedTransaction: rawVictimTx },             // victim from mempool
  { signer: wallet, transaction: attackerTx2 },  // back-run
];

const signedBundle = await fb.signBundle(bundle);
await fb.sendRawBundle(signedBundle, blockNumber + 1);

JIT (Just-In-Time) liquidity sandwich

Uniswap V3 concentrated liquidity lets you provide liquidity in a tight range for one block:

// 1. Just before victim's swap: mint a position concentrated at victim's price
// 2. Victim swaps — your liquidity earns 100% of the fee
// 3. Just after: burn the position
// No price-impact risk; pure fee capture.

Works when victim's swap is large enough that the fee exceeds gas + capital cost.

Multi-block MEV

Cross-block sandwiches when validator is also the searcher (or in collusion):

Block N:    attacker front-run TX
Block N+1:  victim's TX (separate user, expects same price)
Block N+2:  attacker back-run TX

Requires builder/searcher cooperation. PBS (proposer-builder separation) on Ethereum makes this harder; still works on chains with single-block validators.

Defenses that break sandwiches (what to look for as "harder targets")

  • Victim uses private mempool (Flashbots Protect, MEV-Blocker, bloXroute Private Tx)
  • Victim contract has tight minAmountOut (low slippage like 0.1%)
  • DEX uses commit-reveal (rare)
  • Threshold encryption mempools (Shutter, etc.)

Common pitfalls (sandwich-of-sandwich = your sandwich gets sandwiched)

  • Don't broadcast your sandwich publicly — always use Flashbots / private relay
  • Other searchers also see the victim — outbid them via gas price + priority fee
  • Don't sandwich your own user's swap from same Address — easy attribution

Tooling

  • mev-inspect-py (Flashbots) — historical sandwich detection (defender + reverse research)
  • mev-share — partial-order-flow ecosystem
  • searcher-sage — open-source sandwich bot patterns
  • Eigenphi — MEV analytics dashboard (for reconning known searcher patterns)

OPSEC / ethics / legal

  • Sandwich attacks are public mempool predation, generally legal but ethically grey. In bounty context: only ever test on test networks or on a target you own.
  • For research / detection: use mev-inspect-py against historical blocks; no harm.
  • Some chains (e.g., Solana / Jito) have different MEV architectures — adapt accordingly.

References

  • "Flash Boys 2.0" (Daian et al., 2019) — original MEV academic paper
  • Flashbots docs — docs.flashbots.net
  • "MEV Wiki" — github.com/flashbots/mev-research
  • EthCC / Devcon talks: search "MEV" on YouTube
अक्सर पूछे जाने वाले सवाल

sandwich से कौन प्रभावित होता है?

पीड़ित ट्रेडर को उसके ट्रेड के आसपास लगे अतिरिक्त ट्रेड की वजह से बदतर कीमत मिलती है।

कौन-सी सेटिंग मदद करती है?

सख़्त slippage सहनशीलता, जो swap फ़ेल होने से पहले कीमत के हिलने की सीमा तय करती है।

private transaction route क्या है?

यह ट्रेड को सार्वजनिक pending pool में दिखाए बिना भेजता है, जिसे स्किल एक विकल्प बताती है।

जानकारी

लेखक का मूल विवरण

MEV sandwich attacks — front-run + back-run a victim swap on Uniswap V2/V3, Curve, Balancer; mempool monitoring via Flashbots / private RPC, slippage tolerance exploitation, JIT liquidity sandwich, multi-block MEV.

repo: BitterSecurity/Decepticon

लोकप्रियता

GitHub स्टार
6.5k
रैंकिंग में स्थान
#14009
लाइसेंस
Apache-2.0
अपडेट की गई
1/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

detector-overview

6.5k

यह आपके एजेंट को स्कैनर से चिह्नित कोड पढ़ने और तय करने में मदद करती है कि कौन सी जगहें असली सुरक्षा बग हैं और कौन सी गलत चेतावनी।

कोडिंगसिक्योरिटी

exploiter-overview

6.5k

यह आपके एजेंट को कई पक्की सुरक्षा कमज़ोरियों को एक परीक्षण श्रृंखला में जोड़ने और जाँचने में मदद करती है कि वह श्रृंखला कितनी दूर तक पहुँच सकती है।

कोडिंगसिक्योरिटी

llm-redteam-overview

6.5k

यह आपके एजेंट को परीक्षण के लिए सही AI रेड-टीम गाइड खोजने में मदद करती है, प्रॉम्प्ट इंजेक्शन से लेकर मॉडल के दुरुपयोग तक 15 रणनीति समूहों में।

कोडिंगसिक्योरिटी

aatmf-t01-prompt-injection

6.5k

समझाती है कि प्रॉम्प्ट इंजेक्शन क्या है, जिसमें छिपे निर्देश AI सिस्टम के नियम बदलने की कोशिश करते हैं, ताकि सुरक्षा परीक्षक उसकी जाँच कर सकें।

कोडिंगसिक्योरिटी

मिलती-जुलती skills