feat: Add integration tests for balancer v3

Refactor BalancerV3Executor to have an inner _swapCallback method with the real swapping logic. Then we have two external methods:
- handleCallback: called by the router. Here we need to remove the first 68 bytes (4 selector + 32 dataOffset + 32 dataLength)
- swapCallback: called by the Vault directly if we are swapping against the executor directly (no router involved)

Took 1 minute
This commit is contained in:
Diana Carvalho
2025-06-05 17:12:58 +01:00
parent 06ce28c8fd
commit 269e328b5f
5 changed files with 82 additions and 19 deletions

View File

@@ -16,6 +16,7 @@ import {WETH} from "../lib/permit2/lib/solmate/src/tokens/WETH.sol";
import {Permit2TestHelper} from "./Permit2TestHelper.sol";
import "./TestUtils.sol";
import {MaverickV2Executor} from "../src/executors/MaverickV2Executor.sol";
import {BalancerV3Executor} from "../src/executors/BalancerV3Executor.sol";
contract TychoRouterExposed is TychoRouter {
constructor(address _permit2, address weth) TychoRouter(_permit2, weth) {}
@@ -66,6 +67,7 @@ contract TychoRouterTestSetup is Constants, Permit2TestHelper, TestUtils {
EkuboExecutor public ekuboExecutor;
CurveExecutor public curveExecutor;
MaverickV2Executor public maverickv2Executor;
BalancerV3Executor public balancerV3Executor;
MockERC20[] tokens;
function setUp() public {
@@ -125,8 +127,9 @@ contract TychoRouterTestSetup is Constants, Permit2TestHelper, TestUtils {
curveExecutor = new CurveExecutor(ETH_ADDR_FOR_CURVE, PERMIT2_ADDRESS);
maverickv2Executor =
new MaverickV2Executor(MAVERICK_V2_FACTORY, PERMIT2_ADDRESS);
balancerV3Executor = new BalancerV3Executor(PERMIT2_ADDRESS);
address[] memory executors = new address[](8);
address[] memory executors = new address[](9);
executors[0] = address(usv2Executor);
executors[1] = address(usv3Executor);
executors[2] = address(pancakev3Executor);
@@ -135,6 +138,8 @@ contract TychoRouterTestSetup is Constants, Permit2TestHelper, TestUtils {
executors[5] = address(ekuboExecutor);
executors[6] = address(curveExecutor);
executors[7] = address(maverickv2Executor);
executors[8] = address(balancerV3Executor);
return executors;
}