feat: initial TychoRouter skeleton
- remappings.txt is used for more elegant imports - decided not to include all helper methods in skeleton - just main swap method. They are properly documented in the jira tasks. - add filter-paths to slither to exclude submodules, otherwise we will get slither warnings about permit2 and open-zeppelin using different solidity versions: ``` - Version constraint ^0.8.20 is used by: -^0.8.20 (lib/openzeppelin-contracts/contracts/access/AccessControl.sol#4) -^0.8.20 (lib/openzeppelin-contracts/contracts/access/IAccessControl.sol#4) -^0.8.20 (lib/openzeppelin-contracts/contracts/utils/Context.sol#4) -^0.8.20 (lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol#4) -^0.8.20 (lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol#4) - Version constraint ^0.8.0 is used by: -^0.8.0 (lib/permit2/src/interfaces/IAllowanceTransfer.sol#2) -^0.8.0 (lib/permit2/src/interfaces/IEIP712.sol#2) - Version constraint ^0.8.28 is used by: ```
This commit is contained in:
@@ -1,6 +1,68 @@
|
||||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity ^0.8.28;
|
||||
|
||||
contract TychoRouter {
|
||||
constructor() {}
|
||||
import "@openzeppelin/contracts/access/AccessControl.sol";
|
||||
import "@permit2/src/interfaces/IAllowanceTransfer.sol";
|
||||
|
||||
contract TychoRouter is AccessControl {
|
||||
IAllowanceTransfer public immutable permit2;
|
||||
|
||||
//keccak256("NAME_OF_ROLE") : save gas on deployment
|
||||
bytes32 public constant EXECUTOR_SETTER_ROLE =
|
||||
0x6a1dd52dcad5bd732e45b6af4e7344fa284e2d7d4b23b5b09cb55d36b0685c87;
|
||||
bytes32 public constant FEE_SETTER_ROLE =
|
||||
0xe6ad9a47fbda1dc18de1eb5eeb7d935e5e81b4748f3cfc61e233e64f88182060;
|
||||
bytes32 public constant PAUSER_ROLE =
|
||||
0x65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a;
|
||||
bytes32 public constant FUND_RESCUER_ROLE =
|
||||
0x912e45d663a6f4cc1d0491d8f046e06c616f40352565ea1cdb86a0e1aaefa41b;
|
||||
|
||||
constructor(address _permit2) {
|
||||
permit2 = IAllowanceTransfer(_permit2);
|
||||
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev We use the fallback function to allow flexibility on callback.
|
||||
* This function will delegate call a verifier contract and should revert if the
|
||||
* caller is not a pool.
|
||||
*/
|
||||
fallback() external {
|
||||
// TODO execute generic callback
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Executes a swap graph supporting internal splits token amount
|
||||
* splits, checking that the user gets more than minUserAmount of buyToken.
|
||||
*/
|
||||
function swap(
|
||||
uint256 amountIn,
|
||||
address tokenIn,
|
||||
uint256 minUserAmount,
|
||||
bool wrapEth,
|
||||
bool unwrapEth,
|
||||
uint256 nTokens,
|
||||
bytes calldata swaps,
|
||||
IAllowanceTransfer.PermitSingle calldata permitSingle,
|
||||
bytes calldata signature
|
||||
) external returns (uint256 amountOut) {
|
||||
amountOut = 0;
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Allows granting roles to multiple accounts in a single call.
|
||||
*/
|
||||
function batchGrantRole(bytes32 role, address[] memory accounts)
|
||||
external
|
||||
onlyRole(DEFAULT_ADMIN_ROLE)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Allows this contract to receive native token
|
||||
*/
|
||||
// TODO Uncomment once withdraw method is implemented - or else Slither fails
|
||||
// receive() external payable {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user