feat: Take reactor address as input to UniswapXFiller
- Put reactor zero address check in separate line for more easy debugging. - Also includes other small cosmetic changes.
This commit is contained in:
@@ -3,7 +3,6 @@ pragma solidity ^0.8.26;
|
||||
|
||||
/// @dev external struct including a generic encoded order and swapper signature
|
||||
/// The order bytes will be parsed and mapped to a ResolvedOrder in the concrete reactor contract
|
||||
|
||||
struct SignedOrder {
|
||||
bytes order;
|
||||
bytes sig;
|
||||
@@ -41,8 +40,8 @@ struct OutputToken {
|
||||
uint256 amount;
|
||||
address recipient;
|
||||
}
|
||||
/// @dev generic concrete order that specifies exact tokens which need to be sent and received
|
||||
|
||||
/// @dev generic concrete order that specifies exact tokens which need to be sent and received
|
||||
struct ResolvedOrder {
|
||||
OrderInfo info;
|
||||
InputToken input;
|
||||
|
||||
@@ -16,8 +16,7 @@ contract UniswapXFiller is AccessControl, IReactorCallback {
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
// UniswapX V2DutchOrder Reactor
|
||||
IReactor public constant USXEDAReactor =
|
||||
IReactor(0x00000011F84B9aa48e5f8aA8B9897600006289Be);
|
||||
IReactor public immutable USXEDAReactor;
|
||||
address public immutable tychoRouter;
|
||||
|
||||
// keccak256("NAME_OF_ROLE") : save gas on deployment
|
||||
@@ -30,12 +29,14 @@ contract UniswapXFiller is AccessControl, IReactorCallback {
|
||||
address indexed token, uint256 amount, address indexed receiver
|
||||
);
|
||||
|
||||
constructor(address _tychoRouter) {
|
||||
constructor(address _tychoRouter, address _reactor) {
|
||||
if (_tychoRouter == address(0)) revert UniswapXFiller__AddressZero();
|
||||
if (_reactor == address(0)) revert UniswapXFiller__AddressZero();
|
||||
|
||||
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
||||
_grantRole(REACTOR_ROLE, address(USXEDAReactor));
|
||||
tychoRouter = _tychoRouter;
|
||||
USXEDAReactor = IReactor(_reactor);
|
||||
}
|
||||
|
||||
function execute(SignedOrder calldata order, bytes calldata callbackData)
|
||||
@@ -65,7 +66,7 @@ contract UniswapXFiller is AccessControl, IReactorCallback {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Allows withdrawing any ERC20 funds if funds get stuck in case of a bug.
|
||||
* @dev Allows withdrawing any ERC20 funds.
|
||||
*/
|
||||
function withdraw(IERC20[] memory tokens, address receiver)
|
||||
external
|
||||
@@ -84,8 +85,7 @@ contract UniswapXFiller is AccessControl, IReactorCallback {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Allows withdrawing any NATIVE funds if funds get stuck in case of a bug.
|
||||
* The contract should never hold any NATIVE tokens for security reasons.
|
||||
* @dev Allows withdrawing any NATIVE funds.
|
||||
*/
|
||||
function withdrawNative(address receiver)
|
||||
external
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
pragma solidity ^0.8.26;
|
||||
|
||||
import "@src/executors/UniswapV4Executor.sol";
|
||||
import "forge-std/Test.sol";
|
||||
import "@src/uniswap_x/UniswapXFiller.sol";
|
||||
import "../TychoRouterTestSetup.sol";
|
||||
@@ -13,9 +12,6 @@ contract UniswapXFillerTest is Test, TychoRouterTestSetup {
|
||||
UniswapXFiller filler;
|
||||
address fillerAddr;
|
||||
|
||||
bytes32 public constant EXECUTOR_ROLE =
|
||||
0xd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e63;
|
||||
|
||||
event CallbackVerifierSet(address indexed callbackVerifier);
|
||||
event Withdrawal(
|
||||
address indexed token, uint256 amount, address indexed receiver
|
||||
@@ -23,15 +19,20 @@ contract UniswapXFillerTest is Test, TychoRouterTestSetup {
|
||||
|
||||
function fillerSetup() public {
|
||||
vm.startPrank(ADMIN);
|
||||
filler = new UniswapXFiller(tychoRouterAddr);
|
||||
filler = new UniswapXFiller(tychoRouterAddr, REACTOR);
|
||||
fillerAddr = address(filler);
|
||||
filler.grantRole(keccak256("EXECUTOR_ROLE"), EXECUTOR);
|
||||
vm.stopPrank();
|
||||
}
|
||||
|
||||
function testTychoAddressZero() public {
|
||||
function testTychoAddressZeroTychoRouter() public {
|
||||
vm.expectRevert(UniswapXFiller__AddressZero.selector);
|
||||
filler = new UniswapXFiller(address(0));
|
||||
filler = new UniswapXFiller(address(0), REACTOR);
|
||||
}
|
||||
|
||||
function testTychoAddressZeroReactor() public {
|
||||
vm.expectRevert(UniswapXFiller__AddressZero.selector);
|
||||
filler = new UniswapXFiller(tychoRouterAddr, address(0));
|
||||
}
|
||||
|
||||
function testWithdrawNative() public {
|
||||
|
||||
Reference in New Issue
Block a user