feat: update new interface in codebase
This commit is contained in:
@@ -15,9 +15,8 @@ contract TychoRouterExposed is TychoRouter {
|
||||
constructor(
|
||||
IPoolManager _poolManager,
|
||||
address _permit2,
|
||||
address weth,
|
||||
address usv3Factory
|
||||
) TychoRouter(_poolManager, _permit2, weth, usv3Factory) {}
|
||||
address weth
|
||||
) TychoRouter(_poolManager, _permit2, weth) {}
|
||||
|
||||
function wrapETH(uint256 amount) external payable {
|
||||
return _wrapETH(amount);
|
||||
@@ -39,7 +38,8 @@ contract TychoRouterExposed is TychoRouter {
|
||||
contract TychoRouterTestSetup is Test, Constants {
|
||||
TychoRouterExposed tychoRouter;
|
||||
address tychoRouterAddr;
|
||||
address permit2Address = address(0x000000000022D473030F116dDEE9F6B43aC78BA3);
|
||||
address permit2Address =
|
||||
address(0x000000000022D473030F116dDEE9F6B43aC78BA3);
|
||||
UniswapV2Executor public usv2Executor;
|
||||
UniswapV3Executor public usv3Executor;
|
||||
UniswapV4Executor public usv4Executor;
|
||||
@@ -54,7 +54,9 @@ contract TychoRouterTestSetup is Test, Constants {
|
||||
address poolManagerAddress = 0x000000000004444c5dc75cB358380D2e3dE08A90;
|
||||
IPoolManager poolManager = IPoolManager(poolManagerAddress);
|
||||
tychoRouter = new TychoRouterExposed(
|
||||
poolManager, permit2Address, WETH_ADDR, factoryV3
|
||||
poolManager,
|
||||
permit2Address,
|
||||
WETH_ADDR
|
||||
);
|
||||
tychoRouterAddr = address(tychoRouter);
|
||||
tychoRouter.grantRole(keccak256("FUND_RESCUER_ROLE"), FUND_RESCUER);
|
||||
@@ -62,13 +64,14 @@ contract TychoRouterTestSetup is Test, Constants {
|
||||
tychoRouter.grantRole(keccak256("PAUSER_ROLE"), PAUSER);
|
||||
tychoRouter.grantRole(keccak256("UNPAUSER_ROLE"), UNPAUSER);
|
||||
tychoRouter.grantRole(
|
||||
keccak256("EXECUTOR_SETTER_ROLE"), EXECUTOR_SETTER
|
||||
keccak256("EXECUTOR_SETTER_ROLE"),
|
||||
EXECUTOR_SETTER
|
||||
);
|
||||
deployDummyContract();
|
||||
vm.stopPrank();
|
||||
|
||||
usv2Executor = new UniswapV2Executor();
|
||||
usv3Executor = new UniswapV3Executor();
|
||||
usv3Executor = new UniswapV3Executor(factoryV3);
|
||||
usv4Executor = new UniswapV4Executor(poolManager);
|
||||
vm.startPrank(EXECUTOR_SETTER);
|
||||
address[] memory executors = new address[](3);
|
||||
@@ -110,22 +113,22 @@ contract TychoRouterTestSetup is Test, Constants {
|
||||
* @return permitSingle The `PermitSingle` struct containing the approval details.
|
||||
* @return signature The EIP-712 signature for the approval.
|
||||
*/
|
||||
function handlePermit2Approval(address tokenIn, uint256 amount_in)
|
||||
internal
|
||||
returns (IAllowanceTransfer.PermitSingle memory, bytes memory)
|
||||
{
|
||||
function handlePermit2Approval(
|
||||
address tokenIn,
|
||||
uint256 amount_in
|
||||
) internal returns (IAllowanceTransfer.PermitSingle memory, bytes memory) {
|
||||
IERC20(tokenIn).approve(permit2Address, amount_in);
|
||||
IAllowanceTransfer.PermitSingle memory permitSingle = IAllowanceTransfer
|
||||
.PermitSingle({
|
||||
details: IAllowanceTransfer.PermitDetails({
|
||||
token: tokenIn,
|
||||
amount: uint160(amount_in),
|
||||
expiration: uint48(block.timestamp + 1 days),
|
||||
nonce: 0
|
||||
}),
|
||||
spender: tychoRouterAddr,
|
||||
sigDeadline: block.timestamp + 1 days
|
||||
});
|
||||
details: IAllowanceTransfer.PermitDetails({
|
||||
token: tokenIn,
|
||||
amount: uint160(amount_in),
|
||||
expiration: uint48(block.timestamp + 1 days),
|
||||
nonce: 0
|
||||
}),
|
||||
spender: tychoRouterAddr,
|
||||
sigDeadline: block.timestamp + 1 days
|
||||
});
|
||||
|
||||
bytes memory signature = signPermit2(permitSingle, ALICE_PK);
|
||||
return (permitSingle, signature);
|
||||
@@ -157,8 +160,9 @@ contract TychoRouterTestSetup is Test, Constants {
|
||||
permit2Address
|
||||
)
|
||||
);
|
||||
bytes32 detailsHash =
|
||||
keccak256(abi.encode(_PERMIT_DETAILS_TYPEHASH, permit.details));
|
||||
bytes32 detailsHash = keccak256(
|
||||
abi.encode(_PERMIT_DETAILS_TYPEHASH, permit.details)
|
||||
);
|
||||
bytes32 permitHash = keccak256(
|
||||
abi.encode(
|
||||
_PERMIT_SINGLE_TYPEHASH,
|
||||
@@ -168,18 +172,17 @@ contract TychoRouterTestSetup is Test, Constants {
|
||||
)
|
||||
);
|
||||
|
||||
bytes32 digest =
|
||||
keccak256(abi.encodePacked("\x19\x01", domainSeparator, permitHash));
|
||||
bytes32 digest = keccak256(
|
||||
abi.encodePacked("\x19\x01", domainSeparator, permitHash)
|
||||
);
|
||||
(uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest);
|
||||
|
||||
return abi.encodePacked(r, s, v);
|
||||
}
|
||||
|
||||
function pleEncode(bytes[] memory data)
|
||||
public
|
||||
pure
|
||||
returns (bytes memory encoded)
|
||||
{
|
||||
function pleEncode(
|
||||
bytes[] memory data
|
||||
) public pure returns (bytes memory encoded) {
|
||||
for (uint256 i = 0; i < data.length; i++) {
|
||||
encoded = bytes.concat(
|
||||
encoded,
|
||||
@@ -196,9 +199,15 @@ contract TychoRouterTestSetup is Test, Constants {
|
||||
bytes4 selector,
|
||||
bytes memory protocolData
|
||||
) internal pure returns (bytes memory) {
|
||||
return abi.encodePacked(
|
||||
tokenInIndex, tokenOutIndex, split, executor, selector, protocolData
|
||||
);
|
||||
return
|
||||
abi.encodePacked(
|
||||
tokenInIndex,
|
||||
tokenOutIndex,
|
||||
split,
|
||||
executor,
|
||||
selector,
|
||||
protocolData
|
||||
);
|
||||
}
|
||||
|
||||
function encodeUniswapV2Swap(
|
||||
@@ -218,8 +227,14 @@ contract TychoRouterTestSetup is Test, Constants {
|
||||
bool zero2one
|
||||
) internal view returns (bytes memory) {
|
||||
IUniswapV3Pool pool = IUniswapV3Pool(target);
|
||||
return abi.encodePacked(
|
||||
tokenIn, tokenOut, pool.fee(), receiver, target, zero2one
|
||||
);
|
||||
return
|
||||
abi.encodePacked(
|
||||
tokenIn,
|
||||
tokenOut,
|
||||
pool.fee(),
|
||||
receiver,
|
||||
target,
|
||||
zero2one
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user