Skip to content

Commit

Permalink
feat: s10
Browse files Browse the repository at this point in the history
  • Loading branch information
ChefMist committed Sep 10, 2024
1 parent 9c61442 commit e7198f6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
20 changes: 10 additions & 10 deletions src/UniversalRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,22 @@ import {StableSwapRouter} from "./modules/pancakeswap/StableSwapRouter.sol";
import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol";

contract UniversalRouter is RouterImmutables, IUniversalRouter, Dispatcher, Pausable {
modifier checkDeadline(uint256 deadline) {
if (block.timestamp > deadline) revert TransactionDeadlinePassed();
_;
}

constructor(RouterParameters memory params)
RouterImmutables(params)
StableSwapRouter(params.stableFactory, params.stableInfo)
V4SwapRouter(params.v4Vault, params.v4ClPoolManager, params.v4BinPoolManager)
{}

modifier checkDeadline(uint256 deadline) {
if (block.timestamp > deadline) revert TransactionDeadlinePassed();
_;
}

/// @notice To receive ETH from WETH
receive() external payable {
if (msg.sender != address(WETH9) && msg.sender != address(vault)) revert InvalidEthSender();
}

/// @inheritdoc IUniversalRouter
function execute(bytes calldata commands, bytes[] calldata inputs, uint256 deadline)
external
Expand Down Expand Up @@ -76,9 +81,4 @@ contract UniversalRouter is RouterImmutables, IUniversalRouter, Dispatcher, Paus
function unpause() external onlyOwner whenPaused {
_unpause();
}

/// @notice To receive ETH from WETH
receive() external payable {
if (msg.sender != address(WETH9) && msg.sender != address(vault)) revert InvalidEthSender();
}
}
22 changes: 11 additions & 11 deletions src/base/Dispatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ abstract contract Dispatcher is
error InvalidAction(bytes4 action);
error NotAuthorizedForToken(uint256 tokenId);

/// @notice Executes encoded commands along with provided inputs.
/// @param commands A set of concatenated commands, each 1 byte in length
/// @param inputs An array of byte strings containing abi encoded inputs for each command
function execute(bytes calldata commands, bytes[] calldata inputs) external payable virtual;

/// @notice Public view function to be used instead of msg.sender, as the contract performs self-reentrancy and at
/// times msg.sender == address(this). Instead msgSender() returns the initiator of the lock
function msgSender() public view override(BaseActionsRouter) returns (address) {
return _getLocker();
}

/// @notice Decodes and executes the given command with the given inputs
/// @param commandType The command type to execute
/// @param inputs The inputs to execute the command with
Expand Down Expand Up @@ -341,15 +352,4 @@ abstract contract Dispatcher is
return recipient;
}
}

/// @notice Public view function to be used instead of msg.sender, as the contract performs self-reentrancy and at
/// times msg.sender == address(this). Instead msgSender() returns the initiator of the lock
function msgSender() public view override(BaseActionsRouter) returns (address) {
return _getLocker();
}

/// @notice Executes encoded commands along with provided inputs.
/// @param commands A set of concatenated commands, each 1 byte in length
/// @param inputs An array of byte strings containing abi encoded inputs for each command
function execute(bytes calldata commands, bytes[] calldata inputs) external payable virtual;
}

0 comments on commit e7198f6

Please sign in to comment.