RewardsDistributor

Git Source

Inherits: Ownable

Author: Morpho Labs.

This contract allows Morpho users to claim their rewards. This contract is largely inspired by Euler Distributor's contract: https://github.com/euler-xyz/euler-contracts/blob/master/contracts/mining/EulDistributor.sol.

State Variables

MORPHO

STORAGE ///

ERC20 public immutable MORPHO;

currRoot

bytes32 public currRoot;

prevRoot

bytes32 public prevRoot;

claimed

mapping(address => uint256) public claimed;

Functions

constructor

CONSTRUCTOR ///

Constructs Morpho's RewardsDistributor contract.

constructor(address _morpho);

Parameters

NameTypeDescription
_morphoaddressThe address of the MORPHO token to distribute.

updateRoot

EXTERNAL ///

Updates the current merkle tree's root.

function updateRoot(bytes32 _newRoot) external onlyOwner;

Parameters

NameTypeDescription
_newRootbytes32The new merkle tree's root.

withdrawMorphoTokens

Withdraws MORPHO tokens to a recipient.

function withdrawMorphoTokens(address _to, uint256 _amount) external onlyOwner;

Parameters

NameTypeDescription
_toaddressThe address of the recipient.
_amountuint256The amount of MORPHO tokens to transfer.

claim

Claims rewards.

function claim(address _account, uint256 _claimable, bytes32[] calldata _proof) external;

Parameters

NameTypeDescription
_accountaddressThe address of the claimer.
_claimableuint256The overall claimable amount of token rewards.
_proofbytes32[]The merkle proof that validates this claim.

Events

RootUpdated

EVENTS ///

Emitted when the root is updated.

event RootUpdated(bytes32 newRoot);

MorphoWithdrawn

Emitted when MORPHO tokens are withdrawn.

event MorphoWithdrawn(address to, uint256 amount);

RewardsClaimed

Emitted when an account claims rewards.

event RewardsClaimed(address account, uint256 amount);

Errors

ProofInvalidOrExpired

ERRORS ///

Thrown when the proof is invalid or expired.

error ProofInvalidOrExpired();

AlreadyClaimed

Thrown when the claimer has already claimed the rewards.

error AlreadyClaimed();