From fd097ef7a179e296c3301c61304220ce2705d74e Mon Sep 17 00:00:00 2001 From: howy <132113803+howydev@users.noreply.github.com> Date: Fri, 22 Dec 2023 15:44:58 -0500 Subject: [PATCH] fix: [spearbit-55] switch from .transfer to .call (#24) --- src/factory/MultiOwnerMSCAFactory.sol | 6 +++++- src/factory/MultiOwnerTokenReceiverMSCAFactory.sol | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/factory/MultiOwnerMSCAFactory.sol b/src/factory/MultiOwnerMSCAFactory.sol index 6e63337f..e4e7a7e6 100644 --- a/src/factory/MultiOwnerMSCAFactory.sol +++ b/src/factory/MultiOwnerMSCAFactory.sol @@ -24,6 +24,7 @@ contract MultiOwnerMSCAFactory is Ownable2Step { error OwnersArrayEmpty(); error ZeroAddressOwner(); error DuplicateOwner(); + error TransferFailed(); /// @notice Constructor for the factory constructor( @@ -100,7 +101,10 @@ contract MultiOwnerMSCAFactory is Ownable2Step { /// @param amount amount of the token to withdraw in case of rebasing tokens function withdraw(address payable to, address token, uint256 amount) external onlyOwner { if (token == address(0)) { - to.transfer(address(this).balance); + (bool success,) = to.call{value: address(this).balance}(""); + if (!success) { + revert TransferFailed(); + } } else { SafeERC20.safeTransfer(IERC20(token), to, amount); } diff --git a/src/factory/MultiOwnerTokenReceiverMSCAFactory.sol b/src/factory/MultiOwnerTokenReceiverMSCAFactory.sol index 9fe0eb02..7cd6fa14 100644 --- a/src/factory/MultiOwnerTokenReceiverMSCAFactory.sol +++ b/src/factory/MultiOwnerTokenReceiverMSCAFactory.sol @@ -26,6 +26,7 @@ contract MultiOwnerTokenReceiverMSCAFactory is Ownable2Step { error OwnersArrayEmpty(); error ZeroAddressOwner(); error DuplicateOwner(); + error TransferFailed(); /// @notice Constructor for the factory constructor( @@ -108,7 +109,10 @@ contract MultiOwnerTokenReceiverMSCAFactory is Ownable2Step { /// @param amount amount of the token to withdraw in case of rebasing tokens function withdraw(address payable to, address token, uint256 amount) external onlyOwner { if (token == address(0)) { - to.transfer(address(this).balance); + (bool success,) = to.call{value: address(this).balance}(""); + if (!success) { + revert TransferFailed(); + } } else { SafeERC20.safeTransfer(IERC20(token), to, amount); }