Skip to content

cowprotocol/solver-template-py

Repository files navigation

Warning

This repository is outdated and does not currently function as a basis for implementing a solver.

Setup Project

Clone this repository

git clone git@github.com:cowprotocol/solver-template-py.git

Install Requirements

  1. Python 3.10 (or probably also 3.9)
  2. Rust v1.60.0 or Docker
python3.10 -m venv venv
source ./venv/bin/activate
pip install -r requirements.txt

Run Solver Server

python -m src._server

This can also be run via docker with

docker run -p 8000:8000 gchr.io/cowprotocol/solver-template-py

or build your own docker image with

docker build -t test-solver-image .

Feed an Auction Instance to the Solver

curl -X POST "http://127.0.0.1:8000/solve" \
  -H  "accept: application/json" \
  -H  "Content-Type: application/json" \
  --data "@data/small_example.json"

Connect to the orderbook:

Run the driver (auction dispatcher in DryRun mode). Configured to read the orderbook from our staging environment on Gnosis Chain. These parameters can be altered in .env

With Docker

If you have docker installed then you can run this.

docker run -it --rm --env-file .env --add-host host.docker.internal:host-gateway ghcr.io/cowprotocol/services solver

or without an env file (as described in the How to Write a Solver Tutorial)

docker run -it --rm --add-host host.docker.internal:host-gateway ghcr.io/cowprotocol/services solver \
--orderbook-url https://barn.api.cow.fi/xdai/api \
--base-tokens 0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83 \
--node-url "https://rpc.gnosischain.com" \
--cow-dex-ag-solver-url "http://127.0.0.1:8000" \
--solver-account 0x7942a2b3540d1ec40b2740896f87aecb2a588731 \
--solvers CowDexAg \
--transaction-strategy DryRun

Here we have used the orderbook-url for our staging environment on Gnosis Chain (very low traffic) so you can work with your own orders. A complete list of orderbook URLs can be found in a table at the bottom of the services repo README

Without Docker

Clone the services project with

git clone https://github.com/cowprotocol/services.git
cargo run -p solver -- \
    --orderbook-url https://barn.api.cow.fi/xdai/api \
    --base-tokens 0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83 \
    --node-url "https://rpc.gnosischain.com" \
    --cow-dex-ag-solver-url "http://127.0.0.1:8000" \
    --solver-account 0x7942a2b3540d1ec40b2740896f87aecb2a588731 \
    --solvers CowDexAg \
    --transaction-strategy DryRun \
    --log-filter=info,solver=debug

Place an order

Navigate to barn.cowswap.exchange/ and place a tiny (real) order. See your driver pick it up and include it in the next auction being sent to your solver

References

About

A hollow framework for a CoW Protocol solver

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages