SwapTokensForExactETH

Sushiswap Action Plugin - SwapTokensForExactETH

Description

Receive an exact amount of ETH for as few input tokens as possible, along the route determined by the path.

Method

swapTokensForExactETH(uint256, uint256, address[], address, uint256)

Input Parameters

NamePlugin TypeDescription

to

FctAddress

Sushiswap Router address

Method Parameters

NamePlugin TypeDescription

amountOut

FctValue

The amount of ETH to receive.

amountInMax

FctValue

The maximum amount of input tokens that can be required before the transaction reverts.

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 swapTokensForExactETH = new Sushiswap.actions.SwapExactTokensForETH({
 chainId: 1,
 initParams: {
   to: "0x..." // Sushiswap Router
   methodParams: {
     amountOut: "...",
     amountInMax: "...",
     path: ["0x...", "0x..."],
     to: "0x...",
     deadline: "..."
   }
 }
})

Example without initParams

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

swapTokensForExactETH.input.set({
   to: "0x..." // Sushiswap Router
   methodParams: {
     amountOut: "...",
     amountInMax: "...",
     path: ["0x...", "0x..."],
     to: "0x...",
     deadline: "..."
   }
})

Learn more

Learn more about Sushiswap SwapTokensForExactETH function here

Last updated