-
Notifications
You must be signed in to change notification settings - Fork 8
/
ODProxy.sol
49 lines (39 loc) · 1.12 KB
/
ODProxy.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;
import {Address} from '@openzeppelin/utils/Address.sol';
// Open Dollar
// Version 1.7.0
contract ODProxy {
using Address for address;
error TargetAddressRequired();
error TargetCallFailed(bytes _response);
error OnlyOwner();
address public immutable OWNER;
constructor(address _owner) {
OWNER = _owner;
}
/**
* @notice Checks whether msg.sender can call an owned function
*/
modifier onlyOwner() {
if (msg.sender != OWNER) revert OnlyOwner();
_;
}
/**
* @dev protocol delegatecall function
*/
function execute(address _target, bytes memory _data) external payable onlyOwner returns (bytes memory _response) {
if (_target == address(0)) revert TargetAddressRequired();
_response = _target.functionDelegateCall(_data);
}
/**
* @dev arbitrary call function
* @notice prevents erc20 funds from getting stuck in proxy
*/
function arbitraryExecute(
address _target,
bytes memory _data
) external payable onlyOwner returns (bytes memory _response) {
_response = _target.functionCall(_data);
}
}