Repository navigation
Expand file tree
/
Copy pathArbGasInfo.sol
More file actions
172 lines (141 loc) · 9.73 KB
/
Copy pathArbGasInfo.sol
File metadata and controls
172 lines (141 loc) · 9.73 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.4.21 <0.9.0;
import {ArbMultiGasConstraintsTypes} from "./ArbMultiGasConstraintsTypes.sol";
/// @title Provides insight into the cost of using the chain.
/// @notice These methods have been adjusted to account for Nitro's heavy use of calldata compression.
/// Of note to end-users, we no longer make a distinction between non-zero and zero-valued calldata bytes.
/// Precompiled contract that exists in every Arbitrum chain at 0x000000000000000000000000000000000000006c.
interface ArbGasInfo {
/// @notice Get gas prices for a provided aggregator
/// @return return gas prices in wei
/// (
/// per L2 tx,
/// per L1 calldata byte
/// per storage allocation,
/// per ArbGas base,
/// per ArbGas congestion,
/// per ArbGas total
/// )
function getPricesInWeiWithAggregator(
address aggregator
) external view returns (uint256, uint256, uint256, uint256, uint256, uint256);
/// @notice Get gas prices. Uses the caller's preferred aggregator, or the default if the caller doesn't have a preferred one.
/// @return return gas prices in wei
/// (
/// per L2 tx,
/// per L1 calldata byte
/// per storage allocation,
/// per ArbGas base,
/// per ArbGas congestion,
/// per ArbGas total
/// )
function getPricesInWei()
external
view
returns (uint256, uint256, uint256, uint256, uint256, uint256);
/// @notice Get prices in ArbGas for the supplied aggregator
/// @return (per L2 tx, per L1 calldata byte, per storage allocation)
function getPricesInArbGasWithAggregator(
address aggregator
) external view returns (uint256, uint256, uint256);
/// @notice Get prices in ArbGas. Assumes the callers preferred validator, or the default if caller doesn't have a preferred one.
/// @return (per L2 tx, per L1 calldata byte, per storage allocation)
function getPricesInArbGas() external view returns (uint256, uint256, uint256);
/// @notice Get the gas accounting parameters. `gasPoolMax` is always zero, as the exponential pricing model has no such notion.
/// @notice Starting from ArbOS version 50, `speedLimitPerSecond` corresponds to the target of the single-constraint pricing model.
/// @notice For multi-constraint pricing model, use `getGasPricingConstraints` to retrieve the constraint set.
/// @return (speedLimitPerSecond, gasPoolMax, maxBlockGasLimit)
function getGasAccountingParams() external view returns (uint256, uint256, uint256);
/// @notice Get the maxTxGasLimit
/// @notice Available in ArbOS version 50 and above
function getMaxTxGasLimit() external view returns (uint256);
/// @notice Get the minimum gas price needed for a tx to succeed
function getMinimumGasPrice() external view returns (uint256);
/// @notice Get ArbOS's estimate of the L1 basefee in wei
function getL1BaseFeeEstimate() external view returns (uint256);
/// @notice Get how slowly ArbOS updates its estimate of the L1 basefee
function getL1BaseFeeEstimateInertia() external view returns (uint64);
/// @notice Get the L1 pricer reward rate, in wei per unit
/// @notice Available in ArbOS version 11 and above
function getL1RewardRate() external view returns (uint64);
/// @notice Get the L1 pricer reward recipient
/// @notice Available in ArbOS version 11 and above
function getL1RewardRecipient() external view returns (address);
/// @notice Deprecated -- Same as getL1BaseFeeEstimate()
function getL1GasPriceEstimate() external view returns (uint256);
/// @notice Get L1 gas fees paid by the current transaction
function getCurrentTxL1GasFees() external view returns (uint256);
/// @notice Get the backlogged amount of gas burnt in excess of the speed limit
/// @notice Starting from ArbOS version 50, returns the backlog value from the single-constraint pricing model.
/// @notice For multi-constraint pricing model, use `getGasPricingConstraints` to get backlog values for each configured constraint.
function getGasBacklog() external view returns (uint64);
/// @notice Get how slowly ArbOS updates the L2 basefee in response to backlogged gas
/// @notice Starting from ArbOS version 50, returns the inertia value used by the single-constraint pricing model.
/// @notice For new integrations, prefer `getGasPricingConstraints`.
function getPricingInertia() external view returns (uint64);
/// @notice Get the forgivable amount of backlogged gas ArbOS will ignore when raising the basefee
/// @notice Starting from ArbOS version 50, returns the backlog tolerance value used by the single-constraint pricing model.
/// @notice There is no tolerance for backlogged gas in the new multi-constraint pricing model.
function getGasBacklogTolerance() external view returns (uint64);
/// @notice Returns the surplus of funds for L1 batch posting payments (may be negative).
function getL1PricingSurplus() external view returns (int256);
/// @notice Returns the base charge (in L1 gas) attributed to each data batch in the calldata pricer
function getPerBatchGasCharge() external view returns (int64);
/// @notice Returns the cost amortization cap in basis points
function getAmortizedCostCapBips() external view returns (uint64);
/// @notice Returns the available funds from L1 fees
/// @notice Available in ArbOS version 10 and above
function getL1FeesAvailable() external view returns (uint256);
/// @notice Returns the equilibration units parameter for L1 price adjustment algorithm
/// @notice Available in ArbOS version 20 and above
function getL1PricingEquilibrationUnits() external view returns (uint256);
/// @notice Returns the last time the L1 calldata pricer was updated.
/// @notice Available in ArbOS version 20 and above
function getLastL1PricingUpdateTime() external view returns (uint64);
/// @notice Returns the amount of L1 calldata payments due for rewards (per the L1 reward rate)
/// @notice Available in ArbOS version 20 and above
function getL1PricingFundsDueForRewards() external view returns (uint256);
/// @notice Returns the amount of L1 calldata posted since the last update.
/// @notice Available in ArbOS version 20 and above
function getL1PricingUnitsSinceUpdate() external view returns (uint64);
/// @notice Returns the L1 pricing surplus as of the last update (may be negative).
/// @notice Available in ArbOS version 20 and above
function getLastL1PricingSurplus() external view returns (int256);
/// @notice Get the maximum block gas limit
/// @notice Available in ArbOS version 50 and above
function getMaxBlockGasLimit() external view returns (uint64);
/// @notice Get the current gas pricing constraints used by the multi-constraint pricing model.
/// @notice Each constraint contains the following values:
/// - gas_target_per_second: target gas usage per second for the constraint (uint64, gas/sec)
/// - adjustment_window_seconds: time over which the price will rise by a factor of e if demand is 2x the target (uint64, seconds)
/// - uint64 backlog: current backlog in gas units for this constraint (uint64, gas units)
/// @return constraints Array of triples (gas_target_per_second, adjustment_window_seconds, backlog)
/// @notice Available in ArbOS version 50 and above.
function getGasPricingConstraints() external view returns (uint64[3][] memory constraints);
/// @notice Get the current multi-gas pricing constraints used by the multi-dimensional multi-constraint pricing model.
/// @notice Each constraint includes its target throughput, adjustment window, backlog, and weighted resource configuration.
///
/// @notice The array contains one `ResourceConstraint` struct per active constraint.
/// @notice Each constraint provides the following fields:
/// - `resources`: list of (resource kind, weight) pairs (see the ArbMultiGasConstraintsTypes library for definitions)
/// - `adjustmentWindowSecs`: time window (seconds) over which the price rises by a factor of e if demand is 2x the target (uint64, seconds)
/// - `targetPerSec`: target gas usage per second for this constraint (uint64, gas/sec)
/// - `backlog`: current backlog value for this constraint (uint64, gas units)
/// @return constraints Array of `ResourceConstraint` structs representing the current multi-gas pricing configuration.
/// @notice Available in ArbOS version 60 and above.
/// @notice See the `ArbMultiGasConstraintsTypes` library for struct definitions and field details.
function getMultiGasPricingConstraints()
external
view
returns (ArbMultiGasConstraintsTypes.ResourceConstraint[] memory constraints);
/// @notice Get the current per-resource-kind base fees used by the multi-gas pricing model.
/// @dev The returned array is indexed by `uint256(ResourceKind)`.
/// @dev For example, `baseFees[uint256(ResourceKind.Computation)]` is the base fee
/// @dev for computation gas, and `baseFees[uint256(ResourceKind.StorageGrowth)]` is
/// @dev the base fee for storage growth. If a resource kind is unused, its entry will be zero.
/// @return baseFees An array of base fees in wei, one entry for each `ResourceKind` value.
/// @notice Available in ArbOS version 60 and above.
function getMultiGasBaseFee() external view returns (uint256[] memory baseFees);
}