Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions packages/contracts-bedrock/interfaces/L1/IFeesDepositor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,25 @@ interface IFeesDepositor is ISemver, IProxyAdminOwnedBase, IReinitializableBase
event Initialized(uint8 version);
event FundsReceived(address indexed sender, uint256 amount, uint256 newBalance);
event FeesDeposited(address indexed l2Recipient, uint256 amount);
event MinDepositAmountUpdated(uint96 oldminDepositAmount, uint96 newminDepositAmount);
event MinDepositAmountUpdated(uint96 oldMinDepositAmount, uint96 newMinDepositAmount);
event L2RecipientUpdated(address oldL2Recipient, address newL2Recipient);
event GasLimitUpdated(uint64 oldGasLimit, uint64 newGasLimit);
event DepositDataUpdated(bytes oldDepositData, bytes newDepositData);

function minDepositAmount() external view returns (uint96);
function portal() external view returns (IOptimismPortal);
function l2Recipient() external view returns (address);
function gasLimit() external view returns (uint64);
function depositData() external view returns (bytes memory);
function initialize(
uint96 _minDepositAmount,
address _l2Recipient,
IOptimismPortal _portal,
uint64 _gasLimit,
bytes memory _depositData
uint64 _gasLimit
)
external;

function setMinDepositAmount(uint96 _minDepositAmount) external;
function setL2Recipient(address _l2Recipient) external;
function setGasLimit(uint64 _gasLimit) external;
function setDepositData(bytes memory _depositData) external;
function setMinDepositAmount(uint96 _newMinDepositAmount) external;
function setL2Recipient(address _newL2Recipient) external;
function setGasLimit(uint64 _newGasLimit) external;

receive() external payable;

Expand Down
1 change: 1 addition & 0 deletions packages/contracts-bedrock/interfaces/L2/IL1Withdrawer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ISemver } from "interfaces/universal/ISemver.sol";

