Skip to content

krakovia-evm/VyperVestedClaims

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vested Claims Contract

Overview

This smart contract is designed for distributing tokens with a vesting schedule where:

  • 31% of tokens are released at the Token Generation Event (TGE).
  • 69% of tokens are released linearly over time.

Contract Features:

  • Merkle Tree: Utilizes a Merkle tree for efficient and secure distribution of token allocations.
  • Vesting Schedule: Tokens are vested from vesting_start_time to vesting_end_time.
  • Claim Functionality: Allows users to claim their vested tokens based on proof provided in the Merkle tree.

Installation & Usage

  • Deploy: Deploy the contract with necessary parameters like Merkle root, token address, and vesting times.
  • Claim: Users can claim tokens by providing a Merkle proof of their allocation.

Contract Functions

Initialization & Management

  • __init__(merkle_root, token, vesting_start_time, vesting_end_time): Sets up the contract with initial parameters.

Utility Functions

  • _hash_pair(a, b): Helper function to hash two bytes32 values.
  • _verify_proof(proof, leaf): Verifies a Merkle proof against the root.
  • verify_proof(user, amount, proof): Public-facing function to verify proof for a user's claim.

Token Distribution

  • claim(user, total_amount, proof): Allows users or anyone on behalf of users to claim vested tokens.

Auxiliary Functions

  • set_merkle_root(merkle_root): Updates the Merkle root (only callable by owner).
  • rescue_tokens(to, amount): Emergency function to rescue tokens (only callable by owner).

View Functions

  • _calculate_vested_amount(total_amount): Calculates how much of the total allocation is vested based on current time.
  • claimable_amount(user, total_amount): Calculates claimable amount for a user without proof verification.

Important Notes

  • View Function Warning:
    • Do not use the claimable_amount function in on-chain logic as it does not verify the user's proof against the Merkle root. This function is meant for frontend UI to display possible claimable amounts but should not influence contract behavior directly.

Security Considerations

  • Owner Privileges: Functions like set_merkle_root and rescue_tokens can only be called by the contract owner.
  • Merkle Proof: Any claim must be accompanied by a valid Merkle proof to ensure only authorized users can claim tokens.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published