-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdepay.token.sol
58 lines (47 loc) · 2.18 KB
/
depay.token.sol
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.1.0/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.1.0/contracts/math/SafeMath.sol";
contract DEPAY is ERC20 {
uint public lastVestingRelease;
uint public vestingPeriodEnd;
uint public vestingRewardPerSecond;
address public vestingBeneficial;
modifier onlyBeneficial {
require(
msg.sender == vestingBeneficial,
"Only beneficial can call this function."
);
_;
}
constructor() public ERC20("DePay", "DEPAY") {
uint supply = 100000000000000000000000000;
vestingBeneficial = msg.sender;
lastVestingRelease = block.timestamp;
vestingPeriodEnd = block.timestamp.add(1095 days); // 3 years
vestingRewardPerSecond = supply.div(vestingPeriodEnd.sub(lastVestingRelease));
_mint(address(this), supply);
}
function releasable() public view returns (uint) {
uint secondsSinceLastVestingRelease = block.timestamp.sub(lastVestingRelease);
uint secondsTillVestingPeriodEnd = vestingPeriodEnd.sub(block.timestamp);
if (secondsTillVestingPeriodEnd <= 0) {
return balanceOf(address(this)); // total amount left
} else {
return vestingRewardPerSecond.mul(secondsSinceLastVestingRelease);
}
}
function release() public onlyBeneficial {
_transfer(address(this), vestingBeneficial, releasable());
lastVestingRelease = block.timestamp;
vestingRewardPerSecond = balanceOf(address(this)).div(vestingPeriodEnd.sub(lastVestingRelease));
}
function extendVestingPeriod(uint extension) public onlyBeneficial {
vestingPeriodEnd = vestingPeriodEnd.add(extension);
vestingRewardPerSecond = balanceOf(address(this)).div(vestingPeriodEnd.sub(lastVestingRelease));
}
function burnBeforeRelease(uint amount) public onlyBeneficial {
_burn(address(this), amount);
vestingRewardPerSecond = balanceOf(address(this)).div(vestingPeriodEnd.sub(lastVestingRelease));
}
}