Options
All
  • Public
  • Public/Protected
  • All
Menu

A collection of utility functions to convert between price, tickIndex and sqrtPrice.

Hierarchy

  • PriceMath

Index

Constructors

Methods

  • invertPrice(price: Decimal, decimalsA: number, decimalsB: number): Decimal
  • Utility to invert the price Pb/Pa to Pa/Pb NOTE: precision is lost in this conversion

    Parameters

    • price: Decimal

      Pb / Pa

    • decimalsA: number

      Decimals of original token A (i.e. token A in the given Pb / Pa price)

    • decimalsB: number

      Decimals of original token B (i.e. token B in the given Pb / Pa price)

    Returns Decimal

    inverted price, i.e. Pa / Pb

  • invertSqrtPriceX64(sqrtPriceX64: BN): BN
  • Utility to invert the sqrtPriceX64 from X64 repr. of sqrt(Pb/Pa) to X64 repr. of sqrt(Pa/Pb) NOTE: precision is lost in this conversion

    Parameters

    • sqrtPriceX64: BN

      X64 representation of sqrt(Pb / Pa)

    Returns BN

    inverted sqrtPriceX64, i.e. X64 representation of sqrt(Pa / Pb)

  • priceToInitializableTickIndex(price: Decimal, decimalsA: number, decimalsB: number, tickSpacing: number): number
  • priceToSqrtPriceX64(price: Decimal, decimalsA: number, decimalsB: number): BN
  • priceToTickIndex(price: Decimal, decimalsA: number, decimalsB: number): number
  • sqrtPriceX64ToPrice(sqrtPriceX64: BN, decimalsA: number, decimalsB: number): Decimal
  • sqrtPriceX64ToTickIndex(sqrtPriceX64: BN): number
  • tickIndexToPrice(tickIndex: number, decimalsA: number, decimalsB: number): Decimal
  • tickIndexToSqrtPriceX64(tickIndex: number): BN

Generated using TypeDoc