diff --git a/foundry/src/uniswap_x/UniswapXFiller.sol b/foundry/src/uniswap_x/UniswapXFiller.sol index 0904ef8..7826e3c 100644 --- a/foundry/src/uniswap_x/UniswapXFiller.sol +++ b/foundry/src/uniswap_x/UniswapXFiller.sol @@ -67,17 +67,15 @@ contract UniswapXFiller is AccessControl, IReactorCallback { ResolvedOrder memory order = resolvedOrders[0]; - ( - bool tokenInApprovalNeeded, - bool tokenOutApprovalNeeded, - bytes memory tychoCalldata - ) = abi.decode(callbackData, (bool, bool, bytes)); + bool tokenInApprovalNeeded = bool(uint8(callbackData[0]) == 1); + bool tokenOutApprovalNeeded = bool(uint8(callbackData[1]) == 1); + bytes calldata tychoCalldata = bytes(callbackData[2:]); // The TychoRouter will take the input tokens from the filler if (tokenInApprovalNeeded) { // Native ETH input is not supported by UniswapX IERC20(order.input.token).forceApprove( - tychoRouter, order.input.maxAmount + tychoRouter, type(uint256).max ); } diff --git a/foundry/test/uniswap_x/UniswapXFiller.t.sol b/foundry/test/uniswap_x/UniswapXFiller.t.sol index 9ac004c..5128339 100644 --- a/foundry/test/uniswap_x/UniswapXFiller.t.sol +++ b/foundry/test/uniswap_x/UniswapXFiller.t.sol @@ -68,7 +68,8 @@ contract UniswapXFillerTest is Test, TychoRouterTestSetup { swap ); - bytes memory callbackData = abi.encode(true, true, tychoRouterData); + bytes memory callbackData = + abi.encodePacked(true, true, tychoRouterData); deal(WETH_ADDR, address(filler), amountIn); vm.startPrank(address(filler)); @@ -153,7 +154,7 @@ contract UniswapXFillerTest is Test, TychoRouterTestSetup { swap ); - bytes memory callbackData = abi.encode( + bytes memory callbackData = abi.encodePacked( true, // tokenIn approval needed true, // tokenOut approval needed tychoRouterData