Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

Hierarchy

  • Trade

Index

Constructors

  • new Trade(route: Route, amount: TokenAmount): Trade

Properties

executionPrice: Price

The price expressed in terms of output amount/input amount.

fees: readonly TokenAmount[]

Fees paid to the pairs.

inputAmount: TokenAmount

The input amount for the trade assuming no slippage.

nextMidPrice: Price

The mid price after the trade executes assuming no slippage.

outputAmount: TokenAmount

The output amount for the trade assuming no slippage.

priceImpact: Percent

The percent difference between the mid price before the trade and the trade execution price.

route: Route

The route of the trade, i.e. which pairs the trade goes through.

Methods

  • minimumAmountOut(slippageTolerance: Percent): TokenAmount
  • Get the minimum amount that must be received from this trade for the given slippage tolerance

    Parameters

    • slippageTolerance: Percent

      tolerance of unfavorable slippage from the execution price of this trade

    Returns TokenAmount

  • worstExecutionPrice(slippageTolerance: Percent): Price
  • Return the execution price after accounting for slippage tolerance

    Parameters

    • slippageTolerance: Percent

      the allowed tolerated slippage

    Returns Price

  • bestTradeExactIn(pairs: AnyPair[], tokenAmountIn: TokenAmount, tokenOut: Token, __namedParameters?: BestTradeOptions, currentPairs?: AnyPair[], nextAmountIn?: TokenAmount, bestTrades?: Trade[]): Trade[]
  • 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.

    Parameters

    • pairs: AnyPair[]

      the pairs to consider in finding the best trade

    • tokenAmountIn: TokenAmount

      exact amount of the input token to spend

    • tokenOut: Token

      the desired token out

    • __namedParameters: BestTradeOptions = {}
    • currentPairs: AnyPair[] = []

      used in recursion; the current list of pairs

    • nextAmountIn: TokenAmount = tokenAmountIn
    • bestTrades: Trade[] = []

      used in recursion; the current list of best trades

    Returns Trade[]

  • exactIn(route: Route, amountIn: TokenAmount): Trade
  • Constructs an exact in trade with the given amount in and route

    Parameters

    • route: Route

      route of the exact in trade

    • amountIn: TokenAmount

      the amount being passed in

    Returns Trade

Generated using TypeDoc