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.
Mapping listing the reward token associated to each Quest ID
mapping(uint256 => address) public questRewardToken;
Mapping of tokens this contract is or was distributing
mapping(address => bool) public rewardTokens;
List of Closed QuestPeriods by Quest ID
mapping(uint256 => uint256[]) public questClosedPeriods;
Merkle Root for each period of a Quest (indexed by Quest ID)
mapping(uint256 => mapping(uint256 => bytes32)) public questMerkleRootPerPeriod;
Amount of rewards for each period of a Quest (indexed by Quest ID)
mapping(uint256 => mapping(uint256 => uint256)) public questRewardsPerPeriod;
BitMap of claims for each period of a Quest
mapping(uint256 => mapping(uint256 => mapping(uint256 => uint256))) private questPeriodClaimedBitMap;
Address of the QuestBoard contract
address public immutable questBoard;
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)
Returns all current Closed periods for the given Quest ID
function getClosedPeriodsByQuests(uint256 questID) external view returns (uint256[] memory)
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 Questperiod
Timestamp of the periodindex
Index in the Merkle Treeaccount
Address of the user claiming the rewardsamount
Amount of rewards to claimmerkleProof
Proof to claim the rewards
Claims multiple rewards for a given list
function multiClaim(address account, ClaimParams[] calldata claims) external
Parameters:
account
Address of the user claiming the rewardsclaims
List of ClaimParams struct data to claim
With the Struct:
struct ClaimParams { uint256 questID; uint256 period; uint256 index; uint256 amount; bytes32[] merkleProof; }
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 rewardsquestID
ID of the Questclaims
List of ClaimParams struct data to claim
Last modified 1yr ago