Orchestration functions are plain-english wrappers for the function defined in Data and Computation.
Functions suffixed with WithData
are synchronous, and require token reserves to be passed in as arguments. Functions without the suffix are asychronous, and require token addresses to be passed in as arguments.
The function facilitates trading an exact amount of ETH for a specified token.
export function tradeExactEthForTokensWithData(reserves: OptionalReserves, ethAmount: BigNumberish): TradeDetails
Parameter | Type | Description |
---|---|---|
reserves | OptionalReserves | Reserves data for the output token. |
ethAmount | BigNumberish | The input amount of ETH. |
const tradeDetails: TradeDetails = tradeExactEthForTokensWithData(reserves, '1000000000000000000')
The function facilitates trading an exact amount of ETH for a specified token.
export async function tradeExactEthForTokens(tokenAddress: string,ethAmount: BigNumberish,chainIdOrProvider?: ChainIdOrProvider): Promise<TradeDetails>
Parameter | Type | Description |
---|---|---|
tokenAddress | string | Address of output token. |
ethAmount | BigNumberish | The input amount of ETH. |
chainIdOrProvider? | ChainIdOrProvider | A supported chain id (1 , 3 , 4 , or 42 ), or an underlying web3 provider connected to a chain with a supported chain id. |
const tradeDetails: TradeDetails = await tradeExactEthForTokens(tokenAddress, '1000000000000000000')
The function facilitates trading ETH for an exact amount of a specified token.
export function tradeEthForExactTokensWithData(reserves: OptionalReserves, tokenAmount: BigNumberish): TradeDetails
Parameter | Type | Description |
---|---|---|
reserves | OptionalReserves | Reserves data for the output token. |
tokenAmount | BigNumberish | The output amount of tokens. |
const tradeDetails: TradeDetails = tradeEthForExactTokensWithData(reserves, '1000000000000000000')
The function facilitates trading ETH for an exact amount of a specified token.
export async function tradeEthForExactTokens(tokenAddress: string,tokenAmount: BigNumberish,chainIdOrProvider?: ChainIdOrProvider): Promise<TradeDetails>
Parameter | Type | Description |
---|---|---|
tokenAddress | string | Address of output token. |
tokenAmount | BigNumberish | The output amount of tokens. |
chainIdOrProvider? | ChainIdOrProvider | A supported chain id (1 , 3 , 4 , or 42 ), or an underlying web3 provider connected to a chain with a supported chain id. |
const tradeDetails: TradeDetails = await tradeEthForExactTokens(tokenAddress, '1000000000000000000')
The function facilitates trading an exact amount of a specified token for ETH.
export function tradeExactTokensForEthWithData(reserves: OptionalReserves, tokenAmount: BigNumberish): TradeDetails
Parameter | Type | Description |
---|---|---|
reserves | OptionalReserves | Reserves data for the input token. |
tokenAmount | BigNumberish | The input amount of tokens. |
const tradeDetails: TradeDetails = tradeExactTokensForEthWithData(reserves, '1000000000000000000')
The function facilitates trading an exact amount of a specified token for ETH.
export async function tradeExactTokensForEth(tokenAddress: string,tokenAmount: BigNumberish,chainIdOrProvider?: ChainIdOrProvider): Promise<TradeDetails>
Parameter | Type | Description |
---|---|---|
tokenAddress | string | Address of input token. |
tokenAmount | BigNumberish | The input amount of tokens. |
chainIdOrProvider? | ChainIdOrProvider | A supported chain id (1 , 3 , 4 , or 42 ), or an underlying web3 provider connected to a chain with a supported chain id. |
const tradeDetails: TradeDetails = await tradeExactTokensForEth(tokenAddress, '1000000000000000000')
The function facilitates trading a specified token for an exact amount of ETH.
export function tradeTokensForExactEthWithData(reserves: OptionalReserves, ethAmount: BigNumberish): TradeDetails
Parameter | Type | Description |
---|---|---|
reserves | OptionalReserves | Reserves data for the input token. |
ethAmount | BigNumberish | The outpute amount of ETH. |
const tradeDetails: TradeDetails = tradeTokensForExactEthWithData(reserves, '1000000000000000000')
The function facilitates trading a specified token for an exact amount of ETH.
export async function tradeTokensForExactEth(tokenAddress: string,ethAmount: BigNumberish,chainIdOrProvider?: ChainIdOrProvider): Promise<TradeDetails>
Parameter | Type | Description |
---|---|---|
tokenAddress | string | Address of input token. |
ethAmount | BigNumberish | The output amount of ETH. |
chainIdOrProvider? | ChainIdOrProvider | A supported chain id (1 , 3 , 4 , or 42 ), or an underlying web3 provider connected to a chain with a supported chain id. |
const tradeDetails: TradeDetails = await tradeTokensForExactEth(tokenAddress, '1000000000000000000')
The function facilitates trading an exact amount of a specified token for another token.
export function tradeExactTokensForTokensWithData(reservesInput: OptionalReserves,reservesOutput: OptionalReserves,tokenAmount: BigNumberish): TradeDetails
Parameter | Type | Description |
---|---|---|
reservesInput | OptionalReserves | Reserves data for the input token. |
reservesOutput | OptionalReserves | Reserves data for the output token. |
tokenAmount | BigNumberish | The input amount of tokens. |
const tradeDetails: TradeDetails = tradeExactTokensForTokensWithData(reservesInput,reservesOutput,'1000000000000000000')
The function facilitates trading an exact amount of a specified token for another token.
export async function tradeExactTokensForTokens(tokenAddressInput: string,tokenAddressOutput: string,tokenAmount: BigNumberish,chainIdOrProvider?: ChainIdOrProvider): Promise<TradeDetails>
Parameter | Type | Description |
---|---|---|
tokenAddressInput | string | Address of input token. |
tokenAddressOutput | string | Address of output token. |
tokenAmount | BigNumberish | The input amount of tokens. |
chainIdOrProvider? | ChainIdOrProvider | A supported chain id (1 , 3 , 4 , or 42 ), or an underlying web3 provider connected to a chain with a supported chain id. |
const tradeDetails: TradeDetails = await tradeExactTokensForTokens(tokenAddressInput,tokenAddressOutput,'1000000000000000000')
The function facilitates trading a specified token for an exact amount of another token.
export function tradeTokensForExactTokensWithData(reservesInput: OptionalReserves,reservesOutput: OptionalReserves,tokenAmount: BigNumberish): TradeDetails
Parameter | Type | Description |
---|---|---|
reservesInput | OptionalReserves | Reserves data for the input token. |
reservesOutput | OptionalReserves | Reserves data for the output token. |
tokenAmount | BigNumberish | The output amount of tokens. |
const tradeDetails: TradeDetails = tradeTokensForExactTokensWithData(reservesInput,reservesOutput,'1000000000000000000')
The function facilitates trading an exact amount of a specified token for another token.
export async function tradeTokensForExactTokens(tokenAddressInput: string,tokenAddressOutput: string,tokenAmount: BigNumberish,chainIdOrProvider?: ChainIdOrProvider): Promise<TradeDetails>
Parameter | Type | Description |
---|---|---|
tokenAddressInput | string | Address of input token. |
tokenAddressOutput | string | Address of output token. |
tokenAmount | BigNumberish | The output amount of tokens. |
chainIdOrProvider? | ChainIdOrProvider | A supported chain id (1 , 3 , 4 , or 42 ), or an underlying web3 provider connected to a chain with a supported chain id. |
const tradeDetails: TradeDetails = await tradeTokensForExactTokens(tokenAddressInput,tokenAddressOutput,'1000000000000000000')