Forkchoice Ethereum Mainnet

Address Contract Verified

Address 0xD64D9D16ECd74E3Ae9FBA2EABff330abd2291ed2
Balance 0 ETH
Nonce 1
Code Size 3472 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

3472 bytes
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c80639d0014b11161008c578063e4fe4e8a11610066578063e4fe4e8a1461019d578063e74b981b146101b0578063f2fde38b146101c3578063f887ea40146101d6576100ea565b80639d0014b114610164578063c0d7865514610177578063e01af92c1461018a576100ea565b806369e330ec116100c857806369e330ec1461012a5780636ddd17131461013f578063715018a6146101545780638da5cb5b1461015c576100ea565b80630445b667146100ef578063263420b11461010d5780634690484014610122575b600080fd5b6100f76101de565b6040516101049190610cbe565b60405180910390f35b6101156101e4565b6040516101049190610b02565b6101156101f3565b61013d610138366004610a2f565b610202565b005b610147610301565b6040516101049190610b53565b61013d610311565b61011561035c565b61013d610172366004610ad2565b61036b565b61013d6101853660046109f0565b6103dd565b61013d610198366004610a5a565b61048c565b61013d6101ab366004610a92565b610514565b61013d6101be3660046109f0565b6105d9565b61013d6101d13660046109f0565b610688565b6101156106f9565b60045481565b6001546001600160a01b031681565b6003546001600160a01b031681565b6001546001600160a01b031633146102355760405162461bcd60e51b815260040161022c90610c7b565b60405180910390fd5b6001600160a01b038216156102fd57600354600090600160a01b900460ff16610269576003546001600160a01b031661026b565b305b6001546040516323b872dd60e01b81529192506001600160a01b0316906323b872dd906102a090839085908790600401610b16565b602060405180830381600087803b1580156102ba57600080fd5b505af11580156102ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102f29190610a76565b506102fb610708565b505b5050565b600354600160a01b900460ff1681565b61031961099c565b6001600160a01b031661032a61035c565b6001600160a01b0316146103505760405162461bcd60e51b815260040161022c90610bf8565b61035a60006109a0565b565b6000546001600160a01b031690565b61037361099c565b6001600160a01b031661038461035c565b6001600160a01b0316146103aa5760405162461bcd60e51b815260040161022c90610bf8565b600481905560405181907f18ff2fc8464635e4f668567019152095047e34d7a2ab4b97661ba4dc7fd0647690600090a250565b6103e561099c565b6001600160a01b03166103f661035c565b6001600160a01b03161461041c5760405162461bcd60e51b815260040161022c90610bf8565b6001600160a01b0381166104425760405162461bcd60e51b815260040161022c90610c2d565b600280546001600160a01b0319166001600160a01b0383169081179091556040517f7aed1d3e8155a07ccf395e44ea3109a0e2d6c9b29bbbe9f142d9790596f4dc8090600090a250565b61049461099c565b6001600160a01b03166104a561035c565b6001600160a01b0316146104cb5760405162461bcd60e51b815260040161022c90610bf8565b6003805460ff60a01b1916600160a01b831515908102919091179091556040517fd2b6af97bbcf94796ee3844c1f0948ba30b3f2d496875e5e1587309eb210aac590600090a250565b61051c61099c565b6001600160a01b031661052d61035c565b6001600160a01b0316146105535760405162461bcd60e51b815260040161022c90610bf8565b60405163a9059cbb60e01b81526001600160a01b0384169063a9059cbb906105819085908590600401610b3a565b602060405180830381600087803b15801561059b57600080fd5b505af11580156105af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d39190610a76565b50505050565b6105e161099c565b6001600160a01b03166105f261035c565b6001600160a01b0316146106185760405162461bcd60e51b815260040161022c90610bf8565b6001600160a01b03811661063e5760405162461bcd60e51b815260040161022c90610b5e565b600380546001600160a01b0319166001600160a01b0383169081179091556040517f7a7b5a0a132f9e0581eb8527f66eae9ee89c2a3e79d4ac7e41a1f1f4d48a7fc290600090a250565b61069061099c565b6001600160a01b03166106a161035c565b6001600160a01b0316146106c75760405162461bcd60e51b815260040161022c90610bf8565b6001600160a01b0381166106ed5760405162461bcd60e51b815260040161022c90610bb2565b6106f6816109a0565b50565b6002546001600160a01b031681565b6001546040516370a0823160e01b81526000916001600160a01b0316906370a0823190610739903090600401610b02565b60206040518083038186803b15801561075157600080fd5b505afa158015610765573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107899190610aea565b90506004548111156106f657604080516002808252606082018352600092602083019080368337505060015482519293506001600160a01b0316918391506000906107e457634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152600254604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561083857600080fd5b505afa15801561084c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108709190610a13565b8160018151811061089157634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260015460025460405163095ea7b360e01b81529183169263095ea7b3926108d692909116908690600401610b3a565b602060405180830381600087803b1580156108f057600080fd5b505af1158015610904573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109289190610a76565b5060025460035460405163791ac94760e01b81526001600160a01b039283169263791ac9479261096692879260009288929116904290600401610cc7565b600060405180830381600087803b15801561098057600080fd5b505af1158015610994573d6000803e3d6000fd5b505050505050565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060208284031215610a01578081fd5b8135610a0c81610d37565b9392505050565b600060208284031215610a24578081fd5b8151610a0c81610d37565b60008060408385031215610a41578081fd5b8235610a4c81610d37565b946020939093013593505050565b600060208284031215610a6b578081fd5b8135610a0c81610d4c565b600060208284031215610a87578081fd5b8151610a0c81610d4c565b600080600060608486031215610aa6578081fd5b8335610ab181610d37565b92506020840135610ac181610d37565b929592945050506040919091013590565b600060208284031215610ae3578081fd5b5035919050565b600060208284031215610afb578081fd5b5051919050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b60208082526034908201527f456c76616e74697346656552656365697665723a205f666565526563697069656040820152736e742069732061207a65726f206164647265737360601b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602e908201527f456c76616e74697346656552656365697665723a205f726f757465722069732060408201526d61207a65726f206164647265737360901b606082015260800190565b60208082526023908201527f456c76616e74697346656552656365697665723a204f6e6c7920456c76616e7460408201526269732160e81b606082015260800190565b90815260200190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b81811015610d165784516001600160a01b031683529383019391830191600101610cf1565b50506001600160a01b03969096166060850152505050608001529392505050565b6001600160a01b03811681146106f657600080fd5b80151581146106f657600080fdfea26469706673582212200e40f2f0414ba8215e36f3afe367b85683db70128157d02cd394bc0e20750a7c64736f6c63430008000033

