Skip to main content

base_to_quote

Function base_to_quote 

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

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

Formula: quote_amount = (base_amount * price) / PRICE_SCALE

Uses U256 for intermediate multiplication to prevent overflow.

§Arguments

  • base_amount - Amount of base tokens
  • tick - Price tick
  • rounding - Rounding direction

§Returns

Quote token amount, or None if result exceeds u128