FCT_Lib_UniswapV2

FCT_Lib_UniswapV2 adds the ability to do a swaps and add liquidity when not all params are known in advance. It also supports simulating swaps without doing any change on the blockchain.

It is needed because swap and add liquidity needs inputs that are dependent on dynamic data.

The ability to simulate actions like swaps extends the capabilities and possible uses cases for FCTs.

Main Functions

addLiquidity_noMinProtection

function addLiquidity_noMinProtection(
        bytes32 method,
        address tokenA,
        address tokenB,
        uint256 amountADesired,
        uint256 amountBDesired
) external returns (uint256 amountA, uint256 amountB, uint256 liquidity)

Adds liquidity directly from the FCT_Runner without any min amount protection, meaning that the actual amounts that will be used are not assured.

Method

The method field indicates what type of assets to use.

EIP712 String
Value
Meaning

"add tokens to the liquidity pool"

0xc5e812b33ccfc422cc67fe6a4a9c94fd720b8366450ac3abba030cb939faada9

Both assets are tokens

"add token and eth to the liquidity pool"

0xccf1d23669f5eddb14d0c83e333dd0b99a41ea530f8630117b808f26f72e734d

Token1 is a token, Token2 is eth.

Token2 must be set to the "0x0" address. There is a need to set eth_value, on the EIP712 message, to the amountBDesired

"library"

0x2f812b5abd341301dfffaebe6f6590dbc0e3af99ec30818db9326aec1d00bb6a

Token1 is eth, Token2 is a token.

Token1 must be set to the "0x0" address. There is a need to set eth_value, on the EIP712 message, to the amountBDesired

addLiquidityTo_noMinProtection

The same as addLiquidity_noMinProtection except that the "to" address gets the liquidity token instead and the FCT_Runner

swap_noSlippageProtection

Swaps tokens or eth directly from the FCT_Runner without any slippage protection, meaning that the actual amounts that will be used are not assured (except the amount that was defined as "exact" according to the chosen method)

Method

The method field indicates what type of assets to use and whether the input or output amount will be assured (exact value)

EIP712 String
Value
Meaning

"swap <amount> ETH for <X> Tokens"

0x466cc669f6960e4421e91695071448f897ff8b24896d7be50c3dfd35763c11bc

Swap exact value of eth ("amount") with calculated amount of tokens, according to the poll rate, fees and path. path[0] address is ignored. path[length-1] holds the token address.

"swap <X> ETH for <amount> Tokens"

0x2c5bb148f384584019df8863f1ae14981fbaa2a68e1a48fc2cfbb7613b863443

Swap calculated value of eth with exact amount of tokens ("amount"), according to the poll rate, fees and path. path[0] address is ignored. path[length-1] holds the token address.

"swap <amount> Tokens for <X> ETH

0x879b548aa5cfb2c501936de860db8fbbfd55fc8bfb83436d8285c2ff4426b364

Swap exact amount of tokens ("amount") with calculated value of eth, according to the poll rate, fees and path. path[0] holds the token address. path[length-1] address is ignored.

"swap <X> Tokens for <amount> ETH"

0x1f07df2c714f32f537fc738ef067e4599c02281f5b97e1c8f61087fdfba66e00

Swap calculated amount of tokens with exact value of eth ("amount"), according to the poll rate, fees and path. path[0] holds the token address. path[length-1] address is ignored.

"swap <amount> Tokens for <X> Tokens"

0x87553fac71f49f68d60c206941e24a4072378db84d66aacd8c8b551375320e04

Swap exact amount of tokens ("amount") with calculated amount of tokens, according to the poll rate, fees and path. path[0] holds the token-in address. path[length-1] holds the token-out address.

"swap <X> Tokens for <amount> Tokens"

0x4bb12c6033cfb48ed18b80cd06c5cb48cad6e1c071434e80ed8c65f94405bd39

Swap calculated amount of tokens with exact value of eth ("amount"), according to the poll rate, fees and path. path[0] holds the token-in address. path[length-1] holds the token-out address.

swapTo_noSlippageProtection

The same as swap_noSlippageProtection except that the "to" address gets the liquidity token instead and the FCT_Runner

simulateSwap

The same as swap_noSlippageProtection except that the actual swap is not executed.

Last updated