Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add upg to token #14

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions contracts/contracts/DevRewardDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import "./FluenceToken.sol";
import "./Executor.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";

/**
* @title DevRewardDistributor
* @notice Contract for managing developers reward
*/
contract DevRewardDistributor {
using SafeERC20 for IERC20;
using SafeERC20Upgradeable for IERC20Upgradeable;

/**
* @notice Reward token
Expand Down Expand Up @@ -143,7 +143,7 @@ contract DevRewardDistributor {

uint256 amount = currentReward();

IERC20(token).safeTransfer(msg.sender, amount);
IERC20Upgradeable(token).safeTransfer(msg.sender, amount);

emit Claimed(userId, msg.sender, amount, leaf);
}
Expand All @@ -152,7 +152,7 @@ contract DevRewardDistributor {
* @notice used to move any remaining tokens out of the contract after expiration
**/
function transferUnclaimed() external whenClaimingIs(false) {
IERC20 rewardToken = IERC20(token); //gas saving
IERC20Upgradeable rewardToken = IERC20Upgradeable(token); //gas saving

uint256 remainingBalance = rewardToken.balanceOf(address(this));
rewardToken.safeTransfer(address(executor), remainingBalance);
Expand Down
31 changes: 22 additions & 9 deletions contracts/contracts/FluenceToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,51 @@

pragma solidity >=0.8.15;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

contract FluenceToken is ERC20, ERC20Permit, ERC20Votes {
constructor(
contract FluenceToken is ERC20Upgradeable, ERC20PermitUpgradeable, ERC20VotesUpgradeable, OwnableUpgradeable, UUPSUpgradeable {
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}

function initialize(
string memory name_,
string memory symbol_,
uint256 totalSupply_
) ERC20(name_, symbol_) ERC20Permit(name_) {
) initializer public {
__ERC20_init(name_, symbol_);
__Ownable_init();
__UUPSUpgradeable_init();

_mint(msg.sender, totalSupply_);
}

function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal override(ERC20, ERC20Votes) {
) internal override(ERC20Upgradeable, ERC20VotesUpgradeable) {
super._afterTokenTransfer(from, to, amount);
}

function _mint(address to, uint256 amount)
internal
override(ERC20, ERC20Votes)
override(ERC20Upgradeable, ERC20VotesUpgradeable)
{
super._mint(to, amount);
}

function _burn(address account, uint256 amount)
internal
override(ERC20, ERC20Votes)
override(ERC20Upgradeable, ERC20VotesUpgradeable)
{
super._burn(account, amount);
}

function _authorizeUpgrade(address) internal override onlyOwner {}
}
7 changes: 4 additions & 3 deletions contracts/contracts/Vesting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

pragma solidity >=0.8.15;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "./FluenceToken.sol";
import "./interfaces/IVestingERC20.sol";

Expand All @@ -12,7 +13,7 @@ import "./interfaces/IVestingERC20.sol";
* @dev This contract implements the ERC20 standard. It is possible to add the contract to a wallet. Transferring to zero address is unlocking the released amount.
*/
contract Vesting is IVestingERC20 {
using SafeERC20 for IERC20;
using SafeERC20Upgradeable for IERC20Upgradeable;

/**
* @notice Returns the vesting token
Expand Down Expand Up @@ -200,7 +201,7 @@ contract Vesting is IVestingERC20 {

_beforeBurn(from, amount);

IERC20(token).safeTransfer(from, amount);
IERC20Upgradeable(token).safeTransfer(from, amount);

balanceOf[from] -= amount;
}
Expand Down
18 changes: 18 additions & 0 deletions contracts/contracts/dev/DevERC20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: Apache-2.0

pragma solidity >=0.8.15;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

/*
* @dev This contract is used for testing purposes only.
*/
contract DevERC20 is ERC20 {
constructor(
string memory name_,
string memory symbol_,
uint256 totalSupply_
) ERC20(name_, symbol_) {
_mint(msg.sender, totalSupply_);
}
}
19 changes: 14 additions & 5 deletions contracts/deploy/0000_FluenceToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

await hre.deployments.deploy("FluenceToken", {
from: deployer,
args: [
"Fluence Token",
"FLT",
ethers.utils.parseEther(String(config.deployment!.token!.totalSupply)),
],
proxy: {
proxyContract: "ERC1967Proxy",
proxyArgs: ["{implementation}", "{data}"],
execute: {
methodName: "initialize",
args: [
"Fluence Token",
"FLT",
ethers.utils.parseEther(
String(config.deployment!.token!.totalSupply)
),
],
},
},
log: true,
autoMine: true,
waitConfirmations: 1,
Expand Down
1 change: 1 addition & 0 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "solidity-coverage";
import "hardhat-deploy";
import "hardhat-tracer";
import "hardhat-docgen";
import "dotenv/config";
import { HardhatUserConfig, task } from "hardhat/config";
import { Config } from "./utils/config";
import fs from "fs";
Expand Down
Loading
Loading