feat: remove exact_out from USV2

This commit is contained in:
royvardhan
2025-01-30 20:48:35 +05:30
parent 95d45975ad
commit 8cb95f0950
4 changed files with 7 additions and 9 deletions

View File

@@ -4,6 +4,7 @@ pragma solidity ^0.8.28;
import "@interfaces/IExecutor.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@uniswap-v2/contracts/interfaces/IUniswapV2Pair.sol";
import "forge-std/console.sol";
error UniswapV2Executor__InvalidDataLength();
@@ -43,7 +44,7 @@ contract UniswapV2Executor is IExecutor {
bool zeroForOne
)
{
if (data.length < 61) {
if (data.length != 61) {
revert UniswapV2Executor__InvalidDataLength();
}
inToken = IERC20(address(bytes20(data[0:20])));

View File

@@ -80,7 +80,7 @@ contract UniswapV2ExecutorTest is UniswapV2ExecutorExposed, Test, Constants {
assertGe(amountOut, 0);
}
function testSwap() public {
function testSwapUniswapV2() public {
uint256 amountIn = 10 ** 18;
uint256 amountOut = 1847751195973566072891;
bool zeroForOne = false;
@@ -97,7 +97,8 @@ contract UniswapV2ExecutorTest is UniswapV2ExecutorExposed, Test, Constants {
function testSwapExecutorEncoderData() public {
// Generated by the ExecutorStrategyEncoder - test_executor_strategy_encode
bytes memory protocolData =
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc288e6a0c2ddd26feeb64f039a2c41296fcb3f564000000000000000000000000000000000000000010000";
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc288e6a0c2ddd26feeb64f039a2c41296fcb3f5640000000000000000000000000000000000000000100";
console.log("protocolData1", protocolData.length);
(IERC20 tokenIn, address target, address receiver, bool zeroForOne) =
uniswapV2Exposed.decodeParams(protocolData);
@@ -111,7 +112,8 @@ contract UniswapV2ExecutorTest is UniswapV2ExecutorExposed, Test, Constants {
function testSwapExecutorSwap() public {
// Generated by the ExecutorStrategyEncoder - test_executor_strategy_encode
bytes memory protocolData =
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2a478c2975ab1ea89e8196811f51a7b7ade33eb111d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e0000";
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2a478c2975ab1ea89e8196811f51a7b7ade33eb111d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e00";
console.log("protocolData2", protocolData.length);
uint256 amountIn = 10 ** 18;
uint256 amountOut = 1847751195973566072891;
deal(WETH_ADDR, address(uniswapV2Exposed), amountIn);

View File

@@ -143,8 +143,6 @@ mod tests {
"1d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e",
// zero for one
"00",
// exact out
"00",
))
);
}

View File

@@ -46,7 +46,6 @@ impl SwapEncoder for UniswapV2SwapEncoder {
component_id,
bytes_to_address(&encoding_context.receiver)?,
zero_to_one,
encoding_context.exact_out,
);
Ok(args.abi_encode_packed())
@@ -211,8 +210,6 @@ mod tests {
"0000000000000000000000000000000000000001",
// zero for one
"00",
// exact out
"00",
))
);
}