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 tokenB,
|
||||
uint24 fee
|
||||
) public returns (uint160) {
|
||||
) internal view returns (uint160) {
|
||||
UniswapV3Pool state = UniswapV3Pool(
|
||||
getPoolAddress(tokenA, tokenB, fee)
|
||||
);
|
||||
|
@ -88,7 +88,7 @@ contract Helpers {
|
|||
uint256 amountIn,
|
||||
uint256 amountOutMinimum,
|
||||
bool zeroForOne
|
||||
) public returns (ISwapRouter.ExactInputSingleParams memory params) {
|
||||
) internal view returns (ISwapRouter.ExactInputSingleParams memory params) {
|
||||
params = ISwapRouter.ExactInputSingleParams({
|
||||
tokenIn: tokenIn,
|
||||
tokenOut: tokenOut,
|
||||
|
@ -107,21 +107,17 @@ contract Helpers {
|
|||
});
|
||||
}
|
||||
|
||||
function approveTransfer(address tokenIn, uint256 amountIn) public {
|
||||
IERC20(tokenIn).safeApprove(address(router), amountIn);
|
||||
}
|
||||
|
||||
function SwapTokens(
|
||||
address tokenIn,
|
||||
address tokenOut,
|
||||
bool zeroForOne
|
||||
) public returns (address, address) {
|
||||
) internal pure returns (address, address) {
|
||||
if (!zeroForOne) return (tokenOut, tokenIn);
|
||||
else return (tokenIn, tokenOut);
|
||||
}
|
||||
|
||||
function swapSingleInput(ISwapRouter.ExactInputSingleParams memory params)
|
||||
public
|
||||
internal
|
||||
returns (uint256)
|
||||
{
|
||||
return (uint256(router.exactInputSingle(params)));
|
||||
|
|
|
@ -2,36 +2,34 @@ pragma solidity ^0.7.6;
|
|||
pragma abicoder v2;
|
||||
|
||||
import "./helpers.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
||||
|
||||
contract uniswapSellBeta is Helpers {
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
function sell(
|
||||
address tokenIn,
|
||||
address tokenOut,
|
||||
uint24 fee,
|
||||
uint256 amountIn,
|
||||
uint256 amountOutMinimum,
|
||||
bool zeroForOne
|
||||
uint256 amountOutMinimum
|
||||
) public payable returns (uint256 amountOut) {
|
||||
(address tokenA, address tokenB) = SwapTokens(
|
||||
tokenIn,
|
||||
tokenOut,
|
||||
zeroForOne
|
||||
);
|
||||
approveTransfer(tokenA, amountIn);
|
||||
IERC20(tokenIn).safeApprove(address(router), amountIn);
|
||||
amountOut = swapSingleInput(
|
||||
getParams(
|
||||
tokenA,
|
||||
tokenB,
|
||||
msg.sender,
|
||||
tokenIn,
|
||||
tokenOut,
|
||||
address(this),
|
||||
fee,
|
||||
amountIn,
|
||||
amountOutMinimum,
|
||||
zeroForOne
|
||||
tokenOut > tokenIn
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
contract UniswapSellBetaArbitrum is uniswapSellBeta {
|
||||
string public constant name = "UniswapSellBeta";
|
||||
contract ConnectV2UniswapSellBeta is uniswapSellBeta {
|
||||
string public constant name = "Uniswap-Sell-Beta";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user