feat: fix input decoding in usv3 executor and execution dispatcher

This commit is contained in:
royvardhan
2025-02-14 00:53:43 +05:30
parent bd1971334e
commit 80500e615e
10 changed files with 237 additions and 321 deletions

View File

@@ -11,10 +11,11 @@ contract UniswapV2Executor is IExecutor {
using SafeERC20 for IERC20;
// slither-disable-next-line locked-ether
function swap(
uint256 givenAmount,
bytes calldata data
) external payable returns (uint256 calculatedAmount) {
function swap(uint256 givenAmount, bytes calldata data)
external
payable
returns (uint256 calculatedAmount)
{
address target;
address receiver;
bool zeroForOne;
@@ -32,13 +33,12 @@ contract UniswapV2Executor is IExecutor {
}
}
function handleCallback(
bytes calldata data
) external returns (bytes memory result) {}
function handleCallback(bytes calldata data)
external
returns (bytes memory result)
{}
function _decodeData(
bytes calldata data
)
function _decodeData(bytes calldata data)
internal
pure
returns (
@@ -57,20 +57,20 @@ contract UniswapV2Executor is IExecutor {
zeroForOne = uint8(data[60]) > 0;
}
function _getAmountOut(
address target,
uint256 amountIn,
bool zeroForOne
) internal view returns (uint256 amount) {
function _getAmountOut(address target, uint256 amountIn, bool zeroForOne)
internal
view
returns (uint256 amount)
{
IUniswapV2Pair pair = IUniswapV2Pair(target);
uint112 reserveIn;
uint112 reserveOut;
if (zeroForOne) {
// slither-disable-next-line unused-return
(reserveIn, reserveOut, ) = pair.getReserves();
(reserveIn, reserveOut,) = pair.getReserves();
} else {
// slither-disable-next-line unused-return
(reserveOut, reserveIn, ) = pair.getReserves();
(reserveOut, reserveIn,) = pair.getReserves();
}
require(reserveIn > 0 && reserveOut > 0, "L");