Documentation
    Preparing search index...

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

    Index

    Constructors

    Methods

    • Calculate the sqrtPriceX64 & tick index slippage price boundary for a given price and slippage. Note: This function loses precision

      Parameters

      • sqrtPriceX64: BN

        the sqrtPriceX64 to apply the slippage on

      • slippage: Percentage

        the slippage to apply onto the sqrtPriceX64

      Returns { lowerBound: [BN, number]; upperBound: [BN, number] }

      the sqrtPriceX64 & tick index slippage price boundary

    • 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

    • 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)

    • Parameters

      • price: Decimal
      • decimalsA: number
      • decimalsB: number
      • tickSpacing: number

      Returns number

    • Parameters

      • price: Decimal
      • decimalsA: number
      • decimalsB: number

      Returns BN

    • Parameters

      • price: Decimal
      • decimalsA: number
      • decimalsB: number

      Returns number

    • Parameters

      • sqrtPriceX64: BN
      • decimalsA: number
      • decimalsB: number

      Returns Decimal

    • Parameters

      • tickIndex: number
      • decimalsA: number
      • decimalsB: number

      Returns Decimal