Contract 0x565b72163f17849832a692a3c5928cc502f46d69 4

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x0a6dd33e9081648d1c2967f3706ebb4c19b408346201d7b2d4de20b5c6343d21Transfer111934082021-09-24 12:22:4329 mins ago0x577312ccf462b7ab4c568d4597cd02825aa36dfd IN  PancakeHunny: HUNNY Token0 BNB0.000211755
0xe68aff986a031405a8f3eab4b026bb960794b99a342b56120f20931c4660e89bTransfer111932522021-09-24 12:14:5537 mins ago0x577312ccf462b7ab4c568d4597cd02825aa36dfd IN  PancakeHunny: HUNNY Token0 BNB0.000211755
0xf2740cf7b3962a0a26a421a984e6e5b6b0dfb0f5f3fb1d157ac356450be5821bApprove111932512021-09-24 12:14:5237 mins ago0x95a26811f45b2b7f442d23c4a6560473598af9c4 IN  PancakeHunny: HUNNY Token0 BNB0.00022301
0x75e448751e5687d3ee37499fa59211b63cb505f1c7541718310dd59b2c4885a6Transfer111930012021-09-24 12:02:2249 mins ago0x577312ccf462b7ab4c568d4597cd02825aa36dfd IN  PancakeHunny: HUNNY Token0 BNB0.000211755
0xbaea263e2f086ae6adbd2eb183a0a27d33c45e0e84d2d8de99ff5a9e3e02b4feApprove111928602021-09-24 11:55:1956 mins ago0xd79d7e0c4c07b8d4cb31672a0808deeb10ac4cb1 IN  PancakeHunny: HUNNY Token0 BNB0.00022301
0xe1105abc6d683247c5dffa06706cd2903241722df8dd31bbfd2f7678735e25b6Approve111928042021-09-24 11:52:3159 mins ago0xd79d7e0c4c07b8d4cb31672a0808deeb10ac4cb1 IN  PancakeHunny: HUNNY Token0 BNB0.00022301
0x589a158a60d5ac5c19b784db83ca2b63902450abfd07ef616ab8f0ed5c0b5f9dApprove111927912021-09-24 11:51:521 hr ago0x91edbdb654b6d4caa274d05adb11a3696799d712 IN  PancakeHunny: HUNNY Token0 BNB0.00022301
0xa352126dab173cbac863c2b58978773a19e280cf2b6f73b7ecee9b5ebfaa180eTransfer111925182021-09-24 11:38:131 hr 13 mins ago0x577312ccf462b7ab4c568d4597cd02825aa36dfd IN  PancakeHunny: HUNNY Token0 BNB0.000211755
0x189fea8ef0f390d53a38aa162b8f4e3418656a789cfdd71ee271b82d6cc72fe6Approve111917592021-09-24 10:59:501 hr 52 mins ago0x8c5c7b1660525570288d94424b92e2ef305ead00 IN  PancakeHunny: HUNNY Token0 BNB0.00022301
0x0b798cb97725eaf586779df145e1fe5037a5747dbfa99f5e526a95a21acdbb8bApprove111914732021-09-24 10:45:312 hrs 6 mins ago0xf379688078cebc2cf0c37919b82998b1002cc1b0 IN  PancakeHunny: HUNNY Token0 BNB0.000073045
0xbbb8ad8af9e0fd6bff9f934d446aa757b1adfa60762bf0130d640fd66e3986aeTransfer111914582021-09-24 10:44:462 hrs 7 mins ago0x059c28941ce57b0b588c472412ddc1904a0c94cd IN  PancakeHunny: HUNNY Token0 BNB0.0002159901
0x67125d225c941145b52b221ee6f27ba88628c92b1bb14a8d838cd22b3531dd08Approve111912112021-09-24 10:32:232 hrs 19 mins ago0x517b5f0ff3e84df4cd2b5a742e41ab6c89f526dd IN  PancakeHunny: HUNNY Token0 BNB0.00022301
0x52bcc4c3b48c528fa932da2171d77b835a215e7d3aed9846339ed1415d55bee6Approve111904942021-09-24 9:56:322 hrs 55 mins ago0x695c75695330ae2abbd108397871f15c4e48b08e IN  PancakeHunny: HUNNY Token0 BNB0.00012701
0x3c4e9f681cf724ce3b7671261d69b9fc827ad84c93c008a083ee2dab0996da00Approve111904822021-09-24 9:55:562 hrs 56 mins ago0x3fb408ba73569d6d8367483074c0cc38649b4a41 IN  PancakeHunny: HUNNY Token0 BNB0.00022301
0x48b35a5874b0cf748cfc9c958dc856745487e890323b3d161828a3bfccb53184Approve111904812021-09-24 9:55:532 hrs 56 mins ago0x0140d8dc12088080515f331d34bd94cd0231496b IN  PancakeHunny: HUNNY Token0 BNB0.00022301
0x0e46157b101d2c87af3125d8c1e10b25991a4767799ce328060d9e6ebd926609Approve111904772021-09-24 9:55:412 hrs 56 mins ago0x695c75695330ae2abbd108397871f15c4e48b08e IN  PancakeHunny: HUNNY Token0 BNB0.00012701
0x46c03dc70624e3f85de5b01522468ecb348ee1d01b4dc438c99341a268212e9dApprove111904612021-09-24 9:54:532 hrs 57 mins ago0x695c75695330ae2abbd108397871f15c4e48b08e IN  PancakeHunny: HUNNY Token0 BNB0.00022301
0x812ea5cebb563d94908f9678aabb15db922684af36141f25e4df1af4b03094ebApprove111894282021-09-24 9:03:073 hrs 48 mins ago0x5dd7426ec563248d34db174cc4a8625dcff7cdbe IN  PancakeHunny: HUNNY Token0 BNB0.00022301
0xb9699206d8194b739aabe3b18dcc03539a435ae29fef9275be7d2a2ffca88be8Approve111890692021-09-24 8:45:104 hrs 6 mins ago0x4fe993b09411007d848c874942a29b0ff0b27285 IN  PancakeHunny: HUNNY Token0 BNB0.00022301
0x454d96598b632760292478573466cf405132cc14892f756e7126a375ffa33ee3Approve111889582021-09-24 8:39:374 hrs 12 mins ago0xa6fad4946732e3d22bb300bb4fc6897798c99ccb IN  PancakeHunny: HUNNY Token0 BNB0.00022301
0x0fc5ebf8b81e36b6670a573849b061b9911928ec84709fbaca4acbad64667093Approve111889152021-09-24 8:37:284 hrs 14 mins ago0x091330dd975cc1f42902090ed818c80ad1466add IN  PancakeHunny: HUNNY Token0 BNB0.00022301
0x905c265daa3a884392b358ab84853a7153ecfdad42bc52bbafb45bb8da5038e7Approve111887782021-09-24 8:30:374 hrs 21 mins ago0xf0158738ce373828292efade6605b31cc124dad6 IN  PancakeHunny: HUNNY Token0 BNB0.00022301
0xd14a5cb3355bc0f0bd46e695a9027fe01c42bdd2a092958b8916c6ef060daf6bApprove111887312021-09-24 8:28:164 hrs 23 mins ago0x35e7423c1b134d142dca5b5383adace38336d71c IN  PancakeHunny: HUNNY Token0 BNB0.00022301
0x49394081d33a2d58a4d7ab2b30bfa5a9e91df3b72fbe429d07e25363a9cc38a0Approve111884002021-09-24 8:11:434 hrs 40 mins ago0xa04df46dfdf2c6aad9676f63823bce57cc470620 IN  PancakeHunny: HUNNY Token0 BNB0.00022301
0x82be2d9d9cdc69c22f3a6e91a26f3114775819d0ca32310bc0cfd27c0440426eTransfer111881192021-09-24 7:57:244 hrs 54 mins ago0x4b5b37165938b5d406136dbf6f6a62698a1ea425 IN  PancakeHunny: HUNNY Token0 BNB0.00019693
[ Download CSV Export 

OVERVIEW

PancakeHunny is a yield farming protocol on BSC.

Latest 1 internal transaction
Parent Txn Hash Block From To Value
0x870e6914590bcbaf1bb4d8eba11fbff66e698f8a6757071ec4928d1320fd9b1e79062452021-06-01 3:31:00115 days 9 hrs ago PancakeHunny: Deployer  Contract Creation0 BNB
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
HunnyToken

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity)

/**
 *Submitted for verification at BscScan.com on 2021-06-01
*/

// Dependency file: @pancakeswap/pancake-swap-lib/contracts/math/SafeMath.sol

// SPDX-License-Identifier: MIT

// pragma solidity >=0.4.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, 'SafeMath: addition overflow');

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, 'SafeMath: subtraction overflow');
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, 'SafeMath: multiplication overflow');

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, 'SafeMath: division by zero');
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, 'SafeMath: modulo by zero');
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }

    function min(uint256 x, uint256 y) internal pure returns (uint256 z) {
        z = x < y ? x : y;
    }

    // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
    function sqrt(uint256 y) internal pure returns (uint256 z) {
        if (y > 3) {
            z = y;
            uint256 x = y / 2 + 1;
            while (x < z) {
                z = x;
                x = (y / x + x) / 2;
            }
        } else if (y != 0) {
            z = 1;
        }
    }
}


// Dependency file: @pancakeswap/pancake-swap-lib/contracts/GSN/Context.sol


// pragma solidity >=0.4.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 GSN 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.
 */
contract Context {
    // Empty internal constructor, to prevent people from mistakenly deploying
    // an instance of this contract, which should be used via inheritance.
    constructor() internal {}

    function _msgSender() internal view returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}


// Dependency file: @pancakeswap/pancake-swap-lib/contracts/access/Ownable.sol


// pragma solidity >=0.4.0;

/**
 * @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.
 */
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() internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

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

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

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = 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 onlyOwner {
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     */
    function _transferOwnership(address newOwner) internal {
        require(newOwner != address(0), 'Ownable: new owner is the zero address');
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}


// Dependency file: @pancakeswap/pancake-swap-lib/contracts/token/BEP20/IBEP20.sol


// pragma solidity >=0.4.0;

interface IBEP20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

    /**
     * @dev Returns the bep token owner.
     */
    function getOwner() external view returns (address);

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

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

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

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

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

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

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}


// Dependency file: @pancakeswap/pancake-swap-lib/contracts/utils/Address.sol


// pragma solidity ^0.6.2;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            codehash := extcodehash(account)
        }
        return (codehash != accountHash && codehash != 0x0);
    }

    /**
     * @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');

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (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');
        return _functionCallWithValue(target, data, value, errorMessage);
    }

    function _functionCallWithValue(
        address target,
        bytes memory data,
        uint256 weiValue,
        string memory errorMessage
    ) private returns (bytes memory) {
        require(isContract(target), 'Address: call to non-contract');

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{value: weiValue}(data);
        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

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}


// Dependency file: @pancakeswap/pancake-swap-lib/contracts/token/BEP20/SafeBEP20.sol


// pragma solidity ^0.6.0;

/**
 * @title SafeBEP20
 * @dev Wrappers around BEP20 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 SafeBEP20 for IBEP20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeBEP20 {
    using SafeMath for uint256;
    using Address for address;

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

    function safeTransferFrom(
        IBEP20 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
     * {IBEP20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IBEP20 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'
        // solhint-disable-next-line max-line-length
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            'SafeBEP20: approve from non-zero to non-zero allowance'
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

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

    function safeDecreaseAllowance(
        IBEP20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(
            value,
            'SafeBEP20: decreased allowance below zero'
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    /**
     * @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(IBEP20 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, 'SafeBEP20: low-level call failed');
        if (returndata.length > 0) {
            // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), 'SafeBEP20: BEP20 operation did not succeed');
        }
    }
}


// Dependency file: contracts/library/bep20/BEP20Virtual.sol


// pragma solidity >=0.4.0;

// import "@pancakeswap/pancake-swap-lib/contracts/access/Ownable.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/GSN/Context.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/token/BEP20/IBEP20.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/math/SafeMath.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/utils/Address.sol";

/**
 * @dev Implementation of the {IBEP20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {BEP20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-BEP20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of BEP20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IBEP20-approve}.
 */
