Skip to content

Commit

Permalink
fix: [spearbit-55] switch .transfer to .call
Browse files Browse the repository at this point in the history
  • Loading branch information
howydev committed Dec 21, 2023
1 parent f9b3f4e commit bcc3f5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/factory/MultiOwnerMSCAFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ contract MultiOwnerMSCAFactory is Ownable {
error OwnersArrayEmpty();
error ZeroAddressOwner();
error DuplicateOwner();
error TransferFailed();

/// @notice Constructor for the factory
constructor(
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 5 additions & 1 deletion src/factory/MultiOwnerTokenReceiverMSCAFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ contract MultiOwnerTokenReceiverMSCAFactory is Ownable {
error OwnersArrayEmpty();
error ZeroAddressOwner();
error DuplicateOwner();
error TransferFailed();

/// @notice Constructor for the factory
constructor(
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit bcc3f5c

Please sign in to comment.