import { Fraction, FractionJson } from "./fraction";
import type BN from "bn.js";
export declare class Offer {
    price: Fraction;
    volume: Fraction;
    constructor(price: Fraction, volume: number | Fraction);
    clone(): Offer;
    static fromJSON(o: OfferJson): Offer;
}
export interface OfferJson {
    price: FractionJson;
    volume: FractionJson;
}
declare type Fee = {
    fee: Fraction;
};
declare type RemainingFractionAfterFee = {
    remainingFractionAfterFee: Fraction;
};
export declare class Orderbook {
    readonly baseToken: string;
    readonly quoteToken: string;
    readonly remainingFractionAfterFee: Fraction;
    private asks;
    private bids;
    constructor(baseToken: string | number, quoteToken: string | number, options?: Fee | RemainingFractionAfterFee);
    getOffers(): {
        bids: Offer[];
        asks: Offer[];
    };
    toJSON(): OrderbookToJson;
    static fromJSON(o: OrderbookJson): Orderbook;
    pair(): string;
    addBid(bid: Offer): void;
    addAsk(ask: Offer): void;
    /**
     * @returns the inverse of the current order book (e.g. ETH/DAI becomes DAI/ETH)
     * by switching bids/asks and recomputing price/volume to the new reference token.
     */
    inverted(): Orderbook;
    /**
     * In-place adds the given orderbook to the current one, combining all bids and asks at the same price point
     * @param orderbook - the orderbook to be added to this one
     */
    add(orderbook: Orderbook): void;
    /**
     * @param amount - the amount of base tokens to be sold
     * @returns the price for which there are enough bids to fill the specified amount or undefined if there is not enough liquidity
     */
    priceToSellBaseToken(amount: number | BN): Fraction | undefined;
    /**
     * @param amount - the amount of base tokens to be bought
     * @returns the price for which there are enough asks to fill the specified amount or undefined if there is not enough liquidity
     */
    priceToBuyBaseToken(amount: number | BN): Fraction | undefined;
    /**
     * Removes any overlapping bid/asks which could be matched in the current orderbook
     * @returns A new instance of the orderbook with no more overlapping orders.
     */
    reduced(): Orderbook;
    /**
     * Computes the transitive closure of this orderbook (e.g. ETH/DAI) with another one (e.g. DAI/USDC).
     * Throws if the orderbooks cannot be combined (baseToken is not equal to quoteToken)
     * @param orderbook - The orderbook for which the transitive closure will be computed
     * @returns A new instance of an orderbook representing the resulting closure.
     */
    transitiveClosure(orderbook: Orderbook): Orderbook;
    private transitiveAskClosure;
    fee(): Fraction;
    clone(): Orderbook;
}
export interface OrderbookToJson {
    baseToken: string;
    quoteToken: string;
    remainingFractionAfterFee: Fraction;
    asks: Record<string, Offer>;
    bids: Record<string, Offer>;
}
export interface OrderbookJson {
    baseToken: string;
    quoteToken: string;
    remainingFractionAfterFee: FractionJson;
    asks: Record<string, OfferJson>;
    bids: Record<string, OfferJson>;
}
/**
 * Given a list of direct orderbooks this method returns the transitive orderbook
 * between two tokens by computing the transitive closure via a certain number of "hops".
 * @param direct_orderbooks - the map direct (non-transitive) orderbooks between tokens
 * @param base - the base token for which the transitive orderbook should be computed
 * @param quote - the quote token for which the transitive orderbook should be computed
 * @param hops - the number of intermediate tokens that should be considered when computing the transitive orderbook
 */
export declare function transitiveOrderbook(direct_orderbooks: Map<string, Orderbook>, base: string, quote: string, hops: number): Orderbook;
export {};
