Warning
This repository is outdated and does not currently function as a basis for implementing a solver.
Clone this repository
git clone [email protected]:cowprotocol/solver-template-py.git
- Python 3.10 (or probably also 3.9)
- Rust v1.60.0 or Docker
python3.10 -m venv venv
source ./venv/bin/activate
pip install -r requirements.txt
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 .
curl -X POST "http://127.0.0.1:8000/solve" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
--data "@data/small_example.json"
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
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
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
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
- How to Build a Solver: https://docs.cow.fi/tutorials/how-to-write-a-solver
- In Depth Solver Specification: https://docs.cow.fi/off-chain-services/in-depth-solver-specification
- Settlement Contract (namely the settle method): https://github.com/cowprotocol/contracts/blob/ff6fb7cad7787b8d43a6468809cacb799601a10e/src/contracts/GPv2Settlement.sol#L121-L143
- Interaction Model (Currently missing from this framework): https://github.com/cowprotocol/services/blob/cda5e36db34c55e7bf9eb4ea8b6e36ecb046f2b2/crates/shared/src/http_solver/model.rs#L125-L130