mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
minor fixes and edits
This commit is contained in:
parent
9b6df87fa0
commit
3e059c8366
|
@ -65,7 +65,7 @@ contract Helpers {
|
||||||
address tokenA,
|
address tokenA,
|
||||||
address tokenB,
|
address tokenB,
|
||||||
uint24 fee
|
uint24 fee
|
||||||
) public returns (uint160) {
|
) internal view returns (uint160) {
|
||||||
UniswapV3Pool state = UniswapV3Pool(
|
UniswapV3Pool state = UniswapV3Pool(
|
||||||
getPoolAddress(tokenA, tokenB, fee)
|
getPoolAddress(tokenA, tokenB, fee)
|
||||||
);
|
);
|
||||||
|
@ -88,7 +88,7 @@ contract Helpers {
|
||||||
uint256 amountIn,
|
uint256 amountIn,
|
||||||
uint256 amountOutMinimum,
|
uint256 amountOutMinimum,
|
||||||
bool zeroForOne
|
bool zeroForOne
|
||||||
) public returns (ISwapRouter.ExactInputSingleParams memory params) {
|
) internal view returns (ISwapRouter.ExactInputSingleParams memory params) {
|
||||||
params = ISwapRouter.ExactInputSingleParams({
|
params = ISwapRouter.ExactInputSingleParams({
|
||||||
tokenIn: tokenIn,
|
tokenIn: tokenIn,
|
||||||
tokenOut: tokenOut,
|
tokenOut: tokenOut,
|
||||||
|
@ -107,21 +107,17 @@ contract Helpers {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function approveTransfer(address tokenIn, uint256 amountIn) public {
|
|
||||||
IERC20(tokenIn).safeApprove(address(router), amountIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
function SwapTokens(
|
function SwapTokens(
|
||||||
address tokenIn,
|
address tokenIn,
|
||||||
address tokenOut,
|
address tokenOut,
|
||||||
bool zeroForOne
|
bool zeroForOne
|
||||||
) public returns (address, address) {
|
) internal pure returns (address, address) {
|
||||||
if (!zeroForOne) return (tokenOut, tokenIn);
|
if (!zeroForOne) return (tokenOut, tokenIn);
|
||||||
else return (tokenIn, tokenOut);
|
else return (tokenIn, tokenOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
function swapSingleInput(ISwapRouter.ExactInputSingleParams memory params)
|
function swapSingleInput(ISwapRouter.ExactInputSingleParams memory params)
|
||||||
public
|
internal
|
||||||
returns (uint256)
|
returns (uint256)
|
||||||
{
|
{
|
||||||
return (uint256(router.exactInputSingle(params)));
|
return (uint256(router.exactInputSingle(params)));
|
||||||
|
|
|
@ -2,36 +2,34 @@ pragma solidity ^0.7.6;
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
|
|
||||||
import "./helpers.sol";
|
import "./helpers.sol";
|
||||||
|
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||||
|
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
||||||
|
|
||||||
contract uniswapSellBeta is Helpers {
|
contract uniswapSellBeta is Helpers {
|
||||||
|
using SafeERC20 for IERC20;
|
||||||
|
|
||||||
function sell(
|
function sell(
|
||||||
address tokenIn,
|
address tokenIn,
|
||||||
address tokenOut,
|
address tokenOut,
|
||||||
uint24 fee,
|
uint24 fee,
|
||||||
uint256 amountIn,
|
uint256 amountIn,
|
||||||
uint256 amountOutMinimum,
|
uint256 amountOutMinimum
|
||||||
bool zeroForOne
|
|
||||||
) public payable returns (uint256 amountOut) {
|
) public payable returns (uint256 amountOut) {
|
||||||
(address tokenA, address tokenB) = SwapTokens(
|
IERC20(tokenIn).safeApprove(address(router), amountIn);
|
||||||
tokenIn,
|
|
||||||
tokenOut,
|
|
||||||
zeroForOne
|
|
||||||
);
|
|
||||||
approveTransfer(tokenA, amountIn);
|
|
||||||
amountOut = swapSingleInput(
|
amountOut = swapSingleInput(
|
||||||
getParams(
|
getParams(
|
||||||
tokenA,
|
tokenIn,
|
||||||
tokenB,
|
tokenOut,
|
||||||
msg.sender,
|
address(this),
|
||||||
fee,
|
fee,
|
||||||
amountIn,
|
amountIn,
|
||||||
amountOutMinimum,
|
amountOutMinimum,
|
||||||
zeroForOne
|
tokenOut > tokenIn
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract UniswapSellBetaArbitrum is uniswapSellBeta {
|
contract ConnectV2UniswapSellBeta is uniswapSellBeta {
|
||||||
string public constant name = "UniswapSellBeta";
|
string public constant name = "Uniswap-Sell-Beta";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user