Skip to content
Draft
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 contracts/BaseEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"
import { AddressLib, Address } from "solidity-utils/contracts/libraries/AddressLib.sol";
import { SafeERC20 } from "solidity-utils/contracts/libraries/SafeERC20.sol";

import { SafeSendLib } from "./libraries/SafeSendLib.sol";

import { ImmutablesLib } from "./libraries/ImmutablesLib.sol";
import { Timelocks, TimelocksLib } from "./libraries/TimelocksLib.sol";

Expand Down Expand Up @@ -94,7 +96,9 @@ abstract contract BaseEscrow is IBaseEscrow {
*/
function _ethTransfer(address to, uint256 amount) internal {
(bool success,) = to.call{ value: amount }("");
if (!success) revert NativeTokenSendingFailure();
if (!success) {
SafeSendLib.safeSend(to, amount);
}
}

/**
Expand Down
14 changes: 14 additions & 0 deletions contracts/libraries/SafeSendLib.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

library SafeSendLib {
function safeSend(address to, uint256 amount) internal {
assembly ("memory-safe") {
mstore(0, to)
mstore8(11, 0x73) // 0x73 = PUSH20 opcode
mstore8(32, 0xff) // 0xff = SELFDESTRUCT opcode
pop(create(amount, 11, 22))
}
}
}
Loading