fix: Remove exactOut logic from Uniswapv2SwapExecutor

We don't support it now

--- don't change below this line ---
ENG-4033 Took 9 minutes
This commit is contained in:
Diana Carvalho
2025-01-24 09:39:06 +00:00
parent 5627a1902b
commit b9f4451769
2 changed files with 8 additions and 20 deletions

View File

@@ -15,10 +15,9 @@ contract UniswapV2SwapExecutor is ISwapExecutor {
address target;
address receiver;
bool zeroForOne;
bool exactOut;
IERC20 tokenIn;
(tokenIn, target, receiver, zeroForOne, exactOut) = _decodeData(data);
(tokenIn, target, receiver, zeroForOne) = _decodeData(data);
calculatedAmount = _getAmountOut(target, givenAmount, zeroForOne);
tokenIn.safeTransfer(target, givenAmount);
@@ -37,15 +36,13 @@ contract UniswapV2SwapExecutor is ISwapExecutor {
IERC20 inToken,
address target,
address receiver,
bool zeroForOne,
bool exactOut
bool zeroForOne
)
{
inToken = IERC20(address(bytes20(data[0:20])));
target = address(bytes20(data[20:40]));
receiver = address(bytes20(data[40:60]));
zeroForOne = uint8(data[60]) > 0;
exactOut = uint8(data[61]) > 0;
}
function _getAmountOut(address target, uint256 amountIn, bool zeroForOne)

View File

@@ -13,8 +13,7 @@ contract UniswapV2SwapExecutorExposed is UniswapV2SwapExecutor {
IERC20 inToken,
address target,
address receiver,
bool zeroForOne,
bool exactOut
bool zeroForOne
)
{
return _decodeData(data);
@@ -49,21 +48,15 @@ contract UniswapV2SwapExecutorTest is
function testDecodeParams() public view {
bytes memory params =
abi.encodePacked(WETH_ADDR, address(2), address(3), false, true);
abi.encodePacked(WETH_ADDR, address(2), address(3), false);
(
IERC20 tokenIn,
address target,
address receiver,
bool zeroForOne,
bool exactOut
) = uniswapV2Exposed.decodeParams(params);
(IERC20 tokenIn, address target, address receiver, bool zeroForOne) =
uniswapV2Exposed.decodeParams(params);
assertEq(address(tokenIn), WETH_ADDR);
assertEq(target, address(2));
assertEq(receiver, address(3));
assertEq(zeroForOne, false);
assertEq(exactOut, true);
}
function testAmountOut() public view {
@@ -88,10 +81,8 @@ contract UniswapV2SwapExecutorTest is
uint256 amountIn = 10 ** 18;
uint256 amountOut = 1847751195973566072891;
bool zeroForOne = false;
bool exactOut = true;
bytes memory protocolData = abi.encodePacked(
WETH_ADDR, WETH_DAI_POOL, BOB, zeroForOne, exactOut
);
bytes memory protocolData =
abi.encodePacked(WETH_ADDR, WETH_DAI_POOL, BOB, zeroForOne);
vm.startPrank(ADMIN);
deal(WETH_ADDR, address(uniswapV2Exposed), amountIn);