diff --git a/foundry/test/TychoRouterSingleSwap.t.sol b/foundry/test/TychoRouterSingleSwap.t.sol index 8e3bb0e..fdc1410 100644 --- a/foundry/test/TychoRouterSingleSwap.t.sol +++ b/foundry/test/TychoRouterSingleSwap.t.sol @@ -426,36 +426,3 @@ contract TychoRouterSingleSwapTest is TychoRouterTestSetup { assertEq(balanceAfter - balanceBefore, 2018817438608734439722); } } - -contract TychoRouterSingleSwapTestForHashflow is TychoRouterTestSetup { - function getForkBlock() public pure override returns (uint256) { - return 23175437; - } - - function testUSV3HashflowIntegration() public { - // Performs a swap from USDC to WBTC using Hashflow RFQ - // - // USDC ───(Hashflow RFQ)──> WBTC - - // The Hashflow order expects: - // - 4308094737 USDC input -> 3714751 WBTC output - - uint256 amountIn = 4308094737; - uint256 expectedAmountOut = 3714751; - deal(USDC_ADDR, ALICE, amountIn); - uint256 balanceBefore = IERC20(WBTC_ADDR).balanceOf(ALICE); - - vm.startPrank(ALICE); - IERC20(USDC_ADDR).approve(tychoRouterAddr, type(uint256).max); - bytes memory callData = loadCallDataFromFile("test_hashflow"); - (bool success,) = tychoRouterAddr.call(callData); - - vm.stopPrank(); - - uint256 balanceAfter = IERC20(WBTC_ADDR).balanceOf(ALICE); - - assertTrue(success, "Call Failed"); - assertEq(balanceAfter - balanceBefore, expectedAmountOut); - assertEq(IERC20(WETH_ADDR).balanceOf(tychoRouterAddr), 0); - } -} diff --git a/foundry/test/protocols/Hashflow.t.sol b/foundry/test/protocols/Hashflow.t.sol index 2ed8eca..42d32b9 100644 --- a/foundry/test/protocols/Hashflow.t.sol +++ b/foundry/test/protocols/Hashflow.t.sol @@ -280,3 +280,36 @@ contract HashflowExecutorExposed is HashflowExecutor { return _decodeData(data); } } + +contract TychoRouterSingleSwapTestForHashflow is TychoRouterTestSetup { + function getForkBlock() public pure override returns (uint256) { + return 23175437; + } + + function testHashflowIntegration() public { + // Performs a swap from USDC to WBTC using Hashflow RFQ + // + // USDC ───(Hashflow RFQ)──> WBTC + + // The Hashflow order expects: + // - 4308094737 USDC input -> 3714751 WBTC output + + uint256 amountIn = 4308094737; + uint256 expectedAmountOut = 3714751; + deal(USDC_ADDR, ALICE, amountIn); + uint256 balanceBefore = IERC20(WBTC_ADDR).balanceOf(ALICE); + + vm.startPrank(ALICE); + IERC20(USDC_ADDR).approve(tychoRouterAddr, type(uint256).max); + bytes memory callData = loadCallDataFromFile("test_hashflow"); + (bool success,) = tychoRouterAddr.call(callData); + + vm.stopPrank(); + + uint256 balanceAfter = IERC20(WBTC_ADDR).balanceOf(ALICE); + + assertTrue(success, "Call Failed"); + assertEq(balanceAfter - balanceBefore, expectedAmountOut); + assertEq(IERC20(WETH_ADDR).balanceOf(tychoRouterAddr), 0); + } +}