contract BEP20Virtual is Context, IBEP20, Ownable {
    using SafeMath for uint256;
    using Address for address;

    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name, string memory symbol) public {
        _name = name;
        _symbol = symbol;
        _decimals = 18;
    }

    /**
     * @dev Returns the bep token owner.
     */
    function getOwner() external override view returns (address) {
        return owner();
    }

    /**
     * @dev Returns the token name.
     */
    function name() public override view returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the token decimals.
     */
    function decimals() public override view returns (uint8) {
        return _decimals;
    }

    /**
     * @dev Returns the token symbol.
     */
    function symbol() public override view returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {BEP20-totalSupply}.
     */
    function totalSupply() public override view returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {BEP20-balanceOf}.
     */
    function balanceOf(address account) public override view returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {BEP20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {BEP20-allowance}.
     */
    function allowance(address owner, address spender) public override view returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {BEP20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {BEP20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {BEP20};
     *
     * Requirements:
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for `sender`'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(
            sender,
            _msgSender(),
            _allowances[sender][_msgSender()].sub(amount, 'BEP20: transfer amount exceeds allowance')
        );
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {BEP20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {BEP20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
        _approve(
            _msgSender(),
            spender,
            _allowances[_msgSender()][spender].sub(subtractedValue, 'BEP20: decreased allowance below zero')
        );
        return true;
    }

    /**
     * @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
     * the total supply.
     *
     * Requirements
     *
     * - `msg.sender` must be the token owner
     */
    function mint(uint256 amount) public onlyOwner returns (bool) {
        _mint(_msgSender(), amount);
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal virtual {
        require(sender != address(0), 'BEP20: transfer from the zero address');
        require(recipient != address(0), 'BEP20: transfer to the zero address');

        _balances[sender] = _balances[sender].sub(amount, 'BEP20: transfer amount exceeds balance');
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal {
        require(account != address(0), 'BEP20: mint to the zero address');

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal {
        require(account != address(0), 'BEP20: burn from the zero address');

        _balances[account] = _balances[account].sub(amount, 'BEP20: burn amount exceeds balance');
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
     *
     * This is internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal {
        require(owner != address(0), 'BEP20: approve from the zero address');
        require(spender != address(0), 'BEP20: approve to the zero address');

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`.`amount` is then deducted
     * from the caller's allowance.
     *
     * See {_burn} and {_approve}.
     */
    function _burnFrom(address account, uint256 amount) internal {
        _burn(account, amount);
        _approve(
            account,
            _msgSender(),
            _allowances[account][_msgSender()].sub(amount, 'BEP20: burn amount exceeds allowance')
        );
    }
}


// Dependency file: contracts/hunny/HunnyToken.sol

// pragma solidity ^0.6.12;

/*
*
* MIT License
* ===========
*
* Copyright (c) 2020 HUNNYFinance
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

// import "contracts/library/bep20/BEP20Virtual.sol";


// HunnyToken with Governance.
contract HunnyToken is BEP20Virtual('Hunny Token', 'HUNNY') {
    uint16 public maxTransferAmountRate = 10000; // 100%
    address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;

    mapping(address => bool) private _excludedFromAntiWhale;
    address private _operator;

    event OperatorTransferred(address indexed previousOperator, address indexed newOperator);
    event MaxTransferAmountRateUpdated(address indexed operator, uint256 previousRate, uint256 newRate);

    modifier onlyOperator() {
        require(_operator == msg.sender, "operator: caller is not the operator");
        _;
    }

    modifier antiWhale(address sender, address recipient, uint256 amount) {
        if (maxTransferAmount() > 0) {
            if (
                _excludedFromAntiWhale[sender] == false
                && _excludedFromAntiWhale[recipient] == false
            ) {
                require(amount <= maxTransferAmount(), "HUNNY::antiWhale: Transfer amount exceeds the maxTransferAmount");
            }
        }
        _;
    }

    constructor() public {
        _operator = msg.sender;

        _excludedFromAntiWhale[msg.sender] = true;
        _excludedFromAntiWhale[address(0)] = true;
        _excludedFromAntiWhale[address(this)] = true;
        _excludedFromAntiWhale[BURN_ADDRESS] = true;
    }

    function _transfer(address sender, address recipient, uint256 amount) internal override antiWhale(sender, recipient, amount) {
        super._transfer(sender, recipient, amount);
    }

    function maxTransferAmount() public view returns (uint256) {
        return totalSupply().mul(maxTransferAmountRate).div(10000);
    }

    function isExcludedFromAntiWhale(address _account) public view returns (bool) {
        return _excludedFromAntiWhale[_account];
    }

    function updateMaxTransferAmountRate(uint16 _maxTransferAmountRate) public onlyOperator {
        require(_maxTransferAmountRate <= 10000, "HUNNY::updateMaxTransferAmountRate: Max transfer amount rate must not exceed the maximum rate.");
        emit MaxTransferAmountRateUpdated(msg.sender, maxTransferAmountRate, _maxTransferAmountRate);
        maxTransferAmountRate = _maxTransferAmountRate;
    }

    function setExcludedFromAntiWhale(address _account, bool _excluded) public onlyOperator {
        _excludedFromAntiWhale[_account] = _excluded;
    }

    function transferOperator(address newOperator) public onlyOperator {
        require(newOperator != address(0), "HUNNY::transferOperator: new operator is the zero address");
        emit OperatorTransferred(_operator, newOperator);
        _operator = newOperator;
        _excludedFromAntiWhale[newOperator] = true;
    }

    // @dev Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
    function mint(address _to, uint256 _amount) public onlyOwner {
        _mint(_to, _amount);
        _moveDelegates(address(0), _delegates[_to], _amount);
    }

    // Copied and modified from YAM code:
    // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
    // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
    // Which is copied and modified from COMPOUND:
    // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol

    // @dev A record of each accounts delegate
    mapping (address => address) internal _delegates;


    // @dev A checkpoint for marking number of votes from a given block
    struct Checkpoint {
        uint32 fromBlock;
        uint256 votes;
    }

    // @dev A record of votes checkpoints for each account, by index
    mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;

    // @dev The number of checkpoints for each account
    mapping (address => uint32) public numCheckpoints;

    // @dev The EIP-712 typehash for the contract's domain
    bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");

    // @dev The EIP-712 typehash for the delegation struct used by the contract
    bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");

    // @dev A record of states for signing / validating signatures
    mapping (address => uint) public nonces;

    // @dev An event thats emitted when an account changes its delegate
    event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);

    // @dev An event thats emitted when a delegate account's vote balance changes
    event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);

    /**
     * @dev Delegate votes from `msg.sender` to `delegatee`
     * @param delegator The address to get delegatee for
     */
    function delegates(address delegator)
    external
    view
    returns (address)
    {
        return _delegates[delegator];
    }

    /**
     * @dev Delegate votes from `msg.sender` to `delegatee`
     * @param delegatee The address to delegate votes to
     */
    function delegate(address delegatee) external {
        return _delegate(msg.sender, delegatee);
    }

    /**
     * @dev Delegates votes from signatory to `delegatee`
     * @param delegatee The address to delegate votes to
     * @param nonce The contract state required to match the signature
     * @param expiry The time at which to expire the signature
     * @param v The recovery byte of the signature
     * @param r Half of the ECDSA signature pair
     * @param s Half of the ECDSA signature pair
     */
    function delegateBySig(
        address delegatee,
        uint nonce,
        uint expiry,
        uint8 v,
        bytes32 r,
        bytes32 s
    )
    external
    {
        bytes32 domainSeparator = keccak256(
            abi.encode(
                DOMAIN_TYPEHASH,
                keccak256(bytes(name())),
                getChainId(),
                address(this)
            )
        );

        bytes32 structHash = keccak256(
            abi.encode(
                DELEGATION_TYPEHASH,
                delegatee,
                nonce,
                expiry
            )
        );

        bytes32 digest = keccak256(
            abi.encodePacked(
                "\x19\x01",
                domainSeparator,
                structHash
            )
        );

        address signatory = ecrecover(digest, v, r, s);
        require(signatory != address(0), "HUNNY::delegateBySig: invalid signature");
        require(nonce == nonces[signatory]++, "HUNNY::delegateBySig: invalid nonce");
        require(now <= expiry, "HUNNY::delegateBySig: signature expired");
        return _delegate(signatory, delegatee);
    }

    /**
     * @dev Gets the current votes balance for `account`
     * @param account The address to get votes balance
     * @return The number of current votes for `account`
     */
    function getCurrentVotes(address account)
    external
    view
    returns (uint256)
    {
        uint32 nCheckpoints = numCheckpoints[account];
        return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
    }

    /**
     * @dev Determine the prior number of votes for an account as of a block number
     * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
     * @param account The address of the account to check
     * @param blockNumber The block number to get the vote balance at
     * @return The number of votes the account had as of the given block
     */
    function getPriorVotes(address account, uint blockNumber)
    external
    view
    returns (uint256)
    {
        require(blockNumber < block.number, "HUNNY::getPriorVotes: not yet determined");

        uint32 nCheckpoints = numCheckpoints[account];
        if (nCheckpoints == 0) {
            return 0;
        }

        // First check most recent balance
        if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
            return checkpoints[account][nCheckpoints - 1].votes;
        }

        // Next check implicit zero balance
        if (checkpoints[account][0].fromBlock > blockNumber) {
            return 0;
        }

        uint32 lower = 0;
        uint32 upper = nCheckpoints - 1;
        while (upper > lower) {
            uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
            Checkpoint memory cp = checkpoints[account][center];
            if (cp.fromBlock == blockNumber) {
                return cp.votes;
            } else if (cp.fromBlock < blockNumber) {
                lower = center;
            } else {
                upper = center - 1;
            }
        }
        return checkpoints[account][lower].votes;
    }

    function _delegate(address delegator, address delegatee)
    internal
    {
        address currentDelegate = _delegates[delegator];
        uint256 delegatorBalance = balanceOf(delegator); // balance of underlying HUNNYs (not scaled);
        _delegates[delegator] = delegatee;

        emit DelegateChanged(delegator, currentDelegate, delegatee);

        _moveDelegates(currentDelegate, delegatee, delegatorBalance);
    }

    function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
        if (srcRep != dstRep && amount > 0) {
            if (srcRep != address(0)) {
                // decrease old representative
                uint32 srcRepNum = numCheckpoints[srcRep];
                uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
                uint256 srcRepNew = srcRepOld.sub(amount);
                _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
            }

            if (dstRep != address(0)) {
                // increase new representative
                uint32 dstRepNum = numCheckpoints[dstRep];
                uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
                uint256 dstRepNew = dstRepOld.add(amount);
                _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
            }
        }
    }

    function _writeCheckpoint(
        address delegatee,
        uint32 nCheckpoints,
        uint256 oldVotes,
        uint256 newVotes
    )
    internal
    {
        uint32 blockNumber = safe32(block.number, "HUNNY::_writeCheckpoint: block number exceeds 32 bits");

        if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
            checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
        } else {
            checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
            numCheckpoints[delegatee] = nCheckpoints + 1;
        }

        emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
    }

    function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
        require(n < 2**32, errorMessage);
        return uint32(n);
    }

    function getChainId() internal pure returns (uint) {
        uint256 chainId;
        assembly { chainId := chainid() }
        return chainId;
    }
}


// Dependency file: @uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol

// pragma solidity >=0.5.0;

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}


// Dependency file: @uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol

// pragma solidity >=0.5.0;

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}


// Dependency file: contracts/Constants.sol

// pragma solidity 0.6.12;


library Constants {
    // pancake
    address constant PANCAKE_ROUTER = address(0x10ED43C718714eb63d5aA57B78B54704E256024E); // v2
    address constant PANCAKE_FACTORY = address(0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73);
    address constant PANCAKE_CHEF = address(0x73feaa1eE314F8c655E354234017bE2193C9E24E);

//    uint constant PANCAKE_CAKE_BNB_PID = 3;
     uint constant PANCAKE_CAKE_BNB_PID = 251; // mainnet

     uint constant PANCAKE_BUSD_BNB_PID = 252; // mainnet
//     uint constant PANCAKE_BUSD_BNB_PID = 4;

     uint constant PANCAKE_BUSD_USDT_PID = 264; // mainnet
//    uint constant PANCAKE_BUSD_USDT_PID = 0;

    // tokens
    address constant WBNB = address(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);
    address constant CAKE = address(0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82);
    address constant BUSD = address(0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56);

    // external addresses
    address constant HUNNY_DEPLOYER = address(0xe5F7E3DD9A5612EcCb228392F47b7Ddba8cE4F1a);
    address constant HUNNY_LOTTERY = address(0); // update later
    address constant HUNNY_KEEPER = address(0xe5F7E3DD9A5612EcCb228392F47b7Ddba8cE4F1a);

    // minter
    uint256 constant HUNNY_PER_BLOCK_LOTTERY = 12e18;       // 12 HUNNY per block for lottery pool
    uint256 constant HUNNY_PER_PROFIT_BNB = 3200e18;        // 1 BNB earned, mint 3200 HUNNY
    uint256 constant HUNNY_PER_HUNNY_BNB_FLIP = 150e18;    // 1 HUNNY-BNB, earn 150 HUNNY / 365 days
}


// Dependency file: contracts/library/Whitelist.sol

// pragma solidity ^0.6.12;

/*
*
* MIT License
* ===========
*
* Copyright (c) 2020 HunnyFinance
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

// import "@pancakeswap/pancake-swap-lib/contracts/access/Ownable.sol";


contract Whitelist is Ownable {
    mapping(address => bool) private _whitelist;
    bool private _disable;                      // default - false means whitelist feature is working on. if true no more use of whitelist

    event Whitelisted(address indexed _address, bool whitelist);
    event EnableWhitelist();
    event DisableWhitelist();

    modifier onlyWhitelisted {
        require(_disable || _whitelist[msg.sender], "Whitelist: caller is not on the whitelist");
        _;
    }

    function isWhitelist(address _address) public view returns (bool) {
        return _whitelist[_address];
    }

    function setWhitelist(address _address, bool _on) public onlyOwner {
        _whitelist[_address] = _on;

        emit Whitelisted(_address, _on);
    }

    function disableWhitelist(bool disable) public onlyOwner {
        _disable = disable;
        if (disable) {
            emit DisableWhitelist();
        } else {
            emit EnableWhitelist();
        }
    }
}


// Dependency file: contracts/library/uniswap/FullMath.sol

// pragma solidity ^0.6.12;

// taken from https://medium.com/coinmonks/math-in-solidity-part-3-percents-and-proportions-4db014e080b1
// license is CC-BY-4.0
library FullMath {
    function fullMul(uint256 x, uint256 y) internal pure returns (uint256 l, uint256 h) {
        uint256 mm = mulmod(x, y, uint256(-1));
        l = x * y;
        h = mm - l;
        if (mm < l) h -= 1;
    }

    function fullDiv(
        uint256 l,
        uint256 h,
        uint256 d
    ) private pure returns (uint256) {
        uint256 pow2 = d & -d;
        d /= pow2;
        l /= pow2;
        l += h * ((-pow2) / pow2 + 1);
        uint256 r = 1;
        r *= 2 - d * r;
        r *= 2 - d * r;
        r *= 2 - d * r;
        r *= 2 - d * r;
        r *= 2 - d * r;
        r *= 2 - d * r;
        r *= 2 - d * r;
        r *= 2 - d * r;
        return l * r;
    }

    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 d
    ) internal pure returns (uint256) {
        (uint256 l, uint256 h) = fullMul(x, y);

        uint256 mm = mulmod(x, y, d);
        if (mm > l) h -= 1;
        l -= mm;

        if (h == 0) return l / d;

        require(h < d, 'FullMath: FULLDIV_OVERFLOW');
        return fullDiv(l, h, d);
    }
}


// Dependency file: contracts/library/uniswap/Babylonian.sol

// pragma solidity ^0.6.12;

// computes square roots using the babylonian method
// https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
library Babylonian {
    // credit for this implementation goes to
    // https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.sol#L687
    function sqrt(uint256 x) internal pure returns (uint256) {
        if (x == 0) return 0;
        // this block is equivalent to r = uint256(1) << (BitMath.mostSignificantBit(x) / 2);
        // however that code costs significantly more gas
        uint256 xx = x;
        uint256 r = 1;
        if (xx >= 0x100000000000000000000000000000000) {
            xx >>= 128;
            r <<= 64;
        }
        if (xx >= 0x10000000000000000) {
            xx >>= 64;
            r <<= 32;
        }
        if (xx >= 0x100000000) {
            xx >>= 32;
            r <<= 16;
        }
        if (xx >= 0x10000) {
            xx >>= 16;
            r <<= 8;
        }
        if (xx >= 0x100) {
            xx >>= 8;
            r <<= 4;
        }
        if (xx >= 0x10) {
            xx >>= 4;
            r <<= 2;
        }
        if (xx >= 0x8) {
            r <<= 1;
        }
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1; // Seven iterations should be enough
        uint256 r1 = x / r;
        return (r < r1 ? r : r1);
    }
}


// Dependency file: contracts/library/uniswap/BitMath.sol

// pragma solidity ^0.6.12;

library BitMath {
    // returns the 0 indexed position of the most significant bit of the input x
    // s.t. x >= 2**msb and x < 2**(msb+1)
    function mostSignificantBit(uint256 x) internal pure returns (uint8 r) {
        require(x > 0, 'BitMath::mostSignificantBit: zero');

        if (x >= 0x100000000000000000000000000000000) {
            x >>= 128;
            r += 128;
        }
        if (x >= 0x10000000000000000) {
            x >>= 64;
            r += 64;
        }
        if (x >= 0x100000000) {
            x >>= 32;
            r += 32;
        }
        if (x >= 0x10000) {
            x >>= 16;
            r += 16;
        }
        if (x >= 0x100) {
            x >>= 8;
            r += 8;
        }
        if (x >= 0x10) {
            x >>= 4;
            r += 4;
        }
        if (x >= 0x4) {
            x >>= 2;
            r += 2;
        }
        if (x >= 0x2) r += 1;
    }

    // returns the 0 indexed position of the least significant bit of the input x
    // s.t. (x & 2**lsb) != 0 and (x & (2**(lsb) - 1)) == 0)
    // i.e. the bit at the index is set and the mask of all lower bits is 0
    function leastSignificantBit(uint256 x) internal pure returns (uint8 r) {
        require(x > 0, 'BitMath::leastSignificantBit: zero');

        r = 255;
        if (x & uint128(-1) > 0) {
            r -= 128;
        } else {
            x >>= 128;
        }
        if (x & uint64(-1) > 0) {
            r -= 64;
        } else {
            x >>= 64;
        }
        if (x & uint32(-1) > 0) {
            r -= 32;
        } else {
            x >>= 32;
        }
        if (x & uint16(-1) > 0) {
            r -= 16;
        } else {
            x >>= 16;
        }
        if (x & uint8(-1) > 0) {
            r -= 8;
        } else {
            x >>= 8;
        }
        if (x & 0xf > 0) {
            r -= 4;
        } else {
            x >>= 4;
        }
        if (x & 0x3 > 0) {
            r -= 2;
        } else {
            x >>= 2;
        }
        if (x & 0x1 > 0) r -= 1;
    }
}


// Dependency file: contracts/library/uniswap/FixedPoint.sol

// pragma solidity ^0.6.12;

// import 'contracts/library/uniswap/FullMath.sol';
// import 'contracts/library/uniswap/Babylonian.sol';
// import 'contracts/library/uniswap/BitMath.sol';


// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
library FixedPoint {
    // range: [0, 2**112 - 1]
    // resolution: 1 / 2**112
    struct uq112x112 {
        uint224 _x;
    }

    // range: [0, 2**144 - 1]
    // resolution: 1 / 2**112
    struct uq144x112 {
        uint256 _x;
    }

    uint8 public constant RESOLUTION = 112;
    uint256 public constant Q112 = 0x10000000000000000000000000000; // 2**112
    uint256 private constant Q224 = 0x100000000000000000000000000000000000000000000000000000000; // 2**224
    uint256 private constant LOWER_MASK = 0xffffffffffffffffffffffffffff; // decimal of UQ*x112 (lower 112 bits)

    // encode a uint112 as a UQ112x112
    function encode(uint112 x) internal pure returns (uq112x112 memory) {
        return uq112x112(uint224(x) << RESOLUTION);
    }

    // encodes a uint144 as a UQ144x112
    function encode144(uint144 x) internal pure returns (uq144x112 memory) {
        return uq144x112(uint256(x) << RESOLUTION);
    }

    // decode a UQ112x112 into a uint112 by truncating after the radix point
    function decode(uq112x112 memory self) internal pure returns (uint112) {
        return uint112(self._x >> RESOLUTION);
    }

    // decode a UQ144x112 into a uint144 by truncating after the radix point
    function decode144(uq144x112 memory self) internal pure returns (uint144) {
        return uint144(self._x >> RESOLUTION);
    }

    // multiply a UQ112x112 by a uint, returning a UQ144x112
    // reverts on overflow
    function mul(uq112x112 memory self, uint256 y) internal pure returns (uq144x112 memory) {
        uint256 z = 0;
        require(y == 0 || (z = self._x * y) / y == self._x, 'FixedPoint::mul: overflow');
        return uq144x112(z);
    }

    // multiply a UQ112x112 by an int and decode, returning an int
    // reverts on overflow
    function muli(uq112x112 memory self, int256 y) internal pure returns (int256) {
        uint256 z = FullMath.mulDiv(self._x, uint256(y < 0 ? -y : y), Q112);
        require(z < 2**255, 'FixedPoint::muli: overflow');
        return y < 0 ? -int256(z) : int256(z);
    }

    // multiply a UQ112x112 by a UQ112x112, returning a UQ112x112
    // lossy
    function muluq(uq112x112 memory self, uq112x112 memory other) internal pure returns (uq112x112 memory) {
        if (self._x == 0 || other._x == 0) {
            return uq112x112(0);
        }
        uint112 upper_self = uint112(self._x >> RESOLUTION); // * 2^0
        uint112 lower_self = uint112(self._x & LOWER_MASK); // * 2^-112
        uint112 upper_other = uint112(other._x >> RESOLUTION); // * 2^0
        uint112 lower_other = uint112(other._x & LOWER_MASK); // * 2^-112

        // partial products
        uint224 upper = uint224(upper_self) * upper_other; // * 2^0
        uint224 lower = uint224(lower_self) * lower_other; // * 2^-224
        uint224 uppers_lowero = uint224(upper_self) * lower_other; // * 2^-112
        uint224 uppero_lowers = uint224(upper_other) * lower_self; // * 2^-112

        // so the bit shift does not overflow
        require(upper <= uint112(-1), 'FixedPoint::muluq: upper overflow');

        // this cannot exceed 256 bits, all values are 224 bits
        uint256 sum = uint256(upper << RESOLUTION) + uppers_lowero + uppero_lowers + (lower >> RESOLUTION);

        // so the cast does not overflow
        require(sum <= uint224(-1), 'FixedPoint::muluq: sum overflow');

        return uq112x112(uint224(sum));
    }

    // divide a UQ112x112 by a UQ112x112, returning a UQ112x112
    function divuq(uq112x112 memory self, uq112x112 memory other) internal pure returns (uq112x112 memory) {
        require(other._x > 0, 'FixedPoint::divuq: division by zero');
        if (self._x == other._x) {
            return uq112x112(uint224(Q112));
        }
        if (self._x <= uint144(-1)) {
            uint256 value = (uint256(self._x) << RESOLUTION) / other._x;
            require(value <= uint224(-1), 'FixedPoint::divuq: overflow');
            return uq112x112(uint224(value));
        }

        uint256 result = FullMath.mulDiv(Q112, self._x, other._x);
        require(result <= uint224(-1), 'FixedPoint::divuq: overflow');
        return uq112x112(uint224(result));
    }

    // returns a UQ112x112 which represents the ratio of the numerator to the denominator
    // can be lossy
    function fraction(uint256 numerator, uint256 denominator) internal pure returns (uq112x112 memory) {
        require(denominator > 0, 'FixedPoint::fraction: division by zero');
        if (numerator == 0) return FixedPoint.uq112x112(0);

        if (numerator <= uint144(-1)) {
            uint256 result = (numerator << RESOLUTION) / denominator;
            require(result <= uint224(-1), 'FixedPoint::fraction: overflow');
            return uq112x112(uint224(result));
        } else {
            uint256 result = FullMath.mulDiv(numerator, Q112, denominator);
            require(result <= uint224(-1), 'FixedPoint::fraction: overflow');
            return uq112x112(uint224(result));
        }
    }

    // take the reciprocal of a UQ112x112
    // reverts on overflow
    // lossy
    function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
        require(self._x != 0, 'FixedPoint::reciprocal: reciprocal of zero');
        require(self._x != 1, 'FixedPoint::reciprocal: overflow');
        return uq112x112(uint224(Q224 / self._x));
    }

    // square root of a UQ112x112
    // lossy between 0/1 and 40 bits
    function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {
        if (self._x <= uint144(-1)) {
            return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << 112)));
        }

        uint8 safeShiftBits = 255 - BitMath.mostSignificantBit(self._x);
        safeShiftBits -= safeShiftBits % 2;
        return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << safeShiftBits) << ((112 - safeShiftBits) / 2)));
    }
}


// Dependency file: contracts/library/uniswap/UniswapV2Library.sol

// pragma solidity ^0.6.12;

// import "@pancakeswap/pancake-swap-lib/contracts/math/SafeMath.sol";
// import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";

library UniswapV2Library {
    using SafeMath for uint;

    // returns sorted token addresses, used to handle return values from pairs sorted in this order
    function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
        require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
        (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
        require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
    }

    // calculates the CREATE2 address for a pair without making any external calls
    function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
        (address token0, address token1) = sortTokens(tokenA, tokenB);
        pair = address(uint(keccak256(abi.encodePacked(
                hex'ff',
                factory,
                keccak256(abi.encodePacked(token0, token1)),
                hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
            ))));
    }

    // fetches and sorts the reserves for a pair
    function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
        (address token0,) = sortTokens(tokenA, tokenB);
        (uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
        (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
    }

    // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
    function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
        require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
        require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        amountB = amountA.mul(reserveB) / reserveA;
    }

    // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
        require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
        require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        uint amountInWithFee = amountIn.mul(997);
        uint numerator = amountInWithFee.mul(reserveOut);
        uint denominator = reserveIn.mul(1000).add(amountInWithFee);
        amountOut = numerator / denominator;
    }

    // given an output amount of an asset and pair reserves, returns a required input amount of the other asset
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
        require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
        require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        uint numerator = reserveIn.mul(amountOut).mul(1000);
        uint denominator = reserveOut.sub(amountOut).mul(997);
        amountIn = (numerator / denominator).add(1);
    }

    // performs chained getAmountOut calculations on any number of pairs
    function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
        require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
        amounts = new uint[](path.length);
        amounts[0] = amountIn;
        for (uint i; i < path.length - 1; i++) {
            (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
            amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
        }
    }

    // performs chained getAmountIn calculations on any number of pairs
    function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
        require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
        amounts = new uint[](path.length);
        amounts[amounts.length - 1] = amountOut;
        for (uint i = path.length - 1; i > 0; i--) {
            (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
            amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
        }
    }
}


// Dependency file: contracts/library/uniswap/UniswapV2OracleLibrary.sol

// pragma solidity ^0.6.12;

// import 'contracts/library/uniswap/FixedPoint.sol';


// library with helper methods for oracles that are concerned with computing average prices
library UniswapV2OracleLibrary {
    using FixedPoint for *;

    // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1]
    function currentBlockTimestamp() internal view returns (uint32) {
        return uint32(block.timestamp % 2 ** 32);
    }

    // produces the cumulative price using counterfactuals to save gas and avoid a call to sync.
    function currentCumulativePrices(
        address pair
    ) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) {
        blockTimestamp = currentBlockTimestamp();
        price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast();
        price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast();

        // if time has elapsed since the last update on the pair, mock the accumulated price values
        (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves();
        if (blockTimestampLast != blockTimestamp) {
            // subtraction overflow is desired
            uint32 timeElapsed = blockTimestamp - blockTimestampLast;
            // addition overflow is desired
            // counterfactual
            price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;
            // counterfactual
            price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;
        }
    }
}


// Dependency file: contracts/hunny/HunnyOracle.sol

// pragma solidity ^0.6.12;

// import "@pancakeswap/pancake-swap-lib/contracts/access/Ownable.sol";
// import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
// import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";

// import "contracts/Constants.sol";
// import "contracts/library/Whitelist.sol";
// import "contracts/library/uniswap/FixedPoint.sol";
// import "contracts/library/uniswap/UniswapV2Library.sol";
// import "contracts/library/uniswap/UniswapV2OracleLibrary.sol";


// fixed window oracle that recomputes the average price for the entire period once every period
// note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period
contract HunnyOracle is Whitelist {
    using FixedPoint for *;

    uint public constant PERIOD = 10 minutes;
    uint112 public constant BOOTSTRAP_HUNNY_PRICE = 250000000000000; // 1 BNB = 4000 HUNNY

    bool public initialized;

    address public hunnyToken;
    IUniswapV2Pair pair;
    address public token0;
    address public token1;

    uint    public price0CumulativeLast;
    uint    public price1CumulativeLast;
    uint32  public blockTimestampLast;
    FixedPoint.uq112x112 public price0Average;
    FixedPoint.uq112x112 public price1Average;

    constructor(address hunny) public {
        hunnyToken = hunny;

        setWhitelist(msg.sender, true);
    }

    function initialize() internal {
        IUniswapV2Pair _pair = IUniswapV2Pair(IUniswapV2Factory(Constants.PANCAKE_FACTORY).getPair(hunnyToken, Constants.WBNB));

        pair = _pair;

        token0 = _pair.token0();
        token1 = _pair.token1();

        price0CumulativeLast = _pair.price0CumulativeLast(); // fetch the current accumulated price value (1 / 0)
        price1CumulativeLast = _pair.price1CumulativeLast(); // fetch the current accumulated price value (0 / 1)

        // get the blockTimestampLast
        (,, blockTimestampLast) = _pair.getReserves();

        _update();
        initialized = true;
    }

    function update() public onlyWhitelisted {
        if (!initialized) {
            initialize();
        }

        (, , uint32 blockTimestamp) =
        UniswapV2OracleLibrary.currentCumulativePrices(address(pair));
        uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired

        // ensure that at least one full period has passed since the last update
        if (timeElapsed >= PERIOD) {
            _update();
        }
    }

    function _update() internal {
        (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) =
        UniswapV2OracleLibrary.currentCumulativePrices(address(pair));
        uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired

        // overflow is desired, casting never truncates
        // cumulative price is in (uq112x112 price * seconds) units so we simply wrap it after division by time elapsed
        price0Average = FixedPoint.uq112x112(uint224((price0Cumulative - price0CumulativeLast) / timeElapsed));
        price1Average = FixedPoint.uq112x112(uint224((price1Cumulative - price1CumulativeLast) / timeElapsed));

        price0CumulativeLast = price0Cumulative;
        price1CumulativeLast = price1Cumulative;
        blockTimestampLast = blockTimestamp;
    }

    // note this will always return 0 before update has been called successfully for the first time.
    function consult(address token, uint amountIn) public view returns (uint amountOut) {
        if (token == token0) {
            amountOut = price0Average.mul(amountIn).decode144();
        } else {
            require(token == token1, 'HunnyOracle: INVALID_TOKEN');
            amountOut = price1Average.mul(amountIn).decode144();
        }
    }

    function capture() public view returns(uint) {
        uint consultAmount = consult(hunnyToken, 1e18);
        if (consultAmount == 0) {
            return BOOTSTRAP_HUNNY_PRICE;
        } else {
            return consultAmount;
        }
    }
}


// Dependency file: @pancakeswap/pancake-swap-lib/contracts/token/BEP20/BEP20.sol


// pragma solidity >=0.4.0;

/**
 * @dev Implementation of the {IBEP20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {BEP20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-BEP20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of BEP20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IBEP20-approve}.
 */
contract BEP20 is Context, IBEP20, Ownable {
    using SafeMath for uint256;
    using Address for address;

    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name, string memory symbol) public {
        _name = name;
        _symbol = symbol;
        _decimals = 18;
    }

    /**
     * @dev Returns the bep token owner.
     */
    function getOwner() external override view returns (address) {
        return owner();
    }

    /**
     * @dev Returns the token name.
     */
    function name() public override view returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the token decimals.
     */
    function decimals() public override view returns (uint8) {
        return _decimals;
    }

    /**
     * @dev Returns the token symbol.
     */
    function symbol() public override view returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {BEP20-totalSupply}.
     */
    function totalSupply() public override view returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {BEP20-balanceOf}.
     */
    function balanceOf(address account) public override view returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {BEP20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {BEP20-allowance}.
     */
    function allowance(address owner, address spender) public override view returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {BEP20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {BEP20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {BEP20};
     *
     * Requirements:
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for `sender`'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(
            sender,
            _msgSender(),
            _allowances[sender][_msgSender()].sub(amount, 'BEP20: transfer amount exceeds allowance')
        );
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {BEP20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {BEP20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
        _approve(
            _msgSender(),
            spender,
            _allowances[_msgSender()][spender].sub(subtractedValue, 'BEP20: decreased allowance below zero')
        );
        return true;
    }

    /**
     * @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
     * the total supply.
     *
     * Requirements
     *
     * - `msg.sender` must be the token owner
     */
    function mint(uint256 amount) public onlyOwner returns (bool) {
        _mint(_msgSender(), amount);
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal {
        require(sender != address(0), 'BEP20: transfer from the zero address');
        require(recipient != address(0), 'BEP20: transfer to the zero address');

        _balances[sender] = _balances[sender].sub(amount, 'BEP20: transfer amount exceeds balance');
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal {
        require(account != address(0), 'BEP20: mint to the zero address');

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal {
        require(account != address(0), 'BEP20: burn from the zero address');

        _balances[account] = _balances[account].sub(amount, 'BEP20: burn amount exceeds balance');
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
     *
     * This is internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal {
        require(owner != address(0), 'BEP20: approve from the zero address');
        require(spender != address(0), 'BEP20: approve to the zero address');

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`.`amount` is then deducted
     * from the caller's allowance.
     *
     * See {_burn} and {_approve}.
     */
    function _burnFrom(address account, uint256 amount) internal {
        _burn(account, amount);
        _approve(
            account,
            _msgSender(),
            _allowances[account][_msgSender()].sub(amount, 'BEP20: burn amount exceeds allowance')
        );
    }
}


// Dependency file: contracts/interfaces/IPancakeRouter01.sol

// pragma solidity >=0.6.2;

interface IPancakeRouter01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
    external
    payable
    returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
    external
    returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
    external
    returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
    external
    payable
    returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}


// Dependency file: contracts/interfaces/IPancakeRouter02.sol


// pragma solidity >=0.6.2;

// import 'contracts/interfaces/IPancakeRouter01.sol';

interface IPancakeRouter02 is IPancakeRouter01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}


// Dependency file: contracts/interfaces/IPancakePair.sol

// pragma solidity >=0.6.2;

interface IPancakePair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}

// Dependency file: contracts/interfaces/IPancakeFactory.sol

// pragma solidity ^0.6.12;

interface IPancakeFactory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}

// Dependency file: contracts/hunny/legacy/PancakeSwap.sol

// pragma solidity ^0.6.12;

// import "@pancakeswap/pancake-swap-lib/contracts/math/SafeMath.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/token/BEP20/IBEP20.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/token/BEP20/SafeBEP20.sol";

// import "contracts/Constants.sol";
// import "contracts/interfaces/IPancakeRouter02.sol";
// import "contracts/interfaces/IPancakePair.sol";
// import "contracts/interfaces/IPancakeFactory.sol";

contract PancakeSwap {
    using SafeMath for uint;
    using SafeBEP20 for IBEP20;

    IPancakeRouter02 private ROUTER = IPancakeRouter02(Constants.PANCAKE_ROUTER);
    IPancakeFactory private factory = IPancakeFactory(Constants.PANCAKE_FACTORY);

    address internal cake = Constants.CAKE;
    address private _hunny;
    address private _wbnb = Constants.WBNB;

    constructor(address _hunnyAddress) public {
        _hunny = _hunnyAddress;
    }

    function hunnyBNBFlipToken() internal view returns(address) {
        return factory.getPair(_hunny, _wbnb);
    }

    function tokenToHunnyBNB(address token, uint amount) internal returns(uint flipAmount) {
        if (token == cake) {
            flipAmount = _cakeToHunnyBNBFlip(amount);
        } else {
            // flip
            flipAmount = _flipToHunnyBNBFlip(token, amount);
        }
    }

    function _cakeToHunnyBNBFlip(uint amount) private returns(uint flipAmount) {
        swapToken(cake, amount.div(2), _hunny);
        swapToken(cake, amount.sub(amount.div(2)), _wbnb);

        flipAmount = generateFlipToken();
    }

    function _flipToHunnyBNBFlip(address token, uint amount) private returns(uint flipAmount) {
        IPancakePair pair = IPancakePair(token);
        address _token0 = pair.token0();
        address _token1 = pair.token1();
        IBEP20(token).safeApprove(address(ROUTER), 0);
        IBEP20(token).safeApprove(address(ROUTER), amount);
        ROUTER.removeLiquidity(_token0, _token1, amount, 0, 0, address(this), block.timestamp);
        if (_token0 == _wbnb) {
            swapToken(_token1, IBEP20(_token1).balanceOf(address(this)), _hunny);
            flipAmount = generateFlipToken();
        } else if (_token1 == _wbnb) {
            swapToken(_token0, IBEP20(_token0).balanceOf(address(this)), _hunny);
            flipAmount = generateFlipToken();
        } else {
            swapToken(_token0, IBEP20(_token0).balanceOf(address(this)), _hunny);
            swapToken(_token1, IBEP20(_token1).balanceOf(address(this)), _wbnb);
            flipAmount = generateFlipToken();
        }
    }

    function swapToken(address _from, uint _amount, address _to) private {
        if (_from == _to) return;

        address[] memory path;
        if (_from == _wbnb || _to == _wbnb) {
            path = new address[](2);
            path[0] = _from;
            path[1] = _to;
        } else {
            path = new address[](3);
            path[0] = _from;
            path[1] = _wbnb;
            path[2] = _to;
        }

        IBEP20(_from).safeApprove(address(ROUTER), 0);
        IBEP20(_from).safeApprove(address(ROUTER), _amount);
        ROUTER.swapExactTokensForTokens(_amount, 0, path, address(this), block.timestamp);
    }

    function generateFlipToken() private returns(uint liquidity) {
        uint amountADesired = IBEP20(_hunny).balanceOf(address(this));
        uint amountBDesired = IBEP20(_wbnb).balanceOf(address(this));

        IBEP20(_hunny).safeApprove(address(ROUTER), 0);
        IBEP20(_hunny).safeApprove(address(ROUTER), amountADesired);
        IBEP20(_wbnb).safeApprove(address(ROUTER), 0);
        IBEP20(_wbnb).safeApprove(address(ROUTER), amountBDesired);

        (,,liquidity) = ROUTER.addLiquidity(_hunny, _wbnb, amountADesired, amountBDesired, 0, 0, address(this), block.timestamp);

        // send dust
        IBEP20(_hunny).transfer(msg.sender, IBEP20(_hunny).balanceOf(address(this)));
        IBEP20(_wbnb).transfer(msg.sender, IBEP20(_wbnb).balanceOf(address(this)));
    }
}


// Dependency file: contracts/interfaces/IHunnyMinter.sol

// pragma solidity ^0.6.12;

interface IHunnyMinter {
    function isMinter(address) view external returns(bool);
    function amountHunnyToMint(uint bnbProfit) view external returns(uint);
    function amountHunnyToMintForHunnyBNB(uint amount, uint duration) view external returns(uint);
    function withdrawalFee(uint amount, uint depositedAt) view external returns(uint);
    function performanceFee(uint profit) view external returns(uint);
    function mintFor(address flip, uint _withdrawalFee, uint _performanceFee, address to, uint depositedAt) external;
    function mintForHunnyBNB(uint amount, uint duration, address to) external;

    function hunnyPerProfitBNB() view external returns(uint);
    function hunnyPerBlockLottery() view external returns(uint);
    function WITHDRAWAL_FEE_FREE_PERIOD() view external returns(uint);
    function WITHDRAWAL_FEE() view external returns(uint);

    function setMinter(address minter, bool canMint) external;
}


// Dependency file: contracts/interfaces/IHunnyOracle.sol

// pragma solidity ^0.6.12;

interface IHunnyOracle {
    function price0CumulativeLast() external view returns(uint);
    function price1CumulativeLast() external view returns(uint);
    function blockTimestampLast() external view returns(uint);
    function capture() external view returns(uint224);

    function update() external;
}


// Dependency file: contracts/interfaces/legacy/IStakingRewards.sol

// pragma solidity ^0.6.12;

interface IStakingRewards {
    function stakeTo(uint256 amount, address _to) external;
    function notifyRewardAmount(uint256 reward) external;
}

// Dependency file: contracts/interfaces/legacy/IStrategyHelper.sol

// pragma solidity ^0.6.12;

/*
*
* MIT License
* ===========
*
* Copyright (c) 2020 HunnyFinance
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

// import "contracts/interfaces/IHunnyMinter.sol";

interface IStrategyHelper {
    function tokenPriceInBNB(address _token) view external returns(uint);
    function cakePriceInBNB() view external returns(uint);
    function bnbPriceInUSD() view external returns(uint);

    function flipPriceInBNB(address _flip) view external returns(uint);
    function flipPriceInUSD(address _flip) view external returns(uint);

    function profitOf(IHunnyMinter minter, address _flip, uint amount) external view returns (uint _usd, uint _hunny, uint _bnb);

    function tvl(address _flip, uint amount) external view returns (uint);    // in USD
    function tvlInBNB(address _flip, uint amount) external view returns (uint);    // in BNB
    function apy(IHunnyMinter minter, uint pid) external view returns(uint _usd, uint _hunny, uint _bnb);
    function compoundingAPY(uint pid, uint compoundUnit) view external returns(uint);
}


// Dependency file: contracts/hunny/legacy/HunnyMinter.sol

// pragma solidity ^0.6.12;

// import "@pancakeswap/pancake-swap-lib/contracts/token/BEP20/BEP20.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/token/BEP20/SafeBEP20.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/math/SafeMath.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/access/Ownable.sol";

// import "contracts/hunny/legacy/PancakeSwap.sol";
// import "contracts/Constants.sol";
// import "contracts/interfaces/IHunnyMinter.sol";
// import "contracts/interfaces/IHunnyOracle.sol";
// import "contracts/interfaces/legacy/IStakingRewards.sol";
// import "contracts/interfaces/legacy/IStrategyHelper.sol";

contract HunnyMinter is IHunnyMinter, Ownable, PancakeSwap {
    using SafeMath for uint;
    using SafeBEP20 for IBEP20;

    BEP20 private hunny;
    address public dev = Constants.HUNNY_DEPLOYER;
    IBEP20 private WBNB = IBEP20(Constants.WBNB);

    uint public override WITHDRAWAL_FEE_FREE_PERIOD = 2 days;
    uint public override WITHDRAWAL_FEE = 50;
    uint public constant FEE_MAX = 10000;

    uint public PERFORMANCE_FEE = 3000; // 30%

    uint public override hunnyPerProfitBNB;
    uint public override hunnyPerBlockLottery;
    uint public lastLotteryMintBlock;
    uint public hunnyPerHunnyBNBFlip;

    address public hunnyPool;
    address public lotteryPool;
    IHunnyOracle public oracle;
    IStrategyHelper public helper;

    mapping (address => bool) private _minters;

    modifier onlyMinter {
        require(isMinter(msg.sender) == true, "not minter");
        _;
    }

    constructor(address _hunny, address _hunnyPool, address _lotteryPool, address _oracle, address _helper) PancakeSwap(_hunny) public {
        hunny = BEP20(_hunny);
        hunnyPool = _hunnyPool;
        lotteryPool = _lotteryPool;
        oracle = IHunnyOracle(_oracle);
        helper = IStrategyHelper(_helper);

        hunnyPerProfitBNB = Constants.HUNNY_PER_PROFIT_BNB;
        hunnyPerBlockLottery = Constants.HUNNY_PER_BLOCK_LOTTERY;
        lastLotteryMintBlock = block.number;
        hunnyPerHunnyBNBFlip = Constants.HUNNY_PER_HUNNY_BNB_FLIP;
        hunny.approve(hunnyPool, uint(~0));
    }

    function transferHunnyOwner(address _owner) external onlyOwner {
        Ownable(address(hunny)).transferOwnership(_owner);
    }

    function setWithdrawalFee(uint _fee) external onlyOwner {
        require(_fee < 500, "wrong fee");   // less 5%
        WITHDRAWAL_FEE = _fee;
    }

    function setPerformanceFee(uint _fee) external onlyOwner {
        require(_fee < 5000, "wrong fee");
        PERFORMANCE_FEE = _fee;
    }

    function setWithdrawalFeeFreePeriod(uint _period) external onlyOwner {
        WITHDRAWAL_FEE_FREE_PERIOD = _period;
    }

    function setMinter(address minter, bool canMint) external override onlyOwner {
        if (canMint) {
            _minters[minter] = canMint;
        } else {
            delete _minters[minter];
        }
    }

    function setHunnyPerProfitBNB(uint _ratio) external onlyOwner {
        hunnyPerProfitBNB = _ratio;
    }

    function setHunnyPerHunnyBNBFlip(uint _hunnyPerHunnyBNBFlip) external onlyOwner {
        hunnyPerHunnyBNBFlip = _hunnyPerHunnyBNBFlip;
    }

    function setHunnyPerBlockLottery(uint _hunnyPerBlockLottery) external onlyOwner {
        hunnyPerBlockLottery = _hunnyPerBlockLottery;
    }

    function setHelper(IStrategyHelper _helper) external onlyOwner {
        require(address(_helper) != address(0), "zero address");
        helper = _helper;
    }

    function setOracle(IHunnyOracle _oracle) external onlyOwner {
        require(address(_oracle) != address(0), "zero address");
        oracle = _oracle;
    }

    function isMinter(address account) override view public returns(bool) {
        if (hunny.getOwner() != address(this)) {
            return false;
        }

        if (block.timestamp < 1605585600) { // 12:00 SGT 17th November 2020
            return false;
        }
        return _minters[account];
    }

    function amountHunnyToMint(uint bnbProfit) override view public returns(uint) {
        return bnbProfit.mul(hunnyPerProfitBNB).div(1e18);
    }

    function amountHunnyToMintForHunnyBNB(uint amount, uint duration) override view public returns(uint) {
        return amount.mul(hunnyPerHunnyBNBFlip).mul(duration).div(365 days).div(1e18);
    }

    function withdrawalFee(uint amount, uint depositedAt) override view external returns(uint) {
        if (depositedAt.add(WITHDRAWAL_FEE_FREE_PERIOD) > block.timestamp) {
            return amount.mul(WITHDRAWAL_FEE).div(FEE_MAX);
        }
        return 0;
    }

    function performanceFee(uint profit) override view public returns(uint) {
        return profit.mul(PERFORMANCE_FEE).div(FEE_MAX);
    }

    function mintFor(address flip, uint _withdrawalFee, uint _performanceFee, address to, uint) override external onlyMinter {
        uint feeSum = _performanceFee.add(_withdrawalFee);
        IBEP20(flip).safeTransferFrom(msg.sender, address(this), feeSum);

        uint hunnyBNBAmount = tokenToHunnyBNB(flip, IBEP20(flip).balanceOf(address(this)));
        address flipToken = hunnyBNBFlipToken();
        IBEP20(flipToken).safeTransfer(hunnyPool, hunnyBNBAmount);
        IStakingRewards(hunnyPool).notifyRewardAmount(hunnyBNBAmount);

        uint contribution = helper.tvlInBNB(flipToken, hunnyBNBAmount).mul(_performanceFee).div(feeSum);
        uint mintHunny = amountHunnyToMint(contribution);
        mint(mintHunny, to);

        // addition step
        // update oracle price
        oracle.update();
    }

    function mintForHunnyBNB(uint amount, uint duration, address to) override external onlyMinter {
        uint mintHunny = amountHunnyToMintForHunnyBNB(amount, duration);
        if (mintHunny == 0) return;
        mint(mintHunny, to);
    }

    function mint(uint amount, address to) private {
        hunny.mint(amount);
        hunny.transfer(to, amount);

        uint hunnyForDev = amount.mul(15).div(100);
        hunny.mint(hunnyForDev);
        IStakingRewards(hunnyPool).stakeTo(hunnyForDev, dev);

        // mint for lottery pool
        mintForLottery();
    }

    // only after when lottery pool address was set
    // token calculated from the block when dev set lottery pool address only
    function mintForLottery() private {
        if (lotteryPool != address(0)) {
            uint amountHunny = block.number.sub(lastLotteryMintBlock).mul(hunnyPerBlockLottery);
            hunny.mint(amountHunny);
            hunny.transfer(lotteryPool, amountHunny);
        }

        lastLotteryMintBlock = block.number;
    }
}


// Dependency file: contracts/library/HomoraMath.sol

// pragma solidity 0.6.12;

// import "@pancakeswap/pancake-swap-lib/contracts/math/SafeMath.sol";


library HomoraMath {
    using SafeMath for uint;

    function divCeil(uint lhs, uint rhs) internal pure returns (uint) {
        return lhs.add(rhs).sub(1) / rhs;
    }

    function fmul(uint lhs, uint rhs) internal pure returns (uint) {
        return lhs.mul(rhs) / (2**112);
    }

    function fdiv(uint lhs, uint rhs) internal pure returns (uint) {
        return lhs.mul(2**112) / rhs;
    }

    // implementation from https://github.com/Uniswap/uniswap-lib/commit/99f3f28770640ba1bb1ff460ac7c5292fb8291a0
    // original implementation: https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.sol#L687
    function sqrt(uint x) internal pure returns (uint) {
        if (x == 0) return 0;
        uint xx = x;
        uint r = 1;

        if (xx >= 0x100000000000000000000000000000000) {
            xx >>= 128;
            r <<= 64;
        }

        if (xx >= 0x10000000000000000) {
            xx >>= 64;
            r <<= 32;
        }
        if (xx >= 0x100000000) {
            xx >>= 32;
            r <<= 16;
        }
        if (xx >= 0x10000) {
            xx >>= 16;
            r <<= 8;
        }
        if (xx >= 0x100) {
            xx >>= 8;
            r <<= 4;
        }
        if (xx >= 0x10) {
            xx >>= 4;
            r <<= 2;
        }
        if (xx >= 0x8) {
            r <<= 1;
        }

        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1;
        r = (r + x / r) >> 1; // Seven iterations should be enough
        uint r1 = x / r;
        return (r < r1 ? r : r1);
    }
}


// Dependency file: contracts/interfaces/IMasterChef.sol

// pragma solidity ^0.6.12;

interface IMasterChef {
    function cakePerBlock() view external returns(uint);
    function totalAllocPoint() view external returns(uint);

    function poolInfo(uint _pid) view external returns(address lpToken, uint allocPoint, uint lastRewardBlock, uint accCakePerShare);
    function userInfo(uint _pid, address _account) view external returns(uint amount, uint rewardDebt);
    function poolLength() view external returns(uint);

    function deposit(uint256 _pid, uint256 _amount) external;
    function withdraw(uint256 _pid, uint256 _amount) external;
    function emergencyWithdraw(uint256 _pid) external;

    function enterStaking(uint256 _amount) external;
    function leaveStaking(uint256 _amount) external;
}


// Dependency file: contracts/interfaces/AggregatorV3Interface.sol

// pragma solidity >=0.6.0;

interface AggregatorV3Interface {

    function decimals() external view returns (uint8);
    function description() external view returns (string memory);
    function version() external view returns (uint256);

    // getRoundData and latestRoundData should both raise "No data present"
    // if they do not have data to report, instead of returning unset values
    // which could be misinterpreted as actual reported values.
    function getRoundData(uint80 _roundId)
    external
    view
    returns (
        uint80 roundId,
        int256 answer,
        uint256 startedAt,
        uint256 updatedAt,
        uint80 answeredInRound
    );
    function latestRoundData()
    external
    view
    returns (
        uint80 roundId,
        int256 answer,
        uint256 startedAt,
        uint256 updatedAt,
        uint80 answeredInRound
    );

}


// Dependency file: contracts/vaults/legacy/StrategyHelperV1.sol

// pragma solidity ^0.6.12;

// import "@pancakeswap/pancake-swap-lib/contracts/access/Ownable.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/token/BEP20/BEP20.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/token/BEP20/IBEP20.sol";

// import "contracts/Constants.sol";
// import "contracts/library/HomoraMath.sol";
// import "contracts/interfaces/IPancakeFactory.sol";
// import "contracts/interfaces/IPancakePair.sol";
// import "contracts/interfaces/IMasterChef.sol";
// import "contracts/interfaces/IHunnyMinter.sol";
// import "contracts/interfaces/IHunnyOracle.sol";
// import "contracts/interfaces/AggregatorV3Interface.sol";

// no storage
// There are only calculations for apy, tvl, etc.
contract StrategyHelperV1 is Ownable {
    using SafeMath for uint;
    IBEP20 private WBNB = IBEP20(Constants.WBNB);
    IBEP20 private CAKE = IBEP20(Constants.CAKE);
    IBEP20 private BUSD = IBEP20(Constants.BUSD);

    IBEP20 public hunny;
    IHunnyOracle public oracle;
    IMasterChef private master = IMasterChef(Constants.PANCAKE_CHEF);
    IPancakeFactory private factory = IPancakeFactory(Constants.PANCAKE_FACTORY);

    mapping(address => address) private tokenFeeds;

    constructor(address _hunny) public {
        hunny = IBEP20(_hunny);
    }

    // get hunny price to in BNB
    function tokenPriceInBNB(address _token) public view returns(uint) {
        if (_token == address(CAKE)) {
            return  cakePriceInBNB();
        } else if (_token == address(hunny)) {
            return oracle.capture();
        } else {
            return unsafeTokenPriceInBNB(_token);
        }
    }

    function unsafeTokenPriceInBNB(address _token) private view returns(uint) {
        address pair = factory.getPair(_token, address(WBNB));
        uint decimal = uint(BEP20(_token).decimals());

        (uint reserve0, uint reserve1, ) = IPancakePair(pair).getReserves();
        if (IPancakePair(pair).token0() == _token) {
            return reserve1.mul(10**decimal).div(reserve0);
        } else if (IPancakePair(pair).token1() == _token) {
            return reserve0.mul(10**decimal).div(reserve1);
        } else {
            return 0;
        }
    }

    function cakePriceInUSD() view public returns(uint) {
        (, int price, , ,) = AggregatorV3Interface(tokenFeeds[address(CAKE)]).latestRoundData();
        return uint(price).mul(1e10);
    }

    function cakePriceInBNB() view public returns(uint) {
        return cakePriceInUSD().mul(1e18).div(bnbPriceInUSD());
    }

    function bnbPriceInUSD() view public returns(uint) {
        (, int price, , ,) = AggregatorV3Interface(tokenFeeds[address(WBNB)]).latestRoundData();
        return uint(price).mul(1e10);
    }

    function cakePerYearOfPool(uint pid) view public returns(uint) {
        (, uint allocPoint,,) = master.poolInfo(pid);
        return master.cakePerBlock().mul(blockPerYear()).mul(allocPoint).div(master.totalAllocPoint());
    }

    function blockPerYear() pure public returns(uint) {
        // 86400 / 3 * 365
        return 10512000;
    }

    function profitOf(address minter, address flip, uint amount) external view returns (uint _usd, uint _hunny, uint _bnb) {
        _usd = tvl(flip, amount);
        if (address(minter) == address(0)) {
            _hunny = 0;
        } else {
            uint performanceFee = IHunnyMinter(minter).performanceFee(_usd);
            _usd = _usd.sub(performanceFee);
            uint bnbAmount = performanceFee.mul(1e18).div(bnbPriceInUSD());
            _hunny = IHunnyMinter(minter).amountHunnyToMint(bnbAmount);
        }
        _bnb = 0;
    }

    // apy() = cakePrice * (cakePerBlock * blockPerYear * weight) / PoolValue(=WBNB*2)
    function _apy(uint pid) view private returns(uint) {
        (address token,,,) = master.poolInfo(pid);
        uint poolSize = tvl(token, IBEP20(token).balanceOf(address(master))).mul(1e18).div(bnbPriceInUSD());
        return cakePriceInBNB().mul(cakePerYearOfPool(pid)).div(poolSize);
    }

    function apy(address, uint pid) view public returns(uint _usd, uint _hunny, uint _bnb) {
        _usd = compoundingAPY(pid, 1 days);
        _hunny = 0;
        _bnb = 0;
    }

    function tvl(address _flip, uint amount) public view returns (uint) {
        if (_flip == address(CAKE)) {
            return cakePriceInBNB().mul(bnbPriceInUSD()).mul(amount).div(1e36);
        }
        address _token0 = IPancakePair(_flip).token0();
        address _token1 = IPancakePair(_flip).token1();

        // using hunny price from the oracle
        if (_token0 == address(hunny) || _token1 == address(hunny)) {
            uint hunnyBalance = hunny.balanceOf(address(_flip)).mul(amount).div(IBEP20(_flip).totalSupply());
            uint priceInBNB = tokenPriceInBNB(address(hunny));
            uint price = priceInBNB.mul(bnbPriceInUSD()).div(1e18);
            return hunnyBalance.mul(price).div(1e18).mul(2);
        }

        if (_token0 == address(WBNB) || _token1 == address(WBNB)) {
            uint bnb = WBNB.balanceOf(address(_flip)).mul(amount).div(IBEP20(_flip).totalSupply());
            uint price = bnbPriceInUSD();
            return bnb.mul(price).div(1e18).mul(2);
        }

        uint balanceToken0 = IBEP20(_token0).balanceOf(_flip);
        uint price = tokenPriceInBNB(_token0);
        return balanceToken0.mul(price).div(1e18).mul(bnbPriceInUSD()).div(1e18).mul(2);
    }

    function tvlInBNB(address _flip, uint amount) public view returns (uint) {
        if (_flip == address(CAKE)) {
            return cakePriceInBNB().mul(amount).div(1e18);
        }
        address _token0 = IPancakePair(_flip).token0();
        address _token1 = IPancakePair(_flip).token1();

        // using hunny price from the oracle
        if (_token0 == address(hunny) || _token1 == address(hunny)) {
            uint hunnyBalance = hunny.balanceOf(address(_flip)).mul(amount).div(IBEP20(_flip).totalSupply());
            uint priceInBNB = tokenPriceInBNB(address(hunny));
            return hunnyBalance.mul(priceInBNB).div(1e18).mul(2);
        }

        if (_token0 == address(WBNB) || _token1 == address(WBNB)) {
            uint bnb = WBNB.balanceOf(address(_flip)).mul(amount).div(IBEP20(_flip).totalSupply());
            return bnb.mul(2);
        }

        uint balanceToken0 = IBEP20(_token0).balanceOf(_flip);
        uint price = tokenPriceInBNB(_token0);
        return balanceToken0.mul(price).div(1e18).mul(2);
    }

    function compoundingAPY(uint pid, uint compoundUnit) view public returns(uint) {
        uint __apy = _apy(pid);
        uint compoundTimes = 365 days / compoundUnit;
        uint unitAPY = 1e18 + (__apy / compoundTimes);
        uint result = 1e18;

        for(uint i=0; i<compoundTimes; i++) {
            result = (result * unitAPY) / 1e18;
        }

        return result - 1e18;
    }

    function setOracle(address oracleAddress) public onlyOwner {
        oracle = IHunnyOracle(oracleAddress);
    }

    function setTokenFeed(address asset, address feed) public onlyOwner {
        tokenFeeds[asset] = feed;
    }
}


// Dependency file: @openzeppelin/contracts/math/Math.sol


// pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @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, so we distribute
        return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
    }
}


// Dependency file: @openzeppelin/contracts/utils/ReentrancyGuard.sol


// pragma solidity >=0.6.0 <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 () internal {
        _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 make 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;
    }
}


// Dependency file: contracts/library/legacy/RewardsDistributionRecipient.sol

/*
   ____            __   __        __   _
  / __/__ __ ___  / /_ / /  ___  / /_ (_)__ __
 _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ /
/___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\
     /___/

* Docs: https://docs.synthetix.io/
*
*
* MIT License
* ===========
*
* Copyright (c) 2020 Synthetix
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

// pragma solidity ^0.6.2;

// import "@pancakeswap/pancake-swap-lib/contracts/access/Ownable.sol";

abstract contract RewardsDistributionRecipient is Ownable {
    address public rewardsDistribution;

    modifier onlyRewardsDistribution() {
        require(msg.sender == rewardsDistribution, "onlyRewardsDistribution");
        _;
    }

    function notifyRewardAmount(uint256 reward) virtual external;

    function setRewardsDistribution(address _rewardsDistribution) external onlyOwner {
        rewardsDistribution = _rewardsDistribution;
    }
}


// Dependency file: contracts/library/legacy/Pausable.sol

/*
   ____            __   __        __   _
  / __/__ __ ___  / /_ / /  ___  / /_ (_)__ __
 _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ /
/___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\
     /___/

* Docs: https://docs.synthetix.io/
*
*
* MIT License
* ===========
*
* Copyright (c) 2020 Synthetix
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

// pragma solidity ^0.6.2;

// import "@pancakeswap/pancake-swap-lib/contracts/access/Ownable.sol";


abstract contract Pausable is Ownable {
    uint public lastPauseTime;
    bool public paused;

    event PauseChanged(bool isPaused);

    modifier notPaused {
        require(!paused, "This action cannot be performed while the contract is paused");
        _;
    }

    constructor() internal {
        require(owner() != address(0), "Owner must be set");
    }

    function setPaused(bool _paused) external onlyOwner {
        if (_paused == paused) {
            return;
        }

        paused = _paused;
        if (paused) {
            lastPauseTime = now;
        }

        emit PauseChanged(paused);
    }
}


// Dependency file: contracts/interfaces/legacy/IStrategyLegacy.sol

// pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;

/*
*
* MIT License
* ===========
*
* Copyright (c) 2020 HunnyFinance
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

interface IStrategyLegacy {
    struct Profit {
        uint usd;
        uint hunny;
        uint bnb;
    }

    struct APY {
        uint usd;
        uint hunny;
        uint bnb;
    }

    struct UserInfo {
        uint balance;
        uint principal;
        uint available;
        Profit profit;
        uint poolTVL;
        APY poolAPY;
    }

    function deposit(uint _amount) external;
    function depositAll() external;
    function withdraw(uint256 _amount) external;    // HUNNY STAKING POOL ONLY
    function withdrawAll() external;
    function getReward() external;                  // HUNNY STAKING POOL ONLY
    function harvest() external;

    function balance() external view returns (uint);
    function balanceOf(address account) external view returns (uint);
    function principalOf(address account) external view returns (uint);
    function withdrawableBalanceOf(address account) external view returns (uint);   // HUNNY STAKING POOL ONLY
    function profitOf(address account) external view returns (uint _usd, uint _hunny, uint _bnb);
//    function earned(address account) external view returns (uint);
    function tvl() external view returns (uint);    // in USD
    function apy() external view returns (uint _usd, uint _hunny, uint _bnb);

    /* ========== Strategy Information ========== */
//    function pid() external view returns (uint);
//    function poolType() external view returns (PoolTypes);
//    function isMinter() external view returns (bool, address);
//    function getDepositedAt(address account) external view returns (uint);
//    function getRewardsToken() external view returns (address);

    function info(address account) external view returns (UserInfo memory);
}


// Dependency file: contracts/vaults/legacy/HunnyPool.sol

// pragma solidity ^0.6.12;


// import "@openzeppelin/contracts/math/Math.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/math/SafeMath.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/token/BEP20/SafeBEP20.sol";
// import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

// import "contracts/Constants.sol";
// import "contracts/library/legacy/RewardsDistributionRecipient.sol";
// import "contracts/library/legacy/Pausable.sol";
// import "contracts/interfaces/legacy/IStrategyHelper.sol";
// import "contracts/interfaces/IPancakeRouter02.sol";
// import "contracts/interfaces/legacy/IStrategyLegacy.sol";

interface IPresale {
    function endTime() view external returns(uint256);

    function totalBalance() view external returns(uint);
    function flipToken() view external returns(address);
}

contract HunnyPool is IStrategyLegacy, RewardsDistributionRecipient, ReentrancyGuard, Pausable {
    using SafeMath for uint256;
    using SafeBEP20 for IBEP20;

    /* ========== STATE VARIABLES ========== */

    IBEP20 public rewardsToken; // hunny/bnb flip
    IBEP20 public stakingToken;
    uint256 public periodFinish = 0;
    uint256 public rewardRate = 0;
    uint256 public rewardsDuration = 90 days;
    uint256 public lastUpdateTime;
    uint256 public rewardPerTokenStored;

    mapping(address => uint256) public userRewardPerTokenPaid;
    mapping(address => uint256) public rewards;

    uint256 private _totalSupply;
    mapping(address => uint256) private _balances;

    mapping(address => bool) private _stakePermission;

    /* ========== PRESALE ============== */
    address private presaleContract;
    address private constant deadAddress = 0x000000000000000000000000000000000000dEaD;
    mapping(address => uint256) private _presaleBalance;

    uint256 public TIMESTAMP_2_HOURS_AFTER_PRESALE;
    uint256 public TIMESTAMP_90_DAYS_AFTER_PRESALE;

    /* ========== HUNNY HELPER ========= */
    IStrategyHelper public helper;
    IPancakeRouter02 private ROUTER = IPancakeRouter02(Constants.PANCAKE_ROUTER);

    /* ========== CONSTRUCTOR ========== */

    constructor(address _hunny, address _presale, address _helper) public {
        stakingToken = IBEP20(_hunny);   // hunny
        presaleContract = _presale;
        helper = IStrategyHelper(_helper);

        rewardsDistribution = msg.sender;

        _stakePermission[msg.sender] = true;
        _stakePermission[presaleContract] = true;

        stakingToken.safeApprove(address(ROUTER), uint(~0));

        TIMESTAMP_2_HOURS_AFTER_PRESALE = IPresale(_presale).endTime() + 2 hours;
        TIMESTAMP_90_DAYS_AFTER_PRESALE = IPresale(_presale).endTime() + 90 days;
    }

    /* ========== VIEWS ========== */

    function totalSupply() external view returns (uint256) {
        return _totalSupply;
    }

    function balance() override external view returns (uint) {
        return _totalSupply;
    }

    function balanceOf(address account) override external view returns (uint256) {
        return _balances[account];
    }

    function presaleBalanceOf(address account) external view returns(uint256) {
        return _presaleBalance[account];
    }

    function principalOf(address account) override external view returns (uint256) {
        return _balances[account];
    }

    function withdrawableBalanceOf(address account) override public view returns (uint) {
        if (block.timestamp > TIMESTAMP_90_DAYS_AFTER_PRESALE) {
            // unlock all presale hunny after 90 days of presale
            return _balances[account];
        } else if (block.timestamp < TIMESTAMP_2_HOURS_AFTER_PRESALE) {
            return _balances[account].sub(_presaleBalance[account]);
        } else {
            uint soldInPresale = IPresale(presaleContract).totalBalance().div(2).mul(3); // mint 150% of presale for making flip token
            uint hunnySupply = stakingToken.totalSupply().sub(stakingToken.balanceOf(deadAddress));
            if (soldInPresale >= hunnySupply) {
                return _balances[account].sub(_presaleBalance[account]);
            }
            uint hunnyNewMint = hunnySupply.sub(soldInPresale);
            if (hunnyNewMint >= soldInPresale) {
                return _balances[account];
            }

            uint lockedRatio = (soldInPresale.sub(hunnyNewMint)).mul(1e18).div(soldInPresale);
            uint lockedBalance = _presaleBalance[account].mul(lockedRatio).div(1e18);
            return _balances[account].sub(lockedBalance);
        }
    }

    function profitOf(address account) override public view returns (uint _usd, uint _hunny, uint _bnb) {
        _usd = 0;
        _hunny = 0;
        _bnb = helper.tvlInBNB(address(rewardsToken), earned(account));
    }

    function tvl() override public view returns (uint) {
        uint price = helper.tokenPriceInBNB(address(stakingToken));
        return _totalSupply.mul(price).div(1e18);
    }

    function apy() override public view returns(uint _usd, uint _hunny, uint _bnb) {
        uint tokenDecimals = 1e18;
        uint __totalSupply = _totalSupply;
        if (__totalSupply == 0) {
            __totalSupply = tokenDecimals;
        }

        uint rewardPerTokenPerSecond = rewardRate.mul(tokenDecimals).div(__totalSupply);
        uint hunnyPrice = helper.tokenPriceInBNB(address(stakingToken));
        uint flipPrice = helper.tvlInBNB(address(rewardsToken), 1e18);

        _usd = 0;
        _hunny = 0;
        _bnb = rewardPerTokenPerSecond.mul(365 days).mul(flipPrice).div(hunnyPrice);
    }

    function lastTimeRewardApplicable() public view returns (uint256) {
        return Math.min(block.timestamp, periodFinish);
    }

    function rewardPerToken() public view returns (uint256) {
        if (_totalSupply == 0) {
            return rewardPerTokenStored;
        }
        return
        rewardPerTokenStored.add(
            lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(_totalSupply)
        );
    }

    function earned(address account) public view returns (uint256) {
        return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]);
    }

    function getRewardForDuration() external view returns (uint256) {
        return rewardRate.mul(rewardsDuration);
    }

    /* ========== MUTATIVE FUNCTIONS ========== */
    function _deposit(uint256 amount, address _to) private nonReentrant notPaused updateReward(_to) {
        require(amount > 0, "amount");
        _totalSupply = _totalSupply.add(amount);
        _balances[_to] = _balances[_to].add(amount);
        stakingToken.safeTransferFrom(msg.sender, address(this), amount);
        emit Staked(_to, amount);
    }

    function deposit(uint256 amount) override public {
        _deposit(amount, msg.sender);
    }

    function depositAll() override external {
        deposit(stakingToken.balanceOf(msg.sender));
    }

    function withdraw(uint256 amount) override public nonReentrant updateReward(msg.sender) {
        require(amount > 0, "amount");
        require(amount <= withdrawableBalanceOf(msg.sender), "locked");
        _totalSupply = _totalSupply.sub(amount);
        _balances[msg.sender] = _balances[msg.sender].sub(amount);
        stakingToken.safeTransfer(msg.sender, amount);
        emit Withdrawn(msg.sender, amount);
    }

    function withdrawAll() override external {
        uint _withdraw = withdrawableBalanceOf(msg.sender);
        if (_withdraw > 0) {
            withdraw(_withdraw);
        }
        getReward();
    }

    function getReward() override public nonReentrant updateReward(msg.sender) {
        uint256 reward = rewards[msg.sender];
        if (reward > 0) {
            rewards[msg.sender] = 0;
            reward = _flipToWBNB(reward);
            IBEP20(ROUTER.WETH()).safeTransfer(msg.sender, reward);
            emit RewardPaid(msg.sender, reward);
        }
    }

    function _flipToWBNB(uint amount) private returns(uint reward) {
        address wbnb = ROUTER.WETH();
        (uint rewardHunny,) = ROUTER.removeLiquidity(
            address(stakingToken), wbnb,
            amount, 0, 0, address(this), block.timestamp);
        address[] memory path = new address[](2);
        path[0] = address(stakingToken);
        path[1] = wbnb;
        ROUTER.swapExactTokensForTokens(rewardHunny, 0, path, address(this), block.timestamp);

        reward = IBEP20(wbnb).balanceOf(address(this));
    }

    function harvest() override external {}

    function info(address account) override external view returns(UserInfo memory) {
        UserInfo memory userInfo;

        userInfo.balance = _balances[account];
        userInfo.principal = _balances[account];
        userInfo.available = withdrawableBalanceOf(account);

        Profit memory profit;
        (uint usd, uint hunny, uint bnb) = profitOf(account);
        profit.usd = usd;
        profit.hunny = hunny;
        profit.bnb = bnb;
        userInfo.profit = profit;

        userInfo.poolTVL = tvl();

        APY memory poolAPY;
        (usd, hunny, bnb) = apy();
        poolAPY.usd = usd;
        poolAPY.hunny = hunny;
        poolAPY.bnb = bnb;
        userInfo.poolAPY = poolAPY;

        return userInfo;
    }

    /* ========== RESTRICTED FUNCTIONS ========== */
    function setRewardsToken(address _rewardsToken) external onlyOwner {
        require(address(rewardsToken) == address(0), "set rewards token already");

        rewardsToken = IBEP20(_rewardsToken);

        // safe approve
        IBEP20(_rewardsToken).safeApprove(address(ROUTER), 0);
        IBEP20(_rewardsToken).safeApprove(address(ROUTER), uint(~0));
    }

    function setHelper(IStrategyHelper _helper) external onlyOwner {
        require(address(_helper) != address(0), "zero address");
        helper = _helper;
    }

    function setStakePermission(address _address, bool permission) external onlyOwner {
        _stakePermission[_address] = permission;
    }

    function stakeTo(uint256 amount, address _to) external canStakeTo {
        _deposit(amount, _to);
        if (msg.sender == presaleContract) {
            _presaleBalance[_to] = _presaleBalance[_to].add(amount);
        }
    }

    function notifyRewardAmount(uint256 reward) override external onlyRewardsDistribution updateReward(address(0)) {
        if (block.timestamp >= periodFinish) {
            rewardRate = reward.div(rewardsDuration);
        } else {
            uint256 remaining = periodFinish.sub(block.timestamp);
            uint256 leftover = remaining.mul(rewardRate);
            rewardRate = reward.add(leftover).div(rewardsDuration);
        }

        // Ensure the provided reward amount is not more than the balance in the contract.
        // This keeps the reward rate in the right range, preventing overflows due to
        // very high values of rewardRate in the earned and rewardsPerToken functions;
        // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow.
        uint _balance = rewardsToken.balanceOf(address(this));
        require(rewardRate <= _balance.div(rewardsDuration), "reward");

        lastUpdateTime = block.timestamp;
        periodFinish = block.timestamp.add(rewardsDuration);
        emit RewardAdded(reward);
    }

    function recoverBEP20(address tokenAddress, uint256 tokenAmount) external onlyOwner {
        require(tokenAddress != address(stakingToken) && tokenAddress != address(rewardsToken), "tokenAddress");
        IBEP20(tokenAddress).safeTransfer(owner(), tokenAmount);
        emit Recovered(tokenAddress, tokenAmount);
    }

    function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner {
        require(periodFinish == 0 || block.timestamp > periodFinish, "period");
        rewardsDuration = _rewardsDuration;
        emit RewardsDurationUpdated(rewardsDuration);
    }

    /* ========== MODIFIERS ========== */

    modifier updateReward(address account) {
        rewardPerTokenStored = rewardPerToken();
        lastUpdateTime = lastTimeRewardApplicable();
        if (account != address(0)) {
            rewards[account] = earned(account);
            userRewardPerTokenPaid[account] = rewardPerTokenStored;
        }
        _;
    }

    modifier canStakeTo() {
        require(_stakePermission[msg.sender], 'auth');
        _;
    }

    /* ========== EVENTS ========== */

    event RewardAdded(uint256 reward);
    event Staked(address indexed user, uint256 amount);
    event Withdrawn(address indexed user, uint256 amount);
    event RewardPaid(address indexed user, uint256 reward);
    event RewardsDurationUpdated(uint256 newDuration);
    event Recovered(address token, uint256 amount);
}


