feat: Set swap executors and verifiers
- Moved the deployment method into a test template for organization - Created skeletons of dispatcher contracts - Added all possible test cases for thoroughness
This commit is contained in:
@@ -2,14 +2,22 @@
|
||||
pragma solidity ^0.8.28;
|
||||
|
||||
import "@openzeppelin/contracts/access/AccessControl.sol";
|
||||
import "@permit2/src/interfaces/IAllowanceTransfer.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
||||
import "@permit2/src/interfaces/IAllowanceTransfer.sol";
|
||||
import "./SwapExecutionDispatcher.sol";
|
||||
import "./CallbackVerificationDispatcher.sol";
|
||||
|
||||
error TychoRouter__WithdrawalFailed();
|
||||
error TychoRouter__InvalidReceiver();
|
||||
error TychoRouter__NonContractExecutor();
|
||||
error TychoRouter__NonContractVerifier();
|
||||
|
||||
contract TychoRouter is AccessControl {
|
||||
contract TychoRouter is
|
||||
AccessControl,
|
||||
SwapExecutionDispatcher,
|
||||
CallbackVerificationDispatcher
|
||||
{
|
||||
IAllowanceTransfer public immutable permit2;
|
||||
|
||||
using SafeERC20 for IERC20;
|
||||
@@ -68,7 +76,55 @@ contract TychoRouter is AccessControl {
|
||||
external
|
||||
onlyRole(DEFAULT_ADMIN_ROLE)
|
||||
{
|
||||
// TODO
|
||||
for (uint256 i = 0; i < accounts.length; i++) {
|
||||
_grantRole(role, accounts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Entrypoint to add or replace an approved swap executor contract address
|
||||
* @param target address of the swap method contract
|
||||
*/
|
||||
function setSwapExecutor(address target)
|
||||
external
|
||||
onlyRole(EXECUTOR_SETTER_ROLE)
|
||||
{
|
||||
if (target.code.length == 0) revert TychoRouter__NonContractExecutor();
|
||||
swapExecutors[target] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Entrypoint to remove an approved swap executor contract address
|
||||
* @param target address of the swap method contract
|
||||
*/
|
||||
function removeSwapExecutor(address target)
|
||||
external
|
||||
onlyRole(EXECUTOR_SETTER_ROLE)
|
||||
{
|
||||
delete swapExecutors[target];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Entrypoint to add or replace an approved swap executor contract address
|
||||
* @param target address of the swap method contract
|
||||
*/
|
||||
function setCallbackVerifier(address target)
|
||||
external
|
||||
onlyRole(EXECUTOR_SETTER_ROLE)
|
||||
{
|
||||
if (target.code.length == 0) revert TychoRouter__NonContractVerifier();
|
||||
callbackVerifiers[target] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Entrypoint to remove an approved swap executor contract address
|
||||
* @param target address of the swap method contract
|
||||
*/
|
||||
function removeCallbackVerifier(address target)
|
||||
external
|
||||
onlyRole(EXECUTOR_SETTER_ROLE)
|
||||
{
|
||||
delete callbackVerifiers[target];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user