Skip to main content

checked_div_ceil

Function checked_div_ceil 

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

Checked ceiling division: ceil(a / b). Returns ArithmeticOverflow on zero.

Rounds up instead of truncating. Use this for fee calculations and minimum-output computations where truncation would favor the user at the protocol’s expense.

let fee = checked_div_ceil(amount * fee_rate, 10_000)?;