-
Notifications
You must be signed in to change notification settings - Fork 157
Expand file tree
/
Copy pathBaseFeeManager.sol
More file actions
70 lines (57 loc) · 2.63 KB
/
BaseFeeManager.sol
File metadata and controls
70 lines (57 loc) · 2.63 KB
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
// Copyright 2022-2026, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "../precompiles/ArbOwner.sol";
import "../precompiles/ArbGasInfo.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
contract BaseFeeManager is AccessControlEnumerable {
ArbOwner internal constant ARB_OWNER = ArbOwner(address(0x70));
ArbGasInfo internal constant ARB_GAS_INFO = ArbGasInfo(address(0x6c));
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
uint256 public constant MIN_BASE_FEE_WEI = 0.01 gwei;
uint256 public constant MAX_BASE_FEE_WEI = 0.1 gwei;
uint256 public immutable expiryTimestamp;
error InvalidBaseFee(uint256 newL2BaseFee);
error BaseFeeBelowMinimum(uint256 newL2BaseFee, uint256 minimumBaseFee);
error NotExpired(uint256 expiryTimestamp);
constructor(address admin, address manager, uint256 _expiryTimestamp) {
_setupRole(DEFAULT_ADMIN_ROLE, admin);
_setupRole(MANAGER_ROLE, manager);
expiryTimestamp = _expiryTimestamp;
}
/// @notice Removes the contract from the list of chain owners after the expiry timestamp
function revoke() external {
if (block.timestamp < expiryTimestamp) {
revert NotExpired(expiryTimestamp);
}
ARB_OWNER.removeChainOwner(address(this));
}
/// @notice Sets the L2 base fee within the allowed range, and above the minimum base fee
/// @param newL2BaseFeeInWei The new L2 base fee to set (in wei)
function setL2BaseFee(
uint256 newL2BaseFeeInWei
) external onlyRole(MANAGER_ROLE) {
if (newL2BaseFeeInWei < MIN_BASE_FEE_WEI || newL2BaseFeeInWei > MAX_BASE_FEE_WEI) {
revert InvalidBaseFee(newL2BaseFeeInWei);
}
uint256 minimumL2BaseFee = ARB_GAS_INFO.getMinimumGasPrice();
if (newL2BaseFeeInWei < minimumL2BaseFee) {
revert BaseFeeBelowMinimum(newL2BaseFeeInWei, minimumL2BaseFee);
}
ARB_OWNER.setL2BaseFee(newL2BaseFeeInWei);
}
/// @notice Sets the minimum L2 base fee within the allowed range
/// @param newMinimumL2BaseFeeInWei The new minimum L2 base fee to set (in wei)
function setMinimumL2BaseFee(
uint256 newMinimumL2BaseFeeInWei
) external onlyRole(MANAGER_ROLE) {
if (
newMinimumL2BaseFeeInWei < MIN_BASE_FEE_WEI
|| newMinimumL2BaseFeeInWei > MAX_BASE_FEE_WEI
) {
revert InvalidBaseFee(newMinimumL2BaseFeeInWei);
}
ARB_OWNER.setMinimumL2BaseFee(newMinimumL2BaseFeeInWei);
}
}