Skip to main content

quote_to_base

Function quote_to_base 

Source
pub fn quote_to_base(
    quote_amount: u128,
    tick: i16,
    rounding: RoundingDirection,
) -> Option<u128>
Expand description

Convert quote token amount to base token amount at a given tick.

Formula: base_amount = (quote_amount * PRICE_SCALE) / price

Uses U256 for intermediate multiplication to prevent overflow.

§Arguments

  • quote_amount - Amount of quote tokens
  • tick - Price tick
  • rounding - Rounding direction

§Returns

Base token amount, or None if result exceeds u128