-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add minting fee and treasury management
To be added in follow-up commits: - oracle fee compensation - proper tests - updated docs - updated deploy addresses
- Loading branch information
Showing
6 changed files
with
137 additions
and
12 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
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
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,33 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
/// @title A contract that manages fee-related functionality. | ||
interface ITreasuryManager { | ||
/// @notice Sets the minting fee for a given token used for paying. | ||
/// @dev Callable only by the owner. | ||
/// @param token The token whose fee is set. | ||
/// @param newFee The new fee in base units. | ||
function setFee(address token, uint256 newFee) external; | ||
|
||
/// @notice Sets the address that receives the fees. | ||
/// @dev Callable only by the owner. | ||
/// @param newTreasury The new address of the treasury. | ||
function setTreasury(address payable newTreasury) external; | ||
|
||
/// @notice The minting fee of a token. | ||
/// @param token The token used for paying. | ||
/// @return fee The amount of the fee in base units. | ||
function fee(address token) external view returns (uint256 fee); | ||
|
||
/// @notice Returns the address that receives the fees. | ||
function treasury() external view returns (address payable); | ||
|
||
/// @notice Event emitted when a token's fee is changed. | ||
/// @param token The address of the token whose fee was changed. 0 for ether. | ||
/// @param newFee The new amount of fee in base units. | ||
event FeeChanged(address token, uint256 newFee); | ||
|
||
/// @notice Event emitted when the treasury address is changed. | ||
/// @param newTreasury The new address of the treasury. | ||
event TreasuryChanged(address newTreasury); | ||
} |
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: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
/// @title Library for functions related to addresses. | ||
library LibAddress { | ||
/// @notice Error thrown when sending ether fails. | ||
/// @param recipient The address that could not receive the ether. | ||
error FailedToSendEther(address recipient); | ||
|
||
/// @notice Send ether to an address, forwarding all available gas and reverting on errors. | ||
/// @param recipient The recipient of the ether. | ||
/// @param amount The amount of ether to send in base units. | ||
function sendEther(address payable recipient, uint256 amount) internal { | ||
// solhint-disable-next-line avoid-low-level-calls | ||
(bool success, ) = recipient.call{ value: amount }(""); | ||
if (!success) revert FailedToSendEther(recipient); | ||
} | ||
} |
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
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,29 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.19; | ||
|
||
import { ITreasuryManager } from "../interfaces/ITreasuryManager.sol"; | ||
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; | ||
|
||
/// @title A contract that manages fee-related functionality. | ||
contract TreasuryManager is ITreasuryManager, Initializable, OwnableUpgradeable { | ||
address payable public treasury; | ||
|
||
mapping(address => uint256) public fee; | ||
|
||
/// @param treasury_ The address that will receive the fees. | ||
// solhint-disable-next-line func-name-mixedcase | ||
function __TreasuryManager_init(address payable treasury_) internal onlyInitializing { | ||
treasury = treasury_; | ||
} | ||
|
||
function setFee(address token, uint256 newFee) external onlyOwner { | ||
fee[token] = newFee; | ||
emit FeeChanged(token, newFee); | ||
} | ||
|
||
function setTreasury(address payable newTreasury) external onlyOwner { | ||
treasury = newTreasury; | ||
emit TreasuryChanged(newTreasury); | ||
} | ||
} |