Encoding: integration tests are now separate and inside their own test folder Execution: the final integration test should be inside of the protocol test file now and not in TychoRouterProtocolIntegration.t.sol. For this I had to move the BebopExecutionHarness.t.sol outside of the Bebop test file (because of imports) Took 24 minutes # Commit time for manual adjustment: # Took 2 minutes
53 lines
1.8 KiB
Solidity
53 lines
1.8 KiB
Solidity
// SPDX-License-Identifier: BUSL-1.1
|
|
pragma solidity ^0.8.26;
|
|
|
|
import "./TychoRouterTestSetup.sol";
|
|
import "./protocols/UniswapV4Utils.sol";
|
|
import "@src/executors/BebopExecutor.sol";
|
|
|
|
contract TychoRouterTestProtocolIntegration is TychoRouterTestSetup {
|
|
function testMultiProtocolIntegration() public {
|
|
// Test created with calldata from our router encoder.
|
|
//
|
|
// DAI ─(USV2)─> WETH ─(bal)─> WBTC ─(curve)─> USDT ─(ekubo)─> ETH ─(USV4)─> USDC
|
|
|
|
deal(DAI_ADDR, ALICE, 1500 ether);
|
|
uint256 balanceBefore = address(ALICE).balance;
|
|
|
|
// Approve permit2
|
|
vm.startPrank(ALICE);
|
|
IERC20(DAI_ADDR).approve(PERMIT2_ADDRESS, type(uint256).max);
|
|
bytes memory callData = loadCallDataFromFile("test_multi_protocol");
|
|
(bool success,) = tychoRouterAddr.call(callData);
|
|
|
|
vm.stopPrank();
|
|
|
|
uint256 balanceAfter = address(ALICE).balance;
|
|
|
|
assertTrue(success, "Call Failed");
|
|
assertEq(balanceAfter - balanceBefore, 732214216964381330);
|
|
}
|
|
|
|
function testSingleUSV4IntegrationInputETH() public {
|
|
// Test created with calldata from our router encoder.
|
|
|
|
// Performs a single swap from ETH to PEPE without wrapping or unwrapping
|
|
//
|
|
// ETH ───(USV4)──> PEPE
|
|
//
|
|
deal(ALICE, 1 ether);
|
|
uint256 balanceBefore = IERC20(PEPE_ADDR).balanceOf(ALICE);
|
|
|
|
bytes memory callData =
|
|
loadCallDataFromFile("test_single_encoding_strategy_usv4_eth_in");
|
|
(bool success,) = tychoRouterAddr.call{value: 1 ether}(callData);
|
|
|
|
vm.stopPrank();
|
|
|
|
uint256 balanceAfter = IERC20(PEPE_ADDR).balanceOf(ALICE);
|
|
|
|
assertTrue(success, "Call Failed");
|
|
assertEq(balanceAfter - balanceBefore, 235610487387677804636755778);
|
|
}
|
|
}
|