Docs
Search…
⌃K

MultiMerkleDistributor

The MultiMerkleDistributor is the Distributor smart contract in the Quest system. This smart contract is based on the logic of a Merkle Tree Distributor, adapted to handle multiple Merkl Tree, for each Quest, and each period of those Quests. The Distributor will receive the rewards that voter will claim when a period is closed, and then Merkle Roots, generated using Quests parameters, and votes from the closed periods (& previous periods). Once a Merkle Root is set for a period of a Quest, voters can claim the rewards anytime they wish.

Storage mappings & variables

questRewardToken

Mapping listing the reward token associated to each Quest ID
mapping(uint256 => address) public questRewardToken;

rewardTokens

Mapping of tokens this contract is or was distributing
mapping(address => bool) public rewardTokens;

questClosedPeriods

List of Closed QuestPeriods by Quest ID
mapping(uint256 => uint256[]) public questClosedPeriods;

questMerkleRootPerPeriod

Merkle Root for each period of a Quest (indexed by Quest ID)
mapping(uint256 => mapping(uint256 => bytes32)) public questMerkleRootPerPeriod;

questRewardsPerPeriod

Amount of rewards for each period of a Quest (indexed by Quest ID)
mapping(uint256 => mapping(uint256 => uint256)) public questRewardsPerPeriod;

questPeriodClaimedBitMap

BitMap of claims for each period of a Quest
mapping(uint256 => mapping(uint256 => mapping(uint256 => uint256))) private questPeriodClaimedBitMap;

questBoard

Address of the QuestBoard contract
address public immutable questBoard;

Read only methods

isClaimed

Checks if the rewards were claimed for an user on a given period
function isClaimed(uint256 questID, uint256 period, uint256 index) public view returns (bool)

getClosedPeriodsByQuests

Returns all current Closed periods for the given Quest ID
function getClosedPeriodsByQuests(uint256 questID) external view returns (uint256[] memory)

User state-changing functions

claim

Claims the reward for an user for a given period of a Quest
function claim(uint256 questID, uint256 period, uint256 index, address account, uint256 amount, bytes32[] calldata merkleProof) public
Parameters:
  • questID ID of the Quest
  • period Timestamp of the period
  • index Index in the Merkle Tree
  • account Address of the user claiming the rewards
  • amount Amount of rewards to claim
  • merkleProof Proof to claim the rewards

multiClaim

Claims multiple rewards for a given list
function multiClaim(address account, ClaimParams[] calldata claims) external
Parameters:
  • account Address of the user claiming the rewards
  • claims List of ClaimParams struct data to claim
With the Struct:
struct ClaimParams { uint256 questID; uint256 period; uint256 index; uint256 amount; bytes32[] merkleProof; }

claimQuest

Claims the reward for all the given periods of a Quest, and transfer all the rewards at once
function claimQuest(address account, uint256 questID, ClaimParams[] calldata claims) external
Parameters:
  • account Address of the user claiming the rewards
  • questID ID of the Quest
  • claims List of ClaimParams struct data to claim