BuildersTreasuryV2

Overview

The BuildersTreasuryV2 contract serves as a dedicated storage vault and distribution mechanism for builder rewards in the protocol. It is tightly integrated with the BuildersV4 contract and acts as the reward source when the Subnet admin or claim admin claim their share of MOR tokens.

The treasury holds the reward token (MOR) and is the only contract authorized to send out rewards. It tracks the total distributed rewards (claimed amount).

To function correctly, the protocol administrator (owner) must ensure that this contract is regularly and sufficiently funded.

Key Features

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

  2. Access controlled: only the BuildersV4 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 payments.

Storage

rewardToken

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

address public rewardToken;

builders

Stores the address of the authorized BuildersV4 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

BuildersTreasuryV2_init

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

function BuildersTreasuryV2_init(
  address rewardToken_,
) external initializer;
Name
Description

rewardToken_

Address of the MOR token used for rewards

setBuilders

Updates the address of the BuildersV4 contract.

function setBuilders(address builders_) public onlyOwner
Name
Description

builders_

Address of the new BuildersV4 contract to authorize

withdraw

The function to withdraw rewardToken from the contract.

 function withdraw(address receiver_, uint256 amount_) external onlyOwner;
Name
Description

receiver_

Address of the user receiving the rewards

amount_

Amount of tokens to transfer. Wei.

Functions for the BuildersV4 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 tokens to transfer. Wei.

Read functions

supportsInterface

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

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

version

Returns the current version of the contract.

function version() external pure returns (uint256

Last updated

Was this helpful?