Skip to content

Commit

Permalink
Releasing deposit in full from Mezo
Browse files Browse the repository at this point in the history
In case there will be a need of pulling all the funds from Mezo we add a
releaseDeposit function that can be called by the owner only.
  • Loading branch information
dimpar committed Apr 10, 2024
1 parent 74c8cc8 commit 89585dc
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/contracts/MezoAllocator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ contract MezoAllocator is IDispatcher, Ownable2Step {
event MaintainerAdded(address indexed maintainer);
/// @notice Emitted when the maintainer address is updated.
event MaintainerRemoved(address indexed maintainer);
/// @notice Emitted when tBTC is released from MezoPortal.
event DepositReleased(uint256 indexed depositId, uint256 amount);
/// @notice Reverts if the caller is not an authorized account.
error NotAuthorized();
/// @notice Reverts if the caller is not a maintainer.
Expand Down Expand Up @@ -178,6 +180,18 @@ contract MezoAllocator is IDispatcher, Ownable2Step {
tbtc.safeTransfer(address(stbtc), amount);
}

/// @notice Releases deposit in full from MezoPortal.
function releaseDeposit() external onlyOwner {
uint96 amount = mezoPortal
.getDeposit(address(this), address(tbtc), depositId)
.balance;

emit DepositReleased(depositId, amount);
depositBalance = 0;
mezoPortal.withdraw(address(tbtc), depositId, amount);
tbtc.safeTransfer(address(stbtc), tbtc.balanceOf(address(this)));
}

/// @notice Updates the maintainer address.
/// @param maintainerToAdd Address of the new maintainer.
function addMaintainer(address maintainerToAdd) external onlyOwner {
Expand Down

0 comments on commit 89585dc

Please sign in to comment.