import { BigNumberish, Provider, TransactionReceipt } from 'ethers'; import { BaseAPI } from './baseAPI'; import { FillableQuote, QuoteSaltOptionalT, QuoteT, QuoteWithSignature, QuoteWithSignatureT, OrderbookQuote, PoolMinimal, PoolKey } from '../entities'; /** * Represents a class for handling Orderbook (OB) related operations. * * @class OrdersAPI * @extends {BaseAPI} */ export declare class OrdersAPI extends BaseAPI { /** * Selects the best quote from a list of quotes based on a pricing strategy. * * @private * @param {OrderbookQuote[]} quotes - An array of quotes. * @param {BigNumberish} size - The size of the trade. * @param {BigNumberish} [minimumSize] - The minimum size of the trade (optional). * @param {string} [taker] - The address of the taker (optional). * @param {Provider} [provider] - The custom provider to use for this call. * @returns {Promise} - A promise resolving to the best quote from the array of quotes, or null if no valid quote is found. */ private bestQuote; /** * Converts a quote into a fillable quote, with additional properties required for execution. * * @private * @param {string} poolAddress - The address of the pool. * @param {BigNumberish} size - The size of the trade. * @param {OrderbookQuote} quote - The orderbook quote to be converted. * @param {number} [createdAt] - The timestamp of the quote's creation (optional). * @param {string} [referrer] - The address of the referrer (optional). * @param {Provider} [provider] - The custom provider to use for this call. * @returns {Promise} - A promise resolving to the fillable quote. */ private tradeQuoteToFillable; /** * Checks whether a quote is valid. Can optionally throw an error if the quote is invalid. * * @param {OrderbookQuote} quote - The quote to check. * @param {BigNumberish} [size] - The size of the trade (optional). * @param {string} [taker] - The address of the taker (optional). * @param {boolean} [throwError=false] - Whether to throw an error if the quote is invalid (default is false). * @param {Provider} [provider] - The custom provider to use for this call (optional). * @returns {Promise} - A promise that resolves to a boolean indicating whether the quote is valid. */ isQuoteValid(quote: OrderbookQuote, size?: BigNumberish, taker?: string, throwError?: boolean, provider?: Provider): Promise; /** * Fetches the best quote for a specified pool address and trade size. * * @param {string} poolAddress - The address of the pool. * @param {BigNumberish} size - The size of the trade. * @param {boolean} isBuy - Whether it's a buy or a sell. * @param {BigNumberish} [minimumSize] - The minimum size of the trade (optional). * @param {string} [referrer] - The address of the referrer (optional). * @param {string} [taker] - The address of the taker (optional). * @param {Provider} [provider] - The custom provider to use for this call (optional). * @param {PoolKey} [poolKey] - The pool key to stream quotes from, passed for optimization purposes (optional). * @param {PoolMinimal} [pool] - The pool to stream quotes from, passed for optimization purposes (optional). * @returns {Promise} - The best fillable quote, or null if no quotes available. */ quote(poolAddress: string, size: BigNumberish, isBuy: boolean, minimumSize?: BigNumberish, referrer?: string, taker?: string, provider?: Provider, pool?: PoolMinimal): Promise; /** * Streams quotes for the given options and executes a callback for the best quote. * * @param {object} options - The options for the quotes stream: * @param {string} options.poolAddress - The address of the pool. * @param {BigNumberish} options.size - The size of the trade. * @param {boolean} options.isBuy - Whether it's a buy or a sell. * @param {BigNumberish} [options.minimumSize] - The minimum size of the trade (optional). * @param {string} [options.referrer] - The address of the referrer (optional). * @param {string} [options.taker] - The address of the taker (optional). * @param {Provider} [options.provider] - The custom provider to use for this call (optional). * @param {boolean} [options.forceSendRFQ] - Whether to force sending/listening for Request-for-Quotes (optional). * @param {PoolKey} [options.poolKey] - The pool key to stream quotes from, passed for optimization purposes (optional). * @param {PoolMinimal} [options.pool] - The pool to stream quotes from, passed for optimization purposes (optional). * @param {(quote: FillableQuote | null) => void} callback - The callback to execute for the best quote. * @returns {Promise} */ streamQuotes(options: { poolAddress: string; size: BigNumberish; isBuy: boolean; minimumSize?: BigNumberish; referrer?: string; taker?: string; provider?: Provider; forceSendRFQ?: boolean; poolKey?: PoolKey; pool?: PoolMinimal; }, callback: (quote: FillableQuote | null) => void): Promise; /** * Cancels the quotes stream for orderbook quotes. * * @returns {Promise} */ cancelQuoteStream(): void; /** * Cancels all active quotes streams. * * @returns {Promise} */ cancelAllStreams(): Promise; /** * Publishes a quote using an API key. * * @param {QuoteWithSignatureT} quote - The quote to publish. * @returns {Promise} - A promise that resolves to the published quote. */ publishQuoteWithApiKey(quote: QuoteWithSignatureT): Promise; /** * Publishes a list of quotes with an API key. * * @param {QuoteWithSignatureT[]} quotes - The list of quotes to publish. * @returns {Promise} A promise that resolves to the list of returned OB quotes. */ publishQuotesWithApiKey(quotes: QuoteWithSignatureT[]): Promise; /** * Publishes an unsigned quote with an API key. * * @param {string} poolAddress - The address of the pool. * @param {QuoteSaltOptionalT} quote - The unsigned quote to publish. * @returns {Promise} A promise that resolves to the list of returned OB quotes. */ publishUnsignedQuoteWithApiKey(poolAddress: string, quote: QuoteSaltOptionalT): Promise; /** * Publishes a list of unsigned quotes with an API key. * * @param {string} poolAddress - The address of the pool. * @param {QuoteSaltOptionalT[]} quotes - The list of unsigned quotes to publish. * @returns {Promise} A promise that resolves to the list of returned OB quotes. */ publishUnsignedQuotesWithApiKey(poolAddress: string, quotes: QuoteSaltOptionalT[]): Promise; /** * Publishes an unsigned quote. * * @param {string} poolAddress - The address of the pool. * @param {QuoteSaltOptionalT} quote - The unsigned quote to publish. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to the transaction receipt or null if failed. */ publishUnsignedQuote(poolAddress: string, quote: QuoteSaltOptionalT, provider?: Provider): Promise; /** * Publishes a list of unsigned quotes. * * @param {string} poolAddress - The address of the pool. * @param {QuoteSaltOptionalT[]} quotes - The list of unsigned quotes to publish. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to the transaction receipt or null if failed. */ publishUnsignedQuotes(poolAddress: string, quotes: QuoteSaltOptionalT[], provider?: Provider): Promise; /** * Publishes a quote. * * @param {QuoteWithSignatureT} quote - The quote to publish. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to the transaction receipt or null if failed. */ publishQuote(quote: QuoteWithSignatureT, provider?: Provider): Promise; /** * Publishes a list of quotes. * * @param {QuoteWithSignatureT[]} quotes - The list of quotes to publish. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to the transaction receipt or null if failed. */ publishQuotes(quotes: QuoteWithSignatureT[], provider?: Provider): Promise; /** * Signs a quote. * * @param {string} poolAddress - The address of the pool. * @param {QuoteSaltOptionalT} quote - The quote to be signed. * @returns {Promise} A promise that resolves to the signed quote. */ signQuote(poolAddress: string, quote: QuoteSaltOptionalT): Promise; /** * Calculates the hash of a quote. This is a static method. * * @param {QuoteT} quote - The quote to hash. * @param {string} poolAddress - The address of the pool. * @param {number} chainId - The id of the chain. * @returns {string} The calculated hash of the quote. */ static calculateQuoteHash(quote: QuoteT, poolAddress: string, chainId: number): string; /** * Calculates the hash of a quote. * * @method calculateQuoteHash * @param {QuoteT} quote - The quote to hash. * @param {string} poolAddress - The address of the pool. * @returns {string} The calculated hash of the quote. */ calculateQuoteHash(quote: QuoteT, poolAddress: string): string; }