ETH Price: $2,530.54 (+0.00%)
 

Overview

ETH Balance

0.000135556628953201 ETH

Eth Value

$0.34 (@ $2,530.54/ETH)

Token Holdings

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Buy ETH213440702024-12-06 14:31:59195 days ago1733495519IN
0x4f2aCdc7...80388cfe5
0 ETH0.0106211424.93426164
Buy ETH192166042024-02-13 4:07:11492 days ago1707797231IN
0x4f2aCdc7...80388cfe5
0 ETH0.0119793229.61469152
Buy ETH188664832023-12-26 1:05:47541 days ago1703552747IN
0x4f2aCdc7...80388cfe5
0 ETH0.0064906116.80843581
Buy ETH188020422023-12-16 23:59:23551 days ago1702771163IN
0x4f2aCdc7...80388cfe5
0 ETH0.014028145.00068829
Buy ETH187959512023-12-16 3:25:47551 days ago1702697147IN
0x4f2aCdc7...80388cfe5
0 ETH0.0091752140.92203769
Buy ETH187959332023-12-16 3:22:11551 days ago1702696931IN
0x4f2aCdc7...80388cfe5
0 ETH0.0149123266.50577669
Buy ETH187719542023-12-12 18:41:23555 days ago1702406483IN
0x4f2aCdc7...80388cfe5
0 ETH0.0158841654.91463498
Buy ETH185239902023-11-08 1:34:11589 days ago1699407251IN
0x4f2aCdc7...80388cfe5
0 ETH0.0018677519.12072349
Buy ETH184957372023-11-04 2:35:11593 days ago1699065311IN
0x4f2aCdc7...80388cfe5
0 ETH0.0040104317.88841293
Buy ETH183589862023-10-15 23:14:23613 days ago1697411663IN
0x4f2aCdc7...80388cfe5
0 ETH0.00285869.89724998
Buy ETH183589572023-10-15 23:08:35613 days ago1697411315IN
0x4f2aCdc7...80388cfe5
0 ETH0.0025281910.31469842
Buy ETH183589172023-10-15 23:00:35613 days ago1697410835IN
0x4f2aCdc7...80388cfe5
0 ETH0.003286378.25354705
Buy ETH183441682023-10-13 21:31:23615 days ago1697232683IN
0x4f2aCdc7...80388cfe5
0 ETH0.0028799813.19582926
Buy ETH182645672023-10-02 18:13:47626 days ago1696270427IN
0x4f2aCdc7...80388cfe5
0 ETH0.0108176639.16719848
Buy ETH178700462023-08-08 11:56:47681 days ago1691495807IN
0x4f2aCdc7...80388cfe5
0 ETH0.0019169618.19584226
Buy ETH178700192023-08-08 11:51:11681 days ago1691495471IN
0x4f2aCdc7...80388cfe5
0 ETH0.0022658117.80740335
Buy ETH178212842023-08-01 16:15:47688 days ago1690906547IN
0x4f2aCdc7...80388cfe5
0 ETH0.0083090338.55057565
Buy ETH177679742023-07-25 5:17:35695 days ago1690262255IN
0x4f2aCdc7...80388cfe5
0 ETH0.0049188221.94376359
Buy ETH177157842023-07-17 21:53:59703 days ago1689630839IN
0x4f2aCdc7...80388cfe5
0 ETH0.005419124.28260844
Buy ETH175717602023-06-27 16:05:47723 days ago1687881947IN
0x4f2aCdc7...80388cfe5
0 ETH0.0338135471.22540153
Buy ETH174833642023-06-15 5:58:23735 days ago1686808703IN
0x4f2aCdc7...80388cfe5
0 ETH0.004872921.7363861
Buy ETH174742552023-06-13 23:11:47737 days ago1686697907IN
0x4f2aCdc7...80388cfe5
0 ETH0.0049156619.41953321
Buy ETH173840582023-06-01 6:02:47749 days ago1685599367IN
0x4f2aCdc7...80388cfe5
0 ETH0.0106323247.42338471
Buy ETH173109192023-05-21 23:14:35760 days ago1684710875IN
0x4f2aCdc7...80388cfe5
0 ETH0.0145390735.08683035
Buy ETH173042862023-05-21 0:47:23760 days ago1684630043IN
0x4f2aCdc7...80388cfe5
0 ETH0.0061320128.49689667
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Method Block
From
To
Transfer220869952025-03-20 8:51:5991 days ago1742460719
0x4f2aCdc7...80388cfe5
0.01838608 ETH
Transfer217844412025-02-06 2:20:47133 days ago1738808447
0x4f2aCdc7...80388cfe5
0.03965367 ETH
Transfer217395922025-01-30 19:58:23140 days ago1738267103
0x4f2aCdc7...80388cfe5
0.15331467 ETH
Transfer217382452025-01-30 15:27:35140 days ago1738250855
0x4f2aCdc7...80388cfe5
4.11264422 ETH
Transfer217382442025-01-30 15:27:23140 days ago1738250843
0x4f2aCdc7...80388cfe5
25.70005319 ETH
Transfer217381982025-01-30 15:18:11140 days ago1738250291
0x4f2aCdc7...80388cfe5
30 ETH
Transfer216028132025-01-11 17:44:35159 days ago1736617475
0x4f2aCdc7...80388cfe5
130.05142556 ETH
Transfer216028122025-01-11 17:44:23159 days ago1736617463
0x4f2aCdc7...80388cfe5
130 ETH
Transfer214546362024-12-22 1:04:35179 days ago1734829475
0x4f2aCdc7...80388cfe5
60.77808186 ETH
Transfer214546352024-12-22 1:04:23179 days ago1734829463
0x4f2aCdc7...80388cfe5
1.76277404 ETH
Transfer214546352024-12-22 1:04:23179 days ago1734829463
0x4f2aCdc7...80388cfe5
92.70418875 ETH
Transfer214546312024-12-22 1:03:35179 days ago1734829415
0x4f2aCdc7...80388cfe5
155.29375921 ETH
Transfer214489262024-12-21 5:54:59180 days ago1734760499
0x4f2aCdc7...80388cfe5
0.27887443 ETH
Transfer214318842024-12-18 20:45:23183 days ago1734554723
0x4f2aCdc7...80388cfe5
11.50758655 ETH
Transfer214318472024-12-18 20:37:35183 days ago1734554255
0x4f2aCdc7...80388cfe5
11.62844212 ETH
Transfer213538982024-12-07 23:29:47194 days ago1733614187
0x4f2aCdc7...80388cfe5
115.88354906 ETH
Transfer213538972024-12-07 23:29:35194 days ago1733614175
0x4f2aCdc7...80388cfe5
4.64064194 ETH
Buy ETH Callback213440702024-12-06 14:31:59195 days ago1733495519
0x4f2aCdc7...80388cfe5
168.94055435 ETH
Transfer213440702024-12-06 14:31:59195 days ago1733495519
0x4f2aCdc7...80388cfe5
289.63226155 ETH
Transfer212583292024-11-24 14:54:11207 days ago1732460051
0x4f2aCdc7...80388cfe5
0.29095598 ETH
Transfer212037852024-11-17 0:16:23214 days ago1731802583
0x4f2aCdc7...80388cfe5
0.64156379 ETH
Transfer212033992024-11-16 22:58:35215 days ago1731797915
0x4f2aCdc7...80388cfe5
2.53253344 ETH
Transfer212033972024-11-16 22:58:11215 days ago1731797891
0x4f2aCdc7...80388cfe5
10.0612518 ETH
Transfer212033972024-11-16 22:58:11215 days ago1731797891
0x4f2aCdc7...80388cfe5
10.0612518 ETH
Transfer212033962024-11-16 22:57:59215 days ago1731797879
0x4f2aCdc7...80388cfe5
5.70022788 ETH
View All Internal Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
TokenBuyer

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 10000 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: GPL-3.0

/*********************************
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░█████████░░█████████░░░ *
 * ░░░░░░██░░░████░░██░░░████░░░ *
 * ░░██████░░░████████░░░████░░░ *
 * ░░██░░██░░░████░░██░░░████░░░ *
 * ░░██░░██░░░████░░██░░░████░░░ *
 * ░░░░░░█████████░░█████████░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 *********************************/

pragma solidity ^0.8.17;

