|
@@ -5,9 +5,9 @@ import "./StandardToken.sol";
|
|
|
import "./LimitedTransferToken.sol";
|
|
|
|
|
|
/**
|
|
|
-* @title Vested token
|
|
|
-* @dev Tokens that can be vested for a group of addresses.
|
|
|
-*/
|
|
|
+ * @title Vested token
|
|
|
+ * @dev Tokens that can be vested for a group of addresses.
|
|
|
+ */
|
|
|
contract VestedToken is StandardToken, LimitedTransferToken {
|
|
|
|
|
|
struct TokenGrant {
|
|
@@ -21,13 +21,13 @@ contract VestedToken is StandardToken, LimitedTransferToken {
|
|
|
mapping (address => TokenGrant[]) public grants;
|
|
|
|
|
|
/**
|
|
|
- * @dev Grant tokens to a specified address
|
|
|
- * @param _to address The address which the tokens will be granted to.
|
|
|
- * @param _value uint256 The amount of tokens to be granted.
|
|
|
- * @param _start uint64 Represents time of the begining of the grant.
|
|
|
- * @param _cliff uint64 Represents the cliff period.
|
|
|
- * @param _vesting uint64 Represents the vesting period.
|
|
|
- */
|
|
|
+ * @dev Grant tokens to a specified address
|
|
|
+ * @param _to address The address which the tokens will be granted to.
|
|
|
+ * @param _value uint256 The amount of tokens to be granted.
|
|
|
+ * @param _start uint64 Represents time of the begining of the grant.
|
|
|
+ * @param _cliff uint64 Represents the cliff period.
|
|
|
+ * @param _vesting uint64 Represents the vesting period.
|
|
|
+ */
|
|
|
function grantVestedTokens(
|
|
|
address _to,
|
|
|
uint256 _value,
|
|
@@ -53,11 +53,11 @@ contract VestedToken is StandardToken, LimitedTransferToken {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * @dev Revoke the grant of tokens of a specifed address.
|
|
|
- * @param _holder address The address which will have its tokens revoked.
|
|
|
- * @param _grantId uint The id of the token grant.
|
|
|
- */
|
|
|
+ /**
|
|
|
+ * @dev Revoke the grant of tokens of a specifed address.
|
|
|
+ * @param _holder The address which will have its tokens revoked.
|
|
|
+ * @param _grantId The id of the token grant.
|
|
|
+ */
|
|
|
function revokeTokenGrant(address _holder, uint _grantId) {
|
|
|
TokenGrant grant = grants[_holder][_grantId];
|
|
|
|
|
@@ -76,22 +76,22 @@ contract VestedToken is StandardToken, LimitedTransferToken {
|
|
|
Transfer(_holder, msg.sender, nonVested);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @dev Check the amount of grants that an address has.
|
|
|
- * @param _holder address The holder of the grants.
|
|
|
- * @return A uint representing the total amount of grants.
|
|
|
- */
|
|
|
+ /**
|
|
|
+ * @dev Check the amount of grants that an address has.
|
|
|
+ * @param _holder The holder of the grants.
|
|
|
+ * @return A uint representing the total amount of grants.
|
|
|
+ */
|
|
|
function tokenGrantsCount(address _holder) constant returns (uint index) {
|
|
|
return grants[_holder].length;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @dev Get all information about a specifc grant.
|
|
|
- * @param _holder address The address which will have its tokens revoked.
|
|
|
- * @param _grantId uint The id of the token grant.
|
|
|
- * @return Returns all the values that represent a TokenGrant(address, value,
|
|
|
- start, cliff and vesting) plus the vested value at the current time.
|
|
|
- */
|
|
|
+ * @dev Get all information about a specifc grant.
|
|
|
+ * @param _holder The address which will have its tokens revoked.
|
|
|
+ * @param _grantId The id of the token grant.
|
|
|
+ * @return Returns all the values that represent a TokenGrant(address, value, start, cliff
|
|
|
+ * and vesting) plus the vested value at the current time.
|
|
|
+ */
|
|
|
function tokenGrant(address _holder, uint _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting) {
|
|
|
TokenGrant grant = grants[_holder][_grantId];
|
|
|
|
|
@@ -105,12 +105,11 @@ contract VestedToken is StandardToken, LimitedTransferToken {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @dev Get the amount of vested tokens at a specifc time.
|
|
|
- * @param grant TokenGrant The grant to be checked.
|
|
|
- * @param time uint64 The time to be checked
|
|
|
- * @return An uint representing the amount of vested tokens of a specifc grant
|
|
|
- on specifc time.
|
|
|
- */
|
|
|
+ * @dev Get the amount of vested tokens at a specific time.
|
|
|
+ * @param grant TokenGrant The grant to be checked.
|
|
|
+ * @param time The time to be checked
|
|
|
+ * @return An uint representing the amount of vested tokens of a specific grant at a specific time.
|
|
|
+ */
|
|
|
function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
|
|
|
return calculateVestedTokens(
|
|
|
grant.value,
|
|
@@ -154,21 +153,21 @@ contract VestedToken is StandardToken, LimitedTransferToken {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @dev Calculate the amount of non vested tokens at a specific time.
|
|
|
- * @param grant TokenGrant The grant to be checked.
|
|
|
- * @param time uint64 The time to be checked
|
|
|
- * @return An uint representing the amount of non vested tokens of a specifc grant
|
|
|
- on the passed time frame.
|
|
|
- */
|
|
|
+ * @dev Calculate the amount of non vested tokens at a specific time.
|
|
|
+ * @param grant TokenGrant The grant to be checked.
|
|
|
+ * @param time uint64 The time to be checked
|
|
|
+ * @return An uint representing the amount of non vested tokens of a specifc grant on the
|
|
|
+ * passed time frame.
|
|
|
+ */
|
|
|
function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
|
|
|
return grant.value.sub(vestedTokens(grant, time));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @dev Calculate the date when the holder can trasfer all its tokens
|
|
|
- * @param holder address The address of the holder
|
|
|
- * @return An uint representing the date of the last transferable tokens.
|
|
|
- */
|
|
|
+ * @dev Calculate the date when the holder can trasfer all its tokens
|
|
|
+ * @param holder address The address of the holder
|
|
|
+ * @return An uint representing the date of the last transferable tokens.
|
|
|
+ */
|
|
|
function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) {
|
|
|
date = uint64(now);
|
|
|
uint256 grantIndex = grants[holder].length;
|
|
@@ -178,11 +177,11 @@ contract VestedToken is StandardToken, LimitedTransferToken {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @dev Calculate the total amount of transferable tokens of a holder at a given time
|
|
|
- * @param holder address The address of the holder
|
|
|
- * @param time uint64 The specific time.
|
|
|
- * @return An uint representing a holder's total amount of transferable tokens.
|
|
|
- */
|
|
|
+ * @dev Calculate the total amount of transferable tokens of a holder at a given time
|
|
|
+ * @param holder address The address of the holder
|
|
|
+ * @param time uint64 The specific time.
|
|
|
+ * @return An uint representing a holder's total amount of transferable tokens.
|
|
|
+ */
|
|
|
function transferableTokens(address holder, uint64 time) constant public returns (uint256 nonVested) {
|
|
|
uint256 grantIndex = grants[holder].length;
|
|
|
for (uint256 i = 0; i < grantIndex; i++) {
|