interface IL1Withdrawer is ISemver {
error L1Withdrawer_OnlyProxyAdminOwner();
error L1Withdrawer_WithdrawalGasLimitTooLow();

event WithdrawalInitiated(address indexed recipient, uint256 amount);
event FundsReceived(address indexed sender, uint256 amount, uint256 newBalance);
Expand Down
14 changes: 14 additions & 0 deletions packages/contracts-bedrock/interfaces/L2/ISharesCalculator.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title ISharesCalculator
/// @notice Interface for a contract that calculates the recipients and amounts for fee distribution.
/// @dev Meant to be called by the FeeSplitter contract.
interface ISharesCalculator {
/// @notice Struct to hold the recipient and amount for each fee share.
/// @param recipient The address that will receive the fee share
/// @param amount The amount of ETH to be sent to the recipient
struct ShareInfo {
address payable recipient;
uint256 amount;
}

/// @notice Returns the recipients and amounts for fee distribution.
/// @dev Any implementation MUST return ShareInfo where the sum of all amounts equals
/// the total revenue (sum of all vault balances) as it will revert otherwise
/// @param _sequencerFeeVaultBalance Balance of the sequencer fee vault.
/// @param _baseFeeVaultBalance Balance of the base fee vault.
/// @param _operatorFeeVaultBalance Balance of the operator fee vault.
/// @param _l1FeeVaultBalance Balance of the L1 fee vault.
/// @return shareInfo Array of ShareInfo structs containing recipients and amounts.
function getRecipientsAndAmounts(
uint256 _sequencerFeeVaultBalance,
uint256 _baseFeeVaultBalance,
Expand Down
60 changes: 5 additions & 55 deletions packages/contracts-bedrock/snapshots/abi/FeesDepositor.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@
"stateMutability": "payable",
"type": "receive"
},
{
"inputs": [],
"name": "depositData",
"outputs": [
{
"internalType": "bytes",
"name": "",
"type": "bytes"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gasLimit",
Expand Down Expand Up @@ -68,11 +55,6 @@
"internalType": "uint64",
"name": "_gasLimit",
"type": "uint64"
},
{
"internalType": "bytes",
"name": "_depositData",
"type": "bytes"
}
],
"name": "initialize",
Expand Down Expand Up @@ -145,24 +127,11 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "_depositData",
"type": "bytes"
}
],
"name": "setDepositData",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint64",
"name": "_gasLimit",
"name": "_newGasLimit",
"type": "uint64"
}
],
Expand All @@ -175,7 +144,7 @@
"inputs": [
{
"internalType": "address",
"name": "_l2Recipient",
"name": "_newL2Recipient",
"type": "address"
}
],
Expand All @@ -188,7 +157,7 @@
"inputs": [
{
"internalType": "uint96",
"name": "_minDepositAmount",
"name": "_newMinDepositAmount",
"type": "uint96"
}
],
Expand All @@ -210,25 +179,6 @@
"stateMutability": "view",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "bytes",
"name": "oldDepositData",
"type": "bytes"
},
{
"indexed": false,
"internalType": "bytes",
"name": "newDepositData",
"type": "bytes"
}
],
"name": "DepositDataUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down Expand Up @@ -330,13 +280,13 @@
{
"indexed": false,
"internalType": "uint96",
"name": "oldminDepositAmount",
"name": "oldMinDepositAmount",
"type": "uint96"
},
{
"indexed": false,
"internalType": "uint96",
"name": "newminDepositAmount",
"name": "newMinDepositAmount",
"type": "uint96"
}
],
Expand Down
5 changes: 5 additions & 0 deletions packages/contracts-bedrock/snapshots/abi/L1Withdrawer.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,10 @@
"inputs": [],
"name": "L1Withdrawer_OnlyProxyAdminOwner",
"type": "error"
},
{
"inputs": [],
"name": "L1Withdrawer_WithdrawalGasLimitTooLow",
"type": "error"
}
]
10 changes: 5 additions & 5 deletions packages/contracts-bedrock/snapshots/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"sourceCodeHash": "0x6c9d3e2dee44c234d59ab93b6564536dfd807f1c4a02a82d5393bc53cb15b8b7"
},
"src/L1/FeesDepositor.sol:FeesDepositor": {
"initCodeHash": "0x3db0c0c8c85294f014e5aea2f12a24565184836fa92f615df84b93e07026cb1f",
"sourceCodeHash": "0xe6734ce2591585aafe0cdf3955533140dcf83c3af8bad922ffd937df5630739b"
"initCodeHash": "0x3b1acae6460e04be9a855a24de87524f19827239da08f05934c3dd6183a8b5c5",
"sourceCodeHash": "0x613dc957e3bb409d1c7fb767971308b9cb1ed3c953407c8c641a6ec2bbf42fe8"
},
"src/L1/L1CrossDomainMessenger.sol:L1CrossDomainMessenger": {
"initCodeHash": "0x3dc659aafb03bd357f92abfc6794af89ee0ddd5212364551637422bf8d0b00f9",
Expand Down Expand Up @@ -84,8 +84,8 @@
"sourceCodeHash": "0x2e85139090b9072e368a5ff36e5fcf2a90b219c6024e06a7998904cd75412395"
},
"src/L2/L1Withdrawer.sol:L1Withdrawer": {
"initCodeHash": "0x491befab56c270410b21dc33eb20d03502916e01cbda1a88371619953c6ebd10",
"sourceCodeHash": "0xbd1728f6e8e6a1201a7b88f59d0439a00d53be2a1610a504f909ad82308d6218"
"initCodeHash": "0xb25010651e421d159204b9c9d3ae3d3569e57de82eabcff6a1d2560a21b88a82",
"sourceCodeHash": "0xde60d5d9f89f6c1195b11e21b2c3287afaa756a749c052530b76f26b4cdf6c0a"
},
"src/L2/L2CrossDomainMessenger.sol:L2CrossDomainMessenger": {
"initCodeHash": "0xe160be403df12709c371c33195d1b9c3b5e9499e902e86bdabc8eed749c3fd61",
Expand Down Expand Up @@ -149,7 +149,7 @@
},
"src/L2/SuperchainRevSharesCalculator.sol:SuperchainRevSharesCalculator": {
"initCodeHash": "0xdfff95660d2d470e198054bb1717a30a45a806d2eaa3720fb43acaa3356c9a3e",
"sourceCodeHash": "0xc3f488d08c9d2c1a2f2a0cde93c1274df58c87aebcf4e384e475a9d9deb1ea51"
"sourceCodeHash": "0xabf78321b187c9d36dcf8799c079f89f0f2edb1e0ea588c27b1bad07615b9193"
},
"src/L2/SuperchainTokenBridge.sol:SuperchainTokenBridge": {
"initCodeHash": "0xb0d25dc03b9c84b07b263921c2b717e6caad3f4297fa939207e35978d7d25abe",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,5 @@
"offset": 0,
"slot": "2",
"type": "uint64"
},
{
"bytes": "32",
"label": "depositData",
"offset": 0,
"slot": "3",
"type": "bytes"
}
]
59 changes: 21 additions & 38 deletions packages/contracts-bedrock/src/L1/FeesDepositor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ contract FeesDepositor is ProxyAdminOwnedBase, Initializable, ReinitializableBas
/// @notice The gas limit for the deposit transaction.
uint64 public gasLimit;

/// @notice The data for the deposit transaction.
bytes public depositData;

/// @notice Emitted when fees are received.
/// @param sender The sender of the fees.
/// @param amount The amount of fees received.
Expand All @@ -38,9 +35,9 @@ contract FeesDepositor is ProxyAdminOwnedBase, Initializable, ReinitializableBas
event FeesDeposited(address indexed l2Recipient, uint256 amount);