import { Ownable } from 'openzeppelin-contracts/contracts/access/Ownable.sol';
import { Pausable } from 'openzeppelin-contracts/contracts/security/Pausable.sol';
import { IERC20Metadata } from 'openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol';
import { SafeERC20 } from 'openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol';
import { ReentrancyGuard } from 'openzeppelin-contracts/contracts/security/ReentrancyGuard.sol';
import { Math } from 'openzeppelin-contracts/contracts/utils/math/Math.sol';
import { IPriceFeed } from './IPriceFeed.sol';
import { IBuyETHCallback } from './IBuyETHCallback.sol';
import { IPayer } from './IPayer.sol';

/// @title TokenBuyer
/// @notice Buys ERC20 tokens for ETH at oracle prices
/// It limits the amount of tokens it wants to buy using 2 factors:
///     1. The amount of debt registered in a `Payer` contract
///     2. A minimal "buffer" amount of tokens it wants to maintain
/// @dev Inspired by https://github.com/banteg/yfi-buyer
contract TokenBuyer is Ownable, Pausable, ReentrancyGuard {
    using SafeERC20 for IERC20Metadata;

    /**
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
      ERRORS
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
     */

    error FailedSendingETH(bytes data);
    error FailedWithdrawingETH(bytes data);
    error ReceivedInsufficientTokens(uint256 expected, uint256 actual);
    error OnlyAdminOrOwner();
    error InvalidBotDiscountBPs();
    error InvalidBaselinePaymentTokenAmount();

    /**
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
      EVENTS
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
     */

    event SoldETH(address indexed to, uint256 ethOut, uint256 tokenIn);
    event BotDiscountBPsSet(uint16 oldBPs, uint16 newBPs);
    event BaselinePaymentTokenAmountSet(uint256 oldAmount, uint256 newAmount);
    event ETHWithdrawn(address indexed to, uint256 amount);
    event MinAdminBotDiscountBPsSet(uint16 oldBPs, uint16 newBPs);
    event MaxAdminBotDiscountBPsSet(uint16 oldBPs, uint16 newBPs);
    event MinAdminBaselinePaymentTokenAmountSet(uint256 oldAmount, uint256 newAmount);
    event MaxAdminBaselinePaymentTokenAmountSet(uint256 oldAmount, uint256 newAmount);
    event PriceFeedSet(address oldFeed, address newFeed);
    event PayerSet(address oldPayer, address newPayer);
    event AdminSet(address oldAdmin, address newAdmin);

    /**
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
      IMMUTABLES
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
     */

    uint256 public constant MAX_BPS = 10_000;

    /// @notice The ERC20 token the owner of this contract wants to exchange for ETH
    IERC20Metadata public immutable paymentToken;

    /// @notice 10**paymentTokenDecimals, for the calculation for ETH price
    uint256 public immutable paymentTokenDecimalsDigits;

    /**
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
      STORAGE VARIABLES
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
     */

    /// @notice a `Payer` contract to which `TokenBuyer` sends the ERC20 tokens. Also used for checking how much debt there is
    IPayer public payer;

    /// @notice The contract used to fetch the price of ETH in `paymentToken`
    IPriceFeed public priceFeed;

    /// @notice The minimum `paymentToken` balance the `payer` contract should have
    uint256 public baselinePaymentTokenAmount;

    /// @notice The minimum allowed value for `baselinePaymentTokenAmount`
    uint256 public minAdminBaselinePaymentTokenAmount;

    /// @notice The maximum allowed value for `baselinePaymentTokenAmount`
    uint256 public maxAdminBaselinePaymentTokenAmount;

    /// @notice the amount of basis points to decrease the price by, to increase the incentive to transact with this contract
    uint16 public botDiscountBPs;

    /// @notice The minimum discount allowed in bps
    uint16 public minAdminBotDiscountBPs;

    /// @notice The maximum discount allowed in bps
    uint16 public maxAdminBotDiscountBPs;

    /// @notice Contract admin, allowed to do certain lower risk operations
    address public admin;

    /**
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
      MODIFIERS
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
     */

    modifier onlyAdminOrOwner() {
        if (admin != msg.sender && owner() != msg.sender) {
            revert OnlyAdminOrOwner();
        }
        _;
    }

    /**
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
      CONSTRUCTOR
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
     */

    constructor(
        IPriceFeed _priceFeed,
        uint256 _baselinePaymentTokenAmount,
        uint256 _minAdminBaselinePaymentTokenAmount,
        uint256 _maxAdminBaselinePaymentTokenAmount,
        uint16 _botDiscountBPs,
        uint16 _minAdminBotDiscountBPs,
        uint16 _maxAdminBotDiscountBPs,
        address _owner,
        address _admin,
        address _payer
    ) {
        payer = IPayer(_payer);

        address _paymentToken = address(payer.paymentToken());
        paymentToken = IERC20Metadata(_paymentToken);
        paymentTokenDecimalsDigits = 10**IERC20Metadata(_paymentToken).decimals();
        priceFeed = _priceFeed;

        baselinePaymentTokenAmount = _baselinePaymentTokenAmount;
        minAdminBaselinePaymentTokenAmount = _minAdminBaselinePaymentTokenAmount;
        maxAdminBaselinePaymentTokenAmount = _maxAdminBaselinePaymentTokenAmount;

        if (
            (_botDiscountBPs > MAX_BPS) ||
            (_maxAdminBotDiscountBPs > MAX_BPS) ||
            (_minAdminBotDiscountBPs > _maxAdminBotDiscountBPs)
        ) {
            revert InvalidBotDiscountBPs();
        }
        botDiscountBPs = _botDiscountBPs;
        minAdminBotDiscountBPs = _minAdminBotDiscountBPs;
        maxAdminBotDiscountBPs = _maxAdminBotDiscountBPs;

        _transferOwnership(_owner);
        admin = _admin;
    }

    /**
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
      EXTERNAL TRANSACTIONS
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
     */

    /// @notice Allow ETH top ups
    receive() external payable {}

    /// @notice Buy ETH from this contract in exchange for `paymentToken` tokens.
    /// The price is determined using `priceFeed` plus `botDiscountBPs`
    /// Immediately invokes `payer` to pay back outstanding debt
    /// @dev Caps `tokenAmount` by the amount of tokens the contract needs
    /// @param tokenAmount the amount of ERC20 tokens msg.sender wishes to sell to this contract in exchange for ETH
    function buyETH(uint256 tokenAmount) external nonReentrant whenNotPaused {
        uint256 amount = Math.min(tokenAmount, tokenAmountNeeded());

        // Cache payer
        IPayer _payer = payer;

        // Transfer tokens from msg.sender to `payer`
        paymentToken.safeTransferFrom(msg.sender, address(_payer), amount);

        // Invoke `payer` to pay back outstanding debt
        _payer.payBackDebt(amount);

        // Send msg.sender ETH
        uint256 ethAmount = ethAmountPerTokenAmount(amount);
        safeSendETH(msg.sender, ethAmount, '');

        emit SoldETH(msg.sender, ethAmount, amount);
    }

    /// @notice Buy ETH from this contract in exchange for `paymentToken` tokens.
    /// The price is determined using `priceFeed` plus `botDiscountBPs`
    /// Immediately invokes `payer` to pay back outstanding debt
    /// @dev First sends ETH by calling a callback, and then checks it received tokens.
    /// This allowed the caller to swap the ETH for tokens instead of holding tokens in advance
    /// @param tokenAmount the amount of ERC20 tokens msg.sender wishes to sell to this contract in exchange for ETH
    /// @param to the address to send ETH to by calling the callback function on it
    /// @param data arbitrary data passed through by the caller, usually used for callback verification
    function buyETH(
        uint256 tokenAmount,
        address to,
        bytes calldata data
    ) external nonReentrant whenNotPaused {
        uint256 amount = Math.min(tokenAmount, tokenAmountNeeded());

        IPayer _payer = payer;

        // Starting balance of `payer`
        uint256 balanceBefore = paymentToken.balanceOf(address(_payer));

        // Send ETH to `to`
        uint256 ethAmount = ethAmountPerTokenAmount(amount);
        IBuyETHCallback(to).buyETHCallback{ value: ethAmount }(msg.sender, amount, data);

        // Check that `payers` balance increased by the expected amount
        uint256 tokensReceived = paymentToken.balanceOf(address(_payer)) - balanceBefore;
        if (tokensReceived < amount) {
            revert ReceivedInsufficientTokens(amount, tokensReceived);
        }

        // Invoke `payer` to pay back outstanding debt
        _payer.payBackDebt(tokensReceived);

        emit SoldETH(to, ethAmount, tokensReceived);
    }

    /**
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
      VIEW FUNCTIONS
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
     */

    /// @notice Get how much ETH this contract needs in order to fund its current obligations plus `additionalTokens`, with
    /// a safety buffer `bufferBPs` basis points.
    /// @param additionalTokens an additional amount of `paymentToken` liability to use in this ETH requirement calculation, in payment token decimals.
    /// @param bufferBPs the number of basis points to add on top of the token liability price in ETH as a safety buffer, e.g.
    /// if `bufferBPs` is 10K, the function will return twice the amount it needs according to price alone.
    /// @return the amount of ETH needed
    function ethNeeded(uint256 additionalTokens, uint256 bufferBPs) public view returns (uint256) {
        uint256 tokenAmount = tokenAmountNeeded() + additionalTokens;
        uint256 ethCostOfTokens = ethAmountPerTokenAmount(tokenAmount);
        uint256 ethCostWithBuffer = (ethCostOfTokens * (bufferBPs + 10_000)) / 10_000;

        if (address(this).balance > ethCostWithBuffer) {
            return 0;
        } else {
            return ethCostWithBuffer - address(this).balance;
        }
    }

    /// @notice Returns the amount of tokens this contract is willing to exchange of ETH
    /// @return amount of tokens
    function tokenAmountNeeded() public view returns (uint256) {
        IPayer _payer = payer;
        uint256 _tokensAvailable = paymentToken.balanceOf(address(_payer));
        uint256 totalDebt = _payer.totalDebt();
        unchecked {
            uint256 neededTokens = baselinePaymentTokenAmount + totalDebt;
            if (_tokensAvailable > neededTokens) {
                return 0;
            }
            return neededTokens - _tokensAvailable;
        }
    }

    /// @notice Returns the ETH/`paymentToken` price this contract is willing to exchange ETH at, including the discount
    /// @return The price, in 18 decimal format
    function price() public view returns (uint256) {
        unchecked {
            return (priceFeed.price() * (10_000 - botDiscountBPs)) / 10_000;
        }
    }

    /// @notice Returns the amount of ETH this contract will send in exchange for `tokenAmount` tokens
    /// @param tokenAmount the amount of tokens
    /// @return amount of ETH the contract will sell for `tokenAmount` of tokens
    function ethAmountPerTokenAmount(uint256 tokenAmount) public view returns (uint256) {
        unchecked {
            // Example:
            // if tokenAmount == 3400000000 (3400 USDC) (6 decimals)
            // and price() == 1745910000000000000000 (1745.91) (18 decimals)
            // ((3400000000 * 1e36) / 1745910000000000000000) / 1e6 = 1.947408515e18 (3400/1745.91)
            return ((tokenAmount * 1e36) / price()) / paymentTokenDecimalsDigits;
        }
    }

    /// @notice Returns the amount of tokens the contract can buy and the amount of ETH it will pay for it
    /// This takes into account the current ETH balance this contract has
    /// @return tokenAmount amount of tokens the contract can buy
    /// @return ethAmount amount of ETH it will pay for the tokens
    function tokenAmountNeededAndETHPayout() public view returns (uint256, uint256) {
        uint256 tokenAmount = tokenAmountNeeded();
        uint256 ethAmount = ethAmountPerTokenAmount(tokenAmount);
        uint256 ethAvailable = address(this).balance;

        if (ethAvailable >= ethAmount) {
            return (tokenAmount, ethAmount);
        } else {
            // Tokens amount will be rounded down to avoid trying to buy more eth than available
            tokenAmount = tokenAmountPerEthAmount(ethAvailable);

            // Recalculate eth amount because tokens amount are rounded down
            ethAmount = ethAmountPerTokenAmount(tokenAmount);

            return (tokenAmount, ethAmount);
        }
    }

    /// @notice Returns the amount of tokens the contract expects in return for eth
    /// @param ethAmount amount of ETH contract to be swapped
    /// @return amount of tokens the contract will sell the ETH for
    /// @dev result is rounded down
    function tokenAmountPerEthAmount(uint256 ethAmount) public view returns (uint256) {
        return (ethAmount * price() * paymentTokenDecimalsDigits) / 1e36;
    }

    /**
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
      ADMIN or OWNER TRANSACTIONS
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
     */

    /// @notice Update `botDiscountBPs`
    function setBotDiscountBPs(uint16 newBotDiscountBPs) external onlyAdminOrOwner {
        // Admin is limited to min-max range, owner is not
        if (
            admin == msg.sender &&
            (newBotDiscountBPs < minAdminBotDiscountBPs || newBotDiscountBPs > maxAdminBotDiscountBPs)
        ) {
            revert InvalidBotDiscountBPs();
        }

        emit BotDiscountBPsSet(botDiscountBPs, newBotDiscountBPs);

        botDiscountBPs = newBotDiscountBPs;
    }

    /// @notice Update `baselinePaymentTokenAmount`
    /// @param newBaselinePaymentTokenAmount the new `baselinePaymentTokenAmount` in token decimals.
    function setBaselinePaymentTokenAmount(uint256 newBaselinePaymentTokenAmount) external onlyAdminOrOwner {
        // Admin is limited to min-max range, owner is not
        if (
            admin == msg.sender &&
            (newBaselinePaymentTokenAmount < minAdminBaselinePaymentTokenAmount ||
                newBaselinePaymentTokenAmount > maxAdminBaselinePaymentTokenAmount)
        ) {
            revert InvalidBaselinePaymentTokenAmount();
        }

        emit BaselinePaymentTokenAmountSet(baselinePaymentTokenAmount, newBaselinePaymentTokenAmount);

        baselinePaymentTokenAmount = newBaselinePaymentTokenAmount;
    }

    /// @notice pause ETH buying
    function pause() external onlyAdminOrOwner {
        _pause();
    }

    /// @notice unpause ETH buying
    function unpause() external onlyAdminOrOwner {
        _unpause();
    }

    /// @notice Withdraw all ETH to the contract owner
    function withdrawETH() external onlyAdminOrOwner {
        uint256 amount = address(this).balance;
        address to = owner();

        (bool sent, bytes memory data) = to.call{ value: amount }('');
        if (!sent) {
            revert FailedWithdrawingETH(data);
        }

        emit ETHWithdrawn(to, amount);
    }

    /// @notice set a new Admin
    function setAdmin(address newAdmin) external onlyAdminOrOwner {
        emit AdminSet(admin, newAdmin);

        admin = newAdmin;
    }

    /**
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
      OWNER TRANSACTIONS
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
     */

    /// @notice Update minAdminBotDiscountBPs
    function setMinAdminBotDiscountBPs(uint16 newMinAdminBotDiscountBPs) external onlyOwner {
        emit MinAdminBotDiscountBPsSet(minAdminBotDiscountBPs, newMinAdminBotDiscountBPs);

        minAdminBotDiscountBPs = newMinAdminBotDiscountBPs;
    }

    /// @notice Update maxAdminBotDiscountBPs
    function setMaxAdminBotDiscountBPs(uint16 newMaxAdminBotDiscountBPs) external onlyOwner {
        emit MaxAdminBotDiscountBPsSet(maxAdminBotDiscountBPs, newMaxAdminBotDiscountBPs);

        maxAdminBotDiscountBPs = newMaxAdminBotDiscountBPs;
    }

    /// @notice Update minAdminBaselinePaymentTokenAmount
    function setMinAdminBaselinePaymentTokenAmount(uint256 newMinAdminBaselinePaymentTokenAmount) external onlyOwner {
        emit MinAdminBaselinePaymentTokenAmountSet(
            minAdminBaselinePaymentTokenAmount,
            newMinAdminBaselinePaymentTokenAmount
        );

        minAdminBaselinePaymentTokenAmount = newMinAdminBaselinePaymentTokenAmount;
    }

    /// @notice Update maxAdminBaselinePaymentTokenAmount
    function setMaxAdminBaselinePaymentTokenAmount(uint256 newMaxAdminBaselinePaymentTokenAmount) external onlyOwner {
        emit MaxAdminBaselinePaymentTokenAmountSet(
            maxAdminBaselinePaymentTokenAmount,
            newMaxAdminBaselinePaymentTokenAmount
        );

        maxAdminBaselinePaymentTokenAmount = newMaxAdminBaselinePaymentTokenAmount;
    }

    /// @notice Update priceFeed
    function setPriceFeed(IPriceFeed newPriceFeed) external onlyOwner {
        emit PriceFeedSet(address(priceFeed), address(newPriceFeed));

        priceFeed = newPriceFeed;
    }

    /// @notice Update `payer`
    function setPayer(address newPayer) external onlyOwner {
        emit PayerSet(address(payer), newPayer);

        payer = IPayer(newPayer);
    }

    /**
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
      INTERNAL FUNCTIONS
     ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
     */

    function safeSendETH(
        address to,
        uint256 ethAmount,
        bytes memory data
    ) internal {
        // If contract balance is insufficient it reverts
        (bool sent, bytes memory returnData) = to.call{ value: ethAmount }(data);
        if (!sent) {
            revert FailedSendingETH(returnData);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (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 Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        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);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

File 4 of 14 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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);

    /**
     * @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 `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, 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 `from` to `to` 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 from,
        address to,
        uint256 amount
    ) external returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

// 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;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`.
        // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.
        // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.
        // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a
        // good first aproximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1;
        uint256 x = a;
        if (x >> 128 > 0) {
            x >>= 128;
            result <<= 64;
        }
        if (x >> 64 > 0) {
            x >>= 64;
            result <<= 32;
        }
        if (x >> 32 > 0) {
            x >>= 32;
            result <<= 16;
        }
        if (x >> 16 > 0) {
            x >>= 16;
            result <<= 8;
        }
        if (x >> 8 > 0) {
            x >>= 8;
            result <<= 4;
        }
        if (x >> 4 > 0) {
            x >>= 4;
            result <<= 2;
        }
        if (x >> 2 > 0) {
            result <<= 1;
        }

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        uint256 result = sqrt(a);
        if (rounding == Rounding.Up && result * result < a) {
            result += 1;
        }
        return result;
    }
}

File 12 of 14 : IBuyETHCallback.sol
// SPDX-License-Identifier: GPL-3.0

/// @title buyETH Callback interface

/*********************************
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░█████████░░█████████░░░ *
 * ░░░░░░██░░░████░░██░░░████░░░ *
 * ░░██████░░░████████░░░████░░░ *
 * ░░██░░██░░░████░░██░░░████░░░ *
 * ░░██░░██░░░████░░██░░░████░░░ *
 * ░░░░░░█████████░░█████████░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 *********************************/

pragma solidity ^0.8.17;

interface IBuyETHCallback {
    /**
     * @notice Called on the {to} in TokenBuyer#buyETH, with `msg.value` ETH payment in exchange for {amount} TokenBuyer#paymentToken.
     * @param caller the `msg.sender` in TokenBuyer#buyETH
     * @param amount the TokenBuyer#paymentToken amount caller is buying ETH with
     * @param data arbitrary data passed through by the caller via the TokenBuyer#buyETH call
     */
    function buyETHCallback(
        address caller,
        uint256 amount,
        bytes calldata data
    ) external payable;
}

// SPDX-License-Identifier: GPL-3.0

/// @title PriceFeed Interface

/*********************************
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░█████████░░█████████░░░ *
 * ░░░░░░██░░░████░░██░░░████░░░ *
 * ░░██████░░░████████░░░████░░░ *
 * ░░██░░██░░░████░░██░░░████░░░ *
 * ░░██░░██░░░████░░██░░░████░░░ *
 * ░░░░░░█████████░░█████████░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 *********************************/

pragma solidity ^0.8.17;

import { IERC20 } from 'openzeppelin-contracts/contracts/token/ERC20/IERC20.sol';

interface IPayer {
    function payBackDebt(uint256 amount) external;

    function totalDebt() external view returns (uint256);

    function paymentToken() external view returns (IERC20);
}

File 14 of 14 : IPriceFeed.sol
// SPDX-License-Identifier: GPL-3.0

/// @title PriceFeed Interface

/*********************************
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░█████████░░█████████░░░ *
 * ░░░░░░██░░░████░░██░░░████░░░ *
 * ░░██████░░░████████░░░████░░░ *
 * ░░██░░██░░░████░░██░░░████░░░ *
 * ░░██░░██░░░████░░██░░░████░░░ *
 * ░░░░░░█████████░░█████████░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 *********************************/

pragma solidity ^0.8.17;

interface IPriceFeed {
    /**
     * @return uin256 Token/ETH price in WAD format
     */
    function price() external view returns (uint256);
}

Settings
{
  "remappings": [
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 10000
  },
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"contract IPriceFeed","name":"_priceFeed","type":"address"},{"internalType":"uint256","name":"_baselinePaymentTokenAmount","type":"uint256"},{"internalType":"uint256","name":"_minAdminBaselinePaymentTokenAmount","type":"uint256"},{"internalType":"uint256","name":"_maxAdminBaselinePaymentTokenAmount","type":"uint256"},{"internalType":"uint16","name":"_botDiscountBPs","type":"uint16"},{"internalType":"uint16","name":"_minAdminBotDiscountBPs","type":"uint16"},{"internalType":"uint16","name":"_maxAdminBotDiscountBPs","type":"uint16"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_admin","type":"address"},{"internalType":"address","name":"_payer","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"FailedSendingETH","type":"error"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"FailedWithdrawingETH","type":"error"},{"inputs":[],"name":"InvalidBaselinePaymentTokenAmount","type":"error"},{"inputs":[],"name":"InvalidBotDiscountBPs","type":"error"},{"inputs":[],"name":"OnlyAdminOrOwner","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"actual","type":"uint256"}],"name":"ReceivedInsufficientTokens","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newAmount","type":"uint256"}],"name":"BaselinePaymentTokenAmountSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"oldBPs","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"newBPs","type":"uint16"}],"name":"BotDiscountBPsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ETHWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newAmount","type":"uint256"}],"name":"MaxAdminBaselinePaymentTokenAmountSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"oldBPs","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"newBPs","type":"uint16"}],"name":"MaxAdminBotDiscountBPsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newAmount","type":"uint256"}],"name":"MinAdminBaselinePaymentTokenAmountSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"oldBPs","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"newBPs","type":"uint16"}],"name":"MinAdminBotDiscountBPsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldPayer","type":"address"},{"indexed":false,"internalType":"address","name":"newPayer","type":"address"}],"name":"PayerSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldFeed","type":"address"},{"indexed":false,"internalType":"address","name":"newFeed","type":"address"}],"name":"PriceFeedSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"ethOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenIn","type":"uint256"}],"name":"SoldETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"MAX_BPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baselinePaymentTokenAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"botDiscountBPs","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"buyETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"buyETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"ethAmountPerTokenAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"additionalTokens","type":"uint256"},{"internalType":"uint256","name":"bufferBPs","type":"uint256"}],"name":"ethNeeded","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxAdminBaselinePaymentTokenAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxAdminBotDiscountBPs","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minAdminBaselinePaymentTokenAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minAdminBotDiscountBPs","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"payer","outputs":[{"internalType":"contract IPayer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paymentToken","outputs":[{"internalType":"contract IERC20Metadata","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paymentTokenDecimalsDigits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceFeed","outputs":[{"internalType":"contract IPriceFeed","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"setAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newBaselinePaymentTokenAmount","type":"uint256"}],"name":"setBaselinePaymentTokenAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newBotDiscountBPs","type":"uint16"}],"name":"setBotDiscountBPs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMaxAdminBaselinePaymentTokenAmount","type":"uint256"}],"name":"setMaxAdminBaselinePaymentTokenAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newMaxAdminBotDiscountBPs","type":"uint16"}],"name":"setMaxAdminBotDiscountBPs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMinAdminBaselinePaymentTokenAmount","type":"uint256"}],"name":"setMinAdminBaselinePaymentTokenAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newMinAdminBotDiscountBPs","type":"uint16"}],"name":"setMinAdminBotDiscountBPs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newPayer","type":"address"}],"name":"setPayer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPriceFeed","name":"newPriceFeed","type":"address"}],"name":"setPriceFeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tokenAmountNeeded","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenAmountNeededAndETHPayout","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ethAmount","type":"uint256"}],"name":"tokenAmountPerEthAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60c06040523480156200001157600080fd5b50604051620028ba380380620028ba8339810160408190526200003491620002d9565b6200003f3362000258565b6000805460ff60a01b1916815560018055600280546001600160a01b0319166001600160a01b03841690811790915560408051633013ce2960e01b81529051633013ce29916004808201926020929091908290030181865afa158015620000aa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000d091906200039b565b9050806001600160a01b03166080816001600160a01b031681525050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200012b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001519190620003c2565b6200015e90600a620004fc565b60a052600380546001600160a01b0319166001600160a01b038d1617905560048a90556005899055600688905561271061ffff88161180620001a557506127108561ffff16115b80620001b857508461ffff168661ffff16115b15620001d75760405163a125f00160e01b815260040160405180910390fd5b6007805461ffff8781166401000000000261ffff60201b198a8316620100000263ffffffff19909416928c169290921792909217161790556200021a8462000258565b5050600780546001600160a01b03909216660100000000000002600160301b600160d01b0319909216919091179055506200050d9650505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b0381168114620002be57600080fd5b50565b805161ffff81168114620002d457600080fd5b919050565b6000806000806000806000806000806101408b8d031215620002fa57600080fd5b8a516200030781620002a8565b809a505060208b0151985060408b0151975060608b015196506200032e60808c01620002c1565b95506200033e60a08c01620002c1565b94506200034e60c08c01620002c1565b935060e08b01516200036081620002a8565b6101008c01519093506200037481620002a8565b6101208c01519092506200038881620002a8565b809150509295989b9194979a5092959850565b600060208284031215620003ae57600080fd5b8151620003bb81620002a8565b9392505050565b600060208284031215620003d557600080fd5b815160ff81168114620003bb57600080fd5b634e487b7160e01b600052601160045260246000fd5b600181815b808511156200043e578160001904821115620004225762000422620003e7565b808516156200043057918102915b93841c939080029062000402565b509250929050565b6000826200045757506001620004f6565b816200046657506000620004f6565b81600181146200047f57600281146200048a57620004aa565b6001915050620004f6565b60ff8411156200049e576200049e620003e7565b50506001821b620004f6565b5060208310610133831016604e8410600b8410161715620004cf575081810a620004f6565b620004db8383620003fd565b8060001904821115620004f257620004f2620003e7565b0290505b92915050565b6000620003bb60ff84168362000446565b60805160a05161235d6200055d6000396000818161031901528181610a2d015261106d0152600081816102d001528181610f720152818161119c015281816112b701526116c8015261235d6000f3fe6080604052600436106102535760003560e01c80637f5a504e11610138578063cbe49af7116100b0578063efbf81851161007f578063f851a44011610064578063f851a440146106a9578063f8e9bd91146106d3578063fd967f47146106f357600080fd5b8063efbf818514610669578063f2fde38b1461068957600080fd5b8063cbe49af7146105f3578063d531b73814610613578063d55e697514610634578063e086e5ec1461065457600080fd5b8063a00f8d1011610107578063a5409396116100ec578063a54093961461059b578063c8936e43146105b0578063cb852c6b146105d357600080fd5b8063a00f8d1014610566578063a035b1fe1461058657600080fd5b80637f5a504e146104fd5780638456cb591461051d578063846e6ca1146105325780638da5cb5b1461054857600080fd5b80635c975abb116101cb578063715018a61161019a578063741bef1a1161017f578063741bef1a1461049d578063767e34da146104bd5780637a7f7908146104d357600080fd5b8063715018a614610468578063724e78da1461047d57600080fd5b80635c975abb146103bf5780636077588e146103fa5780636d617edb1461041a578063704b6c021461044857600080fd5b806341f32f27116102225780634ada1ddc116102075780634ada1ddc1461036957806355c7c19a1461037f57806356df74a21461039f57600080fd5b806341f32f271461030757806341fbc6451461034957600080fd5b8063123119cd1461025f5780632cf9e5261461029c5780633013ce29146102be5780633f4ba83a146102f257600080fd5b3661025a57005b600080fd5b34801561026b57600080fd5b5060025461027f906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156102a857600080fd5b506102bc6102b7366004611ffb565b610709565b005b3480156102ca57600080fd5b5061027f7f000000000000000000000000000000000000000000000000000000000000000081565b3480156102fe57600080fd5b506102bc61087b565b34801561031357600080fd5b5061033b7f000000000000000000000000000000000000000000000000000000000000000081565b604051908152602001610293565b34801561035557600080fd5b506102bc61036436600461201f565b6108fb565b34801561037557600080fd5b5061033b60045481565b34801561038b57600080fd5b5061033b61039a36600461201f565b610a19565b3480156103ab57600080fd5b506102bc6103ba36600461201f565b610a78565b3480156103cb57600080fd5b5060005474010000000000000000000000000000000000000000900460ff166040519015158152602001610293565b34801561040657600080fd5b506102bc610415366004611ffb565b610ac1565b34801561042657600080fd5b506007546104359061ffff1681565b60405161ffff9091168152602001610293565b34801561045457600080fd5b506102bc61046336600461204d565b610b50565b34801561047457600080fd5b506102bc610c5b565b34801561048957600080fd5b506102bc61049836600461204d565b610c6d565b3480156104a957600080fd5b5060035461027f906001600160a01b031681565b3480156104c957600080fd5b5061033b60055481565b3480156104df57600080fd5b506104e8610cf6565b60408051928352602083019190915201610293565b34801561050957600080fd5b506102bc61051836600461201f565b610d44565b34801561052957600080fd5b506102bc610d8d565b34801561053e57600080fd5b5061033b60065481565b34801561055457600080fd5b506000546001600160a01b031661027f565b34801561057257600080fd5b5061033b61058136600461206a565b610e0b565b34801561059257600080fd5b5061033b610e7d565b3480156105a757600080fd5b5061033b610f2e565b3480156105bc57600080fd5b5060075461043590640100000000900461ffff1681565b3480156105df57600080fd5b5061033b6105ee36600461201f565b611069565b3480156105ff57600080fd5b506102bc61060e36600461208c565b6110c8565b34801561061f57600080fd5b506007546104359062010000900461ffff1681565b34801561064057600080fd5b506102bc61064f36600461204d565b611439565b34801561066057600080fd5b506102bc6114c2565b34801561067557600080fd5b506102bc61068436600461201f565b611629565b34801561069557600080fd5b506102bc6106a436600461204d565b6117cf565b3480156106b557600080fd5b5060075461027f90660100000000000090046001600160a01b031681565b3480156106df57600080fd5b506102bc6106ee366004611ffb565b611879565b3480156106ff57600080fd5b5061033b61271081565b600754660100000000000090046001600160a01b0316331480159061074857503361073c6000546001600160a01b031690565b6001600160a01b031614155b1561077f576040517f61685c2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600754660100000000000090046001600160a01b0316331480156107cd575060075461ffff62010000909104811690821610806107cd575060075461ffff6401000000009091048116908216115b15610804576040517fa125f00100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6007546040805161ffff928316815291831660208301527f15c16d22d1ab90fd24399d246f236dde2e9d89b37cd372aef4309a90e4818910910160405180910390a1600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001661ffff92909216919091179055565b600754660100000000000090046001600160a01b031633148015906108ba5750336108ae6000546001600160a01b031690565b6001600160a01b031614155b156108f1576040517f61685c2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108f9611904565b565b600754660100000000000090046001600160a01b0316331480159061093a57503361092e6000546001600160a01b031690565b6001600160a01b031614155b15610971576040517f61685c2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600754660100000000000090046001600160a01b0316331480156109a157506005548110806109a1575060065481115b156109d8576040517f8966bc1d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60045460408051918252602082018390527f3975fac7851fdaefdf20c77fbcd94534d3cfab47b5db3ebaf076dbb643ce97ec910160405180910390a1600455565b60006ec097ce7bc90715b34b9f10000000007f0000000000000000000000000000000000000000000000000000000000000000610a54610e7d565b610a5e9085612144565b610a689190612144565b610a72919061218a565b92915050565b610a80611974565b60065460408051918252602082018390527f7125a69f372e65066618280ea1afcf6f95bdedc9573a15e792e75872f4af2cf3910160405180910390a1600655565b610ac9611974565b6007546040805161ffff6401000000009093048316815291831660208301527fa30533600f5a24061dc6e4171e435347cbdda4b09edea6e9b638201db41858b0910160405180910390a16007805461ffff909216640100000000027fffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffffffff909216919091179055565b600754660100000000000090046001600160a01b03163314801590610b8f575033610b836000546001600160a01b031690565b6001600160a01b031614155b15610bc6576040517f61685c2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600754604080516001600160a01b0366010000000000009093048316815291831660208301527fbf265e8326285a2747e33e54d5945f7111f2b5edb826eb8c08d4677779b3ff97910160405180910390a1600780546001600160a01b039092166601000000000000027fffffffffffff0000000000000000000000000000000000000000ffffffffffff909216919091179055565b610c63611974565b6108f960006119e8565b610c75611974565b600354604080516001600160a01b03928316815291831660208301527fd2d8394cf7549a5ddbc2ba3dd7b2de8d53c891472d1f2907008ed6a10045fdae910160405180910390a1600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6000806000610d03610f2e565b90506000610d1082611069565b905047818110610d24575090939092509050565b610d2d81610a19565b9250610d3883611069565b92959294509192505050565b610d4c611974565b60055460408051918252602082018390527f395dd7ab1853c254de5620612bc4af58b1dbb7a125c3b363e26f8b3f09c01249910160405180910390a1600555565b600754660100000000000090046001600160a01b03163314801590610dcc575033610dc06000546001600160a01b031690565b6001600160a01b031614155b15610e03576040517f61685c2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108f9611a50565b60008083610e17610f2e565b610e2191906121c5565b90506000610e2e82611069565b90506000612710610e3f86826121c5565b610e499084612144565b610e53919061218a565b905080471115610e695760009350505050610a72565b610e7347826121d8565b9695505050505050565b600754600354604080517fa035b1fe00000000000000000000000000000000000000000000000000000000815290516000936127109361ffff9182168503909116926001600160a01b039091169163a035b1fe916004808201926020929091908290030181865afa158015610ef6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1a91906121eb565b0281610f2857610f2861215b565b04905090565b6002546040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b0391821660048201819052600092909183917f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa158015610fb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fdd91906121eb565b90506000826001600160a01b031663fc7b9c186040518163ffffffff1660e01b8152600401602060405180830381865afa15801561101f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104391906121eb565b60045490915081018083111561105e57600094505050505090565b919091039392505050565b60007f0000000000000000000000000000000000000000000000000000000000000000611094610e7d565b836ec097ce7bc90715b34b9f100000000002816110b3576110b361215b565b04816110c1576110c161215b565b0492915050565b600260015403611139576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b6002600155611146611abf565b600061115985611154610f2e565b611b44565b6002546040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b03918216600482018190529293506000917f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa1580156111e3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061120791906121eb565b9050600061121484611069565b9050866001600160a01b031663fa58e18c8233878a8a6040518663ffffffff1660e01b81526004016112499493929190612204565b6000604051808303818588803b15801561126257600080fd5b505af1158015611276573d6000803e3d6000fd5b50506040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b038781166004830152600094508693507f00000000000000000000000000000000000000000000000000000000000000001691506370a0823190602401602060405180830381865afa1580156112ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132391906121eb565b61132d91906121d8565b905084811015611373576040517f1e93baf50000000000000000000000000000000000000000000000000000000081526004810186905260248101829052604401611130565b6040517f842a3136000000000000000000000000000000000000000000000000000000008152600481018290526001600160a01b0385169063842a313690602401600060405180830381600087803b1580156113ce57600080fd5b505af11580156113e2573d6000803e3d6000fd5b505060408051858152602081018590526001600160a01b038c1693507fc562ae7c506d42d322f7877f39d1a877a98c8960808350c7f903e7f0a7fe51db92500160405180910390a250506001805550505050505050565b611441611974565b600254604080516001600160a01b03928316815291831660208301527f1702a4c98b1577a75e1e0e26c758dbc496fa631d8dbedfbe8f2a4120242afa0b910160405180910390a1600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b600754660100000000000090046001600160a01b031633148015906115015750336114f56000546001600160a01b031690565b6001600160a01b031614155b15611538576040517f61685c2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b47600061154d6000546001600160a01b031690565b9050600080826001600160a01b03168460405160006040518083038185875af1925050503d806000811461159d576040519150601f19603f3d011682016040523d82523d6000602084013e6115a2565b606091505b5091509150816115e057806040517f6a30b5a500000000000000000000000000000000000000000000000000000000815260040161113091906122d6565b826001600160a01b03167f94b2de810873337ed265c5f8cf98c9cffefa06b8607f9a2f1fbaebdfbcfbef1c8560405161161b91815260200190565b60405180910390a250505050565b600260015403611695576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401611130565b60026001556116a2611abf565b60006116b082611154610f2e565b6002549091506001600160a01b03908116906116f0907f000000000000000000000000000000000000000000000000000000000000000016338385611b5c565b6040517f842a3136000000000000000000000000000000000000000000000000000000008152600481018390526001600160a01b0382169063842a313690602401600060405180830381600087803b15801561174b57600080fd5b505af115801561175f573d6000803e3d6000fd5b50505050600061176e83611069565b905061178a338260405180602001604052806000815250611bea565b604080518281526020810185905233917fc562ae7c506d42d322f7877f39d1a877a98c8960808350c7f903e7f0a7fe51db910160405180910390a25050600180555050565b6117d7611974565b6001600160a01b03811661186d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401611130565b611876816119e8565b50565b611881611974565b6007546040805161ffff620100009093048316815291831660208301527fe59c9d139de8469b03def7f51901e2659ec47150588f73a0f2359e1ac3b30d06910160405180910390a16007805461ffff90921662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff909216919091179055565b61190c611c8d565b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000546001600160a01b031633146108f9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401611130565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b611a58611abf565b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586119573390565b60005474010000000000000000000000000000000000000000900460ff16156108f9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401611130565b6000818310611b535781611b55565b825b9392505050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052611be4908590611d11565b50505050565b600080846001600160a01b03168484604051611c0691906122e9565b60006040518083038185875af1925050503d8060008114611c43576040519150601f19603f3d011682016040523d82523d6000602084013e611c48565b606091505b509150915081611c8657806040517fa656af4300000000000000000000000000000000000000000000000000000000815260040161113091906122d6565b5050505050565b60005474010000000000000000000000000000000000000000900460ff166108f9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401611130565b6000611d66826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611e159092919063ffffffff16565b805190915015611e105780806020019051810190611d849190612305565b611e10576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401611130565b505050565b6060611e248484600085611e2c565b949350505050565b606082471015611ebe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401611130565b6001600160a01b0385163b611f2f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611130565b600080866001600160a01b03168587604051611f4b91906122e9565b60006040518083038185875af1925050503d8060008114611f88576040519150601f19603f3d011682016040523d82523d6000602084013e611f8d565b606091505b5091509150611f9d828286611fa8565b979650505050505050565b60608315611fb7575081611b55565b825115611fc75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161113091906122d6565b60006020828403121561200d57600080fd5b813561ffff81168114611b5557600080fd5b60006020828403121561203157600080fd5b5035919050565b6001600160a01b038116811461187657600080fd5b60006020828403121561205f57600080fd5b8135611b5581612038565b6000806040838503121561207d57600080fd5b50508035926020909101359150565b600080600080606085870312156120a257600080fd5b8435935060208501356120b481612038565b9250604085013567ffffffffffffffff808211156120d157600080fd5b818701915087601f8301126120e557600080fd5b8135818111156120f457600080fd5b88602082850101111561210657600080fd5b95989497505060200194505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082028115828204841417610a7257610a72612115565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000826121c0577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b80820180821115610a7257610a72612115565b81810381811115610a7257610a72612115565b6000602082840312156121fd57600080fd5b5051919050565b6001600160a01b038516815283602082015260606040820152816060820152818360808301376000818301608090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01601019392505050565b60005b8381101561228357818101518382015260200161226b565b50506000910152565b600081518084526122a4816020860160208601612268565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000611b55602083018461228c565b600082516122fb818460208701612268565b9190910192915050565b60006020828403121561231757600080fd5b81518015158114611b5557600080fdfea26469706673582212205963633d923e907c74a266aa19c5000cf79106dfb15fd4accf65b9cba55c8f6f64736f6c6343000811003300000000000000000000000005e651bc3a7f7b7640cad61dc383ca28ae000cce000000000000000000000000000000000000000000000000000000746a5288000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e8d4a51000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000960000000000000000000000000bc3807ec262cb779b38d65b38158acc3bfede1000000000000000000000000079095391743e0f017a16c388de6a6a3f175a5cd5000000000000000000000000d97bcd9f47cee35c0a9ec1dc40c1269afc9e8e1d

