Giter Club home page Giter Club logo

defi-path-finder's Introduction

DeFi Arbitrage Path Finder

A simple arbitrage path finder for multiple DEXs.

Two way arbitrage paths are rather simple to find. However, n-way paths get complicated real quick.

This project is an attempt to map triangular paths using 2 DEXs. The concepts used here can easily extend over to 4-way, 5-way, n-way paths.

The sample exchanges used here are:

  • Polygon Sushiswap V2,
  • Polygon Meshswap

Sushiswap V2 data is retrieved through a subgraph endpoint. And Meshswap data is retrieved through their specific API endpoint.

Visit: https://solidquant.github.io/blog/post/building-a-defi-arbitrage-path-finder-(1)/

for more information.

Usage:

Install dependencies:

pip install -r requirements.txt

Run the sample code in examples.py:

import pickle

from defi_path_finder import Preprocessor
from defi_path_finder import make_triangular_paths

if __name__ == '__main__':
    p = Preprocessor()
    pools, reserves = p.load_data(500)

    pairs, paths = make_triangular_paths(pools, [], 6)

    # pickle data to load and use later
    save_data = {
        'EXCHANGES': p.EXCHANGES,
        'TOKENS': p.TOKENS,
        'POOLS': p.POOLS,
        'reserves': reserves,
        'pairs': pairs,
        'paths': paths
    }

    f = open('./paths.pkl', 'wb')
    pickle.dump(save_data, f)
    f.close()

The code above runs for approximately 10 minutes using 6 processes to run this code in parallel.

TODO:

  • add simulation helpers to find the most profitable arbitrage path
  • extend the module to work for n-way paths as well
  • add market impact simulation functions for various AMM types to accommodate for all variants of Uniswap and others

defi-path-finder's People

Contributors

solidquant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.