Skip to main content

fynd_client/
lib.rs

1//! Rust client for the [Fynd](https://fynd.exchange) DEX router.
2//!
3//! `fynd-client` lets you request swap quotes, build signable transaction payloads, and
4//! broadcast signed orders through the Fynd RPC API — all from a single typed interface.
5//!
6//! # Constructing a client
7//!
8//! Use [`FyndClientBuilder`] to configure and build a [`FyndClient`]:
9//!
10//! ```rust,no_run
11//! # use fynd_client::{FyndClient, FyndClientBuilder};
12//! # #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> {
13//! let client = FyndClientBuilder::new(
14//!     "https://rpc.fynd.exchange",
15//!     "https://mainnet.infura.io/v3/YOUR_KEY",
16//! )
17//! .build()
18//! .await?;
19//! # Ok(()) }
20//! ```
21//!
22//! # Minimal quote example
23//!
24//! ```rust,no_run
25//! # use fynd_client::{FyndClientBuilder, Order, OrderSide, QuoteOptions, QuoteParams};
26//! # use bytes::Bytes;
27//! # use num_bigint::BigUint;
28//! # #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> {
29//! # let client = FyndClientBuilder::new("https://rpc.fynd.exchange", "https://example.com")
30//! #     .build().await?;
31//! let weth: Bytes = Bytes::copy_from_slice(&[0xC0; 20]); // placeholder
32//! let usdc: Bytes = Bytes::copy_from_slice(&[0xA0; 20]); // placeholder
33//! let sender: Bytes = Bytes::copy_from_slice(&[0xd8; 20]); // placeholder
34//!
35//! let order = Order::new(
36//!     weth,
37//!     usdc,
38//!     BigUint::from(1_000_000_000_000_000_000u64), // 1 WETH (18 decimals)
39//!     OrderSide::Sell,
40//!     sender,
41//!     None,
42//! );
43//!
44//! let quote = client
45//!     .quote(QuoteParams::new(order, QuoteOptions::default()))
46//!     .await?;
47//!
48//! println!("amount out: {}", quote.amount_out());
49//! # Ok(()) }
50//! ```
51
52pub use client::{
53    ApprovalParams, ExecutionOptions, FyndClient, FyndClientBuilder, RetryConfig, SigningHints,
54    StorageOverrides,
55};
56pub use error::{ErrorCode, FyndError};
57pub use signing::{
58    ApprovalPayload, ExecutionReceipt, FyndPayload, MinedTx, SettledOrder, SignedApproval,
59    SignedSwap, SwapPayload, TxReceipt,
60};
61pub use types::{
62    BackendKind, BlockInfo, ClientFeeParams, EncodingOptions, FeeBreakdown, HealthStatus,
63    InstanceInfo, Order, OrderSide, PermitDetails, PermitSingle, Quote, QuoteOptions, QuoteParams,
64    QuoteStatus, Route, Swap, Transaction, UserTransferType,
65};
66
67mod client;
68mod error;
69mod mapping;
70mod signing;
71mod types;