AddLiquidity

Uniswap Action Plugin - AddLiquidity

Description

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

Method

addLiquidity(address, address, uint256, uint256, uint256, uint256, address, uint256)

Input Parameters

NamePlugin TypeDescription

to

FctAddress

Uniswap V2 Router address

Method Parameters

NamePlugin TypeDescription

tokenA

FctAddress

A pool token

tokenB

FctAddress

A pool token

amountADesired

FctValue

The amount of tokenA to add as liquidity if the B/A price is <= amountBDesired/amountADesired (A depreciates).

amountBDesired

FctValue

The amount of tokenB to add as liquidity if the A/B price is <= amountADesired/amountBDesired (B depreciates).

amountAMin

FctValue

Bounds the extent to which the B/A price can go up before the transaction reverts. Must be <= amountADesired.

amountBMin

FctValue

Bounds the extent to which the A/B price can go up before the transaction reverts. Must be <= amountBDesired.

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 tokenA sent to the pool.

amountB

FctValue

The amount of tokenB sent to the pool.

liquidity

FctValue

The amount of liquidity tokens minted.

Example

Example with initParams

const addLiquidity = new Uniswap.actions.AddLiquidity({
 chainId: 1,
 initParams: {
   to: "0x..." // Uniswap V2 Router
   methodParams: {
     tokenA: "0x...",
     tokenB: "0x...",
     amountADesired: "...",
     amountBDesired: "...",
     amountAMin: "...",
     amountBMin: "...",
     to: "0x...",
     deadline: "...",
   }
 }
})

Example without initParams

const addLiquidity = new Uniswap.actions.AddLiquidity({ chainId: 1 })

addLiquidity.input.set({
   to: "0x..." // Uniswap V2 Router
   value: "...",
   methodParams: {
     tokenA: "0x...",
     tokenB: "0x...",
     amountADesired: "...",
     amountBDesired: "...",
     amountAMin: "...",
     amountBMin: "...",
     to: "0x...",
     deadline: "...",
   }
})

Learn more

Learn more about Uniswap AddLiquidity function here

Last updated