Skip to content

Commit

Permalink
chore: update bridger to manager role
Browse files Browse the repository at this point in the history
  • Loading branch information
blockgroot committed Jul 9, 2024
1 parent ac52ee9 commit 5035a3f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
18 changes: 9 additions & 9 deletions contracts/L2/ETHxPoolV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ interface AggregatorV3Interface {
contract ETHxPoolV1 is AccessControlUpgradeable, ReentrancyGuardUpgradeable {
using SafeERC20 for IERC20;

/// @notice Role hash of BRIDGER
bytes32 public constant BRIDGER_ROLE = keccak256("BRIDGER_ROLE");
/// @notice Role hash of MANAGER
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
/// @notice Conversion factor from ether to wei
uint256 public constant ETHER_TO_WEI = 1e18;
/// @notice Address of ETHx token
Expand Down Expand Up @@ -63,13 +63,13 @@ contract ETHxPoolV1 is AccessControlUpgradeable, ReentrancyGuardUpgradeable {

/// @dev Initialize the contract
/// @param _admin The admin address
/// @param _bridger The bridger address
/// @param _manager The manager address
/// @param _ethx The ETHx token address
/// @param _feeBps The fee basis points
/// @param _ethxOracle The ethxOracle address
function initialize(
address _admin,
address _bridger,
address _manager,
address _ethx,
uint256 _feeBps,
address _ethxOracle
Expand All @@ -84,8 +84,8 @@ contract ETHxPoolV1 is AccessControlUpgradeable, ReentrancyGuardUpgradeable {
__ReentrancyGuard_init();

_grantRole(DEFAULT_ADMIN_ROLE, _admin);
_setupRole(BRIDGER_ROLE, _bridger);
_setupRole(BRIDGER_ROLE, _admin);
_setupRole(MANAGER_ROLE, _manager);
_setupRole(MANAGER_ROLE, _admin);

ETHx = IERC20(_ethx);
feeBps = _feeBps;
Expand Down Expand Up @@ -127,7 +127,7 @@ contract ETHxPoolV1 is AccessControlUpgradeable, ReentrancyGuardUpgradeable {
//////////////////////////////////////////////////////////////*/

/// @dev Withdraws fees earned by the pool
function withdrawFees(address _receiver) external onlyRole(BRIDGER_ROLE) {
function withdrawFees(address _receiver) external onlyRole(MANAGER_ROLE) {
// withdraw fees in ETH
uint256 amountToSendInETH = feeEarnedInETH;
feeEarnedInETH = 0;
Expand All @@ -138,7 +138,7 @@ contract ETHxPoolV1 is AccessControlUpgradeable, ReentrancyGuardUpgradeable {
}

/// @dev Withdraws collected ETH from the contract
function withdrawCollectedETH() external onlyRole(DEFAULT_ADMIN_ROLE) {
function withdrawCollectedETH() external onlyRole(MANAGER_ROLE) {
// withdraw ETH - fees
uint256 ethBalanceMinusFees = address(this).balance - feeEarnedInETH;

Expand All @@ -149,7 +149,7 @@ contract ETHxPoolV1 is AccessControlUpgradeable, ReentrancyGuardUpgradeable {
}

/// @dev Withdraws provisioned ETHx
function withdrawETHx(uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) {
function withdrawETHx(uint256 amount) external onlyRole(MANAGER_ROLE) {
if (amount > ETHx.balanceOf(address(this))) revert InvalidAmount();

ETHx.safeTransfer(msg.sender, amount);
Expand Down
20 changes: 10 additions & 10 deletions test/L2/ETHxPoolV1.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contract ETHxPoolV1Test is Test {
uint256 private constant ETHX_RATE = 1 ether;
uint256 private constant FEE_BPS = 1000;
address private admin;
address private bridger;
address private manager;

address private oracle;
address private ETHx;
Expand All @@ -20,20 +20,20 @@ contract ETHxPoolV1Test is Test {
function setUp() public {
vm.clearMockedCalls();
admin = vm.addr(0x100);
bridger = vm.addr(0x101);
manager = vm.addr(0x101);
address pool = vm.addr(0x1000);

ETHx = vm.addr(0x1001);
oracle = vm.addr(0x1004);
mockRateOracle(oracle);
mockErc20(ETHx, "ETHx");

eTHxPoolV1 = mockETHxPoolV1(pool, admin, bridger, ETHx, FEE_BPS, oracle);
eTHxPoolV1 = mockETHxPoolV1(pool, admin, manager, ETHx, FEE_BPS, oracle);
}

function testInitialization() public {
assertEq(address(eTHxPoolV1.ETHx()), ETHx);
assertTrue(eTHxPoolV1.hasRole(keccak256("BRIDGER_ROLE"), bridger));
assertTrue(eTHxPoolV1.hasRole(keccak256("MANAGER_ROLE"), manager));
assertTrue(eTHxPoolV1.hasRole(0x0, admin));
}

Expand Down Expand Up @@ -138,14 +138,14 @@ contract ETHxPoolV1Test is Test {
assertEq(ERC20Mock(ETHx).balanceOf(user), expectedBalance);
(, uint256 feeAmnt) = eTHxPoolV1.viewSwapETHxAmountAndFee(ethAmount);
address _owner = vm.addr(0x111);
vm.prank(bridger);
vm.prank(manager);
eTHxPoolV1.withdrawFees(_owner);
assertEq(_owner.balance, feeAmnt);
}

function testWithdrawFeesRequiresBridgerRole() public {
function testWithdrawFeesRequiresManagerRole() public {
vm.expectRevert(
"AccessControl: account 0x7fa9385be102ac3eac297483dd6233d62b3e1496 is missing role 0xc809a7fd521f10cdc3c068621a1c61d5fd9bb3f1502a773e53811bc248d919a8"
"AccessControl: account 0x7fa9385be102ac3eac297483dd6233d62b3e1496 is missing role 0x241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b08"
);
eTHxPoolV1.withdrawFees(vm.addr(0x111));
}
Expand All @@ -166,7 +166,7 @@ contract ETHxPoolV1Test is Test {

function testWithdrawETHxRequireAdminRole(uint256 ethxAmount) public {
vm.expectRevert(
"AccessControl: account 0x7fa9385be102ac3eac297483dd6233d62b3e1496 is missing role 0x0000000000000000000000000000000000000000000000000000000000000000"
"AccessControl: account 0x7fa9385be102ac3eac297483dd6233d62b3e1496 is missing role 0x241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b08"
);
eTHxPoolV1.withdrawETHx(ethxAmount);
}
Expand Down Expand Up @@ -214,7 +214,7 @@ contract ETHxPoolV1Test is Test {
function mockETHxPoolV1(
address ethxPool,
address _admin,
address _bridger,
address _manager,
address _ETHx,
uint256 _feeBps,
address _ethxOracle
Expand All @@ -224,7 +224,7 @@ contract ETHxPoolV1Test is Test {
{
mockProxyDeploy(ethxPool);
ETHxPoolV1 mock = ETHxPoolV1(ethxPool);
mock.initialize(_admin, _bridger, _ETHx, _feeBps, _ethxOracle);
mock.initialize(_admin, _manager, _ETHx, _feeBps, _ethxOracle);
return mock;
}
}

0 comments on commit 5035a3f

Please sign in to comment.