Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

merkle-distributor

Crates.io License Build Status Contributors

A program for distributing tokens efficiently via uploading a Merkle root.

This program is largely based off of Uniswap's Merkle Distributor.

Rationale

Although Solana has low fees for executing transactions, it requires staking tokens to pay for storage costs, also known as "rent". These rent costs can add up when sending tokens to thousands or tens of thousands of wallets, making it economically unreasonable to distribute tokens to everyone.

The Merkle distributor, pioneered by Uniswap, solves this issue by deriving a 256-bit "root hash" from a tree of balances. This puts the gas cost on the claimer. Solana has the additional advantage of being able to reclaim rent from closed token accounts, so the net cost to the user should be around 0.000010 SOL (at the time of writing).

The Merkle distributor is also significantly easier to manage from an operations perspective, since one does not need to send a transaction to each individual address that may be redeeming tokens.

License

The Merkle distributor program and SDK is distributed under the GPL v3.0 license.

Functionality

Main logic based on gito distribution source code but modified tio support extra logic. https://github.com/jito-foundation/distributor

  • Admin executes new_distributor instruction to set all settings for vesting contract.

  • User call claim_locked instruction to create PDA that will hold they unlocked/locked amount

  • User claims all unlocked tokens from start of this vesting program and only able to get rest if stake tokens in staking contract. For example (at the begining user claimed 10 Mantis tokens. to get the rest he need to stake 10 Mantis for X period of time to be capable to claim the rest. If user stake only 3 tokens for X duration he would be able to claim only 30% of tokens after X duration time.)

  • When user call stake/unstake on staking(not vesting) contract side it executes CPI update_stake request. So vesting contract recieves updates about stake/unstake actions and update PDAs of correspoding staker to store and use during claim_locked instruction to calculate what % of locked tokens should be unlocked already and then transfer to claimant account.

  • Admin is able to set a new admin account, clawback all tokens that left after clawback_time expired, set_clawback_receiver to update the clawback_receiver address.

  • Vesting Distributor ATA containing the tokens to distribute. Any of vesting PDA's does not receive or hold tokens related to staking feature(contract).