Skip to content

Commit 9f5a227

Browse files
committed
prevent protocol fee recipient from being address(0) when protocol fee is non-zero
Spearbit #5
1 parent f7528db commit 9f5a227

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/EulerSwapProtocolFeeConfig.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ contract EulerSwapProtocolFeeConfig is IEulerSwapProtocolFeeConfig, EVCUtil {
3030

3131
error Unauthorized();
3232
error InvalidProtocolFee();
33+
error InvalidProtocolFeeRecipient();
3334

3435
constructor(address evc, address admin_) EVCUtil(evc) {
3536
admin = admin_;
@@ -52,6 +53,7 @@ contract EulerSwapProtocolFeeConfig is IEulerSwapProtocolFeeConfig, EVCUtil {
5253
/// @inheritdoc IEulerSwapProtocolFeeConfig
5354
function setDefault(address recipient, uint64 fee) external onlyAdmin {
5455
require(fee <= MAX_PROTOCOL_FEE, InvalidProtocolFee());
56+
require(fee == 0 || recipient != address(0), InvalidProtocolFeeRecipient());
5557

5658
defaultRecipient = recipient;
5759
defaultFee = fee;

test/Fees.t.sol

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ contract FeesTest is EulerSwapTestBase {
221221
vm.expectRevert(EulerSwapProtocolFeeConfig.InvalidProtocolFee.selector);
222222
protocolFeeConfig.setDefault(address(8888), 0.15000001e18);
223223

224+
vm.prank(protocolFeeAdmin);
225+
vm.expectRevert(EulerSwapProtocolFeeConfig.InvalidProtocolFeeRecipient.selector);
226+
protocolFeeConfig.setDefault(address(0), 0.1e18);
227+
224228
// Set a default
225229

226230
vm.prank(protocolFeeAdmin);
@@ -275,6 +279,17 @@ contract FeesTest is EulerSwapTestBase {
275279
assertEq(recipient, address(7777));
276280
assertEq(fee, 0.12e18);
277281
}
282+
283+
// Change override back to 0s
284+
285+
vm.prank(protocolFeeAdmin);
286+
protocolFeeConfig.setDefault(address(0), 0);
287+
288+
{
289+
(address recipient, uint64 fee) = protocolFeeConfig.getProtocolFee(address(eulerSwap));
290+
assertEq(recipient, address(0));
291+
assertEq(fee, 0);
292+
}
278293
}
279294

280295
function test_fees_protocolFees_setAdmin() public {

0 commit comments

Comments
 (0)