-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSwipeTeamTimeLock.sol
More file actions
67 lines (48 loc) · 1.87 KB
/
SwipeTeamTimeLock.sol
File metadata and controls
67 lines (48 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
pragma solidity ^0.5.0;
import "./SwipeToken.sol";
// ----------------------------------------------------------------------------
// Swipe Tokens Team Time Lock Contract
// ----------------------------------------------------------------------------
contract SwipeTeamTimeLock is Owned {
using SafeMath for uint;
SwipeToken token;
uint lastCompleteRelease;
uint restRelease;
uint constant releasePerMonth = 6 * 10**23; //600k
constructor(address payable addrToken) public {
token = SwipeToken(addrToken);
restRelease = 0;
lastCompleteRelease = now;
}
function getLockedTokenAmount() public view returns (uint) {
return token.balanceOf(address(this));
}
function getAllowedAmount() public view returns (uint) {
uint amount = restRelease;
if (now < lastCompleteRelease) return amount;
uint lockedAmount = getLockedTokenAmount();
uint months = (now - lastCompleteRelease) / (30 days) + 1;
uint possible = lockedAmount.sub(restRelease).div(releasePerMonth);
if (possible > months) {
possible = months;
}
amount = amount.add(possible.mul(releasePerMonth));
return amount;
}
function withdraw(uint amount) external onlyOwner {
uint allowedAmount = getAllowedAmount();
require(allowedAmount >= amount, 'not enough tokens');
if (token.transfer(msg.sender, amount)) {
restRelease = allowedAmount.sub(amount);
while(now > lastCompleteRelease) {
lastCompleteRelease += 30 days;
}
}
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () external payable {
revert();
}
}