Deployed Bytecode

0x6080604052600436106102535760003560e01c80637f5a504e11610138578063cbe49af7116100b0578063efbf81851161007f578063f851a44011610064578063f851a440146106a9578063f8e9bd91146106d3578063fd967f47146106f357600080fd5b8063efbf818514610669578063f2fde38b1461068957600080fd5b8063cbe49af7146105f3578063d531b73814610613578063d55e697514610634578063e086e5ec1461065457600080fd5b8063a00f8d1011610107578063a5409396116100ec578063a54093961461059b578063c8936e43146105b0578063cb852c6b146105d357600080fd5b8063a00f8d1014610566578063a035b1fe1461058657600080fd5b80637f5a504e146104fd5780638456cb591461051d578063846e6ca1146105325780638da5cb5b1461054857600080fd5b80635c975abb116101cb578063715018a61161019a578063741bef1a1161017f578063741bef1a1461049d578063767e34da146104bd5780637a7f7908146104d357600080fd5b8063715018a614610468578063724e78da1461047d57600080fd5b80635c975abb146103bf5780636077588e146103fa5780636d617edb1461041a578063704b6c021461044857600080fd5b806341f32f27116102225780634ada1ddc116102075780634ada1ddc1461036957806355c7c19a1461037f57806356df74a21461039f57600080fd5b806341f32f271461030757806341fbc6451461034957600080fd5b8063123119cd1461025f5780632cf9e5261461029c5780633013ce29146102be5780633f4ba83a146102f257600080fd5b3661025a57005b600080fd5b34801561026b57600080fd5b5060025461027f906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156102a857600080fd5b506102bc6102b7366004611ffb565b610709565b005b3480156102ca57600080fd5b5061027f7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b3480156102fe57600080fd5b506102bc61087b565b34801561031357600080fd5b5061033b7f00000000000000000000000000000000000000000000000000000000000f424081565b604051908152602001610293565b34801561035557600080fd5b506102bc61036436600461201f565b6108fb565b34801561037557600080fd5b5061033b60045481565b34801561038b57600080fd5b5061033b61039a36600461201f565b610a19565b3480156103ab57600080fd5b506102bc6103ba36600461201f565b610a78565b3480156103cb57600080fd5b5060005474010000000000000000000000000000000000000000900460ff166040519015158152602001610293565b34801561040657600080fd5b506102bc610415366004611ffb565b610ac1565b34801561042657600080fd5b506007546104359061ffff1681565b60405161ffff9091168152602001610293565b34801561045457600080fd5b506102bc61046336600461204d565b610b50565b34801561047457600080fd5b506102bc610c5b565b34801561048957600080fd5b506102bc61049836600461204d565b610c6d565b3480156104a957600080fd5b5060035461027f906001600160a01b031681565b3480156104c957600080fd5b5061033b60055481565b3480156104df57600080fd5b506104e8610cf6565b60408051928352602083019190915201610293565b34801561050957600080fd5b506102bc61051836600461201f565b610d44565b34801561052957600080fd5b506102bc610d8d565b34801561053e57600080fd5b5061033b60065481565b34801561055457600080fd5b506000546001600160a01b031661027f565b34801561057257600080fd5b5061033b61058136600461206a565b610e0b565b34801561059257600080fd5b5061033b610e7d565b3480156105a757600080fd5b5061033b610f2e565b3480156105bc57600080fd5b5060075461043590640100000000900461ffff1681565b3480156105df57600080fd5b5061033b6105ee36600461201f565b611069565b3480156105ff57600080fd5b506102bc61060e36600461208c565b6110c8565b34801561061f57600080fd5b506007546104359062010000900461ffff1681565b34801561064057600080fd5b506102bc61064f36600461204d565b611439565b34801561066057600080fd5b506102bc6114c2565b34801561067557600080fd5b506102bc61068436600461201f565b611629565b34801561069557600080fd5b506102bc6106a436600461204d565b6117cf565b3480156106b557600080fd5b5060075461027f90660100000000000090046001600160a01b031681565b3480156106df57600080fd5b506102bc6106ee366004611ffb565b611879565b3480156106ff57600080fd5b5061033b61271081565b600754660100000000000090046001600160a01b0316331480159061074857503361073c6000546001600160a01b031690565b6001600160a01b031614155b1561077f576040517f61685c2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600754660100000000000090046001600160a01b0316331480156107cd575060075461ffff62010000909104811690821610806107cd575060075461ffff6401000000009091048116908216115b15610804576040517fa125f00100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6007546040805161ffff928316815291831660208301527f15c16d22d1ab90fd24399d246f236dde2e9d89b37cd372aef4309a90e4818910910160405180910390a1600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001661ffff92909216919091179055565b600754660100000000000090046001600160a01b031633148015906108ba5750336108ae6000546001600160a01b031690565b6001600160a01b031614155b156108f1576040517f61685c2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108f9611904565b565b600754660100000000000090046001600160a01b0316331480159061093a57503361092e6000546001600160a01b031690565b6001600160a01b031614155b15610971576040517f61685c2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600754660100000000000090046001600160a01b0316331480156109a157506005548110806109a1575060065481115b156109d8576040517f8966bc1d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60045460408051918252602082018390527f3975fac7851fdaefdf20c77fbcd94534d3cfab47b5db3ebaf076dbb643ce97ec910160405180910390a1600455565b60006ec097ce7bc90715b34b9f10000000007f00000000000000000000000000000000000000000000000000000000000f4240610a54610e7d565b610a5e9085612144565b610a689190612144565b610a72919061218a565b92915050565b610a80611974565b60065460408051918252602082018390527f7125a69f372e65066618280ea1afcf6f95bdedc9573a15e792e75872f4af2cf3910160405180910390a1600655565b610ac9611974565b6007546040805161ffff6401000000009093048316815291831660208301527fa30533600f5a24061dc6e4171e435347cbdda4b09edea6e9b638201db41858b0910160405180910390a16007805461ffff909216640100000000027fffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffffffff909216919091179055565b600754660100000000000090046001600160a01b03163314801590610b8f575033610b836000546001600160a01b031690565b6001600160a01b031614155b15610bc6576040517f61685c2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600754604080516001600160a01b0366010000000000009093048316815291831660208301527fbf265e8326285a2747e33e54d5945f7111f2b5edb826eb8c08d4677779b3ff97910160405180910390a1600780546001600160a01b039092166601000000000000027fffffffffffff0000000000000000000000000000000000000000ffffffffffff909216919091179055565b610c63611974565b6108f960006119e8565b610c75611974565b600354604080516001600160a01b03928316815291831660208301527fd2d8394cf7549a5ddbc2ba3dd7b2de8d53c891472d1f2907008ed6a10045fdae910160405180910390a1600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6000806000610d03610f2e565b90506000610d1082611069565b905047818110610d24575090939092509050565b610d2d81610a19565b9250610d3883611069565b92959294509192505050565b610d4c611974565b60055460408051918252602082018390527f395dd7ab1853c254de5620612bc4af58b1dbb7a125c3b363e26f8b3f09c01249910160405180910390a1600555565b600754660100000000000090046001600160a01b03163314801590610dcc575033610dc06000546001600160a01b031690565b6001600160a01b031614155b15610e03576040517f61685c2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108f9611a50565b60008083610e17610f2e565b610e2191906121c5565b90506000610e2e82611069565b90506000612710610e3f86826121c5565b610e499084612144565b610e53919061218a565b905080471115610e695760009350505050610a72565b610e7347826121d8565b9695505050505050565b600754600354604080517fa035b1fe00000000000000000000000000000000000000000000000000000000815290516000936127109361ffff9182168503909116926001600160a01b039091169163a035b1fe916004808201926020929091908290030181865afa158015610ef6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1a91906121eb565b0281610f2857610f2861215b565b04905090565b6002546040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b0391821660048201819052600092909183917f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816906370a0823190602401602060405180830381865afa158015610fb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fdd91906121eb565b90506000826001600160a01b031663fc7b9c186040518163ffffffff1660e01b8152600401602060405180830381865afa15801561101f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104391906121eb565b60045490915081018083111561105e57600094505050505090565b919091039392505050565b60007f00000000000000000000000000000000000000000000000000000000000f4240611094610e7d565b836ec097ce7bc90715b34b9f100000000002816110b3576110b361215b565b04816110c1576110c161215b565b0492915050565b600260015403611139576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b6002600155611146611abf565b600061115985611154610f2e565b611b44565b6002546040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b03918216600482018190529293506000917f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816906370a0823190602401602060405180830381865afa1580156111e3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061120791906121eb565b9050600061121484611069565b9050866001600160a01b031663fa58e18c8233878a8a6040518663ffffffff1660e01b81526004016112499493929190612204565b6000604051808303818588803b15801561126257600080fd5b505af1158015611276573d6000803e3d6000fd5b50506040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b038781166004830152600094508693507f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb481691506370a0823190602401602060405180830381865afa1580156112ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132391906121eb565b61132d91906121d8565b905084811015611373576040517f1e93baf50000000000000000000000000000000000000000000000000000000081526004810186905260248101829052604401611130565b6040517f842a3136000000000000000000000000000000000000000000000000000000008152600481018290526001600160a01b0385169063842a313690602401600060405180830381600087803b1580156113ce57600080fd5b505af11580156113e2573d6000803e3d6000fd5b505060408051858152602081018590526001600160a01b038c1693507fc562ae7c506d42d322f7877f39d1a877a98c8960808350c7f903e7f0a7fe51db92500160405180910390a250506001805550505050505050565b611441611974565b600254604080516001600160a01b03928316815291831660208301527f1702a4c98b1577a75e1e0e26c758dbc496fa631d8dbedfbe8f2a4120242afa0b910160405180910390a1600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b600754660100000000000090046001600160a01b031633148015906115015750336114f56000546001600160a01b031690565b6001600160a01b031614155b15611538576040517f61685c2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b47600061154d6000546001600160a01b031690565b9050600080826001600160a01b03168460405160006040518083038185875af1925050503d806000811461159d576040519150601f19603f3d011682016040523d82523d6000602084013e6115a2565b606091505b5091509150816115e057806040517f6a30b5a500000000000000000000000000000000000000000000000000000000815260040161113091906122d6565b826001600160a01b03167f94b2de810873337ed265c5f8cf98c9cffefa06b8607f9a2f1fbaebdfbcfbef1c8560405161161b91815260200190565b60405180910390a250505050565b600260015403611695576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401611130565b60026001556116a2611abf565b60006116b082611154610f2e565b6002549091506001600160a01b03908116906116f0907f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816338385611b5c565b6040517f842a3136000000000000000000000000000000000000000000000000000000008152600481018390526001600160a01b0382169063842a313690602401600060405180830381600087803b15801561174b57600080fd5b505af115801561175f573d6000803e3d6000fd5b50505050600061176e83611069565b905061178a338260405180602001604052806000815250611bea565b604080518281526020810185905233917fc562ae7c506d42d322f7877f39d1a877a98c8960808350c7f903e7f0a7fe51db910160405180910390a25050600180555050565b6117d7611974565b6001600160a01b03811661186d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401611130565b611876816119e8565b50565b611881611974565b6007546040805161ffff620100009093048316815291831660208301527fe59c9d139de8469b03def7f51901e2659ec47150588f73a0f2359e1ac3b30d06910160405180910390a16007805461ffff90921662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff909216919091179055565b61190c611c8d565b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000546001600160a01b031633146108f9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401611130565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b611a58611abf565b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586119573390565b60005474010000000000000000000000000000000000000000900460ff16156108f9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401611130565b6000818310611b535781611b55565b825b9392505050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052611be4908590611d11565b50505050565b600080846001600160a01b03168484604051611c0691906122e9565b60006040518083038185875af1925050503d8060008114611c43576040519150601f19603f3d011682016040523d82523d6000602084013e611c48565b606091505b509150915081611c8657806040517fa656af4300000000000000000000000000000000000000000000000000000000815260040161113091906122d6565b5050505050565b60005474010000000000000000000000000000000000000000900460ff166108f9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401611130565b6000611d66826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611e159092919063ffffffff16565b805190915015611e105780806020019051810190611d849190612305565b611e10576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401611130565b505050565b6060611e248484600085611e2c565b949350505050565b606082471015611ebe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401611130565b6001600160a01b0385163b611f2f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611130565b600080866001600160a01b03168587604051611f4b91906122e9565b60006040518083038185875af1925050503d8060008114611f88576040519150601f19603f3d011682016040523d82523d6000602084013e611f8d565b606091505b5091509150611f9d828286611fa8565b979650505050505050565b60608315611fb7575081611b55565b825115611fc75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161113091906122d6565b60006020828403121561200d57600080fd5b813561ffff81168114611b5557600080fd5b60006020828403121561203157600080fd5b5035919050565b6001600160a01b038116811461187657600080fd5b60006020828403121561205f57600080fd5b8135611b5581612038565b6000806040838503121561207d57600080fd5b50508035926020909101359150565b600080600080606085870312156120a257600080fd5b8435935060208501356120b481612038565b9250604085013567ffffffffffffffff808211156120d157600080fd5b818701915087601f8301126120e557600080fd5b8135818111156120f457600080fd5b88602082850101111561210657600080fd5b95989497505060200194505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082028115828204841417610a7257610a72612115565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000826121c0577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b80820180821115610a7257610a72612115565b81810381811115610a7257610a72612115565b6000602082840312156121fd57600080fd5b5051919050565b6001600160a01b038516815283602082015260606040820152816060820152818360808301376000818301608090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01601019392505050565b60005b8381101561228357818101518382015260200161226b565b50506000910152565b600081518084526122a4816020860160208601612268565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000611b55602083018461228c565b600082516122fb818460208701612268565b9190910192915050565b60006020828403121561231757600080fd5b81518015158114611b5557600080fdfea26469706673582212205963633d923e907c74a266aa19c5000cf79106dfb15fd4accf65b9cba55c8f6f64736f6c63430008110033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000005e651bc3a7f7b7640cad61dc383ca28ae000cce000000000000000000000000000000000000000000000000000000746a5288000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e8d4a51000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000960000000000000000000000000bc3807ec262cb779b38d65b38158acc3bfede1000000000000000000000000079095391743e0f017a16c388de6a6a3f175a5cd5000000000000000000000000d97bcd9f47cee35c0a9ec1dc40c1269afc9e8e1d

