feat: add integration test for complex swaps

This commit is contained in:
royvardhan
2025-02-19 20:32:55 +05:30
parent baeebb9fe4
commit 5e9b38876e
2 changed files with 154 additions and 3 deletions

View File

@@ -195,4 +195,27 @@ contract UniswapV4ExecutorTest is Test, Constants {
IERC20(WBTC_ADDR).balanceOf(address(uniswapV4Exposed)) == amountOut
);
}
function testMultipleSwapIntegration() public {
// USDE -> USDT -> WBTC ->
// Generated by the Tycho swap encoder - test_encode_uniswap_v4_combined
bytes memory protocolData =
hex"4c9edd5852cd905f086c759e8383e09bff1e68b32260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000000000001015615deb798bb3e4dfa0139dfa1b3d433cc23b72f91dd7346dac17f958d2ee523a2206206994597c13d831ec70000640000012260fac5e5542a773aa44fbcfedf7c193bc2c599000bb800003c";
uint256 amountIn = 100 ether;
deal(USDE_ADDR, address(uniswapV4Exposed), amountIn);
uint256 usdeBalanceBeforePool = USDE.balanceOf(poolManager);
uint256 usdeBalanceBeforeSwapExecutor =
USDE.balanceOf(address(uniswapV4Exposed));
uint256 amountOut = uniswapV4Exposed.swap(amountIn, protocolData);
assertEq(USDE.balanceOf(poolManager), usdeBalanceBeforePool + amountIn);
assertEq(
USDE.balanceOf(address(uniswapV4Exposed)),
usdeBalanceBeforeSwapExecutor - amountIn
);
assertTrue(
IERC20(WBTC_ADDR).balanceOf(address(uniswapV4Exposed)) == amountOut
);
}
}