Skip to content

Commit

Permalink
fix: [spearbit-55] switch from .transfer to .call (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
howydev authored Dec 22, 2023
1 parent 4d4f76a commit fd097ef
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 Ownable2Step {
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 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);
}
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 Ownable2Step {
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 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);
}
Expand Down

0 comments on commit fd097ef

Please sign in to comment.