Coder Social home page Coder Social logo

flashbot's Introduction

Flashbot

Flashbot is an arbitrage bot that fills 0x limit orders using DY/DX flash loans and 1inch.exchange

Based on extropy.io defi bot But uses 1inch v2 API instead of 1inch v1 (OneSplit) smart contract

How it works

  1. Fetches 0x limit orders from Mesh network
  2. Checks 1inch.exchange prices and finds if there is a profitable arbitrage opportunity
  3. If the opportunity was found Flashbot calls getFlashLoan function of TradingBot.sol smart contract which:
    • flash borrows 10 000 WETH from DY/DX
    • Fills 0x WETH/DAI order
    • Makes a swap on 1inch.exchange to get WETH for DAI from the previous step
    • Checks if arbitrage was profitable
    • If not profitable reverts transaction, if yes - pays borrowed WETH back to DY/DX

Example output

How to run and test

npm i

Fill in .env file like in .env.example

Create a local ethereum mainnet fork:

NODE_OPTIONS="--max-old-space-size=4096" ganache-cli --fork https://mainnet.infura.io/v3/<YOUR INFURA KEY> -p 8545 --gasLimit 0xfffffffffff -d --mnemonic "YOUR MNEMONIC HERE"

Compile and deploy FlashBot smart contract

truffle migrate

Run Flashbot

node ./src/bot.js

Future work

  1. Add more flash loan protocols
  2. Add a possibility to choose assets pairs for the arbitrage and choose the arbitrage strategy
  3. Liquidation bot

flashbot's People

Contributors

kmadorin 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.