-
Notifications
You must be signed in to change notification settings - Fork 14
/
L1EscrowMom.sol
83 lines (70 loc) · 2.69 KB
/
L1EscrowMom.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2021 Dai Foundation
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
pragma solidity ^0.8.14;
interface AuthorityLike {
function canCall(address src, address dst, bytes4 sig) external view returns (bool);
}
interface EscrowLike {
function approve(address token, address spender, uint256 value) external;
}
// Bypass governance delay to disable a L1Escrow
contract L1EscrowMom {
address public owner;
address public authority;
address public immutable escrow;
address public immutable token;
event SetOwner(address indexed oldOwner, address indexed newOwner);
event SetAuthority(address indexed oldAuthority, address indexed newAuthority);
event Refuse(address indexed escrow, address token, address spender);
modifier onlyOwner {
require(msg.sender == owner, "L1EscrowMom/only-owner");
_;
}
modifier auth {
require(isAuthorized(msg.sender, msg.sig), "L1EscrowMom/not-authorized");
_;
}
constructor(address escrow_, address token_) {
owner = msg.sender;
escrow = escrow_;
token = token_;
emit SetOwner(address(0), msg.sender);
}
function isAuthorized(address src, bytes4 sig) internal view returns (bool) {
if (src == address(this)) {
return true;
} else if (src == owner) {
return true;
} else if (authority == address(0)) {
return false;
} else {
return AuthorityLike(authority).canCall(src, address(this), sig);
}
}
// Governance actions with delay
function setOwner(address owner_) external onlyOwner {
emit SetOwner(owner, owner_);
owner = owner_;
}
function setAuthority(address authority_) external onlyOwner {
emit SetAuthority(authority, authority_);
authority = authority_;
}
// Governance action without delay
function refuse(address spender) external auth {
emit Refuse(escrow, token, spender);
EscrowLike(escrow).approve(token, spender, 0);
}
}