Files
tycho-execution/foundry/interfaces/IExecutor.sol
Diana Carvalho 50429ad05c feat: Add swap method with tests
Changes:
- If the tokenIn is ETH, skip permit2 approval
- Make executors payable: When using delegatecall the executor inherits the execution context of whoever calls it. Our main swap function can accept ETH, it needs to be payable so by consequence the executors also need to be.
- Set uniswap v2 executor in test router
- Add tests for all possible cases of swap
- Add tests for all cases of splitSwap
- Add test functions to handle permit2 and encode swaps

--- don't change below this line ---
ENG-4041 Took 3 hours 50 minutes

Took 49 seconds


Took 14 seconds
2025-01-28 16:59:29 +00:00

33 lines
1.1 KiB
Solidity

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.28;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
pragma abicoder v2;
interface IExecutor {
/**
* @notice Performs a swap on a liquidity pool.
* @dev This method takes the amount of the input token and returns the amount of
* the output token which has been swapped.
*
* Note Part of the informal interface is that the executor supports sending the received
* tokens to a receiver address. If the underlying smart contract does not provide this
* functionality consider adding an additional transfer in the implementation.
*
* @param givenAmount The amount of the input token to swap.
* @param data Data that holds information necessary to perform the swap.
* @return calculatedAmount The amount of the output token swapped, depending on
* the givenAmount inputted.
*/
function swap(uint256 givenAmount, bytes calldata data)
external
payable
returns (uint256 calculatedAmount);
}
interface IExecutorErrors {
error InvalidParameterLength(uint256);
error UnknownPoolType(uint8);
}