fix: USV3 encoding/decoding after rebase

- Also do some renamings and comment improvements:
transfer method -> type
- Remove integration tests since we no longer support direct calls to USV3 executor, even for testing.
This commit is contained in:
TAMARA LIPOWSKI
2025-04-14 11:23:08 -04:00
committed by Diana Carvalho
parent 7e98145ad7
commit f3c4128eda
5 changed files with 29 additions and 107 deletions

View File

@@ -5,7 +5,7 @@ import "@interfaces/IExecutor.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@permit2/src/interfaces/IAllowanceTransfer.sol";
error TokenTransfer__InvalidPermit2();
error TokenTransfer__AddressZero();
contract TokenTransfer {
using SafeERC20 for IERC20;
@@ -25,7 +25,7 @@ contract TokenTransfer {
constructor(address _permit2) {
if (_permit2 == address(0)) {
revert TokenTransfer__InvalidPermit2();
revert TokenTransfer__AddressZero();
}
permit2 = IAllowanceTransfer(_permit2);
}

View File

@@ -11,6 +11,7 @@ error UniswapV3Executor__InvalidDataLength();
error UniswapV3Executor__InvalidFactory();
error UniswapV3Executor__InvalidTarget();
error UniswapV3Executor__InvalidInitCode();
error UniswapV3Executor__InvalidTransferType(uint8 transferType);
contract UniswapV3Executor is IExecutor, ICallback, TokenTransfer {
using SafeERC20 for IERC20;
@@ -97,12 +98,13 @@ contract UniswapV3Executor is IExecutor, ICallback, TokenTransfer {
address tokenIn = address(bytes20(msgData[132:152]));
require(
uint8(msgData[171]) <= uint8(TransferType.NONE),
"InvalidTransferMethod"
);
TransferType transferType = TransferType(uint8(msgData[171]));
address sender = address(bytes20(msgData[172:192]));
// Transfer type does not exist
if (uint8(msgData[175]) > uint8(TransferType.NONE)) {
revert UniswapV3Executor__InvalidTransferType(uint8(msgData[175]));
}
TransferType transferType = TransferType(uint8(msgData[175]));
address sender = address(bytes20(msgData[176:196]));
verifyCallback(msgData[132:]);
@@ -168,7 +170,7 @@ contract UniswapV3Executor is IExecutor, ICallback, TokenTransfer {
TransferType transferType
) internal view returns (bytes memory) {
return abi.encodePacked(
tokenIn, tokenOut, fee, uint8(transferType), msg.sender, self
tokenIn, tokenOut, fee, uint8(transferType), msg.sender
);
}