pub mod aggregate;
pub mod config;
pub mod fiat;
pub mod manager;
pub mod provider;
pub mod providers;
pub mod store;
pub use aggregate::{aggregate_tick, combine, resolve_per_base, AggregateResult};
pub use config::{PriceSettings, ProviderConfig};
pub use manager::{synthesise_legacy_price_settings, PriceManager, TickReport};
pub use provider::{
PriceProvider, ProviderError, ProviderHealth, ProviderId, ProviderQuotes, Quote,
};
pub use store::{AggregatedPrice, PriceError, PriceStore};
use mostro_core::error::{MostroError, ServiceError};
#[cfg(test)]
pub(crate) fn test_price_overrides(
) -> &'static std::sync::RwLock<std::collections::HashMap<String, f64>> {
static OVERRIDES: std::sync::OnceLock<
std::sync::RwLock<std::collections::HashMap<String, f64>>,
> = std::sync::OnceLock::new();
OVERRIDES.get_or_init(|| std::sync::RwLock::new(std::collections::HashMap::new()))
}
pub fn get_bitcoin_price(currency: &str) -> Result<f64, MostroError> {
#[cfg(test)]
if let Some(price) = test_price_overrides()
.read()
.expect("price override read lock")
.get(currency)
{
return Ok(*price);
}
match PriceManager::global() {
Some(m) => m.get_price(currency),
None => Err(MostroError::MostroInternalErr(ServiceError::NoAPIResponse)),
}
}