@@ -7,7 +7,21 @@ import "../token/T.sol";
77
88import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol " ;
99
10+ /// @title Token Grant
11+ /// @notice Token Grant releases its token balance gradually to the grantee
12+ /// based on the vesting schedule with a cliff and vesting period.
13+ /// Can be revoked by grant creator. Allows to stake granted tokens
14+ /// according to the provided staking policy.
1015contract TokenGrant {
16+ // TODO Not implemented yet:
17+ // TODO - TokenGrantFactory, master clone factory TokenGrant contract
18+ // TODO initialization prevention.
19+ // TODO - Staking, including checking the policy, allowed staking
20+ // TODO contracts, and calling the staking contract.
21+ // TODO - Grant revoke functionality.
22+ // TODO - VendingMachine integration and functions allowing to convert
23+ // TODO granted KEEP/NU into T and back
24+
1125 using SafeERC20 for T;
1226
1327 T public token;
@@ -59,6 +73,8 @@ contract TokenGrant {
5973 // TODO: implement
6074 }
6175
76+ /// @notice Witthdraws all the amount that is currently withdrawable. Can
77+ /// be called only by the grantee.
6278 function withdraw () external onlyGrantee {
6379 uint256 withdrawable = withdrawableAmount ();
6480 require (withdrawable > 0 , "There is nothing to withdraw " );
@@ -68,6 +84,9 @@ contract TokenGrant {
6884 token.safeTransfer (grantee, withdrawable);
6985 }
7086
87+ /// @notice Calculates the amount unlocked so far. Includes the amount
88+ /// staked and withdrawn. Returns 0 if the vesting schedule has not
89+ /// started yet or if the cliff has not yet ended.
7190 function unlockedAmount () public view returns (uint256 ) {
7291 /* solhint-disable-next-line not-rely-on-time */
7392 if (block .timestamp < start) {
@@ -90,6 +109,9 @@ contract TokenGrant {
90109 return (amount * timeElapsed) / duration;
91110 }
92111
112+ /// @notice Calculates the currently withdrawable amount. The amount
113+ /// withdrawable is the amount vested minus the amount staked and
114+ /// minus the amount already withdrawn.
93115 function withdrawableAmount () public view returns (uint256 ) {
94116 uint256 unlocked = unlockedAmount ();
95117
0 commit comments