Skip to content

Commit c5205c0

Browse files
committed
fix: split withdraw into withdrawERC20 and withdrawETH in BrokerLiquidator
1 parent 4b75951 commit c5205c0

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/liquidator/BrokerLiquidator.sol

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ contract BrokerLiquidator is UUPSUpgradeable, AccessControlUpgradeable, IBrokerL
8383

8484
receive() external payable {}
8585

86-
/// @dev withdraws ERC20 tokens or native BNB from the contract.
87-
/// @param token The address of the token. Use BNB_ADDRESS (0xEeee...EEeE) for native BNB.
86+
/// @dev withdraws ERC20 tokens.
87+
/// @param token The address of the token.
8888
/// @param amount The amount to withdraw.
89-
function withdraw(address token, uint256 amount) external onlyRole(MANAGER) {
90-
if (token == BNB_ADDRESS) {
91-
(bool success, ) = msg.sender.call{ value: amount }("");
92-
require(success, "broker-liquidator/native-transfer-failed");
93-
} else {
94-
SafeTransferLib.safeTransfer(token, msg.sender, amount);
95-
}
89+
function withdrawERC20(address token, uint256 amount) external onlyRole(MANAGER) {
90+
SafeTransferLib.safeTransfer(token, msg.sender, amount);
91+
}
92+
/// @dev withdraws ETH.
93+
/// @param amount The amount to withdraw.
94+
function withdrawETH(uint256 amount) external onlyRole(MANAGER) {
95+
SafeTransferLib.safeTransferETH(msg.sender, amount);
9696
}
9797

9898
/// @dev sets the token whitelist.

src/liquidator/IBrokerLiquidator.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ interface IBrokerLiquidator {
1818
bytes swapToken0Data;
1919
bytes swapToken1Data;
2020
}
21-
function withdraw(address token, uint256 amount) external;
21+
function withdrawERC20(address token, uint256 amount) external;
22+
function withdrawETH(uint256 amount) external;
2223
function flashLiquidate(
2324
bytes32 id,
2425
address borrower,

0 commit comments

Comments
 (0)