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

@@ -198,8 +198,6 @@ contract TychoRouterTestProtocolIntegration is TychoRouterTestSetup {
}
function testSingleMaverickIntegration() public {
vm.stopPrank();
deal(GHO_ADDR, ALICE, 1 ether);
uint256 balanceBefore = IERC20(USDC_ADDR).balanceOf(ALICE);
@@ -295,4 +293,25 @@ contract TychoRouterTestProtocolIntegration is TychoRouterTestSetup {
vm.stopPrank();
}
function testSingleBalancerV3Integration() public {
address steakUSDTlite =
address(0x097FFEDb80d4b2Ca6105a07a4D90eB739C45A666);
address steakUSDR = address(0x30881Baa943777f92DC934d53D3bFdF33382cab3);
deal(steakUSDTlite, ALICE, 1 ether);
uint256 balanceBefore = IERC20(steakUSDTlite).balanceOf(ALICE);
vm.startPrank(ALICE);
IERC20(steakUSDTlite).approve(tychoRouterAddr, type(uint256).max);
bytes memory callData =
loadCallDataFromFile("test_single_encoding_strategy_balancer_v3");
(bool success,) = tychoRouterAddr.call(callData);
uint256 balanceAfter = IERC20(steakUSDR).balanceOf(ALICE);
assertTrue(success, "Call Failed");
assertGe(balanceAfter - balanceBefore, 999725);
assertEq(IERC20(steakUSDR).balanceOf(tychoRouterAddr), 0);
}
}