BuildersTreasury

Overview

The BuildersTreasury contract serves as a dedicated storage vault and distribution mechanism for builder rewards in the Morpheus protocol. It is tightly integrated with the Builders contract and acts as the reward source when builders (administrators of pools) claim their share of MOR tokens.

The treasury holds the reward token (typically MOR) and is the only contract authorized to send out rewards to builder pool administrators. It tracks the total distributed rewards to ensure correct accounting.

To function correctly, the Morpheus protocol administrators must ensure that this contract is regularly and sufficiently funded. This is critical for the accurate calculation and fair distribution of rewards, since the reward rate and availability are derived based on the current token balance in the treasury.

Key Features

  1. Reward source: acts as the source of truth and distribution for builder rewards in the protocol.

  2. Access controlled: only the Builders contract can trigger reward transfers.

  3. Reward accounting: tracks the total amount of rewards that have been distributed.

  4. Protocol-funded: must be funded by Morpheus protocol operators on L1 (e.g., Ethereum) to ensure proper cross-chain reward emission calculations.

Storage

rewardToken

Holds the address of the MOR token used as the reward currency.

address public rewardToken;

builders

Stores the address of the authorized Builders contract that can distribute rewards.

address public builders;

distributedRewards

Tracks the total amount of rewards that have been distributed through this treasury.

uint256 public distributedRewards;

Functions for the contract owner

BuildersTreasury_init

Initializes the treasury contract with the reward token and Builders contract.

function BuildersTreasury_init(
  address rewardToken_,
  address builders_
) external initializer;
Name
Description

rewardToken_

Address of the MOR token used for rewards

builders_

Address of the Builders contract authorized to manage rewards

setBuilders

Updates the address of the Builders contract.

function setBuilders(address builders_) public onlyOwner
Name
Description

builders_

Address of the new Builders contract to authorize

Functions for the Builders contract

sendRewards

Transfers reward tokens to a specified receiver. Callable only by the Builders contract.

function sendRewards(address receiver_, uint256 amount_) external onlyBuilders
Name
Description

receiver_

Address of the user receiving the rewards

amount_

Amount of reward tokens to transfer. Wei.

Read functions

supportsInterface

Used for interface detection (ERC165). Returns true if the contract supports a specific interfaceId_. Supports IBuildersTreasury, IERC165.

function supportsInterface(bytes4 interfaceId_) external pure returns (bool)

getAllRewards

Returns the total rewards managed by the treasury, including both distributed and undistributed tokens.

function getAllRewards() public view returns (uint256)


Last updated

Was this helpful?