TokenDistributor

Git Source

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

NameTypeDescription
_tokenaddressAddress of the ERC20 token to be distributed
_tokenDistributorParamsTokenDistributorParamsTokenDistributor 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

NameTypeDescription
_proofbytes32[]Array of bytes32 merkle proof hashes
_useraddressAddress of the user to check
_amountuint256Amount of tokens to check

Returns

NameTypeDescription
_claimableboolWhether 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

NameTypeDescription
_proofbytes32[]Array of bytes32 merkle proof hashes
_amountuint256Amount 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

NameTypeDescription
_proofbytes32[]Array of bytes32 merkle proof hashes
_amountuint256Amount of tokens to claim
_delegateeaddressAddress to delegate the token votes to
_expiryuint256Expiration timestamp of the signature
_vuint8Recovery byte of the signature
_rbytes32ECDSA signature r value
_sbytes32ECDSA 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

NameTypeDescription
_sweepReceiveraddressAddress 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;