relevant tag icon
UMA Merkle Reward Distributor
copy icon
UMA
• version 1.0.0
Rewards
Merkle
Audited

UMA Merkle Reward Distributor

Audited

Allows an owner to distribute any reward ERC20 to claimants according to Merkle roots. The owner can specify multiple Merkle roots distributions with customized reward currencies.

*Visit desktop site to download or deploy

Version

1.0.0

Creator

UMA

Recent Use

🍞 0x77CA downloaded
🥐 0x77CA saved
🥖 0xB2a9 downloaded

Last Publish

11/5/2022
Any contract you deploy is yours.
Fully owned and controlled by your wallet.
Documentation
Source Code
setWindow(uint256,address,bytes32,string) :
This function allows the owner of the contract to set a new window for rewards distribution. It takes in four parameters: rewardsToDeposit (the amount of rewards to be deposited in the window), rewardToken (the address of the token to be used for rewards), merkleRoot (the Merkle root of the window's data), and ipfsHash (the IPFS hash of the window's data). The function then sets the window by incrementing the nextCreatedIndex and calling the _setWindow() function with the given parameters. (autogenerated documentation)
deleteWindow(uint256) :
This function allows the owner of the contract to delete a window from the Merkle tree. It takes the window index as an argument and removes the window from the merkleWindows mapping. It then emits an event to signal that the window has been deleted. (autogenerated documentation)
withdrawRewards(uint256) :
This function allows the owner of the contract to withdraw rewards from a specified ERC20 token. It takes two parameters, an ERC20 token and an amount, and then transfers the specified amount of the token to the sender of the transaction. It also emits an event to log the withdrawal. (autogenerated documentation)
claimMulti() :
This function is used to process multiple claims at once. It takes an array of Claim objects as an argument and loops through each one. For each claim, it verifies and marks it as claimed, and adds the amount of the claim to a running total. If the next claim in the array is for a different account or a different reward token, the running total is sent to the account as a single transfer. This allows multiple claims to be processed in a single transaction, reducing gas costs. (autogenerated documentation)
claim() :
This function is used to claim rewards from a Merkle window. It takes a Claim memory _claim as an argument, which contains the account address, amount, and window index of the claim. The function first verifies that the claim is valid and then marks it as claimed. Finally, it transfers the reward token to the account address specified in the claim, for the amount specified in the claim. (autogenerated documentation)
isClaimed(uint256,uint256) :
This function checks if a given account has already claimed a reward in a given window. It does this by looking up the account index in the claimedBitMap array, which is a 2D array of 256-bit words. The account index is divided by 256 to get the word index, and the remainder is used to get the bit index. A mask is then created with a bit set at the bit index, and the word is compared to the mask. If the word and the mask match, then the account has already claimed a reward in the window. (autogenerated documentation)
getRewardTokenForWindow(uint256) :
This function retrieves the address of the reward token associated with a given window index. It does this by accessing the merkleWindows array and returning the address stored in the rewardToken field of the window at the given index. (autogenerated documentation)
verifyClaim() :
This function verifies a claim made by a user. It takes a Claim memory struct as an argument and returns a boolean value indicating whether the claim is valid or not. The function first calculates the leaf node of the Merkle tree by hashing the account address, amount, and account index of the claim. It then uses the MerkleProof.verify() function to check if the leaf node is present in the Merkle tree, using the merkle proof and the merkle root of the corresponding window index. If the leaf node is present, the claim is valid and the function returns true. (autogenerated documentation)
_setClaimed(uint256,uint256) :
This function sets a bit in the claimedBitMap array to indicate that a particular account has claimed a reward from a particular window. The windowIndex and accountIndex parameters are used to determine the index of the bit to be set. The claimedWordIndex is calculated by dividing the accountIndex by 256, and the claimedBitIndex is calculated by taking the remainder of the accountIndex divided by 256. The bit is then set by performing a bitwise OR operation on the existing value in the claimedBitMap array with a value of 1 shifted left by the claimedBitIndex. (autogenerated documentation)
_setWindow(uint256,uint256,address,bytes32,string) :
This function is used to set a new window in the MerkleWindows array. It takes in five parameters: windowIndex, rewardsDeposited, rewardToken, merkleRoot, and ipfsHash. It sets the merkleRoot, remainingAmount, rewardToken, and ipfsHash of the window at the given windowIndex. It also emits a CreatedWindow event and transfers the rewardsDeposited amount of rewardToken from the msg.sender to the contract address. (autogenerated documentation)
_verifyAndMarkClaimed() :
This function verifies and marks a claim made by a user. It first checks that the claim is valid using the verifyClaim() function. It then checks that the user has not already claimed for the window. If both of these checks pass, the function sets the claim as claimed, subtracts the amount from the remaining amount of the window, and emits an event. (autogenerated documentation)

Get Cookin'
share iconShare

copy iconDownload Source
copy iconnpx cookbookdev i uma-merkle-distributor
copy icon

Recent Use

🍞 0x77CA downloaded
🥐 0x77CA saved
🥖 0xB2a9 downloaded

Last Publish

11/5/2022

Version

1.0.0

Creator

UMA

Cookbook is free.
Any contract you deploy is yours.
Your contract is owned and controlled by you.