GetAmountsOut

Uniswap Action Plugin - GetAmountsOut

Description

Given an input asset amount and an array of token addresses, calculates all subsequent maximum output token amounts.

Method

getAmountsOut(uint256, address[])

Input Parameters

NamePlugin TypeDescription

to

FctAddress

Uniswap V2 Router address

Method Parameters

NamePlugin TypeDescription

amountIn

FctValue

Input asset amount

path

FctAddressList

Path of the trade

Returned Values

NamePlugin TypeDescription

firstAmount

FctValue

First amount out

lastAmount

FctValue

Last amount out

Example

Example with initParams

const getAmountsOut = new Uniswap.getters.GetAmountsOut({
 chainId: 1,
 initParams: {
   to: "0x..." // Uniswap V2 Router
   methodParams: {
     amountIn: "...",
     path: ["0x...", "0x..."],
   }
 }
})

Example without initParams

const getAmountsOut = new Uniswap.getters.GetAmountsOut({ 
  chainId: 1
})

getAmountsOut.input.set({
   to: "0x..." // Uniswap V2 Router
   methodParams: {
     amountIn: "...",
     path: ["0x...", "0x..."],
   }
})

Learn more

Learn more about Uniswap GetAmountsOut function here

Last updated