// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.8.13; import "@yield-protocol/utils-v2/src/utils/RevertMsgExtractor.sol"; import "@yield-protocol/utils-v2/src/utils/IsContract.sol"; /// @dev Router forwards calls between two contracts, so that any permissions /// given to the original caller are stripped from the call. /// This is useful when implementing generic call routing functions on contracts /// that might have ERC20 approvals or AccessControl authorizations. contract Router { using IsContract for address; address immutable public owner; constructor () { owner = msg.sender; } /// @dev Allow users to route calls, to be used with batch function route(address target, bytes calldata data) external payable returns (bytes memory result) { require(msg.sender == owner, "Only owner"); require(target.isContract(), "Target is not a contract"); bool success; (success, result) = target.call(data); if (!success) revert(RevertMsgExtractor.getRevertMsg(result)); } }