Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [spearbit-55] switch from .transfer to .call #24

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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