Skip to main content

fynd_core/
lib.rs

1#![deny(missing_docs)]
2//! Pure solving logic for the [Fynd](https://fynd.xyz) DEX router.
3//!
4//! This crate contains the route-finding algorithms, market-data pipeline, and encoder that
5//! powers Fynd. It has **no HTTP dependencies** and can be embedded directly in any application.
6//!
7//! For documentation, guides, and API reference see **<https://docs.fynd.xyz/>**.
8//!
9//! # Use cases
10//!
11//! - **Standalone routing** — embed Fynd's algorithms directly without running an HTTP server.
12//! - **Custom algorithms** — implement the [`Algorithm`] trait and plug in via
13//!   [`FyndBuilder::with_algorithm`](solver::FyndBuilder).
14//! - **HTTP server** — use the [`fynd-rpc`](https://crates.io/crates/fynd-rpc) crate, which wraps
15//!   this crate with Actix Web.
16//!
17//! # Quick start
18//!
19//! See the [Fynd quickstart](https://docs.fynd.xyz/get-started/quickstart) to run a local
20//! instance, or the [custom algorithm guide](https://docs.fynd.xyz/guides/custom-algorithm)
21//! to implement your own routing strategy.
22
23/// Route-finding algorithms. Includes [`MostLiquidAlgorithm`] and the
24/// pluggable [`Algorithm`] trait.
25pub mod algorithm;
26/// Derived data computations: spot prices, pool depths, and gas prices.
27pub mod derived;
28/// Encodes solved routes into ABI-encoded on-chain calldata via Tycho's router contracts.
29pub mod encoding;
30/// Market data feed: Tycho WebSocket integration, gas price fetching, and protocol registry.
31pub mod feed;
32pub(crate) mod graph;
33/// External price validation for quotes.
34pub mod price_guard;
35/// [`FyndBuilder`](solver::FyndBuilder) assembles the full pipeline and returns a
36/// [`Solver`](solver::Solver).
37pub mod solver;
38/// Core domain types: [`Order`](types::Order), [`Route`](types::Route), [`Quote`](types::Quote),
39/// etc.
40pub mod types;
41/// Multi-threaded solver pool management with pluggable algorithm registry.
42pub mod worker_pool;
43/// Request orchestration: fans out orders to all solver pools and selects the best result.
44pub mod worker_pool_router;
45
46// Re-export commonly used types for convenience
47pub use algorithm::{Algorithm, AlgorithmConfig, AlgorithmError, MostLiquidAlgorithm};
48// Required for implementing the Algorithm trait externally
49pub use derived::computation::ComputationRequirements;
50pub use price_guard::config::PriceGuardConfig;
51pub use solver::{FyndBuilder, PoolConfig, Solver, SolverBuildError, SolverParts, WaitReadyError};
52pub use types::{
53    BlockInfo, ClientFeeParams, ComponentId, EncodingOptions, FeeBreakdown, Order, OrderQuote,
54    OrderSide, OrderValidationError, PermitDetails, PermitSingle, Quote, QuoteOptions,
55    QuoteRequest, QuoteStatus, Route, RouteValidationError, SingleOrderQuote, SolveError,
56    SolveResult, Swap, TaskId, Transaction, UserTransferType,
57};
58pub use worker_pool::{
59    pool::{WorkerPool, WorkerPoolBuilder, WorkerPoolConfig},
60    registry::UnknownAlgorithmError,
61    TaskQueueHandle,
62};
63pub use worker_pool_router::{config::WorkerPoolRouterConfig, SolverPoolHandle, WorkerPoolRouter};