feat: remove exact_out from USV2
This commit is contained in:
@@ -4,6 +4,7 @@ pragma solidity ^0.8.28;
|
|||||||
import "@interfaces/IExecutor.sol";
|
import "@interfaces/IExecutor.sol";
|
||||||
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
||||||
import "@uniswap-v2/contracts/interfaces/IUniswapV2Pair.sol";
|
import "@uniswap-v2/contracts/interfaces/IUniswapV2Pair.sol";
|
||||||
|
import "forge-std/console.sol";
|
||||||
|
|
||||||
error UniswapV2Executor__InvalidDataLength();
|
error UniswapV2Executor__InvalidDataLength();
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ contract UniswapV2Executor is IExecutor {
|
|||||||
bool zeroForOne
|
bool zeroForOne
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (data.length < 61) {
|
if (data.length != 61) {
|
||||||
revert UniswapV2Executor__InvalidDataLength();
|
revert UniswapV2Executor__InvalidDataLength();
|
||||||
}
|
}
|
||||||
inToken = IERC20(address(bytes20(data[0:20])));
|
inToken = IERC20(address(bytes20(data[0:20])));
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ contract UniswapV2ExecutorTest is UniswapV2ExecutorExposed, Test, Constants {
|
|||||||
assertGe(amountOut, 0);
|
assertGe(amountOut, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testSwap() public {
|
function testSwapUniswapV2() public {
|
||||||
uint256 amountIn = 10 ** 18;
|
uint256 amountIn = 10 ** 18;
|
||||||
uint256 amountOut = 1847751195973566072891;
|
uint256 amountOut = 1847751195973566072891;
|
||||||
bool zeroForOne = false;
|
bool zeroForOne = false;
|
||||||
@@ -97,7 +97,8 @@ contract UniswapV2ExecutorTest is UniswapV2ExecutorExposed, Test, Constants {
|
|||||||
function testSwapExecutorEncoderData() public {
|
function testSwapExecutorEncoderData() public {
|
||||||
// Generated by the ExecutorStrategyEncoder - test_executor_strategy_encode
|
// Generated by the ExecutorStrategyEncoder - test_executor_strategy_encode
|
||||||
bytes memory protocolData =
|
bytes memory protocolData =
|
||||||
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc288e6a0c2ddd26feeb64f039a2c41296fcb3f564000000000000000000000000000000000000000010000";
|
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc288e6a0c2ddd26feeb64f039a2c41296fcb3f5640000000000000000000000000000000000000000100";
|
||||||
|
console.log("protocolData1", protocolData.length);
|
||||||
|
|
||||||
(IERC20 tokenIn, address target, address receiver, bool zeroForOne) =
|
(IERC20 tokenIn, address target, address receiver, bool zeroForOne) =
|
||||||
uniswapV2Exposed.decodeParams(protocolData);
|
uniswapV2Exposed.decodeParams(protocolData);
|
||||||
@@ -111,7 +112,8 @@ contract UniswapV2ExecutorTest is UniswapV2ExecutorExposed, Test, Constants {
|
|||||||
function testSwapExecutorSwap() public {
|
function testSwapExecutorSwap() public {
|
||||||
// Generated by the ExecutorStrategyEncoder - test_executor_strategy_encode
|
// Generated by the ExecutorStrategyEncoder - test_executor_strategy_encode
|
||||||
bytes memory protocolData =
|
bytes memory protocolData =
|
||||||
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2a478c2975ab1ea89e8196811f51a7b7ade33eb111d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e0000";
|
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2a478c2975ab1ea89e8196811f51a7b7ade33eb111d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e00";
|
||||||
|
console.log("protocolData2", protocolData.length);
|
||||||
uint256 amountIn = 10 ** 18;
|
uint256 amountIn = 10 ** 18;
|
||||||
uint256 amountOut = 1847751195973566072891;
|
uint256 amountOut = 1847751195973566072891;
|
||||||
deal(WETH_ADDR, address(uniswapV2Exposed), amountIn);
|
deal(WETH_ADDR, address(uniswapV2Exposed), amountIn);
|
||||||
|
|||||||
@@ -143,8 +143,6 @@ mod tests {
|
|||||||
"1d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e",
|
"1d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e",
|
||||||
// zero for one
|
// zero for one
|
||||||
"00",
|
"00",
|
||||||
// exact out
|
|
||||||
"00",
|
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ impl SwapEncoder for UniswapV2SwapEncoder {
|
|||||||
component_id,
|
component_id,
|
||||||
bytes_to_address(&encoding_context.receiver)?,
|
bytes_to_address(&encoding_context.receiver)?,
|
||||||
zero_to_one,
|
zero_to_one,
|
||||||
encoding_context.exact_out,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(args.abi_encode_packed())
|
Ok(args.abi_encode_packed())
|
||||||
@@ -211,8 +210,6 @@ mod tests {
|
|||||||
"0000000000000000000000000000000000000001",
|
"0000000000000000000000000000000000000001",
|
||||||
// zero for one
|
// zero for one
|
||||||
"00",
|
"00",
|
||||||
// exact out
|
|
||||||
"00",
|
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user