Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude/CODEBASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Key properties:
| [`fynd-core`](../fynd-core/CLAUDE.md) | `fynd-core/` | Pure solving logic: algorithms, worker pools, graph, feed, derived data, encoding. No HTTP deps |
| [`fynd-rpc`](../fynd-rpc/CLAUDE.md) | `fynd-rpc/` | HTTP RPC server builder (Actix Web): API handlers, middleware, `FyndRPCBuilder` |
| [`fynd-rpc-types`](../fynd-rpc-types/CLAUDE.md) | `fynd-rpc-types/` | Shared DTO types for the RPC API (request/response wire format) |
| [`fynd-nexus`](../fynd-nexus/README.md) | `fynd-nexus/` | Service binary that holds the Bebop, Hashflow and Metric connections of one chain and serves their latest prices to pods started with `--nexus-url` |
| [`fynd-nexus`](../fynd-nexus/README.md) | `fynd-nexus/` | Service binary that holds the Bebop, Hashflow and Metric connections of one chain and serves their latest prices to pods started with `--nexus-url`; with `--tycho-url` it also runs the Tycho market |
| `fynd-test-fixtures` | `test-fixtures/` | Shared types for recorded-market test fixtures: `MarketRecording`, expected outputs, test scenarios |
| [`fynd-bench-harness`](../bench-harness/README.md) | `bench-harness/` | Runs the routing algorithms over one market and writes a report: the `algorithm_bench`, `profile` and `derived` targets, the configs, the viewer. Takes an `AlgorithmRegistry`, so a crate outside this workspace can benchmark its own algorithm |

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion fynd-core/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ applications.
| Module | Description |
|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `algorithm/` | `Algorithm` trait + built-in `MostLiquidAlgorithm`, `BellmanFordAlgorithm`, `PathFrankWolfeAlgorithm`, `WaterFillAlgorithm`. Pluggable via associated graph types. `AlgorithmConfig` shared by built-ins. `AlgorithmRegistry` (`registry.rs`) maps pool-config algorithm names to custom algorithms; built-in names live in `worker_pool/registry.rs` (`AlgorithmSpawner`, `AVAILABLE_ALGORITHMS`) |
| `solver.rs` | `FyndBuilder` assembles the full pipeline (feed + gas + computations + pools + encoder + router). `Solver` runs it |
| `solver.rs` | `FyndBuilder` assembles the full pipeline (feed + gas + computations + pools + encoder + router). `Solver` runs it. `FyndBuilder::build_market` starts only the market (Tycho feed, gas price, derived data) and returns a `MarketFeed`, for a service that needs no worker pools |
| `worker_pool/` | `WorkerPool` manages dedicated OS threads. `SolverWorker` runs a prioritized select loop (shutdown > market events > derived events > tasks). `TaskQueue` is `async_channel`-based. Two rules govern component admission to a worker's graph: the free function `should_drop_component` excludes exclusive components in a `PublicOnly` pool and the pool's `exclude_protocols`; `fallback::manager::PammManager` excludes pAMMs the market does not back. The algorithm's graph and fallback pricing also exclude `algorithm_exclude_protocols`. Post-processors still see those components and receive market events filtered only by the pool rule. The first holds for the worker's life; the pAMM rule expires, so `PammManager::apply_pamm_admission` re-decides it per market event, in both directions, on `propamm_admissions_total{outcome=admitted|withheld|evicted,pool}`. `price_impact` runs after route finding: it computes `price_impact_bps` from the route token map and each swap's reported spot price, supports linear and split routes, and reads no shared `MarketState`. On failure the worker omits the field, logs at debug, and increments `worker_pool_price_impact_calculations_total{pool,outcome}` |
| `worker_pool_router/` | `WorkerPoolRouter` allocates the worker pools that serve each order (`allocation`: `OrderClass` matched by `SolverPoolHandle::serves`, which also drops pools whose `SolverPoolHandle::supports_required_tokens` is false when the request requires tokens; a handle built by hand defaults to false; when that leaves an order with no pool, the whole solve fails with `RequiredTokensNotSupported`), fans out to those, drops candidates whose pAMM fallback misses `min_amount_out`, ranks the rest by `amount_out_net_gas` descending; price guard (if enabled) validates in rank order; optionally encodes |
| `feed/` | `TychoFeed` (Tycho WebSocket plus non-Tycho sources → MarketState), `BookStream` (runs the off-chain book venues and applies their books), `book_venues/` (the `BookVenue` enum and one file per venue: its environment variables, support check, book settings and own connection; `open_book_feed` is the one place that picks a venue's feed), `GasPriceFetcher`, `MarketEvent` broadcasting, `protocol_registry` (free functions that parse and register `--protocols` entries), `metrics_sampler` (exports per-protocol market gauges on a timer). `component_filter` drops components from one worker's graph topology and incoming events; `exclusivity` classifies exclusive components. `TychoFeed` passes each Tycho update's sync status to `MarketState::update_sync_status`. It marks a protocol out of sync when Tycho reports it `Stale`, `Ended`, or `Delayed` with a block whose timestamp lags the last updated block's by more than `max_sync_lag` (`FyndBuilder::max_sync_lag`), and logs each transition. The worker keys its constraint cache on `MarketState::constraint_generation` and rejects a returned route through an unsynced pool. Fallback selection skips unsynced candidates. Components stay in `MarketState`, so a protocol routes again the block it recovers |
Expand Down
4 changes: 3 additions & 1 deletion fynd-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ pub use replay::{replay_route, ReplayError, RouteReplay};
// `rustc-hash` version itself.
pub use rustc_hash;
pub use simulation::simulator::{SimulationBlock, SimulationPurpose};
pub use solver::{FyndBuilder, PoolConfig, Solver, SolverBuildError, SolverParts, WaitReadyError};
pub use solver::{
FyndBuilder, MarketFeed, PoolConfig, Solver, SolverBuildError, SolverParts, WaitReadyError,
};
/// Processes ephemeral pending bundles against live Tycho market state. Obtained by calling
/// [`FyndBuilder::build_with_pending`](solver::FyndBuilder::build_with_pending).
pub use tycho_simulation::evm::pending::PendingBlockProcessor;
Expand Down
Loading
Loading