Trade class
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.
Constructors
- Trade(Route route, CurrencyAmount amount, TradeType tradeType)
Properties
- executionPrice ↔ Price
-
The price expressed in terms of output amount/input amount.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- inputAmount ↔ CurrencyAmount
-
The input amount for the trade assuming no slippage.
getter/setter pair
- nextMidPrice ↔ Price
-
The mid price after the trade executes assuming no slippage.
getter/setter pair
- outputAmount ↔ CurrencyAmount
-
The output amount for the trade assuming no slippage.
getter/setter pair
- priceImpact ↔ Percent
-
The percent difference between the mid price before the trade and the trade execution price.
getter/setter pair
- route ↔ Route
-
The route of the trade, i.e. which pairs the trade goes through.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tradeType ↔ TradeType
-
The type of the trade, either exact in or exact out.
getter/setter pair
Methods
-
maximumAmountIn(
Percent slippageTolerance) → 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
-
minimumAmountOut(
Percent slippageTolerance) → CurrencyAmount - 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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
bestTradeExactIn(
List< Pair> pairs, CurrencyAmount currencyAmountIn, Currency currencyOut, {int maxNumResults = 3, int maxHops = 3, List<Pair> ? currentPairs, CurrencyAmount? originalAmountIn, List<Trade> ? bestTrades}) → List<Trade> -
Given a list of pairs, and a fixed amount in, returns the top
maxNumResultstrades that go from an input token amount to an output token, making at mostmaxHopshops. 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 currencyAmountIn 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 originalAmountIn used in recursion; the original value of the currencyAmountIn parameter @param bestTrades used in recursion; the current list of best trades -
bestTradeExactOut(
List< Pair> pairs, Currency currencyIn, CurrencyAmount currencyAmountOut, {int maxNumResults = 3, int maxHops = 3, List<Pair> ? currentPairs, CurrencyAmount? originalAmountOut, List<Trade> ? bestTrades}) → List<Trade> -
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
maxNumResultstrades that go from an input token to an output token amount, making at mostmaxHopshops 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 currencyAmountOut 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 originalAmountOut used in recursion; the original value of the currencyAmountOut parameter @param bestTrades used in recursion; the current list of best trades -
exactIn(
Route route, CurrencyAmount amountIn) → Trade - 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
-
exactOut(
Route route, CurrencyAmount amountOut) → Trade - 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