From 89585dcfee1a55207136eed34be7bb6d4ccb84d0 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 10 Apr 2024 12:18:01 +0200 Subject: [PATCH] Releasing deposit in full from Mezo 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. --- core/contracts/MezoAllocator.sol | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/contracts/MezoAllocator.sol b/core/contracts/MezoAllocator.sol index edf078132..e47fed42f 100644 --- a/core/contracts/MezoAllocator.sol +++ b/core/contracts/MezoAllocator.sol @@ -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. @@ -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 {