loom_defi_uniswap_v3_math/
unsafe_math.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
use alloy::primitives::U256;

use crate::U256_1;

pub fn div_rounding_up(a: U256, b: U256) -> U256 {
    let quotient = a.wrapping_div(b);
    let remainder = a.wrapping_rem(b);
    if remainder.is_zero() {
        quotient
    } else {
        quotient + U256_1
    }
}