Skip to main content

parse_quantity_from_ticks

Function parse_quantity_from_ticks 

Source
pub fn parse_quantity_from_ticks(ticks: i64, decimals: u8) -> Result<Quantity>
Expand description

Converts a Lighter base-amount tick count into a Nautilus [Quantity].

Order sizes on the wire are signed i64 multiples of 10^-decimals base-asset units. Nautilus [Quantity] is non-negative, so a negative ticks value is rejected: callers (e.g. position parsers) extract the sign separately before invoking this helper.

Conversion routes through [Decimal] and [Quantity::from_decimal_dp] so out-of-range tick counts return an error rather than panicking inside the unchecked mantissa-exponent constructor.

ยงErrors

Returns an error if decimals exceeds MAX_DECIMALS, if ticks is negative, or if the resulting value exceeds the [Quantity] range.