Skip to content
Verified contractPartialMIT

VaultecFlare

Address0xe84fd1114011dd9fe5de3f6392f4f77e33af7abe
Balance

0 ETH

 

Transactions

8

 

Compiler

solc 0.8.30

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.30+commit.73712a01
Language
solidity
Optimization
No
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
22,927,966
Creation transaction
0x6e9c21dddc…4e1d83a0de

VaultecFlare.sol

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

/**
 * @title IERC20
 * @dev Interface for the ERC20 standard.
 */
interface IERC20 {
    function transfer(address to, uint256 amount) external returns (bool);
    function balanceOf(address account) external view returns (uint256);
}

/**
 * @title IUniswapV2Router02
 * @dev Interface for the Uniswap V2 Router.
 */
interface IUniswapV2Router02 {
    function WETH() external pure returns (address);
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
}

/**
 * @title IUniswapV3SwapRouter
 * @dev Interface for the Uniswap V3 Swap Router.
 */
interface IUniswapV3SwapRouter {
    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }

    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
    function WETH9() external pure returns (address);
}

/**
 * @title VaultecFlare
 * @dev A contract that uses ETH to buy a specific ERC20 token from Uniswap V2 or V3
 *      and immediately burns it by sending it to a dead address.
 *      V2 function supports fee-on-transfer tokens.
 */
contract VaultecFlare {
    address public owner;
    IUniswapV2Router02 public immutable uniswapRouterV2;
    IUniswapV3SwapRouter public immutable uniswapRouterV3;
    address public tokenToBurn;

    address public immutable WETH;
    address public constant DEAD_ADDRESS = 0x000000000000000000000000000000000000dEaD;

    event TokensBurnedV2(address indexed burner, address indexed token, uint256 ethAmount, uint256 tokensBoughtAndBurned);
    event TokensBurnedV3(address indexed burner, address indexed token, uint256 ethAmount, uint256 tokensBoughtAndBurned, uint24 fee);
    event TokenToBurnUpdated(address indexed newToken);

    modifier onlyOwner() {
        require(msg.sender == owner, "OnlyOwner: caller is not the owner");
        _;
    }

    constructor(address _routerV2, address _routerV3, address _tokenToBurn) {
        owner = msg.sender;
        uniswapRouterV2 = IUniswapV2Router02(_routerV2);
        uniswapRouterV3 = IUniswapV3SwapRouter(_routerV3);
        WETH = uniswapRouterV2.WETH(); // WETH address is the same for both
        tokenToBurn = _tokenToBurn;
    }

    /**
     * @notice Accepts ETH, buys the designated token on Uniswap V2, and burns it.
     * @dev This function supports fee-on-transfer tokens.
     * @param _minAmountOut The minimum amount of tokens to receive to protect against slippage.
     */
    function VaultecFlareV2(uint256 _minAmountOut) external payable {
        require(msg.value > 0, "VaultecFlare: ETH amount must be greater than 0");

        address[] memory path = new address[](2);
        path[0] = WETH;
        path[1] = tokenToBurn;

        uint256 balanceBefore = IERC20(tokenToBurn).balanceOf(address(this));

        uniswapRouterV2.swapExactETHForTokensSupportingFeeOnTransferTokens{value: msg.value}(
            _minAmountOut,
            path,
            address(this), // The contract receives the tokens first
            block.timestamp
        );

        uint256 balanceAfter = IERC20(tokenToBurn).balanceOf(address(this));
        uint256 tokensBought = balanceAfter - balanceBefore;
        
        require(tokensBought > 0, "VaultecFlare: No tokens were received from swap");

        IERC20(tokenToBurn).transfer(DEAD_ADDRESS, tokensBought);

        emit TokensBurnedV2(msg.sender, tokenToBurn, msg.value, tokensBought);
    }

    /**
     * @notice Accepts ETH, buys the designated token on Uniswap V3, and burns it.
     * @param _fee The fee tier of the WETH/token liquidity pool (e.g., 500, 3000, 10000).
     * @param _minAmountOut The minimum amount of tokens to receive to protect against slippage.
     */
    function VaultecFlareV3(uint24 _fee, uint256 _minAmountOut) external payable {
        require(msg.value > 0, "VaultecFlare: ETH amount must be greater than 0");

        IUniswapV3SwapRouter.ExactInputSingleParams memory params = IUniswapV3SwapRouter.ExactInputSingleParams({
            tokenIn: WETH,
            tokenOut: tokenToBurn,
            fee: _fee,
            recipient: address(this),
            deadline: block.timestamp,
            amountIn: msg.value,
            amountOutMinimum: _minAmountOut,
            sqrtPriceLimitX96: 0
        });

        uint256 tokensBought = uniswapRouterV3.exactInputSingle{value: msg.value}(params);
        IERC20(tokenToBurn).transfer(DEAD_ADDRESS, tokensBought);

        emit TokensBurnedV3(msg.sender, tokenToBurn, msg.value, tokensBought, _fee);
    }

    /**
     * @notice Updates the address of the token to be bought and burned.
     * @param _newTokenToBurn The new ERC20 token address.
     */
    function setTokenToBurn(address _newTokenToBurn) external onlyOwner {
        require(_newTokenToBurn != address(0), "VaultecFlare: Invalid token address");
        tokenToBurn = _newTokenToBurn;
        emit TokenToBurnUpdated(_newTokenToBurn);
    }

    /**
     * @notice Allows the owner to withdraw any ETH accidentally sent to the contract.
     */
    function withdrawStuckETH() external onlyOwner {
        (bool success, ) = owner.call{value: address(this).balance}("");
        require(success, "VaultecFlare: ETH withdrawal failed");
    }

    /**
     * @notice Allows the owner to withdraw any other ERC20 tokens accidentally sent here.
     * @param _tokenAddress The address of the stuck token.
     * @param _amount The amount of tokens to withdraw.
     */
    function withdrawStuckTokens(address _tokenAddress, uint256 _amount) external onlyOwner {
        require(_tokenAddress != tokenToBurn, "VaultecFlare: Cannot withdraw the burn token");
        IERC20(_tokenAddress).transfer(owner, _amount);
    }

    // Fallback to accept ETH
    receive() external payable {}
}
Compiler settingsShow
{
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": false
  }
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.