fix: Fix tests (not there yet)

Took 58 minutes
This commit is contained in:
Diana Carvalho
2025-05-16 17:57:29 +01:00
parent eeebd51114
commit d4244a7089
23 changed files with 417 additions and 300 deletions

View File

@@ -16,7 +16,8 @@ contract BalancerV2ExecutorExposed is BalancerV2Executor {
IERC20 tokenOut,
bytes32 poolId,
address receiver,
bool needsApproval
bool needsApproval,
TransferType transferType
)
{
return _decodeData(data);
@@ -40,7 +41,12 @@ contract BalancerV2ExecutorTest is Constants, TestUtils {
function testDecodeParams() public view {
bytes memory params = abi.encodePacked(
WETH_ADDR, BAL_ADDR, WETH_BAL_POOL_ID, address(2), true
WETH_ADDR,
BAL_ADDR,
WETH_BAL_POOL_ID,
address(2),
true,
RestrictTransferFrom.TransferType.None
);
(
@@ -48,7 +54,8 @@ contract BalancerV2ExecutorTest is Constants, TestUtils {
IERC20 tokenOut,
bytes32 poolId,
address receiver,
bool needsApproval
bool needsApproval,
RestrictTransferFrom.TransferType transferType
) = balancerV2Exposed.decodeParams(params);
assertEq(address(tokenIn), WETH_ADDR);
@@ -56,6 +63,9 @@ contract BalancerV2ExecutorTest is Constants, TestUtils {
assertEq(poolId, WETH_BAL_POOL_ID);
assertEq(receiver, address(2));
assertEq(needsApproval, true);
assertEq(
uint8(transferType), uint8(RestrictTransferFrom.TransferType.None)
);
}
function testDecodeParamsInvalidDataLength() public {
@@ -89,7 +99,8 @@ contract BalancerV2ExecutorTest is Constants, TestUtils {
IERC20 tokenOut,
bytes32 poolId,
address receiver,
bool needsApproval
bool needsApproval,
RestrictTransferFrom.TransferType transferType
) = balancerV2Exposed.decodeParams(protocolData);
assertEq(address(tokenIn), WETH_ADDR);
@@ -97,6 +108,9 @@ contract BalancerV2ExecutorTest is Constants, TestUtils {
assertEq(poolId, WETH_BAL_POOL_ID);
assertEq(receiver, BOB);
assertEq(needsApproval, true);
assertEq(
uint8(transferType), uint8(RestrictTransferFrom.TransferType.None)
);
}
function testSwapIntegration() public {

View File

@@ -37,6 +37,7 @@ contract CurveExecutorExposed is CurveExecutor {
int128 i,
int128 j,
bool tokenApprovalNeeded,
RestrictTransferFrom.TransferType transferType,
address receiver
)
{
@@ -67,6 +68,7 @@ contract CurveExecutorTest is Test, Constants {
uint8(2),
uint8(0),
true,
RestrictTransferFrom.TransferType.None,
ALICE
);
@@ -78,6 +80,7 @@ contract CurveExecutorTest is Test, Constants {
int128 i,
int128 j,
bool tokenApprovalNeeded,
RestrictTransferFrom.TransferType transferType,
address receiver
) = curveExecutorExposed.decodeData(data);
@@ -88,6 +91,9 @@ contract CurveExecutorTest is Test, Constants {
assertEq(i, 2);
assertEq(j, 0);
assertEq(tokenApprovalNeeded, true);
assertEq(
uint8(transferType), uint8(RestrictTransferFrom.TransferType.None)
);
assertEq(receiver, ALICE);
}
@@ -96,7 +102,14 @@ contract CurveExecutorTest is Test, Constants {
uint256 amountIn = 1 ether;
deal(DAI_ADDR, address(curveExecutorExposed), amountIn);
bytes memory data = _getData(DAI_ADDR, USDC_ADDR, TRIPOOL, 1, ALICE);
bytes memory data = _getData(
DAI_ADDR,
USDC_ADDR,
TRIPOOL,
1,
ALICE,
RestrictTransferFrom.TransferType.None
);
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
@@ -109,8 +122,14 @@ contract CurveExecutorTest is Test, Constants {
uint256 amountIn = 1 ether;
deal(address(curveExecutorExposed), amountIn);
bytes memory data =
_getData(ETH_ADDR_FOR_CURVE, STETH_ADDR, STETH_POOL, 1, ALICE);
bytes memory data = _getData(
ETH_ADDR_FOR_CURVE,
STETH_ADDR,
STETH_POOL,
1,
ALICE,
RestrictTransferFrom.TransferType.None
);
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
@@ -126,8 +145,14 @@ contract CurveExecutorTest is Test, Constants {
uint256 amountIn = 1 ether;
deal(WETH_ADDR, address(curveExecutorExposed), amountIn);
bytes memory data =
_getData(WETH_ADDR, WBTC_ADDR, TRICRYPTO2_POOL, 3, ALICE);
bytes memory data = _getData(
WETH_ADDR,
WBTC_ADDR,
TRICRYPTO2_POOL,
3,
ALICE,
RestrictTransferFrom.TransferType.None
);
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
@@ -140,7 +165,14 @@ contract CurveExecutorTest is Test, Constants {
uint256 amountIn = 100 * 10 ** 6;
deal(USDC_ADDR, address(curveExecutorExposed), amountIn);
bytes memory data = _getData(USDC_ADDR, SUSD_ADDR, SUSD_POOL, 1, ALICE);
bytes memory data = _getData(
USDC_ADDR,
SUSD_ADDR,
SUSD_POOL,
1,
ALICE,
RestrictTransferFrom.TransferType.None
);
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
@@ -153,8 +185,14 @@ contract CurveExecutorTest is Test, Constants {
uint256 amountIn = 1 ether;
deal(FRAX_ADDR, address(curveExecutorExposed), amountIn);
bytes memory data =
_getData(FRAX_ADDR, USDC_ADDR, FRAX_USDC_POOL, 1, ALICE);
bytes memory data = _getData(
FRAX_ADDR,
USDC_ADDR,
FRAX_USDC_POOL,
1,
ALICE,
RestrictTransferFrom.TransferType.None
);
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
@@ -167,8 +205,14 @@ contract CurveExecutorTest is Test, Constants {
uint256 amountIn = 100 * 10 ** 6;
deal(USDC_ADDR, address(curveExecutorExposed), amountIn);
bytes memory data =
_getData(USDC_ADDR, USDE_ADDR, USDE_USDC_POOL, 1, ALICE);
bytes memory data = _getData(
USDC_ADDR,
USDE_ADDR,
USDE_USDC_POOL,
1,
ALICE,
RestrictTransferFrom.TransferType.None
);
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
@@ -181,8 +225,14 @@ contract CurveExecutorTest is Test, Constants {
uint256 amountIn = 100 * 10 ** 6;
deal(DOLA_ADDR, address(curveExecutorExposed), amountIn);
bytes memory data =
_getData(DOLA_ADDR, FRAXPYUSD_POOL, DOLA_FRAXPYUSD_POOL, 1, ALICE);
bytes memory data = _getData(
DOLA_ADDR,
FRAXPYUSD_POOL,
DOLA_FRAXPYUSD_POOL,
1,
ALICE,
RestrictTransferFrom.TransferType.None
);
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
@@ -196,8 +246,14 @@ contract CurveExecutorTest is Test, Constants {
uint256 initialBalance = address(ALICE).balance; // this address already has some ETH assigned to it
deal(XYO_ADDR, address(curveExecutorExposed), amountIn);
bytes memory data =
_getData(XYO_ADDR, ETH_ADDR_FOR_CURVE, ETH_XYO_POOL, 2, ALICE);
bytes memory data = _getData(
XYO_ADDR,
ETH_ADDR_FOR_CURVE,
ETH_XYO_POOL,
2,
ALICE,
RestrictTransferFrom.TransferType.None
);
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
@@ -210,8 +266,14 @@ contract CurveExecutorTest is Test, Constants {
uint256 amountIn = 1000 ether;
deal(BSGG_ADDR, address(curveExecutorExposed), amountIn);
bytes memory data =
_getData(BSGG_ADDR, USDT_ADDR, BSGG_USDT_POOL, 2, ALICE);
bytes memory data = _getData(
BSGG_ADDR,
USDT_ADDR,
BSGG_USDT_POOL,
2,
ALICE,
RestrictTransferFrom.TransferType.None
);
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
@@ -224,8 +286,14 @@ contract CurveExecutorTest is Test, Constants {
uint256 amountIn = 1 ether;
deal(WETH_ADDR, address(curveExecutorExposed), amountIn);
bytes memory data =
_getData(WETH_ADDR, USDC_ADDR, TRICRYPTO_POOL, 2, ALICE);
bytes memory data = _getData(
WETH_ADDR,
USDC_ADDR,
TRICRYPTO_POOL,
2,
ALICE,
RestrictTransferFrom.TransferType.None
);
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
@@ -238,8 +306,14 @@ contract CurveExecutorTest is Test, Constants {
uint256 amountIn = 1 ether;
deal(UWU_ADDR, address(curveExecutorExposed), amountIn);
bytes memory data =
_getData(UWU_ADDR, WETH_ADDR, UWU_WETH_POOL, 2, ALICE);
bytes memory data = _getData(
UWU_ADDR,
WETH_ADDR,
UWU_WETH_POOL,
2,
ALICE,
RestrictTransferFrom.TransferType.None
);
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
@@ -252,8 +326,14 @@ contract CurveExecutorTest is Test, Constants {
uint256 amountIn = 1 ether;
deal(USDT_ADDR, address(curveExecutorExposed), amountIn);
bytes memory data =
_getData(USDT_ADDR, CRVUSD_ADDR, CRVUSD_USDT_POOL, 1, ALICE);
bytes memory data = _getData(
USDT_ADDR,
CRVUSD_ADDR,
CRVUSD_USDT_POOL,
1,
ALICE,
RestrictTransferFrom.TransferType.None
);
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
@@ -266,8 +346,14 @@ contract CurveExecutorTest is Test, Constants {
uint256 amountIn = 100 * 10 ** 9; // 9 decimals
deal(WTAO_ADDR, address(curveExecutorExposed), amountIn);
bytes memory data =
_getData(WTAO_ADDR, WSTTAO_ADDR, WSTTAO_WTAO_POOL, 1, ALICE);
bytes memory data = _getData(
WTAO_ADDR,
WSTTAO_ADDR,
WSTTAO_WTAO_POOL,
1,
ALICE,
RestrictTransferFrom.TransferType.None
);
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
@@ -280,7 +366,8 @@ contract CurveExecutorTest is Test, Constants {
address tokenOut,
address pool,
uint8 poolType,
address receiver
address receiver,
RestrictTransferFrom.TransferType transferType
) internal view returns (bytes memory data) {
(int128 i, int128 j) = _getIndexes(tokenIn, tokenOut, pool);
data = abi.encodePacked(
@@ -291,6 +378,7 @@ contract CurveExecutorTest is Test, Constants {
uint8(uint256(uint128(i))),
uint8(uint256(uint128(j))),
true,
transferType,
receiver
);
}

View File

@@ -3,7 +3,7 @@ pragma solidity ^0.8.26;
import "../TestUtils.sol";
import {Constants} from "../Constants.sol";
import {EkuboExecutor} from "@src/executors/EkuboExecutor.sol";
import "@src/executors/EkuboExecutor.sol";
import {ICore} from "@ekubo/interfaces/ICore.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {NATIVE_TOKEN_ADDRESS} from "@ekubo/math/constants.sol";
@@ -45,8 +45,7 @@ contract EkuboExecutorTest is Constants, TestUtils {
uint256 usdcBalanceBeforeExecutor = USDC.balanceOf(address(executor));
bytes memory data = abi.encodePacked(
false, // transferFromNeeded (transfer user to core)
true, // transferNeeded (transfer from executor to core)
uint8(RestrictTransferFrom.TransferType.Transfer), // transfer type (transfer from executor to core)
address(executor), // receiver
NATIVE_TOKEN_ADDRESS, // tokenIn
USDC_ADDR, // tokenOut
@@ -83,8 +82,7 @@ contract EkuboExecutorTest is Constants, TestUtils {
uint256 ethBalanceBeforeExecutor = address(executor).balance;
bytes memory data = abi.encodePacked(
false, // transferFromNeeded (transfer user to core)
true, // transferNeeded (transfer from executor to core)
uint8(RestrictTransferFrom.TransferType.Transfer), // transferNeeded (transfer from executor to core)
address(executor), // receiver
USDC_ADDR, // tokenIn
NATIVE_TOKEN_ADDRESS, // tokenOut
@@ -142,8 +140,7 @@ contract EkuboExecutorTest is Constants, TestUtils {
// Same test case as in swap_encoder::tests::ekubo::test_encode_swap_multi
function testMultiHopSwap() public {
bytes memory data = abi.encodePacked(
false, // transferFromNeeded (transfer user to core)
true, // transferNeeded (transfer from executor to core)
uint8(RestrictTransferFrom.TransferType.Transfer), // transferNeeded (transfer from executor to core)
address(executor), // receiver
NATIVE_TOKEN_ADDRESS, // tokenIn
USDC_ADDR, // tokenOut of 1st swap

View File

@@ -17,7 +17,7 @@ contract MaverickV2ExecutorExposed is MaverickV2Executor {
IERC20 tokenIn,
address target,
address receiver,
bool transferNeeded
RestrictTransferFrom.TransferType transferType
)
{
return _decodeData(data);
@@ -39,16 +39,28 @@ contract MaverickV2ExecutorTest is TestUtils, Constants {
}
function testDecodeParams() public view {
bytes memory params =
abi.encodePacked(GHO_ADDR, GHO_USDC_POOL, address(2), true);
bytes memory params = abi.encodePacked(
GHO_ADDR,
GHO_USDC_POOL,
address(2),
true,
RestrictTransferFrom.TransferType.Transfer
);
(IERC20 tokenIn, address target, address receiver, bool transferNeeded)
= maverickV2Exposed.decodeParams(params);
(
IERC20 tokenIn,
address target,
address receiver,
RestrictTransferFrom.TransferType transferType
) = maverickV2Exposed.decodeParams(params);
assertEq(address(tokenIn), GHO_ADDR);
assertEq(target, GHO_USDC_POOL);
assertEq(receiver, address(2));
assertEq(transferNeeded, true);
assertEq(
uint8(transferType),
uint8(RestrictTransferFrom.TransferType.Transfer)
);
}
function testDecodeParamsInvalidDataLength() public {
@@ -61,8 +73,12 @@ contract MaverickV2ExecutorTest is TestUtils, Constants {
function testSwap() public {
uint256 amountIn = 10e18;
bytes memory protocolData =
abi.encodePacked(GHO_ADDR, GHO_USDC_POOL, BOB, true);
bytes memory protocolData = abi.encodePacked(
GHO_ADDR,
GHO_USDC_POOL,
BOB,
RestrictTransferFrom.TransferType.Transfer
);
deal(GHO_ADDR, address(maverickV2Exposed), amountIn);
uint256 balanceBefore = USDC.balanceOf(BOB);
@@ -79,13 +95,20 @@ contract MaverickV2ExecutorTest is TestUtils, Constants {
bytes memory protocolData =
loadCallDataFromFile("test_encode_maverick_v2");
(IERC20 tokenIn, address pool, address receiver, bool transferNeeded) =
maverickV2Exposed.decodeParams(protocolData);
(
IERC20 tokenIn,
address pool,
address receiver,
RestrictTransferFrom.TransferType transferType
) = maverickV2Exposed.decodeParams(protocolData);
assertEq(address(tokenIn), GHO_ADDR);
assertEq(pool, GHO_USDC_POOL);
assertEq(receiver, BOB);
assertEq(transferNeeded, true);
assertEq(
uint8(transferType),
uint8(RestrictTransferFrom.TransferType.Transfer)
);
}
function testSwapIntegration() public {

View File

@@ -23,7 +23,7 @@ contract UniswapV2ExecutorExposed is UniswapV2Executor {
address target,
address receiver,
bool zeroForOne,
bool transferNeeded
RestrictTransferFrom.TransferType transferType
)
{
return _decodeData(data);
@@ -82,22 +82,30 @@ contract UniswapV2ExecutorTest is Constants, Permit2TestHelper, TestUtils {
}
function testDecodeParams() public view {
bytes memory params =
abi.encodePacked(WETH_ADDR, address(2), address(3), false, true);
bytes memory params = abi.encodePacked(
WETH_ADDR,
address(2),
address(3),
false,
RestrictTransferFrom.TransferType.Transfer
);
(
IERC20 tokenIn,
address target,
address receiver,
bool zeroForOne,
bool transferNeeded
RestrictTransferFrom.TransferType transferType
) = uniswapV2Exposed.decodeParams(params);
assertEq(address(tokenIn), WETH_ADDR);
assertEq(target, address(2));
assertEq(receiver, address(3));
assertEq(zeroForOne, false);
assertEq(transferNeeded, true);
assertEq(
uint8(transferType),
uint8(RestrictTransferFrom.TransferType.Transfer)
);
}
function testDecodeParamsInvalidDataLength() public {
@@ -148,8 +156,13 @@ contract UniswapV2ExecutorTest is Constants, Permit2TestHelper, TestUtils {
uint256 amountIn = 10 ** 18;
uint256 amountOut = 1847751195973566072891;
bool zeroForOne = false;
bytes memory protocolData =
abi.encodePacked(WETH_ADDR, WETH_DAI_POOL, BOB, zeroForOne, true);
bytes memory protocolData = abi.encodePacked(
WETH_ADDR,
WETH_DAI_POOL,
BOB,
zeroForOne,
RestrictTransferFrom.TransferType.Transfer
);
deal(WETH_ADDR, address(uniswapV2Exposed), amountIn);
uniswapV2Exposed.swap(amountIn, protocolData);
@@ -162,8 +175,13 @@ contract UniswapV2ExecutorTest is Constants, Permit2TestHelper, TestUtils {
uint256 amountIn = 10 ** 18;
uint256 amountOut = 1847751195973566072891;
bool zeroForOne = false;
bytes memory protocolData =
abi.encodePacked(WETH_ADDR, WETH_DAI_POOL, BOB, zeroForOne, false);
bytes memory protocolData = abi.encodePacked(
WETH_ADDR,
WETH_DAI_POOL,
BOB,
zeroForOne,
RestrictTransferFrom.TransferType.None
);
deal(WETH_ADDR, address(this), amountIn);
IERC20(WETH_ADDR).transfer(address(WETH_DAI_POOL), amountIn);
@@ -175,21 +193,24 @@ contract UniswapV2ExecutorTest is Constants, Permit2TestHelper, TestUtils {
function testDecodeIntegration() public view {
bytes memory protocolData =
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc288e6a0c2ddd26feeb64f039a2c41296fcb3f564000000000000000000000000000000000000000010000";
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc288e6a0c2ddd26feeb64f039a2c41296fcb3f564000000000000000000000000000000000000000010001";
(
IERC20 tokenIn,
address target,
address receiver,
bool zeroForOne,
bool transferNeeded
RestrictTransferFrom.TransferType transferType
) = uniswapV2Exposed.decodeParams(protocolData);
assertEq(address(tokenIn), WETH_ADDR);
assertEq(target, 0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640);
assertEq(receiver, 0x0000000000000000000000000000000000000001);
assertEq(zeroForOne, false);
assertEq(transferNeeded, false);
assertEq(
uint8(transferType),
uint8(RestrictTransferFrom.TransferType.Transfer)
);
}
function testSwapIntegration() public {
@@ -208,8 +229,13 @@ contract UniswapV2ExecutorTest is Constants, Permit2TestHelper, TestUtils {
uint256 amountIn = 10 ** 18;
bool zeroForOne = false;
address fakePool = address(new FakeUniswapV2Pool(WETH_ADDR, DAI_ADDR));
bytes memory protocolData =
abi.encodePacked(WETH_ADDR, fakePool, BOB, zeroForOne, true);
bytes memory protocolData = abi.encodePacked(
WETH_ADDR,
fakePool,
BOB,
zeroForOne,
RestrictTransferFrom.TransferType.Transfer
);
deal(WETH_ADDR, address(uniswapV2Exposed), amountIn);
vm.expectRevert(UniswapV2Executor__InvalidTarget.selector);
@@ -223,8 +249,13 @@ contract UniswapV2ExecutorTest is Constants, Permit2TestHelper, TestUtils {
vm.rollFork(26857267);
uint256 amountIn = 10 * 10 ** 6;
bool zeroForOne = true;
bytes memory protocolData =
abi.encodePacked(BASE_USDC, USDC_MAG7_POOL, BOB, zeroForOne, true);
bytes memory protocolData = abi.encodePacked(
BASE_USDC,
USDC_MAG7_POOL,
BOB,
zeroForOne,
RestrictTransferFrom.TransferType.Transfer
);
deal(BASE_USDC, address(uniswapV2Exposed), amountIn);

View File

@@ -22,8 +22,7 @@ contract UniswapV3ExecutorExposed is UniswapV3Executor {
address receiver,
address target,
bool zeroForOne,
bool transferFromNeeded,
bool transferNeeded
RestrictTransferFrom.TransferType transferType
)
{
return _decodeData(data);
@@ -72,8 +71,7 @@ contract UniswapV3ExecutorTest is Test, Constants, Permit2TestHelper {
address(2),
address(3),
false,
false,
true
RestrictTransferFrom.TransferType.Transfer
);
(
@@ -83,8 +81,7 @@ contract UniswapV3ExecutorTest is Test, Constants, Permit2TestHelper {
address receiver,
address target,
bool zeroForOne,
bool transferFromNeeded,
bool transferNeeded
RestrictTransferFrom.TransferType transferType
) = uniswapV3Exposed.decodeData(data);
assertEq(tokenIn, WETH_ADDR);
@@ -93,8 +90,10 @@ contract UniswapV3ExecutorTest is Test, Constants, Permit2TestHelper {
assertEq(receiver, address(2));
assertEq(target, address(3));
assertEq(zeroForOne, false);
assertEq(transferFromNeeded, false);
assertEq(transferNeeded, true);
assertEq(
uint8(transferType),
uint8(RestrictTransferFrom.TransferType.Transfer)
);
}
function testSwapIntegration() public {
@@ -110,8 +109,7 @@ contract UniswapV3ExecutorTest is Test, Constants, Permit2TestHelper {
address(this),
DAI_WETH_USV3,
zeroForOne,
false,
true
RestrictTransferFrom.TransferType.Transfer
);
uint256 amountOut = uniswapV3Exposed.swap(amountIn, data);
@@ -149,7 +147,11 @@ contract UniswapV3ExecutorTest is Test, Constants, Permit2TestHelper {
vm.startPrank(DAI_WETH_USV3);
bytes memory protocolData = abi.encodePacked(
WETH_ADDR, DAI_ADDR, poolFee, false, true, address(uniswapV3Exposed)
WETH_ADDR,
DAI_ADDR,
poolFee,
RestrictTransferFrom.TransferType.Transfer,
address(uniswapV3Exposed)
);
uint256 dataOffset = 3; // some offset
uint256 dataLength = protocolData.length;
@@ -182,8 +184,7 @@ contract UniswapV3ExecutorTest is Test, Constants, Permit2TestHelper {
address(this),
fakePool,
zeroForOne,
false,
true
RestrictTransferFrom.TransferType.Transfer
);
vm.expectRevert(UniswapV3Executor__InvalidTarget.selector);
@@ -196,8 +197,7 @@ contract UniswapV3ExecutorTest is Test, Constants, Permit2TestHelper {
address receiver,
address target,
bool zero2one,
bool transferFromNeeded,
bool transferNeeded
RestrictTransferFrom.TransferType transferType
) internal view returns (bytes memory) {
IUniswapV3Pool pool = IUniswapV3Pool(target);
return abi.encodePacked(
@@ -207,8 +207,7 @@ contract UniswapV3ExecutorTest is Test, Constants, Permit2TestHelper {
receiver,
target,
zero2one,
transferFromNeeded,
transferNeeded
transferType
);
}
}

View File

@@ -21,8 +21,7 @@ contract UniswapV4ExecutorExposed is UniswapV4Executor {
address tokenIn,
address tokenOut,
bool zeroForOne,
bool transferFromNeeded,
bool transferNeeded,
RestrictTransferFrom.TransferType transferType,
address receiver,
UniswapV4Pool[] memory pools
)
@@ -53,8 +52,6 @@ contract UniswapV4ExecutorTest is Constants, TestUtils {
int24 tickSpacing1 = 60;
uint24 pool2Fee = 1000;
int24 tickSpacing2 = -10;
bool transferFromNeeded = false;
bool transferNeeded = true;
UniswapV4Executor.UniswapV4Pool[] memory pools =
new UniswapV4Executor.UniswapV4Pool[](2);
@@ -73,8 +70,7 @@ contract UniswapV4ExecutorTest is Constants, TestUtils {
USDE_ADDR,
USDT_ADDR,
zeroForOne,
transferFromNeeded,
transferNeeded,
RestrictTransferFrom.TransferType.Transfer,
ALICE,
pools
);
@@ -83,8 +79,7 @@ contract UniswapV4ExecutorTest is Constants, TestUtils {
address tokenIn,
address tokenOut,
bool zeroForOneDecoded,
bool transferFromNeededDecoded,
bool transferNeededDecoded,
RestrictTransferFrom.TransferType transferType,
address receiver,
UniswapV4Executor.UniswapV4Pool[] memory decodedPools
) = uniswapV4Exposed.decodeData(data);
@@ -92,8 +87,10 @@ contract UniswapV4ExecutorTest is Constants, TestUtils {
assertEq(tokenIn, USDE_ADDR);
assertEq(tokenOut, USDT_ADDR);
assertEq(zeroForOneDecoded, zeroForOne);
assertEq(transferFromNeededDecoded, transferFromNeeded);
assertEq(transferNeededDecoded, transferNeeded);
assertEq(
uint8(transferType),
uint8(RestrictTransferFrom.TransferType.Transfer)
);
assertEq(receiver, ALICE);
assertEq(decodedPools.length, 2);
assertEq(decodedPools[0].intermediaryToken, USDT_ADDR);
@@ -120,7 +117,12 @@ contract UniswapV4ExecutorTest is Constants, TestUtils {
});
bytes memory data = UniswapV4Utils.encodeExactInput(
USDE_ADDR, USDT_ADDR, true, false, true, ALICE, pools
USDE_ADDR,
USDT_ADDR,
true,
RestrictTransferFrom.TransferType.Transfer,
ALICE,
pools
);
uint256 amountOut = uniswapV4Exposed.swap(amountIn, data);
@@ -172,7 +174,12 @@ contract UniswapV4ExecutorTest is Constants, TestUtils {
});
bytes memory data = UniswapV4Utils.encodeExactInput(
USDE_ADDR, WBTC_ADDR, true, false, true, ALICE, pools
USDE_ADDR,
WBTC_ADDR,
true,
RestrictTransferFrom.TransferType.Transfer,
ALICE,
pools
);
uint256 amountOut = uniswapV4Exposed.swap(amountIn, data);

View File

@@ -8,8 +8,7 @@ library UniswapV4Utils {
address tokenIn,
address tokenOut,
bool zeroForOne,
bool transferFromNeeded,
bool transferNeeded,
RestrictTransferFrom.TransferType transferType,
address receiver,
UniswapV4Executor.UniswapV4Pool[] memory pools
) public pure returns (bytes memory) {
@@ -25,13 +24,7 @@ library UniswapV4Utils {
}
return abi.encodePacked(
tokenIn,
tokenOut,
zeroForOne,
transferFromNeeded,
transferNeeded,
receiver,
encodedPools
tokenIn, tokenOut, zeroForOne, transferType, receiver, encodedPools
);
}
}