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:
TAMARA LIPOWSKI
2025-07-08 09:48:25 -04:00
parent ce1fe1dd94
commit 00f22d62c1
3 changed files with 15 additions and 15 deletions

View File

@@ -3,7 +3,6 @@ pragma solidity ^0.8.26;
/// @dev external struct including a generic encoded order and swapper signature /// @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 /// The order bytes will be parsed and mapped to a ResolvedOrder in the concrete reactor contract
struct SignedOrder { struct SignedOrder {
bytes order; bytes order;
bytes sig; bytes sig;
@@ -41,8 +40,8 @@ struct OutputToken {
uint256 amount; uint256 amount;
address recipient; 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 { struct ResolvedOrder {
OrderInfo info; OrderInfo info;
InputToken input; InputToken input;

View File

@@ -16,8 +16,7 @@ contract UniswapXFiller is AccessControl, IReactorCallback {
using SafeERC20 for IERC20; using SafeERC20 for IERC20;
// UniswapX V2DutchOrder Reactor // UniswapX V2DutchOrder Reactor
IReactor public constant USXEDAReactor = IReactor public immutable USXEDAReactor;
IReactor(0x00000011F84B9aa48e5f8aA8B9897600006289Be);
address public immutable tychoRouter; address public immutable tychoRouter;
// keccak256("NAME_OF_ROLE") : save gas on deployment // 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 address indexed token, uint256 amount, address indexed receiver
); );
constructor(address _tychoRouter) { constructor(address _tychoRouter, address _reactor) {
if (_tychoRouter == address(0)) revert UniswapXFiller__AddressZero(); if (_tychoRouter == address(0)) revert UniswapXFiller__AddressZero();
if (_reactor == address(0)) revert UniswapXFiller__AddressZero();
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(REACTOR_ROLE, address(USXEDAReactor)); _grantRole(REACTOR_ROLE, address(USXEDAReactor));
tychoRouter = _tychoRouter; tychoRouter = _tychoRouter;
USXEDAReactor = IReactor(_reactor);
} }
function execute(SignedOrder calldata order, bytes calldata callbackData) 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) function withdraw(IERC20[] memory tokens, address receiver)
external 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. * @dev Allows withdrawing any NATIVE funds.
* The contract should never hold any NATIVE tokens for security reasons.
*/ */
function withdrawNative(address receiver) function withdrawNative(address receiver)
external external

View File

@@ -1,7 +1,6 @@
// SPDX-License-Identifier: BUSL-1.1 // SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.26; pragma solidity ^0.8.26;
import "@src/executors/UniswapV4Executor.sol";
import "forge-std/Test.sol"; import "forge-std/Test.sol";
import "@src/uniswap_x/UniswapXFiller.sol"; import "@src/uniswap_x/UniswapXFiller.sol";
import "../TychoRouterTestSetup.sol"; import "../TychoRouterTestSetup.sol";
@@ -13,9 +12,6 @@ contract UniswapXFillerTest is Test, TychoRouterTestSetup {
UniswapXFiller filler; UniswapXFiller filler;
address fillerAddr; address fillerAddr;
bytes32 public constant EXECUTOR_ROLE =
0xd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e63;
event CallbackVerifierSet(address indexed callbackVerifier); event CallbackVerifierSet(address indexed callbackVerifier);
event Withdrawal( event Withdrawal(
address indexed token, uint256 amount, address indexed receiver address indexed token, uint256 amount, address indexed receiver
@@ -23,15 +19,20 @@ contract UniswapXFillerTest is Test, TychoRouterTestSetup {
function fillerSetup() public { function fillerSetup() public {
vm.startPrank(ADMIN); vm.startPrank(ADMIN);
filler = new UniswapXFiller(tychoRouterAddr); filler = new UniswapXFiller(tychoRouterAddr, REACTOR);
fillerAddr = address(filler); fillerAddr = address(filler);
filler.grantRole(keccak256("EXECUTOR_ROLE"), EXECUTOR); filler.grantRole(keccak256("EXECUTOR_ROLE"), EXECUTOR);
vm.stopPrank(); vm.stopPrank();
} }
function testTychoAddressZero() public { function testTychoAddressZeroTychoRouter() public {
vm.expectRevert(UniswapXFiller__AddressZero.selector); 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 { function testWithdrawNative() public {