A Cumulative Merkle Distributor for Airdrop

Penguin Finance
3 min readMar 1, 2022

--

When conducting an airdrop to a large number of users, the typical approach is to store users’ wallet addresses in a program, and claims are initiated by the users. This approach, however, will generate massive storage costs, called “rent” in Solana, when there are numerous wallet addresses to be stored.

At present, the open-source Merkle Distributor of Saber is widely used in Solana. The principle is to generate a Merkle Root for all the wallet addresses and store them in a program, which requires Merkle proof when users initiate claims.

Meanwhile, this scheme can be operationally cumbersome because users can only claim one reward at a time and cannot execute in batches when in a scenario where users are airdropped multiple times coupled with repeated wallet addresses for each airdrop. In addition, each operation can generate an exorbitant rent cost which makes airdrops less attractive to users.

Improved Scheme

Saber’s airdrop scheme will generate a new Merkle Tree for the wallet addresses and quantities airdropped each day, and create a corresponding distributor instance in the program. Each wallet address has a corresponding ‘claim status’ that shows whether the reward has been claimed, and this status is associated with a sole distributor instance.

Saber Merkle Distributor for Airdrops

The improved airdrop scheme shares the same step as the original one on the first airdrop. They both generate a Merkle Tree for all the wallet addresses and quantities and create a corresponding distributor instance in the program with this Merkle Root. When generating a Merkle Tree at the second round of airdrop, the amount corresponding to the wallet address needs to be accumulated.

For example, wallet A receives 100 tokens on day one, and it receives further 200 tokens on day two, so a total amount of 300 tokens should be displayed in wallet A on day two. The newly generated Merkle Tree does not create a fresh distributor instance but renews the Merkle Root generated in the first airdrop.

Png Merkle Distributor

Besides, Saber’s ‘claim_status’ are recorded with Boolean, which tells whether an airdrop reward has been claimed. This ‘claim_status’, in the improved scheme, is replaced by ‘claimed_amount’ which marks the amount of reward claimed by a wallet address. Accordingly, the amount a user can claim for each time is the amount in the current Merkle Tree minus the amount claimed, that is:

claim_amount = amount_in_merkle_tree - claim_status.claimed_amount

This scheme, which allows users to claim rewards in a batch after multiple airdrops, eradicates the cumbersome operations and high fees with one move.

Once again, this scheme applies to the scenario where multiple airdrops are needed and there are repeated wallet addresses for each airdrop.

Github:

Team

Penguin Finance Website|Twitter

Bunny Ducky Website| Twitter

--

--

Penguin Finance
Penguin Finance

Written by Penguin Finance

Penguin Finance is a liquidity management protocol for projects built on Solana.

No responses yet