-
Notifications
You must be signed in to change notification settings - Fork 1
/
LTap.sol
57 lines (48 loc) · 2.62 KB
/
LTap.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
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.18;
import "@boringcrypto/boring-solidity/contracts/BoringOwnable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";
/*
__/\\\\\\\\\\\\\\\_____/\\\\\\\\\_____/\\\\\\\\\\\\\____/\\\\\\\\\\\_______/\\\\\_____________/\\\\\\\\\_____/\\\\\\\\\____
_\///////\\\/////____/\\\\\\\\\\\\\__\/\\\/////////\\\_\/////\\\///______/\\\///\\\________/\\\////////____/\\\\\\\\\\\\\__
_______\/\\\________/\\\/////////\\\_\/\\\_______\/\\\_____\/\\\_______/\\\/__\///\\\____/\\\/____________/\\\/////////\\\_
_______\/\\\_______\/\\\_______\/\\\_\/\\\\\\\\\\\\\/______\/\\\______/\\\______\//\\\__/\\\_____________\/\\\_______\/\\\_
_______\/\\\_______\/\\\\\\\\\\\\\\\_\/\\\/////////________\/\\\_____\/\\\_______\/\\\_\/\\\_____________\/\\\\\\\\\\\\\\\_
_______\/\\\_______\/\\\/////////\\\_\/\\\_________________\/\\\_____\//\\\______/\\\__\//\\\____________\/\\\/////////\\\_
_______\/\\\_______\/\\\_______\/\\\_\/\\\_________________\/\\\______\///\\\__/\\\_____\///\\\__________\/\\\_______\/\\\_
_______\/\\\_______\/\\\_______\/\\\_\/\\\______________/\\\\\\\\\\\____\///\\\\\/________\////\\\\\\\\\_\/\\\_______\/\\\_
_______\///________\///________\///__\///______________\///////////_______\/////_____________\/////////__\///________\///__
*/
/// @title Locked TAP
/// @notice Allow users to redeem LTAP for TAP after a certain period of time, in a 1:1 ratio.
contract LTap is BoringOwnable, ERC20Permit {
IERC20 tapToken;
uint256 public lockedUntil;
uint256 public maxLockedUntil;
/// @notice Creates a new LTAP token
/// @dev LTAP tokens are minted by depositing TAP
/// @param _tapToken Address of the TAP token
/// @param _maxLockedUntil Latest possible end of locking period
constructor(
IERC20 _tapToken,
uint256 _maxLockedUntil
) ERC20("LTAP", "LTAP") ERC20Permit("LTAP") {
tapToken = _tapToken;
lockedUntil = _maxLockedUntil;
maxLockedUntil = _maxLockedUntil;
}
function deposit(uint256 amount) external {
tapToken.transferFrom(msg.sender, address(this), amount);
_mint(msg.sender, amount);
}
function redeem() external {
require(block.timestamp > lockedUntil, "Still locked");
uint256 amount = balanceOf(msg.sender);
_burn(msg.sender, amount);
tapToken.transfer(msg.sender, amount);
}
function setLockedUntil(uint256 _lockedUntil) external onlyOwner {
require(_lockedUntil <= maxLockedUntil, "Too late");
lockedUntil = _lockedUntil;
}
}