Cexles Finance
Search
K
Comment on page

SwapHelperUniswapV3

The contract implements the token swap functionality through UniswapV3 smart contracts. Using oracle we calculate the minimum price per swap.

Solidity API

SwapHelperUniswapV3

ADMIN_ROLE

bytes32 ADMIN_ROLE

SWAPPER_ROLE

bytes32 SWAPPER_ROLE

PRECISION

uint256 PRECISION

swapRouter

contract ISwapRouter swapRouter

factory

contract IUniswapV3Factory factory

getAmountOut

function getAmountOut(address tokenIn, address tokenOut, uint128 amountIn, uint24 fee, uint32 secondsAgo) public view returns (uint256 amountOut)
See {ISwapHelperV3}

sortTokens

function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1)

secondsAgoDefault

function secondsAgoDefault() external view returns (uint256)
Returns a seconds ago default param

slippage

function slippage() external view returns (uint256)
Returns a slippage for calculate price

constructor

constructor(address swapRouter_, address factory_, uint256 slippage_, uint32 secondsAgoDefault_) public
Creates an instance of a contract that allows you to do a single swap on smart contracts UniswapV3 and sends an outputToken to the address
Parameters
Name
Type
Description
swapRouter_
address
Swap router address for exchange
factory_
address
Factory address
slippage_
uint256
Maximum slippage for swap
secondsAgoDefault_
uint32
Number of seconds from the current time to query the average price for the period

swap

function swap(address beneficiary, address tokenIn, address tokenOut, uint128 amountIn, uint24 fee) external returns (uint256 amountOut)
See {ISwapHelperV3}

swapWithCustomSlippage

function swapWithCustomSlippage(address beneficiary, address tokenIn, address tokenOut, uint128 amountIn, uint24 fee, uint256 slippageForSwap) external returns (uint256 amountOut)
See {ISwapHelperV3}

updateSecondsAgoDefault

function updateSecondsAgoDefault(uint32 value) external returns (bool)
Update secondsAgoDefault param responsible for the number of seconds since the current moment to query the average price value (100% = 1000000)
Parameters
Name
Type
Description
value
uint32
Number of seconds

updateSlippage

function updateSlippage(uint256 value) external returns (bool)
Update slippage for calculate minimum price swap
Parameters
Name
Type
Description
value
uint256
Number of seconds

onlyRole

modifier onlyRole(bytes32 role)
Modifier to check different roles
Parameters
Name
Type
Description
role
bytes32
Role bytes32 to check availability for user