feat: Add executor and selector to Swap

Add tests to Swap
Modify ExecutionDispatcher and TychoRouter to account for these changes

--- don't change below this line ---
ENG-4041 Took 57 minutes


Took 10 seconds
This commit is contained in:
Diana Carvalho
2025-01-28 12:19:07 +00:00
parent dfa0f7d176
commit c2347ac79e
7 changed files with 176 additions and 86 deletions

View File

@@ -11,7 +11,7 @@ import "@permit2/src/interfaces/IAllowanceTransfer.sol";
import "./ExecutionDispatcher.sol";
import "./CallbackVerificationDispatcher.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";
import {Swap} from "./Swap.sol";
import {LibSwap} from "../lib/LibSwap.sol";
error TychoRouter__WithdrawalFailed();
error TychoRouter__AddressZero();
@@ -29,7 +29,7 @@ contract TychoRouter is
using SafeERC20 for IERC20;
using LibPrefixLengthEncodedByteArray for bytes;
using Swap for bytes;
using LibSwap for bytes;
//keccak256("NAME_OF_ROLE") : save gas on deployment
bytes32 public constant EXECUTOR_SETTER_ROLE =
@@ -185,8 +185,12 @@ contract TychoRouter is
currentAmountIn = split > 0
? (amounts[tokenInIndex] * split) / 0xffffff
: remainingAmounts[tokenInIndex];
currentAmountOut =
_callExecutor(currentAmountIn, swapData.protocolData());
currentAmountOut = _callExecutor(
swapData.executor(),
swapData.executorSelector(),
currentAmountIn,
swapData.protocolData()
);
amounts[tokenOutIndex] += currentAmountOut;
remainingAmounts[tokenOutIndex] += currentAmountOut;
remainingAmounts[tokenInIndex] -= currentAmountIn;