From 529456f40cee3e555090d7defdf50c9c341e6c50 Mon Sep 17 00:00:00 2001 From: royvardhan Date: Tue, 18 Feb 2025 21:24:49 +0530 Subject: [PATCH] feat: add single swap integration test for usv4 executor --- .../test/executors/UniswapV4Executor.t.sol | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/foundry/test/executors/UniswapV4Executor.t.sol b/foundry/test/executors/UniswapV4Executor.t.sol index e35b676..61a10ce 100644 --- a/foundry/test/executors/UniswapV4Executor.t.sol +++ b/foundry/test/executors/UniswapV4Executor.t.sol @@ -133,6 +133,27 @@ contract UniswapV4ExecutorTest is Test, Constants { assertTrue(USDT.balanceOf(address(uniswapV4Exposed)) == amountOut); } + function testSingleSwapIntegration() public { + // USDE -> USDT + // Generated by the Tycho swap encoder - test_encode_uniswap_v4 + bytes memory protocolData = + hex"4c9edd5852cd905f086c759e8383e09bff1e68b3dac17f958d2ee523a2206206994597c13d831ec70000000000000000000000000000000000000000000000000000000000000001015615deb798bb3e4dfa0139dfa1b3d433cc23b72f91dd7346dac17f958d2ee523a2206206994597c13d831ec7000064000001"; + + 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(USDT.balanceOf(address(uniswapV4Exposed)) == amountOut); + } + function testMultipleSwap() public { // USDE -> USDT -> WBTC uint256 amountIn = 100 ether;