-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSwipeTimeLock.sol
More file actions
84 lines (56 loc) · 2.37 KB
/
SwipeTimeLock.sol
File metadata and controls
84 lines (56 loc) · 2.37 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
pragma solidity ^0.5.0;
import "./SwipeToken.sol";
// ----------------------------------------------------------------------------
// Swipe Tokens Time Lock Contract
// ----------------------------------------------------------------------------
contract SwipeTimeLock is Owned {
using SafeMath for uint;
SwipeToken token;
uint tokenslocked;
// Release 10M tokens time period
uint[] unlockTimestamps = [
1596240000, // 08/01/2020
1627776000, // 08/01/2021
1659312000, // 08/01/2022
1690848000, // 08/01/2023
1722470400, // 08/01/2024
1754006400 // 08/01/2025
];
constructor(address payable addrToken) public {
token = SwipeToken(addrToken);
}
function getLockCount() public view returns (uint) {
uint lock = 60000000000000000000000000;
for (uint i = 0; i < 6; i ++) {
if (now < unlockTimestamps[i]) break;
lock = lock.sub(10000000000000000000000000);
}
return lock;
}
function getLockedTokenAmount() public view returns (uint) {
return token.balanceOf(address(this));
}
function withdraw() public onlyOwner returns (uint withdrawed) {
uint tokenLocked = getLockedTokenAmount();
uint lockCount = getLockCount();
require(tokenLocked >= lockCount, 'no unlocked tokens');
uint allowed = tokenLocked.sub(lockCount);
if (token.transfer(msg.sender, allowed)) {
return allowed;
}
return 0;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () external payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
require(tokenAddress != address(token), 'SXP token is not allowed');
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
}