Giter Site home page Giter Site logo

cow-dex-solver's Introduction

DEX COW SOLVER - a demo solver

Logic of the solver:

  • For each order, it requests the best trading route on paraswap and decomposes it into subpath trades
  • From the all the subpath trades, it identifies possible cows on the subpath and trades the cows internally against each other.
  • Then all the left over volume from the subtrades that don’t fit into a cow is settled against 0x.
  • Try to remove all subpath trades from zeroEx with buffer trades In between, it can fail on many steps, e.g. if the subtrades build a ring, it can’t deal with it.

How to use it:

Start the server by running:

cargo run

then post requests to it like:

curl -vX POST "http://127.0.0.1:8000/solve" -H  "accept: application/json" -H  "Content-Type: application/json" --data "@$PWD/data/test.json"

Alternatively, the code can also be run via docker:

Running api

docker build -t cowdexsolver -f docker/Dockerfile.binary .
docker run -p8000:8000 -ti cowdexsolver cowdexsolver --bind-address 0.0.0.0:8000

How to run simulations together with the cowswap official driver:

In order to see how the solutions would be submitted, which exact settlements would be build with the provided solutions and in order to investigate the settlements-simulations in tenderly, you can follow the following steps:

Prepare driver code:

Run the following commands to get the cowswap driver repo

git clone [email protected]:gnosis/gp-v2-services.git
cd gp-v2-services

and then start the driver by:

export INFURA_KEY=<your infura key>

cargo run -p solver --  --orderbook-url https://protocol-mainnet.gnosis.io \
   --node-url "https://mainnet.infura.io/v3/$INFURA_KEY" \
  --cow-dex-ag-solver-url "http://127.0.0.1:8000" \
  --solver-account 0xa6DDBD0dE6B310819b49f680F65871beE85f517e \
  --solvers CowDexAg \
  --transaction-strategy DryRun

This will start the driver.

Then you want to start the cowDexAg solver by running from this repo:

cargo run

Now, the driver should supply current open orders from production to the cowDexAg solver and the solver will find a solution and returning it back to the driver.

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.