import type { Token } from "@saberhq/token-utils"; import { Percent, Price, TokenAmount } from "@saberhq/token-utils"; import type { AnyPair } from "./pair"; import { Route } from "./route"; interface InputOutput { readonly inputAmount: TokenAmount; readonly outputAmount: TokenAmount; } export declare function inputOutputComparator(a: InputOutput, b: InputOutput): number; export declare function tradeComparator(a: Trade, b: Trade): number; export interface BestTradeOptions { maxNumResults?: number; maxHops?: number; } /** * Represents a trade executed against a list of pairs. * Does not account for slippage, i.e. trades that front run this trade and move the price. */ export declare class Trade { /** * The route of the trade, i.e. which pairs the trade goes through. */ readonly route: Route; /** * The input amount for the trade assuming no slippage. */ readonly inputAmount: TokenAmount; /** * The output amount for the trade assuming no slippage. */ readonly outputAmount: TokenAmount; /** * The price expressed in terms of output amount/input amount. */ readonly executionPrice: Price; /** * The mid price after the trade executes assuming no slippage. */ readonly nextMidPrice: Price; /** * The percent difference between the mid price before the trade and the trade execution price. */ readonly priceImpact: Percent; /** * Fees paid to the pairs. */ readonly fees: readonly TokenAmount[]; /** * Constructs an exact in trade with the given amount in and route * @param route route of the exact in trade * @param amountIn the amount being passed in */ static exactIn(route: Route, amountIn: TokenAmount): Trade; constructor(route: Route, amount: TokenAmount); /** * Get the minimum amount that must be received from this trade for the given slippage tolerance * @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade */ minimumAmountOut(slippageTolerance: Percent): TokenAmount; /** * Given a list of pairs, and a fixed amount in, returns the top `maxNumResults` trades that go from an input token * amount to an output token, making at most `maxHops` hops. * Note this does not consider aggregation, as routes are linear. It's possible a better route exists by splitting * the amount in among multiple routes. * @param pairs the pairs to consider in finding the best trade * @param tokenAmountIn exact amount of the input token to spend * @param tokenOut the desired token out * @param maxNumResults maximum number of results to return * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pair * @param currentPairs used in recursion; the current list of pairs * @param originalAmountIn used in recursion; the original value of the tokenAmountIn parameter * @param bestTrades used in recursion; the current list of best trades */ static bestTradeExactIn(pairs: AnyPair[], tokenAmountIn: TokenAmount, tokenOut: Token, { maxNumResults, maxHops }?: BestTradeOptions, currentPairs?: AnyPair[], nextAmountIn?: TokenAmount, bestTrades?: Trade[]): Trade[]; /** * Return the execution price after accounting for slippage tolerance * @param slippageTolerance the allowed tolerated slippage */ worstExecutionPrice(slippageTolerance: Percent): Price; } export {}; //# sourceMappingURL=trade.d.ts.map