Skip to content

Commit

Permalink
Merge pull request #32 from fei-protocol/POZ-Remove-ERC20-Burnable
Browse files Browse the repository at this point in the history
Remove ERC20 burnable
  • Loading branch information
Joeysantoro committed Feb 6, 2021
2 parents 3ca2c69 + d10bcc1 commit e096ee0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
20 changes: 10 additions & 10 deletions contracts/genesis/GenesisGroup.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "./IGenesisGroup.sol";
import "./IDOInterface.sol";
Expand All @@ -13,7 +12,7 @@ import "../bondingcurve/IBondingCurve.sol";

/// @title IGenesisGroup implementation
/// @author Fei Protocol
contract GenesisGroup is IGenesisGroup, CoreRef, ERC20, ERC20Burnable, Timed {
contract GenesisGroup is IGenesisGroup, CoreRef, ERC20, Timed {
using Decimal for Decimal.D256;

IBondingCurve private bondingcurve;
Expand Down Expand Up @@ -81,7 +80,7 @@ contract GenesisGroup is IGenesisGroup, CoreRef, ERC20, ERC20Burnable, Timed {
}

function commit(address from, address to, uint amount) external override onlyGenesisPeriod {
burnFrom(from, amount);
_burnFrom(from, amount);

committedFGEN[to] += amount;
totalCommittedFGEN += amount;
Expand All @@ -98,7 +97,7 @@ contract GenesisGroup is IGenesisGroup, CoreRef, ERC20, ERC20Burnable, Timed {
require(tribeAmount != 0, "GenesisGroup: No redeemable TRIBE");

uint amountIn = balanceOf(to);
burnFrom(to, amountIn);
_burnFrom(to, amountIn);

uint committed = committedFGEN[to];
committedFGEN[to] = 0;
Expand Down Expand Up @@ -183,7 +182,7 @@ contract GenesisGroup is IGenesisGroup, CoreRef, ERC20, ERC20Burnable, Timed {
require(address(this).balance >= total, "GenesisGroup: Not enough ETH to redeem");
require(msg.sender == from || allowance(from, msg.sender) >= total, "GenesisGroup: Not approved for emergency withdrawal");

burnFrom(from, heldFGEN);
_burnFrom(from, heldFGEN);
committedFGEN[from] = 0;
totalCommittedFGEN -= committed;

Expand All @@ -206,12 +205,13 @@ contract GenesisGroup is IGenesisGroup, CoreRef, ERC20, ERC20Burnable, Timed {
return (totalFei * amountIn / totalIn, totalTribe * amountIn / totalIn);
}

function burnFrom(address account, uint amount) public override {
// Sender doesn't need approval
if (msg.sender == account) {
increaseAllowance(account, amount);

function _burnFrom(address account, uint amount) internal {
if (msg.sender != account) {
uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "GenesisGroup: burn amount exceeds allowance");
_approve(account, _msgSender(), decreasedAllowance);
}
super.burnFrom(account, amount);
_burn(account, amount);
}

function _feiTribeExchangeRate() public view returns (Decimal.D256 memory) {
Expand Down
16 changes: 8 additions & 8 deletions contracts/pool/Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma experimental ABIEncoderV2;

import "@uniswap/lib/contracts/libraries/TransferHelper.sol";
import "@openzeppelin/contracts/utils/SafeCast.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "./IPool.sol";
import "../utils/Timed.sol";
Expand All @@ -13,7 +12,7 @@ import "../external/Decimal.sol";

/// @title abstract implementation of IPool interface
/// @author Fei Protocol
abstract contract Pool is IPool, ERC20, ERC20Burnable, Timed {
abstract contract Pool is IPool, ERC20, Timed {
using Decimal for Decimal.D256;
using SafeMath128 for uint128;
using SafeCast for uint;
Expand Down Expand Up @@ -94,11 +93,12 @@ abstract contract Pool is IPool, ERC20, ERC20Burnable, Timed {
return rewardToken.balanceOf(address(this));
}

function burnFrom(address account, uint amount) public override {
if (msg.sender == account) {
increaseAllowance(account, amount);
function _burnFrom(address account, uint amount) internal {
if (msg.sender != account) {
uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "Pool: burn amount exceeds allowance");
_approve(account, _msgSender(), decreasedAllowance);
}
super.burnFrom(account, amount);
_burn(account, amount);
}

function _totalRedeemablePoolTokens() internal view returns(uint) {
Expand Down Expand Up @@ -144,7 +144,7 @@ abstract contract Pool is IPool, ERC20, ERC20Burnable, Timed {

uint amountPool = balanceOf(from);
if (amountPool != 0) {
_burn(from, amountPool);
_burnFrom(from, amountPool);
}
return amountStaked;
}
Expand All @@ -153,7 +153,7 @@ abstract contract Pool is IPool, ERC20, ERC20Burnable, Timed {
(uint amountReward, uint amountPool) = redeemableReward(from);
require(amountPool != 0, "Pool: User has no redeemable pool tokens");

burnFrom(from, amountPool);
_burnFrom(from, amountPool);
_incrementClaimed(amountReward);

rewardToken.transfer(to, amountReward);
Expand Down
3 changes: 1 addition & 2 deletions contracts/token/Fei.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "./IIncentive.sol";
import "./IFei.sol";
import "../refs/CoreRef.sol";

/// @title IFei implementation
/// @author Fei Protocol
contract Fei is IFei, ERC20, ERC20Burnable, CoreRef {
contract Fei is IFei, ERC20Burnable, CoreRef {

mapping (address => address) public override incentiveContract;

Expand Down
4 changes: 2 additions & 2 deletions test/genesis/GenesisGroup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ describe('GenesisGroup', function () {
it('reverts', async function() {
await expectRevert(
this.genesisGroup.redeem(userAddress, {from: secondUserAddress}),
'ERC20: burn amount exceeds allowance'
'GenesisGroup: burn amount exceeds allowance'
);
});
});
Expand Down Expand Up @@ -635,7 +635,7 @@ describe('GenesisGroup', function () {

describe('Unapproved commit', function() {
it('reverts', async function() {
await expectRevert(this.genesisGroup.commit(userAddress, userAddress, '500', {from: secondUserAddress}), "ERC20: burn amount exceeds allowance");
await expectRevert(this.genesisGroup.commit(userAddress, userAddress, '500', {from: secondUserAddress}), "GenesisGroup: burn amount exceeds allowance");
});
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/pool/FeiPool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ describe('Pool', function () {
it('reverts', async function() {
await expectRevert(
this.pool.claim(userAddress, userAddress, {from: secondUserAddress}),
'ERC20: burn amount exceeds allowance'
'Pool: burn amount exceeds allowance'
);
});
});
Expand Down Expand Up @@ -421,7 +421,7 @@ describe('Pool', function () {
it('reverts', async function() {
await expectRevert(
this.pool.claim(userAddress, secondUserAddress, {from: secondUserAddress}),
'ERC20: burn amount exceeds allowance'
'Pool: burn amount exceeds allowance'
);
});
});
Expand Down

0 comments on commit e096ee0

Please sign in to comment.