Giter VIP home page Giter VIP logo

binodnp / vesting-schedule Goto Github PK

View Code? Open in Web Editor NEW
12.0 4.0 2.0 577 KB

An easy to use ERC20 vesting schedule for founders, employees, and advisors.

Home Page: https://www.linkedin.com/in/binodnirvan/

License: Apache License 2.0

Batchfile 0.09% Shell 0.29% JavaScript 58.37% Solidity 41.24%
solidity solidity-contracts vesting vesting-schedule erc20 ethereum blockchain smart-contracts

vesting-schedule's Introduction

Vesting Schedule

An easy to use ERC20 vesting schedule for founders, employees, and advisors.

How to Install?

Install Truffle Tools

https://truffleframework.com

Clone the Repository

https://github.com/binodnp/vesting-schedule

Install Packages

npm install

Running Tests

Start Local RPC Client

ganache-cli --acounts 15

Run Tests

truffle test

Documentation


Types & Enumerators

Allocation Struct

///@notice Token allocation structure for vesting schedule.
struct Allocation {
    string  memberName;
    uint256 startedOn;
    uint256 releaseOn;
    uint256 allocation;
    uint256 closingBalance;
    bool deleted;
    uint256 withdrawn;
    uint256 lastWithdrawnOn;
}
Name Type Description
memberName string The full name of the beneficiary.
startedOn uint256 The timestamp of the allocation start.
releaseOn uint256 The timestamp on which the first withdrawal becomes avaiable.
allocation uint256 The total amount allocated to this member.
closingBalance uint256 The remaining balance of the vesting schedule allocation.
deleted bool Indicates that the vesting schedule allocation was deleted.
withdrawn uint256 The total amount withdrawn from the allocation.
lastWithdrawnOn uint256 The timestamp of the latest withdrawal.

Withdrawal Frequency Enum

The supported withdrawal frequencies are:

  • Daily (1 day)
  • Weekly (7 days)
  • Half Monthly (15 days)
  • Monthly (30 days)
  • Quarterly (91 days)
  • Half Yearly (182 days)

Features

Funding (ERC20 Vesting Token)

fund

Enables this vesting schedule contract to receive the ERC20 (vesting coin) token. Please note that this action can only be performed by an administrator.

Before calling this function, please approve your desired amount of the coin for this smart contract address to transferFrom.

function fund() external onlyAdmin returns(bool)

removeFunds

Allows you to withdraw the surplus balance of the vesting coin from this contract. Please note that this action is restricted to administrators only and you may only withdraw amounts above the sum total allocation balances. In other words, you cannot withdraw the token amount held by this contract on behalf of the beneficiaries.

function removeFunds(uint256 _amount) external onlyAdmin returns(bool)
Name Type Description
_amount uint256 The amount desired to withdraw.

Allocations

createAllocation

Creates a vesting schedule allocation for a new beneficiary. A beneficiary could mean founders, employees,or advisors. Please note that this action can only be performed by an administrator.

function createAllocation(address _address, string _memberName, uint256 _amount, uint256 _releaseOn) external onlyAdmin returns(bool)
Name Type Description
_address address The address which will receive the tokens in the future date.
_memberName string The name of the candidate for which this vesting schedule allocation is being created for.
_amount uint256 The total amount of tokens being vested over the period of vesting duration.
_releaseOn uint256 The date on which the first schedule becomes available for withdrawal.

deleteAllocation

Deletes the specified vesting schedule allocation. Please note that this action can only be performed by an administrator.

function deleteAllocation(address _address) external onlyAdmin returns(bool)
Name Type Description
_address address The address of the beneficiary whose allocation is being requested to be deleted.

increaseAllocation

Increases the total allocation of the specified vesting schedule. Please note that this action can only be performed by an administrator.

function increaseAllocation(address _address, uint256 _additionalAmount) external onlyAdmin returns(bool)
Name Type Description
_address address The address of the beneficiary whose allocation is being requested to be increased.
_additionalAmount uint256 The additional amount in vesting coin to be addeded to the existing allocation

decreaseAllocation

Decreases the total allocation of the specified vesting schedule. Please note that this action can only be performed by an administrator.

function decreaseAllocation(address _address, uint256 _lessAmount) external onlyAdmin returns(bool)
Name Type Description
_address address The address of the beneficiary whose allocation is being requested to be decreased.
_lessAmount uint256 The amount in vesting coin to be decreased from the existing allocation.

extendAllocation

Extends the release date of the specified vesting schedule allocation. Please note that this action can only be performed by an administrator.

function extendAllocation(address _address, uint256 _newReleaseDate) external onlyAdmin returns(bool)
Name Type Description
_address address The address of the beneficiary who allocation is being requested to be extended.
_newReleaseDate uint256 A new release date to extend the allocation to.

Withdrawals

withdraw

This action enables the beneficiaries (founders, employees, consultants, or advisors) to withdraw a desired amount from this contract. Please note that withdrawals cannot be performed when the contract is paused.

function withdraw(uint256 _amount) external canWithdraw(_amount) afterEarliestWithdrawalDate whenNotPaused returns(bool)
Name Type Description
_amount uint256 The amount desired to be withdrawn by the caller.

vesting-schedule's People

Contributors

binodnp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.