Contract 0x3b87475ac293eeed0e8bc25713eb8242a9497c3f 3

 
 
Txn Hash
Block
From
To
Value [Txn Fee]
0xd02e1967647b2d7a9bb34218d92e1ea72233b8e0e6d1bc25b5b729b61dde19fe95686112021-07-29 7:04:5515 hrs 5 mins ago0xb7d53f88fb6406aa99ef13787b638a9a6693f146 IN  Merlin: Staking0 BNB0.00046586
0x0cdfa10bf1e226fc0865698bc754b772789732033bec4f162cce019c32b7848c94794632021-07-26 0:18:573 days 21 hrs ago0x4ceaecfec87b4d0c3de801577f63edc92e8d6468 IN  Merlin: Staking0 BNB0.00072841
0x953ac8c392f1fdb59446438dbe9ff78ec6d1624526e74dfe2e6ad8262060d85394791142021-07-26 0:01:293 days 22 hrs ago0x56db27dc3dc1cccff010855901244442f0ca5430 IN  Merlin: Staking0 BNB0.000560695
0x54112c9ed99dc7cc295f5b3a30e849b7b9cf0ebabb6d1c2e8d0fbe2609a905be94213122021-07-23 23:24:295 days 22 hrs ago0x20c00d7e78452bd6c37d11302999ade9927f08fa IN  Merlin: Staking0 BNB0.00046592
0xf1acce4099b08afdaad76432b1c59051c5a8119ea585f95d800f6621646d7d7594212822021-07-23 23:22:595 days 22 hrs ago0x20c00d7e78452bd6c37d11302999ade9927f08fa IN  Merlin: Staking0 BNB0.00010638
0x408679e0c820235ec38567afa2f5e748cf666bce0e24a242e4a8af8acb5cf88f94155362021-07-23 18:35:266 days 3 hrs ago0x0a96ff6944322c8d8b0ec58eb03645dd4b445caf IN  Merlin: Staking0 BNB0.00028414
0x7abec6a7ff4d033427ca98e24e969a5405b3781b575782f8a3f92864339109cd93937492021-07-23 0:18:576 days 21 hrs ago0xfea17493407720e6972d7443f021e90fdf14203a IN  Merlin: Staking0 BNB0.000288875
0x8da7b708557597063424b3da7efd7051ae994803b6cd6377f0e149e196f70b0393937202021-07-23 0:17:306 days 21 hrs ago0xfea17493407720e6972d7443f021e90fdf14203a IN  Merlin: Staking0 BNB0.00010638
0x61adb3f7cc6dbf51eeffbc468e6153b27c87f65ae82eb18976f1da2c63f7d1a393937172021-07-23 0:17:216 days 21 hrs ago0xfea17493407720e6972d7443f021e90fdf14203a IN  Merlin: Staking0 BNB0.00028414
0x423ce0312baeb9103ad6ac7bdec3d5f48d8e9bf4456f48769f16c1fb3e8d260f93920512021-07-22 22:53:386 days 23 hrs ago0xfea17493407720e6972d7443f021e90fdf14203a IN  Merlin: Staking0 BNB0.000288875
0x511f1dea76a62809ff47a94230ecf87e108a4547aff0db4d4a2c2c10a541374693650372021-07-22 0:22:497 days 21 hrs ago0xfea17493407720e6972d7443f021e90fdf14203a IN  Merlin: Staking0 BNB0.000288875
0x05e946561b5348ff7b2fabc05ddfa3a29bb62f8da041e46a0e48fe4d6edcb6a693640822021-07-21 23:35:047 days 22 hrs ago0xfea17493407720e6972d7443f021e90fdf14203a IN  Merlin: Staking0 BNB0.000363875
0x397d77aee30fe9fd432c96ec87a19461bad64149f6e446e07b23b6e3c95da6ee92864552021-07-19 6:50:5710 days 15 hrs ago0x8bfc9c381d9cf982005d8ebce354eb6f9d581d1f IN  Merlin: Staking0 BNB0.00054086
0x8392f0c3495153b35af1a6a471ac6e03741c40139c141e20cfe7b1b1d10ec0fd92546882021-07-18 4:21:4811 days 17 hrs ago0x49d5ee5cc9618c96f7de47c194fb71953f857be0 IN  Merlin: Staking0 BNB0.0004658
0x0c7b83ffefb855f0be4b24a82d6b9d7db6d0d5937da5917c087924d1ba57022391878372021-07-15 20:37:2014 days 1 hr ago0x3755ce0cd86ef9ffc816fc7f663094a76505d177 IN  Merlin: Staking0 BNB0.00083318
0xe02fcfc3f35e674992e5b34c83274549bb0c0f01076e0fd35fddf017e72148d391875842021-07-15 20:24:4114 days 1 hr ago0x3755ce0cd86ef9ffc816fc7f663094a76505d177 IN  Merlin: Staking0 BNB0.00083318
0x72721fe9eb755fb4360a9b7206a25e2b91366ff204c6438cc548f38bf209079b91873582021-07-15 20:13:2314 days 1 hr ago0x3755ce0cd86ef9ffc816fc7f663094a76505d177 IN  Merlin: Staking0 BNB0.00010638
0xd8d3c7d2132ccb9b3da4ca5cc21c6e981de663624507dcdfe78a236e0657a2f791119582021-07-13 5:21:5716 days 16 hrs ago0x4ce7c691e0d895b44df70bba17ea5f5760f4cd6c IN  Merlin: Staking0 BNB0.00046586
0x9af23d09001fd82ddc0719ef2ef9d5f4957c9a8eb876f1bf6d24a14cb91352f091119472021-07-13 5:21:2416 days 16 hrs ago0x4ce7c691e0d895b44df70bba17ea5f5760f4cd6c IN  Merlin: Staking0 BNB0.000384105
0x57dfa14e3f1812bc1c7511fbab7b83f5f6eaa2eff38368d208a8c6e823b9697f91092892021-07-13 3:08:3016 days 19 hrs ago0x4ea672f3b8c5e34990cf7144ef5bf2b7a349be4d IN  Merlin: Staking0 BNB0.00046592
0x6345ff013257fef559cb64503394a78eb2bfb5261dd06f363e42cb839e88e5de90941502021-07-12 14:31:3317 days 7 hrs ago0x984e683d2d64b2be8e2670bac5c146c66c02cdce IN  Merlin: Staking0 BNB0.00083318
0x783ec58ccaf559a5babfec322d9ea63ba135b9f9c68ff693aa3b6b412df1d08f90938862021-07-12 14:18:2117 days 7 hrs ago0x984e683d2d64b2be8e2670bac5c146c66c02cdce IN  Merlin: Staking0 BNB0.00083318
0xe039c205499817e372c7ca9dd10b838b33ffb3a9b681c08f18ceda75a9f690f690896962021-07-12 10:48:5017 days 11 hrs ago0x21bc930d54df549d8bd4f8586ca05e4a6fbb871a IN  Merlin: Staking0 BNB0.00046592
0xa5f56ba33db99e5f29ad4a9b97b69eebe08ea4d813c82726666de49e51a1ba6190683912021-07-11 17:03:1818 days 5 hrs ago0x35e2971bd63d6cbe4daccc7ff368aa12bac85aa8 IN  Merlin: Staking0 BNB0.000384105
0x652ab8628a24b0ecaeb8f0cc98b1adb6a820f2da491faeb951d436f4720e9cbb90624512021-07-11 12:06:1818 days 10 hrs ago0x15728dc02fcbdba945108cfa0fd449abe5e64c19 IN  Merlin: Staking0 BNB0.000459105
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MerlinPool

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 27 : MerlinPool.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;

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

