def METHOD_NAME(liquidity, sqrtPriceA, sqrtPriceB, roundUp):
    if sqrtPriceB > sqrtPriceA:
        sqrtPriceA, sqrtPriceB = sqrtPriceB, sqrtPriceA
    diff = sqrtPriceA - sqrtPriceB
    product_num = liquidity * diff
    product_denom = sqrtPriceA * sqrtPriceB
    if roundUp:
        return round_osmo_prec_up(round_osmo_prec_up(product_num) / round_osmo_prec_down(product_denom))
    return round_osmo_prec_down(round_osmo_prec_down(product_num) / round_osmo_prec_up(product_denom))