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
//! V2 protocol support for the Polymarket CTF Exchange.
//!
//! V2 changes the EIP-712 signed struct to 11 fields — dropping `taker`,
//! `nonce`, `expiration`, and `feeRateBps`; adding `timestamp`, `metadata`,
//! and `builder`. The domain version is bumped from `"1"` to `"2"`.
//! [`SignatureType::Poly1271`] is added for smart-contract wallet signers.
//!
//! `expiration` remains part of the API payload but is **not** covered by
//! the EIP-712 signature.
//!
//! # Example
//!
//! ```no_run
//! use alloy_primitives::{address, U256};
//! use alloy_signer_local::PrivateKeySigner;
//! use rs_order_utils::v2::{ExchangeOrderBuilder, OrderData};
//! use rs_order_utils::Side;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let signer = PrivateKeySigner::random();
//! let maker = signer.address();
//!
//! let builder = ExchangeOrderBuilder::new(
//! address!("4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E"),
//! 137,
//! signer,
//! None,
//! );
//!
//! let order = OrderData {
//! maker,
//! signer: None,
//! token_id: U256::from(123456u64),
//! maker_amount: U256::from(1_000_000u64),
//! taker_amount: U256::from(950_000u64),
//! side: Side::Buy,
//! signature_type: None,
//! timestamp: None,
//! metadata: None,
//! builder: None,
//! expiration: None,
//! };
//!
//! let signed = builder.build_signed_order(order).await?;
//! println!("signature: {}", signed.signature);
//! # Ok(())
//! # }
//! ```
pub use ExchangeOrderBuilder;
pub use ;
pub use ;
pub use SignatureType;