test: Sequential swap integration test
- And other small fixes after merge
This commit is contained in:
committed by
Diana Carvalho
parent
0d8150e22f
commit
c67c9acac4
@@ -28,6 +28,39 @@ contract TychoRouterTestIntegration is TychoRouterTestSetup {
|
||||
assertEq(balancerAfter - balancerBefore, 2659881924818443699787);
|
||||
}
|
||||
|
||||
function testSequentialIntegration() public {
|
||||
// Test created with calldata from our router encoder, replacing the executor
|
||||
// address with the USV2 executor address.
|
||||
|
||||
// Note: This test does not assert anything. It is only used to obtain integration test
|
||||
// data for our router solidity test.
|
||||
//
|
||||
// Performs a split swap from WETH to USDC though WBTC and DAI using USV2 pools
|
||||
//
|
||||
// WETH ───(USV2)──> WBTC ───(USV2)──> USDC
|
||||
|
||||
deal(WETH_ADDR, ALICE, 1 ether);
|
||||
uint256 balancerBefore = IERC20(DAI_ADDR).balanceOf(ALICE);
|
||||
|
||||
// Approve permit2
|
||||
vm.startPrank(ALICE);
|
||||
IERC20(WETH_ADDR).approve(PERMIT2_ADDRESS, type(uint256).max);
|
||||
// Encoded solution generated using `test_split_swap_strategy_encoder_simple`
|
||||
// but manually replacing the executor address
|
||||
// `5c2f5a71f67c01775180adc06909288b4c329308` with the one in this test
|
||||
// `5615deb798bb3e4dfa0139dfa1b3d433cc23b72f`
|
||||
(bool success,) = tychoRouterAddr.call(
|
||||
hex"51bcc7b60000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000018f61ec00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc2000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000681632fc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000003ede3eca2a72b3aecc820e955b36f38437d013950000000000000000000000000000000000000000000000000000000067eead0400000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000000041e396cbca5c5cfa3ea8a9ed8b63a4ac3a8b079e4de510d79f656cd660303e69482f89ed071d177b3ac73030619cc15e5ca42a41543551e47d67089437166978a01c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a60051f6c5be66fff9dc69962d73da0a617a827c382329c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2bb2b8038a1640196fbe3e38816f3e67cba72d9403ede3eca2a72b3aecc820e955b36f38437d01395000051f6c5be66fff9dc69962d73da0a617a827c3823292260fac5e5542a773aa44fbcfedf7c193bc2c599004375dff511095cc5a197a54140a24efef3a4163ede3eca2a72b3aecc820e955b36f38437d01395010000000000000000000000000000000000000000000000000000"
|
||||
);
|
||||
|
||||
vm.stopPrank();
|
||||
|
||||
uint256 balancerAfter = IERC20(DAI_ADDR).balanceOf(ALICE);
|
||||
|
||||
assertTrue(success, "Call Failed");
|
||||
assertEq(balancerAfter - balancerBefore, 2659881924818443699787);
|
||||
}
|
||||
|
||||
function testSplitSwapSingleWithoutPermit2Integration() public {
|
||||
// Test created with calldata from our router encoder, replacing the executor
|
||||
// address with the USV2 executor address.
|
||||
@@ -244,6 +277,36 @@ contract TychoRouterTestIntegration is TychoRouterTestSetup {
|
||||
assertEq(IERC20(WETH_ADDR).balanceOf(tychoRouterAddr), 0);
|
||||
}
|
||||
|
||||
function testSequentialSwapIntegration() public {
|
||||
// Test created with calldata from our router encoder, replacing the executor
|
||||
// address with the USV2 executor address.
|
||||
|
||||
// Performs a split swap from WETH to USDC though WBTC and DAI using USV2 pools
|
||||
//
|
||||
// WETH ──(USV2)──> WBTC ───(USV2)──> USDC
|
||||
deal(WETH_ADDR, ALICE, 1 ether);
|
||||
uint256 balancerBefore = IERC20(USDC_ADDR).balanceOf(ALICE);
|
||||
|
||||
// Approve permit2
|
||||
vm.startPrank(ALICE);
|
||||
IERC20(WETH_ADDR).approve(PERMIT2_ADDRESS, type(uint256).max);
|
||||
// Encoded solution generated using `test_split_swap_strategy_encoder_complex`
|
||||
(bool success,) = tychoRouterAddr.call(
|
||||
hex"51bcc7b60000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000018f61ec00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc2000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000068168aea00000000000000000000000000000000000000000000000000000000000000000000000000000000000000003ede3eca2a72b3aecc820e955b36f38437d013950000000000000000000000000000000000000000000000000000000067ef04f200000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000004154956683effd126a9182e2d82ebd3d778e5283b93d571b13cdbc9dfbf3d9f655057a2332ed566f79bed7514a22ef1c52969132bc71a5a2ef125d78e39ec264511c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a600515615deb798bb3e4dfa0139dfa1b3d433cc23b72fc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2bb2b8038a1640196fbe3e38816f3e67cba72d9403ede3eca2a72b3aecc820e955b36f38437d013950000515615deb798bb3e4dfa0139dfa1b3d433cc23b72f2260fac5e5542a773aa44fbcfedf7c193bc2c599004375dff511095cc5a197a54140a24efef3a4163ede3eca2a72b3aecc820e955b36f38437d01395010000000000000000000000000000000000000000000000000000"
|
||||
);
|
||||
|
||||
vm.stopPrank();
|
||||
|
||||
uint256 balancerAfter = IERC20(USDC_ADDR).balanceOf(ALICE);
|
||||
|
||||
assertTrue(success, "Call Failed");
|
||||
assertEq(balancerAfter - balancerBefore, 2552915143);
|
||||
|
||||
// All input tokens are transferred to the router at first. Make sure we used
|
||||
// all of it (and thus our splits are correct).
|
||||
assertEq(IERC20(WETH_ADDR).balanceOf(tychoRouterAddr), 0);
|
||||
}
|
||||
|
||||
function testCyclicSequentialSwapIntegration() public {
|
||||
deal(USDC_ADDR, ALICE, 100 * 10 ** 6);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user