import "./interface/IStakingRewards.sol";
import "./interface/IStrategy.sol";
import "./interface/IStrategyHelper.sol";
import "./interface/IPancakeRouter02.sol";
import "./interface/IZapBSC.sol";

import "./library/Pausable.sol";
import "./library/PoolConstant.sol";
import "./library/RewardsDistributionRecipient.sol";

import "./PriceCalculatorBSC.sol";

contract MerlinPool is IStrategy, RewardsDistributionRecipient, ReentrancyGuard, Pausable {
    using SafeMath for uint256;
    using SafeBEP20 for IBEP20;

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

    IBEP20 public _rewardsToken;
    IBEP20 public  _stakingToken;
    address public merlinBNB;
    address public  WBNB;
    uint256 public periodFinish = 0;
    uint256 public rewardRate = 0;
    uint256 public rewardsDuration = 90 days;
    uint256 public lastUpdateTime;
    uint256 public rewardPerTokenStored;
    IZapBSC public zapBSC;
    address public BTCB;
    address public ETH;

    mapping(address => uint256) public userRewardPerTokenPaid;
    mapping(address => uint256) public rewards;
    mapping(address => uint) private _depositedAt;

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

    mapping(address => bool) private _stakePermission;

    /* ========== HELPER ========= */
    PriceCalculatorBSC private  priceCalculator;
    IPancakeRouter02 private ROUTER;

    PoolConstant.PoolTypes public constant override poolType = PoolConstant.PoolTypes.MerlinPool;

    /* ========== CONSTRUCTOR ========== */
    constructor(
        address _merlin,
        address _router,
        address _priceCalc,
        address _merlinBNB,
        address _wbnb,
        address _zapBSC,
        address _btcb,
        address _eth
    ) public {
        _stakingToken = IBEP20(_merlin);
        ROUTER = IPancakeRouter02(_router);
        priceCalculator = PriceCalculatorBSC(_priceCalc);
        merlinBNB = _merlinBNB;
        WBNB = _wbnb;
        zapBSC = IZapBSC(_zapBSC);
        BTCB = _btcb;
        ETH = _eth;

        rewardsDistribution = msg.sender;

        _stakePermission[msg.sender] = true;

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

        IBEP20(WBNB).safeApprove(address(ROUTER), uint(~0));
        IBEP20(_btcb).safeApprove(address(ROUTER), uint(~0));
        IBEP20(_eth).safeApprove(address(ROUTER), uint(~0));

    }

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

    function totalSupply() override 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];
    }

    function profitOf(address account) public view returns (uint _usd, uint _merlin, uint _bnb) {
        _usd = 0;
        _merlin = 0;
        (_bnb,) = priceCalculator.valueOfAsset(address(_rewardsToken), earned(account));
    }

    function tvl() public view returns (uint valueInBNB) {
        ( valueInBNB,) = priceCalculator.valueOfAsset(address(_stakingToken), _totalSupply);
    }

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

        uint rewardPerTokenPerSecond = rewardRate.mul(tokenDecimals).div(__totalSupply);
        ( uint merlinPrice,) = priceCalculator.valueOfAsset(address(_stakingToken), 1e18);

        _usd = 0;
        _merlin = 0;
        _bnb = rewardPerTokenPerSecond.mul(365 days).mul(1e18).div(merlinPrice);
    }

    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) override 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);
        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 getRewardInBTC() public nonReentrant updateReward(msg.sender) {
        uint256 reward = rewards[msg.sender];

        if (reward > 0) {
            rewards[msg.sender] = 0;
            reward = _flipToWBNB(reward);

            address[] memory path = new address[](2);
            path[0] = WBNB;
            path[1] = BTCB;
            ROUTER.swapExactTokensForTokens(reward, 0, path, address(this), block.timestamp);

            reward = IBEP20(BTCB).balanceOf(address(this));

            if (reward > 0) {
              IBEP20(BTCB).safeTransfer(msg.sender, reward);
              emit RewardPaid(msg.sender, reward);
            }
        }
    }

    function getRewardInETH() public nonReentrant updateReward(msg.sender) {
        uint256 reward = rewards[msg.sender];

        if (reward > 0) {
            rewards[msg.sender] = 0;
            reward = _flipToWBNB(reward);

            address[] memory path = new address[](2);
            path[0] = WBNB;
            path[1] = ETH;
            ROUTER.swapExactTokensForTokens(reward, 0, path, address(this), block.timestamp);

            reward = IBEP20(ETH).balanceOf(address(this));


            if (reward > 0) {
              IBEP20(ETH).safeTransfer(msg.sender, reward);
              emit RewardPaid(msg.sender, reward);
            }
        }
    }

    function _flipToWBNB(uint amount) private returns(uint reward) {
        address wbnb = ROUTER.WETH();
        (uint rewardMerlin,) = 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(rewardMerlin, 0, path, address(this), block.timestamp);

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


    function harvest() override external {}

    function info(address account) 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 merlin, uint bnb) = profitOf(account);
        profit.usd = usd;
        profit.merlin = merlin;
        profit.bnb = bnb;
        userInfo.profit = profit;

        userInfo.poolTVL = tvl();

        APY memory poolAPY;
        (usd, merlin, bnb) = apy();
        poolAPY.usd = usd;
        poolAPY.merlin = merlin;
        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);
        IBEP20(_rewardsToken).safeApprove(address(ROUTER), uint(~0));
    }

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

    function stakeTo(uint256 amount, address _to) external canStakeTo {
        _deposit(amount, _to);
    }

    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');
        _;
    }

    function stakingToken() external override view returns (address) {
        return address(_stakingToken);
    }

    function rewardsToken() external override view returns (address) {
        return address(_rewardsToken);
    }

    function minter() external view override returns (address) {
        return address(0);
    }

    function priceShare() external view override returns (uint) {
        return 1e18;
    }

    function depositedAt(address account) external view override returns (uint) {
        return _depositedAt[account];
    }

    function sharesOf(address ) public view override returns (uint) {
        return 0;
    }

    /* ========== 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);
}

File 2 of 27 : PriceCalculatorBSC.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;

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

import "./interface/IPancakePair.sol";
import "./interface/IPancakeFactory.sol";
// import "./interface/AggregatorV3Interface.sol";

contract PriceCalculatorBSC is OwnableUpgradeable {
    using SafeMath for uint;

    // address public constant WBNB = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c;
    // address public constant CAKE = 0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82;
    // address public constant BUNNY = 0xC9849E6fdB743d08fAeE3E34dd2D1bc69EA11a51;
    // address public constant VAI = 0x4BD17003473389A42DAF6a0a729f6Fdb328BbBd7;
    // address public constant BUSD = 0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56;

    // IPancakeFactory private constant factory = IPancakeFactory(0xBCfCcbde45cE874adCB698cC183deBcF17952812);
    // AggregatorV3Interface private constant bnbPriceFeed = AggregatorV3Interface(0x0567F2323251f0Aab15c8dFb1967E4e8A7D42aeE);

    address public WBNB;
    address public CAKE;
    address public BUNNY;
    address public VAI;
    address public BUSD;

    IPancakeFactory private factory;
    // AggregatorV3Interface private bnbPriceFeed;

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

    mapping(address => address) private pairTokens;

    /* ========== INITIALIZER ========== */

    function initialize(
        address _wbnb,
        address _cake,
        address _bunny,
        address _vai,
        address _busd,
        address _factory
        // address _bnbPriceFeed
    ) external initializer {
        __Ownable_init();

        WBNB = _wbnb;
        CAKE = _cake;
        BUNNY = _bunny;
        VAI = _vai;
        BUSD = _busd;

        factory = IPancakeFactory(_factory);
        // bnbPriceFeed = AggregatorV3Interface(_bnbPriceFeed);

        setPairToken(VAI, BUSD);
    }

    /* ========== Restricted Operation ========== */
    function setPairToken(address asset, address pairToken) public onlyOwner {
        pairTokens[asset] = pairToken;
    }

    /* ========== Value Calculation ========== */

    function priceOfBNB() pure public returns (uint) {
        // (, int price, , ,) = bnbPriceFeed.latestRoundData();
        int price = 570;
        return uint(price).mul(1e10);
    }

    function priceOfCake() view public returns (uint) {
        (, uint cakePriceInUSD) = valueOfAsset(CAKE, 1e18);
        return cakePriceInUSD;
    }

    function priceOfBunny() view public returns (uint) {
        (, uint bunnyPriceInUSD) = valueOfAsset(BUNNY, 1e18);
        return bunnyPriceInUSD;
    }

    function pricesInUSD(address[] memory assets) public view returns (uint[] memory) {
        uint[] memory prices = new uint[](assets.length);
        for (uint i = 0; i < assets.length; i++) {
            (, uint valueInUSD) = valueOfAsset(assets[i], 1e18);
            prices[i] = valueInUSD;
        }
        return prices;
    }

    function valueOfAsset(address asset, uint amount) public view returns (uint valueInBNB, uint valueInUSD) {
        if (asset == address(0) || asset == WBNB) {
            valueInBNB = amount;
            valueInUSD = amount.mul(priceOfBNB()).div(1e18);
        }
        else if (keccak256(abi.encodePacked(IPancakePair(asset).symbol())) == keccak256("Cake-LP")) {
            if (IPancakePair(asset).token0() == WBNB || IPancakePair(asset).token1() == WBNB) {
                valueInBNB = amount.mul(IBEP20(WBNB).balanceOf(address(asset))).mul(2).div(IPancakePair(asset).totalSupply());
                valueInUSD = valueInBNB.mul(priceOfBNB()).div(1e18);
            } else {
                uint balanceToken0 = IBEP20(IPancakePair(asset).token0()).balanceOf(asset);
                (uint token0PriceInBNB,) = valueOfAsset(IPancakePair(asset).token0(), 1e18);

                valueInBNB = amount.mul(balanceToken0).mul(2).mul(token0PriceInBNB).div(1e18).div(IPancakePair(asset).totalSupply());
                valueInUSD = valueInBNB.mul(priceOfBNB()).div(1e18);
            }
        }
        else {
            address pairToken = pairTokens[asset] == address(0) ? WBNB : pairTokens[asset];
            address pair = factory.getPair(asset, pairToken);
            valueInBNB = IBEP20(pairToken).balanceOf(pair).mul(amount).div(IBEP20(asset).balanceOf(pair));
            if (pairToken != WBNB) {
                (uint pairValueInBNB,) = valueOfAsset(pairToken, 1e18);
                valueInBNB = valueInBNB.mul(pairValueInBNB).div(1e18);
            }
            valueInUSD = valueInBNB.mul(priceOfBNB()).div(1e18);
        }
    }
}

