Skip to content

Commit

Permalink
Smaller refactorings and cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
dimpar committed Apr 10, 2024
1 parent c52a2da commit 6ca6e0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions core/contracts/MezoAllocator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,18 @@ contract MezoAllocator is IDispatcher, Ownable2Step {
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.
error NotMaintainer();
error CallerNotMaintainer();
/// @notice Reverts if the caller is not the stBTC contract.
error NotStbtc();
/// @notice Reverts if the caller is not a maintainer.
error CallerNotStbtc();
/// @notice Reverts if the maintainer is already registered.
error MaintainerNotRegistered();
/// @notice Reverts if the caller is already a maintainer.
error MaintainerAlreadyRegistered();

modifier onlyMaintainer() {
if (!isMaintainer[msg.sender]) {
revert NotMaintainer();
revert CallerNotMaintainer();
}
_;
}
Expand Down Expand Up @@ -175,7 +173,7 @@ contract MezoAllocator is IDispatcher, Ownable2Step {
/// MezoPortal for a given deposit id.
/// @param amount Amount of tBTC to withdraw.
function withdraw(uint256 amount) external {
if (msg.sender != address(stbtc)) revert NotStbtc();
if (msg.sender != address(stbtc)) revert CallerNotStbtc();

emit DepositWithdrawn(depositId, amount);
mezoPortal.withdraw(address(tbtc), depositId, uint96(amount));
Expand All @@ -185,6 +183,8 @@ contract MezoAllocator is IDispatcher, Ownable2Step {
}

/// @notice Releases deposit in full from MezoPortal.
/// @dev This is a special function that can be used to migrate funds during
/// allocator upgrade or in case of emergencies.
function releaseDeposit() external onlyOwner {
uint96 amount = mezoPortal
.getDeposit(address(this), address(tbtc), depositId)
Expand Down Expand Up @@ -232,7 +232,7 @@ contract MezoAllocator is IDispatcher, Ownable2Step {
}

/// @notice Returns the total amount of tBTC allocated to MezoPortal.
function totalAssets() external view returns (uint256 totalAmount) {
function totalAssets() external view returns (uint256) {
return depositBalance;
}

Expand Down
4 changes: 2 additions & 2 deletions core/test/MezoAllocator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe("MezoAllocator", () => {
it("should revert", async () => {
await expect(
mezoAllocator.connect(thirdParty).allocate(),
).to.be.revertedWithCustomError(mezoAllocator, "NotMaintainer")
).to.be.revertedWithCustomError(mezoAllocator, "CallerNotMaintainer")
})
})

Expand Down Expand Up @@ -153,7 +153,7 @@ describe("MezoAllocator", () => {
it("should revert", async () => {
await expect(
mezoAllocator.connect(thirdParty).withdraw(1n),
).to.be.revertedWithCustomError(mezoAllocator, "NotStbtc")
).to.be.revertedWithCustomError(mezoAllocator, "CallerNotStbtc")
})
})

Expand Down

0 comments on commit 6ca6e0e

Please sign in to comment.