audius-claim-distribution
audius-claim-distribution copied to clipboard
Audius Claim Distribution
This repo contains the contract to do token claim distribution for a set of users by precomputing the merkle root hash, indices and proofs for all users before loading that hash on chain.
How to use
There are two pieces of information that the migrations depend on and both are set in contract-config.js, the tokenAddress and merkleRoot. tokenAddress is the address for the ERC-20 Audius token and the merkleRoot instructions are given below.
Generating the merkle root and the JSON file
This Uniswap repo (https://github.com/Uniswap/merkle-distributor) contains the contract that we vendored in this repo. It also contains scripts to convert a json array of [{ "address": <address>, "earnings": <integer wei amount>, "reasons": '' }] into the merkle object. In order to generate that object:
- In the scripts/ folder run
python csv_to_json.pyto convert our csv with columnswalletandtokensto a uniswap script compatible[{ "address": <address>, "earnings": <integer wei amount>, "reasons": '' }]array. - In the
merkle-distributorrepo under scripts/ runtscto generate the node.js files. - Run
node generate-merkle-root.js -i allocation_output.json >> allocation_merkle_output.jsonto get the merkle object - Run
node verify-merkle-root.js -i allocation_merkle_output.jsonagainst the output merkle json object to verify it's validity. - Once the validation passes, the object is finalized and the merkle root hash can be used
Mainnet artifacts
All data for claim distribution on mainnet is in ./mainnet-artifacts/
dataset-query.sql- this query was run against an Audius discovery provider to generate the user token claim data set, stored atclaim-dataset.csv. It can be reproced against any discovery provider that has indexed up to blocknumber of17782488against POA mainnet. This blocknumber is visible in the dataset asmax_blocknumber.merkle-input.json- contains a JSON-formatted array of { "address", "earnings", "reasons" } entries. Generated from step 1 above:python scripts/csv_to_json.py ./mainnet-artifacts/claim-dataset.csv ./mainnet-artifacts/merkle-input.jsonmerkle-output.json- contains the full merkle tree, including its root hash. This hash is used in theAudiusClaimDistributorcontract constructor. Generated from step 3 above -node scripts/generate-merkle-root.js -i ./mainnet-artifacts/merkle-input.json >> ./mainnet-artifacts/merkle-output.json
Shoutout
Thanks to the Uniswap team for open-sourcing this scalable mechanic!