cowp

Crates.iocowp
lib.rscowp
version0.1.1
created_at2026-01-17 12:48:46.819481+00
updated_at2026-01-22 21:40:24.801033+00
descriptionUnofficial Rust client for the CoW Protocol API (cowp)
homepage
repositoryhttps://github.com/yldfi/yldfi-rs/tree/main/crates/cowp
max_upload_size
id2050400
size72,003
michaeldim (michaeldim)

documentation

README

yld_fi

cowswap

Unofficial Rust client for the CoW Protocol (CowSwap) API

crates.io MIT License

Features

  • MEV Protection - Batch auctions protect against frontrunning
  • Gasless Trading - Fees are taken from output tokens
  • Coincidence of Wants - Direct peer-to-peer matching for better prices
  • Quote API - Get swap quotes (free, no authentication)
  • Order Management - Create, query, and cancel orders
  • Trade History - Query executed trades
  • Multi-chain - Supports Ethereum, Gnosis Chain, and Arbitrum

Installation

[dependencies]
cowp = "0.1"
tokio = { version = "1", features = ["full"] }

Quick Start

use cowp::{Client, Chain, QuoteRequest};

#[tokio::main]
async fn main() -> Result<(), cowp::Error> {
    let client = Client::new()?;

    // Get a sell quote (exact input)
    let request = QuoteRequest::sell(
        "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
        "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
        "1000000000000000000", // 1 WETH
        "0xYourAddress",
    );

    let quote = client.get_quote(None, &request).await?;
    println!("Output: {} USDC", quote.quote.buy_amount);
    println!("Fee: {} WETH", quote.quote.fee_amount);

    Ok(())
}

Buy Orders (Exact Output)

use cowp::{Client, QuoteRequest};

let request = QuoteRequest::buy(
    "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
    "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
    "1000000000", // Want exactly 1000 USDC
    "0xYourAddress",
);

let quote = client.get_quote(None, &request).await?;
println!("You will pay: {} WETH", quote.quote.sell_amount);

Multi-Chain Support

Chain API URL
Ethereum https://api.cow.fi/mainnet
Gnosis https://api.cow.fi/xdai
Arbitrum https://api.cow.fi/arbitrum_one
Sepolia https://api.cow.fi/sepolia

License

MIT

Commit count: 46

cargo fmt