SimulateSwap

Uniswap Getter Plugin - SimulateSwap

Description

A getter function that simulates swap on Uniswap V2 and returns values of the swap. (This swap doesn't change the state of the blockchain)

Method

simulateSwap(uint256,bytes32,address[])

Input Parameters

NamePlugin TypeDescription

to

FctAddress

Uniswap V2 Router address

Method Parameters

NamePlugin TypeDescription

amount

FctValue

Amount that will be swapped

method

FctString (hashed)

Method of the swap

path

FctAddressList

Path of the swap

Returned Values

NamePlugin TypeDescription

amountIn

FctValue

Amount that was used to swap with

amountOut

FctValue

Amount that was received after swap

tokenIn

FctAddress

Token that was swapped from

tokenOut

FctAddress

Token that was received

Example

Example with initParams

const simulateSwap = new Uniswap.getters.SimulateSwap({
 chainId: 1,
 initParams: {
   to: "0x..." // Uniswap V2 Router
   methodParams: {
     amount: "...",
     method: "...",
     path: ["0x...", "0x..."],
   }
 }
})

Example without initParams

const simulateSwap = new Uniswap.getters.SimulateSwap({ 
  chainId: 1
})

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

Learn more

Learn more about Uniswap function here

Last updated