Skip to content

Commit e2a04dc

Browse files
committed
feat: remove transfer restriction code in EIGEN (#1241)
**Motivation:** per ELIP5, remove transfer restriction code from eigen mint function will be removed in next PR so we can limit change scope in each PR, and make each change more readable **Modifications:** remove transfer restriction code from eigen **Result:** remove transfer restriction code from eigen
1 parent 1f0e695 commit e2a04dc

File tree

4 files changed

+17
-294
lines changed

4 files changed

+17
-294
lines changed

src/contracts/token/Eigen.sol

Lines changed: 17 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,24 @@ contract Eigen is OwnableUpgradeable, ERC20VotesUpgradeable {
1111
IERC20 public immutable bEIGEN;
1212

1313
/// STORAGE
14+
/// @dev Do not remove, deprecated storage.
1415
/// @notice mapping of minter addresses to the timestamp after which they are allowed to mint
15-
mapping(address => uint256) public mintAllowedAfter;
16+
mapping(address => uint256) internal __deprecated_mintAllowedAfter;
17+
/// @dev Do not remove, deprecated storage.
1618
/// @notice mapping of minter addresses to the amount of tokens they are allowed to mint
17-
mapping(address => uint256) public mintingAllowance;
18-
19+
mapping(address => uint256) internal __deprecated_mintingAllowance;
20+
/// @dev Do not remove, deprecated storage.
1921
/// @notice the timestamp after which transfer restrictions are disabled
20-
uint256 public transferRestrictionsDisabledAfter;
22+
uint256 internal __deprecated_transferRestrictionsDisabledAfter;
23+
/// @dev Do not remove, deprecated storage.
2124
/// @notice mapping of addresses that are allowed to transfer tokens to any address
22-
mapping(address => bool) public allowedFrom;
25+
mapping(address => bool) internal __deprecated_allowedFrom;
26+
/// @dev Do not remove, deprecated storage.
2327
/// @notice mapping of addresses that are allowed to receive tokens from any address
24-
mapping(address => bool) public allowedTo;
28+
mapping(address => bool) internal __deprecated_allowedTo;
2529

26-
/// @notice event emitted when the allowedFrom status of an address is set
27-
event SetAllowedFrom(address indexed from, bool isAllowedFrom);
28-
/// @notice event emitted when the allowedTo status of an address is set
29-
event SetAllowedTo(address indexed to, bool isAllowedTo);
3030
/// @notice event emitted when a minter mints
3131
event Mint(address indexed minter, uint256 amount);
32-
/// @notice event emitted when the transfer restrictions disabled
33-
event TransferRestrictionsDisabled();
3432

3533
constructor(
3634
IERC20 _bEIGEN
@@ -63,59 +61,19 @@ contract Eigen is OwnableUpgradeable, ERC20VotesUpgradeable {
6361
minters.length == mintAllowedAfters.length,
6462
"Eigen.initialize: minters and mintAllowedAfters must be the same length"
6563
);
66-
// set minting allowances for each minter
67-
for (uint256 i = 0; i < minters.length; i++) {
68-
mintingAllowance[minters[i]] = mintingAllowances[i];
69-
mintAllowedAfter[minters[i]] = mintAllowedAfters[i];
70-
// allow each minter to transfer tokens
71-
allowedFrom[minters[i]] = true;
72-
emit SetAllowedFrom(minters[i], true);
73-
}
74-
75-
// set transfer restrictions to be disabled at type(uint256).max to be set down later
76-
transferRestrictionsDisabledAfter = type(uint256).max;
77-
}
78-
79-
/**
80-
* @notice This function allows the owner to set the allowedFrom status of an address
81-
* @param from the address whose allowedFrom status is being set
82-
* @param isAllowedFrom the new allowedFrom status
83-
*/
84-
function setAllowedFrom(address from, bool isAllowedFrom) external onlyOwner {
85-
allowedFrom[from] = isAllowedFrom;
86-
emit SetAllowedFrom(from, isAllowedFrom);
87-
}
88-
89-
/**
90-
* @notice This function allows the owner to set the allowedTo status of an address
91-
* @param to the address whose allowedTo status is being set
92-
* @param isAllowedTo the new allowedTo status
93-
*/
94-
function setAllowedTo(address to, bool isAllowedTo) external onlyOwner {
95-
allowedTo[to] = isAllowedTo;
96-
emit SetAllowedTo(to, isAllowedTo);
97-
}
98-
99-
/**
100-
* @notice Allows the owner to disable transfer restrictions
101-
*/
102-
function disableTransferRestrictions() external onlyOwner {
103-
require(
104-
transferRestrictionsDisabledAfter == type(uint256).max,
105-
"Eigen.disableTransferRestrictions: transfer restrictions are already disabled"
106-
);
107-
transferRestrictionsDisabledAfter = 0;
108-
emit TransferRestrictionsDisabled();
10964
}
11065

11166
/**
11267
* @notice This function allows minter to mint tokens
11368
*/
11469
function mint() external {
115-
require(mintingAllowance[msg.sender] > 0, "Eigen.mint: msg.sender has no minting allowance");
116-
require(block.timestamp > mintAllowedAfter[msg.sender], "Eigen.mint: msg.sender is not allowed to mint yet");
117-
uint256 amount = mintingAllowance[msg.sender];
118-
mintingAllowance[msg.sender] = 0;
70+
require(__deprecated_mintingAllowance[msg.sender] > 0, "Eigen.mint: msg.sender has no minting allowance");
71+
require(
72+
block.timestamp > __deprecated_mintAllowedAfter[msg.sender],
73+
"Eigen.mint: msg.sender is not allowed to mint yet"
74+
);
75+
uint256 amount = __deprecated_mintingAllowance[msg.sender];
76+
__deprecated_mintingAllowance[msg.sender] = 0;
11977
_mint(msg.sender, amount);
12078
emit Mint(msg.sender, amount);
12179
}
@@ -150,24 +108,6 @@ contract Eigen is OwnableUpgradeable, ERC20VotesUpgradeable {
150108
}
151109
}
152110

153-
/**
154-
* @notice Overrides the beforeTokenTransfer function to enforce transfer restrictions
155-
* @param from the address tokens are being transferred from
156-
* @param to the address tokens are being transferred to
157-
* @param amount the amount of tokens being transferred
158-
*/
159-
function _beforeTokenTransfer(address from, address to, uint256 amount) internal override {
160-
// if transfer restrictions are enabled
161-
if (block.timestamp <= transferRestrictionsDisabledAfter) {
162-
// if both from and to are not whitelisted
163-
require(
164-
from == address(0) || to == address(0) || allowedFrom[from] || allowedTo[to],
165-
"Eigen._beforeTokenTransfer: from or to must be whitelisted"
166-
);
167-
}
168-
super._beforeTokenTransfer(from, to, amount);
169-
}
170-
171111
/**
172112
* @notice Overridden to return the total bEIGEN supply instead.
173113
* @dev The issued supply of EIGEN should match the bEIGEN balance of this contract,

src/test/harnesses/EigenHarness.sol

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,4 @@ contract EigenHarness is Eigen {
1010
function mint(address to, uint amount) public {
1111
_mint(to, amount);
1212
}
13-
14-
/**
15-
* @notice This function allows the owner to set the allowedFrom status of an address
16-
* @param from the address whose allowedFrom status is being set
17-
* @param isAllowedFrom the new allowedFrom status
18-
* @dev this function is callable by anoyone in the harness
19-
*/
20-
function setAllowedFromPermissionless(address from, bool isAllowedFrom) external {
21-
allowedFrom[from] = isAllowedFrom;
22-
emit SetAllowedFrom(from, isAllowedFrom);
23-
}
24-
25-
function setTransferRestrictionsDisabledAfterToMax() external {
26-
transferRestrictionsDisabledAfter = type(uint).max;
27-
}
28-
29-
function transferOwnershipPermissionless(address newOwner) external {
30-
_transferOwnership(newOwner);
31-
}
3213
}

src/test/token/EigenTransferRestrictions.t.sol

Lines changed: 0 additions & 188 deletions
This file was deleted.

src/test/token/EigenWrapping.t.sol

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,6 @@ contract EigenWrappingTests is Test {
184184
// dummy mint
185185
EigenHarness(address(eigen)).mint(minter1, totalSupply / 2);
186186
EigenHarness(address(eigen)).mint(minter2, totalSupply / 2);
187-
188-
// set allowed froms
189-
EigenHarness(address(eigen)).setAllowedFromPermissionless(minter1, true);
190-
EigenHarness(address(eigen)).setAllowedFromPermissionless(minter2, true);
191-
192-
// set transfer restrictions to be disabled after to max
193-
EigenHarness(address(eigen)).setTransferRestrictionsDisabledAfterToMax();
194-
195-
// set owner to minter1
196-
EigenHarness(address(eigen)).transferOwnershipPermissionless(minter1);
197187
}
198188

199189
function _simulateBackingAndSetTransferRestrictions() internal {

0 commit comments

Comments
 (0)