Class OptionAPI

This class provides an API for interacting with options in the Premia system. It includes methods for fetching default base and quote tokens, as well as default token pairs. All methods are asynchronous and return promises.

Hierarchy

  • BaseAPI
    • OptionAPI

Constructors

Properties

premia: Premia

Methods

  • Filters a list of pool objects according to the provided options.

    Parameters

    • pools: PoolMinimal[]

      An array of pool objects to filter.

    • Optional options: {
          maturity?: BigNumberish;
          priceOracle?: string;
          quoteTokens?: string[];
          strike?: BigNumberish;
      }

      An object containing filter conditions.

      • Optional maturity?: BigNumberish

        The maturity time.

      • Optional priceOracle?: string

        The address of the price oracle (optional).

      • Optional quoteTokens?: string[]

        Array of quote tokens' addresses (optional).

      • Optional strike?: BigNumberish

        The strike price.

    Returns PoolMinimal[]

    • The filtered array of pool objects.
  • Parses a token input to return a token address string.

    Parameters

    • token: TokenOrAddress

      The token input which can be either a Token object or a string representing the address.

    Returns string

    • The token address as a string.
  • Cancels all ongoing streams.

    Returns Promise<void>

  • Cancels the streaming of quotes for the provided pool address, isCall, and isBuy parameters.

    Parameters

    • poolAddress: string

      The pool address.

    • isCall: boolean

      Whether the quote is for a call option.

    • isBuy: boolean

      Whether the quote is for a buy or sell.

    Returns Promise<void>

  • Returns an array of default base token information based on the chain ID.

    Returns TokenInfo[]

    An array of TokenInfo objects.

  • Fetches an array of default base tokens based on the chain ID.

    Returns Promise<Token[]>

    A promise that resolves to an array of Token objects.

  • Returns the default pairs of tokens based on the chain ID.

    Returns undefined | PairList

    A PairList object or undefined if there are no default pairs for the given chain ID.

  • Returns an array of default quote token information based on the chain ID.

    Returns TokenInfo[]

    An array of TokenInfo objects.

  • Fetches an array of default quote tokens based on the chain ID.

    Returns Promise<Token[]>

    A promise that resolves to an array of Token objects.

  • Fetches an array of default token pairs based on the chain ID.

    Returns Promise<TokenPair[]>

    A promise that resolves to an array of TokenPair objects.

  • Gets the profit or loss for a given pool, action (buy/sell), and premium.

    Parameters

    • poolAddress: string

      The address of the pool.

    • isBuy: boolean

      Whether the action is a buy.

    • premium: BigNumberish

      The premium for the transaction.

    Returns Promise<bigint>

    • A promise that resolves to the calculated profit or loss.
  • Calculates the increment to use for strike prices based on the spot price.

    Parameters

    • spotPrice: BigNumberish

      The spot price.

    • decimals: number = ...

      The number of decimal places for the price (defaults to WAD_DECIMALS).

    Returns bigint

    • The increment for the strike prices.
  • Generates a list of suggested strike prices based on the spot price.

    Parameters

    • spotPrice: BigNumberish

      The spot price.

    • decimals: number = ...

      The number of decimal places for the price (defaults to WAD_DECIMALS).

    Returns bigint[]

    • An array of suggested strike prices.
  • Provides the best quotes available for each pool that matches the provided options. The method is cached for a second to improve performance.

    Parameters

    • options: {
          isBuy: boolean;
          isCall: boolean;
          maturity: BigNumberish;
          minimumSize?: BigNumberish;
          priceOracle?: string;
          quoteTokens?: string[];
          referrer?: string;
          size: BigNumberish;
          strike: BigNumberish;
          taker?: string;
          token: TokenOrAddress;
      }

      Multi-quote options object.

      • isBuy: boolean

        Whether the quote is for a buy or sell.

      • isCall: boolean

        Whether the quote is for a call option.

      • maturity: BigNumberish

        The maturity time.

      • Optional minimumSize?: BigNumberish

        The minimum size of the trade (optional).

      • Optional priceOracle?: string

        The address of the price oracle (optional).

      • Optional quoteTokens?: string[]

        Array of quote tokens' addresses (optional).

      • Optional referrer?: string

        The address of the referrer (optional).

      • size: BigNumberish

        The size of the trade.

      • strike: BigNumberish

        The strike price.

      • Optional taker?: string

        The address of the taker (optional).

      • token: TokenOrAddress

        The token object or address.

    Returns Promise<(null | FillableQuote)[]>

    • A promise that resolves to an array of the best quotes.
  • Provides the best quote available from different sources (RFQ, Pool, Vault) based on the provided options. The method is cached for a second to improve performance.

    Parameters

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

      Quote options object.

      • isBuy: boolean

        Whether the quote is a buy or sell.

      • Optional minimumSize?: BigNumberish

        The minimum size of the trade (optional).

      • poolAddress: string

        The pool's address.

      • Optional referrer?: string

        The address of the referrer (optional).

      • size: BigNumberish

        The size of the trade.

      • Optional taker?: string

        The address of the taker (optional).

    Returns Promise<null | FillableQuote>

    • A promise that resolves to the best quote.
  • Provides the best quotes available from each provider (RFQ, Pool, Vault) for each pool that matches the provided options. The method is cached for a second to improve performance.

    Parameters

    • options: {
          isBuy: boolean;
          isCall: boolean;
          maturity: BigNumberish;
          minimumSize?: BigNumberish;
          priceOracle?: string;
          quoteTokens?: string[];
          referrer?: string;
          size: BigNumberish;
          strike: BigNumberish;
          taker?: string;
          token: TokenOrAddress;
      }

      Quotes by provider options object.

      • isBuy: boolean

        Whether the quote is for a buy or sell.

      • isCall: boolean

        Whether the quote is for a call option.

      • maturity: BigNumberish

        The maturity time.

      • Optional minimumSize?: BigNumberish

        The minimum size of the trade (optional).

      • Optional priceOracle?: string

        The address of the price oracle (optional).

      • Optional quoteTokens?: string[]

        Array of quote tokens' addresses (optional).

      • Optional referrer?: string

        The address of the referrer (optional).

      • size: BigNumberish

        The size of the trade.

      • strike: BigNumberish

        The strike price.

      • Optional taker?: string

        The address of the taker (optional).

      • token: TokenOrAddress

        The token object or address.

    Returns Promise<{
        [provider: string]: (FillableQuote | null)[];
    }>

    • A promise that resolves to an object where each key is a provider and the value is an array of the best quotes.
  • Streams best quotes available for each pool that matches the provided options. Quotes are updated in real-time and passed to a callback.

    Parameters

    • options: {
          isBuy: boolean;
          isCall: boolean;
          maturity: BigNumberish;
          minimumSize?: BigNumberish;
          priceOracle?: string;
          quoteTokens?: string[];
          referrer?: string;
          size: BigNumberish;
          strike: BigNumberish;
          taker?: string;
          token: TokenOrAddress;
      }

      Quote options object.

      • isBuy: boolean

        Whether the quote is for a buy or sell.

      • isCall: boolean

        Whether the quote is for a call option.

      • maturity: BigNumberish

        The maturity time.

      • Optional minimumSize?: BigNumberish

        The minimum size of the trade (optional).

      • Optional priceOracle?: string

        The address of the price oracle (optional).

      • Optional quoteTokens?: string[]

        Array of quote tokens' addresses (optional).

      • Optional referrer?: string

        The address of the referrer (optional).

      • size: BigNumberish

        The size of the trade.

      • strike: BigNumberish

        The strike price.

      • Optional taker?: string

        The address of the taker (optional).

      • token: TokenOrAddress

        The token object or address.

    • callback: ((quotes) => void)

      Function to be called when new quotes are available.

        • (quotes): void
        • Parameters

          Returns void

    Returns Promise<void>

  • Streams the best quotes available from each provider (RFQ, Pool, Vault) for the pool that matches the provided options. The best quote among all providers is updated in real-time and passed to a callback.

    Parameters

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

      Quote options object.

      • isBuy: boolean

        Whether the quote is for a buy or sell.

      • Optional minimumSize?: BigNumberish

        The minimum size of the trade (optional).

      • poolAddress: string

        The pool address.

      • Optional referrer?: string

        The address of the referrer (optional).

      • size: BigNumberish

        The size of the trade.

      • Optional taker?: string

        The address of the taker (optional).

    • callback: ((quote) => void)

      Function to be called when a new best quote is available.

        • (quote): void
        • Parameters

          Returns void

    Returns Promise<void>

  • Streams best quotes available from each provider (RFQ, Pool, Vault) for each pool that matches the provided options. Quotes are updated in real-time and passed to a callback.

    Parameters

    • options: {
          isBuy: boolean;
          isCall: boolean;
          maturity: BigNumberish;
          minimumSize?: BigNumberish;
          priceOracle?: string;
          quoteTokens?: string[];
          referrer?: string;
          size: BigNumberish;
          strike: BigNumberish;
          taker?: string;
          token: TokenOrAddress;
      }

      Quote options object.

      • isBuy: boolean

        Whether the quote is for a buy or sell.

      • isCall: boolean

        Whether the quote is for a call option.

      • maturity: BigNumberish

        The maturity time.

      • Optional minimumSize?: BigNumberish

        The minimum size of the trade (optional).

      • Optional priceOracle?: string

        The address of the price oracle (optional).

      • Optional quoteTokens?: string[]

        Array of quote tokens' addresses (optional).

      • Optional referrer?: string

        The address of the referrer (optional).

      • size: BigNumberish

        The size of the trade.

      • strike: BigNumberish

        The strike price.

      • Optional taker?: string

        The address of the taker (optional).

      • token: TokenOrAddress

        The token object or address.

    • callback: ((quotes) => void)

      Function to be called when new quotes are available.

        • (quotes): void
        • Parameters

          Returns void

    Returns Promise<void>

Generated using TypeDoc