Skip to main content

checked_div

Function checked_div 

Source
pub fn checked_div(a: u64, b: u64) -> Result<u64, ProgramError>
Expand description

Checked u64 division: returns ArithmeticOverflow on divide-by-zero.

Every AMM price calculation involves division. This is the missing companion to checked_add/checked_sub/checked_mul.

let price = checked_div(reserve_b, reserve_a)?;