use crypto_market_type::MarketType;
pub(crate) fn normalize_pair(symbol: &str) -> Option<String> {
if symbol.ends_with("-PERP") {
let base = symbol.strip_suffix("-PERP").unwrap();
Some(format!("{base}/USD"))
} else if symbol.contains("-MOVE-") {
let v: Vec<&str> = symbol.split('-').collect();
Some(format!("{}/USD", v[0]))
} else if symbol.contains("BVOL/") || symbol.contains('/') {
Some(symbol.to_string())
} else if let Some(pos) = symbol.rfind('-') {
let base = &symbol[..pos];
Some(format!("{base}/USD"))
} else {
Some(format!("{symbol}/USD"))
}
}
pub(crate) fn get_market_type(symbol: &str) -> MarketType {
if symbol.ends_with("-PERP") {
MarketType::LinearSwap
} else if symbol.contains("-MOVE-") {
MarketType::Move
} else if symbol.contains("BVOL/") {
MarketType::BVOL
} else if symbol.contains('/') {
MarketType::Spot
} else if symbol.contains('-') {
MarketType::LinearFuture
} else {
MarketType::Unknown
}
}