• This repository has been archived on 28/Sep/2022
  • Stars
    star
    115
  • Rank 305,813 (Top 7 %)
  • Language
    Python
  • License
    GNU Affero Genera...
  • Created almost 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Maker Keeper Framework: Keeper to arbitrage on OasisDEX, `join`, `exit`, `boom` and `bust`. Efficiently handles both bad debt liquidations and surplus Dai.

arbitrage-keeper

Build Status codecov

The DAI Stablecoin System incentivizes external agents, called keepers, to automate certain operations around the Ethereum blockchain.

arbitrage-keeper performs arbitrage on OasisDEX, join, exit, boom and bust.

Keeper constantly looks for profitable enough arbitrage opportunities and executes them the moment they become available. It can make profit on:

  • taking orders on OasisDEX (on DAI/PETH, DAI/W-ETH and PETH/W-ETH pairs),
  • calling join and exit to exchange between W-ETH and PETH,
  • calling boom and bust to exchange between DAI and PETH.

Opportunities discovered by the keeper are sequences of token exchanges executed using methods listed above. An opportunity can consist of two or three steps, technically it could be more but practically it will never be more than three.

Steps can be executed sequentially (each one as a separate Ethereum transaction, checking if one has been successful before executing the next one) or in one go. The latter method requires a TxManager contract deployed, its address has to be passed as the --tx-manager argument. Also the TxManager contract has to be owned by the account the keeper operates from.

You can find the source code of the TxManager here: https://github.com/makerdao/tx-manager.

The base token is the token all arbitrage opportunities will start with. Some amount of this token will be exchanged to some other token(s) and then exchanged back to the base token, aiming to end up with more of it than we started with. It implies that some amount of this token has to be provided to the keeper. The higher the amount, the more profitable each arbitrage may be. Maximum engagement in terms of base token can be set using the --max-engagement argument.

It is also beneficial to provide very small amounts of other tokens to the keeper as well, mostly because of the rounding issues which may occur on subsequent arbitrage steps. Currently the keeper operates on DAI, PETH and W-ETH. It means that if we choose DAI as the base token, we should also give it some tiny amounts of PETH and W-ETH. It may happen that due to rounding issues these amounts will increase or decrease over time. Usually it is no more than 1 Wei increase or decrease per one arbitrage opportunity.

arbitrage-keeper provides valuable source of information where to look for arbitrage opportunities in the Dai system and how to exploit them. It also demonstrates how to do atomic risk-free arbitrage using the tx-manager contract.

The arbitrage-keeper will not work with multicollateral Dai, mainly because boom and bust actions will not be present in it anymore. Instead of that, surplus and bad debt will be liquidated via auctions, supported by the new auction-keeper.

https://chat.makerdao.com/channel/keeper

Installation

This project uses Python 3.6.2.

In order to clone the project and install required third-party packages please execute:

git clone https://github.com/makerdao/arbitrage-keeper.git
cd arbitrage-keeper
git submodule update --init --recursive
pip3 install -r requirements.txt

For some known Ubuntu and macOS issues see the pymaker README.

Usage

usage: arbitrage-keeper [-h] [--rpc-host RPC_HOST] [--rpc-port RPC_PORT]
                        [--rpc-timeout RPC_TIMEOUT] --eth-from ETH_FROM
                        --tub-address TUB_ADDRESS --tap-address TAP_ADDRESS
                        --oasis-address OASIS_ADDRESS
                        [--oasis-support-address OASIS_SUPPORT_ADDRESS]
                        [--tx-manager TX_MANAGER] [--gas-price GAS_PRICE]
                        --base-token BASE_TOKEN --min-profit MIN_PROFIT
                        --max-engagement MAX_ENGAGEMENT
                        [--max-errors MAX_ERRORS] [--debug]