File 3 of 27 : IMerlinMinter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;

interface IMerlinMinter {
    function isMinter(address) view external returns(bool);
    function amountMerlinToMint(uint bnbProfit) 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 payable;

    function merlinPerProfitBNB() 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;

    function mintGov(uint amount) external;
}

File 4 of 27 : IPancakeFactory.sol
// SPDX-License-Identifier: MIT
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;
}

File 5 of 27 : IPancakePair.sol
// SPDX-License-Identifier: MIT
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;
}

File 6 of 27 : IPancakeRouter01.sol
// SPDX-License-Identifier: MIT
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);
}

File 7 of 27 : IPancakeRouter02.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2;

import './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;
}

File 8 of 27 : IStakingRewards.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;

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

File 9 of 27 : IStrategy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;


import "../library/PoolConstant.sol";
import "./IVaultController.sol";

struct Profit {
    uint usd;
    uint merlin;
    uint bnb;
}

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

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


interface IStrategy is IVaultController {
    function deposit(uint _amount) external;
    function depositAll() external;
    function withdraw(uint256 _amount) external;    // MERLIN STAKING POOL ONLY
    function withdrawAll() external;
    function getReward() external;                  // MERLIN STAKING POOL ONLY
    function harvest() external;

    function totalSupply() external view returns (uint);
    function balance() external view returns (uint);
    function balanceOf(address account) external view returns (uint);
    function sharesOf(address account) external view returns (uint);
    function principalOf(address account) external view returns (uint);
    function earned(address account) external view returns (uint);
    function withdrawableBalanceOf(address account) external view returns (uint);   // MERLIN STAKING POOL ONLY
    function priceShare() external view returns(uint);