/// @notice Emitted when the deposit threshold is updated.
/// @param oldminDepositAmount The old deposit threshold.
/// @param newminDepositAmount The new deposit threshold.
event MinDepositAmountUpdated(uint96 oldminDepositAmount, uint96 newminDepositAmount);
/// @param oldMinDepositAmount The old deposit threshold.
/// @param newMinDepositAmount The new deposit threshold.
event MinDepositAmountUpdated(uint96 oldMinDepositAmount, uint96 newMinDepositAmount);

/// @notice Emitted when the L2 recipient is updated.
/// @param oldL2Recipient The old L2 recipient.
Expand All @@ -52,11 +49,6 @@ contract FeesDepositor is ProxyAdminOwnedBase, Initializable, ReinitializableBas
/// @param newGasLimit The new gas limit.
event GasLimitUpdated(uint64 oldGasLimit, uint64 newGasLimit);

/// @notice Emitted when the deposit data is updated.
/// @param oldDepositData The old deposit data.
/// @param newDepositData The new deposit data.
event DepositDataUpdated(bytes oldDepositData, bytes newDepositData);

/// @notice Semantic version.
/// @custom:semver 1.0.0
string public constant version = "1.0.0";
Expand All @@ -71,13 +63,11 @@ contract FeesDepositor is ProxyAdminOwnedBase, Initializable, ReinitializableBas
/// @param _l2Recipient The L2 recipient of the fees.
/// @param _portal The portal contract.
/// @param _gasLimit The gas limit for the deposit transaction.
/// @param _depositData The deposit data for the deposit transaction.
function initialize(
uint96 _minDepositAmount,
address _l2Recipient,
IOptimismPortal _portal,
uint64 _gasLimit,
bytes memory _depositData
uint64 _gasLimit
)
external
reinitializer(initVersion())
Expand All @@ -89,54 +79,47 @@ contract FeesDepositor is ProxyAdminOwnedBase, Initializable, ReinitializableBas
minDepositAmount = _minDepositAmount;
l2Recipient = _l2Recipient;
gasLimit = _gasLimit;
depositData = _depositData;
}

/// @notice Receives ETH and deposits it to the L2 recipient through the portal when the threshold is reached.
/// @dev Be aware that when the DepositTransaction is sent, the `from` address will be the alias of this contract
/// address.
receive() external payable {
uint256 balance = address(this).balance;
emit FundsReceived(msg.sender, msg.value, balance);

if (balance >= minDepositAmount) {
address recipient = l2Recipient;
portal.depositTransaction{ value: balance }(recipient, balance, gasLimit, false, depositData);
portal.depositTransaction{ value: balance }(recipient, balance, gasLimit, false, "");
emit FeesDeposited(recipient, balance);
}
}

/// @notice Updates the deposit threshold.
/// @param _minDepositAmount The new deposit threshold.
function setMinDepositAmount(uint96 _minDepositAmount) external {
/// @param _newMinDepositAmount The new deposit threshold.
function setMinDepositAmount(uint96 _newMinDepositAmount) external {
_assertOnlyProxyAdminOwner();
uint96 oldminDepositAmount = minDepositAmount;
minDepositAmount = _minDepositAmount;
emit MinDepositAmountUpdated(oldminDepositAmount, _minDepositAmount);
uint96 oldMinDepositAmount = minDepositAmount;
minDepositAmount = _newMinDepositAmount;
emit MinDepositAmountUpdated(oldMinDepositAmount, _newMinDepositAmount);
}

/// @notice Updates the L2 recipient for the deposit transaction.
/// @param _l2Recipient The new L2 recipient.
function setL2Recipient(address _l2Recipient) external {
/// @dev The L2 recipient MUST be able to receive ether or the deposit on L2 will fail.
/// @param _newL2Recipient The new L2 recipient.
function setL2Recipient(address _newL2Recipient) external {
_assertOnlyProxyAdminOwner();
address oldL2Recipient = l2Recipient;
l2Recipient = _l2Recipient;
emit L2RecipientUpdated(oldL2Recipient, _l2Recipient);
l2Recipient = _newL2Recipient;
emit L2RecipientUpdated(oldL2Recipient, _newL2Recipient);
}

/// @notice Updates the gas limit for the deposit transaction.
/// @param _gasLimit The new gas limit.
function setGasLimit(uint64 _gasLimit) external {
/// @param _newGasLimit The new gas limit.
function setGasLimit(uint64 _newGasLimit) external {
_assertOnlyProxyAdminOwner();
uint64 oldGasLimit = gasLimit;
gasLimit = _gasLimit;
emit GasLimitUpdated(oldGasLimit, _gasLimit);
}

/// @notice Updates the deposit data.
/// @param _depositData The new deposit data.
function setDepositData(bytes memory _depositData) external {
_assertOnlyProxyAdminOwner();
bytes memory oldDepositData = depositData;
depositData = _depositData;
emit DepositDataUpdated(oldDepositData, _depositData);
gasLimit = _newGasLimit;
emit GasLimitUpdated(oldGasLimit, _newGasLimit);
}
}
Loading