-----Decoded View---------------
Arg [0] : _priceFeed (address): 0x05e651Bc3a7f7B7640cAD61dC383ca28Ae000cce
Arg [1] : _baselinePaymentTokenAmount (uint256): 500000000000
Arg [2] : _minAdminBaselinePaymentTokenAmount (uint256): 0
Arg [3] : _maxAdminBaselinePaymentTokenAmount (uint256): 1000000000000
Arg [4] : _botDiscountBPs (uint16): 10
Arg [5] : _minAdminBotDiscountBPs (uint16): 0
Arg [6] : _maxAdminBotDiscountBPs (uint16): 150
Arg [7] : _owner (address): 0x0BC3807Ec262cB779b38D65b38158acC3bfedE10
Arg [8] : _admin (address): 0x79095391743e0f017A16c388De6a6a3f175a5cD5
Arg [9] : _payer (address): 0xd97Bcd9f47cEe35c0a9ec1dc40C1269afc9E8E1D

-----Encoded View---------------
10 Constructor Arguments found :
Arg [0] : 00000000000000000000000005e651bc3a7f7b7640cad61dc383ca28ae000cce
Arg [1] : 000000000000000000000000000000000000000000000000000000746a528800
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [3] : 000000000000000000000000000000000000000000000000000000e8d4a51000
Arg [4] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000096
Arg [7] : 0000000000000000000000000bc3807ec262cb779b38d65b38158acc3bfede10
Arg [8] : 00000000000000000000000079095391743e0f017a16c388de6a6a3f175a5cd5
Arg [9] : 000000000000000000000000d97bcd9f47cee35c0a9ec1dc40c1269afc9e8e1d


Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.