    /* ========== Strategy Information ========== */

    // function pid() external view returns (uint);
    function poolType() external view returns (PoolConstant.PoolTypes);
    function depositedAt(address account) external view returns (uint);
    function rewardsToken() external view returns (address);

    event Deposited(address indexed user, uint256 amount);
    event Withdrawn(address indexed user, uint256 amount, uint256 withdrawalFee);
    event ProfitPaid(address indexed user, uint256 profit, uint256 performanceFee);
    event MerlinPaid(address indexed user, uint256 profit, uint256 performanceFee);
    event Harvested(uint256 profit);
}

File 10 of 27 : IStrategyHelper.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;

import "../interface/IMerlinMinter.sol";

interface IStrategyHelper {
    function tokenPriceInBNB(address _token) view external returns(uint);
    function cakePriceInBNB() view external returns(uint);
    function bnbPriceInUSD() view external returns(uint);
    function profitOf(IMerlinMinter minter, address _flip, uint amount) external view returns (uint _usd, uint _bunny, 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(IMerlinMinter minter, uint pid) external view returns(uint _usd, uint _bunny, uint _bnb);
}

File 11 of 27 : IVaultController.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;

interface IVaultController {
    function minter() external view returns (address);
    function stakingToken() external view returns (address);
}

File 12 of 27 : IZapBSC.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
// pragma experimental ABIEncoderV2;

interface IZapBSC {
    function zapIn(address _to) external payable;
    function zapOut(address _from, uint amount) external;
    function zapInToken(address _from, uint amount, address _to) external;
}

File 13 of 27 : Pausable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;

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

File 14 of 27 : PoolConstant.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;


library PoolConstant {

    enum PoolTypes {
        MerlinPool, MerlinStake, CakeStake, FlipToFlip, FlipToCake, FlipToCakeMaximizer, Merlin
    }

    struct PoolInfoBSC {
        address pool;
        uint balance;
        uint principal;
        uint available;
        uint share;
        uint apyPool;
        uint apyBunny;
        uint apyBorrow;
        uint tvl;
        uint utilized;
        uint liquidity;
        uint pUSD;
        uint pBNB;
        uint pBASE;
        uint pMERL;
        uint pCAKE;
        uint depositedAt;
        uint feeDuration;
        uint feePercentage;
    }

    struct PoolInfoETH {
        address pool;
        uint collateralETH;
        uint collateralBSC;
        uint bnbDebt;
        uint leverage;
        uint tvl;
        uint updatedAt;
        uint depositedAt;
        uint feeDuration;
        uint feePercentage;
    }
}

File 15 of 27 : 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
*/

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

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

File 16 of 27 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal initializer {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal initializer {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

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

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

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

File 17 of 27 : Initializable.sol
// SPDX-License-Identifier: MIT

// solhint-disable-next-line compiler-version
pragma solidity >=0.4.24 <0.8.0;

import "../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {

    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /// @dev Returns true if and only if the function is running in the constructor
    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 18 of 27 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @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) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

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

        // 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");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

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

File 19 of 27 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;
import "../proxy/Initializable.sol";

/*
 * @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.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal initializer {
        __Context_init_unchained();
    }

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

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

File 20 of 27 : Math.sol
// SPDX-License-Identifier: MIT

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

File 21 of 27 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

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

File 22 of 27 : Context.sol
// SPDX-License-Identifier: GPL-3.0-or-later

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

File 23 of 27 : Ownable.sol
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity >=0.4.0;

import '../GSN/Context.sol';

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

File 24 of 27 : 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;
        }
    }
}

File 25 of 27 : IBEP20.sol
// SPDX-License-Identifier: GPL-3.0-or-later

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

File 26 of 27 : SafeBEP20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import './IBEP20.sol';
import '../../math/SafeMath.sol';
import '../../utils/Address.sol';

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

File 27 of 27 : Address.sol
// SPDX-License-Identifier: MIT

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

Settings
{
  "remappings": [],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "evmVersion": "istanbul",
  "libraries": {},
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract ABI

[{"inputs":[{"internalType":"address","name":"_merlin","type":"address"},{"internalType":"address","name":"_router","type":"address"},{"internalType":"address","name":"_priceCalc","type":"address"},{"internalType":"address","name":"_merlinBNB","type":"address"},{"internalType":"address","name":"_wbnb","type":"address"},{"internalType":"address","name":"_zapBSC","type":"address"},{"internalType":"address","name":"_btcb","type":"address"},{"internalType":"address","name":"_eth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"profit","type":"uint256"}],"name":"Harvested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"profit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"performanceFee","type":"uint256"}],"name":"MerlinPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PauseChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"profit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"performanceFee","type":"uint256"}],"name":"ProfitPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Recovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newDuration","type":"uint256"}],"name":"RewardsDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawalFee","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"BTCB","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WBNB","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_rewardsToken","outputs":[{"internalType":"contract IBEP20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_stakingToken","outputs":[{"internalType":"contract IBEP20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"apy","outputs":[{"internalType":"uint256","name":"_usd","type":"uint256"},{"internalType":"uint256","name":"_merlin","type":"uint256"},{"internalType":"uint256","name":"_bnb","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"balance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"depositedAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getRewardForDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRewardInBTC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getRewardInETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"harvest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"info","outputs":[{"components":[{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint256","name":"available","type":"uint256"},{"components":[{"internalType":"uint256","name":"usd","type":"uint256"},{"internalType":"uint256","name":"merlin","type":"uint256"},{"internalType":"uint256","name":"bnb","type":"uint256"}],"internalType":"struct Profit","name":"profit","type":"tuple"},{"internalType":"uint256","name":"poolTVL","type":"uint256"},{"components":[{"internalType":"uint256","name":"usd","type":"uint256"},{"internalType":"uint256","name":"merlin","type":"uint256"},{"internalType":"uint256","name":"bnb","type":"uint256"}],"internalType":"struct APY","name":"poolAPY","type":"tuple"}],"internalType":"struct UserInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastTimeRewardApplicable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"merlinBNB","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reward","type":"uint256"}],"name":"notifyRewardAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodFinish","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolType","outputs":[{"internalType":"enum PoolConstant.PoolTypes","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"principalOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"profitOf","outputs":[{"internalType":"uint256","name":"_usd","type":"uint256"},{"internalType":"uint256","name":"_merlin","type":"uint256"},{"internalType":"uint256","name":"_bnb","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"recoverBEP20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerTokenStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsDistribution","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_rewardsDistribution","type":"address"}],"name":"setRewardsDistribution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewardsDuration","type":"uint256"}],"name":"setRewardsDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"__rewardsToken","type":"address"}],"name":"setRewardsToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"bool","name":"permission","type":"bool"}],"name":"setStakePermission","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"sharesOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"stakeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakingToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tvl","outputs":[{"internalType":"uint256","name":"valueInBNB","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userRewardPerTokenPaid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"withdrawableBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"zapBSC","outputs":[{"internalType":"contract IZapBSC","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

6080604052600060085560006009556276a700600a553480156200002257600080fd5b506040516200342f3803806200342f83398101604081905262000045916200052c565b6000620000516200022c565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35060016002556000620000ac62000230565b6001600160a01b03161415620000df5760405162461bcd60e51b8152600401620000d6906200074a565b60405180910390fd5b600580546001600160a01b03199081166001600160a01b038b81169190911783556017805483168b83161781556016805484168b84161790556006805484168a8416179055600780548416898416179055600d80548416888416179055600e80548416878416179055600f8054841686841617905560018054339416841781556000938452601560209081526040909420805460ff191690911790555492546200019d9390821692911690600019906200023f811b62001a8f17901c565b601754600754620001ca916001600160a01b0391821691166000196200023f602090811b62001a8f17901c565b601754620001f4906001600160a01b0384811691166000196200023f602090811b62001a8f17901c565b6017546200021e906001600160a01b0383811691166000196200023f602090811b62001a8f17901c565b5050505050505050620007df565b3390565b6000546001600160a01b031690565b801580620002ce5750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e906200027890309086906004016200063b565b60206040518083038186803b1580156200029157600080fd5b505afa158015620002a6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002cc919062000604565b155b620002ed5760405162461bcd60e51b8152600401620000d690620006ed565b620003488363095ea7b360e01b84846040516024016200030f92919062000655565b60408051808303601f190181529190526020810180516001600160e01b0319939093166001600160e01b03938416179052906200034d16565b505050565b6060620003a9826040518060400160405280602081526020017f5361666542455032303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316620003e960201b62001b8e179092919060201c565b805190915015620003485780806020019051810190620003ca9190620005db565b620003485760405162461bcd60e51b8152600401620000d690620006a3565b6060620003fa848460008562000402565b949350505050565b60606200040f85620004d4565b6200042e5760405162461bcd60e51b8152600401620000d69062000775565b60006060866001600160a01b031685876040516200044d91906200061d565b60006040518083038185875af1925050503d80600081146200048c576040519150601f19603f3d011682016040523d82523d6000602084013e62000491565b606091505b50915091508115620004a7579150620003fa9050565b805115620004b85780518082602001fd5b8360405162461bcd60e51b8152600401620000d691906200066e565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590620003fa575050151592915050565b80516001600160a01b03811681146200052657600080fd5b92915050565b600080600080600080600080610100898b03121562000549578384fd5b620005558a8a6200050e565b9750620005668a60208b016200050e565b9650620005778a60408b016200050e565b9550620005888a60608b016200050e565b9450620005998a60808b016200050e565b9350620005aa8a60a08b016200050e565b9250620005bb8a60c08b016200050e565b9150620005cc8a60e08b016200050e565b90509295985092959890939650565b600060208284031215620005ed578081fd5b81518015158114620005fd578182fd5b9392505050565b60006020828403121562000616578081fd5b5051919050565b6000825162000631818460208701620007ac565b9190910192915050565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03929092168252602082015260400190565b60006020825282518060208401526200068f816040850160208701620007ac565b601f01601f19169190910160400192915050565b6020808252602a908201527f5361666542455032303a204245503230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b60208082526036908201527f5361666542455032303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000606082015260800190565b60208082526011908201527013dddb995c881b5d5cdd081899481cd95d607a1b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b60005b83811015620007c9578181015183820152602001620007af565b83811115620007d9576000848401525b50505050565b612c4080620007ef6000396000f3fe608060405234801561001057600080fd5b50600436106103775760003560e01c806380faa57d116101d3578063cc1a378f11610104578063e5328e06116100a2578063ebe2b12b1161007c578063ebe2b12b1461060f578063efa0880614610617578063f2fde38b1461062a578063f5eb42dc1461063d57610377565b8063e5328e06146105f7578063e8f431dd146105ff578063e9c9f44f1461060757610377565b8063d7e3433b116100de578063d7e3433b146105c1578063de320cc1146105d4578063de5f6268146105e7578063df136d65146105ef57610377565b8063cc1a378f1461059e578063cd3daf9d146105b1578063d1af0c7d146105b957610377565b806391b4ded911610171578063b69ef8a81161014b578063b69ef8a814610402578063b6b55f251461057b578063c81c5ed51461058e578063c8f33c911461059657610377565b806391b4ded914610556578063b1dd61b61461055e578063b388dbf31461057357610377565b8063853828b6116101ad578063853828b61461052b5780638b876347146105335780638da5cb5b146105465780638dd950021461054e57610377565b806380faa57d146105135780638322fff21461051b57806383beae2e1461052357610377565b80633c6b16ab116102ad5780635c975abb1161024b57806370a082311161022557806370a082311461045b578063715018a6146104fb57806372f702f3146105035780637b0a47ee1461050b57610377565b80635c975abb146104de5780635eaa8163146104f357806361e20a1c1461045b57610377565b80634641257d116102875780634641257d146104a857806354198ce9146104b057806354d39b34146104c35780635bea689e146104d657610377565b80633c6b16ab146104855780633d18b912146104985780633fc6df6e146104a057610377565b80631c1f78eb1161031a5780632e1a7d4d116102f45780632e1a7d4d14610440578063386a9525146104535780633aa6c4f91461045b5780633bcfc4b81461046e57610377565b80631c1f78eb1461041d578063208e5acc146104255780632421a9f21461043857610377565b80630aae7a6b116103565780630aae7a6b146103cd57806316c38b3c146103ed57806318160ddd14610402578063197621431461040a57610377565b80628cc2621461037c5780630700037d146103a557806307546172146103b8575b600080fd5b61038f61038a3660046123ed565b610650565b60405161039c9190612ae5565b60405180910390f35b61038f6103b33660046123ed565b6106ce565b6103c06106e0565b60405161039c9190612601565b6103e06103db3660046123ed565b6106e6565b60405161039c9190612a8e565b6104006103fb36600461251d565b61079a565b005b61038f61084e565b6104006104183660046123ed565b610854565b61038f6108ab565b61038f6104333660046123ed565b6108c9565b6103c06108e4565b61040061044e366004612555565b6108f3565b61038f610a5c565b61038f6104693660046123ed565b610a62565b610476610a7d565b60405161039c93929190612b5e565b610400610493366004612555565b610b80565b610400610d79565b6103c0610f08565b610400610f17565b6104766104be3660046123ed565b610f19565b6104006104d1366004612585565b610fbd565b610400610ffa565b6104e661129b565b60405161039c91906126ac565b61038f6112a4565b6104006112b0565b6103c061132f565b61038f61133e565b61038f611344565b6103c0611352565b6103c0611361565b610400611375565b61038f6105413660046123ed565b611399565b6103c06113ab565b6103c06113ba565b61038f6113c9565b6105666113cf565b60405161039c91906126b7565b6103c06113d4565b610400610589366004612555565b6113e3565b6103c06113ed565b61038f6113fc565b6104006105ac366004612555565b611402565b61038f611498565b6103c06114e0565b6104006105cf366004612425565b6114f4565b6104006105e23660046123ed565b611554565b6104006115ed565b61038f61166f565b61038f611675565b610400611706565b6103c061195b565b61038f61196a565b61040061062536600461245d565b611970565b6104006106383660046123ed565b611a4b565b61038f61064b3660046123ed565b611a89565b6001600160a01b03811660009081526011602090815260408083205460109092528220546106c891906106c290670de0b6b3a7640000906106bc9061069d90610697611498565b90611ba5565b6001600160a01b03881660009081526014602052604090205490611bee565b90611c28565b90611c6a565b92915050565b60116020526000908152604090205481565b60005b90565b6106ee61238b565b6106f661238b565b6001600160a01b038316600081815260146020818152604083205480865293909252815282015261072683610a62565b60408201526107336123cc565b600080600061074187610f19565b82875260208701829052604087018190526060880187905291945092509050610768611675565b60808601526107756123cc565b61077d610a7d565b9183526020830152604082015260a0860152509295945050505050565b6107a2611c8f565b6000546001600160a01b039081169116146107d85760405162461bcd60e51b81526004016107cf906128d3565b60405180910390fd5b60045460ff16151581151514156107ee5761084b565b6004805460ff1916821515179081905560ff161561080b57426003555b6004546040517f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec5916108429160ff909116906126ac565b60405180910390a15b50565b60135490565b61085c611c8f565b6000546001600160a01b039081169116146108895760405162461bcd60e51b81526004016107cf906128d3565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b60006108c4600a54600954611bee90919063ffffffff16565b905090565b6001600160a01b031660009081526012602052604090205490565b6005546001600160a01b031681565b6002805414156109155760405162461bcd60e51b81526004016107cf90612a57565b6002805533610922611498565b600c5561092d611344565b600b556001600160a01b038116156109745761094881610650565b6001600160a01b038216600090815260116020908152604080832093909355600c546010909152919020555b600082116109945760405162461bcd60e51b81526004016107cf9061281c565b61099d33610a62565b8211156109bc5760405162461bcd60e51b81526004016107cf9061292e565b6013546109c99083611ba5565b601355336000908152601460205260409020546109e69083611ba5565b33600081815260146020526040902091909155600554610a12916001600160a01b039091169084611c93565b336001600160a01b03167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d583604051610a4b9190612ae5565b60405180910390a250506001600255565b600a5481565b6001600160a01b031660009081526014602052604090205490565b60135460009081908190670de0b6b3a76400009080610a995750805b6000610ab4826106bc85600954611bee90919063ffffffff16565b60165460055460405163493457b560e11b81529293506000926001600160a01b0392831692639268af6a92610af892911690670de0b6b3a764000090600401612693565b604080518083038186803b158015610b0f57600080fd5b505afa158015610b23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b4791906125a9565b50600097508796509050610b75816106bc670de0b6b3a7640000610b6f866301e13380611bee565b90611bee565b945050505050909192565b6001546001600160a01b03163314610baa5760405162461bcd60e51b81526004016107cf906129e9565b6000610bb4611498565b600c55610bbf611344565b600b556001600160a01b03811615610c0657610bda81610650565b6001600160a01b038216600090815260116020908152604080832093909355600c546010909152919020555b6008544210610c2557600a54610c1d908390611c28565b600955610c68565b600854600090610c359042611ba5565b90506000610c4e60095483611bee90919063ffffffff16565b600a54909150610c62906106bc8684611c6a565b60095550505b600480546040516370a0823160e01b81526000926101009092046001600160a01b0316916370a0823191610c9e91309101612601565b60206040518083038186803b158015610cb657600080fd5b505afa158015610cca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cee919061256d565b9050610d05600a5482611c2890919063ffffffff16565b6009541115610d265760405162461bcd60e51b81526004016107cf906127c5565b42600b819055600a54610d399190611c6a565b6008556040517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d90610d6c908590612ae5565b60405180910390a1505050565b600280541415610d9b5760405162461bcd60e51b81526004016107cf90612a57565b6002805533610da8611498565b600c55610db3611344565b600b556001600160a01b03811615610dfa57610dce81610650565b6001600160a01b038216600090815260116020908152604080832093909355600c546010909152919020555b336000908152601160205260409020548015610eff5733600090815260116020526040812055610e2981611cb2565b9050610ec63382601760009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610e7e57600080fd5b505afa158015610e92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb69190612409565b6001600160a01b03169190611c93565b336001600160a01b03167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e048682604051610a4b9190612ae5565b50506001600255565b6001546001600160a01b031681565b565b601654600454600091829182916001600160a01b0390811691639268af6a9161010090910416610f4887610650565b6040518363ffffffff1660e01b8152600401610f65929190612693565b604080518083038186803b158015610f7c57600080fd5b505afa158015610f90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb491906125a9565b50929491935050565b3360009081526015602052604090205460ff16610fec5760405162461bcd60e51b81526004016107cf906129ab565b610ff68282611f61565b5050565b60028054141561101c5760405162461bcd60e51b81526004016107cf90612a57565b6002805533611029611498565b600c55611034611344565b600b556001600160a01b0381161561107b5761104f81610650565b6001600160a01b038216600090815260116020908152604080832093909355600c546010909152919020555b336000908152601160205260409020548015610eff57336000908152601160205260408120556110aa81611cb2565b604080516002808252606080830184529394509091602083019080368337505060075482519293506001600160a01b0316918391506000906110e857fe5b6001600160a01b039283166020918202929092010152600e5482519116908290600190811061111357fe5b6001600160a01b0392831660209182029290920101526017546040516338ed173960e01b81529116906338ed173990611159908590600090869030904290600401612aee565b600060405180830381600087803b15801561117357600080fd5b505af1158015611187573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111af9190810190612488565b50600e546040516370a0823160e01b81526001600160a01b03909116906370a08231906111e0903090600401612601565b60206040518083038186803b1580156111f857600080fd5b505afa15801561120c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611230919061256d565b9150811561129157600e5461124f906001600160a01b03163384611c93565b336001600160a01b03167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486836040516112889190612ae5565b60405180910390a25b5050506001600255565b60045460ff1681565b670de0b6b3a764000090565b6112b8611c8f565b6000546001600160a01b039081169116146112e55760405162461bcd60e51b81526004016107cf906128d3565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6005546001600160a01b031690565b60095481565b60006108c4426008546120de565b600f546001600160a01b031681565b60045461010090046001600160a01b031681565b600061138033610a62565b9050801561139157611391816108f3565b61084b610d79565b60106020526000908152604090205481565b6000546001600160a01b031690565b6007546001600160a01b031681565b60035481565b600081565b6006546001600160a01b031681565b61084b8133611f61565b600d546001600160a01b031681565b600b5481565b61140a611c8f565b6000546001600160a01b039081169116146114375760405162461bcd60e51b81526004016107cf906128d3565b6008541580611447575060085442115b6114635760405162461bcd60e51b81526004016107cf906129c9565b600a8190556040517ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d390610842908390612ae5565b6000601354600014156114ae5750600c546106e3565b6108c46114d76013546106bc670de0b6b3a7640000610b6f600954610b6f600b54610697611344565b600c5490611c6a565b60045461010090046001600160a01b031690565b6114fc611c8f565b6000546001600160a01b039081169116146115295760405162461bcd60e51b81526004016107cf906128d3565b6001600160a01b03919091166000908152601560205260409020805460ff1916911515919091179055565b61155c611c8f565b6000546001600160a01b039081169116146115895760405162461bcd60e51b81526004016107cf906128d3565b6001600160a01b0381166115af5760405162461bcd60e51b81526004016107cf906127e5565b60048054610100600160a81b0319166101006001600160a01b038481168202929092179283905560175461084b939190910482169116600019611a8f565b6005546040516370a0823160e01b8152610f17916001600160a01b0316906370a082319061161f903390600401612601565b60206040518083038186803b15801561163757600080fd5b505afa15801561164b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610589919061256d565b600c5481565b60165460055460135460405163493457b560e11b81526000936001600160a01b0390811693639268af6a936116b1939290911691600401612693565b604080518083038186803b1580156116c857600080fd5b505afa1580156116dc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170091906125a9565b50919050565b6002805414156117285760405162461bcd60e51b81526004016107cf90612a57565b6002805533611735611498565b600c55611740611344565b600b556001600160a01b038116156117875761175b81610650565b6001600160a01b038216600090815260116020908152604080832093909355600c546010909152919020555b336000908152601160205260409020548015610eff57336000908152601160205260408120556117b681611cb2565b604080516002808252606080830184529394509091602083019080368337505060075482519293506001600160a01b0316918391506000906117f457fe5b6001600160a01b039283166020918202929092010152600f5482519116908290600190811061181f57fe5b6001600160a01b0392831660209182029290920101526017546040516338ed173960e01b81529116906338ed173990611865908590600090869030904290600401612aee565b600060405180830381600087803b15801561187f57600080fd5b505af1158015611893573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118bb9190810190612488565b50600f546040516370a0823160e01b81526001600160a01b03909116906370a08231906118ec903090600401612601565b60206040518083038186803b15801561190457600080fd5b505afa158015611918573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061193c919061256d565b9150811561129157600f5461124f906001600160a01b03163384611c93565b600e546001600160a01b031681565b60085481565b611978611c8f565b6000546001600160a01b039081169116146119a55760405162461bcd60e51b81526004016107cf906128d3565b6005546001600160a01b038381169116148015906119d657506004546001600160a01b038381166101009092041614155b6119f25760405162461bcd60e51b81526004016107cf90612908565b611a0e6119fd6113ab565b6001600160a01b0384169083611c93565b7f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa288282604051611a3f929190612693565b60405180910390a15050565b611a53611c8f565b6000546001600160a01b03908116911614611a805760405162461bcd60e51b81526004016107cf906128d3565b61084b816120f4565b50600090565b801580611b175750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e90611ac59030908690600401612615565b60206040518083038186803b158015611add57600080fd5b505afa158015611af1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b15919061256d565b155b611b335760405162461bcd60e51b81526004016107cf9061287d565b611b898363095ea7b360e01b8484604051602401611b52929190612693565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612175565b505050565b6060611b9d8484600085612204565b949350505050565b6000611be783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506122c8565b9392505050565b600082611bfd575060006106c8565b82820282848281611c0a57fe5b0414611be75760405162461bcd60e51b81526004016107cf9061283c565b6000611be783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506122f4565b600082820183811015611be75760405162461bcd60e51b81526004016107cf9061278e565b3390565b611b898363a9059cbb60e01b8484604051602401611b52929190612693565b600080601760009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611d0357600080fd5b505afa158015611d17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3b9190612409565b601754600554604051635d5155ef60e11b81529293506000926001600160a01b039283169263baa2abde92611d8192911690869089908790819030904290600401612653565b6040805180830381600087803b158015611d9a57600080fd5b505af1158015611dae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dd291906125a9565b50604080516002808252606080830184529394509091602083019080368337505060055482519293506001600160a01b031691839150600090611e1157fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508281600181518110611e3f57fe5b6001600160a01b0392831660209182029290920101526017546040516338ed173960e01b81529116906338ed173990611e85908590600090869030904290600401612aee565b600060405180830381600087803b158015611e9f57600080fd5b505af1158015611eb3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611edb9190810190612488565b506040516370a0823160e01b81526001600160a01b038416906370a0823190611f08903090600401612601565b60206040518083038186803b158015611f2057600080fd5b505afa158015611f34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f58919061256d565b95945050505050565b600280541415611f835760405162461bcd60e51b81526004016107cf90612a57565b6002805560045460ff1615611faa5760405162461bcd60e51b81526004016107cf9061294e565b80611fb3611498565b600c55611fbe611344565b600b556001600160a01b0381161561200557611fd981610650565b6001600160a01b038216600090815260116020908152604080832093909355600c546010909152919020555b600083116120255760405162461bcd60e51b81526004016107cf9061281c565b6013546120329084611c6a565b6013556001600160a01b0382166000908152601460205260409020546120589084611c6a565b6001600160a01b038084166000908152601460209081526040808320949094556012905291909120429055600554612093911633308661232b565b816001600160a01b03167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d846040516120cc9190612ae5565b60405180910390a25050600160025550565b60008183106120ed5781611be7565b5090919050565b6001600160a01b03811661211a5760405162461bcd60e51b81526004016107cf90612748565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60606121ca826040518060400160405280602081526020017f5361666542455032303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611b8e9092919063ffffffff16565b805190915015611b8957808060200190518101906121e89190612539565b611b895760405162461bcd60e51b81526004016107cf906126fe565b606061220f85612352565b61222b5760405162461bcd60e51b81526004016107cf90612a20565b60006060866001600160a01b0316858760405161224891906125e5565b60006040518083038185875af1925050503d8060008114612285576040519150601f19603f3d011682016040523d82523d6000602084013e61228a565b606091505b5091509150811561229e579150611b9d9050565b8051156122ae5780518082602001fd5b8360405162461bcd60e51b81526004016107cf91906126cb565b600081848411156122ec5760405162461bcd60e51b81526004016107cf91906126cb565b505050900390565b600081836123155760405162461bcd60e51b81526004016107cf91906126cb565b50600083858161232157fe5b0495945050505050565b61234c846323b872dd60e01b858585604051602401611b529392919061262f565b50505050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590611b9d575050151592915050565b6040518060c001604052806000815260200160008152602001600081526020016123b36123cc565b8152602001600081526020016123c76123cc565b905290565b60405180606001604052806000815260200160008152602001600081525090565b6000602082840312156123fe578081fd5b8135611be781612be7565b60006020828403121561241a578081fd5b8151611be781612be7565b60008060408385031215612437578081fd5b823561244281612be7565b9150602083013561245281612bfc565b809150509250929050565b6000806040838503121561246f578182fd5b823561247a81612be7565b946020939093013593505050565b6000602080838503121561249a578182fd5b825167ffffffffffffffff8111156124b0578283fd5b8301601f810185136124c0578283fd5b80516124d36124ce82612b9b565b612b74565b81815283810190838501858402850186018910156124ef578687fd5b8694505b838510156125115780518352600194909401939185019185016124f3565b50979650505050505050565b60006020828403121561252e578081fd5b8135611be781612bfc565b60006020828403121561254a578081fd5b8151611be781612bfc565b600060208284031215612566578081fd5b5035919050565b60006020828403121561257e578081fd5b5051919050565b60008060408385031215612597578182fd5b82359150602083013561245281612be7565b600080604083850312156125bb578182fd5b505080516020909101519092909150565b8051825260208082015190830152604090810151910152565b600082516125f7818460208701612bbb565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b039788168152958716602087015260408601949094526060850192909252608084015290921660a082015260c081019190915260e00190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b60208101600783106126c557fe5b91905290565b60006020825282518060208401526126ea816040850160208701612bbb565b601f01601f19169190910160400192915050565b6020808252602a908201527f5361666542455032303a204245503230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252600690820152651c995dd85c9960d21b604082015260600190565b60208082526019908201527f736574207265776172647320746f6b656e20616c726561647900000000000000604082015260600190565b602080825260069082015265185b5bdd5b9d60d21b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60208082526036908201527f5361666542455032303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600c908201526b746f6b656e4164647265737360a01b604082015260600190565b6020808252600690820152651b1bd8dad95960d21b604082015260600190565b6020808252603c908201527f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060408201527f7768696c652074686520636f6e74726163742069732070617573656400000000606082015260800190565b6020808252600490820152630c2eae8d60e31b604082015260600190565b6020808252600690820152651c195c9a5bd960d21b604082015260600190565b60208082526017908201527f6f6e6c7952657761726473446973747269627574696f6e000000000000000000604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6000610140820190508251825260208301516020830152604083015160408301526060830151612ac160608401826125cc565b50608083015160c083015260a0830151612ade60e08401826125cc565b5092915050565b90815260200190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b81811015612b3d5784516001600160a01b031683529383019391830191600101612b18565b50506001600160a01b03969096166060850152505050608001529392505050565b9283526020830191909152604082015260600190565b60405181810167ffffffffffffffff81118282101715612b9357600080fd5b604052919050565b600067ffffffffffffffff821115612bb1578081fd5b5060209081020190565b60005b83811015612bd6578181015183820152602001612bbe565b8381111561234c5750506000910152565b6001600160a01b038116811461084b57600080fd5b801515811461084b57600080fdfea2646970667358221220daafc73b5bea3aed6ce72bf39acd6de2f74c1551b8c463f652a900185b93616164736f6c634300060c0033000000000000000000000000da360309c59cb8c434b28a91b823344a9644427800000000000000000000000010ed43c718714eb63d5aa57b78b54704e256024e000000000000000000000000cbc54fec7a8bcf2e391a93a2abe02f35f70520880000000000000000000000005f66f543b20a4bd4195521c14e9ae77ed7111c98000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00000000000000000000000091348e07f37ce11544c0ff50048870d7a23a51d60000000000000000000000007130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c0000000000000000000000002170ed0880ac9a755fd29b2688956bd959f933f8

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

000000000000000000000000da360309c59cb8c434b28a91b823344a9644427800000000000000000000000010ed43c718714eb63d5aa57b78b54704e256024e000000000000000000000000cbc54fec7a8bcf2e391a93a2abe02f35f70520880000000000000000000000005f66f543b20a4bd4195521c14e9ae77ed7111c98000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00000000000000000000000091348e07f37ce11544c0ff50048870d7a23a51d60000000000000000000000007130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c0000000000000000000000002170ed0880ac9a755fd29b2688956bd959f933f8

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 000000000000000000000000da360309c59cb8c434b28a91b823344a96444278
Arg [1] : 00000000000000000000000010ed43c718714eb63d5aa57b78b54704e256024e
Arg [2] : 000000000000000000000000cbc54fec7a8bcf2e391a93a2abe02f35f7052088
Arg [3] : 0000000000000000000000005f66f543b20a4bd4195521c14e9ae77ed7111c98
Arg [4] : 000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c
Arg [5] : 00000000000000000000000091348e07f37ce11544c0ff50048870d7a23a51d6
Arg [6] : 0000000000000000000000007130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c
Arg [7] : 0000000000000000000000002170ed0880ac9a755fd29b2688956bd959f933f8


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.