pub fn u256_to_price(amount: U256, decimals: u8) -> Result<Price>Expand description
Convert a U256 amount to [Price].
- If
decimals == 18, the value represents wei and uses the dedicated losslessPrice::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 [PRICE_RAW_MAX].