Class OrdersAPI

Represents a class for handling Orderbook (OB) related operations.

Hierarchy

  • BaseAPI
    • OrdersAPI

Constructors

Properties

premia: Premia

Methods

  • Private

    Selects the best quote from a list of quotes based on a pricing strategy.

    Parameters

    • quotes: OrderbookQuote[]

      An array of quotes.

    • size: BigNumberish

      The size of the trade.

    • Optional minimumSize: BigNumberish

      The minimum size of the trade (optional).

    Returns Promise<null | OrderbookQuote>

    • A promise resolving to the best quote from the array of quotes, or null if no valid quote is found.
  • Calculates the hash of a quote.

    Method

    calculateQuoteHash

    Parameters

    • quote: QuoteT

      The quote to hash.

    • poolAddress: string

      The address of the pool.

    Returns string

    The calculated hash of the quote.

  • Cancels the quotes stream for orderbook quotes.

    Returns void

  • Checks whether a quote is valid. Can optionally throw an error if the quote is invalid.

    Parameters

    • quote: OrderbookQuote

      The quote to check.

    • Optional size: BigNumberish

      The size of the trade (optional).

    • Optional throwError: boolean = false

      Whether to throw an error if the quote is invalid (default is false).

    Returns Promise<boolean>

    • A promise that resolves to a boolean indicating whether the quote is valid.
  • Publishes a quote.

    Parameters

    Returns Promise<null | TransactionReceipt>

    A promise that resolves to the transaction receipt or null if failed.

  • Publishes a list of quotes.

    Parameters

    Returns Promise<null | TransactionReceipt>

    A promise that resolves to the transaction receipt or null if failed.

  • Publishes an unsigned quote.

    Parameters

    • poolAddress: string

      The address of the pool.

    • quote: QuoteSaltOptionalT

      The unsigned quote to publish.

    Returns Promise<null | TransactionReceipt>

    A promise that resolves to the transaction receipt or null if failed.

  • Publishes an unsigned quote with an API key.

    Parameters

    • poolAddress: string

      The address of the pool.

    • quote: QuoteSaltOptionalT

      The unsigned quote to publish.

    Returns Promise<OrderbookQuote[]>

    A promise that resolves to the list of returned OB quotes.

  • Publishes a list of unsigned quotes.

    Parameters

    • poolAddress: string

      The address of the pool.

    • quotes: QuoteSaltOptionalT[]

      The list of unsigned quotes to publish.

    Returns Promise<null | TransactionReceipt>

    A promise that resolves to the transaction receipt or null if failed.

  • Publishes a list of unsigned quotes with an API key.

    Parameters

    • poolAddress: string

      The address of the pool.

    • quotes: QuoteSaltOptionalT[]

      The list of unsigned quotes to publish.

    Returns Promise<OrderbookQuote[]>

    A promise that resolves to the list of returned OB quotes.

  • Fetches the best quote for a specified pool address and trade size.

    Parameters

    • poolAddress: string

      The address of the pool.

    • size: BigNumberish

      The size of the trade.

    • isBuy: boolean

      Whether it's a buy or a sell.

    • Optional minimumSize: BigNumberish

      The minimum size of the trade (optional).

    • Optional referrer: string

      The address of the referrer (optional).

    • Optional taker: string

      The address of the taker (optional).

    Returns Promise<null | FillableQuote>

    • The best fillable quote, or null if no quotes available.
  • Streams quotes for the given options and executes a callback for the best quote.

    Parameters

    • options: {
          isBuy: boolean;
          minimumSize?: BigNumberish;
          poolAddress: string;
          referrer?: string;
          size: BigNumberish;
          taker?: string;
      }

      The options for the quotes stream:

      • isBuy: boolean

        Whether it's a buy or a sell.

      • Optional minimumSize?: BigNumberish

        The minimum size of the trade (optional).

      • poolAddress: string

        The address of the pool.

      • Optional referrer?: string

        The address of the referrer (optional).

      • size: BigNumberish

        The size of the trade.

      • Optional taker?: string
    • callback: ((quote) => void)

      The callback to execute for the best quote.

    Returns Promise<void>

  • Private

    Converts a quote into a fillable quote, with additional properties required for execution.

    Parameters

    • poolAddress: string

      The address of the pool.

    • size: BigNumberish

      The size of the trade.

    • quote: QuoteWithSignatureT

      The quote to be converted.

    • Optional createdAt: number

      The timestamp of the quote's creation (optional).

    • Optional referrer: string

      The address of the referrer (optional).

    Returns Promise<FillableQuote>

    • A promise resolving to the fillable quote.
  • Calculates the hash of a quote. This is a static method.

    Parameters

    • quote: QuoteT

      The quote to hash.

    • poolAddress: string

      The address of the pool.

    • chainId: number

      The id of the chain.

    Returns string

    The calculated hash of the quote.

Generated using TypeDoc