Uses dapp.tools
This is a set highly optimized contracts that can be used front and back slices in a UniswapV2 sandwich attack.
For a sandwich front/back slice, there is only so much optimization that can be done on your contracts. This repository currently includes:
- Avoid using
SLOAD
for owner checking - Compact payload construction
- Manual memory pointer construction
- Catch-all function signatures
- ....
NOTE: Please be aware that this repository does NOT provide protection against Uncle Bandit attacks
Single Swap | Gas Used |
---|---|
Univ2 Router | 109809 |
Solidity Inline Assembly Contract | 92422 |
Yulp Contracts | 92234 |
You'll need NodeJS on your machine.
Yul+ contracts are first compiled via the JS compiler, then relayed to Dapptool's HEVM via FFI. That way we can use Dapptool's testing suite alongside with Yul+.
Running the tests
# clone the repository, enter contracts directory
git clone https://github.com/libevm/subway.git
cd subway/contracts
# install dependencies (for yulp and ffi support)
yarn
# run the tests (requires a Ethereum Node)
# use Infura as last resort
dapp test --rpc-url $RPC_URL --verbosity 2 --ffi