pub fn u256_to_quantity(amount: U256, decimals: u8) -> Result<Quantity>Expand description
Convert a U256 amount to [Quantity].
- If
decimals == 18, the value represents wei and uses the dedicated losslessQuantity::from_weiconstructor. - Other precisions use checked integer scaling and clamp
decimalsto [FIXED_PRECISION]. Discarded source digits are rounded half to even.
ยงErrors
Returns an error if scaling overflows or the result exceeds [QUANTITY_RAW_MAX].