GNU LESSER GENERAL PUBLIC LICENSE (see https://www.gnu.org/licenses/lgpl-3.0.html)
Merkle tree redemption contract for distributing $WORK tokens. Tokens are distributed on a per-epoch basis and claimees can claim from past epochs at any time.
Based on Balancer Labs Merkle Distributor with modifications to use Hardhat/ethers.
Mumbai: 0xB3F54a4C816Be3Baae88Eb49711Dc6Eb63632F6c
Polygon: 0xd8C5C9D730f66cc42dB4b5A5E43b2e872d34424B
Ownable Merkle tree contract for making ERC-20 token distributions.
- constructor - takes the address of the token to be disbursed
constructor(address _token) public
- _disburse - transfers tokens from contract to recipient
function _disburse(address _recipient, uint _balance) private
- _claimEpoch performs verification checks, marks epoch claimed and emits Claimed event
function _claimEpoch(address _recipient, uint _epoch, uint _claimedBalance, bytes32[] memory _merkleProof) private
- claimEpoch claim tokens for the selected epoch
function claimEpoch(address _recipient, uint _epoch, uint _claimedBalance, bytes32[] memory _merkleProof) public
- claimEpochs claim tokens for multiple pochs
function claimEpochs(address _recipient, Claim[] memory claims) public
- merkleRoots returns the merkle roots for the specified range of epochs
function merkleRoots(uint _begin, uint _end) external view returns (bytes32[] memory)
- verifyClaim verifies a claim
function verifyClaim(address _recipient, uint _epoch, uint _claimedBalance, bytes32[] memory _merkleProof) public view returns (bool valid)
- newRoot uploads the merkle root if the Merkle contract holds enough tokens to cover redemptions.
function newRoot(uint _epoch, bytes32 _merkleRoot, uint _totalAllocation) external onlyOwner
- Claimed returns address, epoch and claimed balance when claim completes
- RootAdded returns address of sender, epoch number and total token allocation when new root is uploaded
The default network for all scripts is Polygon network.
npm run compile
compiles all contracts and outputs ABIs to ./abis
npm run test
runs unit tests and performs gas profiling
Deploys Merkle Redeem contract with specified $WORK token address, sets the deployer as the contract owner.
- Make a copy of
config.example.json
calledconfig.json
. - Enter the address of the $WORK token contract as
workTokenAddress
inconfig.json
. - Enter the private key for the deployer account as
privateKey
inconfig.json
. This account will be the owner of the contract. npm run compile
npm run deploy
- Make a copy of
config.example.json
calledconfig.json
. - Enter the private key for the owner account as
privateKey
inconfig.json
. - Enter the address of the MerkleRedeem contract as
merkleContractAddress
inconfig.json
. - Enter the current epoch as
epoch
inconfig.json
. - Create a file
claims/claims_[epoch].json
with the claims data in the following form whereclaimBalance
is the in the base token unit amount or wei.
[
{
address: "0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199",
claimBalance: "1111111111111"
},
...
]
npm run create
Claims the tokens for the first address in the proof data structure for the epoch specified in the config.
- Make a copy of
config.example.json
calledconfig.json
. - Enter the private key for the owner account as
privateKey
inconfig.json
. - Enter the address of the MerkleRedeem contract as
merkleContractAddress
inconfig.json
. - Enter the current epoch as
epoch
inconfig.json
. npm run claim