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

@@ -101,4 +101,23 @@ contract BalancerV3ExecutorTest is Constants, TestUtils {
assertGt(balanceAfter, balanceBefore);
assertEq(balanceAfter - balanceBefore, amountOut);
}
function testSwapIntegration() public {
bytes memory protocolData =
loadCallDataFromFile("test_encode_balancer_v3");
uint256 amountIn = 10 ** 18;
address waEthUSDT_ADDR =
address(0x7Bc3485026Ac48b6cf9BaF0A377477Fff5703Af8);
address aaveGHO_ADDR =
address(0xC71Ea051a5F82c67ADcF634c36FFE6334793D24C);
deal(waEthUSDT_ADDR, address(balancerV3Exposed), amountIn);
uint256 balanceBefore = IERC20(aaveGHO_ADDR).balanceOf(BOB);
uint256 amountOut = balancerV3Exposed.swap(amountIn, protocolData);
uint256 balanceAfter = IERC20(aaveGHO_ADDR).balanceOf(BOB);
assertGt(balanceAfter, balanceBefore);
assertEq(balanceAfter - balanceBefore, amountOut);
}
}