Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
d85be4a8
Commit
d85be4a8
authored
May 04, 2017
by
João Gabriel Carvalho
Committed by
maurelian
May 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add natspec to vestedToken.sol
parent
f6f91298
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
7 deletions
+42
-7
VestedToken.sol
contracts/token/VestedToken.sol
+42
-7
No files found.
contracts/token/VestedToken.sol
View file @
d85be4a8
...
@@ -6,8 +6,7 @@ import "./LimitedTransferToken.sol";
...
@@ -6,8 +6,7 @@ import "./LimitedTransferToken.sol";
/**
/**
* @title Vested token
* @title Vested token
* @dev This tokens can be granted to a specific address after a determined
* @dev Tokens that can be vested for a group of addresses.
amount of time.
*/
*/
contract VestedToken is StandardToken, LimitedTransferToken {
contract VestedToken is StandardToken, LimitedTransferToken {
...
@@ -25,9 +24,9 @@ contract VestedToken is StandardToken, LimitedTransferToken {
...
@@ -25,9 +24,9 @@ contract VestedToken is StandardToken, LimitedTransferToken {
* @dev Grant tokens to a specified address
* @dev Grant tokens to a specified address
* @param _to address The address which the tokens will be granted to.
* @param _to address The address which the tokens will be granted to.
* @param _value uint256 The amount of tokens to be granted.
* @param _value uint256 The amount of tokens to be granted.
* @param _start uint
64 The
time of the begining of the grant.
* @param _start uint
64 Represents
time of the begining of the grant.
* @param _cliff uint64
The time before the grant is enforceble
.
* @param _cliff uint64
Represents the cliff period
.
* @param _vesting uint64
The time in which the tokens will be veste
d.
* @param _vesting uint64
Represents the vesting perio
d.
*/
*/
function grantVestedTokens(
function grantVestedTokens(
address _to,
address _to,
...
@@ -80,16 +79,18 @@ contract VestedToken is StandardToken, LimitedTransferToken {
...
@@ -80,16 +79,18 @@ contract VestedToken is StandardToken, LimitedTransferToken {
/**
/**
* @dev Check the amount of grants that an address has.
* @dev Check the amount of grants that an address has.
* @param _holder address The holder of the grants.
* @param _holder address The holder of the grants.
* @return A uint representing the
index of the grant
.
* @return A uint representing the
total amount of grants
.
*/
*/
function tokenGrantsCount(address _holder) constant returns (uint index) {
function tokenGrantsCount(address _holder) constant returns (uint index) {
return grants[_holder].length;
return grants[_holder].length;
}
}
/**
/**
* @dev
* @dev
Get all information about a specifc grant.
* @param _holder address The address which will have its tokens revoked.
* @param _holder address The address which will have its tokens revoked.
* @param _grantId uint The id of the token grant.
* @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.
*/
*/
function tokenGrant(address _holder, uint _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting) {
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];
TokenGrant grant = grants[_holder][_grantId];
...
@@ -103,6 +104,13 @@ contract VestedToken is StandardToken, LimitedTransferToken {
...
@@ -103,6 +104,13 @@ contract VestedToken is StandardToken, LimitedTransferToken {
vested = vestedTokens(grant, uint64(now));
vested = vestedTokens(grant, uint64(now));
}
}
/**
* @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.
*/
function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return calculateVestedTokens(
return calculateVestedTokens(
grant.value,
grant.value,
...
@@ -113,6 +121,15 @@ contract VestedToken is StandardToken, LimitedTransferToken {
...
@@ -113,6 +121,15 @@ contract VestedToken is StandardToken, LimitedTransferToken {
);
);
}
}
/**
* @dev Calculate amount of vested tokens at a specifc time.
* @param tokens uint256 The amount of tokens grantted.
* @param time uint64 The time to be checked
* @param start uint64 A time representing the begining of the grant
* @param _cliff uint64 Represents the cliff period.
* @param _vesting uint64 Represents the vesting period.
* @return An uint representing the amount of vested tokensof a specif grant.
*/
function calculateVestedTokens(
function calculateVestedTokens(
uint256 tokens,
uint256 tokens,
uint256 time,
uint256 time,
...
@@ -136,10 +153,22 @@ contract VestedToken is StandardToken, LimitedTransferToken {
...
@@ -136,10 +153,22 @@ contract VestedToken is StandardToken, LimitedTransferToken {
vestedTokens = vestedTokens.add(vestingTokens.mul(time.sub(cliff)).div(vesting.sub(cliff)));
vestedTokens = vestedTokens.add(vestingTokens.mul(time.sub(cliff)).div(vesting.sub(cliff)));
}
}
/**
* @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) {
function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return grant.value.sub(vestedTokens(grant, time));
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.
*/
function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) {
function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) {
date = uint64(now);
date = uint64(now);
uint256 grantIndex = grants[holder].length;
uint256 grantIndex = grants[holder].length;
...
@@ -148,6 +177,12 @@ contract VestedToken is StandardToken, LimitedTransferToken {
...
@@ -148,6 +177,12 @@ 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.
*/
function transferableTokens(address holder, uint64 time) constant public returns (uint256 nonVested) {
function transferableTokens(address holder, uint64 time) constant public returns (uint256 nonVested) {
uint256 grantIndex = grants[holder].length;
uint256 grantIndex = grants[holder].length;
for (uint256 i = 0; i < grantIndex; i++) {
for (uint256 i = 0; i < grantIndex; i++) {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment