Class PricingAPI

Represents a class for handling pricing comparison operations.

Hierarchy

  • BaseAPI
    • PricingAPI

Constructors

Properties

Methods

Constructors

Properties

premia: Premia

Methods

  • Evaluates and returns the best quote from a set of quotes based on the provided size and other options.

    The function initially filters out null and undefined quotes. If all quotes are null or undefined, it returns null. If the pool keys of the quotes are not identical, it emits a warning unless ignoreWarnings is set to true.

    It then filters the quotes based on the minimum size and the deadline. Only RFQ quotes can be filtered by deadline. The size of the quote should be greater or equal to the minimum size provided.

    It finally compares all the quotes and returns the one deemed the best using the better method.

    Parameters

    • quotes: (null | QuoteOrFillableQuoteT)[]

      Array of quotes or fillable quotes to be compared.

    • size: BigNumberish

      The size to consider when comparing quotes.

    • Optional minimumSize: BigNumberish

      The minimum size to filter quotes by. If not provided, size will be used.

    • Optional ignoreWarnings: boolean = false

      Whether to ignore warnings if pool keys for quotes compared are not identical.

    Returns null | QuoteOrFillableQuoteT

    The best quote from the provided set, or null if no quotes pass the filtering conditions.

  • Compares two quotes and returns the better one based on multiple factors.

    The function considers various factors including deadline, size, price, origin and timestamp (for RFQs) in determining which quote is better. If both quotes are essentially equivalent, quoteA is returned.

    Throws

    If minimum size is greater than size.

    Throws

    If quotes have opposite directions.

    Parameters

    • quoteA: null | QuoteOrFillableQuoteT

      The first quote or fillable quote to be compared.

    • quoteB: null | QuoteOrFillableQuoteT

      The second quote or fillable quote to be compared.

    • size: BigNumberish

      The size to consider when comparing quotes.

    • Optional minimumSize: BigNumberish

      The minimum size to filter quotes by. If not provided, size will be used.

    • Optional ignoreWarnings: boolean = false

      Whether to ignore warnings if pool keys for quotes compared are not identical.

    Returns null | QuoteOrFillableQuoteT

    The better quote from the two provided, or null if neither quote passes the comparison conditions.

  • Calculates the limit of a premium based on maximum slippage percentage.

    The function computes the limit for a premium considering a given maximum slippage percentage. If the operation is a 'buy', the premium limit is increased by the slippage offset, otherwise, for a 'sell', the premium limit is decreased by the slippage offset.

    Parameters

    • premium: BigNumberish

      The premium value used as the base for limit calculation.

    • maxSlippagePercent: BigNumberish

      The maximum slippage percentage to calculate the offset.

    • isBuy: boolean

      A flag indicating whether the operation is a 'buy' or 'sell'.

    Returns BigNumberish

    The calculated limit for the premium considering the slippage.

Generated using TypeDoc