From c940d8b5366f463116b64dc24ddde56e87decace Mon Sep 17 00:00:00 2001 From: Diana Carvalho Date: Tue, 18 Feb 2025 14:59:26 +0000 Subject: [PATCH] docs(univ3): Add comment explaining msg.data Took 55 minutes --- foundry/src/TychoRouter.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/foundry/src/TychoRouter.sol b/foundry/src/TychoRouter.sol index 60a9560..9e16b61 100644 --- a/foundry/src/TychoRouter.sol +++ b/foundry/src/TychoRouter.sol @@ -365,6 +365,8 @@ contract TychoRouter is AccessControl, Dispatcher, Pausable, ReentrancyGuard { bytes calldata data ) external { if (data.length < 24) revert TychoRouter__InvalidDataLength(); + // We are taking advantage of the fact that the data we need is already encoded in the correct format inside msg.data + // This way we preserve the bytes calldata (and don't need to convert it to bytes memory) uint256 dataOffset = 4 + 32 + 32 + 32; // Skip selector + 2 ints + data_offset uint256 dataLength = uint256(bytes32(msg.data[dataOffset:dataOffset + 32]));