SwapExactETHForTokens

Uniswap Action Plugin - SwapExactETHForTokens

Description

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

Method

swapExactETHForTokens(uint256, address[], address, uint256)

Input Parameters

NamePlugin TypeDescription

to

FctAddress

Uniswap V2 Router address

value

FctValue

The amount of ETH to send.

Method Parameters

NamePlugin TypeDescription

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 swapExactETHForTokens = new Uniswap.actions.SwapExactETHForTokens({
 chainId: 1,
 initParams: {
   to: "0x..." // Uniswap V2 Router
   value: "...",
   methodParams: {
     amountOutMin: "...",
     path: ["0x...", "0x..."],
     to: "0x...",
     deadline: "..."
   }
 }
})

Example without initParams

const swapExactETHForTokens = new Uniswap.actions.SwapExactETHForTokens({ chainId: 1 })

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

Learn more

Learn more about Uniswap SwapExactETHForTokens function here

Last updated