Skip to content

Latest commit

 

History

History
executable file
·
83 lines (65 loc) · 2.75 KB

Analysis.md

File metadata and controls

executable file
·
83 lines (65 loc) · 2.75 KB

Analysis

TokenVault.sol

Description of contract system

This contract is a vault that allows tokens of investors to be locked up for a period of time.

Functions

TokenVault

function TokenVault(
  uint _freezeEndsAt, 
  HumanStandardToken _token, 
  uint _tokensToBeAllocated)

This function instantiates the vault. It accepts a UNIX timestamp to indicate when the tokens should be unlocked. It also accepts a token contract, which indicates which token we intend to lock up. Finally, it accepts the number of tokens that we expect the vault to hold.

setInvestor

function setInvestor(
  address investor, 
  uint amount) 
  public onlyOwner

This function sets the allocation for an investor with a given amount.

lock

function lock() 
  onlyOwner

This function sets the lockedAt variable to the time that the function is called if two conditions are met. The first is that the vault should not already be locked. The second is that the balance of the vault contract (in the specified token) should equal the sum of the amounts allocated in the setInvestor function. This sum is recorded in the tokensAllocatedTotal state variable.

recoverFailedLock

function recoverFailedLock() onlyOwner

This function allows the owner of the vault to transfer all the tokens back to him if the contract was not locked properly.

getBalance

function getBalance() public constant returns (
  uint howManyTokensCurrentlyInVault)

This function returns the balance of the vault.

claim

function claim()

This function allows an investor to claim their tokens. The conditions that are checked include checking that the vault was locked, the current time is after the specified end freeze time, the balance of this investor is positive (ensuring this investor is owed tokens), and the investor has not claimed their tokens. If the conditions are met, then the tokens are transferred to the investor.

getState

function getState() public constant returns(State)

This function returns the current state of the vault. The vault is Loading if it has not been locked, Holding if it has been locked and the time is before the freeze ends, and Distributing if the current time is after the freeze period.

Library Contracts

The following contracts were used:

  • HumanStandrardToken.sol
  • StandardToken.sol
  • Token.sol
  • Ownable.sol