Skip to content

Commit

Permalink
Merge pull request #3 from 0xSplits/remove-swapper-callback-verification
Browse files Browse the repository at this point in the history
remove swapper callback verification
  • Loading branch information
wminshew authored May 10, 2023
2 parents 90b5ab0 + 4fd86aa commit ad265dc
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 50 deletions.
12 changes: 0 additions & 12 deletions src/SwapperFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ contract SwapperFactory {

SwapperImpl public immutable swapperImpl;

/// mapping of canonical swappers for flash callback validation
mapping(SwapperImpl => bool) internal $isSwapper;

constructor() {
swapperImpl = new SwapperImpl();
}
Expand All @@ -49,16 +46,7 @@ contract SwapperFactory {
oracle: oracle
});
swapper.initializer(swapperInitParams);
$isSwapper[swapper] = true;

emit CreateSwapper({swapper: swapper, params: swapperInitParams});
}

/// -----------------------------------------------------------------------
/// functions - public & external - view
/// -----------------------------------------------------------------------

function isSwapper(SwapperImpl swapper) external view returns (bool) {
return $isSwapper[swapper];
}
}
10 changes: 2 additions & 8 deletions src/integrations/UniV3Swap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {SafeTransferLib} from "solady/utils/SafeTransferLib.sol";
import {TokenUtils} from "splits-utils/TokenUtils.sol";

import {ISwapperFlashCallback} from "../interfaces/ISwapperFlashCallback.sol";
import {SwapperCallbackValidation} from "../peripherals/SwapperCallbackValidation.sol";
import {SwapperImpl} from "../SwapperImpl.sol";
import {SwapperFactory} from "../SwapperFactory.sol";

Expand All @@ -18,7 +17,6 @@ import {SwapperFactory} from "../SwapperFactory.sol";
/// @notice Used by EOAs & simple bots to execute swapper#flash with uniswap v3
/// This contract uses token = address(0) to refer to ETH.
contract UniV3Swap is ISwapperFlashCallback {
using SwapperCallbackValidation for SwapperFactory;
using SafeTransferLib for address;
using TokenUtils for address;

Expand Down Expand Up @@ -60,14 +58,10 @@ contract UniV3Swap is ISwapperFlashCallback {
/// swapper#flash callback
/// @dev by end of function if tokenToBeneficiary_ is eth, must have sent amountToBeneficiary_
/// to swapper#payback. Otherwise, must approve swapper to transferFrom amountToBeneficiary_
/// DO NOT HOLD FUNDS IN THIS CONTRACT WITHOUT PROPER VERIFICATION OF MSG.SENDER
function swapperFlashCallback(address tokenToBeneficiary_, uint256 amountToBeneficiary_, bytes calldata data_)
external
{
SwapperImpl swapper = SwapperImpl(msg.sender);
if (!swapperFactory.verifyCallback(swapper)) {
revert Unauthorized();
}

uint256 ethBalance = address(this).balance;
if (!tokenToBeneficiary_._isETH() && ethBalance != 0) {
weth9.deposit{value: ethBalance}();
Expand Down Expand Up @@ -99,7 +93,7 @@ contract UniV3Swap is ISwapperFlashCallback {
weth9.withdraw(weth9Balance);

// send req'd amt to swapper#payback
swapper.payback{value: amountToBeneficiary_}();
SwapperImpl(msg.sender).payback{value: amountToBeneficiary_}();

// xfr excess out
ethBalance = address(this).balance;
Expand Down
19 changes: 0 additions & 19 deletions src/peripherals/SwapperCallbackValidation.sol

This file was deleted.

11 changes: 0 additions & 11 deletions test/SwapperFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,6 @@ contract SwapperFactoryTest is BaseTest, LibCloneBase {
test_clone_canDelegateCall();
}

/// -----------------------------------------------------------------------
/// isSwapper
/// -----------------------------------------------------------------------

function test_isSwapper() public {
SwapperImpl expectedSwapper = SwapperImpl(_predictNextAddressFrom(address(swapperFactory)));
assertFalse(swapperFactory.isSwapper(expectedSwapper));
swapperFactory.createSwapper(params);
assertTrue(swapperFactory.isSwapper(expectedSwapper));
}

/// -----------------------------------------------------------------------
/// internal
/// -----------------------------------------------------------------------
Expand Down

0 comments on commit ad265dc

Please sign in to comment.