AddLiquidityETH

Sushiswap Action Plugin - AddLiquidityETH

Description

Adds liquidity to an ERC-20⇄WETH pool with ETH.

Method

addLiquidityETH(address, uint256, uint256, uint256, address, uint256)

Input Parameters

NamePlugin TypeDescription

to

FctAddress

Sushiswap Router address

value

FctValue

The amount of ETH to add as liquidity if the token/WETH price is <= amountTokenDesired/value (WETH depreciates).

Method Parameters

NamePlugin TypeDescription

token

FctAddress

A pool token

amountTokenDesired

FctValue

The amount of token to add as liquidity if the WETH/token price is <= value/amountTokenDesired (token depreciates).

amountTokenMin

FctValue

Bounds the extent to which the WETH/token price can go up before the transaction reverts. Must be <= amountTokenDesired.

amountETHMin

FctValue

Bounds the extent to which the token/WETH price can go up before the transaction reverts. Must be <= value

to

FctAddress

Recipient of the liquidity tokens.

deadline

FctValue

Unix timestamp after which the transaction will revert.

Returned Values

NamePlugin TypeDescription

amountA

FctValue

The amount of token sent to the pool.

amountB

FctValue

The amount of ETH converted to WETH and sent to the pool.

liquidity

FctValue

The amount of liquidity tokens minted.

Example

Example with initParams

const addLiquidityETH = new Sushiswap.actions.AddLiquidityETH({
 chainId: 1,
 initParams: {
   to: "0x...", // Sushiswap Router
   value: "...",
   methodParams: {
     token: "0x...",
     amountTokenDesired: "...",
     amountTokenMin: "...",
     amountETHMin: "...",
     to: "0x...",
     deadline: "...",
   }
 }
})

Example without initParams

const addLiquidityETH = new Sushiswap.actions.AddLiquidityETH({ chainId: 1 })

addLiquidityETH.input.set({
   to: "0x...", // Sushiswap Router
   value: "...",
   methodParams: {
     token: "0x...",
     amountTokenDesired: "...",
     amountTokenMin: "...",
     amountETHMin: "...",
     to: "0x...",
     deadline: "...",
   }
})

Learn more

Learn more about Sushiswap AddLiquidityETH function here

Last updated