Skip to content

Commit 5039fe0

Browse files
committed
feat: remove transfer restriction function from backing eigen (#1245)
**Motivation:** per ELIP-5, remove transfer restriction function from backing eigen **Modifications:** remove transfer restriction function from backing eigen **Result:** remove transfer restriction function from backing eigen
1 parent e2a04dc commit 5039fe0

File tree

3 files changed

+19
-102
lines changed

3 files changed

+19
-102
lines changed

src/contracts/token/BackingEigen.sol

Lines changed: 7 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,19 @@ contract BackingEigen is OwnableUpgradeable, ERC20VotesUpgradeable {
1111
IERC20 public immutable EIGEN;
1212

1313
/// STORAGE
14+
/// @dev Do not remove, deprecated storage.
1415
/// @notice the timestamp after which transfer restrictions are disabled
15-
uint256 public transferRestrictionsDisabledAfter;
16+
uint256 internal __dreprecated_transferRestrictionsDisabledAfter;
17+
/// @dev Do not remove, deprecated storage.
1618
/// @notice mapping of addresses that are allowed to transfer tokens to any address
17-
mapping(address => bool) public allowedFrom;
19+
mapping(address => bool) internal __dreprecated_allowedFrom;
20+
/// @dev Do not remove, deprecated storage.
1821
/// @notice mapping of addresses that are allowed to receive tokens from any address
19-
mapping(address => bool) public allowedTo;
22+
mapping(address => bool) internal __dreprecated_allowedTo;
23+
2024
// @notice whether or not an address is allowed to mint new bEIGEN tokens
2125
mapping(address => bool) public isMinter;
2226

23-
/// @notice event emitted when the allowedFrom status of an address is set
24-
event SetAllowedFrom(address indexed from, bool isAllowedFrom);
25-
/// @notice event emitted when the allowedTo status of an address is set
26-
event SetAllowedTo(address indexed to, bool isAllowedTo);
27-
/// @notice event emitted when the transfer restrictions are disabled
28-
event TransferRestrictionsDisabled();
29-
/// @notice event emitted when the EIGEN token is backed
3027
event Backed();
3128
// @notice event emitted when the `isMinter` mapping is modified
3229
event IsMinterModified(address indexed minterAddress, bool newStatus);
@@ -75,52 +72,12 @@ contract BackingEigen is OwnableUpgradeable, ERC20VotesUpgradeable {
7572
_transferOwnership(initialOwner);
7673
__ERC20Permit_init("bEIGEN");
7774

78-
// set transfer restrictions to be disabled at type(uint256).max to be set down later
79-
transferRestrictionsDisabledAfter = type(uint256).max;
80-
81-
// the EIGEN contract should be allowed to transfer tokens to any address for unwrapping
82-
// likewise, anyone should be able to transfer bEIGEN to EIGEN for wrapping
83-
_setAllowedFrom(address(EIGEN), true);
84-
_setAllowedTo(address(EIGEN), true);
85-
8675
// Mint the entire supply of EIGEN - this is a one-time event that
8776
// ensures bEIGEN fully backs EIGEN.
8877
_mint(address(EIGEN), 1_673_646_668_284_660_000_000_000_000);
8978
emit Backed();
9079
}
9180

92-
/// EXTERNAL FUNCTIONS
93-
94-
/**
95-
* @notice This function allows the owner to set the allowedFrom status of an address
96-
* @param from the address whose allowedFrom status is being set
97-
* @param isAllowedFrom the new allowedFrom status
98-
*/
99-
function setAllowedFrom(address from, bool isAllowedFrom) external onlyOwner {
100-
_setAllowedFrom(from, isAllowedFrom);
101-
}
102-
103-
/**
104-
* @notice This function allows the owner to set the allowedTo status of an address
105-
* @param to the address whose allowedTo status is being set
106-
* @param isAllowedTo the new allowedTo status
107-
*/
108-
function setAllowedTo(address to, bool isAllowedTo) external onlyOwner {
109-
_setAllowedTo(to, isAllowedTo);
110-
}
111-
112-
/**
113-
* @notice Allows the owner to disable transfer restrictions
114-
*/
115-
function disableTransferRestrictions() external onlyOwner {
116-
require(
117-
transferRestrictionsDisabledAfter == type(uint256).max,
118-
"BackingEigen.disableTransferRestrictions: transfer restrictions are already disabled"
119-
);
120-
transferRestrictionsDisabledAfter = 0;
121-
emit TransferRestrictionsDisabled();
122-
}
123-
12481
/// VIEW FUNCTIONS
12582

12683
/**
@@ -139,34 +96,4 @@ contract BackingEigen is OwnableUpgradeable, ERC20VotesUpgradeable {
13996
function CLOCK_MODE() public pure override returns (string memory) {
14097
return "mode=timestamp";
14198
}
142-
143-
/// INTERNAL FUNCTIONS
144-
145-
function _setAllowedFrom(address from, bool isAllowedFrom) internal {
146-
allowedFrom[from] = isAllowedFrom;
147-
emit SetAllowedFrom(from, isAllowedFrom);
148-
}
149-
150-
function _setAllowedTo(address to, bool isAllowedTo) internal {
151-
allowedTo[to] = isAllowedTo;
152-
emit SetAllowedTo(to, isAllowedTo);
153-
}
154-
155-
/**
156-
* @notice Overrides the beforeTokenTransfer function to enforce transfer restrictions
157-
* @param from the address tokens are being transferred from
158-
* @param to the address tokens are being transferred to
159-
* @param amount the amount of tokens being transferred
160-
*/
161-
function _beforeTokenTransfer(address from, address to, uint256 amount) internal override {
162-
// if transfer restrictions are enabled
163-
if (block.timestamp <= transferRestrictionsDisabledAfter) {
164-
// if both from and to are not whitelisted
165-
require(
166-
allowedFrom[from] || allowedTo[to] || from == address(0),
167-
"BackingEigen._beforeTokenTransfer: from or to must be whitelisted"
168-
);
169-
}
170-
super._beforeTokenTransfer(from, to, amount);
171-
}
17299
}

src/test/token/EigenWrapping.t.sol

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,8 @@ contract EigenWrappingTests is Test {
2626
uint totalSupply = 1.67e9 ether;
2727

2828
// EVENTS FROM EIGEN.sol
29-
/// @notice event emitted when the allowedFrom status of an address is set
30-
event SetAllowedFrom(address indexed from, bool isAllowedFrom);
31-
/// @notice event emitted when the allowedTo status of an address is set
32-
event SetAllowedTo(address indexed to, bool isAllowedTo);
3329
/// @notice event emitted when a minter mints
3430
event Mint(address indexed minter, uint amount);
35-
/// @notice event emitted when the transfer restrictions are disabled
36-
event TransferRestrictionsDisabled();
3731

3832
modifier filterAddress(address fuzzedAddress) {
3933
vm.assume(!fuzzedOutAddresses[fuzzedAddress]);
@@ -70,7 +64,9 @@ contract EigenWrappingTests is Test {
7064
vm.assume(unwrapper != address(0));
7165

7266
_simulateMint();
73-
_simulateBackingAndSetTransferRestrictions();
67+
68+
// initialize bEIGEN
69+
bEIGEN.initialize(minter1);
7470

7571
// minter1 balance
7672
uint minter1Balance = eigen.balanceOf(minter1);
@@ -105,7 +101,9 @@ contract EigenWrappingTests is Test {
105101
vm.assume(wrapper != address(0));
106102

107103
_simulateMint();
108-
_simulateBackingAndSetTransferRestrictions();
104+
105+
// initialize bEIGEN
106+
bEIGEN.initialize(minter1);
109107

110108
// initial bEIGEN balance
111109
uint initialBEIGENBalanceOfEigenToken = bEIGEN.balanceOf(address(eigen));
@@ -142,7 +140,9 @@ contract EigenWrappingTests is Test {
142140

143141
function test_CannotUnwrapMoreThanBalance(address unwrapper, uint unwrapAmount) public filterAddress(unwrapper) {
144142
_simulateMint();
145-
_simulateBackingAndSetTransferRestrictions();
143+
144+
// initialize bEIGEN
145+
bEIGEN.initialize(minter1);
146146

147147
// unwrap amount should be less than minter1 balance
148148
unwrapAmount = unwrapAmount % eigen.balanceOf(minter1);
@@ -159,7 +159,9 @@ contract EigenWrappingTests is Test {
159159

160160
function test_CannotWrapMoreThanBalance(address wrapper, uint wrapAmount) public filterAddress(wrapper) {
161161
_simulateMint();
162-
_simulateBackingAndSetTransferRestrictions();
162+
163+
// initialize bEIGEN
164+
bEIGEN.initialize(minter1);
163165

164166
// wrap amount should be less than minter1 balance
165167
wrapAmount = wrapAmount % eigen.balanceOf(minter1);
@@ -185,12 +187,4 @@ contract EigenWrappingTests is Test {
185187
EigenHarness(address(eigen)).mint(minter1, totalSupply / 2);
186188
EigenHarness(address(eigen)).mint(minter2, totalSupply / 2);
187189
}
188-
189-
function _simulateBackingAndSetTransferRestrictions() internal {
190-
bEIGEN.initialize(minter1);
191-
192-
vm.startPrank(minter1);
193-
bEIGEN.setAllowedFrom(minter1, true);
194-
vm.stopPrank();
195-
}
196190
}

src/test/token/bEIGEN.t.sol

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ contract bEIGENTest is Test {
4848

4949
// check that the owner is initialOwner
5050
assertEq(bEIGEN.owner(), initialOwner);
51-
// check the transfer restrictions are disabled after one year in the future
52-
assertEq(bEIGEN.transferRestrictionsDisabledAfter(), type(uint).max);
5351
}
5452

5553
function testFuzz_CanBackTheEigenToken(uint eigenSupply) public {
@@ -89,8 +87,6 @@ contract bEIGENTest is Test {
8987

9088
function test_burn() public {
9189
test_setIsMinterAndMint();
92-
vm.prank(initialOwner);
93-
bEIGEN.setAllowedFrom(mintTo, true);
9490

9591
uint amountToBurn = 1005e18;
9692
uint balanceBefore = bEIGEN.balanceOf(mintTo);

0 commit comments

Comments
 (0)