import { TradeType, CurrencyAmount, Currency, Percent, Price } from '@pulsex/swap-sdk-core'; import { PairV1, PairV2 } from './pair'; import { RouteV1, RouteV2 } from './route'; interface InputOutput { readonly inputAmount: CurrencyAmount; readonly outputAmount: CurrencyAmount; } export declare function inputOutputComparator(a: InputOutput, b: InputOutput): number; export declare function tradeComparator(a: TradeV1 | TradeV2, b: TradeV1 | TradeV2): 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 TradeV1 { /** * The route of the trade, i.e. which pairs the trade goes through and the input/output currencies. */ readonly route: RouteV1; /** * The type of the trade, either exact in or exact out. */ readonly tradeType: TTradeType; /** * The input amount for the trade assuming no slippage. */ readonly inputAmount: CurrencyAmount; /** * The output amount for the trade assuming no slippage. */ readonly outputAmount: CurrencyAmount; /** * The price expressed in terms of output amount/input amount. */ readonly executionPrice: Price; /** * The percent difference between the mid price before the trade and the trade execution price. */ readonly priceImpact: Percent; /** * 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: RouteV1, amountIn: CurrencyAmount): TradeV1; /** * Constructs an exact out trade with the given amount out and route * @param route route of the exact out trade * @param amountOut the amount returned by the trade */ static exactOut(route: RouteV1, amountOut: CurrencyAmount): TradeV1; constructor(route: RouteV1, amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount : CurrencyAmount, tradeType: TTradeType); /** * 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): CurrencyAmount; /** * Get the maximum amount in that can be spent via this trade for the given slippage tolerance * @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade */ maximumAmountIn(slippageTolerance: Percent): CurrencyAmount; /** * 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 nextAmountIn exact amount of input currency to spend * @param currencyOut the desired currency 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 currencyAmountIn used in recursion; the original value of the currencyAmountIn parameter * @param bestTrades used in recursion; the current list of best trades */ static bestTradeExactIn(pairs: PairV1[], currencyAmountIn: CurrencyAmount, currencyOut: TOutput, { maxNumResults, maxHops }?: BestTradeOptions, currentPairs?: PairV1[], nextAmountIn?: CurrencyAmount, bestTrades?: TradeV1[]): TradeV1[]; /** * Return the execution price after accounting for slippage tolerance * @param slippageTolerance the allowed tolerated slippage */ worstExecutionPrice(slippageTolerance: Percent): Price; /** * similar to the above method but instead targets a fixed output amount * given a list of pairs, and a fixed amount out, returns the top `maxNumResults` trades that go from an input token * to an output token amount, 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 currencyIn the currency to spend * @param nextAmountOut the exact amount of currency 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 currencyAmountOut used in recursion; the original value of the currencyAmountOut parameter * @param bestTrades used in recursion; the current list of best trades */ static bestTradeExactOut(pairs: PairV1[], currencyIn: TInput, currencyAmountOut: CurrencyAmount, { maxNumResults, maxHops }?: BestTradeOptions, currentPairs?: PairV1[], nextAmountOut?: CurrencyAmount, bestTrades?: TradeV1[]): TradeV1[]; } /** * 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 TradeV2 { /** * The route of the trade, i.e. which pairs the trade goes through and the input/output currencies. */ readonly route: RouteV2; /** * The type of the trade, either exact in or exact out. */ readonly tradeType: TTradeType; /** * The input amount for the trade assuming no slippage. */ readonly inputAmount: CurrencyAmount; /** * The output amount for the trade assuming no slippage. */ readonly outputAmount: CurrencyAmount; /** * The price expressed in terms of output amount/input amount. */ readonly executionPrice: Price; /** * The percent difference between the mid price before the trade and the trade execution price. */ readonly priceImpact: Percent; /** * 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: RouteV2, amountIn: CurrencyAmount): TradeV2; /** * Constructs an exact out trade with the given amount out and route * @param route route of the exact out trade * @param amountOut the amount returned by the trade */ static exactOut(route: RouteV2, amountOut: CurrencyAmount): TradeV2; constructor(route: RouteV2, amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount : CurrencyAmount, tradeType: TTradeType); /** * 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): CurrencyAmount; /** * Get the maximum amount in that can be spent via this trade for the given slippage tolerance * @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade */ maximumAmountIn(slippageTolerance: Percent): CurrencyAmount; /** * 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 nextAmountIn exact amount of input currency to spend * @param currencyOut the desired currency 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 currencyAmountIn used in recursion; the original value of the currencyAmountIn parameter * @param bestTrades used in recursion; the current list of best trades */ static bestTradeExactIn(pairs: PairV2[], currencyAmountIn: CurrencyAmount, currencyOut: TOutput, { maxNumResults, maxHops }?: BestTradeOptions, currentPairs?: PairV2[], nextAmountIn?: CurrencyAmount, bestTrades?: TradeV2[]): TradeV2[]; /** * Return the execution price after accounting for slippage tolerance * @param slippageTolerance the allowed tolerated slippage */ worstExecutionPrice(slippageTolerance: Percent): Price; /** * similar to the above method but instead targets a fixed output amount * given a list of pairs, and a fixed amount out, returns the top `maxNumResults` trades that go from an input token * to an output token amount, 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 currencyIn the currency to spend * @param nextAmountOut the exact amount of currency 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 currencyAmountOut used in recursion; the original value of the currencyAmountOut parameter * @param bestTrades used in recursion; the current list of best trades */ static bestTradeExactOut(pairs: PairV2[], currencyIn: TInput, currencyAmountOut: CurrencyAmount, { maxNumResults, maxHops }?: BestTradeOptions, currentPairs?: PairV2[], nextAmountOut?: CurrencyAmount, bestTrades?: TradeV2[]): TradeV2[]; } export {}; //# sourceMappingURL=trade.d.ts.map