Function: claim(address user, uint256 tokenAmount, byte[32][] merkleProof)
This function is used to claim tokens and ETH for a user. It is only callable by the user themselves if selfClaim is true; otherwise, it is only callable by the owner.
Inputs
userControl: Arbitrary address.
Constraints: Must be
msg.senderifselfClaimis true and must be in the Merkle tree.Impact: Address of the user to claim for.
tokenAmountControl: Arbitrary
uint256.Constraints: Must be in the Merkle tree.
Impact: Amount of tokens to claim.
merkleProofControl: Arbitrary
bytes32[].Constraints: Must be a valid Merkle proof for the user and token amount.
Impact: Merkle proof for verification.
Branches and code coverage
Intended branches
Invoke
MerkleProof.verifyto verify the Merkle proof.Update the claim record.
Transfer ERC-20 tokens.
Transfer ETH.
Emit the
Claimedevent.
Negative behavior
Revert if claiming is paused.
Revert if the caller is not the user themselves, when
selfClaimis true.Revert if the user has already claimed.
Revert if the Merkle proof is invalid.
Revert if the token amount is zero and the ETH amount per user is zero.
Revert if the token balance is insufficient.
Revert if the ETH balance is insufficient.