pub fn get_fraction(ratio_f64: f64) -> anyhow::Result<(NonZeroU64, NonZeroU64)> {
    let rate_fraction = Fraction::from(ratio_f64);
    if rate_fraction.sign() == Some(fraction::Sign::Minus) {
        return Err(anyhow::anyhow!("number is negative"));
    }

    let numerator = NonZeroU64::new(
        *rate_fraction
            .numer()
            .ok_or(anyhow::anyhow!("number is not rational"))?,
    )
    .ok_or(anyhow::anyhow!("numerator is zero"))?;
    let denominator = NonZeroU64::new(
        *rate_fraction
            .denom()
            .ok_or(anyhow::anyhow!("number is not rational"))?,
    )
    .ok_or(anyhow::anyhow!("denominator is zero"))?;

    Ok((numerator, denominator))
}
Using the base token price and eth price, calculate the fraction of the base token to eth.
core/lib/external_price_api/src/utils.rs