basis-points
A small, validated basis-points type for Solana-oriented Rust code.
What it provides
BasisPointsnewtype with enforced range0..=10_000- Conversions to integer types (
u16,u32,u64,u128) - Optional
rust_decimalconversions (BasisPoints↔ proportional rate in0..=1) - Optional Anchor derives via feature flags
Install
Features
decimal: enablerust_decimalconversionsanchor: enable Anchor serialization/IDL traits
Example
use BasisPoints;
let fee = new?; // 0.25%
let raw: u16 = fee.into;
assert_eq!;
# Ok::