evm-dex-pool 1.2.2

Reusable EVM DEX pool implementations (UniswapV2, UniswapV3, ERC4626) with traits and math
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use alloy::primitives::U256;

const U256_1: U256 = U256::from_limbs([1, 0, 0, 0]);

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
    }
}