Verified Source Code Full Match

Compiler: v0.8.0+commit.c7dfd78e EVM: istanbul Optimization: Yes (200 runs)
ElvantisFeeReceiver.sol 89 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import './interfaces/IElvantisFeeReceiver.sol';
import './interfaces/IDEXRouter.sol';

// This contract will only be used for Elvantis Token
contract ElvantisFeeReceiver is Ownable, IElvantisFeeReceiver {
    IERC20 public elvantis;
    IDEXRouter public router;
    address public feeRecipient;

    bool public swapEnabled = true;
    uint256 public swapThreshold = 1 ether;
    
    event FeeRecipientUpdated(address indexed feeRecipient);
    event RouterUpdated(address indexed router);
    event SwapUpdated(bool indexed enabled);
    event SwapThresholdUpdated(uint256 indexed threshold);

    modifier onlyElvantis {
        require(msg.sender == address(elvantis), "ElvantisFeeReceiver: Only Elvantis!");
        _;
    }

    constructor(address _elvantis, address _router, address _owner) {
        require(_elvantis != address(0) && _router != address(0) && _owner != address(0), "ElvantisFeeReceiver: zero address");

        elvantis = IERC20(_elvantis);
        router = IDEXRouter(_router);
        transferOwnership(_owner);
    }

    function onFeeReceived(address token, uint256 amount) external override onlyElvantis {
        if(token != address(0)) {
            address recipient = swapEnabled ? address(this) : feeRecipient;
            elvantis.transferFrom(address(elvantis), recipient, amount);
            _swapTokensForETH();
        }
    }

    function _swapTokensForETH() private {
        uint256 amount = elvantis.balanceOf(address(this));
        if(amount > swapThreshold) {
            address[] memory path = new address[](2);
            path[0] = address(elvantis);
            path[1] = router.WETH();

            elvantis.approve(address(router), amount);
            
            router.swapExactTokensForETHSupportingFeeOnTransferTokens(
                amount,
                0,
                path,
                feeRecipient,
                block.timestamp
            );
        }
    }
    
    function setFeeRecipient(address _feeRecipient) onlyOwner external {
        require(_feeRecipient != address(0), "ElvantisFeeReceiver: _feeRecipient is a zero address");
        feeRecipient = _feeRecipient;
        emit FeeRecipientUpdated(_feeRecipient);
    }

    function setRouter(IDEXRouter _router) onlyOwner external {
        require(address(_router) != address(0), "ElvantisFeeReceiver: _router is a zero address");
        router = _router;
        emit RouterUpdated(address(_router));
    }

    function setSwapEnabled(bool _enabled) onlyOwner external {
        swapEnabled = _enabled;
        emit SwapUpdated(_enabled);
    }

    function setSwapThreshold(uint256 _threshold) onlyOwner external {
        swapThreshold = _threshold;
        emit SwapThresholdUpdated(_threshold);
    }

    function drainAccidentallySentTokens(IERC20 token, address recipient, uint256 amount) onlyOwner external {
        token.transfer(recipient, amount);
    }
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
IElvantisFeeReceiver.sol 7 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IElvantisFeeReceiver {
    function onFeeReceived(address token, uint256 amount) external;
}
IDEXRouter.sol 15 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IDEXRouter {
    function WETH() external pure returns (address);

    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external;
} 
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

Read Contract

elvantis 0x263420b1 → address
feeRecipient 0x46904840 → address
owner 0x8da5cb5b → address
router 0xf887ea40 → address
swapEnabled 0x6ddd1713 → bool
swapThreshold 0x0445b667 → uint256

Write Contract 8 functions

These functions modify contract state and require a wallet transaction to execute.

drainAccidentallySentTokens 0xe4fe4e8a
address token
address recipient
uint256 amount
onFeeReceived 0x69e330ec
address token
uint256 amount
renounceOwnership 0x715018a6
No parameters
setFeeRecipient 0xe74b981b
address _feeRecipient
setRouter 0xc0d78655
address _router
setSwapEnabled 0xe01af92c
bool _enabled
setSwapThreshold 0x9d0014b1
uint256 _threshold
transferOwnership 0xf2fde38b
address newOwner

Recent Transactions

No transactions found for this address