1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//! # cowprotocol
//!
//! Crate name on crates.io. Hosted at
//! [`cowdao-grants/cow-rs`](https://github.com/cowdao-grants/cow-rs).
//!
//! Rust SDK for the [CoW Protocol](https://cow.fi).
//!
//! ## Surface
//!
//! - [`OrderData`]: the 12-field signed payload, with
//! [`OrderData::hash_struct`] for EIP-712 hashing,
//! [`OrderData::uid`] for the 56-byte order identifier and
//! [`OrderData::sign`] for ECDSA signing.
//! - [`DomainSeparator`], [`hashed_eip712_message`] and
//! [`hashed_ethsign_message`] for the typed-data envelope.
//! - [`Signature`], [`EcdsaSignature`] and [`SignatureError`] covering
//! EIP-712, EthSign, EIP-1271 and PreSign schemes.
//! - [`Chain`]: all eleven chains the orderbook supports
//! (Mainnet, Bnb, Gnosis, Polygon, Base, Plasma, Arbitrum One, Avalanche,
//! Ink, Linea, Sepolia), with their `api.cow.fi` URL slugs.
//! - [`OrderBookApi`]: async client for the orderbook HTTP API, with
//! methods for quoting, posting, lookup, cancellation, trade and account
//! queries, native-price lookups and app-data pinning.
//! - [`OrderCreation`], [`OrderCancellation`] and [`OrderCancellations`]
//! for the submission and cancellation flows.
//! - [`AppDataHash`] and [`AppDataDoc`] for the canonical metadata
//! document and its keccak digest.
//! - [`EthFlowOrder`] plus the [`ETH_FLOW_PRODUCTION`] /
//! [`ETH_FLOW_STAGING`] addresses for native-ETH sells via the
//! periphery EthFlow contract.
//! - [`GPv2Settlement`] and [`GPv2OrderData`] for typed contract bindings,
//! plus [`GPV2_SETTLEMENT`], [`GPV2_VAULT_RELAYER`], [`WETH9`] and
//! [`ERC20`] address constants.
//! - [`ConditionalOrderParams`], [`Proof`] and [`PollOutcome`] for the
//! `ComposableCoW` conditional-order primitives, plus the
//! [`COMPOSABLE_COW`], [`EXTENSIBLE_FALLBACK_HANDLER`] and
//! [`CURRENT_BLOCK_TIMESTAMP_FACTORY`] address constants.
//! - [`TwapData`] / [`TwapStaticInput`] for the canonical TWAP handler
//! `staticInput`, locked byte-conformant against cow-py's
//! `test_twap.py` vector.
//! - [`Multiplexer`] plus [`conditional_order_leaf`] / [`verify_proof`]
//! for batched conditional orders behind a single
//! `ComposableCoW.setRoot`, matching the contract's OpenZeppelin
//! sorted-pair merkle proof verifier exactly.
//!
//! ## Quote example
//!
//! ```no_run
//! use cowprotocol::{Chain, OrderBookApi, QuoteRequest};
//! use alloy_primitives::{Address, U256, address};
//!
//! # async fn run() -> cowprotocol::Result<()> {
//! let api = OrderBookApi::new(Chain::Mainnet);
//! let request = QuoteRequest::sell_amount_before_fee(
//! address!("A0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"), // USDC
//! address!("6B175474E89094C44Da98b954EedeAC495271d0F"), // DAI
//! address!("70997970C51812dc3A010C7d01b50e0d17dc79C8"),
//! U256::from(100_000_000_u64),
//! );
//! let response = api.get_quote(&request).await?;
//! println!("buy amount: {}", response.quote.buy_amount);
//! # Ok(()) }
//! ```
//!
//! See `examples/post_order.rs` for the full sign-and-submit flow on
//! Sepolia.
//!
//! ## Parity references
//!
//! - [`cowprotocol/cow-sdk`](https://github.com/cowprotocol/cow-sdk) (TypeScript, canonical)
//! - [`cowdao-grants/cow-py`](https://github.com/cowdao-grants/cow-py) (Python)
//! - [`cowprotocol/services`](https://github.com/cowprotocol/services) (Rust, server-side)
//!
//! ## Licence
//!
//! GPL-3.0-or-later, matching the upstream `cowdao-grants/cow-rs` repository.
//! Portions of the source are adapted from [`cowprotocol/services`] under its
//! MIT OR Apache-2.0 licence.
//!
//! [`cowprotocol/services`]: https://github.com/cowprotocol/services
pub use crate::;