Uniswap sell beta connector done

This commit is contained in:
Samyak Jain 2021-11-20 16:21:36 +05:30
parent c952949ded
commit 07d9240556
3 changed files with 10 additions and 20 deletions

View File

@ -5,7 +5,6 @@ contract Events {
uint24 fee,
uint256 amountIn,
uint256 amountOut,
uint256 amountOutMinimum,
bool zeroForOne
uint256 amountOutMinimum
);
}

View File

@ -85,8 +85,7 @@ contract Helpers {
address recipient,
uint24 fee,
uint256 amountIn,
uint256 amountOutMinimum,
bool zeroForOne
uint256 amountOutMinimum
) internal view returns (ISwapRouter.ExactInputSingleParams memory params) {
params = ISwapRouter.ExactInputSingleParams({
tokenIn: tokenIn,
@ -98,7 +97,7 @@ contract Helpers {
amountOutMinimum: amountOutMinimum,
sqrtPriceLimitX96: getPriceLimit(
amountIn,
zeroForOne,
tokenIn < tokenOut,
tokenIn,
tokenOut,
fee

View File

@ -14,37 +14,29 @@ contract uniswapSellBeta is Helpers, Events {
address tokenOut,
uint24 fee,
uint256 amountIn,
uint256 amountOutMinimum,
bool zeroForOne
uint256 amountOutMinimum
)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
{
(address token0, address token1) = SwapTokens(
tokenIn,
tokenOut,
zeroForOne
);
IERC20(token0).safeApprove(address(router), amountIn);
IERC20(tokenIn).safeApprove(address(router), amountIn);
uint256 amountOut = swapSingleInput(
getParams(
token0,
token1,
tokenIn,
tokenOut,
address(this),
fee,
amountIn,
amountOutMinimum,
zeroForOne
amountOutMinimum
)
);
_eventName = "LogSell(uint24,uint256,uint256,uint256,bool)";
_eventName = "LogSell(uint24,uint256,uint256,uint256)";
_eventParam = abi.encode(
fee,
amountIn,
amountOut,
amountOutMinimum,
zeroForOne
amountOutMinimum
);
}
}