Skip to content
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: 4 additions & 2 deletions src/utils/SafeTransferLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,10 @@ library SafeTransferLib {
let balanceBefore := balance(to) // Check via delta, in case `SELFDESTRUCT` is bricked.
mstore(0x00, to)
pop(call(gas(), mover, amount, 0x00, 0x20, codesize(), 0x00))
if iszero(lt(add(amount, balance(to)), balanceBefore)) { break }
if lt(selfBalanceBefore, selfbalance()) { invalid() } // Just in case.
// If `address(to).balance >= amount + balanceBefore`, skip vault workflow.
if iszero(lt(balance(to), add(amount, balanceBefore))) { break }
// Just in case `SELFDESTRUCT` is changed to not revert and do nothing.
if lt(selfBalanceBefore, selfbalance()) { invalid() }
}
let m := mload(0x40)
// If the mover is missing or bricked, deploy a minimal vault
Expand Down
4 changes: 4 additions & 0 deletions test/SafeTransferLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,10 @@ contract SafeTransferLibTest is SoladyTest {
assertEq(to.balance, amount0);
assertEq(address(this).balance, selfBalanceBefore - amount0);

if (_randomChance(2)) {
vm.etch(SafeTransferLib.ETH_MOVER, "");
}

if (SafeTransferLib.ETH_MOVER.code.length == 0) {
address vault = this.safeMoveETH(to, amount1);
assertEq(vault.balance, amount1);
Expand Down