Skip to main content

Module utils

Module utils 

Source
Expand description

Shared numeric helpers for quote math.

Functionsยง

add_slippage
value * (10_000 + bps) / 10_000. Saturates on the rare case the multiplication itself overflows u64.
mul_div_u128
a * b / c in u128, surfacing overflow as QuoteError::MathOverflow.
slippage_bounds
(value - delta, value + delta) with delta = value * bps / 10_000; None on overflow.
sub_slippage
value * (10_000 - bps) / 10_000. bps larger than 10_000 saturates to 0.