Skip to main content

Module math

Module math 

Source
Expand description

Tick / lot price conversions.

Enums§

LotConversionError

Constants§

MAX_UI_ORDER_SIZE_UNITS
Release-safety ceiling for user-entered base-asset size. This is far above normal UI presets but prevents pathological input from ever reaching an on-chain lot conversion.

Functions§

base_lots_to_units
Converts on-chain base lots into the absolute token unit size float.
pct_change_24h
24h percentage change from mark vs. prior-day mark; 0.0 when prev_day is zero.
phoenix_decimal_to_num_base_lots
Convert Phoenix HTTP Decimal (value, decimals) into num_base_lots for a market’s base_lot_decimals (equivalent to size * 10^base_lot_decimals with exact rationals). When scaling down (base_lot_decimals < value_decimals), truncates toward zero like an exact integer quotient.
ticks_to_price
Converts on-chain price ticks into an absolute USD float representation.
ui_size_to_num_base_lots
Converts a user-entered base-asset size into on-chain base lots with explicit validation. Values are floored to whole lots, matching the previous truncate-toward-zero behavior, but invalid and overflowing inputs now return an error instead of silently saturating through as u64.