Skip to content

Commit

Permalink
Merge pull request #21 from skip-mev/the-great-merge
Browse files Browse the repository at this point in the history
The great merge
  • Loading branch information
thal0x authored Mar 30, 2023
2 parents 08396e9 + 9da4353 commit af73db9
Show file tree
Hide file tree
Showing 810 changed files with 134,409 additions and 188 deletions.
9 changes: 0 additions & 9 deletions .gitignore

This file was deleted.

188 changes: 9 additions & 179 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,198 +1,28 @@
# Skipper

Example MEV searching bot for the Cosmos ecosystem, using Skip.
Example MEV searching bots for the Cosmos ecosystem, using Skip.

``` python
"""
||====================================================================||
||//$\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//$\\||
||(100)==================| SKIP MONEY PRINTER |================(100)||
||\\$// ~ '------========--------' \\$//||
||<< / /$\ // ____ \\ \ >>||
||>>| 12 //L\\ // ///..) \\ L38036133B 12 |<<||
||<<| \\ // || <|| >\ || |>>||
||>>| \$/ || $$ --/ || One Hundred |<<||
||<<| L38036133B *\\ |\_/ //* series |>>||
||>>| 12 *\\/___\_//* 1989 |<<||
||<<\ Treasurer ______/MEV BOTS\________ Secretary 12 />>||
||//$\ ~| TO SKIP OR NOT TO SKIP |~ /$\\||
||(100)=================== BRRRRRRRRRRRRRRRRRR =================(100)||
||\\$//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\$//||
||====================================================================||
"""
```
![Skipper](skipper-image.jpeg "Shout out Stable Diffusion")

# Overview

This repository contains an example MEV bot that searches for and executes on
profitable MEV opportunities throughout the Interchain, starting with Juno and Terra 2.
This repository contains example MEV bots that search for and executes on
profitable MEV opportunities throughout the Interchain, starting with Juno, Terra, and Evmos.

* If you're new to MEV or searching, use this repo as an educational tool to
help you learn the what and how of searching.

* If you're already an experienced searcher, use this repo as an example on how
to easily sign and send bundles to Skip on our supported chains.

For more searcher documentation, please see: https://skip-protocol.notion.site/Skip-Searcher-Documentation-0af486e8dccb4081bdb0451fe9538c99
For more searcher documentation, please see: https://docs.skip.money/searcher

For an overview of Skip, please see: https://woolen-background-b64.notion.site/Skip-What-it-is-How-it-Works-af39cd3eb5334920b41b16cf65665601
For an overview of Skip Select, please see: https://docs.skip.money/how-skip-works

# About our bots

