Skip to content

Commit

Permalink
Remove protocol fees
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongeric committed Nov 15, 2023
1 parent 29efb09 commit 5968586
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
264776
264895
Original file line number Diff line number Diff line change
@@ -1 +1 @@
312241
312360
24 changes: 24 additions & 0 deletions src/base/ReactorErrors.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

interface ReactorErrors {
// Occurs when an output = ETH and the reactor does contain enough ETH but
// the direct filler did not include enough ETH in their call to execute/executeBatch
error InsufficientEth();

// A nested call failed
error CallFailed();

error InvalidToken();
error UnsupportedAction();
error ReactorCallbackNotSupported();

/// @notice thrown when an order's deadline is before its end time
error DeadlineBeforeEndTime();

/// @notice thrown when an order's end time is before its start time
error OrderEndTimeBeforeStartTime();

/// @notice thrown when an order's inputs and outputs both decay
error InputAndOutputDecay();
}
29 changes: 12 additions & 17 deletions src/reactors/RelayOrderReactor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {IReactorCallback} from "UniswapX/src/interfaces/IReactorCallback.sol";
import {IReactor} from "UniswapX/src/interfaces/IReactor.sol";
import {ProtocolFees} from "UniswapX/src/base/ProtocolFees.sol";
import {ReactorEvents} from "../base/ReactorEvents.sol";
import {ReactorErrors} from "../base/ReactorErrors.sol";
import {InputTokenWithRecipient, ResolvedRelayOrder} from "../base/ReactorStructs.sol";
import {CurrencyLibrary, NATIVE} from "../lib/CurrencyLibrary.sol";
import {Permit2Lib} from "../lib/Permit2Lib.sol";
Expand All @@ -19,31 +20,20 @@ import {RelayDecayLib} from "../lib/RelayDecayLib.sol";

/// @notice Reactor for relaying calls to UniversalRouter onchain
/// @dev This reactor only supports V2/V3 swaps, do NOT attempt to use other Universal Router commands
contract RelayOrderReactor is ReactorEvents, ProtocolFees, ReentrancyGuard, IReactor {
contract RelayOrderReactor is ReactorEvents, ReactorErrors, ReentrancyGuard, IReactor {
using SafeTransferLib for ERC20;
using CurrencyLibrary for address;
using Permit2Lib for ResolvedRelayOrder;
using ResolvedRelayOrderLib for ResolvedRelayOrder;
using RelayOrderLib for RelayOrder;
using RelayDecayLib for InputTokenWithRecipient[];

// Occurs when an output = ETH and the reactor does contain enough ETH but
// the direct filler did not include enough ETH in their call to execute/executeBatch
error InsufficientEth();
// A nested call failed
error CallFailed();
error InvalidToken();
error UnsupportedAction();
error ReactorCallbackNotSupported();

/// @notice permit2 address used for token transfers and signature verification
IPermit2 public immutable permit2;

address public immutable universalRouter;

constructor(IPermit2 _permit2, address _protocolFeeOwner, address _universalRouter)
ProtocolFees(_protocolFeeOwner)
{
constructor(IPermit2 _permit2, address _universalRouter) {
permit2 = _permit2;
universalRouter = _universalRouter;
}
Expand Down Expand Up @@ -121,9 +111,6 @@ contract RelayOrderReactor is ReactorEvents, ProtocolFees, ReentrancyGuard, IRea
for (uint256 i = 0; i < ordersLength; i++) {
ResolvedRelayOrder memory order = orders[i];

// TODO fees impl
// _injectFees(order);

order.validate(msg.sender);

// Since relay order inputs specify recipients we don't pass in recipient here
Expand Down Expand Up @@ -195,6 +182,14 @@ contract RelayOrderReactor is ReactorEvents, ProtocolFees, ReentrancyGuard, IRea
/// @notice validate the relay order fields
/// @dev Throws if the order is invalid
function _validateOrder(RelayOrder memory order) internal pure {
// assert that actions are valid and allowed, that calldata is well formed, etc.
if (order.info.deadline < order.decayEndTime) {
revert DeadlineBeforeEndTime();
}

if (order.decayEndTime < order.decayStartTime) {
revert OrderEndTimeBeforeStartTime();
}

// TODO: add additional validations related to relayed actions, if desired
}
}
2 changes: 1 addition & 1 deletion test/integration/RelayOrderReactorIntegration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ contract RelayOrderReactorIntegrationTest is GasSnapshot, Test, PermitSignature
filler = makeAddr("filler");
vm.createSelectFork(vm.envString("FOUNDRY_RPC_URL"), 17972788);

deployCodeTo("RelayOrderReactor.sol", abi.encode(PERMIT2, address(0), UNIVERSAL_ROUTER), RELAY_ORDER_REACTOR);
deployCodeTo("RelayOrderReactor.sol", abi.encode(PERMIT2, UNIVERSAL_ROUTER), RELAY_ORDER_REACTOR);
reactor = RelayOrderReactor(RELAY_ORDER_REACTOR);
permitExecutor = new PermitExecutor(address(filler), reactor, address(filler));

Expand Down

0 comments on commit 5968586

Please sign in to comment.