import { CacheEvents, TypedEventEmitter } from './types';
import { BlockMetadata, EncodedStrategy, OrdersMap, TokenPair, TradeData } from '../common/types';
import { BigNumberish } from '../utils/numerics';
declare const ChainCache_base: new () => TypedEventEmitter<CacheEvents>;
export declare class ChainCache extends ChainCache_base {
    private _strategiesByPair;
    private _strategiesById;
    private _ordersByDirectedPair;
    private _latestBlockNumber;
    private _latestTradesByPair;
    private _latestTradesByDirectedPair;
    private _blocksMetadata;
    private _tradingFeePPMByPair;
    private _handleCacheMiss;
    static fromSerialized(serializedCache: string): ChainCache;
    private _deserialize;
    serialize(): string;
    setCacheMissHandler(handler: (token0: string, token1: string) => Promise<void>): void;
    private _checkAndHandleCacheMiss;
    clear(silent?: boolean): void;
    getStrategiesByPair(token0: string, token1: string): Promise<EncodedStrategy[] | undefined>;
    getStrategyById(id: BigNumberish): EncodedStrategy | undefined;
    getCachedPairs(onlyWithStrategies?: boolean): TokenPair[];
    /**
     * returns the orders that sell targetToken for sourceToken
     */
    getOrdersByPair(sourceToken: string, targetToken: string, keepNonTradable?: boolean): Promise<OrdersMap>;
    hasCachedPair(token0: string, token1: string): boolean;
    getLatestTradeByPair(token0: string, token1: string): Promise<TradeData | undefined>;
    getLatestTradeByDirectedPair(sourceToken: string, targetToken: string): Promise<TradeData | undefined>;
    getLatestTrades(): TradeData[];
    getLatestBlockNumber(): number;
    getTradingFeePPMByPair(token0: string, token1: string): Promise<number | undefined>;
    get blocksMetadata(): BlockMetadata[];
    set blocksMetadata(blocks: BlockMetadata[]);
    /**
     * This method is to be used when all the existing strategies of a pair are
     * fetched and are to be stored in the cache.
     * Once a pair is cached, the only way to update it is by using `applyBatchedUpdates`.
     * If all the strategies of a pair are deleted, the pair remains in the cache and there's
     * no need to add it again.
     * @param {string} token0 - address of the first token of the pair
     * @param {string} token1 - address of the second token of the pair
     * @param {EncodedStrategy[]} strategies - the strategies to be cached
     * @throws {Error} if the pair is already cached
     * @returns {void}
     */
    addPair(token0: string, token1: string, strategies: EncodedStrategy[], noPairAddedEvent?: boolean): void;
    /**
     * This methods allows setting the trading fee of a pair.
     * Note that fees can also be updated via `applyBatchedUpdates`.
     * This specific method is useful when the fees were fetched from the chain
     * as part of initialization or some other operation mode which doesn't
     * rely on even processing
     *
     * @param {string} token0 - address of the first token of the pair
     * @param {string} token1 - address of the second token of the pair
     * @param tradingFeePPM - the pair's trading fee
     */
    addPairFees(token0: string, token1: string, tradingFeePPM: number): void;
    /**
     * This method is to be used when events from a range of blocks are fetched
     * and are to be applied to the cache.
     * All the events should belong to pairs that are already cached.
     * The way to use this work flow is to first call `getLatestBlockNumber` to
     * get the latest block number that was already cached, then fetch all the
     * events from that block number to the latest block number, and finally
     * call this method with the fetched events.
     * Note: the cache can handle a case of a strategy that was created and then updated and then deleted
     * @param {number} latestBlockNumber - the latest block number that was fetched
     * @param {TradeData[]} latestTrades - the trades that were conducted
     * @param {EncodedStrategy[]} createdStrategies - the strategies that were created
     * @param {EncodedStrategy[]} updatedStrategies - the strategies that were updated
     * @param {EncodedStrategy[]} deletedStrategies - the strategies that were deleted
     * @throws {Error} if the pair of a strategy is not cached
     * @returns {void}
     */
    applyBatchedUpdates(latestBlockNumber: number, latestFeeUpdates: [string, string, number][], latestTrades: TradeData[], createdStrategies: EncodedStrategy[], updatedStrategies: EncodedStrategy[], deletedStrategies: EncodedStrategy[]): void;
    private _setLatestBlockNumber;
    private _setLatestTrade;
    private _addStrategyOrders;
    private _removeStrategyOrders;
    private _addStrategy;
    private _updateStrategy;
    private _deleteStrategy;
}
export {};
//# sourceMappingURL=ChainCache.d.ts.map