Skipper is a Python-based bot for Cosmos that captures cyclic arbitrage opportunities across all major DEXs on Juno and Terra 2 by backrunning transactions that trade against particular pools. You can read more about JUNO, Loop DEX, and JunoSwap in our [state of JUNO MEV report](https://medium.com/@skip_protocol/skips-state-of-mev-juno-667a51a17b70)
There are two bots in the skipper repo, skipper-py and skipper-go:

**skipper-py**: A Python-based bot for CosmWasm-based Cosmos chains that captures cyclic arbitrage opportunities across all major DEXs on Juno and Terra by backrunning transactions that trade against particular pools. You can read more about JUNO, Loop DEX, and JunoSwap in our [state of JUNO MEV report](https://medium.com/@skip_protocol/skips-state-of-mev-juno-667a51a17b70)

# Quick Start

This bot requires:

- Python 3.10

### **Install Python 3.10** ###
```
sudo apt update && sudo apt upgrade -y
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.10 python3-pip python3-virtualenv python3.10-distutils
```

Check your Python 3.10 is functioning:

```
python3.10 --version
```

Clone the repository:
```
git clone https://github.com/skip-mev/skipper.git
```

Move into the directory:
```
cd skipper
```

Create a virtual environment
```
python3.10 -m venv venv
```

Activate virtual Environment, (venv) will show on left-hand side of shell
```
source venv/bin/activate
```

Once you have python 3.10 and are in the directory, install all the dependencies:
```
pip install -r requirements.txt
```

Edit files in envs/ to your liking (specifiying your mnemonic, profit as bid %, choosing node to query from).

The most important being your mnemonic, creating a new wallet is highly suggested for security, and for this wallet to only be used for this bot, as your mnemonic must be entered.
```
MNEMONIC = "<your mnemonic>"
```

Choose the specific .env file you want to target in `main.py` (change based on network run)
```
# Load environment variables
load_dotenv('envs/juno.env')
#load_dotenv('envs/terra.env')
```

Lastly, run the bot:
```python
python3.10 main.py
```
To leave the virtual environment use command
```
deactivate
```

# Run bot with docker

### **Install pre-requisites** ###
```
sudo apt update -y && apt upgrade -y && apt autoremove -y
sudo apt install docker.io docker-compose -y
```

Edit files in envs/ to your liking (specifiying your mnemonic, profit as bid %, choosing node to query from).

The most important being your mnemonic, creating a new wallet is highly suggested for security, and for this wallet to only be used for this bot, as your mnemonic must be entered.
```
MNEMONIC = "<your mnemonic>"
```

Choose the specific .env file you want to target in `main.py` (change based on network run)
```
# Load environment variables
load_dotenv('envs/juno.env')
#load_dotenv('envs/terra.env')
```

Build the docker image
```
docker build -t mevbot .
```

Run the docker image
```
docker run -d --name mevbot mevbot:latest
```

Shell into container & check logs (if running on terra, log will be logs/terra.log)
```
docker exec -it mevbot cat logs/juno.log
```

Change env variables after image is built
```
docker exec -it mevbot /bin/sh
```
```
cd envs && nano juno.env -> edit to your liking
```
```
exit
```
```
docker restart mevbot
```

# How the Bot Works

This example bot searches for 3-pool cyclic arbitrage opportunities
on Juno mainnet. A cylic arb route is a collection of pools and corresponding
swaps that result in receiving more of the same asset than was put in.

An example is as follows:
```bash
Swaps:
Pool 1: A -> B
Pool 2: B -> C
Pool 3: C -> A

Transfers: 100 Token A -> 20 Token B -> 150 Token C -> 120 Token A
```

In particular, this bot reads from a contracts.json file that has contract addresses
of popular pools on JunoSwap and Loop Dex. In addition, for each pool, the file also
has a list of 3-pool cyclic routes. Using this file, the high level steps are:

1. Continously query rpc node for current mempool txs (unconfirmed Txs)
2. Parse txs in mempool and look for swaps against JunoSwap pools
3. When a swap is found, grab the current reserve amounts for the pools we're tracking
4. Simulate the swap tx and update the reserves for the pools swapped against
5. Check if the swap created a cylic arb in any of our routes of interest
7. If an arb opportunity is created, find the optimal amount to put into the route
8. Check how profitable the cyclic arb would be after gas and bidding costs
9. If it's profitable after costs, then send a bundle to the Skip Auction

# We're Here To Help

If you have any questions, join our discord and ask in the
traders channel! Got our Skipper interns monitoring 24/7.

Discord: https://discord.gg/UgazvFgKef
**skipper-go**: A Golang-based bot for EVM-based Cosmos chains that captures cyclic arbitrage opportunities across all major DEXs on Evmos (Diffusion, EvmoSwap, Cronus) by backrunning transactions that trade against particular pools. Execution is carried out by an on-chain smart contract written in Solidity (also included in the repo for your own deployment / learning purposes).
48 changes: 48 additions & 0 deletions skipper-go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
### Foundry ###
# Compiler files
cache/
out/
broadcast/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env

### Go ###
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins

backrunner

*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work

### Go Patch ###
/vendor/
/Godeps/

# End of https://www.toptal.com/developers/gitignore/api/go
12 changes: 12 additions & 0 deletions skipper-go/.gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[submodule "contracts/lib/forge-std"]
path = contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "contracts/lib/openzeppelin-contracts"]
path = contracts/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "contracts/lib/v2-core"]
path = contracts/lib/v2-core
url = https://github.com/uniswap/v2-core
[submodule "contracts/lib/v2-periphery"]
path = contracts/lib/v2-periphery
url = https://github.com/uniswap/v2-periphery
Loading

0 comments on commit af73db9

Please sign in to comment.