SwapETHForExactTokens

Sushiswap Action Plugin - SwapETHForExactTokens

Description

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

Method

swapETHForExactTokens(uint256, address[], address, uint256)

Input Parameters

NamePlugin TypeDescription

to

FctAddress

Sushiswap Router address

value

FctValue

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

Method Parameters

NamePlugin TypeDescription

amountOut

FctValue

The amount of tokens to receive.

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

Example without initParams

const swapETHForExactTokens = new Sushiswap.actions.SwapETHForExactTokens({ 
  chainId: 1
})

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

Learn more

Learn more about Sushiswap SwapETHForExactTokens function here

Last updated