From e664511a217b3e8a576f3f78ed15bc0d530bd5de Mon Sep 17 00:00:00 2001 From: Javier Gonzalez Date: Fri, 17 Dec 2021 17:00:40 -0600 Subject: [PATCH] remove unfinished tokens --- contracts/VestedToken.sol | 299 -------------------------------------- test/VestedToken.ts | 61 -------- 2 files changed, 360 deletions(-) delete mode 100644 contracts/VestedToken.sol delete mode 100644 test/VestedToken.ts diff --git a/contracts/VestedToken.sol b/contracts/VestedToken.sol deleted file mode 100644 index e3d4ebb..0000000 --- a/contracts/VestedToken.sol +++ /dev/null @@ -1,299 +0,0 @@ -//SPDX-License-Identifier: Unlicense -pragma solidity 0.8.6; - -import "@openzeppelin/contracts/access/AccessControl.sol"; -import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; -// import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; - -// import { -// ISuperfluid, -// ISuperToken, -// ISuperAgreement -// } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol"; - -// import { -// IConstantFlowAgreementV1 -// } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/agreements/IConstantFlowAgreementV1.sol"; - -import "hardhat/console.sol"; - -/** - * @title Vested Token - * @author Javier Gonzalez - * @dev Implementation of a Vested Token. - * @notice Vested Token is a token that can be minted and vested. - * Has a percentage immediately available to the owner, - * the mint function is only callable by a multisig and mints tokens - * that are vested for a timelocked period with a cliff. - * i.e. TotalSupply is 100,000,000,000 tokens, - * owner recieves 20% immediately, - * owner can mint 20,000,000 tokens for a timelocked period of 1 year, - * the rest of the 80% is vested for 4 years with a cliff of 1 year. - */ -contract VestedToken is ERC20, AccessControl { - bytes32 public constant VESTEE_ROLE = keccak256("VESTEE"); - - constructor( - string memory name, - string memory symbol, - uint256 initialSupply, - address safe, - address admin - ) ERC20(name, symbol) { - _mint(safe, initialSupply); - _setupRole(DEFAULT_ADMIN_ROLE, admin); - } - - modifier onlyAdmin { - require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Admin Role required to call"); - _; - } - - function mint(address _to, uint256 _amount) onlyAdmin public { - _mint(_to, _amount); - } - - function addVestee(address _vestee) onlyAdmin public { - _setupRole(VESTEE_ROLE, _vestee); - } -} - -// abstract contract FluidVesting is Ownable { -// function callAgreement( -// ISuperAgreement agreementClass, -// bytes memory callData, -// bytes memory userData -// ) -// external override -// returns(bytes memory returnedData) -// { -// return _callAgreement(msg.sender, agreementClass, callData, userData); -// } - - // enum RecipientState { Registered, Flowing, Stopped } - - // struct FlowRecipient { - // address recipient; - // uint256 flowRate; - // bool permanent; - // RecipientState state; - // } - - // event FlowStopped( - // address recipient, - // uint256 flowRate, - // bool wasPermanent - // ); - - // ISuperfluid _host; - // IConstantFlowAgreementV1 _cfa; - // ISuperToken public acceptedToken; - - // mapping(address => FlowRecipient) _recipients; - // mapping(address => bool) _permanentRecipients; - // mapping(address => bool) _impermanentRecipients; - // mapping(address => uint256) _recipientLastStopped; - // mapping(address => uint256) _recipientToPauseDuration; - - // address admin; - // uint256 public cliffEnd; - // uint256 public starttime; - // uint256 public vestingDuration; - // bool public vestingActive; - -// constructor(ISuperfluid host, IConstantFlowAgreementV1 cfa, ISuperToken _acceptedToken, uint256 _cliffEnd, uint256 _vestingDuration) { -// require(address(host) != address(0), "host is zero address"); -// require(address(cfa) != address(0), "cfa is zero address"); -// require(address(_acceptedToken) != address(0), "acceptedToken is zero address"); -// require(_vestingDuration > 0, "vestingDuration must be larger than 0"); - -// if(_cliffEnd == 0) _cliffEnd = block.timestamp; -// _host = host; -// _cfa = cfa; -// acceptedToken = _acceptedToken; -// cliffEnd = _cliffEnd; -// vestingDuration = _vestingDuration; -// admin = msg.sender; - -// initializeRecipients(); -// } - -// modifier onlyAdmin() { -// require(msg.sender == admin, "Only allowed by admin"); -// _; -// } - -// modifier notRegistered(address adr) { -// require(!isRecipientRegistered(adr), "Registered Recipient"); -// _; -// } - -// modifier registeredRecipient(address adr) { -// require(isRecipientRegistered(adr), "Not Registered Recipient"); -// _; -// } - - - -// function initializeRecipients() virtual internal; - - - -// function launchVesting(address[] calldata recipientAddresses) public onlyOwner { -// require(block.timestamp > cliffEnd, "Cliff period not ended."); - -// for(uint i = 0; i < recipientAddresses.length; i++) { -// openStream(recipientAddresses[i]); -// } - - - -// if(!vestingActive) { -// starttime = block.timestamp; -// vestingActive = true; -// } -// } - -// function openStream(address recipient) internal { -// _host.callAgreement( -// _cfa, -// abi.encodeWithSelector( -// _cfa.createFlow.selector, -// acceptedToken, -// recipient, -// _recipients[recipient].flowRate, -// new bytes(0) -// ), -// new bytes(0) -// ); -// _recipients[recipient].state = RecipientState.Flowing; -// } - -// function resumeStream() public { -// if(isRecipientRegistered(msg.sender) && isPermanentRecipient(msg.sender)) { -// openStream(msg.sender); -// if(_recipientLastStopped[msg.sender] > 0) { -// uint256 lastPauseDuration = block.timestamp - _recipientLastStopped[msg.sender]; -// _recipientToPauseDuration[msg.sender] = _recipientToPauseDuration[msg.sender] + lastPauseDuration; -// _recipientLastStopped[msg.sender] = 0; -// } -// } else { -// revert("Only Stream Recipient can reopen the stream."); -// } -// } - -// function elapsedTime() public view returns (uint256) { -// require(starttime > 0, "Vesting has not yet started."); -// return block.timestamp.sub(starttime); -// } - -// function estimateElapsedTokens(address recipient) public view onlyAdmin returns (uint256) { -// require(vestingActive, "Vesting inactive"); -// uint256 durationEstimate = block.timestamp - starttime * _recipients[recipient].flowRate; -// uint256 pauseEstimate = _recipientToPauseDuration[recipient] * _recipients[recipient].flowRate; -// return durationEstimate - pauseEstimate; -// } - -// function estimateTotalTokens(address recipient) public onlyAdmin view returns (uint256) { -// return vestingDuration.mul(_recipients[recipient].flowRate); -// } - -// function estimateRemainingTokens(address recipient) public onlyAdmin view returns (uint256) { -// return estimateTotalTokens(recipient).sub(estimateElapsedTokens(recipient)); -// } - -// function getFlowRecipient(address adr) public onlyAdmin view returns (FlowRecipient memory) { -// return _recipients[adr]; -// } - -// function registerRecipient(address adr, uint256 flowRate, bool isPermanent) public onlyOwner notRegistered(adr) returns (FlowRecipient memory) { -// FlowRecipient memory newRecipient = FlowRecipient(adr, flowRate, isPermanent, RecipientState.Registered); -// _recipients[adr] = newRecipient; -// return newRecipient; -// } - - - -// function isPermanentRecipient(address adr) internal registeredRecipient(adr) view returns (bool) { -// return _recipients[adr].permanent; -// } - - - -// function flowTokenBalance() public view returns (uint256) { -// return acceptedToken.balanceOf(address(this)); -// } - - - -// function withdraw(IERC20 token, uint256 amount) public onlyOwner { -// require(amount <= token.balanceOf(address(this)), "Withdrawal amount exceeds balance"); -// bool transferSuccess = token.transfer(msg.sender, amount); -// if(!transferSuccess) revert("Token transfer failed"); -// } - -// } - - - -// contract InvestorsVesting is FluidVesting { -// constructor(ISuperfluid host, IConstantFlowAgreementV1 cfa, ISuperToken _acceptedToken, uint256 _cliffEnd, uint256 _vestingDuration) FluidVesting(host, cfa, _acceptedToken, _cliffEnd, _vestingDuration) {} - -// function initializeRecipients() internal override { -// // Investors (36 months) -// registerRecipient(0x0caCf3518029666703c08aB7f1F9AD1Aca4C38D1, 317097919800000, true); -// } -// } - -// contract TeamVesting is FluidVesting { - -// constructor(ISuperfluid host, IConstantFlowAgreementV1 cfa, ISuperToken _acceptedToken, uint256 _cliffEnd, uint256 _vestingDuration) FluidVesting(host, cfa, _acceptedToken, _cliffEnd, _vestingDuration) {} - -// function initializeRecipients() internal override { -// // Team (48 months) -// registerRecipient(0x6960CcbAe6A13813618f275B10EE0FB55271ce1D, 396372399800000, true); -// } -// } - -// contract StoppableVesting is FluidVesting { - -// constructor(ISuperfluid host, IConstantFlowAgreementV1 cfa, ISuperToken _acceptedToken, uint256 _cliffEnd, uint256 _vestingDuration) FluidVesting(host, cfa, _acceptedToken, _cliffEnd, _vestingDuration) {} - -// function initializeRecipients() internal override { -// // Stoppable (48 months, no cliff) -// registerRecipient(0x474B73e8966D61999B1f829704337C0133F77b56, 396372399800000, false); -// } - -// function closeVesting(address[] calldata recipientAddresses) public onlyOwner { -// require(vestingActive, "Vesting not started"); -// require(elapsedTime() > vestingDuration, "Vesting duration has not expired yet."); -// for(uint i = 0; i < recipientAddresses.length; i++) { -// closeStream(recipientAddresses[i]); -// } -// } - -// function closeStream(address recipient) public onlyOwner { -// require(_recipients[recipient].state == RecipientState.Flowing, "Stream inactive"); - -// if(elapsedTime() < vestingDuration) { -// require(!isPermanentRecipient(recipient), "Stream for this receiver is permanent and cannot be closed."); -// } - -// _host.callAgreement( -// _cfa, -// abi.encodeWithSelector( -// _cfa.deleteFlow.selector, -// acceptedToken, -// address(this), -// recipient, -// new bytes(0) -// ), -// new bytes(0) -// ); - -// _recipients[recipient].state = RecipientState.Stopped; -// _recipientLastStopped[recipient] = block.timestamp; - -// emit FlowStopped(recipient, _recipients[recipient].flowRate, isPermanentRecipient(recipient)); -// } -// } diff --git a/test/VestedToken.ts b/test/VestedToken.ts deleted file mode 100644 index 5f367c5..0000000 --- a/test/VestedToken.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { ethers } from "hardhat"; -import { BigNumber, Contract, Signer } from "ethers"; -import chai from "chai"; -import { solidity } from "ethereum-waffle"; -import { getAddress } from "@ethersproject/address"; - -chai.use(solidity); -const { expect } = chai; -const TEN_MILLION_IN_WEI = ethers.BigNumber.from("100000000000000000000000000") as BigNumber; -const ONE_FINNEY = ethers.utils.parseUnits("1.0", "finney") as BigNumber; -const ONE_ETH = ethers.utils.parseUnits("1.0", "ether") as BigNumber; - - -describe("VestedToken", () => { - let VestedToken: any, token: Contract, deployer: Signer, admin: Signer, safe: Signer, addresses: Signer[] - const setupVestedToken = async () => { - [deployer, admin, safe, ...addresses] = await ethers.getSigners(); - VestedToken = await ethers.getContractFactory("VestedToken"); - token = await VestedToken.deploy("OrgToken", "TST", TEN_MILLION_IN_WEI, await safe.getAddress(), await admin.getAddress()); - await token.deployed(); - } - - describe("Deployment", () => { - beforeEach(setupVestedToken) - - it("Should create a token on deploying a contract", async () => { - expect(await token.name()).to.equal("OrgToken"); - expect(await token.symbol()).to.equal("TST"); - }); - - it("Should launch with the total supply given as a parameter in the constructor to the safe", async () => { - expect(await token.totalSupply()).to.equal(TEN_MILLION_IN_WEI); - expect(await token.balanceOf(await safe.getAddress())).to.equal(TEN_MILLION_IN_WEI); - }); - - it("Should give admin access to parameter in the constructor", async () => { - await token.connect(admin).mint(await deployer.getAddress(), TEN_MILLION_IN_WEI), - expect(await token.totalSupply()).to.equal(TEN_MILLION_IN_WEI.mul(ethers.BigNumber.from(2))); - }); - - it("Should only let admin mint new tokens", async () => { - await expect( - token.connect(deployer) - .mint(await deployer.getAddress(), TEN_MILLION_IN_WEI) - ).to.be.revertedWith("Admin Role required to call"); - }); - }) - describe("Grant Vesting", () => { - beforeEach(setupVestedToken) - - it("Should allow admin to grant VESTEE role to any address", async () => { - const { keccak256, formatBytes32String } = ethers.utils; - const vestee = formatBytes32String('VESTEE') - expect( - await token.hasRole(vestee, await deployer.getAddress()) - ).to.equal(false); - await token.connect(admin).addVestee(await deployer.getAddress()) - expect(await token.hasRole(vestee, await deployer.getAddress())).to.equal(true); - }); - }) -});