// Dependency file: contracts/vaults/legacy/HunnyBNBPool.sol

// pragma solidity ^0.6.12;


/*
*
* MIT License
* ===========
*
* Copyright (c) 2020 HunnyFinance
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

// import "@pancakeswap/pancake-swap-lib/contracts/token/BEP20/SafeBEP20.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/access/Ownable.sol";

// import "contracts/Constants.sol";
// import "contracts/interfaces/IMasterChef.sol";
// import "contracts/interfaces/IHunnyMinter.sol";
// import "contracts/interfaces/legacy/IStrategyHelper.sol";
// import "contracts/interfaces/legacy/IStrategyLegacy.sol";

contract HunnyBNBPool is IStrategyLegacy, Ownable {
    using SafeBEP20 for IBEP20;
    using SafeMath for uint256;

    IBEP20 private HUNNY;
    IBEP20 private CAKE = IBEP20(Constants.CAKE);
    IBEP20 private WBNB = IBEP20(Constants.WBNB);

    IBEP20 public token;
    address public presale;

    uint public totalShares;
    mapping (address => uint) private _shares;
    mapping (address => uint) public depositedAt;

    IHunnyMinter public minter;
    IStrategyHelper public helper;

    constructor(address _hunny, address _presale, address _helper) public {
        HUNNY = IBEP20(_hunny);
        presale = _presale;
        helper = IStrategyHelper(_helper);
    }

    function setFlipToken(address _token) public onlyOwner {
        require(address(token) == address(0), 'flip token set already');
        token = IBEP20(_token);
    }

    function setMinter(IHunnyMinter _minter) external onlyOwner {
        minter = _minter;
        if (address(_minter) != address(0)) {
            token.safeApprove(address(_minter), 0);
            token.safeApprove(address(_minter), uint(~0));
        }
    }

    function setHelper(IStrategyHelper _helper) external onlyOwner {
        require(address(_helper) != address(0), "zero address");
        helper = _helper;
    }

    function balance() override public view returns (uint) {
        return token.balanceOf(address(this));
    }

    function balanceOf(address account) override public view returns(uint) {
        return _shares[account];
    }

    function withdrawableBalanceOf(address account) override public view returns (uint) {
        return _shares[account];
    }

    function sharesOf(address account) public view returns (uint) {
        return _shares[account];
    }

    function principalOf(address account) override public view returns (uint) {
        return _shares[account];
    }

    function profitOf(address account) override public view returns (uint _usd, uint _hunny, uint _bnb) {
        if (address(minter) == address(0) || !minter.isMinter(address(this))) {
            return (0, 0, 0);
        }
        return (0, minter.amountHunnyToMintForHunnyBNB(balanceOf(account), block.timestamp.sub(depositedAt[account])), 0);
    }

    function tvl() override public view returns (uint) {
        return helper.tvl(address(token), balance());
    }

    function apy() override public view returns(uint _usd, uint _hunny, uint _bnb) {
        if (address(minter) == address(0) || !minter.isMinter(address(this))) {
            return (0, 0, 0);
        }

        uint amount = 1e18;
        uint hunny = minter.amountHunnyToMintForHunnyBNB(amount, 365 days);
        uint _tvl = helper.tvlInBNB(address(token), amount);
        uint hunnyPrice = helper.tokenPriceInBNB(address(HUNNY));

        return (hunny.mul(hunnyPrice).div(_tvl), 0, 0);
    }

    function info(address account) override external view returns(UserInfo memory) {
        UserInfo memory userInfo;

        userInfo.balance = balanceOf(account);
        userInfo.principal = principalOf(account);
        userInfo.available = withdrawableBalanceOf(account);

        Profit memory profit;
        (uint usd, uint hunny, uint bnb) = profitOf(account);
        profit.usd = usd;
        profit.hunny = hunny;
        profit.bnb = bnb;
        userInfo.profit = profit;

        userInfo.poolTVL = tvl();

        APY memory poolAPY;
        (usd, hunny, bnb) = apy();
        poolAPY.usd = usd;
        poolAPY.hunny = hunny;
        poolAPY.bnb = bnb;
        userInfo.poolAPY = poolAPY;

        return userInfo;
    }

    function priceShare() public view returns(uint) {
        return balance().mul(1e18).div(totalShares);
    }

    function depositTo(uint256, uint256 _amount, address _to) external {
        require(msg.sender == presale || msg.sender == owner(), "not presale contract");
        _depositTo(_amount, _to);
    }

    function _depositTo(uint _amount, address _to) private {
        token.safeTransferFrom(msg.sender, address(this), _amount);

        uint amount = _shares[_to];
        if (amount != 0 && depositedAt[_to] != 0) {
            uint duration = block.timestamp.sub(depositedAt[_to]);
            mintHunny(amount, duration);
        }

        totalShares = totalShares.add(_amount);
        _shares[_to] = _shares[_to].add(_amount);
        depositedAt[_to] = block.timestamp;
    }

    function deposit(uint _amount) override public {
        _depositTo(_amount, msg.sender);
    }

    function depositAll() override external {
        deposit(token.balanceOf(msg.sender));
    }

    function withdrawAll() override external {
        uint _withdraw = balanceOf(msg.sender);

        totalShares = totalShares.sub(_shares[msg.sender]);
        delete _shares[msg.sender];
        uint depositTimestamp = depositedAt[msg.sender];
        delete depositedAt[msg.sender];

        mintHunny(_withdraw, block.timestamp.sub(depositTimestamp));
        token.safeTransfer(msg.sender, _withdraw);
    }

    function mintHunny(uint amount, uint duration) private {
        if (address(minter) == address(0) || !minter.isMinter(address(this))) {
            return;
        }

        minter.mintForHunnyBNB(amount, duration, msg.sender);
    }

    function harvest() override external {

    }

    function withdraw(uint256) override external {
        revert("Use withdrawAll");
    }

    function getReward() override external {
        revert("Use withdrawAll");
    }
}


// Dependency file: contracts/vaults/legacy/CakeVault.sol

// pragma solidity ^0.6.12;


/*
*
* MIT License
* ===========
*
* Copyright (c) 2020 HunnyFinance
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

// import "@pancakeswap/pancake-swap-lib/contracts/token/BEP20/BEP20.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/token/BEP20/SafeBEP20.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/access/Ownable.sol";

// import "contracts/Constants.sol";
// import "contracts/interfaces/IMasterChef.sol";
// import "contracts/interfaces/IHunnyMinter.sol";
// import "contracts/interfaces/legacy/IStrategyHelper.sol";
// import "contracts/interfaces/legacy/IStrategyLegacy.sol";

contract CakeVault is IStrategyLegacy, Ownable {
    using SafeBEP20 for IBEP20;
    using SafeMath for uint256;

    IBEP20 private CAKE;
    IMasterChef private CAKE_MASTER_CHEF;

    address public keeper = Constants.HUNNY_KEEPER;

    uint public poolId = 0;

    uint public totalShares;
    mapping (address => uint) private _shares;

    IStrategyHelper public helper;
    mapping (address => bool) private _whitelist;

    constructor(address cake, address cakeMasterChef) public {
        CAKE = IBEP20(cake);
        CAKE_MASTER_CHEF = IMasterChef(cakeMasterChef);

        CAKE.safeApprove(address(CAKE_MASTER_CHEF), uint(~0));
    }

    function setKeeper(address _keeper) external {
        require(msg.sender == _keeper || msg.sender == owner(), 'auth');
        require(_keeper != address(0), 'zero address');
        keeper = _keeper;
    }

    function setHelper(IStrategyHelper _helper) external {
        require(msg.sender == address(_helper) || msg.sender == owner(), 'auth');
        require(address(_helper) != address(0), "zero address");

        helper = _helper;
    }

    function setWhitelist(address _address, bool _on) external onlyOwner {
        _whitelist[_address] = _on;
    }

    function balance() override public view returns (uint) {
        (uint amount,) = CAKE_MASTER_CHEF.userInfo(poolId, address(this));
        return CAKE.balanceOf(address(this)).add(amount);
    }

    // @returns cake amount
    function balanceOf(address account) override public view returns(uint) {
        if (totalShares == 0) return 0;
        return balance().mul(sharesOf(account)).div(totalShares);
    }

    function withdrawableBalanceOf(address account) override public view returns (uint) {
        return balanceOf(account);
    }

    function sharesOf(address account) public view returns (uint) {
        return _shares[account];
    }

    function principalOf(address account) override public view returns (uint) {
        return balanceOf(account);
    }

    function profitOf(address) override public view returns (uint _usd, uint _hunny, uint _bnb) {
        // Not available
        return (0, 0, 0);
    }

    function tvl() override public view returns (uint) {
        return helper.tvl(address(CAKE), balance());
    }

    function apy() override public view returns(uint _usd, uint _hunny, uint _bnb) {
        return helper.apy(IHunnyMinter(address (0)), poolId);
    }

    function info(address account) override external view returns(UserInfo memory) {
        UserInfo memory userInfo;

        userInfo.balance = balanceOf(account);
        userInfo.principal = principalOf(account);
        userInfo.available = withdrawableBalanceOf(account);

        Profit memory profit;
        (uint usd, uint hunny, uint bnb) = profitOf(account);
        profit.usd = usd;
        profit.hunny = hunny;
        profit.bnb = bnb;
        userInfo.profit = profit;

        userInfo.poolTVL = tvl();

        APY memory poolAPY;
        (usd, hunny, bnb) = apy();
        poolAPY.usd = usd;
        poolAPY.hunny = hunny;
        poolAPY.bnb = bnb;
        userInfo.poolAPY = poolAPY;

        return userInfo;
    }

    function priceShare() public view returns(uint) {
        if (totalShares == 0) return 0;
        return balance().mul(1e18).div(totalShares);
    }

    function _depositTo(uint _amount, address _to) private {
        require(_whitelist[msg.sender], "not whitelist");

        uint _pool = balance();
        CAKE.safeTransferFrom(msg.sender, address(this), _amount);
        uint shares = 0;
        if (totalShares == 0) {
            shares = _amount;
        } else {
            shares = (_amount.mul(totalShares)).div(_pool);
        }

        totalShares = totalShares.add(shares);
        _shares[_to] = _shares[_to].add(shares);

        CAKE_MASTER_CHEF.leaveStaking(0);
        uint balanceOfCake = CAKE.balanceOf(address(this));
        CAKE_MASTER_CHEF.enterStaking(balanceOfCake);
    }

    function deposit(uint _amount) override public {
        _depositTo(_amount, msg.sender);
    }

    function depositAll() override external {
        deposit(CAKE.balanceOf(msg.sender));
    }

    function withdrawAll() override external {
        uint amount = sharesOf(msg.sender);
        withdraw(amount);
    }

    function harvest() override external {
        CAKE_MASTER_CHEF.leaveStaking(0);
        uint cakeAmount = CAKE.balanceOf(address(this));
        CAKE_MASTER_CHEF.enterStaking(cakeAmount);
    }

    // salvage purpose only
    function withdrawToken(address token, uint amount) external {
        require(msg.sender == keeper || msg.sender == owner(), 'auth');
        require(token != address(CAKE));

        IBEP20(token).safeTransfer(msg.sender, amount);
    }

    function withdraw(uint256 _amount) override public {
        uint _withdraw = balance().mul(_amount).div(totalShares);
        totalShares = totalShares.sub(_amount);
        _shares[msg.sender] = _shares[msg.sender].sub(_amount);

        CAKE_MASTER_CHEF.leaveStaking(_withdraw.sub(CAKE.balanceOf(address(this))));
        CAKE.safeTransfer(msg.sender, _withdraw);

        CAKE_MASTER_CHEF.enterStaking(CAKE.balanceOf(address(this)));
    }

    function getReward() override external {
        revert("N/A");
    }
}


// Dependency file: contracts/interfaces/legacy/ICakeVault.sol

// pragma solidity ^0.6.12;

interface ICakeVault {
    function priceShare() external view returns(uint);
    function balanceOf(address account) external view returns(uint);
    function sharesOf(address account) external view returns(uint);
    function deposit(uint _amount) external;
    function withdraw(uint256 _amount) external;
}

// Dependency file: contracts/vaults/legacy/CakeFlipVault.sol

// pragma solidity ^0.6.12;


// import "@openzeppelin/contracts/math/Math.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/math/SafeMath.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/token/BEP20/SafeBEP20.sol";
// import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

// import "contracts/Constants.sol";
// import "contracts/library/legacy/RewardsDistributionRecipient.sol";
// import "contracts/library/legacy/Pausable.sol";
// import "contracts/interfaces/legacy/IStrategyHelper.sol";
// import "contracts/interfaces/IMasterChef.sol";
// import "contracts/interfaces/legacy/ICakeVault.sol";
// import "contracts/interfaces/IHunnyMinter.sol";
// import "contracts/interfaces/legacy/IStrategyLegacy.sol";

contract CakeFlipVault is IStrategyLegacy, RewardsDistributionRecipient, ReentrancyGuard, Pausable {
    using SafeMath for uint256;
    using SafeBEP20 for IBEP20;

    /* ========== STATE VARIABLES ========== */
    ICakeVault public rewardsToken;
    IBEP20 public stakingToken;
    uint256 public periodFinish = 0;
    uint256 public rewardRate = 0;
    uint256 public rewardsDuration = 24 hours;
    uint256 public lastUpdateTime;
    uint256 public rewardPerTokenStored;

    mapping(address => uint256) public userRewardPerTokenPaid;
    mapping(address => uint256) public rewards;

    uint256 private _totalSupply;
    mapping(address => uint256) private _balances;

    /* ========== CAKE     ============= */
    address private CAKE = Constants.CAKE;
    IMasterChef private CAKE_MASTER_CHEF;
    uint public poolId;
    address public keeper = Constants.HUNNY_KEEPER;
    mapping (address => uint) public depositedAt;

    /* ========== HUNNY HELPER / MINTER ========= */
    IStrategyHelper public helper;
    IHunnyMinter public minter;


    /* ========== CONSTRUCTOR ========== */

    constructor(uint _pid, address cake, address cakeMasterChef, address cakeVault, address hunnyMinter) public {
        CAKE = cake;
        CAKE_MASTER_CHEF = IMasterChef(cakeMasterChef);

        (address _token,,,) = CAKE_MASTER_CHEF.poolInfo(_pid);
        stakingToken = IBEP20(_token);
        stakingToken.safeApprove(address(CAKE_MASTER_CHEF), uint(~0));
        poolId = _pid;

        rewardsDistribution = msg.sender;
        setMinter(IHunnyMinter(hunnyMinter));
        setRewardsToken(cakeVault); // cake vault address
    }

    /* ========== VIEWS ========== */
    function totalSupply() external view returns (uint256) {
        return _totalSupply;
    }

    function balance() override external view returns (uint) {
        return _totalSupply;
    }

    function balanceOf(address account) override external view returns (uint256) {
        return _balances[account];
    }

    function principalOf(address account) override external view returns (uint256) {
        return _balances[account];
    }

    function withdrawableBalanceOf(address account) override public view returns (uint) {
        return _balances[account];
    }

    // return cakeAmount, hunnyAmount, 0
    function profitOf(address account) override public view returns (uint _usd, uint _hunny, uint _bnb) {
        uint cakeVaultPrice = rewardsToken.priceShare();
        uint _earned = earned(account);
        uint amount = _earned.mul(cakeVaultPrice).div(1e18);

        if (address(minter) != address(0) && minter.isMinter(address(this))) {
            uint performanceFee = minter.performanceFee(amount);
            // cake amount
            _usd = amount.sub(performanceFee);

            uint bnbValue = helper.tvlInBNB(CAKE, performanceFee);
            // hunny amount
            _hunny = minter.amountHunnyToMint(bnbValue);
        } else {
            _usd = amount;
            _hunny = 0;
        }

        _bnb = 0;
    }

    function tvl() override public view returns (uint) {
        uint stakingTVL = helper.tvl(address(stakingToken), _totalSupply);

        uint price = rewardsToken.priceShare();
        uint earned = rewardsToken.balanceOf(address(this)).mul(price).div(1e18);
        uint rewardTVL = helper.tvl(CAKE, earned);

        return stakingTVL.add(rewardTVL);
    }

    function tvlStaking() external view returns (uint) {
        return helper.tvl(address(stakingToken), _totalSupply);
    }

    function tvlReward() external view returns (uint) {
        uint price = rewardsToken.priceShare();
        uint earned = rewardsToken.balanceOf(address(this)).mul(price).div(1e18);
        return helper.tvl(CAKE, earned);
    }

    function apy() override public view returns(uint _usd, uint _hunny, uint _bnb) {
        uint dailyAPY = helper.compoundingAPY(poolId, 365 days).div(365);

        uint cakeAPY = helper.compoundingAPY(0, 1 days);
        uint cakeDailyAPY = helper.compoundingAPY(0, 365 days).div(365);

        // let x = 0.5% (daily flip apr)
        // let y = 0.87% (daily cake apr)
        // sum of yield of the year = x*(1+y)^365 + x*(1+y)^364 + x*(1+y)^363 + ... + x
        // ref: https://en.wikipedia.org/wiki/Geometric_series
        // = x * (1-(1+y)^365) / (1-(1+y))
        // = x * ((1+y)^365 - 1) / (y)

        _usd = dailyAPY.mul(cakeAPY).div(cakeDailyAPY);
        _hunny = 0;
        _bnb = 0;
    }

    function lastTimeRewardApplicable() public view returns (uint256) {
        return Math.min(block.timestamp, periodFinish);
    }

    function rewardPerToken() public view returns (uint256) {
        if (_totalSupply == 0) {
            return rewardPerTokenStored;
        }
        return
        rewardPerTokenStored.add(
            lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(_totalSupply)
        );
    }

    function earned(address account) public view returns (uint256) {
        return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]);
    }

    function getRewardForDuration() external view returns (uint256) {
        return rewardRate.mul(rewardsDuration);
    }

    /* ========== MUTATIVE FUNCTIONS ========== */
    function _deposit(uint256 amount, address _to) private nonReentrant notPaused updateReward(_to) {
        require(amount > 0, "amount");
        _totalSupply = _totalSupply.add(amount);
        _balances[_to] = _balances[_to].add(amount);
        depositedAt[_to] = block.timestamp;
        stakingToken.safeTransferFrom(msg.sender, address(this), amount);
        CAKE_MASTER_CHEF.deposit(poolId, amount);
        emit Staked(_to, amount);

        _harvest();
    }

    function deposit(uint256 amount) override public {
        _deposit(amount, msg.sender);
    }

    function depositAll() override external {
        deposit(stakingToken.balanceOf(msg.sender));
    }

    function withdraw(uint256 amount) override public nonReentrant updateReward(msg.sender) {
        require(amount > 0, "amount");
        _totalSupply = _totalSupply.sub(amount);
        _balances[msg.sender] = _balances[msg.sender].sub(amount);
        CAKE_MASTER_CHEF.withdraw(poolId, amount);

        if (address(minter) != address(0) && minter.isMinter(address(this))) {
            uint _depositedAt = depositedAt[msg.sender];
            uint withdrawalFee = minter.withdrawalFee(amount, _depositedAt);
            if (withdrawalFee > 0) {
                uint performanceFee = withdrawalFee.div(100);
                minter.mintFor(address(stakingToken), withdrawalFee.sub(performanceFee), performanceFee, msg.sender, _depositedAt);
                amount = amount.sub(withdrawalFee);
            }
        }

        stakingToken.safeTransfer(msg.sender, amount);
        emit Withdrawn(msg.sender, amount);

        _harvest();
    }

    function withdrawAll() override external {
        uint _withdraw = withdrawableBalanceOf(msg.sender);
        if (_withdraw > 0) {
            withdraw(_withdraw);
        }
        getReward();
    }

    function getReward() override public nonReentrant updateReward(msg.sender) {
        uint256 reward = rewards[msg.sender];
        if (reward > 0) {
            rewards[msg.sender] = 0;
            rewardsToken.withdraw(reward);
            uint cakeBalance = IBEP20(CAKE).balanceOf(address(this));

            if (address(minter) != address(0) && minter.isMinter(address(this))) {
                uint performanceFee = minter.performanceFee(cakeBalance);
                minter.mintFor(CAKE, 0, performanceFee, msg.sender, depositedAt[msg.sender]);
                cakeBalance = cakeBalance.sub(performanceFee);
            }

            IBEP20(CAKE).safeTransfer(msg.sender, cakeBalance);
            emit RewardPaid(msg.sender, cakeBalance);
        }
    }

    function harvest() override public {
        CAKE_MASTER_CHEF.withdraw(poolId, 0);
        _harvest();
    }

    function _harvest() private {
        uint cakeAmount = IBEP20(CAKE).balanceOf(address(this));
        uint _before = rewardsToken.sharesOf(address(this));
        rewardsToken.deposit(cakeAmount);
        uint amount = rewardsToken.sharesOf(address(this)).sub(_before);
        if (amount > 0) {
            _notifyRewardAmount(amount);
        }
    }

    function info(address account) override external view returns(UserInfo memory) {
        UserInfo memory userInfo;

        userInfo.balance = _balances[account];
        userInfo.principal = _balances[account];
        userInfo.available = withdrawableBalanceOf(account);

        Profit memory profit;
        (uint usd, uint hunny, uint bnb) = profitOf(account);
        profit.usd = usd;
        profit.hunny = hunny;
        profit.bnb = bnb;
        userInfo.profit = profit;

        userInfo.poolTVL = tvl();

        APY memory poolAPY;
        (usd, hunny, bnb) = apy();
        poolAPY.usd = usd;
        poolAPY.hunny = hunny;
        poolAPY.bnb = bnb;
        userInfo.poolAPY = poolAPY;

        return userInfo;
    }

    /* ========== RESTRICTED FUNCTIONS ========== */
    function setKeeper(address _keeper) external {
        require(msg.sender == _keeper || msg.sender == owner(), 'auth');
        require(_keeper != address(0), 'zero address');
        keeper = _keeper;
    }

    function setMinter(IHunnyMinter _minter) public onlyOwner {
        // can zero
        minter = _minter;
        if (address(_minter) != address(0)) {
            IBEP20(CAKE).safeApprove(address(_minter), 0);
            IBEP20(CAKE).safeApprove(address(_minter), uint(~0));

            stakingToken.safeApprove(address(_minter), 0);
            stakingToken.safeApprove(address(_minter), uint(~0));
        }
    }

    function setRewardsToken(address _rewardsToken) private onlyOwner {
        require(address(rewardsToken) == address(0), "set rewards token already");

        rewardsToken = ICakeVault(_rewardsToken);

        IBEP20(CAKE).safeApprove(_rewardsToken, 0);
        IBEP20(CAKE).safeApprove(_rewardsToken, uint(~0));
    }

    function setHelper(IStrategyHelper _helper) external onlyOwner {
        require(address(_helper) != address(0), "zero address");
        helper = _helper;
    }

    function notifyRewardAmount(uint256 reward) override public onlyRewardsDistribution {
        _notifyRewardAmount(reward);
    }

    function _notifyRewardAmount(uint256 reward) private updateReward(address(0)) {
        if (block.timestamp >= periodFinish) {
            rewardRate = reward.div(rewardsDuration);
        } else {
            uint256 remaining = periodFinish.sub(block.timestamp);
            uint256 leftover = remaining.mul(rewardRate);
            rewardRate = reward.add(leftover).div(rewardsDuration);
        }

        // Ensure the provided reward amount is not more than the balance in the contract.
        // This keeps the reward rate in the right range, preventing overflows due to
        // very high values of rewardRate in the earned and rewardsPerToken functions;
        // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow.
        uint _balance = rewardsToken.sharesOf(address(this));
        require(rewardRate <= _balance.div(rewardsDuration), "reward");

        lastUpdateTime = block.timestamp;
        periodFinish = block.timestamp.add(rewardsDuration);
        emit RewardAdded(reward);
    }

    function recoverBEP20(address tokenAddress, uint256 tokenAmount) external onlyOwner {
        require(tokenAddress != address(stakingToken) && tokenAddress != address(rewardsToken), "tokenAddress");
        IBEP20(tokenAddress).safeTransfer(owner(), tokenAmount);
        emit Recovered(tokenAddress, tokenAmount);
    }

    function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner {
        require(periodFinish == 0 || block.timestamp > periodFinish, "period");
        rewardsDuration = _rewardsDuration;
        emit RewardsDurationUpdated(rewardsDuration);
    }

    /* ========== MODIFIERS ========== */

    modifier updateReward(address account) {
        rewardPerTokenStored = rewardPerToken();
        lastUpdateTime = lastTimeRewardApplicable();
        if (account != address(0)) {
            rewards[account] = earned(account);
            userRewardPerTokenPaid[account] = rewardPerTokenStored;
        }
        _;
    }

    /* ========== EVENTS ========== */

    event RewardAdded(uint256 reward);
    event Staked(address indexed user, uint256 amount);
    event Withdrawn(address indexed user, uint256 amount);
    event RewardPaid(address indexed user, uint256 reward);
    event RewardsDurationUpdated(uint256 newDuration);
    event Recovered(address token, uint256 amount);
}


