@@ -7,7 +7,21 @@ import "../token/T.sol";
7
7
8
8
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol " ;
9
9
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.
10
15
contract 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
+
11
25
using SafeERC20 for T;
12
26
13
27
T public token;
@@ -59,6 +73,8 @@ contract TokenGrant {
59
73
// TODO: implement
60
74
}
61
75
76
+ /// @notice Witthdraws all the amount that is currently withdrawable. Can
77
+ /// be called only by the grantee.
62
78
function withdraw () external onlyGrantee {
63
79
uint256 withdrawable = withdrawableAmount ();
64
80
require (withdrawable > 0 , "There is nothing to withdraw " );
@@ -68,6 +84,9 @@ contract TokenGrant {
68
84
token.safeTransfer (grantee, withdrawable);
69
85
}
70
86
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.
71
90
function unlockedAmount () public view returns (uint256 ) {
72
91
/* solhint-disable-next-line not-rely-on-time */
73
92
if (block .timestamp < start) {
@@ -90,6 +109,9 @@ contract TokenGrant {
90
109
return (amount * timeElapsed) / duration;
91
110
}
92
111
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.
93
115
function withdrawableAmount () public view returns (uint256 ) {
94
116
uint256 unlocked = unlockedAmount ();
95
117
0 commit comments