← Index
Source: docs/zsub/hacking-instructions-2/frontrunning-3.md (auto-generated by scripts/generate-docs-html.mjs — edit the .md, not this file)

Frontrunning Attacks Exercise 3

Intro

It's Sandwich time!

And this time, we are going back to a code you might be familiar with (maybe because you wrote it ^^).

In the first DEX exercise we implemented different functions in Chocolate.sol smart contract:

These functions lack of slippage protection and you are going to exploit it to sandwich users that are using the swapChocolates function!

Note: This exercise is executed on an Ethereum mainnet Fork block number 15969633. Everything is already configured in the hardhat.config.js file

Accounts

Tasks

Task 1

Get all the pending transactions from the mempool, find the transactions to the swapChocolates function, and perform a sandwich attack to ALL the users in order to generate MAX PROFIT in ETH.

Hardhat Mining Modes