@@ -21,44 +21,93 @@ contract TokenVesting is Ownable {
2121 event Revoked ();
2222
2323 // beneficiary of tokens after they are released
24- address public beneficiary ;
24+ address private beneficiary_ ;
2525
26- uint256 public cliff ;
27- uint256 public start ;
28- uint256 public duration ;
26+ uint256 private cliff_ ;
27+ uint256 private start_ ;
28+ uint256 private duration_ ;
2929
30- bool public revocable ;
30+ bool private revocable_ ;
3131
32- mapping (address => uint256 ) public released ;
33- mapping (address => bool ) public revoked ;
32+ mapping (address => uint256 ) private released_ ;
33+ mapping (address => bool ) private revoked_ ;
3434
3535 /**
3636 * @dev Creates a vesting contract that vests its balance of any ERC20 token to the
3737 * _beneficiary, gradually in a linear fashion until _start + _duration. By then all
3838 * of the balance will have vested.
3939 * @param _beneficiary address of the beneficiary to whom vested tokens are transferred
40- * @param _cliff duration in seconds of the cliff in which tokens will begin to vest
40+ * @param _cliffDuration duration in seconds of the cliff in which tokens will begin to vest
4141 * @param _start the time (as Unix time) at which point vesting starts
4242 * @param _duration duration in seconds of the period in which the tokens will vest
4343 * @param _revocable whether the vesting is revocable or not
4444 */
4545 constructor (
4646 address _beneficiary ,
4747 uint256 _start ,
48- uint256 _cliff ,
48+ uint256 _cliffDuration ,
4949 uint256 _duration ,
5050 bool _revocable
5151 )
5252 public
5353 {
5454 require (_beneficiary != address (0 ));
55- require (_cliff <= _duration);
55+ require (_cliffDuration <= _duration);
5656
57- beneficiary = _beneficiary;
58- revocable = _revocable;
59- duration = _duration;
60- cliff = _start.add (_cliff);
61- start = _start;
57+ beneficiary_ = _beneficiary;
58+ revocable_ = _revocable;
59+ duration_ = _duration;
60+ cliff_ = _start.add (_cliffDuration);
61+ start_ = _start;
62+ }
63+
64+ /**
65+ * @return the beneficiary of the tokens.
66+ */
67+ function beneficiary () public view returns (address ) {
68+ return beneficiary_;
69+ }
70+
71+ /**
72+ * @return the cliff time of the token vesting.
73+ */
74+ function cliff () public view returns (uint256 ) {
75+ return cliff_;
76+ }
77+
78+ /**
79+ * @return the start time of the token vesting.
80+ */
81+ function start () public view returns (uint256 ) {
82+ return start_;
83+ }
84+
85+ /**
86+ * @return the duration of the token vesting.
87+ */
88+ function duration () public view returns (uint256 ) {
89+ return duration_;
90+ }
91+
92+ /**
93+ * @return true if the vesting is revocable.
94+ */
95+ function revocable () public view returns (bool ) {
96+ return revocable_;
97+ }
98+
99+ /**
100+ * @return the amount of the token released.
101+ */
102+ function released (address _token ) public view returns (uint256 ) {
103+ return released_[_token];
104+ }
105+
106+ /**
107+ * @return true if the token is revoked.
108+ */
109+ function revoked (address _token ) public view returns (bool ) {
110+ return revoked_[_token];
62111 }
63112
64113 /**
@@ -70,9 +119,9 @@ contract TokenVesting is Ownable {
70119
71120 require (unreleased > 0 );
72121
73- released [_token] = released [_token].add (unreleased);
122+ released_ [_token] = released_ [_token].add (unreleased);
74123
75- _token.safeTransfer (beneficiary , unreleased);
124+ _token.safeTransfer (beneficiary_ , unreleased);
76125
77126 emit Released (unreleased);
78127 }
@@ -83,15 +132,15 @@ contract TokenVesting is Ownable {
83132 * @param _token ERC20 token which is being vested
84133 */
85134 function revoke (IERC20 _token ) public onlyOwner {
86- require (revocable );
87- require (! revoked [_token]);
135+ require (revocable_ );
136+ require (! revoked_ [_token]);
88137
89138 uint256 balance = _token.balanceOf (address (this ));
90139
91140 uint256 unreleased = releasableAmount (_token);
92141 uint256 refund = balance.sub (unreleased);
93142
94- revoked [_token] = true ;
143+ revoked_ [_token] = true ;
95144
96145 _token.safeTransfer (owner (), refund);
97146
@@ -103,7 +152,7 @@ contract TokenVesting is Ownable {
103152 * @param _token ERC20 token which is being vested
104153 */
105154 function releasableAmount (IERC20 _token ) public view returns (uint256 ) {
106- return vestedAmount (_token).sub (released [_token]);
155+ return vestedAmount (_token).sub (released_ [_token]);
107156 }
108157
109158 /**
@@ -112,14 +161,14 @@ contract TokenVesting is Ownable {
112161 */
113162 function vestedAmount (IERC20 _token ) public view returns (uint256 ) {
114163 uint256 currentBalance = _token.balanceOf (this );
115- uint256 totalBalance = currentBalance.add (released [_token]);
164+ uint256 totalBalance = currentBalance.add (released_ [_token]);
116165
117- if (block .timestamp < cliff ) {
166+ if (block .timestamp < cliff_ ) {
118167 return 0 ;
119- } else if (block .timestamp >= start .add (duration ) || revoked [_token]) {
168+ } else if (block .timestamp >= start_ .add (duration_ ) || revoked_ [_token]) {
120169 return totalBalance;
121170 } else {
122- return totalBalance.mul (block .timestamp .sub (start )).div (duration );
171+ return totalBalance.mul (block .timestamp .sub (start_ )).div (duration_ );
123172 }
124173 }
125174}
0 commit comments