Skip to main content

waterpump_evm_zerox_client/
lib.rs

1//! 0x Swap API Client
2//!
3//! A Rust client for interacting with the 0x Swap API.
4//!
5//! # Example
6//!
7//! ```no_run
8//! use waterpump_evm_zerox_client::{ZeroExSwapClient, PriceRequest};
9//! use alloy_primitives::Address;
10//!
11//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
12//! let client = ZeroExSwapClient::new("your-api-key".to_string());
13//!
14//! // Get a price quote
15//! let request = PriceRequest {
16//!     chain_id: 1,
17//!     buy_token: Address::from_str("0xdac17f958d2ee523a2206206994597c13d831ec7")?,
18//!     sell_token: Address::from_str("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48")?,
19//!     sell_amount: "100000000".to_string(),
20//!     taker: None,
21//!     tx_origin: None,
22//!     recipient: None,
23//!     swap_fee_recipient: None,
24//!     swap_fee_bps: None,
25//!     swap_fee_token: None,
26//!     trade_surplus_recipient: None,
27//!     trade_surplus_max_bps: None,
28//!     gas_price: None,
29//!     slippage_bps: None,
30//!     excluded_sources: None,
31//!     sell_entire_balance: None,
32//!     enable_plasma: None,
33//! };
34//!
35//! let price = client.get_price_allowance_holder(request).await?;
36//! println!("Buy amount: {}", price.buy_amount);
37//!
38//! // Get supported chains
39//! let chains = client.get_chains().await?;
40//! for chain in chains.chains() {
41//!     println!("{}: {}", chain.chain_name, chain.chain_id);
42//! }
43//! # Ok(())
44//! # }
45//! ```
46
47pub mod client;
48pub mod error;
49pub mod serde_helpers;
50pub mod swapper;
51pub mod traits;
52pub mod types;
53
54pub use client::ZeroExSwapClient;
55pub use error::{Result, ZeroExApiError};
56pub use swapper::{
57    is_native_token, QuoteResult, SwapOptions, SwapResult, ZeroExSwapper, NATIVE_TOKEN_ADDRESS,
58};
59pub use traits::IZeroExSwapper;
60pub use types::{
61    AllowanceIssue, AllowanceType, BalanceIssue, ChainId, ChainInfo, ChainsResponse, FeeDetail,
62    Fees, Fill, Issues, Permit2Info, PriceRequest, PriceResponse, QuoteRequest, QuoteResponse,
63    Route, TokenInfo, TokenMetadata, TokenTaxInfo, Transaction,
64};