Comment on page
SwapHelperUniswapV3
The contract implements the token swap functionality through UniswapV3 smart contracts. Using oracle we calculate the minimum price per swap.
bytes32 ADMIN_ROLE
bytes32 SWAPPER_ROLE
uint256 PRECISION
contract ISwapRouter swapRouter
contract IUniswapV3Factory factory
function getAmountOut(address tokenIn, address tokenOut, uint128 amountIn, uint24 fee, uint32 secondsAgo) public view returns (uint256 amountOut)
See {ISwapHelperV3}
function sortTokens(address tokenA, address tokenB) external pure returns (address token0, address token1)
function secondsAgoDefault() external view returns (uint256)
Returns a seconds ago default param
function slippage() external view returns (uint256)
Returns a slippage for calculate price
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 addressParameters
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 |
function swap(address beneficiary, address tokenIn, address tokenOut, uint128 amountIn, uint24 fee) external returns (uint256 amountOut)
See {ISwapHelperV3}
function swapWithCustomSlippage(address beneficiary, address tokenIn, address tokenOut, uint128 amountIn, uint24 fee, uint256 slippageForSwap) external returns (uint256 amountOut)
See {ISwapHelperV3}
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 |
function updateSlippage(uint256 value) external returns (bool)
Update slippage for calculate minimum price swap
Parameters
Name | Type | Description |
---|---|---|
value | uint256 | Number of seconds |
modifier onlyRole(bytes32 role)
Modifier to check different roles
Parameters
Name | Type | Description |
---|---|---|
role | bytes32 | Role bytes32 to check availability for user |
Last modified 6mo ago