feat: Support new transfer logic in all executors

TODO:
- Fix failing tests
- Remove permit2 from initialization of contracts
This commit is contained in:
TAMARA LIPOWSKI
2025-05-14 20:42:19 -04:00
parent 0f9af65846
commit 27dfde3118
22 changed files with 378 additions and 462 deletions

View File

@@ -4,7 +4,6 @@ pragma solidity ^0.8.26;
import "../../src/executors/UniswapV4Executor.sol";
import "../TestUtils.sol";
import "./UniswapV4Utils.sol";
import "@src/executors/TokenTransfer.sol";
import "@src/executors/UniswapV4Executor.sol";
import {Constants} from "../Constants.sol";
import {SafeCallback} from "@uniswap/v4-periphery/src/base/SafeCallback.sol";
@@ -22,7 +21,8 @@ contract UniswapV4ExecutorExposed is UniswapV4Executor {
address tokenIn,
address tokenOut,
bool zeroForOne,
TokenTransfer.TransferType transferType,
bool transferFromNeeded,
bool transferNeeded,
address receiver,
UniswapV4Pool[] memory pools
)
@@ -53,8 +53,8 @@ contract UniswapV4ExecutorTest is Constants, TestUtils {
int24 tickSpacing1 = 60;
uint24 pool2Fee = 1000;
int24 tickSpacing2 = -10;
TokenTransfer.TransferType transferType =
TokenTransfer.TransferType.TRANSFER_FROM_TO_PROTOCOL;
bool transferFromNeeded = false;
bool transferNeeded = true;
UniswapV4Executor.UniswapV4Pool[] memory pools =
new UniswapV4Executor.UniswapV4Pool[](2);
@@ -70,14 +70,21 @@ contract UniswapV4ExecutorTest is Constants, TestUtils {
});
bytes memory data = UniswapV4Utils.encodeExactInput(
USDE_ADDR, USDT_ADDR, zeroForOne, transferType, ALICE, pools
USDE_ADDR,
USDT_ADDR,
zeroForOne,
transferFromNeeded,
transferNeeded,
ALICE,
pools
);
(
address tokenIn,
address tokenOut,
bool zeroForOneDecoded,
TokenTransfer.TransferType transferTypeDecoded,
bool transferFromNeededDecoded,
bool transferNeededDecoded,
address receiver,
UniswapV4Executor.UniswapV4Pool[] memory decodedPools
) = uniswapV4Exposed.decodeData(data);
@@ -85,7 +92,8 @@ contract UniswapV4ExecutorTest is Constants, TestUtils {
assertEq(tokenIn, USDE_ADDR);
assertEq(tokenOut, USDT_ADDR);
assertEq(zeroForOneDecoded, zeroForOne);
assertEq(uint8(transferTypeDecoded), uint8(transferType));
assertEq(transferFromNeededDecoded, transferFromNeeded);
assertEq(transferNeededDecoded, transferNeeded);
assertEq(receiver, ALICE);
assertEq(decodedPools.length, 2);
assertEq(decodedPools[0].intermediaryToken, USDT_ADDR);
@@ -112,12 +120,7 @@ contract UniswapV4ExecutorTest is Constants, TestUtils {
});
bytes memory data = UniswapV4Utils.encodeExactInput(
USDE_ADDR,
USDT_ADDR,
true,
TokenTransfer.TransferType.TRANSFER_TO_PROTOCOL,
ALICE,
pools
USDE_ADDR, USDT_ADDR, true, false, true, ALICE, pools
);
uint256 amountOut = uniswapV4Exposed.swap(amountIn, data);
@@ -169,12 +172,7 @@ contract UniswapV4ExecutorTest is Constants, TestUtils {
});
bytes memory data = UniswapV4Utils.encodeExactInput(
USDE_ADDR,
WBTC_ADDR,
true,
TokenTransfer.TransferType.TRANSFER_TO_PROTOCOL,
ALICE,
pools
USDE_ADDR, WBTC_ADDR, true, false, true, ALICE, pools
);
uint256 amountOut = uniswapV4Exposed.swap(amountIn, data);