pub fn bps_of(amount: u64, basis_points: u16) -> Result<u64, ProgramError>Expand description
Compute basis-point fee: amount * bps / 10_000 (floor).
Uses u128 intermediate to prevent overflow. Nearly every DeFi program computes fees in basis points — this one-liner eliminates a whole class of bugs.
ⓘ
let fee = bps_of(trade_amount, 30)?; // 0.3% fee