Swap

Uniswap V2 - Swap

Description

Swaps on Uniswap V2 without slippage and recipient address is the sender

Method

swap_noSlippageProtection(uint256,bytes32,address[])

Input Parameters

NamePlugin TypeDescription

to

FctAddress

FCT Uniswap library

Method Parameters

NamePlugin TypeDescription

amount

FctValue

Amount to use in the swap OR Amount to receive in the swap. This depends on the swap method

method

FctString (hashed)

Method string. In the FCT it will be a hashed value

path

FctAddressList

An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

Returned Values

NamePlugin TypeDescription

amountIn

FctValue

amountOut

FctValue

tokenIn

FctAddress

tokenOut

FctAddress

Example

Example with initParams

const swap = new FCT_UNISWAP.actions.SwapNoSlippageProtection({
 chainId: 1,
 initParams: {
   to: "0x..." // FCT Uniswap library 
   methodParams: {
     amount: "...",
     method: "...",
     path: ["0x...", "0x..."],
   }
 }
})

Example without initParams

const swap = new FCT_UNISWAP.actions.SwapNoSlippageProtection({ 
  chainId: 1
})

swap.input.set({
   to: "0x..." // FCT Uniswap library 
   methodParams: {
     amount: "...",
     method: "...",
     path: ["0x...", "0x..."],
   }
})

Learn more

Learn more about Uniswap here

Last updated