Advertisement
Guest User

Untitled

a guest
Jul 9th, 2021
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. pragma solidity 0.6.12;
  2.  
  3. import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.1.0/contracts/access/Ownable.sol";
  4. import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.1.0/contracts/math/SafeMath.sol";
  5. import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.1.0/contracts/token/ERC20/SafeERC20.sol";
  6.  
  7. contract KudexLiquidityLock is Ownable {
  8. using SafeMath for uint256;
  9. using SafeERC20 for IERC20;
  10.  
  11. // Variables
  12. address token;
  13.  
  14. address creator;
  15. address admin;
  16.  
  17. uint256 unlockTime;
  18.  
  19.  
  20. constructor(
  21. address _token,
  22. address _admin,
  23. address _creator,
  24. uint256 _unlockTime
  25. ) public {
  26. token = _token;
  27. admin = _admin;
  28. creator = _creator;
  29. unlockTime = _unlockTime;
  30. }
  31.  
  32. function isUnlockable() public view returns (bool) {
  33. return block.timestamp >= unlockTime;
  34. }
  35.  
  36. function getTimeLeft() public view returns (uint256) {
  37. if( isUnlockable() ) {
  38. return 0;
  39. } else {
  40. return (unlockTime - block.timestamp);
  41. }
  42. }
  43.  
  44. function unlockTokens() public {
  45. require( address(msg.sender) == creator || address(msg.sender) == admin );
  46.  
  47. require( isUnlockable(), "The lock time has not yet passed");
  48.  
  49. // Transfer the token to the user's wallet
  50. IERC20 theToken = IERC20(token);
  51.  
  52. theToken.safeTransfer(msg.sender, theToken.balanceOf(address(this)));
  53.  
  54. }
  55.  
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement