Skip to content

Commit

Permalink
Replacing withdrawer role with hardcoded stBTC contract
Browse files Browse the repository at this point in the history
  • Loading branch information
dimpar committed Apr 8, 2024
1 parent d7fafb3 commit 4a3eb9d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 61 deletions.
27 changes: 2 additions & 25 deletions core/contracts/MezoAllocator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ contract MezoAllocator is Ownable2Step {
stBTC public immutable stbtc;
/// @notice Maintainer address which can trigger deposit flow.
address public maintainer;
/// @notice Address that can withdraw tBTC from Mezo Portal.
address public withdrawer;
/// @notice keeps track of the latest deposit ID assigned in Mezo Portal.
uint256 public depositId;

Expand All @@ -58,9 +56,6 @@ contract MezoAllocator is Ownable2Step {
/// @notice Emitted when the maintainer address is updated.
event MaintainerUpdated(address indexed maintainer);

/// @notice Emitted when the withdrawer address is updated.
event WithdrawerUpdated(address indexed withdrawer);

/// @notice Reverts if the caller is not an authorized account.
error NotAuthorized();

Expand All @@ -74,13 +69,6 @@ contract MezoAllocator is Ownable2Step {
_;
}

modifier onlyWithdrawer() {
if (msg.sender != withdrawer) {
revert NotAuthorized();
}
_;
}

/// @notice Initializes the MezoAllocator contract.
/// @param _mezoPortal Address of the MezoPortal contract.
/// @param _tbtc Address of the tBTC token contract.
Expand Down Expand Up @@ -142,7 +130,8 @@ contract MezoAllocator is Ownable2Step {
/// This function can withdraw partial or a full amount of tBTC from
/// MezoPortal for a given deposit id.
/// @param amount Amount of tBTC to withdraw.
function withdraw(uint256 amount) external onlyWithdrawer {
function withdraw(uint256 amount) external {
if (msg.sender != address(stbtc)) revert NotAuthorized();
uint96 balance = mezoPortal
.getDeposit(address(this), address(tbtc), depositId)
.balance;
Expand All @@ -165,22 +154,10 @@ contract MezoAllocator is Ownable2Step {
emit MaintainerUpdated(_maintainer);
}

/// @notice Updates the withdrawer address.
/// @param _withdrawer Address of the new withdrawer.
function updateWithdrawer(address _withdrawer) external onlyOwner {
if (_withdrawer == address(0)) {
revert ZeroAddress();
}
withdrawer = _withdrawer;

emit WithdrawerUpdated(_withdrawer);
}

/// @notice Returns the total amount of tBTC allocated to MezoPortal.
function totalAssets()
external
view
override
returns (uint256 totalAmount)
{
return
Expand Down
26 changes: 0 additions & 26 deletions core/deploy/14_mezo_allocator_update_withdrawer.ts

This file was deleted.

10 changes: 0 additions & 10 deletions core/test/Deployment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,5 @@ describe("Deployment", () => {
})
})
})

describe("updateWithdrawer", () => {
context("when a new withdrawer has been set", () => {
it("should be set to a new maintainer address", async () => {
const actualWithdrawer = await mezoAllocator.withdrawer()

expect(actualWithdrawer).to.be.equal(await stbtc.getAddress())
})
})
})
})
})

0 comments on commit 4a3eb9d

Please sign in to comment.