chore: Improve docstrings and decode bools always the same way

Took 26 minutes
This commit is contained in:
Diana Carvalho
2025-05-15 18:01:27 +01:00
parent 7fd9f611e5
commit 0b5233ead4
4 changed files with 18 additions and 15 deletions

View File

@@ -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.

View File

@@ -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;
}
}

View File

@@ -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(

View File

@@ -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