-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement SablierFees contract
- Loading branch information
1 parent
d10ac77
commit f0494ae
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity >=0.8.22; | ||
|
||
import { ISablierFees } from "./interfaces/ISablierFees.sol"; | ||
import { Errors } from "./libraries/Errors.sol"; | ||
|
||
import { Adminable } from "./Adminable.sol"; | ||
|
||
/// @title SablierFees | ||
/// @notice See the documentation in {ISablierFees}. | ||
abstract contract SablierFees is Adminable, ISablierFees { | ||
/// @inheritdoc ISablierFees | ||
function collectFees() external override { | ||
uint256 feeAmount = address(this).balance; | ||
|
||
// Effect: transfer the fees to the admin. | ||
(bool success,) = admin.call{ value: feeAmount }(""); | ||
|
||
// Revert if the call failed. | ||
if (!success) { | ||
revert Errors.SablierFees_FeeTransferFail(admin, feeAmount); | ||
} | ||
|
||
// Log the fee withdrawal. | ||
emit ISablierFees.CollectFees({ admin: admin, feeAmount: feeAmount }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity >=0.8.22; | ||
|
||
/// @notice This contract handles the logic for managing Sablier fees. | ||
interface ISablierFees { | ||
/// @notice Emitted when the accrued fees are collected. | ||
/// @param admin The address of the current contract admin, which has received the fees. | ||
/// @param feeAmount The amount of collected fees. | ||
event CollectFees(address indexed admin, uint256 indexed feeAmount); | ||
|
||
/// @notice Collects the accrued fees by transferring them to the contract admin. | ||
/// | ||
/// @dev Emits a {CollectFees} event. | ||
/// | ||
/// Notes: | ||
/// - If the admin is a contract, it must be able to receive ETH. | ||
function collectFees() external; | ||
} |