From eb864ec31dd9a81daf2af43b7502e7643d37dd47 Mon Sep 17 00:00:00 2001 From: howydev <132113803+howydev@users.noreply.github.com> Date: Wed, 20 Dec 2023 19:55:40 -0500 Subject: [PATCH] fix: [spearbit-55] switch .transfer to .call --- 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 a8cfaad0..55953818 100644 --- a/src/factory/MultiOwnerMSCAFactory.sol +++ b/src/factory/MultiOwnerMSCAFactory.sol @@ -24,6 +24,7 @@ contract MultiOwnerMSCAFactory is Ownable { error OwnersArrayEmpty(); error ZeroAddressOwner(); error DuplicateOwner(); + error TransferFailed(); /// @notice Constructor for the factory constructor( @@ -100,7 +101,10 @@ contract MultiOwnerMSCAFactory is Ownable { /// @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 2c42365b..a79e279d 100644 --- a/src/factory/MultiOwnerTokenReceiverMSCAFactory.sol +++ b/src/factory/MultiOwnerTokenReceiverMSCAFactory.sol @@ -26,6 +26,7 @@ contract MultiOwnerTokenReceiverMSCAFactory is Ownable { error OwnersArrayEmpty(); error ZeroAddressOwner(); error DuplicateOwner(); + error TransferFailed(); /// @notice Constructor for the factory constructor( @@ -108,7 +109,10 @@ contract MultiOwnerTokenReceiverMSCAFactory is Ownable { /// @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); }