Skip to content

Commit c38aa29

Browse files
committed
feat: add TokenWrapped and TokenUnwrapped events in Eigen for observability (#1331)
**Motivation:** add TokenWrapped and TokenUnwrapped events in Eigen for observability **Modifications:** add TokenWrapped and TokenUnwrapped events in Eigen add corresponding tests **Result:** we can track wrapping/unwrapping actions between Eigen and BackingEigen
1 parent 2de8ed1 commit c38aa29

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/contracts/token/Eigen.sol

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ contract Eigen is OwnableUpgradeable, ERC20VotesUpgradeable {
2727
/// @notice mapping of addresses that are allowed to receive tokens from any address
2828
mapping(address => bool) internal __deprecated_allowedTo;
2929

30+
/// EVENTS
31+
/// @notice Emitted when bEIGEN tokens are wrapped into EIGEN
32+
event TokenWrapped(address indexed account, uint256 amount);
33+
/// @notice Emitted when EIGEN tokens are unwrapped into bEIGEN
34+
event TokenUnwrapped(address indexed account, uint256 amount);
35+
3036
constructor(
3137
IERC20 _bEIGEN
3238
) {
@@ -54,6 +60,7 @@ contract Eigen is OwnableUpgradeable, ERC20VotesUpgradeable {
5460
) external {
5561
require(bEIGEN.transferFrom(msg.sender, address(this), amount), "Eigen.wrap: bEIGEN transfer failed");
5662
_mint(msg.sender, amount);
63+
emit TokenWrapped(msg.sender, amount);
5764
}
5865

5966
/**
@@ -64,6 +71,7 @@ contract Eigen is OwnableUpgradeable, ERC20VotesUpgradeable {
6471
) external {
6572
_burn(msg.sender, amount);
6673
require(bEIGEN.transfer(msg.sender, amount), "Eigen.unwrap: bEIGEN transfer failed");
74+
emit TokenUnwrapped(msg.sender, amount);
6775
}
6876

6977
/**

src/test/token/EigenWrapping.t.sol

+16-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ contract EigenWrappingTests is Test {
2929
/// @notice event emitted when a minter status is modified
3030
event IsMinterModified(address indexed minterAddress, bool newStatus);
3131

32+
// EVENTS FROM Eigen.sol
33+
/// @notice event emitted when bEIGEN tokens are wrapped into EIGEN
34+
event TokenWrapped(address indexed account, uint amount);
35+
/// @notice event emitted when EIGEN tokens are unwrapped into bEIGEN
36+
event TokenUnwrapped(address indexed account, uint amount);
37+
3238
modifier filterAddress(address fuzzedAddress) {
3339
vm.assume(!fuzzedOutAddresses[fuzzedAddress]);
3440
_;
@@ -54,11 +60,11 @@ contract EigenWrappingTests is Test {
5460
bEIGEN.initialize(minter1);
5561

5662
// set minters (for future minting if needed)
57-
vm.expectEmit(true, false, false, false);
63+
vm.expectEmit(true, true, true, true);
5864
emit IsMinterModified(minter1, true);
5965
bEIGEN.setIsMinter(minter1, true);
6066

61-
vm.expectEmit(true, false, false, false);
67+
vm.expectEmit(true, true, true, true);
6268
emit IsMinterModified(minter2, true);
6369
bEIGEN.setIsMinter(minter2, true);
6470

@@ -69,13 +75,17 @@ contract EigenWrappingTests is Test {
6975
vm.startPrank(minter1);
7076
bEIGEN.mint(minter1, totalSupply / 2);
7177
bEIGEN.approve(address(eigen), totalSupply / 2);
78+
vm.expectEmit(true, true, true, true);
79+
emit TokenWrapped(minter1, totalSupply / 2);
7280
eigen.wrap(totalSupply / 2);
7381
vm.stopPrank();
7482

7583
// Mint and wrap tokens for minter2
7684
vm.startPrank(minter2);
7785
bEIGEN.mint(minter2, totalSupply / 2);
7886
bEIGEN.approve(address(eigen), totalSupply / 2);
87+
vm.expectEmit(true, true, true, true);
88+
emit TokenWrapped(minter2, totalSupply / 2);
7989
eigen.wrap(totalSupply / 2);
8090
vm.stopPrank();
8191

@@ -106,6 +116,8 @@ contract EigenWrappingTests is Test {
106116
// unwrap amount should be less than minter1 balance
107117
unwrapAmount = unwrapAmount % minter1Balance;
108118
vm.prank(unwrapper);
119+
vm.expectEmit(true, false, false, false);
120+
emit TokenUnwrapped(unwrapper, unwrapAmount);
109121
eigen.unwrap(unwrapAmount);
110122

111123
// check total supply and balance changes
@@ -145,6 +157,8 @@ contract EigenWrappingTests is Test {
145157
// approve bEIGEN
146158
bEIGEN.approve(address(eigen), wrapAmount);
147159
// wrap
160+
vm.expectEmit(true, false, false, false);
161+
emit TokenWrapped(wrapper, wrapAmount);
148162
eigen.wrap(wrapAmount);
149163
vm.stopPrank();
150164

0 commit comments

Comments
 (0)