@uniswap/v3-sdk / Exports / Trade
Class: Trade<TInput, TOutput, TTradeType>
Represents a trade executed against a set of routes where some percentage of the input is split across each route.
Each route has its own set of pools. Pools can not be re-used across routes.
Does not account for slippage, i.e., changes in price environment that can occur between the time the trade is submitted and when it is executed.
Type parameters
Name | Type | Description |
---|---|---|
TInput | extends Currency | The input token, either Ether or an ERC-20 |
TOutput | extends Currency | The output token, either Ether or an ERC-20 |
TTradeType | extends TradeType | The trade type, either exact input or exact output |
Table of contents
Constructors
Properties
Accessors
Methods
- maximumAmountIn
- minimumAmountOut
- worstExecutionPrice
- bestTradeExactIn
- bestTradeExactOut
- createUncheckedTrade
- createUncheckedTradeWithMultipleRoutes
- exactIn
- exactOut
- fromRoute
- fromRoutes
Constructors
constructor
• Private
new Trade<TInput
, TOutput
, TTradeType
>(__namedParameters
)
Construct a trade by passing in the pre-computed property values
Type parameters
Name | Type |
---|---|
TInput | extends Currency |
TOutput | extends Currency |
TTradeType | extends TradeType |
Parameters
Name | Type |
---|---|
__namedParameters | Object |
__namedParameters.routes | { inputAmount : CurrencyAmount <TInput > ; outputAmount : CurrencyAmount <TOutput > ; route : Route <TInput , TOutput > }[] |
__namedParameters.tradeType | TTradeType |
Defined in
Properties
_executionPrice
• Private
_executionPrice: undefined
| Price
<TInput
, TOutput
>
The cached result of the computed execution price
Defined in
_inputAmount
• Private
_inputAmount: undefined
| CurrencyAmount
<TInput
>
The cached result of the input amount computation
Defined in
_outputAmount
• Private
_outputAmount: undefined
| CurrencyAmount
<TOutput
>
The cached result of the output amount computation
Defined in
_priceImpact
• Private
_priceImpact: undefined
| Percent
The cached result of the price impact computation
Defined in
swaps
• Readonly
swaps: { inputAmount
: CurrencyAmount
<TInput
> ; outputAmount
: CurrencyAmount
<TOutput
> ; route
: Route
<TInput
, TOutput
> }[]
The swaps of the trade, i.e. which routes and how much is swapped in each that make up the trade.
Defined in
tradeType
• Readonly
tradeType: TTradeType
The type of the trade, either exact in or exact out.
Defined in
Accessors
executionPrice
• get
executionPrice(): Price
<TInput
, TOutput
>
The price expressed in terms of output amount/input amount.
Returns
Price
<TInput
, TOutput
>
Defined in
inputAmount
• get
inputAmount(): CurrencyAmount
<TInput
>
The input amount for the trade assuming no slippage.
Returns
CurrencyAmount
<TInput
>
Defined in
outputAmount
• get
outputAmount(): CurrencyAmount
<TOutput
>
The output amount for the trade assuming no slippage.
Returns
CurrencyAmount
<TOutput
>