SwapExactTokensForTokens

Uniswap Action Plugin - SwapExactTokensForTokens

Description

Swaps an exact amount of tokens for as much ETH as possible, along the route determined by the path.

Method

swapExactTokensForTokens(uint256, uint256, address[], address, uint256)

Input Parameters

NamePlugin TypeDescription

to

FctAddress

Uniswap V2 Router address

Method Parameters

NamePlugin TypeDescription

amountIn

FctValue

The amount of input tokens to send.

amountOutMin

FctValue

The minimum amount of output tokens that must be received for the transaction not to revert.

path

FctAddressList

An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

to

FctAddress

Recipient of the output tokens.

deadline

FctValue

Unix timestamp after which the transaction will revert.

Example

Example with initParams

const swapExactTokensForTokens = new Uniswap.actions.SwapExactTokensForTokens({
 chainId: 1,
 initParams: {
   to: "0x..." // Uniswap V2 Router
   methodParams: {
     amountIn: "...",
     amountOutMin: "...",
     path: ["0x...", "0x..."],
     to: "0x...",
     deadline: "..."
   }
 }
})

Example without initParams

const swapExactTokensForTokens = new Uniswap.actions.SwapExactTokensForTokens({ 
  chainId: 1
})

swapExactTokensForTokens.input.set({
   to: "0x..." // Uniswap V2 Router
   methodParams: {
     amountIn: "...",
     amountOutMin: "...",
     path: ["0x...", "0x..."],
     to: "0x...",
     deadline: "..."
   }
})

Learn more

Learn more about Uniswap SwapExactTokensForTokens function here

Last updated