Skip to content

Commit

Permalink
feat: revert when swap fee is too high
Browse files Browse the repository at this point in the history
  • Loading branch information
blockgroot committed Jul 11, 2024
1 parent e748057 commit 0a19155
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions contracts/L2/ETHxPoolV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ contract ETHxPoolV1 is AccessControlUpgradeable, ReentrancyGuardUpgradeable {
error InvalidAmount();
/// @dev Thrown when input is invalid basis fee
error InvalidBps();
/// @dev Thrown when input fee is too high
error HighFees();
/// @dev Thrown when transfer is failed
error TransferFailed();

Expand Down Expand Up @@ -161,6 +163,7 @@ contract ETHxPoolV1 is AccessControlUpgradeable, ReentrancyGuardUpgradeable {
/// @param _feeBps The fee basis points
function setFeeBps(uint256 _feeBps) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (_feeBps > 10_000) revert InvalidBps();
if (_feeBps > 1000) revert HighFees();

feeBps = _feeBps;

Expand Down
7 changes: 7 additions & 0 deletions test/L2/ETHxPoolV1.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ contract ETHxPoolV1Test is Test {
eTHxPoolV1.setFeeBps(feeBps);
}

function testSetFeeHighFees(uint256 feeBps) public {
vm.assume(feeBps > 1000 && feeBps <= 10_000);
vm.prank(admin);
vm.expectRevert(abi.encodeWithSelector(ETHxPoolV1.HighFees.selector));
eTHxPoolV1.setFeeBps(feeBps);
}

function testSetFeeAdminRequired() public {
address nonAdmin = vm.addr(0x102);
vm.prank(nonAdmin);
Expand Down

0 comments on commit 0a19155

Please sign in to comment.