SwapTo

Uniswap V2 - SwapTo

Description

Swaps on Uniswap V2 without slippage and with recipient address

Method

swapTo_noSlippageProtection(uint256,bytes32,address,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

recipient

FctAddress

Address which recieves the swap tokens

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 swapTo = new FCT_UNISWAP.actions.SwapToNoSlippageProtection({
 chainId: 1,
 initParams: {
   to: "0x..." // FCT Uniswap library 
   methodParams: {
     amount: "...",
     method: "...",
     recipient: "0x...",
     path: ["0x...", "0x..."],
   }
 }
})

Example without initParams

const swapTo = new FCT_UNISWAP.actions.SwapToNoSlippageProtection({ 
  chainId: 1
})

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

Learn more

Learn more about Uniswap here

Last updated