optional arguments:
  -h, --help            show this help message and exit
  --rpc-host RPC_HOST   JSON-RPC host (default: `localhost')
  --rpc-port RPC_PORT   JSON-RPC port (default: `8545')
  --rpc-timeout RPC_TIMEOUT
                        JSON-RPC timeout (in seconds, default: 10)
  --eth-from ETH_FROM   Ethereum account from which to send transactions
  --tub-address TUB_ADDRESS
                        Ethereum address of the Tub contract
  --tap-address TAP_ADDRESS
                        Ethereum address of the Tap contract
  --oasis-address OASIS_ADDRESS
                        Ethereum address of the OasisDEX contract
  --oasis-support-address OASIS_SUPPORT_ADDRESS
                        Ethereum address of the OasisDEX support contract
  --tx-manager TX_MANAGER
                        Ethereum address of the TxManager contract to use for
                        multi-step arbitrage
  --gas-price GAS_PRICE
                        Gas price in Wei (default: node default)
  --base-token BASE_TOKEN
                        The token all arbitrage sequences will start and end
                        with
  --min-profit MIN_PROFIT
                        Minimum profit (in base token) from one arbitrage
                        operation
  --max-engagement MAX_ENGAGEMENT
                        Maximum engagement (in base token) in one arbitrage
                        operation
  --max-errors MAX_ERRORS
                        Maximum number of allowed errors before the keeper
                        terminates (default: 100)
  --debug               Enable debug output

License

See COPYING file.

Disclaimer

YOU (MEANING ANY INDIVIDUAL OR ENTITY ACCESSING, USING OR BOTH THE SOFTWARE INCLUDED IN THIS GITHUB REPOSITORY) EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE SOFTWARE IS AT YOUR SOLE RISK. THE SOFTWARE IN THIS GITHUB REPOSITORY IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. YOU RELEASE AUTHORS OR COPYRIGHT HOLDERS FROM ALL LIABILITY FOR YOU HAVING ACQUIRED OR NOT ACQUIRED CONTENT IN THIS GITHUB REPOSITORY. THE AUTHORS OR COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS CONCERNING ANY CONTENT CONTAINED IN OR ACCESSED THROUGH THE SERVICE, AND THE AUTHORS OR COPYRIGHT HOLDERS WILL NOT BE RESPONSIBLE OR LIABLE FOR THE ACCURACY, COPYRIGHT COMPLIANCE, LEGALITY OR DECENCY OF MATERIAL CONTAINED IN OR ACCESSED THROUGH THIS GITHUB REPOSITORY.

More Repositories

1

multicall

Multicall: Aggregate multiple constant function call results into one
Solidity
811
star
2

awesome-makerdao

A collection of tools, documents, articles, blog posts, interviews, and videos related to MakerDAO and the Dai stablecoin.
688
star
3

dss

Dai Stablecoin System
Solidity
673
star
4

developerguides

Developer guides to integrate with MakerDAO's smart contracts, SDKs, APIs, products, and partners
Shell
641
star
5

market-maker-keeper

Maker Keeper Framework: Market maker keepers for OasisDEX, EtherDelta, 0x (RadarRelay, ERCdEX), Paradex, DDEX, IDEX, Bibox, Ethfinex, GoPax, HitBTC, TheOcean, OKEX and Gate.io.
Python
452
star
6

multicall.js

Multicall.js: A JavaScript blockchain state management library for dapps
JavaScript
410
star
7

pymaker

Python API for Maker contracts
Python
193
star
8

community

Contains current and historical governance polls and executives used in the governance of the Maker Protocol. Previously contained a lot of other content which remains in the 'prior-cleanup' branch.
MDX
183
star
9

sai

Single Collateral Dai
Solidity
160
star
10

auction-keeper

Maker Keeper Framework: Keeper to participate in `flip`, `flop` and `flap` auctions in multicollateral Dai.
Python
120
star
11

spells-mainnet

Staging repo for MakerDAO weekly executive spells
Solidity
114
star
12

starknet-dai-bridge

TypeScript
98
star
13

dai.js

JavaScript
97
star
14

simple-arbitrage-keeper

Arbitrage Keeper on OasisDEX and Uniswap V1
Python
88
star
15

dss-teleport

Solidity
81
star
16

pyexchange

Python API for some cryptocurrency exchanges
Python
75
star
17

optimism-dai-bridge

Optimism Dai and upgradable token bridge
TypeScript
72
star
18

dss-proxy-actions

Set of proxy functions for MCD (using mcd-cdp-handler)
Solidity
72
star
19

dss-deploy

Set of smart contracts and bash scripts to deploy Multi collateral DAI
Solidity
66
star
20

tx-manager

Solidity contract to make multiple calls in one Ethereum transaction. Used by Maker keepers.
Makefile
66
star
21

mips

Maker Improvement Proposals (MIPs)
63
star
22

spells-goerli

Solidity
58
star
23

dss-direct-deposit

Solidity
57
star
24

integration-examples

A set of examples of how to use the DAI.js library with various purposes and configs
JavaScript
56
star
25

oracles-v2

Nix
50
star
26

bite-keeper

Maker Keeper Framework: Keeper to bite undercollateralized cups.
Python
49
star
27

dss-deploy-scripts

Shell
47
star
28

dss-flash

MakerDAO Flash Mint Module
Solidity
47
star
29

governance-portal-v2

Governance Portal V2
TypeScript
46
star
30

mips-best-practices

A collection of best practices and code samples for technical Maker Improvement Proposals (MIPs).
Solidity
44
star
31

endgame-toolkit

Smart contract modules to enable MakerDAO Endgame.
Solidity
42
star
32

dss-exec-lib

DSS Executive Spellcrafting Library Contracts
Solidity
37
star
33

market-maker-stats

Maker Keeper Framework: Set of tools to analyze market maker keepers performance.
Python
33
star
34

testchain

Start a local test chain with the MakerDAO contracts deployed on it, quickly and easily.
Shell
33
star
35

dss-conduits

Solidity
33
star
36

dss-kiln

Slow burner for protocol assets.
Solidity
33
star
37

dss-interfaces

Abstract developer interfaces to the Dai Stablecoin System core contracts.
Solidity
33
star
38

price-feed

price feed, with expiration and medianizer poke
Solidity
32
star
39

sdai

A tokenized wrapper around the DSR.
Solidity
31
star
40

univ3-lp-oracle

Solidity
31
star
41

dss-vest

Solidity
31
star
42

exchange-callees

Exchange Callee contracts for LIQ2.0 Flash Loans
Solidity
30
star
43

uniswap-price-feed

Python
30
star
44

auction-demo-keeper

JavaScript
30
star
45

evm

Shell
28
star
46

cdp-keeper

Maker Keeper Framework: Keeper to actively manage open CDPs.
Python
28
star
47

lockstake

Solidity
27
star
48

btc-market

Trade bitcoins for tokens via btc-relay
27
star
49

mkr-mcd-spec

High level KSpecification for the MCD System by Runtime Verification and Maker Foundation
Python
27
star
50

dss-gem-joins

Solidity
25
star
51

arbitrum-dai-bridge

TypeScript
25
star
52

dss-cdp-manager

Solidity
25
star
53

dss-allocator

Solidity
24
star
54

governance-portal

Governance Portal
JavaScript
24
star
55

mcd-changelog

Multi-Collateral DAI Public Releases Page
HTML
24
star
56

univ2-lp-oracle

Solidity
23
star
57

ilk-registry

A publicly-modifiable registry of ilks in the Dai Stablecoin System.
Solidity
22
star
58

scd-cdp-portal

Single-Collateral Dai CDP Portal
JavaScript
21
star
59

dss-proxy

Solidity
21
star
60

dockerized-auction-keeper

Shell
21
star
61

token-auction

Continuous Splitting Token Auction
Makefile
21
star
62

osm

Feed with 1 hour delay
Solidity
21
star
63

simplecoin1

Something to play with while we wait
Makefile
20
star
64

setzer

manipulate feeds
Shell
20
star
65

sky

Python
19
star
66

xdomain

TypeScript
19
star
67

medianizer

Returns median value of several DSValue, DSCache or other Medianizers
Solidity
18
star
68

mcd-cli

MCD Command-line interface
Shell
18
star
69

dss-bridge

18
star
70

curve-lp-oracle

Solidity
17
star
71

dai-ui

JavaScript
16
star
72

dss-crop-join

Solidity
16
star
73

petrometer

Tool which summarizes daily and total gas consumption of all transactions sent from a specified Ethereum address.
Python
16
star
74

plunger

Tool for overriding Ethereum transactions stuck in the pool
Python
16
star
75

esm

Emergency Shutdown Module
Solidity
16
star
76

governance-manual

Welcome to the Maker Operational Manual. This set of documents intends to acquaint MKR Holders with the voting process and to serve as reference material for them to consult during the day-to-day operation of the protocol.
16
star
77

median

Medianizer 2
Solidity
15
star
78

MIP21-RWA-Example

MIP21 example
Solidity
14
star
79

dss-lite-psm

14
star
80

dss-charter

Solidity
13
star
81

spells-kovan

Solidity
12
star
82

dai-cli

SCD Command-line interface
Shell
12
star
83

redeem

UI for redeeming MKR tokens
JavaScript
12
star
84

rwa-toolkit

SW Repo; Content Manager: CES-001; MIP21 Toolkit: Equipment for Off-chain Asset Backed Lending in MakerDAO
Solidity
12
star
85

dss-cron

Solidity
12
star
86

dss-chain-log

Simple way to track the mcd changelog on-chain.
Solidity
12
star
87

proxy-registry

This Registry deploys new proxy instances through DSProxyFactory and keeps a registry of owner => proxy
Solidity
12
star
88

oracle-suite

Go
11
star
89

dss-test

Solidity
11
star
90

univ2-pool-migrator

Solidity
11
star
91

megapoker

Smart contract to poke and drip
Solidity
10
star
92

token-faucet

Mostly well behaved ERC20s faucet
Solidity
10
star
93

vote-proxy

ds-chief mkr proxy voting with a hot/cold wallet
Solidity
10
star
94

scd-mcd-migration

Solidity
9
star
95

dss-darkspell

spell to conceal bug fix source and bytecode during pause delay
Solidity
9
star
96

nst

Ruby
9
star
97

protego

Solidity
9
star
98

wormhole-integration-tests

Gathers all related repos and runs a suite of integration tests using forked networks.
TypeScript
9
star
99

mcd-security

The Maker Foundation's highest priority is the security of the Maker protocol. This repository is dedicated to providing transparency to our community with respect to the results of our MCD Audits and our Bug Bounty Program results.
9
star
100

vulcan0x

SCD GraphQL API
PLpgSQL
8
star