Skip to content

Commit 0421543

Browse files
committed
add events to EulerSwapProtocolFeeConfig on admin actions
Spearbit #6
1 parent 9f5a227 commit 0421543

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/EulerSwapProtocolFeeConfig.sol

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,18 @@ contract EulerSwapProtocolFeeConfig is IEulerSwapProtocolFeeConfig, EVCUtil {
3232
error InvalidProtocolFee();
3333
error InvalidProtocolFeeRecipient();
3434

35+
/// @notice Emitted when admin is set/changed
36+
event AdminUpdated(address indexed oldAdmin, address indexed newAdmin);
37+
/// @notice Emitted when the default configuration is changed
38+
event DefaultUpdated(address indexed oldRecipient, address indexed newRecipient, uint64 oldFee, uint64 newFee);
39+
/// @notice Emitted when a per-pool override is created or changed
40+
event OverrideSet(address indexed pool, address indexed recipient, uint64 fee);
41+
/// @notice Emitted when a per-pool override is removed (and thus falls back to the default)
42+
event OverrideRemoved(address indexed pool);
43+
3544
constructor(address evc, address admin_) EVCUtil(evc) {
45+
emit AdminUpdated(address(0), admin_);
46+
3647
admin = admin_;
3748
}
3849

@@ -47,6 +58,8 @@ contract EulerSwapProtocolFeeConfig is IEulerSwapProtocolFeeConfig, EVCUtil {
4758

4859
/// @inheritdoc IEulerSwapProtocolFeeConfig
4960
function setAdmin(address newAdmin) external onlyAdmin {
61+
emit AdminUpdated(admin, newAdmin);
62+
5063
admin = newAdmin;
5164
}
5265

@@ -55,6 +68,8 @@ contract EulerSwapProtocolFeeConfig is IEulerSwapProtocolFeeConfig, EVCUtil {
5568
require(fee <= MAX_PROTOCOL_FEE, InvalidProtocolFee());
5669
require(fee == 0 || recipient != address(0), InvalidProtocolFeeRecipient());
5770

71+
emit DefaultUpdated(defaultRecipient, recipient, defaultFee, fee);
72+
5873
defaultRecipient = recipient;
5974
defaultFee = fee;
6075
}
@@ -63,11 +78,15 @@ contract EulerSwapProtocolFeeConfig is IEulerSwapProtocolFeeConfig, EVCUtil {
6378
function setOverride(address pool, address recipient, uint64 fee) external onlyAdmin {
6479
require(fee <= MAX_PROTOCOL_FEE, InvalidProtocolFee());
6580

81+
emit OverrideSet(pool, recipient, fee);
82+
6683
overrides[pool] = Override({exists: true, recipient: recipient, fee: fee});
6784
}
6885

6986
/// @inheritdoc IEulerSwapProtocolFeeConfig
7087
function removeOverride(address pool) external onlyAdmin {
88+
emit OverrideRemoved(pool);
89+
7190
delete overrides[pool];
7291
}
7392

test/Fees.t.sol

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ contract FeesTest is EulerSwapTestBase {
238238

239239
// Override
240240

241+
vm.expectEmit(true, true, true, true);
242+
emit EulerSwapProtocolFeeConfig.OverrideSet(address(eulerSwap), address(9999), 0.07e18);
241243
vm.prank(protocolFeeAdmin);
242244
protocolFeeConfig.setOverride(address(eulerSwap), address(9999), 0.07e18);
243245

@@ -271,6 +273,8 @@ contract FeesTest is EulerSwapTestBase {
271273

272274
// Remove override
273275

276+
vm.expectEmit(true, true, true, true);
277+
emit EulerSwapProtocolFeeConfig.OverrideRemoved(address(eulerSwap));
274278
vm.prank(protocolFeeAdmin);
275279
protocolFeeConfig.removeOverride(address(eulerSwap));
276280

@@ -293,17 +297,28 @@ contract FeesTest is EulerSwapTestBase {
293297
}
294298

295299
function test_fees_protocolFees_setAdmin() public {
296-
assertEq(protocolFeeConfig.admin(), protocolFeeAdmin);
300+
address origAdmin = protocolFeeConfig.admin();
301+
assertEq(origAdmin, protocolFeeAdmin);
297302

298303
vm.expectRevert(EulerSwapProtocolFeeConfig.Unauthorized.selector);
299304
protocolFeeConfig.setDefault(address(8888), 0.1e18);
300305

306+
vm.expectEmit(true, true, true, true);
307+
emit EulerSwapProtocolFeeConfig.AdminUpdated(origAdmin, address(this));
301308
vm.prank(protocolFeeAdmin);
302309
protocolFeeConfig.setAdmin(address(this));
303310

304311
assertEq(protocolFeeConfig.admin(), address(this));
312+
}
305313

306-
protocolFeeConfig.setDefault(address(8888), 0.1e18);
314+
function test_fees_protocolFees_defaults() public {
315+
address origFefaultRecipient = protocolFeeConfig.defaultRecipient();
316+
uint64 origDefaultFee = protocolFeeConfig.defaultFee();
317+
318+
vm.expectEmit(true, true, true, true);
319+
emit EulerSwapProtocolFeeConfig.DefaultUpdated(origFefaultRecipient, address(7654), origDefaultFee, 0.071e18);
320+
vm.prank(protocolFeeAdmin);
321+
protocolFeeConfig.setDefault(address(7654), 0.071e18);
307322
}
308323

309324
function test_fuzzFeeRounding(uint256 amount, uint256 fee) public pure {

0 commit comments

Comments
 (0)