Skip to content

Commit 0f77ce5

Browse files
funkornaut0010xDiscotech0xiamflux0xChin
authored
feat: fee splitter system (#469)
---- Co-authored-by: Disco <[email protected]> Co-authored-by: Flux <[email protected]> Co-authored-by: Chiin <[email protected]>
1 parent b200250 commit 0f77ce5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+5086
-324
lines changed

packages/contracts-bedrock/deploy-config/hardhat.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@
2525
"baseFeeVaultRecipient": "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc",
2626
"l1FeeVaultRecipient": "0x71bE63f3384f5fb98995898A86B02Fb2426c5788",
2727
"sequencerFeeVaultRecipient": "0xfabb0ac9d68b0b445fb7357272ff202c5651694a",
28+
"operatorFeeVaultRecipient": "0x1CBd3b2770909D4e10f157cABC84C7264073C9Ec",
29+
"operatorFeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
2830
"baseFeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
2931
"l1FeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
3032
"sequencerFeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
3133
"baseFeeVaultWithdrawalNetwork": 0,
3234
"l1FeeVaultWithdrawalNetwork": 0,
3335
"sequencerFeeVaultWithdrawalNetwork": 0,
36+
"operatorFeeVaultWithdrawalNetwork": 0,
3437
"enableGovernance": true,
3538
"governanceTokenName": "Optimism",
3639
"governanceTokenSymbol": "OP",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import { ISemver } from "interfaces/universal/ISemver.sol";
5+
import { IProxyAdminOwnedBase } from "interfaces/L1/IProxyAdminOwnedBase.sol";
6+
import { IReinitializableBase } from "interfaces/universal/IReinitializableBase.sol";
7+
import { IOptimismPortal2 as IOptimismPortal } from "interfaces/L1/IOptimismPortal2.sol";
8+
9+
interface IFeesDepositor is ISemver, IProxyAdminOwnedBase, IReinitializableBase {
10+
event FundsReceived(address indexed sender, uint256 amount, uint256 newBalance);
11+
event FeesDeposited(address indexed l2Recipient, uint256 amount);
12+
event MinDepositAmountUpdated(uint96 oldminDepositAmount, uint96 newminDepositAmount);
13+
event L2RecipientUpdated(address oldL2Recipient, address newL2Recipient);
14+
event GasLimitUpdated(uint64 oldGasLimit, uint64 newGasLimit);
15+
event DepositDataUpdated(bytes oldDepositData, bytes newDepositData);
16+
17+
function minDepositAmount() external view returns (uint256);
18+
function portal() external view returns (IOptimismPortal);
19+
function l2Recipient() external view returns (address);
20+
function gasLimit() external view returns (uint64);
21+
function depositData() external view returns (bytes memory);
22+
function initialize(
23+
uint96 _minDepositAmount,
24+
address _l2Recipient,
25+
IOptimismPortal _portal,
26+
uint64 _gasLimit,
27+
bytes memory _depositData
28+
)
29+
external;
30+
31+
function setMinDepositAmount(uint96 _minDepositAmount) external;
32+
function setL2Recipient(address _l2Recipient) external;
33+
function setGasLimit(uint64 _gasLimit) external;
34+
function setDepositData(bytes memory _depositData) external;
35+
36+
function __constructor__() external;
37+
}

packages/contracts-bedrock/interfaces/L2/IBaseFeeVault.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface IBaseFeeVault {
1515
function minWithdrawalAmount() external view returns (uint256 amount_);
1616
function recipient() external view returns (address recipient_);
1717
function totalProcessed() external view returns (uint256);
18-
function withdraw() external;
18+
function withdraw() external returns (uint256 value_);
1919
function withdrawalNetwork() external view returns (Types.WithdrawalNetwork network_);
2020

2121
function version() external view returns (string memory);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import { ISemver } from "interfaces/universal/ISemver.sol";
5+
import { ISharesCalculator } from "interfaces/L2/ISharesCalculator.sol";
6+
7+
interface IFeeSplitter is ISemver {
8+
error FeeSplitter_ExceedsMaxFeeDisbursementTime();
9+
error FeeSplitter_SharesCalculatorCannotBeZero();
10+
error FeeSplitter_DisbursementIntervalNotReached();
11+
error FeeSplitter_FeeShareInfoEmpty();
12+
error FeeSplitter_NoFeesCollected();
13+
error FeeSplitter_FeeVaultMustWithdrawToL2();
14+
error FeeSplitter_FeeVaultMustWithdrawToFeeSplitter();
15+
error FeeSplitter_OnlyProxyAdminOwner();
16+
error FeeSplitter_FailedToSendToRevenueShareRecipient();
17+
error FeeSplitter_SharesCalculatorMalformedOutput();
18+
error FeeSplitter_ReceiveWindowClosed();
19+
error FeeSplitter_SenderNotApprovedVault();
20+
21+
event FeesReceived(address indexed sender, uint256 amount);
22+
event FeeDisbursementIntervalUpdated(uint128 oldFeeDisbursementInterval, uint128 newFeeDisbursementInterval);
23+
event FeesDisbursed(ISharesCalculator.ShareInfo[] shareInfo, uint256 grossRevenue);
24+
event SharesCalculatorUpdated(address oldSharesCalculator, address newSharesCalculator);
25+
26+
function sharesCalculator() external view returns (ISharesCalculator);
27+
function lastDisbursementTime() external view returns (uint128);
28+
function feeDisbursementInterval() external view returns (uint128);
29+
30+
function initialize(ISharesCalculator _sharesCalculator) external;
31+
32+
function disburseFees() external;
33+
34+
function setFeeDisbursementInterval(uint128 _newFeeDisbursementInterval) external;
35+
36+
function setSharesCalculator(ISharesCalculator _newSharesCalculator) external;
37+
38+
receive() external payable;
39+
}
Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.0;
33

4-
library Types {
5-
enum WithdrawalNetwork {
6-
L1,
7-
L2
8-
}
9-
}
4+
import { Types } from "src/libraries/Types.sol";
105

116
interface IFeeVault {
7+
error FeeSplitter_OnlyProxyAdminOwner();
8+
129
event Withdrawal(uint256 value, address to, address from);
1310
event Withdrawal(uint256 value, address to, address from, Types.WithdrawalNetwork withdrawalNetwork);
11+
event MinWithdrawalAmountUpdated(uint256 oldWithdrawalAmount, uint256 newWithdrawalAmount);
12+
event RecipientUpdated(address oldRecipient, address newRecipient);
13+
event WithdrawalNetworkUpdated(
14+
Types.WithdrawalNetwork oldWithdrawalNetwork, Types.WithdrawalNetwork newWithdrawalNetwork
15+
);
1416

1517
receive() external payable;
1618

1719
function MIN_WITHDRAWAL_AMOUNT() external view returns (uint256);
1820
function RECIPIENT() external view returns (address);
1921
function WITHDRAWAL_NETWORK() external view returns (Types.WithdrawalNetwork);
20-
function minWithdrawalAmount() external view returns (uint256 amount_);
21-
function recipient() external view returns (address recipient_);
22+
function minWithdrawalAmount() external view returns (uint256);
23+
function recipient() external view returns (address);
2224
function totalProcessed() external view returns (uint256);
23-
function withdraw() external;
24-
function withdrawalNetwork() external view returns (Types.WithdrawalNetwork network_);
25+
function withdraw() external returns (uint256 value_);
26+
function withdrawalNetwork() external view returns (Types.WithdrawalNetwork);
27+
function setMinWithdrawalAmount(uint256 _newMinWithdrawalAmount) external;
28+
function setRecipient(address _newRecipient) external;
29+
function setWithdrawalNetwork(Types.WithdrawalNetwork _newWithdrawalNetwork) external;
2530

26-
function __constructor__() external;
31+
function __constructor__(
32+
address _recipient,
33+
uint256 _minWithdrawalAmount,
34+
Types.WithdrawalNetwork _withdrawalNetwork
35+
) external;
2736
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import { Types } from "src/libraries/Types.sol";
5+
6+
interface IFeeVaultInitializer {
7+
/// @notice Emitted when a fee vault implementation is deployed.
8+
/// @param vaultType The type of fee vault being deployed.
9+
/// @param newImplementation The deployed implementation address.
10+
/// @param recipient The recipient address for the implementation.
11+
/// @param network The withdrawal network for the implementation.
12+
/// @param minWithdrawalAmount The minimum withdrawal amount for the implementation.
13+
event FeeVaultDeployed(
14+
string indexed vaultType,
15+
address indexed newImplementation,
16+
address recipient,
17+
Types.WithdrawalNetwork network,
18+
uint256 minWithdrawalAmount
19+
);
20+
21+
function version() external view returns (string memory);
22+
}

packages/contracts-bedrock/interfaces/L2/IL1FeeVault.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface IL1FeeVault {
1515
function minWithdrawalAmount() external view returns (uint256 amount_);
1616
function recipient() external view returns (address recipient_);
1717
function totalProcessed() external view returns (uint256);
18-
function withdraw() external;
18+
function withdraw() external returns (uint256 value_);
1919
function withdrawalNetwork() external view returns (Types.WithdrawalNetwork network_);
2020

2121
function version() external view returns (string memory);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import { ISemver } from "interfaces/universal/ISemver.sol";
5+
6+
interface IL1Withdrawer is ISemver {
7+
error L1Withdrawer_OnlyProxyAdminOwner();
8+
9+
event WithdrawalInitiated(uint256 amount, address indexed recipient);
10+
event MinWithdrawalAmountUpdated(uint256 oldMinWithdrawalAmount, uint256 newMinWithdrawalAmount);
11+
event RecipientUpdated(address oldRecipient, address newRecipient);
12+
event WithdrawalGasLimitUpdated(uint96 oldWithdrawalGasLimit, uint96 newWithdrawalGasLimit);
13+
14+
function minWithdrawalAmount() external view returns (uint256);
15+
function recipient() external view returns (address);
16+
function withdrawalGasLimit() external view returns (uint96);
17+
18+
function setMinWithdrawalAmount(uint256 _newMinWithdrawalAmount) external;
19+
function setRecipient(address _newRecipient) external;
20+
function setWithdrawalGasLimit(uint96 _newWithdrawalGasLimit) external;
21+
22+
function __constructor__(uint256 _minWithdrawalAmount, address _recipient, uint96 _withdrawalGasLimit) external;
23+
}

packages/contracts-bedrock/interfaces/L2/IOperatorFeeVault.sol

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ interface IOperatorFeeVault {
1515
function minWithdrawalAmount() external view returns (uint256 amount_);
1616
function recipient() external view returns (address recipient_);
1717
function totalProcessed() external view returns (uint256);
18-
function withdraw() external;
18+
function withdraw() external returns (uint256 value_);
1919
function withdrawalNetwork() external view returns (Types.WithdrawalNetwork network_);
2020

2121
function version() external view returns (string memory);
2222

23-
function __constructor__()
23+
function __constructor__(
24+
address _recipient,
25+
uint256 _minWithdrawalAmount,
26+
Types.WithdrawalNetwork _withdrawalNetwork
27+
)
2428
external;
2529
}

packages/contracts-bedrock/interfaces/L2/ISequencerFeeVault.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ interface ISequencerFeeVault {
1515
function minWithdrawalAmount() external view returns (uint256 amount_);
1616
function recipient() external view returns (address recipient_);
1717
function totalProcessed() external view returns (uint256);
18-
function withdraw() external;
18+
function withdraw() external returns (uint256 value_);
1919
function withdrawalNetwork() external view returns (Types.WithdrawalNetwork network_);
20+
function setMinWithdrawalAmount(uint256 _newMinWithdrawalAmount) external;
21+
function setRecipient(address _newRecipient) external;
22+
function setWithdrawalNetwork(Types.WithdrawalNetwork _newWithdrawalNetwork) external;
2023

2124
function version() external view returns (string memory);
2225
function l1FeeWallet() external view returns (address);

0 commit comments

Comments
 (0)