Skip to content

Commit

Permalink
feat: implement SablierFees contract
Browse files Browse the repository at this point in the history
  • Loading branch information
andreivladbrg committed Jan 9, 2025
1 parent d10ac77 commit f0494ae
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/SablierFees.sol
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 });
}
}
18 changes: 18 additions & 0 deletions src/interfaces/ISablierFees.sol
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;
}

0 comments on commit f0494ae

Please sign in to comment.