// Root file: contracts/hunny/HunnyDeployer.sol

pragma solidity ^0.6.12;

// import "@pancakeswap/pancake-swap-lib/contracts/math/SafeMath.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/access/Ownable.sol";
// import "@pancakeswap/pancake-swap-lib/contracts/token/BEP20/SafeBEP20.sol";

// import "contracts/hunny/HunnyToken.sol";
// import "contracts/hunny/HunnyOracle.sol";
// import "contracts/hunny/legacy/HunnyMinter.sol";
// import "contracts/Constants.sol";
// import "contracts/vaults/legacy/StrategyHelperV1.sol";
// import "contracts/vaults/legacy/HunnyPool.sol";
// import "contracts/vaults/legacy/HunnyBNBPool.sol";
// import "contracts/vaults/legacy/CakeVault.sol";
// import "contracts/vaults/legacy/CakeFlipVault.sol";
// import "contracts/interfaces/IPancakeRouter02.sol";

interface Presale {
    function totalBalance() external view returns(uint);
    function flipToken() external view returns(address);
    function initialize(address _token, address _masterChef, address _rewardToken) external;
    function distributeTokens(uint _pid, uint _fromIndex, uint _toIndex) external;
    function distributeTokensWhiteList(uint _pid) external;
    function finalize() external;
}

