RollingMerkleDistributor
A rolling Merkle distributor. At the end of ever claim window, a privileged account can deploy a new root (and window) to distribute more funds. The stakeholder must also supply the funds to be distributed by the contract in a separate transaction. The intention is for the stakeholder to rollover unclaimed funds from the previous window into the next Merkle root, so users can claim anytime and never "miss" their chance to do so. This is an entirely trust based process. Privileged accounts can leave a user's fund out of the root, or deploy a root that allows them alone to reclaim all the funds. This is by design.
function MAX_PERIOD() external view returns (uint256)
The maximum length of a claim window that can be defined at rollover. Does not apply to the length of the claim window for initial distribution, defined at deployment.
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function authority() external view returns (contract RolesAuthority)
The contract used to source permissions for accounts targeting this contract.
Name | Type | Description |
---|---|---|
_0 | contract RolesAuthority | undefined |
function claim(RollingMerkleDistributorTypes.Claim _claim) external nonpayable
Name | Type | Description |
---|---|---|
_claim | RollingMerkleDistributorTypes.Claim | undefined |
function initialize(contract RolesAuthority _authority, bytes20 _specialTarget) external nonpayable
One time method to be called at deployment to configure the contract. Required so EndaomentAuth contracts can be deployed as minimal proxies (clones).
Name | Type | Description |
---|---|---|
_authority | contract RolesAuthority | Contract that will be used to source permissions for accounts targeting this contract. |
_specialTarget | bytes20 | The bytes that this contract will pass as the "target" when looking up permissions from the authority. If set to empty bytes, this contract will pass its own address instead. |
function isClaimed(uint256 _window, uint256 _index) external view returns (bool)
Helper method that reads from the boolean flag array and returns whether the Merkle tree leaf node at a given index, for a given claim distribution window, has already been claimed.
Name | Type | Description |
---|---|---|
_window | uint256 | The Unix timestamp of the end date of the claim window for which claim status is being queried. |
_index | uint256 | The position of the claim in the list of the Merkle tree's leaf nodes. |
Name | Type | Description |
---|---|---|
_0 | bool | _isClaimed The claim status for this node and this claim window. |
function merkleRoot() external view returns (bytes32)
The current Merkle root which claimants must provide a proof against.
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
function rollover(bytes32 _newRoot, uint256 _period) external nonpayable
Privileged method that sets a new Merkle root and defines a new claim window. Can only be called after the previous window has closed.
Name | Type | Description |
---|---|---|
_newRoot | bytes32 | The new Merkle root for this distribution. |
_period | uint256 | The length of the new claim window in seconds. Must be less than MAX_PERIOD. |
function specialTarget() external view returns (bytes20)
If set to a non-zero value, this contract will pass these byes as the target contract to the RolesAuthority's
canCall
method, rather than its own contract. This allows a single RolesAuthority permission to manage permissions simultaneously for a group of contracts that identify themselves as a certain type. For example: set a permission for all "entity" contracts.Name | Type | Description |
---|---|---|
_0 | bytes20 | undefined |
function token() external view returns (contract IERC20)
The ERC20 token that will be distributed by this contract.
Name | Type | Description |
---|---|---|
_0 | contract IERC20 | undefined |
function windowEnd() external view returns (uint256)
A Unix timestamp denoting the last second of the current claim window.
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
event Claimed(uint256 indexed window, uint256 index, address indexed claimant, uint256 amount)
Updated when an account completes a proof based claim.
Name | Type | Description |
---|---|---|
window indexed | uint256 | undefined |
index | uint256 | undefined |
claimant indexed | address | undefined |
amount | uint256 | undefined |
event MerkleRootRolledOver(bytes32 indexed merkleRoot, uint256 windowEnd)
Emitted when an authorized account rolls over the Merkle root and claim window. Also emitted on deploy with initial root and claim window.
Name | Type | Description |
---|---|---|
merkleRoot indexed | bytes32 | undefined |
windowEnd | uint256 | undefined |
error AlreadyClaimed()
Thrown if a claimant attempts to claim funds that were already claimed.
error AlreadyInitialized()
Thrown if there is a second call to initialize.
error InvalidAuthority()
Thrown if there is an attempt to deploy with address 0 as the authority.
error InvalidPeriod()
Thrown if there is an attempt to define a claim window period that is 0 seconds, or too long.
error InvalidProof()
Thrown if the claimant provides an invalid Merkle proof when attempting to claim.
error OutsideClaimWindow()
Thrown if a claim is attempted after the claim window has closed, but before its rolled over.
error PriorWindowStillOpen()
Thrown if there is an attempt to rollover while the current claim window is still open.
error Unauthorized()
Thrown when an account without proper permissions calls a privileged method.
Last modified 4mo ago