v2/trade library

Classes

BestTradeOptions
InputOutput
minimal interface so the input output comparator may be shared across types
Trade
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.

Functions

computePriceImpact(Price midPrice, CurrencyAmount inputAmount, CurrencyAmount outputAmount) Percent
Returns the percent difference between the mid price and the execution price, i.e. price impact. @param midPrice mid price before the trade @param inputAmount the input amount of the trade @param outputAmount the output amount of the trade
inputOutputComparator(InputOutput a, InputOutput b) int
comparator function that allows sorting trades by their output amounts, in decreasing order, and then input amounts in increasing order. i.e. the best trades have the most outputs for the least inputs and are sorted first
tradeComparator(Trade a, Trade b) int
wrappedAmount(CurrencyAmount currencyAmount, ChainId chainId) TokenAmount
Given a currency amount and a chain ID, returns the equivalent representation as the token amount. In other words, if the currency is ETHER, returns the WETH token amount for the given chain. Otherwise, returns the input currency amount.
wrappedCurrency(Currency currency, int chainId) Token?