Skip to content

Commit

Permalink
Create transferProxy.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
lcfr-eth authored May 14, 2023
1 parent 76dfe22 commit ee33d29
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions contracts/transferProxy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

/// @author lcfr.eth
/// @notice helper contract for Flashbots rescues using bundler.lcfr.io

contract transferProxy {

error notApproved();

function transfer(bytes[] calldata _data, address _contract, address _from) external {
assembly {
// check if caller isApprovedForAll() by _from on _contract or revert
mstore(0x00, shl(224, 0xe985e9c5))
mstore(add(0x00, 0x04), _from)
mstore(add(0x00, 0x24), caller())

let success := staticcall(gas(), _contract, 0x00, 0x44, 0x00, 0x00)

returndatacopy(0x00, 0x00, returndatasize())

if iszero(success) {
revert(0x00, returndatasize())
}

if iszero(mload(0x00)) {
mstore(0x00, shl(224, 0x383462e29))
revert(0x00, 0x04)
}

let i := 0
for {} 1 { i:= add(i, 1) } {
if eq(i, _data.length){ break }

let data := calldataload(add(_data.offset, shl(5, i)))
let len := calldataload(add(_data.offset, data))

calldatacopy(0x00, add(_data.offset, add(data, 0x20)), len)

success := call( gas(), _contract, 0x00, 0x00, len, 0x00, 0x00)

if iszero(success) {
returndatacopy(0x00, 0x00, returndatasize())
revert(0x00, returndatasize())
}
}
}
}
}

1 comment on commit ee33d29

@vercel
Copy link

@vercel vercel bot commented on ee33d29 May 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.