// assume that the presale contract has been deployed
// deploy following contract only when the presale ended
// ready for add liquidity and open legacy pools
contract Deployer1 is Ownable {
    HunnyToken public hunny;
    HunnyOracle public hunnyOracle;
    StrategyHelperV1 public helper;

    HunnyPool public hunnyPool;
    HunnyBNBPool public hunnyBNBPool;
    HunnyMinter public hunnyMinter;

    constructor(address presaleAddress) public {
        // deploy hunny token
        hunny = new HunnyToken();
        hunnyOracle = new HunnyOracle(address(hunny));
        helper = new StrategyHelperV1(address(hunny));

        // deploy HUNNY Pool
        hunnyPool = new HunnyPool(
            address(hunny),
            address(presaleAddress),
            address(helper)
        );

        // deploy HUNNY BNB pool
        hunnyBNBPool = new HunnyBNBPool(
            address(hunny),
            address(presaleAddress),
            address(helper)
        );

        // deploy hunny minter
        hunnyMinter = new HunnyMinter(
            address(hunny),
            address(hunnyPool),
            address(Constants.HUNNY_LOTTERY),
            address(hunnyOracle),
            address(helper)
        );
    }

    function transferContractOwner(address deployer2) public onlyOwner {
        hunny.transferOwnership(deployer2);
        hunny.transferOperator(deployer2);
        hunnyOracle.transferOwnership(deployer2);
        helper.transferOwnership(deployer2);
        hunnyPool.transferOwnership(deployer2);
        hunnyBNBPool.transferOwnership(deployer2);
        hunnyMinter.transferOwnership(deployer2);
    }
}

