Skip to content

Cross-chain CoW Protocol solver implementation in Rust with automated settlement optimization and bridge integration

Notifications You must be signed in to change notification settings

0xDevNinja/cowSolver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cowSolver

CI

Overview

cowSolver is a high-performance cross-chain solver implementation for the CoW Protocol. It enables seamless token swaps across multiple blockchain networks with optimal routing and settlement. The project is written in Rust and is composed of modular components that can be independently extended and tested.

Architecture

The solver consists of several layers:

  • Solver Engine – Handles batch auction processing and orchestration.
  • Order Matching – Performs CoW discovery and matches orders via direct pairs and rings.
  • AMM Routing – Computes optimal multi-hop routing through AMMs like Uniswap, Balancer and Curve.
  • Pricing Engine – Calculates clearing prices using uniform or volume-weighted strategies.
  • Domain Models – Defines structs for orders, tokens, chains and settlements.
  • Math Utilities – Provides precise decimal arithmetic and slippage calculations.
  • Adapters Layer – Implements chain RPC clients and DEX integrations for on-chain interactions.
  • Bridge Integration – Executes cross-chain settlements using bridges.
  • Strategy Layer – Houses solving strategies with pluggable heuristics.
  • CLI Binary – Offers command-line interface for interacting with the solver.
  • Daemon Service – Provides a long-running service with HTTP/gRPC APIs.
  • Integration Tests – Validates end-to-end flows across modules.
  • Performance Optimizations – Contains utilities for improving throughput and reducing gas.

See the docs/architecture.md guide for a detailed diagram and explanation of how these components interact.

Getting Started

Prerequisites

  • Rust 1.75 or later installed (rustup toolchain install stable)
  • Cargo for building and testing
  • (Optional) Docker for running local testnets

Building and Running

Clone the repository and run:

git clone https://github.com/0xDevNinja/cowSolver.git
cd cowSolver
cargo build --release
cargo test

To start the daemon service:

cargo run --bin daemon -- --help

CLI Usage

The CLI binary is located in src/bin/cli.rs. Build and run it:

cargo run --bin cli -- run
cargo run --bin cli -- submit --order-file examples/order.json

Use --help with any subcommand to see available options.

Enabling Chainstore Fallback

Some features such as cross-chain settlement rely on external services. To enable the optional chainstore fallback for fetching missing blocks via Bitswap, set the following environment variable:

export FOREST_ENABLE_CHAINSTORE_FALLBACK=1

See the Chainstore Fallback guide for more details.

Contributing

We welcome contributions! Please see CONTRIBUTING.md for development setup, coding guidelines, and instructions for submitting issues and pull requests.

License

This project is licensed under the MIT License.

About

Cross-chain CoW Protocol solver implementation in Rust with automated settlement optimization and bridge integration

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages