SwapExactTokensForETH

Sushiswap Action Plugin - SwapExactTokensForETH

Description

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

Method

swapExactTokensForETH(uint256, uint256, address[], address, uint256)

Input Parameters

NamePlugin TypeDescription

to

FctAddress

Sushiswap 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 ETH.

deadline

FctValue

Unix timestamp after which the transaction will revert.

Example

Example with initParams

const swapExactTokensForETH = new Sushiswap.actions.SwapExactTokensForETH({
 chainId: 1,
 initParams: {
   to: "0x..." // Sushiswap Router
   methodParams: {
     amountIn: "...",
     amountOutMin: "...",
     path: ["0x...", "0x..."],
     to: "0x...",
     deadline: "..."
   }
 }
})

Example without initParams

const swapExactTokensForETH = new Sushiswap.actions.SwapExactTokensForETH({ 
   chainId: 1
})

await swapExactTokensForETH.input.set({
   to: "0x..." // Sushiswap Router
   methodParams: {
     amountIn: "...",
     amountOutMin: "...",
     path: ["0x...", "0x..."],
     to: "0x...",
     deadline: "..."
   }
})

Learn more

Learn more about Sushiswap SwapExactTokensForETH function here

Last updated