contract Deployer2 is Ownable {
    using SafeMath for uint256;
    using SafeBEP20 for IBEP20;

    Deployer1 public deployer1;
    Presale public presale;

    constructor(address deployer1Address, address payable presaleAddress) public {
        deployer1 = Deployer1(deployer1Address);
        presale = Presale(presaleAddress);
    }

    // allow deployer2 receive BNB from presale contract
    receive() external payable{}

    function step1_presaleInitialize() public onlyOwner {
        // mint token for presale contract
        deployer1.hunny().mint(address(presale), presale.totalBalance());

        // this part used to add liquidity and distribute to HUNNY pool as reward
        deployer1.hunny().mint(address(this), presale.totalBalance().div(2));

        // initialize presale
        presale.initialize(
            address(deployer1.hunny()),
            address(deployer1.hunnyBNBPool()),
            address(deployer1.hunnyPool())
        );

        // set flip token
        deployer1.hunnyBNBPool().setFlipToken(presale.flipToken());

        // set rewards token
        deployer1.hunnyPool().setRewardsToken(presale.flipToken());

        // update anti-whale max value
        // anti bots
        deployer1.hunny().updateMaxTransferAmountRate(4);
    }

    function step2_1_presaleDistributeTokens(uint fromIndex, uint toIndex) public onlyOwner {
        deployer1.hunny().updateMaxTransferAmountRate(10000);
        presale.distributeTokens(0, fromIndex, toIndex);
        deployer1.hunny().updateMaxTransferAmountRate(4);
    }

    function step2_2_presaleDistributeTokensWhiteList() public onlyOwner {
        deployer1.hunny().updateMaxTransferAmountRate(10000);
        presale.distributeTokensWhiteList(0);
        deployer1.hunny().updateMaxTransferAmountRate(4);
    }

    function step3_presaleFinalize() public onlyOwner {
        // transfer remain fund to this address
        presale.finalize();

        // transfer HUNNY token ownership
        deployer1.hunny().transferOwnership(address(deployer1.hunnyMinter()));

        // set minter role for HUNNY-BNB Hive Pool
        deployer1.hunnyMinter().setMinter(address(deployer1.hunnyBNBPool()), true);

        // set minter address in HUNNY-BNB Hive Pool
        deployer1.hunnyBNBPool().setMinter(IHunnyMinter(address(deployer1.hunnyMinter())));

        // set stake permission for Hunny Minter from HUNNY Hive Pool
        deployer1.hunnyPool().setStakePermission(address(deployer1.hunnyMinter()), true);

        // transfer hunny oracle owner to hunny minter
        deployer1.hunnyOracle().transferOwnership(address(deployer1.hunnyMinter()));
    }

    function step4_setupLiquidityReward(uint256 bnbAmount) public onlyOwner {
        deployer1.hunny().updateMaxTransferAmountRate(10000);
        IPancakeRouter02 router = IPancakeRouter02(Constants.PANCAKE_ROUTER);

        address token = address(deployer1.hunny());
        uint256 tokenAmount = bnbAmount.mul(deployer1.hunny().balanceOf(address(this))).div(address(this).balance);

        IBEP20(token).safeApprove(address(router), 0);
        IBEP20(token).safeApprove(address(router), tokenAmount);
        router.addLiquidityETH{value: bnbAmount}(token, tokenAmount, 0, 0, address(this), block.timestamp);

        payable(owner()).transfer(address(this).balance);
        deployer1.hunny().transfer(owner(), deployer1.hunny().balanceOf(address(this)));

        // set reward distribution on this address
        deployer1.hunnyPool().setRewardsDistribution(address(this));

        // transfer reward to HUNNY Hive Pool
        uint256 rewardAmount = IBEP20(presale.flipToken()).balanceOf(address(this));
        IBEP20(presale.flipToken()).transfer(address(deployer1.hunnyPool()), rewardAmount);
        deployer1.hunnyPool().notifyRewardAmount(rewardAmount);

        // set reward distribution on HUNNY Hive Pool
        deployer1.hunnyPool().setRewardsDistribution(address(deployer1.hunnyMinter()));

        deployer1.hunny().updateMaxTransferAmountRate(4);
    }

    function transferContractOwner(address newOwner) public onlyOwner {
        Ownable(address(presale)).transferOwnership(newOwner);

        deployer1.hunny().transferOperator(newOwner);
        deployer1.helper().transferOwnership(newOwner);

        deployer1.hunnyPool().transferOwnership(newOwner);
        deployer1.hunnyBNBPool().transferOwnership(newOwner);
        deployer1.hunnyMinter().transferOwnership(newOwner);
    }

    // in the emergency situation, transfer remain fund to dev
    // dev will init liquidity and distribute reward
    function emergencyTransfer() public payable onlyOwner {
        payable(owner()).transfer(address(this).balance);
        deployer1.hunny().transfer(owner(), deployer1.hunny().balanceOf(address(this)));
    }
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"fromDelegate","type":"address"},{"indexed":true,"internalType":"address","name":"toDelegate","type":"address"}],"name":"DelegateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"indexed":false,"internalType":"uint256","name":"previousBalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newBalance","type":"uint256"}],"name":"DelegateVotesChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"uint256","name":"previousRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newRate","type":"uint256"}],"name":"MaxTransferAmountRateUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOperator","type":"address"},{"indexed":true,"internalType":"address","name":"newOperator","type":"address"}],"name":"OperatorTransferred","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":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"BURN_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DELEGATION_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint32","name":"","type":"uint32"}],"name":"checkpoints","outputs":[{"internalType":"uint32","name":"fromBlock","type":"uint32"},{"internalType":"uint256","name":"votes","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"delegatee","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"delegatee","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"delegateBySig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"delegator","type":"address"}],"name":"delegates","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getCurrentVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"getPriorVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"isExcludedFromAntiWhale","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTransferAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTransferAmountRate","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"numCheckpoints","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"bool","name":"_excluded","type":"bool"}],"name":"setExcludedFromAntiWhale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOperator","type":"address"}],"name":"transferOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_maxTransferAmountRate","type":"uint16"}],"name":"updateMaxTransferAmountRate","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040526006805462ffff001916622710001790553480156200002257600080fd5b506040518060400160405280600b81526020016a243ab7373c902a37b5b2b760a91b8152506040518060400160405280600581526020016448554e4e5960d81b8152506000620000776200019b60201b60201c565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3508151620000d69060049060208501906200019f565b508051620000ec9060059060208401906200019f565b50506006805460ff19908116601217909155600880546001600160a01b031916339081179091556000908152600760205260408082208054841660019081179091557f6d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6df8054851682179055308352908220805484168217905561dead9091527fb0c2646e02af70b79e3fe9277b98373379f54150e4e26b2b5650139f7a75a65d8054909216179055506200023b565b3390565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620001e257805160ff191683800117855562000212565b8280016001018555821562000212579182015b8281111562000212578251825591602001919060010190620001f5565b506200022092915062000224565b5090565b5b8082111562000220576000815560010162000225565b612143806200024b6000396000f3fe608060405234801561001057600080fd5b50600436106102065760003560e01c8063782d6fe11161011a578063a9e75723116100ad578063dd62ed3e1161007c578063dd62ed3e1461042a578063e7a324dc1461043d578063f1127ed814610445578063f2fde38b14610466578063fccc28131461047957610206565b8063a9e75723146103e9578063b4b5ea57146103f1578063c3cda52014610404578063c7f59a671461041757610206565b806395d89b41116100e957806395d89b41146103a8578063a0712d68146103b0578063a457c2d7146103c3578063a9059cbb146103d657610206565b8063782d6fe1146103725780637ecebe0014610385578063893d20e8146103985780638da5cb5b146103a057610206565b8063395093511161019d5780635c19a95c1161016c5780635c19a95c146103115780636a141e2c146103245780636fcfff451461033757806370a0823114610357578063715018a61461036a57610206565b806339509351146102b65780633ff8bf2e146102c957806340c10f19146102de578063587cde1e146102f157610206565b806323b872dd116101d957806323b872dd14610266578063269f534c1461027957806329605e771461028c578063313ce567146102a157610206565b806306fdde031461020b578063095ea7b31461022957806318160ddd1461024957806320606b701461025e575b600080fd5b610213610481565b6040516102209190611ac4565b60405180910390f35b61023c610237366004611924565b610517565b6040516102209190611a4a565b610251610535565b6040516102209190611a55565b61025161053b565b61023c6102743660046118a9565b61055f565b61023c61028736600461185a565b6105e6565b61029f61029a36600461185a565b610604565b005b6102a96106d1565b6040516102209190612042565b61023c6102c4366004611924565b6106da565b6102d1610728565b6040516102209190611fe9565b61029f6102ec366004611924565b610737565b6103046102ff36600461185a565b61079f565b6040516102209190611a36565b61029f61031f36600461185a565b6107bd565b61029f6103323660046119e1565b6107ca565b61034a61034536600461185a565b61087f565b604051610220919061201b565b61025161036536600461185a565b610897565b61029f6108b2565b610251610380366004611924565b610931565b61025161039336600461185a565b610b1a565b610304610b2c565b610304610b3b565b610213610b4a565b61023c6103be366004611a03565b610bab565b61023c6103d1366004611924565b610bfb565b61023c6103e4366004611924565b610c63565b610251610c77565b6102516103ff36600461185a565b610ca6565b61029f61041236600461194e565b610d0a565b61029f6104253660046118e9565b610ede565b610251610438366004611875565b610f33565b610251610f5e565b6104586104533660046119ad565b610f82565b60405161022092919061202c565b61029f61047436600461185a565b610faf565b610304610fed565b60048054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561050d5780601f106104e25761010080835404028352916020019161050d565b820191906000526020600020905b8154815290600101906020018083116104f057829003601f168201915b5050505050905090565b600061052b610524610ff3565b8484610ff7565b5060015b92915050565b60035490565b7f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b600061056c8484846110ab565b6105dc84610578610ff3565b6105d78560405180606001604052806028815260200161209b602891396001600160a01b038a166000908152600260205260408120906105b6610ff3565b6001600160a01b031681526020810191909152604001600020549190611137565b610ff7565b5060019392505050565b6001600160a01b031660009081526007602052604090205460ff1690565b6008546001600160a01b031633146106375760405162461bcd60e51b815260040161062e90611ed9565b60405180910390fd5b6001600160a01b03811661065d5760405162461bcd60e51b815260040161062e90611e7c565b6008546040516001600160a01b038084169216907f74da04524d50c64947f5dd5381ef1a4dca5cba8ed1d816243f9e48aa0b5617ed90600090a3600880546001600160a01b039092166001600160a01b0319909216821790556000908152600760205260409020805460ff19166001179055565b60065460ff1690565b600061052b6106e7610ff3565b846105d785600260006106f8610ff3565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490611163565b600654610100900461ffff1681565b61073f610ff3565b6000546001600160a01b0390811691161461076c5760405162461bcd60e51b815260040161062e90611e47565b6107768282611188565b6001600160a01b0380831660009081526009602052604081205461079b92168361123c565b5050565b6001600160a01b039081166000908152600960205260409020541690565b6107c7338261137e565b50565b6008546001600160a01b031633146107f45760405162461bcd60e51b815260040161062e90611ed9565b6127108161ffff16111561081a5760405162461bcd60e51b815260040161062e90611d8d565b60065460405133917fb62a50fc861a770636e85357becb3b82a32e911106609d4985871eaf29011e089161085991610100900461ffff16908590611ff8565b60405180910390a26006805461ffff9092166101000262ffff0019909216919091179055565b600b6020526000908152604090205463ffffffff1681565b6001600160a01b031660009081526001602052604090205490565b6108ba610ff3565b6000546001600160a01b039081169116146108e75760405162461bcd60e51b815260040161062e90611e47565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60004382106109525760405162461bcd60e51b815260040161062e90611d04565b6001600160a01b0383166000908152600b602052604090205463ffffffff168061098057600091505061052f565b6001600160a01b0384166000908152600a6020908152604080832063ffffffff6000198601811685529252909120541683106109ef576001600160a01b0384166000908152600a602090815260408083206000199490940163ffffffff1683529290522060010154905061052f565b6001600160a01b0384166000908152600a6020908152604080832083805290915290205463ffffffff16831015610a2a57600091505061052f565b600060001982015b8163ffffffff168163ffffffff161115610ae357600282820363ffffffff16048103610a5c61182c565b506001600160a01b0387166000908152600a6020908152604080832063ffffffff808616855290835292819020815180830190925280549093168082526001909301549181019190915290871415610abe5760200151945061052f9350505050565b805163ffffffff16871115610ad557819350610adc565b6001820392505b5050610a32565b506001600160a01b0385166000908152600a6020908152604080832063ffffffff9094168352929052206001015491505092915050565b600c6020526000908152604090205481565b6000610b36610b3b565b905090565b6000546001600160a01b031690565b60058054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561050d5780601f106104e25761010080835404028352916020019161050d565b6000610bb5610ff3565b6000546001600160a01b03908116911614610be25760405162461bcd60e51b815260040161062e90611e47565b610bf3610bed610ff3565b83611188565b506001919050565b600061052b610c08610ff3565b846105d7856040518060600160405280602581526020016120e96025913960026000610c32610ff3565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190611137565b600061052b610c70610ff3565b84846110ab565b600654600090610b369061271090610ca090610100900461ffff16610c9a610535565b90611413565b9061144d565b6001600160a01b0381166000908152600b602052604081205463ffffffff1680610cd1576000610d03565b6001600160a01b0383166000908152600a6020908152604080832063ffffffff60001986011684529091529020600101545b9392505050565b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866610d35610481565b80519060200120610d4461148f565b30604051602001610d589493929190611a82565b60405160208183030381529060405280519060200120905060007fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf888888604051602001610da99493929190611a5e565b60405160208183030381529060405280519060200120905060008282604051602001610dd6929190611a1b565b604051602081830303815290604052805190602001209050600060018288888860405160008152602001604052604051610e139493929190611aa6565b6020604051602081039080840390855afa158015610e35573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610e685760405162461bcd60e51b815260040161062e90611f60565b6001600160a01b0381166000908152600c602052604090208054600181019091558914610ea75760405162461bcd60e51b815260040161062e90611cc1565b87421115610ec75760405162461bcd60e51b815260040161062e90611c1d565b610ed1818b61137e565b505050505b505050505050565b6008546001600160a01b03163314610f085760405162461bcd60e51b815260040161062e90611ed9565b6001600160a01b03919091166000908152600760205260409020805460ff1916911515919091179055565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b7fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf81565b600a6020908152600092835260408084209091529082529020805460019091015463ffffffff9091169082565b610fb7610ff3565b6000546001600160a01b03908116911614610fe45760405162461bcd60e51b815260040161062e90611e47565b6107c781611493565b61dead81565b3390565b6001600160a01b03831661101d5760405162461bcd60e51b815260040161062e90611b5c565b6001600160a01b0382166110435760405162461bcd60e51b815260040161062e90611fa7565b6001600160a01b0380841660008181526002602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259061109e908590611a55565b60405180910390a3505050565b82828260006110b8610c77565b111561112c576001600160a01b03831660009081526007602052604090205460ff1615801561110057506001600160a01b03821660009081526007602052604090205460ff16155b1561112c5761110d610c77565b81111561112c5760405162461bcd60e51b815260040161062e90611c64565b610ed6868686611514565b6000818484111561115b5760405162461bcd60e51b815260040161062e9190611ac4565b505050900390565b600082820183811015610d035760405162461bcd60e51b815260040161062e90611be6565b6001600160a01b0382166111ae5760405162461bcd60e51b815260040161062e90611e10565b6003546111bb9082611163565b6003556001600160a01b0382166000908152600160205260409020546111e19082611163565b6001600160a01b0383166000818152600160205260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611230908590611a55565b60405180910390a35050565b816001600160a01b0316836001600160a01b03161415801561125e5750600081115b15611379576001600160a01b038316156112f0576001600160a01b0383166000908152600b602052604081205463ffffffff16908161129e5760006112d0565b6001600160a01b0385166000908152600a6020908152604080832063ffffffff60001987011684529091529020600101545b905060006112de828561161e565b90506112ec86848484611660565b5050505b6001600160a01b03821615611379576001600160a01b0382166000908152600b602052604081205463ffffffff16908161132b57600061135d565b6001600160a01b0384166000908152600a6020908152604080832063ffffffff60001987011684529091529020600101545b9050600061136b8285611163565b9050610ed685848484611660565b505050565b6001600160a01b03808316600090815260096020526040812054909116906113a584610897565b6001600160a01b0385811660008181526009602052604080822080546001600160a01b031916898616908117909155905194955093928616927f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a461140d82848361123c565b50505050565b6000826114225750600061052f565b8282028284828161142f57fe5b0414610d035760405162461bcd60e51b815260040161062e90611d4c565b6000610d0383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506117c5565b4690565b6001600160a01b0381166114b95760405162461bcd60e51b815260040161062e90611ba0565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03831661153a5760405162461bcd60e51b815260040161062e90611b17565b6001600160a01b0382166115605760405162461bcd60e51b815260040161062e90611f1d565b61159d816040518060600160405280602681526020016120c3602691396001600160a01b0386166000908152600160205260409020549190611137565b6001600160a01b0380851660009081526001602052604080822093909355908416815220546115cc9082611163565b6001600160a01b0380841660008181526001602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061109e908590611a55565b6000610d0383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611137565b600061168443604051806060016040528060358152602001612066603591396117fc565b905060008463ffffffff161180156116cd57506001600160a01b0385166000908152600a6020908152604080832063ffffffff6000198901811685529252909120548282169116145b1561170a576001600160a01b0385166000908152600a6020908152604080832063ffffffff6000198901168452909152902060010182905561177b565b60408051808201825263ffffffff808416825260208083018681526001600160a01b038a166000818152600a84528681208b8616825284528681209551865490861663ffffffff199182161787559251600196870155908152600b9092529390208054928801909116919092161790555b846001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a72484846040516117b692919061200d565b60405180910390a25050505050565b600081836117e65760405162461bcd60e51b815260040161062e9190611ac4565b5060008385816117f257fe5b0495945050505050565b60008164010000000084106118245760405162461bcd60e51b815260040161062e9190611ac4565b509192915050565b604080518082019091526000808252602082015290565b80356001600160a01b038116811461052f57600080fd5b60006020828403121561186b578081fd5b610d038383611843565b60008060408385031215611887578081fd5b6118918484611843565b91506118a08460208501611843565b90509250929050565b6000806000606084860312156118bd578081fd5b83356118c881612050565b925060208401356118d881612050565b929592945050506040919091013590565b600080604083850312156118fb578182fd5b6119058484611843565b915060208301358015158114611919578182fd5b809150509250929050565b60008060408385031215611936578182fd5b6119408484611843565b946020939093013593505050565b60008060008060008060c08789031215611966578182fd5b6119708888611843565b95506020870135945060408701359350606087013560ff81168114611993578283fd5b9598949750929560808101359460a0909101359350915050565b600080604083850312156119bf578182fd5b6119c98484611843565b9150602083013563ffffffff81168114611919578182fd5b6000602082840312156119f2578081fd5b813561ffff81168114610d03578182fd5b600060208284031215611a14578081fd5b5035919050565b61190160f01b81526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b901515815260200190565b90815260200190565b9384526001600160a01b039290921660208401526040830152606082015260800190565b938452602084019290925260408301526001600160a01b0316606082015260800190565b93845260ff9290921660208401526040830152606082015260800190565b6000602080835283518082850152825b81811015611af057858101830151858201604001528201611ad4565b81811115611b015783604083870101525b50601f01601f1916929092016040019392505050565b60208082526025908201527f42455032303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f42455032303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526027908201527f48554e4e593a3a64656c656761746542795369673a207369676e617475726520604082015266195e1c1a5c995960ca1b606082015260800190565b6020808252603f908201527f48554e4e593a3a616e74695768616c653a205472616e7366657220616d6f756e60408201527f74206578636565647320746865206d61785472616e73666572416d6f756e7400606082015260800190565b60208082526023908201527f48554e4e593a3a64656c656761746542795369673a20696e76616c6964206e6f6040820152626e636560e81b606082015260800190565b60208082526028908201527f48554e4e593a3a6765745072696f72566f7465733a206e6f74207965742064656040820152671d195c9b5a5b995960c21b606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252605e908201527f48554e4e593a3a7570646174654d61785472616e73666572416d6f756e74526160408201527f74653a204d6178207472616e7366657220616d6f756e742072617465206d757360608201527f74206e6f742065786365656420746865206d6178696d756d20726174652e0000608082015260a00190565b6020808252601f908201527f42455032303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526039908201527f48554e4e593a3a7472616e736665724f70657261746f723a206e6577206f706560408201527f7261746f7220697320746865207a65726f206164647265737300000000000000606082015260800190565b60208082526024908201527f6f70657261746f723a2063616c6c6572206973206e6f7420746865206f70657260408201526330ba37b960e11b606082015260800190565b60208082526023908201527f42455032303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526027908201527f48554e4e593a3a64656c656761746542795369673a20696e76616c6964207369604082015266676e617475726560c81b606082015260800190565b60208082526022908201527f42455032303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b61ffff91909116815260200190565b61ffff92831681529116602082015260400190565b918252602082015260400190565b63ffffffff91909116815260200190565b63ffffffff929092168252602082015260400190565b60ff91909116815260200190565b6001600160a01b03811681146107c757600080fdfe48554e4e593a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d6265722065786365656473203332206269747342455032303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212209f51fd7000cfc41223d148bf6a24f57d1d0b83a53b42a221d36134442a9bae1464736f6c634300060c0033

