feat: Add sequential swap methods

- Add some basic tests (will add more in next commits)
- Adapt sequential tests (which originally tested split swap)
- Adapt a forgotten single swap test

TODO:
- Fix encoding of single and sequential swaps to not expect the split sawp format every time (the split and the token indices are not necessary and consume unnecessary gas).
This commit is contained in:
TAMARA LIPOWSKI
2025-03-17 23:50:39 -04:00
committed by Diana Carvalho
parent 8f2346330a
commit 3ae9d3ad67
3 changed files with 221 additions and 5 deletions

View File

@@ -29,6 +29,13 @@ contract TychoRouterExposed is TychoRouter {
) external returns (uint256) {
return _splitSwap(amountIn, nTokens, swaps);
}
function exposedSequentialSwap(
uint256 amountIn,
bytes calldata swaps
) external returns (uint256) {
return _sequentialSwap(amountIn, swaps);
}
}
contract TychoRouterTestSetup is Constants {
@@ -193,6 +200,18 @@ contract TychoRouterTestSetup is Constants {
);
}
function encodeSequentialSwap(
uint8 tokenInIndex,
uint8 tokenOutIndex,
uint24 split,
address executor,
bytes memory protocolData
) internal pure returns (bytes memory) {
return abi.encodePacked(
tokenInIndex, tokenOutIndex, split, executor, protocolData
);
}
function encodeUniswapV2Swap(
address tokenIn,
address target,