Merge pull request #13 from propeller-heads/router/tnl/ENG-4032-router-skeleton

feat: TychoRouter Skeleton
This commit is contained in:
Tamara
2025-01-21 09:31:52 -05:00
committed by GitHub
8 changed files with 99 additions and 3 deletions

View File

@@ -13,4 +13,5 @@ jobs:
- uses: actions/checkout@v4
- uses: crytic/slither-action@v0.4.0
with:
target: 'foundry/'
target: 'foundry/'
slither-args: '--filter-paths foundry/lib/'

6
.gitmodules vendored Normal file
View File

@@ -0,0 +1,6 @@
[submodule "foundry/lib/openzeppelin-contracts"]
path = foundry/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "foundry/lib/permit2"]
path = foundry/lib/permit2
url = https://github.com/Uniswap/permit2

1
foundry/lib/permit2 Submodule

Submodule foundry/lib/permit2 added at cc56ad0f34

3
foundry/remappings.txt Normal file
View File

@@ -0,0 +1,3 @@
@openzeppelin/=lib/openzeppelin-contracts/
@permit2/=lib/permit2/
@src/=src/

View File

@@ -0,0 +1,3 @@
{
"filter_paths": "lib"
}

View File

@@ -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 {}
}

View File

@@ -0,0 +1,19 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.28;
import {Test, console} from "forge-std/Test.sol";
import {TychoRouter} from "@src/TychoRouter.sol";
contract TychoRouterTest is Test {
TychoRouter public tychoRouter;
function setupTychoRouter() public {
address permit2Address =
address(0x000000000022D473030F116dDEE9F6B43aC78BA3);
tychoRouter = new TychoRouter(permit2Address);
}
function testSetupTychoRouter() public {
setupTychoRouter();
}
}