Deployed ByteCode Sourcemap

35395:11529:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;26220:92;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;27707:161;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;26696:100::-;;;:::i;:::-;;;;;;;:::i;39417:122::-;;;:::i;28339:397::-;;;;;;:::i;:::-;;:::i;37110:136::-;;;;;;:::i;:::-;;:::i;37826:327::-;;;;;;:::i;:::-;;:::i;:::-;;26379:92;;;:::i;:::-;;;;;;;:::i;29144:210::-;;;;;;:::i;:::-;;:::i;35462:43::-;;;:::i;:::-;;;;;;;:::i;38255:162::-;;;;;;:::i;:::-;;:::i;40379:137::-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;40661:104::-;;;;;;:::i;:::-;;:::i;37254:405::-;;;;;;:::i;:::-;;:::i;39299:49::-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;26858:119::-;;;;;;:::i;:::-;;:::i;9033:140::-;;;:::i;43242:1242::-;;;;;;:::i;:::-;;:::i;39823:39::-;;;;;;:::i;:::-;;:::i;26063:94::-;;;:::i;8391:79::-;;;:::i;26536:96::-;;;:::i;30385:130::-;;;;;;:::i;:::-;;:::i;29856:311::-;;;;;;:::i;:::-;;:::i;27189:167::-;;;;;;:::i;:::-;;:::i;36966:136::-;;;:::i;42571:243::-;;;;;;:::i;:::-;;:::i;41196:1177::-;;;;;;:::i;:::-;;:::i;37667:151::-;;;;;;:::i;:::-;;:::i;27418:143::-;;;;;;:::i;:::-;;:::i;39629:117::-;;;:::i;39164:70::-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;;:::i;9328:109::-;;;;;;:::i;:::-;;:::i;35520:81::-;;;:::i;26220:92::-;26299:5;26292:12;;;;;;;;;;;;;-1:-1:-1;;26292:12:0;;;;;;;;;;;;;;;;;;;;;;;;;;26266:13;;26292:12;;26299:5;;26292:12;;;26299:5;26292:12;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;26220:92;:::o;27707:161::-;27782:4;27799:39;27808:12;:10;:12::i;:::-;27822:7;27831:6;27799:8;:39::i;:::-;-1:-1:-1;27856:4:0;27707:161;;;;;:::o;26696:100::-;26776:12;;26696:100;:::o;39417:122::-;39459:80;39417:122;:::o;28339:397::-;28471:4;28488:36;28498:6;28506:9;28517:6;28488:9;:36::i;:::-;28535:171;28558:6;28579:12;:10;:12::i;:::-;28606:89;28644:6;28606:89;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;28606:19:0;;;;;;:11;:19;;;;;;28626:12;:10;:12::i;:::-;-1:-1:-1;;;;;28606:33:0;;;;;;;;;;;;-1:-1:-1;28606:33:0;;;;:37;:89::i;:::-;28535:8;:171::i;:::-;-1:-1:-1;28724:4:0;28339:397;;;;;:::o;37110:136::-;-1:-1:-1;;;;;37206:32:0;37182:4;37206:32;;;:22;:32;;;;;;;;;37110:136::o;37826:327::-;35952:9;;-1:-1:-1;;;;;35952:9:0;35965:10;35952:23;35944:72;;;;-1:-1:-1;;;35944:72:0;;;;;;;:::i;:::-;;;;;;;;;-1:-1:-1;;;;;37912:25:0;::::1;37904:95;;;::::0;-1:-1:-1;;;37904:95:0;;::::1;::::0;::::1;;;:::i;:::-;38035:9;::::0;38015:43:::1;::::0;-1:-1:-1;;;;;38015:43:0;;::::1;::::0;38035:9:::1;::::0;38015:43:::1;::::0;38035:9:::1;::::0;38015:43:::1;38069:9;:23:::0;;-1:-1:-1;;;;;;38069:23:0::1;-1:-1:-1::0;;;;;38069:23:0;;;::::1;::::0;;::::1;::::0;;-1:-1:-1;38103:35:0;;;:22:::1;:35;::::0;;;;:42;;-1:-1:-1;;38103:42:0::1;-1:-1:-1::0;38103:42:0::1;::::0;;37826:327::o;26379:92::-;26454:9;;;;26379:92;:::o;29144:210::-;29224:4;29241:83;29250:12;:10;:12::i;:::-;29264:7;29273:50;29312:10;29273:11;:25;29285:12;:10;:12::i;:::-;-1:-1:-1;;;;;29273:25:0;;;;;;;;;;;;;;;;;-1:-1:-1;29273:25:0;;;:34;;;;;;;;;;;:38;:50::i;35462:43::-;;;;;;;;;:::o;38255:162::-;8613:12;:10;:12::i;:::-;8603:6;;-1:-1:-1;;;;;8603:22:0;;;:6;;:22;8595:67;;;;-1:-1:-1;;;8595:67:0;;;;;;;:::i;:::-;38327:19:::1;38333:3;38338:7;38327:5;:19::i;:::-;-1:-1:-1::0;;;;;38384:15:0;;::::1;38380:1;38384:15:::0;;;:10:::1;:15;::::0;;;;;38357:52:::1;::::0;38384:15:::1;38401:7:::0;38357:14:::1;:52::i;:::-;38255:162:::0;;:::o;40379:137::-;-1:-1:-1;;;;;40487:21:0;;;40455:7;40487:21;;;:10;:21;;;;;;;;40379:137::o;40661:104::-;40725:32;40735:10;40747:9;40725;:32::i;:::-;40661:104;:::o;37254:405::-;35952:9;;-1:-1:-1;;;;;35952:9:0;35965:10;35952:23;35944:72;;;;-1:-1:-1;;;35944:72:0;;;;;;;:::i;:::-;37387:5:::1;37361:22;:31;;;;37353:138;;;::::0;-1:-1:-1;;;37353:138:0;;::::1;::::0;::::1;;;:::i;:::-;37548:21;::::0;37507:87:::1;::::0;37536:10:::1;::::0;37507:87:::1;::::0;::::1;::::0;37548:21:::1;::::0;::::1;;;::::0;37571:22;;37507:87:::1;:::i;:::-;;;;;;;;37605:21;:46:::0;;::::1;::::0;;::::1;;;-1:-1:-1::0;;37605:46:0;;::::1;::::0;;;::::1;::::0;;37254:405::o;39299:49::-;;;;;;;;;;;;;;;:::o;26858:119::-;-1:-1:-1;;;;;26951:18:0;26924:7;26951:18;;;-1:-1:-1;26951:18:0;;;;;;;26858:119::o;9033:140::-;8613:12;:10;:12::i;:::-;8603:6;;-1:-1:-1;;;;;8603:22:0;;;:6;;:22;8595:67;;;;-1:-1:-1;;;8595:67:0;;;;;;;:::i;:::-;9132:1:::1;9116:6:::0;;9095:40:::1;::::0;-1:-1:-1;;;;;9116:6:0;;::::1;::::0;9095:40:::1;::::0;9132:1;;9095:40:::1;9163:1;9146:19:::0;;-1:-1:-1;;;;;;9146:19:0::1;::::0;;9033:140::o;43242:1242::-;43338:7;43385:12;43371:11;:26;43363:79;;;;-1:-1:-1;;;43363:79:0;;;;;;;:::i;:::-;-1:-1:-1;;;;;43477:23:0;;43455:19;43477:23;;;:14;:23;;;;;;;;;43511:58;;43556:1;43549:8;;;;;43511:58;-1:-1:-1;;;;;43629:20:0;;;;;;:11;:20;;;;;;;;:38;-1:-1:-1;;43650:16:0;;43629:38;;;;;;;;;:48;;-1:-1:-1;;43625:147:0;;-1:-1:-1;;;;;43716:20:0;;;;;;:11;:20;;;;;;;;-1:-1:-1;;43737:16:0;;;;43716:38;;;;;;;;-1:-1:-1;43716:44:0;;;-1:-1:-1;43709:51:0;;43625:147;-1:-1:-1;;;;;43833:20:0;;;;;;:11;:20;;;;;;;;:23;;;;;;;;:33;:23;:33;-1:-1:-1;;43829:88:0;;;43904:1;43897:8;;;;;43829:88;43929:12;-1:-1:-1;;43971:16:0;;43998:428;44013:5;44005:13;;:5;:13;;;43998:428;;;44077:1;44060:13;;;44059:19;;;44051:27;;44120:20;;:::i;:::-;-1:-1:-1;;;;;;44143:20:0;;;;;;:11;:20;;;;;;;;:28;;;;;;;;;;;;;44120:51;;;;;;;;;;;;;;;;-1:-1:-1;44120:51:0;;;;;;;;;;;;44190:27;;44186:229;;;44245:8;;;;-1:-1:-1;44238:15:0;;-1:-1:-1;;;;44238:15:0;44186:229;44279:12;;:26;;;-1:-1:-1;44275:140:0;;;44334:6;44326:14;;44275:140;;;44398:1;44389:6;:10;44381:18;;44275:140;43998:428;;;;;-1:-1:-1;;;;;;44443:20:0;;;;;;:11;:20;;;;;;;;:27;;;;;;;;;;:33;;;;-1:-1:-1;;43242:1242:0;;;;:::o;39823:39::-;;;;;;;;;;;;;:::o;26063:94::-;26115:7;26142;:5;:7::i;:::-;26135:14;;26063:94;:::o;8391:79::-;8429:7;8456:6;-1:-1:-1;;;;;8456:6:0;;8391:79::o;26536:96::-;26617:7;26610:14;;;;;;;;;;;;;-1:-1:-1;;26610:14:0;;;;;;;;;;;;;;;;;;;;;;;;;;26584:13;;26610:14;;26617:7;;26610:14;;;26617:7;26610:14;;;;;;;;;;;;;;;;;;;;;;;;30385:130;30441:4;8613:12;:10;:12::i;:::-;8603:6;;-1:-1:-1;;;;;8603:22:0;;;:6;;:22;8595:67;;;;-1:-1:-1;;;8595:67:0;;;;;;;:::i;:::-;30458:27:::1;30464:12;:10;:12::i;:::-;30478:6;30458:5;:27::i;:::-;-1:-1:-1::0;30503:4:0::1;30385:130:::0;;;:::o;29856:311::-;29941:4;29958:179;29981:12;:10;:12::i;:::-;30008:7;30030:96;30069:15;30030:96;;;;;;;;;;;;;;;;;:11;:25;30042:12;:10;:12::i;:::-;-1:-1:-1;;;;;30030:25:0;;;;;;;;;;;;;;;;;-1:-1:-1;30030:25:0;;;:34;;;;;;;;;;;;:38;:96::i;27189:167::-;27267:4;27284:42;27294:12;:10;:12::i;:::-;27308:9;27319:6;27284:9;:42::i;36966:136::-;37061:21;;37016:7;;37043:51;;37088:5;;37043:40;;37061:21;;;;;37043:13;:11;:13::i;:::-;:17;;:40::i;:::-;:44;;:51::i;42571:243::-;-1:-1:-1;;;;;42698:23:0;;42651:7;42698:23;;;:14;:23;;;;;;;;;42739:67;;42805:1;42739:67;;;-1:-1:-1;;;;;42758:20:0;;;;;;:11;:20;;;;;;;;-1:-1:-1;;42779:16:0;;42758:38;;;;;;;;;-1:-1:-1;42758:44:0;;42739:67;42732:74;42571:243;-1:-1:-1;;;42571:243:0:o;41196:1177::-;41385:23;39459:80;41514:6;:4;:6::i;:::-;41498:24;;;;;;41541:12;:10;:12::i;:::-;41580:4;41435:165;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;41411:200;;;;;;41385:226;;41624:18;39675:71;41736:9;41764:5;41788:6;41669:140;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;41645:175;;;;;;41624:196;;41833:14;41938:15;41972:10;41874:123;;;;;;;;;:::i;:::-;;;;;;;;;;;;;41850:158;;;;;;41833:175;;42021:17;42041:26;42051:6;42059:1;42062;42065;42041:26;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;42041:26:0;;-1:-1:-1;;42041:26:0;;;-1:-1:-1;;;;;;;42086:23:0;;42078:75;;;;-1:-1:-1;;;42078:75:0;;;;;;;:::i;:::-;-1:-1:-1;;;;;42181:17:0;;;;;;:6;:17;;;;;:19;;-1:-1:-1;42181:19:0;;;;;42172:28;;42164:76;;;;-1:-1:-1;;;42164:76:0;;;;;;;:::i;:::-;42266:6;42259:3;:13;;42251:65;;;;-1:-1:-1;;;42251:65:0;;;;;;;:::i;:::-;42334:31;42344:9;42355;42334;:31::i;:::-;42327:38;;;;41196:1177;;;;;;;:::o;37667:151::-;35952:9;;-1:-1:-1;;;;;35952:9:0;35965:10;35952:23;35944:72;;;;-1:-1:-1;;;35944:72:0;;;;;;;:::i;:::-;-1:-1:-1;;;;;37766:32:0;;;::::1;;::::0;;;:22:::1;:32;::::0;;;;:44;;-1:-1:-1;;37766:44:0::1;::::0;::::1;;::::0;;;::::1;::::0;;37667:151::o;27418:143::-;-1:-1:-1;;;;;27526:18:0;;;27499:7;27526:18;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;27418:143::o;39629:117::-;39675:71;39629:117;:::o;39164:70::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;9328:109::-;8613:12;:10;:12::i;:::-;8603:6;;-1:-1:-1;;;;;8603:22:0;;;:6;;:22;8595:67;;;;-1:-1:-1;;;8595:67:0;;;;;;;:::i;:::-;9401:28:::1;9420:8;9401:18;:28::i;35520:81::-:0;35559:42;35520:81;:::o;6929:98::-;7009:10;6929:98;:::o;33227:372::-;-1:-1:-1;;;;;33355:19:0;;33347:68;;;;-1:-1:-1;;;33347:68:0;;;;;;;:::i;:::-;-1:-1:-1;;;;;33434:21:0;;33426:68;;;;-1:-1:-1;;;33426:68:0;;;;;;;:::i;:::-;-1:-1:-1;;;;;33507:18:0;;;;;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;;:36;;;33559:32;;;;;33507:36;;33559:32;:::i;:::-;;;;;;;;33227:372;;;:::o;36772:186::-;36870:6;36878:9;36889:6;36151:1;36129:19;:17;:19::i;:::-;:23;36125:335;;;-1:-1:-1;;;;;36191:30:0;;;;;;:22;:30;;;;;;;;:39;;;:102;;-1:-1:-1;;;;;;36251:33:0;;;;;;:22;:33;;;;;;;;:42;36191:102;36169:280;;;36346:19;:17;:19::i;:::-;36336:6;:29;;36328:105;;;;-1:-1:-1;;;36328:105:0;;;;;;;:::i;:::-;36908:42:::1;36924:6;36932:9;36943:6;36908:15;:42::i;1890:226::-:0;2010:7;2046:12;2038:6;;;;2030:29;;;;-1:-1:-1;;;2030:29:0;;;;;;;;:::i;:::-;-1:-1:-1;;;2082:5:0;;;1890:226::o;987:181::-;1045:7;1077:5;;;1101:6;;;;1093:46;;;;-1:-1:-1;;;1093:46:0;;;;;;;:::i;31799:308::-;-1:-1:-1;;;;;31875:21:0;;31867:65;;;;-1:-1:-1;;;31867:65:0;;;;;;;:::i;:::-;31960:12;;:24;;31977:6;31960:16;:24::i;:::-;31945:12;:39;-1:-1:-1;;;;;32016:18:0;;;;;;-1:-1:-1;32016:18:0;;;;;;:30;;32039:6;32016:22;:30::i;:::-;-1:-1:-1;;;;;31995:18:0;;;;;;-1:-1:-1;31995:18:0;;;;;;:51;;;;32062:37;;31995:18;;;32062:37;;;;32092:6;;32062:37;:::i;:::-;;;;;;;;31799:308;;:::o;44935:947::-;-1:-1:-1;;;;;45031:16:0;;;;;;;;;;:30;;;45060:1;45051:6;:10;45031:30;45027:848;;;-1:-1:-1;;;;;45082:20:0;;;45078:385;;-1:-1:-1;;;;;45190:22:0;;45171:16;45190:22;;;:14;:22;;;;;;;;;;45251:60;;45310:1;45251:60;;;-1:-1:-1;;;;;45267:19:0;;;;;;:11;:19;;;;;;;;-1:-1:-1;;45287:13:0;;45267:34;;;;;;;;;-1:-1:-1;45267:40:0;;45251:60;45231:80;-1:-1:-1;45330:17:0;45350:21;45231:80;45364:6;45350:13;:21::i;:::-;45330:41;;45390:57;45407:6;45415:9;45426;45437;45390:16;:57::i;:::-;45078:385;;;;-1:-1:-1;;;;;45483:20:0;;;45479:385;;-1:-1:-1;;;;;45591:22:0;;45572:16;45591:22;;;:14;:22;;;;;;;;;;45652:60;;45711:1;45652:60;;;-1:-1:-1;;;;;45668:19:0;;;;;;:11;:19;;;;;;;;-1:-1:-1;;45688:13:0;;45668:34;;;;;;;;;-1:-1:-1;45668:40:0;;45652:60;45632:80;-1:-1:-1;45731:17:0;45751:21;45632:80;45765:6;45751:13;:21::i;:::-;45731:41;;45791:57;45808:6;45816:9;45827;45838;45791:16;:57::i;45479:385::-;44935:947;;;:::o;44492:435::-;-1:-1:-1;;;;;44605:21:0;;;44579:23;44605:21;;;:10;:21;;;;;;;;;;44664:20;44605:21;44664:9;:20::i;:::-;-1:-1:-1;;;;;44741:21:0;;;;;;;:10;:21;;;;;;:33;;-1:-1:-1;;;;;;44741:33:0;;;;;;;;;;44792:54;;44637:47;;-1:-1:-1;44741:33:0;44792:54;;;;;;44741:21;44792:54;44859:60;44874:15;44891:9;44902:16;44859:14;:60::i;:::-;44492:435;;;;:::o;2375:471::-;2433:7;2678:6;2674:47;;-1:-1:-1;2708:1:0;2701:8;;2674:47;2745:5;;;2749:1;2745;:5;:1;2769:5;;;;;:10;2761:56;;;;-1:-1:-1;;;2761:56:0;;;;;;;:::i;3322:132::-;3380:7;3407:39;3411:1;3414;3407:39;;;;;;;;;;;;;;;;;:3;:39::i;46768:153::-;46878:9;46768:153;:::o;9543:229::-;-1:-1:-1;;;;;9617:22:0;;9609:73;;;;-1:-1:-1;;;9609:73:0;;;;;;;:::i;:::-;9719:6;;;9698:38;;-1:-1:-1;;;;;9698:38:0;;;;9719:6;;;9698:38;;;9747:6;:17;;-1:-1:-1;;;;;;9747:17:0;-1:-1:-1;;;;;9747:17:0;;;;;;;;;;9543:229::o;31005:513::-;-1:-1:-1;;;;;31145:20:0;;31137:70;;;;-1:-1:-1;;;31137:70:0;;;;;;;:::i;:::-;-1:-1:-1;;;;;31226:23:0;;31218:71;;;;-1:-1:-1;;;31218:71:0;;;;;;;:::i;:::-;31322;31344:6;31322:71;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;31322:17:0;;;;;;-1:-1:-1;31322:17:0;;;;;;;;:21;:71::i;:::-;-1:-1:-1;;;;;31302:17:0;;;;;;;-1:-1:-1;31302:17:0;;;;;;:91;;;;31427:20;;;;;;;:32;;31452:6;31427:24;:32::i;:::-;-1:-1:-1;;;;;31404:20:0;;;;;;;-1:-1:-1;31404:20:0;;;;;;;:55;;;;31475:35;;;;;;;;;;31503:6;;31475:35;:::i;1451:136::-;1509:7;1536:43;1540:1;1543;1536:43;;;;;;;;;;;;;;;;;:3;:43::i;45890:701::-;46065:18;46086:77;46093:12;46086:77;;;;;;;;;;;;;;;;;:6;:77::i;:::-;46065:98;;46195:1;46180:12;:16;;;:85;;;;-1:-1:-1;;;;;;46200:22:0;;;;;;:11;:22;;;;;;;;:65;-1:-1:-1;;46223:16:0;;46200:40;;;;;;;;;:50;:65;;;:50;;:65;46180:85;46176:339;;;-1:-1:-1;;;;;46282:22:0;;;;;;:11;:22;;;;;;;;-1:-1:-1;;46305:16:0;;46282:40;;;;;;;;;-1:-1:-1;46282:46:0;:57;;;46176:339;;;46411:33;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;46372:22:0;;-1:-1:-1;46372:22:0;;;:11;:22;;;;;:36;;;;;;;;;;:72;;;;-1:-1:-1;;46372:72:0;;;;;;;;;;;;;;-1:-1:-1;46372:72:0;;;;46459:25;;;:14;:25;;;;;;:44;;;;;46487:16;;;46459:44;;;;46176:339;46532:51;;-1:-1:-1;;;;;46532:51:0;;;;;;;46564:8;;46574;;46532:51;:::i;:::-;;;;;;;;45890:701;;;;;:::o;3950:312::-;4070:7;4105:12;4098:5;4090:28;;;;-1:-1:-1;;;4090:28:0;;;;;;;;:::i;:::-;;4129:9;4145:1;4141;:5;;;;;;;3950:312;-1:-1:-1;;;;;3950:312:0:o;46599:161::-;46674:6;46712:12;46705:5;46701:9;;46693:32;;;;-1:-1:-1;;;46693:32:0;;;;;;;;:::i;:::-;-1:-1:-1;46750:1:0;;46599:161;-1:-1:-1;;46599:161:0:o;-1:-1:-1:-;;;;;;;;;;;;;;;;;;;:::o;5:130::-;72:20;;-1:-1;;;;;26249:54;;27212:35;;27202:2;;27261:1;;27251:12;950:241;;1054:2;1042:9;1033:7;1029:23;1025:32;1022:2;;;-1:-1;;1060:12;1022:2;1122:53;1167:7;1143:22;1122:53;:::i;1198:366::-;;;1319:2;1307:9;1298:7;1294:23;1290:32;1287:2;;;-1:-1;;1325:12;1287:2;1387:53;1432:7;1408:22;1387:53;:::i;:::-;1377:63;;1495:53;1540:7;1477:2;1520:9;1516:22;1495:53;:::i;:::-;1485:63;;1281:283;;;;;:::o;1571:491::-;;;;1709:2;1697:9;1688:7;1684:23;1680:32;1677:2;;;-1:-1;;1715:12;1677:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;1767:63;-1:-1;1867:2;1906:22;;72:20;97:33;72:20;97:33;:::i;:::-;1671:391;;1875:63;;-1:-1;;;1975:2;2014:22;;;;612:20;;1671:391::o;2069:360::-;;;2187:2;2175:9;2166:7;2162:23;2158:32;2155:2;;;-1:-1;;2193:12;2155:2;2255:53;2300:7;2276:22;2255:53;:::i;:::-;2245:63;;2345:2;2385:9;2381:22;206:20;27358:5;25991:13;25984:21;27336:5;27333:32;27323:2;;-1:-1;;27369:12;27323:2;2353:60;;;;2149:280;;;;;:::o;2436:366::-;;;2557:2;2545:9;2536:7;2532:23;2528:32;2525:2;;;-1:-1;;2563:12;2525:2;2625:53;2670:7;2646:22;2625:53;:::i;:::-;2615:63;2715:2;2754:22;;;;612:20;;-1:-1;;;2519:283::o;2809:865::-;;;;;;;2996:3;2984:9;2975:7;2971:23;2967:33;2964:2;;;-1:-1;;3003:12;2964:2;3065:53;3110:7;3086:22;3065:53;:::i;:::-;3055:63;;3155:2;3198:9;3194:22;612:20;3163:63;;3263:2;3306:9;3302:22;612:20;3271:63;;3371:2;3412:9;3408:22;882:20;26560:4;27970:5;26549:16;27947:5;27944:33;27934:2;;-1:-1;;27981:12;27934:2;2958:716;;;;-1:-1;2958:716;;3477:3;3517:22;;340:20;;3586:3;3626:22;;;340:20;;-1:-1;2958:716;-1:-1;;2958:716::o;3681:364::-;;;3801:2;3789:9;3780:7;3776:23;3772:32;3769:2;;;-1:-1;;3807:12;3769:2;3869:53;3914:7;3890:22;3869:53;:::i;:::-;3859:63;;3959:2;4001:9;3997:22;748:20;26466:10;27850:5;26455:22;27826:5;27823:34;27813:2;;-1:-1;;27861:12;4052:239;;4155:2;4143:9;4134:7;4130:23;4126:32;4123:2;;;-1:-1;;4161:12;4123:2;489:6;476:20;26168:6;27604:5;26157:18;27580:5;27577:34;27567:2;;-1:-1;;27615:12;4298:241;;4402:2;4390:9;4381:7;4377:23;4373:32;4370:2;;;-1:-1;;4408:12;4370:2;-1:-1;612:20;;4364:175;-1:-1;4364:175::o;12930:659::-;-1:-1;;;6835:87;;6820:1;6941:11;;4848:37;;;;13441:12;;;4848:37;13552:12;;;13175:414::o;13596:222::-;-1:-1;;;;;26249:54;;;;4617:37;;13723:2;13708:18;;13694:124::o;13825:210::-;25991:13;;25984:21;4731:34;;13946:2;13931:18;;13917:118::o;14042:222::-;4848:37;;;14169:2;14154:18;;14140:124::o;14271:556::-;4848:37;;;-1:-1;;;;;26249:54;;;;14647:2;14632:18;;4617:37;14730:2;14715:18;;4848:37;14813:2;14798:18;;4848:37;14482:3;14467:19;;14453:374::o;14834:556::-;4848:37;;;15210:2;15195:18;;4848:37;;;;15293:2;15278:18;;4848:37;-1:-1;;;;;26249:54;15376:2;15361:18;;4617:37;15045:3;15030:19;;15016:374::o;15397:548::-;4848:37;;;26560:4;26549:16;;;;15765:2;15750:18;;12883:35;15848:2;15833:18;;4848:37;15931:2;15916:18;;4848:37;15604:3;15589:19;;15575:370::o;15952:310::-;;16099:2;;16120:17;16113:47;5201:5;25460:12;25617:6;16099:2;16088:9;16084:18;25605:19;-1:-1;26763:101;26777:6;26774:1;26771:13;26763:101;;;26844:11;;;;;26838:18;26825:11;;;25645:14;26825:11;26818:39;26792:10;;26763:101;;;26879:6;26876:1;26873:13;26870:2;;;-1:-1;25645:14;26935:6;16088:9;26926:16;;26919:27;26870:2;-1:-1;27132:7;27116:14;-1:-1;;27112:28;5359:39;;;;25645:14;5359:39;;16070:192;-1:-1;;;16070:192::o;16269:416::-;16469:2;16483:47;;;5635:2;16454:18;;;25605:19;5671:34;25645:14;;;5651:55;-1:-1;;;5726:12;;;5719:29;5767:12;;;16440:245::o;16692:416::-;16892:2;16906:47;;;6018:2;16877:18;;;25605:19;6054:34;25645:14;;;6034:55;-1:-1;;;6109:12;;;6102:28;6149:12;;;16863:245::o;17115:416::-;17315:2;17329:47;;;6400:2;17300:18;;;25605:19;6436:34;25645:14;;;6416:55;-1:-1;;;6491:12;;;6484:30;6533:12;;;17286:245::o;17538:416::-;17738:2;17752:47;;;7191:2;17723:18;;;25605:19;7227:29;25645:14;;;7207:50;7276:12;;;17709:245::o;17961:416::-;18161:2;18175:47;;;7527:2;18146:18;;;25605:19;7563:34;25645:14;;;7543:55;-1:-1;;;7618:12;;;7611:31;7661:12;;;18132:245::o;18384:416::-;18584:2;18598:47;;;7912:2;18569:18;;;25605:19;7948:34;25645:14;;;7928:55;8017:33;8003:12;;;7996:55;8070:12;;;18555:245::o;18807:416::-;19007:2;19021:47;;;8321:2;18992:18;;;25605:19;8357:34;25645:14;;;8337:55;-1:-1;;;8412:12;;;8405:27;8451:12;;;18978:245::o;19230:416::-;19430:2;19444:47;;;8702:2;19415:18;;;25605:19;8738:34;25645:14;;;8718:55;-1:-1;;;8793:12;;;8786:32;8837:12;;;19401:245::o;19653:416::-;19853:2;19867:47;;;9088:2;19838:18;;;25605:19;9124:34;25645:14;;;9104:55;-1:-1;;;9179:12;;;9172:25;9216:12;;;19824:245::o;20076:416::-;20276:2;20290:47;;;9467:2;20261:18;;;25605:19;9503:34;25645:14;;;9483:55;9572:34;9558:12;;;9551:56;9641:32;9627:12;;;9620:54;9693:12;;;20247:245::o;20499:416::-;20699:2;20713:47;;;9944:2;20684:18;;;25605:19;9980:33;25645:14;;;9960:54;10033:12;;;20670:245::o;20922:416::-;21122:2;21136:47;;;21107:18;;;25605:19;10320:34;25645:14;;;10300:55;10374:12;;;21093:245::o;21345:416::-;21545:2;21559:47;;;10625:2;21530:18;;;25605:19;10661:34;25645:14;;;10641:55;10730:27;10716:12;;;10709:49;10777:12;;;21516:245::o;21768:416::-;21968:2;21982:47;;;11028:2;21953:18;;;25605:19;11064:34;25645:14;;;11044:55;-1:-1;;;11119:12;;;11112:28;11159:12;;;21939:245::o;22191:416::-;22391:2;22405:47;;;11410:2;22376:18;;;25605:19;11446:34;25645:14;;;11426:55;-1:-1;;;11501:12;;;11494:27;11540:12;;;22362:245::o;22614:416::-;22814:2;22828:47;;;11791:2;22799:18;;;25605:19;11827:34;25645:14;;;11807:55;-1:-1;;;11882:12;;;11875:31;11925:12;;;22785:245::o;23037:416::-;23237:2;23251:47;;;12176:2;23222:18;;;25605:19;12212:34;25645:14;;;12192:55;-1:-1;;;12267:12;;;12260:26;12305:12;;;23208:245::o;23460:218::-;26168:6;26157:18;;;;12400:36;;23585:2;23570:18;;23556:122::o;23685:329::-;26168:6;26157:18;;;12518:49;;26157:18;;24000:2;23985:18;;12518:49;23838:2;23823:18;;23809:205::o;24250:333::-;4848:37;;;24569:2;24554:18;;4848:37;24405:2;24390:18;;24376:207::o;24590:218::-;26466:10;26455:22;;;;12768:36;;24715:2;24700:18;;24686:122::o;24815:329::-;26466:10;26455:22;;;;12768:36;;25130:2;25115:18;;4848:37;24968:2;24953:18;;24939:205::o;25151:214::-;26560:4;26549:16;;;;12883:35;;25274:2;25259:18;;25245:120::o;27153:117::-;-1:-1;;;;;26249:54;;27212:35;;27202:2;;27261:1;;27251:12

Swarm Source

ipfs://9f51fd7000cfc41223d148bf6a24f57d1d0b83a53b42a221d36134442a9bae14
Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.