TokenDistributor
Inherits: Authorizable, ITokenDistributor
This contract allows users to claim tokens from a merkle tree proof
State Variables
token
Address of the ERC20 token to be distributed
IProtocolToken public token;
root
The merkle root of the token distribution
bytes32 public root;
totalClaimable
Total amount of tokens to be distributed
uint256 public totalClaimable;
claimPeriodStart
Timestamp when the claim period starts
uint256 public claimPeriodStart;
claimPeriodEnd
Timestamp when the claim period ends
uint256 public claimPeriodEnd;
claimed
Mapping containing the users that have already claimed
mapping(address _user => bool _hasClaimed) public claimed;
Functions
constructor
constructor(address _token, TokenDistributorParams memory _tokenDistributorParams) Authorizable(msg.sender);
Parameters
Name | Type | Description |
---|---|---|
_token | address | Address of the ERC20 token to be distributed |
_tokenDistributorParams | TokenDistributorParams | TokenDistributor valid parameters struct |
canClaim
Checks if a user can claim tokens
function canClaim(bytes32[] calldata _proof, address _user, uint256 _amount) external view returns (bool _claimable);
Parameters
Name | Type | Description |
---|---|---|
_proof | bytes32[] | Array of bytes32 merkle proof hashes |
_user | address | Address of the user to check |
_amount | uint256 | Amount of tokens to check |
Returns
Name | Type | Description |
---|---|---|
_claimable | bool | Whether the user can claim the amount with the proof provided |
claim
Claims tokens from the distributor
function claim(bytes32[] calldata _proof, uint256 _amount) external;
Parameters
Name | Type | Description |
---|---|---|
_proof | bytes32[] | Array of bytes32 merkle proof hashes |
_amount | uint256 | Amount of tokens to claim |
claimAndDelegate
Claims tokens from the distributor and delegates them using a signature
function claimAndDelegate(
bytes32[] calldata _proof,
uint256 _amount,
address _delegatee,
uint256 _expiry,
uint8 _v,
bytes32 _r,
bytes32 _s
) external;
Parameters
Name | Type | Description |
---|---|---|
_proof | bytes32[] | Array of bytes32 merkle proof hashes |
_amount | uint256 | Amount of tokens to claim |
_delegatee | address | Address to delegate the token votes to |
_expiry | uint256 | Expiration timestamp of the signature |
_v | uint8 | Recovery byte of the signature |
_r | bytes32 | ECDSA signature r value |
_s | bytes32 | ECDSA signature s value |
sweep
Withdraws tokens from the distributor to a given address after the claim period has ended
function sweep(address _sweepReceiver) external override isAuthorized;
Parameters
Name | Type | Description |
---|---|---|
_sweepReceiver | address | Address to send the tokens to |
_canClaim
function _canClaim(bytes32[] calldata _proof, address _user, uint256 _amount) internal view returns (bool _claimable);
_claim
function _claim(bytes32[] calldata _proof, uint256 _amount) internal;