crypto-pair 2.3.20

Parse exchange-specific symbols to unified format
Documentation
1
2
3
4
5
6
7
8
9
pub(crate) fn normalize_pair(symbol: &str) -> Option<String> {
    let (base, quote) = if symbol.ends_with("usdc") || symbol.ends_with("usdt") {
        (symbol[0..(symbol.len() - 4)].to_string(), symbol[(symbol.len() - 4)..].to_string())
    } else {
        (symbol[..(symbol.len() - 3)].to_string(), symbol[(symbol.len() - 3)..].to_string())
    };

    Some(format!("{base}/{quote}").to_uppercase())
}