-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathL2SystemConfig.sol
More file actions
81 lines (63 loc) · 2.64 KB
/
Copy pathL2SystemConfig.sol
File metadata and controls
81 lines (63 loc) · 2.64 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
71
72
73
74
75
76
77
78
79
80
81
// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
contract L2SystemConfig is OwnableUpgradeable {
/**********
* Events *
**********/
/// @notice Emitted when the base fee overhead is updated.
/// @param oldBaseFeeOverhead The old base fee overhead.
/// @param newBaseFeeOverhead The new base fee overhead.
event BaseFeeOverheadUpdated(uint256 oldBaseFeeOverhead, uint256 newBaseFeeOverhead);
/// @notice Emitted when the base fee scalar is updated.
/// @param oldBaseFeeScalar The old base fee scalar.
/// @param newBaseFeeScalar The new base fee scalar.
event BaseFeeScalarUpdated(uint256 oldBaseFeeScalar, uint256 newBaseFeeScalar);
/*************
* Constants *
*************/
uint256 private constant PRECISION = 1e18;
/*********************
* Storage Variables *
*********************/
/// @notice The base fee overhead. This is part of the L2 base fee calculation.
uint256 public baseFeeOverhead;
/// @notice The base fee scalar. This is part of the L2 base fee calculation.
uint256 public baseFeeScalar;
/***************
* Constructor *
***************/
constructor() {
_disableInitializers();
}
function initialize(address _owner) external initializer {
__Ownable_init();
transferOwnership(_owner);
}
/*************************
* Public View Functions *
*************************/
/// @notice Calculates the L2 base fee based on the L1 base fee.
/// @param l1BaseFee The L1 base fee.
/// @return l2BaseFee The L2 base fee.
function getL2BaseFee(uint256 l1BaseFee) public view returns (uint256 l2BaseFee) {
l2BaseFee = (l1BaseFee * baseFeeScalar) / PRECISION + baseFeeOverhead;
}
/************************
* Restricted Functions *
************************/
/// @notice Updates the base fee overhead.
/// @param _baseFeeOverhead The new base fee overhead.
function updateBaseFeeOverhead(uint256 _baseFeeOverhead) external onlyOwner {
uint256 oldBaseFeeOverhead = baseFeeOverhead;
baseFeeOverhead = _baseFeeOverhead;
emit BaseFeeOverheadUpdated(oldBaseFeeOverhead, _baseFeeOverhead);
}
/// @notice Updates the base fee scalar.
/// @param _baseFeeScalar The new base fee scalar.
function updateBaseFeeScalar(uint256 _baseFeeScalar) external onlyOwner {
uint256 oldBaseFeeScalar = baseFeeScalar;
baseFeeScalar = _baseFeeScalar;
emit BaseFeeScalarUpdated(oldBaseFeeScalar, _baseFeeScalar);
}
}