diff --git a/foundry/src/TychoRouter.sol b/foundry/src/TychoRouter.sol index e07831a..9bfad5a 100644 --- a/foundry/src/TychoRouter.sol +++ b/foundry/src/TychoRouter.sol @@ -121,7 +121,8 @@ contract TychoRouter is * @param unwrapEth If true, unwraps the resulting WETH into native ETH and sends it to the receiver. * @param nTokens The total number of tokens involved in the swap graph (used to initialize arrays for internal calculations). * @param receiver The address to receive the output tokens. - * @param transferFromNeeded If true, the contract will transfer the input token from the caller to the receiver. Otherwise, assume funds are already in router. + * @param transferFromNeeded If true, the contract will transfer the input token from the caller to the router. + * Otherwise, assume funds are already in router or will be transferred later by the executors (This is the case for executors with callback). * @param swaps Encoded swap graph data containing details of each swap. * * @return amountOut The total amount of the output token received by the receiver. @@ -177,7 +178,8 @@ contract TychoRouter is * @param unwrapEth If true, unwraps the resulting WETH into native ETH and sends it to the receiver. * @param nTokens The total number of tokens involved in the swap graph (used to initialize arrays for internal calculations). * @param receiver The address to receive the output tokens. - * @param transferFromNeeded If true, the contract will transfer the input token from the caller to the receiver. Otherwise, assume funds are already in router. + * @param transferFromNeeded If true, the contract will transfer the input token from the caller to the router. + * Otherwise, assume funds are already in router or will be transferred later by the executors (This is the case for executors with callback). * @param permitSingle A Permit2 structure containing token approval details for the input token. Ignored if `wrapEth` is true. * @param signature A valid signature authorizing the Permit2 approval. Ignored if `wrapEth` is true. * @param swaps Encoded swap graph data containing details of each swap. @@ -240,7 +242,8 @@ contract TychoRouter is * @param wrapEth If true, wraps the input token (native ETH) into WETH. * @param unwrapEth If true, unwraps the resulting WETH into native ETH and sends it to the receiver. * @param receiver The address to receive the output tokens. - * @param transferFromNeeded If true, the contract will transfer the input token from the caller to the receiver. Otherwise, assume funds are already in router. + * @param transferFromNeeded If true, the contract will transfer the input token from the caller to the tokenInReceiver. + * Otherwise, assume funds are already in router or will be transferred later by the executors (This is the case for executors with callback). * @param tokenInReceiver The address to receive the input tokens. This is used when `transferFromNeeded` is true. * @param swaps Encoded swap graph data containing details of each swap. * @@ -294,8 +297,8 @@ contract TychoRouter is * @param wrapEth If true, wraps the input token (native ETH) into WETH. * @param unwrapEth If true, unwraps the resulting WETH into native ETH and sends it to the receiver. * @param receiver The address to receive the output tokens. - * @param transferFromNeeded If true, the contract will transfer the input token from the caller to the receiver. Otherwise, assume funds are already in router. - * @param tokenInReceiver The address to receive the input tokens. This is used when `transferFromNeeded` is true. + * @param transferFromNeeded If true, the contract will transfer the input token from the caller to the tokenInReceiver. + * Otherwise, assume funds are already in router or will be transferred later by the executors (This is the case for executors with callback). * @param tokenInReceiver The address to receive the input tokens. This is used when `transferFromNeeded` is true. * @param permitSingle A Permit2 structure containing token approval details for the input token. Ignored if `wrapEth` is true. * @param signature A valid signature authorizing the Permit2 approval. Ignored if `wrapEth` is true. * @param swaps Encoded swap graph data containing details of each swap. @@ -355,8 +358,8 @@ contract TychoRouter is * @param wrapEth If true, wraps the input token (native ETH) into WETH. * @param unwrapEth If true, unwraps the resulting WETH into native ETH and sends it to the receiver. * @param receiver The address to receive the output tokens. - * @param transferFromNeeded If true, the contract will transfer the input token from the caller to the receiver. Otherwise, assume funds are already in router. - * @param tokenInReceiver The address to receive the input tokens. This is used when `transferFromNeeded` is true. + * @param transferFromNeeded If true, the contract will transfer the input token from the caller to the tokenInReceiver. + * Otherwise, assume funds are already in router or will be transferred later by the executors (This is the case for executors with callback). * @param tokenInReceiver The address to receive the input tokens. This is used when `transferFromNeeded` is true. * @param swapData Encoded swap details. * * @return amountOut The total amount of the output token received by the receiver. @@ -409,8 +412,8 @@ contract TychoRouter is * @param wrapEth If true, wraps the input token (native ETH) into WETH. * @param unwrapEth If true, unwraps the resulting WETH into native ETH and sends it to the receiver. * @param receiver The address to receive the output tokens. - * @param transferFromNeeded If true, the contract will transfer the input token from the caller to the receiver. Otherwise, assume funds are already in router. - * @param tokenInReceiver The address to receive the input tokens. This is used when `transferFromNeeded` is true. + * @param transferFromNeeded If true, the contract will transfer the input token from the caller to the tokenInReceiver. + * Otherwise, assume funds are already in router or will be transferred later by the executors (This is the case for executors with callback). * @param tokenInReceiver The address to receive the input tokens. This is used when `transferFromNeeded` is true. * @param permitSingle A Permit2 structure containing token approval details for the input token. Ignored if `wrapEth` is true. * @param signature A valid signature authorizing the Permit2 approval. Ignored if `wrapEth` is true. * @param swapData Encoded swap details. diff --git a/foundry/src/executors/BalancerV2Executor.sol b/foundry/src/executors/BalancerV2Executor.sol index b0a6670..54958e1 100644 --- a/foundry/src/executors/BalancerV2Executor.sol +++ b/foundry/src/executors/BalancerV2Executor.sol @@ -78,6 +78,6 @@ contract BalancerV2Executor is IExecutor { tokenOut = IERC20(address(bytes20(data[20:40]))); poolId = bytes32(data[40:72]); receiver = address(bytes20(data[72:92])); - approvalNeeded = uint8(data[92]) > 0; + approvalNeeded = data[92] != 0; } } diff --git a/foundry/src/executors/UniswapV3Executor.sol b/foundry/src/executors/UniswapV3Executor.sol index cc36e11..4f0a68a 100644 --- a/foundry/src/executors/UniswapV3Executor.sol +++ b/foundry/src/executors/UniswapV3Executor.sol @@ -159,8 +159,8 @@ contract UniswapV3Executor is IExecutor, ICallback, OneTransferFromOnly { receiver = address(bytes20(data[43:63])); target = address(bytes20(data[63:83])); zeroForOne = uint8(data[83]) > 0; - transferFromNeeded = uint8(data[84]) > 0; - transferNeeded = uint8(data[85]) > 0; + transferFromNeeded = data[84] != 0; + transferNeeded = data[85] != 0; } function _makeV3CallbackData( diff --git a/foundry/src/executors/UniswapV4Executor.sol b/foundry/src/executors/UniswapV4Executor.sol index 1867a6e..7b30926 100644 --- a/foundry/src/executors/UniswapV4Executor.sol +++ b/foundry/src/executors/UniswapV4Executor.sol @@ -155,9 +155,9 @@ contract UniswapV4Executor is tokenIn = address(bytes20(data[0:20])); tokenOut = address(bytes20(data[20:40])); - zeroForOne = (data[40] != 0); - transferFromNeeded = (data[41] != 0); - transferNeeded = (data[42] != 0); + zeroForOne = data[40] != 0; + transferFromNeeded = data[41] != 0; + transferNeeded = data[42] != 0; receiver = address(bytes20(data[43:63])); uint256 poolsLength = (data.length - 63) / 26; // 26 bytes per pool object