Skip to content
Verified contractExactMIT

ProfitGatedArb

Address0x0433be407faca971991ecf8277a007623a689a84
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.34

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.34+commit.80d5c536
Language
solidity
Optimization
No
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,365,415
Creation transaction
0x1f3f09d24d…43eb24d49c

contracts/ProfitGatedArb.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IERC20 {
    function transfer(address recipient, uint256 amount) external returns (bool);
        function balanceOf(address account) external view returns (uint256);
            function approve(address spender, uint256 amount) external returns (bool);
            }

            interface ISwapRouter {
                struct ExactInputSingleParams {
                        address tokenIn;
                                address tokenOut;
                                        uint24 fee;
                                                address recipient;
                                                        uint256 amountIn;
                                                                uint256 amountOutMinimum;
                                                                        uint160 sqrtPriceLimitX96;
                                                                            }
                                                                                function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
                                                                                }

                                                                                contract ProfitGatedArb {
                                                                                    address public constant WETH = 0x4200000000000000000000000000000000000006;
                                                                                        address public constant SWAP_ROUTER = 0x2626664c2603336E57B271c5C0b26F421741e481;
                                                                                            address public immutable owner = 0x2D4EDb1125619b33dD69251B09D3ccCAF7011f4a;

                                                                                                function executeOperation(
                                                                                                        address asset,
                                                                                                                uint256 amount,
                                                                                                                        uint256 premium,
                                                                                                                                address initiator,
                                                                                                                                        bytes calldata params
                                                                                                                                            ) external returns (bool) {
                                                                                                                                                    require(msg.sender == owner || initiator == address(this), "Unauthorized");

                                                                                                                                                            uint256 amountOwed = amount + premium;

                                                                                                                                                                    (address tokenOut, uint24 fee) = abi.decode(params, (address, uint24));

                                                                                                                                                                            IERC20(WETH).approve(SWAP_ROUTER, amount);
                                                                                                                                                                                    ISwapRouter.ExactInputSingleParams memory swapParams1 = ISwapRouter.ExactInputSingleParams({
                                                                                                                                                                                                tokenIn: WETH,
                                                                                                                                                                                                            tokenOut: tokenOut,
                                                                                                                                                                                                                        fee: fee,
                                                                                                                                                                                                                                    recipient: address(this),
                                                                                                                                                                                                                                                amountIn: amount,
                                                                                                                                                                                                                                                            amountOutMinimum: 0,
                                                                                                                                                                                                                                                                        sqrtPriceLimitX96: 0
                                                                                                                                                                                                                                                                                });
                                                                                                                                                                                                                                                                                        uint256 tokenOutReceived = ISwapRouter(SWAP_ROUTER).exactInputSingle(swapParams1);

                                                                                                                                                                                                                                                                                                IERC20(tokenOut).approve(SWAP_ROUTER, tokenOutReceived);
                                                                                                                                                                                                                                                                                                        ISwapRouter.ExactInputSingleParams memory swapParams2 = ISwapRouter.ExactInputSingleParams({
                                                                                                                                                                                                                                                                                                                    tokenIn: tokenOut,
                                                                                                                                                                                                                                                                                                                                tokenOut: WETH,
                                                                                                                                                                                                                                                                                                                                            fee: fee,
                                                                                                                                                                                                                                                                                                                                                        recipient: address(this),
                                                                                                                                                                                                                                                                                                                                                                    amountIn: tokenOutReceived,
                                                                                                                                                                                                                                                                                                                                                                                amountOutMinimum: amountOwed,
                                                                                                                                                                                                                                                                                                                                                                                            sqrtPriceLimitX96: 0
                                                                                                                                                                                                                                                                                                                                                                                                    });
                                                                                                                                                                                                                                                                                                                                                                                                            uint256 wethReturned = ISwapRouter(SWAP_ROUTER).exactInputSingle(swapParams2);

                                                                                                                                                                                                                                                                                                                                                                                                                    require(wethReturned > amountOwed, "Arbitrage unprofitable - reverting");

                                                                                                                                                                                                                                                                                                                                                                                                                            IERC20(WETH).transfer(msg.sender, amountOwed);

                                                                                                                                                                                                                                                                                                                                                                                                                                    uint256 netProfit = IERC20(WETH).balanceOf(address(this));
                                                                                                                                                                                                                                                                                                                                                                                                                                            if (netProfit > 0) {
                                                                                                                                                                                                                                                                                                                                                                                                                                                        IERC20(WETH).transfer(owner, netProfit);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                        return true;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.