Skip to main content

Distributor

Command

yarn start dw uc distributor [arguments] [-options]
# or
yarn start dw uc d [arguments] [-options]

Distributor commands list

yarn start dw uc d -h

Overview

The Distributor commands are used to manage the distribution of side tokens via a Merkle Tree. This allows for efficient and secure distribution of rewards to a large number of recipients.

API

CommandDescription
read (r)read commands
write (w)write commands

Read

CommandDescription
stateshow current distributor state

Write

CommandDescription
add-tokenadd a new token to distribute
set-merkle-rootupdates merkle root and CID on the distributor contract
distributegenerates and optionally uploads new distribution data

Command Details

state

Displays a comprehensive overview of the Distributor contract's current state, including roles, configuration, and token balances.

Arguments:

  • <pool address>: The contract address of the pool.

Information Displayed:

  • Distributor Address: The address of the Distributor contract.
  • Pool Address: The address of the associated pool contract.
  • Admins: The count and list of addresses with the DEFAULT_ADMIN_ROLE.
  • Managers: The count and list of addresses with the MANAGER_ROLE.
  • Tokens Supported: The count and list of supported reward tokens. For each token, it shows:
    • Token Address
    • Name and Symbol
    • Current balance in the distributor contract (formatted and in wei)
    • Decimals
  • CID: The IPFS Content ID of the current distribution data.
  • Merkle Root: The current Merkle root.
  • Last Processed Block: The block number up to which rewards have been calculated.

Example:

# Get the full state of the distributor for a given pool
yarn start dw uc d r state 0x...

Use Case: To get a complete and detailed picture of the distributor's configuration, permissions, and current token holdings. This is useful for auditing and debugging.

add-token

Adds a new ERC20 token to the list of tokens that can be distributed. This is a privileged operation.

Arguments:

  • <pool address>: The contract address of the pool.
  • <token address>: The contract address of the ERC20 token to add.

Example:

# Add a new token to the distributor
yarn start dw uc d w add-token 0x... 0x...

Use Case: To enable rewards distribution for a new type of token.

set-merkle-root

Updates the Merkle root and associated IPFS CID on the Distributor contract. This is a privileged operation that points the contract to a new set of distribution data.

Arguments:

  • <pool address>: The contract address of the pool.
  • <merkle root>: The new Merkle root hash.
  • <cid>: The IPFS Content ID (CID) of the file containing the distribution data.

Example:

# Update the merkle root and CID
yarn start dw uc d w set-merkle-root 0x... 0x... Qm...

Use Case: To activate a new rewards distribution after the distribution data has been generated and uploaded to IPFS.

distribute

Generates a new rewards distribution based on pool shares, and provides options to automate the entire process from data generation to on-chain updates.

Arguments:

  • <pool address>: The contract address of the pool.
  • <tokens...>: A list of token addresses and the total amount to be distributed for each, e.g., 0xtoken1... 1000 0xtoken2... 500.5.

Options:

OptionDescriptionDefault
--blacklist [addresses...]A list of addresses to exclude from the distribution.[]
--from-block [block]The starting block for calculating pool share balances.undefined
--to-block [block]The ending block for calculating pool share balances.undefined
--max-batch-size [size]The maximum number of blocks to fetch events for in a single batch.50000
--output-path [path]The local file path to save the generated distribution data../distribution-[merkle-root].json
--skip-writeIf set, the distribution data will not be written to a local file.false
--skip-transferIf set, the command will not attempt to transfer the reward tokens to the distributor contract.false
--ipfs-gateway [gateway]A custom IPFS gateway to fetch previous distribution data from.undefined
--upload [pinningUrl]A URL for a pinning service to upload the distribution data to.false
--skip-set-rootIf set, the new Merkle root will not be set on the distributor contract.false

Example:

# Generate a new distribution for two tokens, upload it to a pinning service, and update the contract
yarn start dw uc d w distribute 0x... 0xtoken1... 1000 0xtoken2... 500.5 --upload https://my-pinning-service.com/

Use Case: To perform a complete rewards distribution run. This command can calculate rewards, generate the necessary data, upload it to IPFS, and update the smart contract all in one go, making it a powerful tool for automating rewards distribution.