Function: function claimTokens(bytes32[] proof, uint256 epoch, uint256 index, uint256 tokenIdx, uint16 shareBbps)
The function allows the user to claim their share if provided a valid Merkle proof. The merkleRoot data for verification can be only provided by the owner of the contract using the updateTokenShares function. The caller of the function cannot control recipient address, so they can only claim the funds assigned to them. At the same time, the caller has control of which of the epochs they want to claim funds.
Inputs
proofValidation: The
MerkleProofLib.verifyfunction returns true if the proof is valid.Impact: Merkle proof containing sibling hashes on the branch from the leaf to the root of the Merkle tree.
epochValidation: If
tokenClaims[epoch][recipient]is true, the caller already claimed for thisepoch.Impact: Epoch for which the user wants to claim tokens.
indexValidation: Used to calculate the hash of the leaf; if
MerkleProofLib.verifyreturns true, theindexis valid.Impact: It is used to calculate the hash, but in fact it is redundant.
tokenIdxValidation: Used to calculate the hash of the leaf; if
MerkleProofLib.verifyreturns true, thetokenIdxis valid.Impact: The index of the token that will be claimed.
shareBbpsValidation: Used to calculate the hash of the leaf; if
MerkleProofLib.verifyreturns true, theshareBbpsis valid.Impact: The portion of
share.amounts[tokenIdx]transfererred to the caller, in basis points.
Branches and code coverage (including function calls)
Intended branches
The caller claimed funds properly.
Negative behavior
The invalid
proof.The
tokenSharesdoes not exist forepoch.The caller already claimed funds for this
epoch.The invalid
tokenIdx.The invalid
shareBbps.
Function call analysis
MerkleProofLib.verify(proof, share.merkleRoot, keccak256(abi.encodePacked(index, recipient, tokenIdx, shareBbps)External/Internal? Internal.
Argument control?
proof,index,tokenIdx, andshareBbps.Impact: Returns
trueifleafexists in the Merkle tree withrootand givenproof.
IERC20(token).safeTransfer(recipient, amount)External/Internal? External.
Argument control? N/A.
Impact: Transfers the amount of token calculated based on
shareBbpsto the caller of the function.