Skip to content

Instantly share code, notes, and snippets.

@Gi7w0rm
Created January 9, 2026 21:35
Show Gist options
  • Select an option

  • Save Gi7w0rm/9b57327bbdb2f02cb5f376a302324883 to your computer and use it in GitHub Desktop.

Select an option

Save Gi7w0rm/9b57327bbdb2f02cb5f376a302324883 to your computer and use it in GitHub Desktop.

This is a MEV (Maximal Extractable Value) bot contract designed to perform sandwich attacks and arbitrage on decentralized exchanges. Here's a breakdown of what it does:

Key Components:

Owner & Access Control

  • Owner: 0x6c8ec8f14be7c01672d31cfa5f2cefeab2562b50
  • Target DEX: 0x764c64b2a09b09acb100b80d8c505aa6a0302ef2 (likely a DEX router)
  • Token: 0xf65b5c5104c4fafd4b709d9d60a185eae063276c (token being traded)

Main Attack Functions:

1. attack(uint256 bribeAmount) (0x64dd891a)

// Performs sandwich attack with miner bribe
function attack(uint256 bribeAmount) external onlyOwner {
    // Loop through 5 stored pool addresses
    for (uint i = 0; i < 5; i++) {
        address pool = pools[i];
        
        // 1. Get quote from pool
        uint256 amountOut = pool.getAmountOut(poolAddress);
        
        // 2. If profitable, buy tokens
        if (amountOut <= balance) {
            pool.swap(poolAddress, amountOut);
            
            // 3. Check token balance
            uint256 tokenBalance = token.balanceOf(address(this));
            
            // 4. Approve and sell tokens back
            token.approve(pool, tokenBalance);
            pool.sell(tokenBalance);
            
            // 5. Calculate profit
            uint256 profit = currentBalance - initialBalance;
            
            // Emit trade event
        }
    }
    
    // 6. Pay miner bribe to get transaction included first
    require(profit > bribeAmount, "Not profitable after bribe");
    block.coinbase.transfer(bribeAmount);
    
    // 7. Withdraw remaining profit to owner
    owner.transfer(address(this).balance);
}

2. Unknown function 0x4b70f3ed

// Similar attack without specifying bribe amount
// Loops through same 5 pools performing trades

3. Unknown function 0xe99b36d4(address, uint256)

// Single-pool attack with specific parameters
// Takes pool address and bribe amount as inputs

Supporting Functions:

  • withdraw() - Sends all ETH to owner
  • withdrawToken(address) - Sends all tokens of specified address to owner
  • owner() - Returns owner address
  • target() - Returns target DEX address

How the Attack Works:

  1. Monitor mempool for large pending trades
  2. Front-run: Submit transaction with higher gas to execute BEFORE victim
    • Buy tokens, driving price up
  3. Victim's transaction executes at worse price
  4. Back-run: Immediately sell tokens at profit
  5. Bribe miner with part of profits to ensure transaction ordering
  6. Withdraw profits to owner

Malicious Aspects:

  • ✗ Exploits transaction ordering for profit
  • ✗ Harms regular users by increasing their slippage
  • ✗ Uses miner bribes (payments to block.coinbase) to guarantee execution order
  • ✗ Multiple attack vectors for flexibility
  • ✗ Hardcoded pools array for quick execution

This is a classic MEV sandwich attack bot that extracts value from unsuspecting traders on DEXs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment