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
59
60
61
62
//! Derived data computation system.
//!
//! This module provides a framework for computing derived market data
//! (token prices, pool depths, spot prices, etc.) from raw market data.
//!
//! # Architecture
//!
//! - **Computations**: Implement the `DerivedComputation` trait to define new data types
//! - **Manager**: `ComputationManager` explicitly owns each computation type
//! - **Store**: `DerivedDataStore` with typed fields (no type erasure)
//! - **Events**: Broadcast notifications when computations complete
//! - **Tracker**: Per-worker readiness tracking based on algorithm requirements
//!
//! # Computation Dependencies
//!
//! Computations may depend on other computations' outputs via the `DerivedDataStore`.
//! The dependency graph must be respected when running computations:
//!
//! ```text
//! SpotPriceComputation
//! / \
//! v v
//! PoolDepthComputation TokenGasPriceComputation
//! ```
//!
//! - **SpotPriceComputation**: No dependencies, computes spot prices for all pools
//! - **PoolDepthComputation**: Depends on `spot_prices`
//! - **TokenGasPriceComputation**: Depends on `spot_prices` and `gas_price` (from market data)
//!
//! # Example
//!
//! ```ignore
//! // Create the computation manager
//! let config = ComputationManagerConfig::new(weth_address);
//! let manager = ComputationManager::new(config, shared_market_data)?;
//!
//! // Get a reference to the store for workers
//! let store = manager.store();
//!
//! // Handle market events (typically from TychoFeed broadcast)
//! manager.handle_event(&event)?;
//!
//! // Workers can read derived data
//! let guard = store.read().await;
//! if let Some(prices) = guard.token_prices() {
//! // Use prices...
//! }
//! ```
pub
pub
pub
pub
pub
pub
// Only export the public API: manager, config, store, and shared reference type
pub use FailedItemError;
pub use ;
pub use DerivedData;