FTM Price: $0.98 (-4.17%)
Gas: 207 GWei

Contract

0x0bf946c05Eee229949499CDAF7968e88266e6b3C
 

Overview

FTM Balance

Fantom LogoFantom LogoFantom Logo0 FTM

FTM Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
Lock545794412023-01-28 4:46:19426 days ago1674881179IN
0x0bf946c0...8266e6b3C
0 FTM0.0025567249
0x60c06040545743752023-01-28 2:50:23426 days ago1674874223IN
 Create: RaveLPLock
0 FTM0.2200307455

Latest 1 internal transaction

Parent Txn Hash Block From To Value
545743752023-01-28 2:50:23426 days ago1674874223  Contract Creation0 FTM
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RaveLPLock

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 10000 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 16 : lplocker.sol
pragma solidity >= 0.8.10;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/Base64.sol";
import { BeefyVaultV6 as Vault } from "./Autocompounder/Vault.sol";

interface Router {
  function removeLiquidity(
        address tokenA,
        address tokenB,
        bool stable,
        uint256 liquidity,
        uint256 amountAMin,
        uint256 amountBMin,
        address to,
        uint256 deadline
    ) external returns (uint256 amountA, uint256 amountB);
}

interface Pair {
    event Approval(
        address indexed owner,
        address indexed spender,
        uint256 amount
    );
    event Burn(
        address indexed sender,
        uint256 amount0,
        uint256 amount1,
        address indexed to
    );
    event Claim(
        address indexed sender,
        address indexed recipient,
        uint256 amount0,
        uint256 amount1
    );
    event Fees(address indexed sender, uint256 amount0, uint256 amount1);
    event Initialized(uint8 version);
    event Mint(address indexed sender, uint256 amount0, uint256 amount1);
    event Swap(
        address indexed sender,
        uint256 amount0In,
        uint256 amount1In,
        uint256 amount0Out,
        uint256 amount1Out,
        address indexed to
    );
    event Sync(uint256 reserve0, uint256 reserve1);
    event Transfer(address indexed from, address indexed to, uint256 amount);

    function allowance(address, address) external view returns (uint256);

    function approve(address spender, uint256 amount) external returns (bool);

    function balanceOf(address) external view returns (uint256);

    function blockTimestampLast() external view returns (uint256);

    function burn(address to)
        external
        returns (uint256 amount0, uint256 amount1);

    function claimFees() external returns (uint256 claimed0, uint256 claimed1);

    function claimable0(address) external view returns (uint256);

    function claimable1(address) external view returns (uint256);

    function current(address tokenIn, uint256 amountIn)
        external
        view
        returns (uint256 amountOut);

    function currentCumulativePrices()
        external
        view
        returns (
            uint256 reserve0Cumulative,
            uint256 reserve1Cumulative,
            uint256 blockTimestamp
        );

    function decimals() external view returns (uint8);

    function factory() external view returns (address);

    function fees() external view returns (address);

    function getAmountOut(uint256 amountIn, address tokenIn)
        external
        view
        returns (uint256);

    function getReserves()
        external
        view
        returns (
            uint256 _reserve0,
            uint256 _reserve1,
            uint256 _blockTimestampLast
        );

    function index0() external view returns (uint256);

    function index1() external view returns (uint256);

    function initialize() external;

    function metadata()
        external
        view
        returns (
            uint256 dec0,
            uint256 dec1,
            uint256 r0,
            uint256 r1,
            bool st,
            address t0,
            address t1
        );

    function mint(address to) external returns (uint256 liquidity);

    function name() external view returns (string memory);

    function nonces(address) external view returns (uint256);

    function observationLength() external view returns (uint256);

    function observations(uint256)
        external
        view
        returns (
            uint256 timestamp,
            uint256 reserve0Cumulative,
            uint256 reserve1Cumulative
        );

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

    function prices(
        address tokenIn,
        uint256 amountIn,
        uint256 points
    ) external view returns (uint256[] memory);

    function quote(
        address tokenIn,
        uint256 amountIn,
        uint256 granularity
    ) external view returns (uint256 amountOut);

    function reserve0() external view returns (uint256);

    function reserve0CumulativeLast() external view returns (uint256);

    function reserve1() external view returns (uint256);

    function reserve1CumulativeLast() external view returns (uint256);

    function sample(
        address tokenIn,
        uint256 amountIn,
        uint256 points,
        uint256 window
    ) external view returns (uint256[] memory);

    function skim(address to) external;

    function stable() external view returns (bool);

    function supplyIndex0(address) external view returns (uint256);

    function supplyIndex1(address) external view returns (uint256);

    function swap(
        uint256 amount0Out,
        uint256 amount1Out,
        address to,
        bytes memory data
    ) external;

    function symbol() external view returns (string memory);

    function sync() external;

    function token0() external view returns (address);

    function token1() external view returns (address);

    function tokens() external view returns (address, address);

    function totalSupply() external view returns (uint256);

    function transfer(address dst, uint256 amount) external returns (bool);

    function transferFrom(
        address src,
        address dst,
        uint256 amount
    ) external returns (bool);
}


contract RaveLPLock is ERC721Enumerable {
    uint256 constant private YEAR = 52 weeks;
    mapping(uint256 => Lock) locks;
    mapping(uint256 => bool) claimed;
    uint256 constant MAX_LOCK = YEAR/2;
    Pair immutable lp;
    Vault immutable vault;
    uint256 amountLeft = 100_000 * 10**18;
    uint256 constant reward = 125; // x/1000
    IERC20 constant RAVE = IERC20(0x88888a335b1F65a79Ec56A610D865b8b25B6060B);
    Router constant router = Router(0x1A05EB736873485655F29a37DEf8a0AA87F5a447);
    bool migration = false;

    constructor(
      address _lp,
      address _vault
    ) ERC721("Locked RAVE-FTM LP", "lRAVE") {
      lp = Pair(_lp);
      vault = Vault(_vault);
    }

    struct Lock {
        address creator;
        uint amount;
        uint rave;
        uint unlock;
        uint time;
        bool active;
        uint amountLeftAtTime;
    }

    function calculateAllocatedRAVE(uint256 lpAmount, uint256 time) public view returns(uint256 raveAtTime) {
        uint totalLPSupply = lp.totalSupply();
        (,uint _reserve0,) = lp.getReserves();
        uint valueOfLP /* value of 1 LP token in RAVE */ = (_reserve0 * 2)/totalLPSupply;
        uint valueOfAmount = lpAmount * valueOfLP;
        uint raveAtMaxTime = valueOfAmount * (reward/1000);
        raveAtTime = raveAtMaxTime * (time/MAX_LOCK);
    }

    function getValueOfLPInRAVE(uint lpAmount) public view returns(uint256 valueOfLP) {
      uint totalLPSupply = lp.totalSupply();
      (,uint _reserve0,) = lp.getReserves();
      valueOfLP = ((_reserve0 * 2)/totalLPSupply)*lpAmount;
    }

    function lock(uint256 amount, uint256 time) external payable {
        uint allocatedRAVE = calculateAllocatedRAVE(amount, time);
        require(allocatedRAVE < amountLeft, "The program has ended, or you are locking too much RAVE/FTM.");
        require(time >= (YEAR/12), "You must lock for at least 1 month");
        lp.transferFrom(msg.sender, address(this), amount);
        uint256 shares = vault.deposit(amount);
        amountLeft = amountLeft - allocatedRAVE;
        uint tokenId = uint256(uint160(msg.sender)) + block.timestamp;
        locks[tokenId] = Lock(msg.sender, shares, allocatedRAVE, block.timestamp + time, time, true, amountLeft);
        _mint(msg.sender, tokenId);
    }

    function unlock(uint256 tokenId) external payable {
        Lock memory _lock = locks[tokenId];
        require(block.timestamp >= _lock.unlock, "Token still locked");
        require(msg.sender == ownerOf(tokenId), "Not the owner of the lock");
        require(_lock.active, "Lock has been closed");
        _burn(tokenId);
        vault.withdraw(_lock.amount);
        RAVE.transferFrom(address(this), ownerOf(tokenId), _lock.rave);
        lp.transferFrom(address(this), ownerOf(tokenId), _lock.amount * vault.getPricePerFullShare());
        locks[tokenId].active = false;
    }

    function unlockEarly(uint256 tokenId) external payable {
        Lock memory _lock = locks[tokenId];
        require(block.timestamp < _lock.unlock, "Token unlocked");
        require(msg.sender == ownerOf(tokenId), "Not the owner of the lock");
        require(_lock.active, "Lock has been closed");
        uint lockStart = _lock.unlock - _lock.time;
        uint timeLocked = block.timestamp - lockStart;
        uint mod = (migration) ? (1) : (timeLocked/MAX_LOCK);
        uint amount =  _lock.amount * vault.getPricePerFullShare();
        vault.withdraw(_lock.amount);
        RAVE.transferFrom(address(this), ownerOf(tokenId), _lock.rave * mod);
        lp.transferFrom(address(this), ownerOf(tokenId), _lock.amount * mod);
        router.removeLiquidity(lp.token0(), lp.token1(), lp.stable(), amount - (amount * mod), 0, 0, address(this), block.timestamp);
        uint raveToSend = (getValueOfLPInRAVE(amount - (amount * mod))/2) + (_lock.rave - _lock.rave * mod);
        RAVE.transferFrom(address(this), 0x87f385d152944689f92Ed523e9e5E9Bd58Ea62ef, (_lock.rave - (_lock.rave * mod)) + raveToSend);
        locks[tokenId].active = false;
    }

    function claimRewards(uint256 tokenId) external payable {
      Lock memory _lock = locks[tokenId];
      require(block.timestamp < _lock.unlock, "Token unlocked");
      require(msg.sender == ownerOf(tokenId), "Not the owner of the lock");
      require(!claimed[tokenId], "Already claimed for this tokenId");
      uint percentOfMax = _lock.rave/_lock.amountLeftAtTime;
      uint ftmAllocated = percentOfMax*address(this).balance;
      claimed[tokenId] = true;
      payable(msg.sender).transfer(ftmAllocated);
    }

    function checkPenalty(uint256 tokenId) public view returns(uint256) {
      Lock memory _lock = locks[tokenId];
      uint lockStart = _lock.unlock - _lock.time;
      uint timeLocked = block.timestamp - lockStart;
      uint mod = (migration) ? (1) : (timeLocked/MAX_LOCK);
      return 1 - mod;
    }

    function checkRewards(uint256 tokenId) public view returns(uint256) {
      Lock memory _lock = locks[tokenId];
      uint percentOfMax = _lock.rave/_lock.amountLeftAtTime;
      uint ftmAllocated = percentOfMax*address(this).balance;
      return (claimed[tokenId]) ? 0 : ftmAllocated;
    }

    // a multicall-type view so we only need to call this once/tokenId
    // we could do this in the frontend, but its just so much easier this way
    function checkDetails(uint256 tokenId) external view returns(Lock memory, bool, uint256, uint256) {
      return (locks[tokenId], claimed[tokenId], checkPenalty(tokenId), checkRewards(tokenId));
    }

    function startMigration() external {
        require(msg.sender == 0x3e522051A9B1958Aa1e828AC24Afba4a551DF37d, "LPLocker: Not owner");
        migration = true;
        RAVE.transferFrom(address(this), msg.sender, amountLeft);
    }

    function tokenURI(uint256 tokenId) override(ERC721) public view returns (string memory output) {
        output = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet" viewBox="0 0 350 350"><style>.base { fill: white; font-family: Veranda, serif; font-size: 14px; }</style><rect width="100%" height="100%" fill="black" /><text x="10" y="20" class="base">';
        output = string(abi.encodePacked(output, "Token ID", Strings.toString(tokenId), '</text><text x="10" y="40" class="base">'));
        output = string(abi.encodePacked(output, "Locked LP (18 decimals)", Strings.toString(locks[tokenId].amount), '</text><text x="10" y="60" class="base">'));
        output = string(abi.encodePacked(output, "End Time ", Strings.toString(locks[tokenId].unlock), '</text><text x="10" y="80" class="base">'));
        output = string(abi.encodePacked(output, "FTM Rewards (18 decimals)", Strings.toString(checkRewards(tokenId)), '</text><text x="10" y="80" class="base">'));
        output = string(abi.encodePacked(output, "RAVE to be rewarded (18 decimals)", Strings.toString(locks[tokenId].rave), '</text></svg>'));


        string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "Rave Lock #', Strings.toString(tokenId), '", "description": "RAVE-FTM LP locks earn RAVE and autocompound Equalizer farm rewards.", "image": "data:image/svg+xml;base64,', Base64.encode(bytes(output)), '"}'))));
        output = string(abi.encodePacked('data:application/json;base64,', json));
    }

    function recoverLostTokens(address token) external {
        require(msg.sender == 0x87f385d152944689f92Ed523e9e5E9Bd58Ea62ef);
        IERC20(token).transferFrom(address(this), 0x87f385d152944689f92Ed523e9e5E9Bd58Ea62ef, IERC20(token).balanceOf(address(this)));
    }
}

File 2 of 16 : Vault.sol
/**
 *Submitted for verification at FtmScan.com on 2022-08-26
*/

// SPDX-License-Identifier: MIT
// File: @openzeppelin/contracts/utils/Context.sol


pragma solidity >=0.6.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.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address payable) {
        return payable(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;
    }
}

// File: @openzeppelin/contracts/token/ERC20/IERC20.sol


pragma solidity >=0.6.0 ;

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

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

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

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

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

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

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

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

// File: @openzeppelin/contracts/math/SafeMath.sol


pragma solidity >=0.6.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, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, 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 (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @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) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @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) {
        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, reverting 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) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting 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) {
        require(b > 0, "SafeMath: modulo by zero");
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * 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);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * 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);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * 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;
    }
}

// File: @openzeppelin/contracts/token/ERC20/ERC20.sol


pragma solidity >=0.6.0 ;



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

    mapping (address => uint256) private _balances;

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

    uint256 private _totalSupply;

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

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

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

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
     * called.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return _decimals;
    }

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

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

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

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

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

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

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

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

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

        _beforeTokenTransfer(sender, recipient, amount);

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

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

        _beforeTokenTransfer(address(0), account, amount);

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

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

        _beforeTokenTransfer(account, address(0), amount);

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

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

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

    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal virtual {
        _decimals = decimals_;
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}

// File: @openzeppelin/contracts/utils/Address.sol


pragma solidity >=0.6.2 ;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // 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);
    }

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(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: @openzeppelin/contracts/token/ERC20/SafeERC20.sol


pragma solidity >=0.6.0 ;



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

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

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

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

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

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: 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(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

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

// File: @openzeppelin/contracts/access/Ownable.sol


pragma solidity >=0.6.0 ;

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        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;
    }
}

// File: @openzeppelin/contracts/utils/ReentrancyGuard.sol


pragma solidity >=0.6.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: contracts/BIFI/interfaces/beefy/IStrategy.sol


pragma solidity >=0.6.0 <0.9.0;

interface IStrategy {
    function vault() external view returns (address);
    function want() external view returns (IERC20);
    function beforeDeposit() external;
    function deposit() external;
    function withdraw(uint256) external;
    function balanceOf() external view returns (uint256);
    function balanceOfWant() external view returns (uint256);
    function balanceOfPool() external view returns (uint256);
    function harvest() external;
    function retireStrat() external;
    function panic() external;
    function pause() external;
    function unpause() external;
    function paused() external view returns (bool);
    function unirouter() external view returns (address);
}

// File: contracts/BIFI/vaults/BeefyVaultV6.sol


pragma solidity >=0.6.0;





/**
 * @dev Implementation of a vault to deposit funds for yield optimizing.
 * This is the contract that receives funds and that users interface with.
 * The yield optimizing strategy itself is implemented in a separate 'Strategy.sol' contract.
 */
contract BeefyVaultV6 is ERC20, Ownable, ReentrancyGuard {
    using SafeERC20 for IERC20;
    using SafeMath for uint256;

    struct StratCandidate {
        address implementation;
        uint proposedTime;
    }

    // The last proposed strategy to switch to.
    StratCandidate public stratCandidate;
    // The strategy currently in use by the vault.
    IStrategy public strategy;
    // The minimum time it has to pass before a strat candidate can be approved.
    uint256 public immutable approvalDelay;

    event NewStratCandidate(address implementation);
    event UpgradeStrat(address implementation);

    /**
     * @dev Sets the value of {token} to the token that the vault will
     * hold as underlying value. It initializes the vault's own 'moo' token.
     * This token is minted when someone does a deposit. It is burned in order
     * to withdraw the corresponding portion of the underlying assets.
     * @param _strategy the address of the strategy.
     * @param _name the name of the vault token.
     * @param _symbol the symbol of the vault token.
     * @param _approvalDelay the delay before a new strat can be approved.
     */
    constructor (
        IStrategy _strategy,
        string memory _name,
        string memory _symbol,
        uint256 _approvalDelay
    ) public ERC20(
        _name,
        _symbol
    ) {
        strategy = _strategy;
        approvalDelay = _approvalDelay;
    }

    function want() public view returns (IERC20) {
        return IERC20(strategy.want());
    }

    /**
     * @dev It calculates the total underlying value of {token} held by the system.
     * It takes into account the vault contract balance, the strategy contract balance
     *  and the balance deployed in other contracts as part of the strategy.
     */
    function balance() public view returns (uint) {
        return want().balanceOf(address(this)).add(IStrategy(strategy).balanceOf());
    }

    /**
     * @dev Custom logic in here for how much the vault allows to be borrowed.
     * We return 100% of tokens for now. Under certain conditions we might
     * want to keep some of the system funds at hand in the vault, instead
     * of putting them to work.
     */
    function available() public view returns (uint256) {
        return want().balanceOf(address(this));
    }

    /**
     * @dev Function for various UIs to display the current value of one of our yield tokens.
     * Returns an uint256 with 18 decimals of how much underlying asset one vault share represents.
     */
    function getPricePerFullShare() public view returns (uint256) {
        return totalSupply() == 0 ? 1e18 : balance().mul(1e18).div(totalSupply());
    }

    /**
     * @dev A helper function to call deposit() with all the sender's funds.
     */
    function depositAll() external {
        deposit(want().balanceOf(msg.sender));
    }

    /**
     * @dev The entrypoint of funds into the system. People deposit with this function
     * into the vault. The vault is then in charge of sending funds into the strategy.
     */
    function deposit(uint _amount) public nonReentrant returns(uint256) {
        strategy.beforeDeposit();

        uint256 _pool = balance();
        want().safeTransferFrom(msg.sender, address(this), _amount);
        earn();
        uint256 _after = balance();
        _amount = _after.sub(_pool); // Additional check for deflationary tokens
        uint256 shares = 0;
        if (totalSupply() == 0) {
            shares = _amount;
        } else {
            shares = (_amount.mul(totalSupply())).div(_pool);
        }
        _mint(msg.sender, shares);
        return shares;
    }

    /**
     * @dev Function to send funds into the strategy and put them to work. It's primarily called
     * by the vault's deposit() function.
     */
    function earn() public {
        uint _bal = available();
        want().safeTransfer(address(strategy), _bal);
        strategy.deposit();
    }

    /**
     * @dev A helper function to call withdraw() with all the sender's funds.
     */
    function withdrawAll() external {
        withdraw(balanceOf(msg.sender));
    }

    /**
     * @dev Function to exit the system. The vault will withdraw the required tokens
     * from the strategy and pay up the token holder. A proportional number of IOU
     * tokens are burned in the process.
     */
    function withdraw(uint256 _shares) public {
        uint256 r = (balance().mul(_shares)).div(totalSupply());
        _burn(msg.sender, _shares);

        uint b = want().balanceOf(address(this));
        if (b < r) {
            uint _withdraw = r.sub(b);
            strategy.withdraw(_withdraw);
            uint _after = want().balanceOf(address(this));
            uint _diff = _after.sub(b);
            if (_diff < _withdraw) {
                r = b.add(_diff);
            }
        }

        want().safeTransfer(msg.sender, r);
    }

    /** 
     * @dev Sets the candidate for the new strat to use with this vault.
     * @param _implementation The address of the candidate strategy.  
     */
    function proposeStrat(address _implementation) public onlyOwner {
        require(address(this) == IStrategy(_implementation).vault(), "Proposal not valid for this Vault");
        stratCandidate = StratCandidate({
            implementation: _implementation,
            proposedTime: block.timestamp
         });

        emit NewStratCandidate(_implementation);
    }

    /** 
     * @dev It switches the active strat for the strat candidate. After upgrading, the 
     * candidate implementation is set to the 0x00 address, and proposedTime to a time 
     * happening in +100 years for safety. 
     */

    function upgradeStrat() public onlyOwner {
        require(stratCandidate.implementation != address(0), "There is no candidate");
        require(stratCandidate.proposedTime.add(approvalDelay) < block.timestamp, "Delay has not passed");

        emit UpgradeStrat(stratCandidate.implementation);

        strategy.retireStrat();
        strategy = IStrategy(stratCandidate.implementation);
        stratCandidate.implementation = address(0);
        stratCandidate.proposedTime = 5000000000;

        earn();
    }

    /**
     * @dev Rescues random funds stuck that the strat can't handle.
     * @param _token address of the token to rescue.
     */
    function inCaseTokensGetStuck(address _token) external onlyOwner {
        require(_token != address(want()), "!token");

        uint256 amount = IERC20(_token).balanceOf(address(this));
        IERC20(_token).safeTransfer(msg.sender, amount);
    }
}

File 3 of 16 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

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

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

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

File 4 of 16 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 5 of 16 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 6 of 16 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

File 7 of 16 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

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

File 8 of 16 : Base64.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides a set of functions to operate with Base64 strings.
 *
 * _Available since v4.5._
 */
library Base64 {
    /**
     * @dev Base64 Encoding/Decoding Table
     */
    string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

    /**
     * @dev Converts a `bytes` to its Bytes64 `string` representation.
     */
    function encode(bytes memory data) internal pure returns (string memory) {
        /**
         * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence
         * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol
         */
        if (data.length == 0) return "";

        // Loads the table into memory
        string memory table = _TABLE;

        // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter
        // and split into 4 numbers of 6 bits.
        // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up
        // - `data.length + 2`  -> Round up
        // - `/ 3`              -> Number of 3-bytes chunks
        // - `4 *`              -> 4 characters for each chunk
        string memory result = new string(4 * ((data.length + 2) / 3));

        /// @solidity memory-safe-assembly
        assembly {
            // Prepare the lookup table (skip the first "length" byte)
            let tablePtr := add(table, 1)

            // Prepare result pointer, jump over length
            let resultPtr := add(result, 32)

            // Run over the input, 3 bytes at a time
            for {
                let dataPtr := data
                let endPtr := add(data, mload(data))
            } lt(dataPtr, endPtr) {

            } {
                // Advance 3 bytes
                dataPtr := add(dataPtr, 3)
                let input := mload(dataPtr)

                // To write each character, shift the 3 bytes (18 bits) chunk
                // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)
                // and apply logical AND with 0x3F which is the number of
                // the previous character in the ASCII table prior to the Base64 Table
                // The result is then added to the table to get the character to write,
                // and finally write it in the result pointer but with a left shift
                // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits

                mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance
            }

            // When data `bytes` is not exactly 3 bytes long
            // it is padded with `=` characters at the end
            switch mod(mload(data), 3)
            case 1 {
                mstore8(sub(resultPtr, 1), 0x3d)
                mstore8(sub(resultPtr, 2), 0x3d)
            }
            case 2 {
                mstore8(sub(resultPtr, 1), 0x3d)
            }
        }

        return result;
    }
}

File 9 of 16 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 10 of 16 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 11 of 16 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 12 of 16 : ERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "./IERC721Enumerable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
        return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _allTokens.length;
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }

    /**
     * @dev See {ERC721-_beforeTokenTransfer}.
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 firstTokenId,
        uint256 batchSize
    ) internal virtual override {
        super._beforeTokenTransfer(from, to, firstTokenId, batchSize);

        if (batchSize > 1) {
            // Will only trigger during construction. Batch transferring (minting) is not available afterwards.
            revert("ERC721Enumerable: consecutive transfers not supported");
        }

        uint256 tokenId = firstTokenId;

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}

File 13 of 16 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 14 of 16 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 15 of 16 : ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return
            interfaceId == type(IERC721).interfaceId ||
            interfaceId == type(IERC721Metadata).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: address zero is not a valid owner");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _ownerOf(tokenId);
        require(owner != address(0), "ERC721: invalid token ID");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        _requireMinted(tokenId);

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overridden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not token owner or approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        _requireMinted(tokenId);

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
        _safeTransfer(from, to, tokenId, data);
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
     */
    function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
        return _owners[tokenId];
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _ownerOf(tokenId) != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        address owner = ERC721.ownerOf(tokenId);
        return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId, 1);

        // Check that tokenId was not minted by `_beforeTokenTransfer` hook
        require(!_exists(tokenId), "ERC721: token already minted");

        unchecked {
            // Will not overflow unless all 2**256 token ids are minted to the same owner.
            // Given that tokens are minted one by one, it is impossible in practice that
            // this ever happens. Might change if we allow batch minting.
            // The ERC fails to describe this case.
            _balances[to] += 1;
        }

        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);

        _afterTokenTransfer(address(0), to, tokenId, 1);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     * This is an internal function that does not check if the sender is authorized to operate on the token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId, 1);

        // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook
        owner = ERC721.ownerOf(tokenId);

        // Clear approvals
        delete _tokenApprovals[tokenId];

        unchecked {
            // Cannot overflow, as that would require more tokens to be burned/transferred
            // out than the owner initially received through minting and transferring in.
            _balances[owner] -= 1;
        }
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);

        _afterTokenTransfer(owner, address(0), tokenId, 1);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId, 1);

        // Check that tokenId was not transferred by `_beforeTokenTransfer` hook
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");

        // Clear approvals from the previous owner
        delete _tokenApprovals[tokenId];

        unchecked {
            // `_balances[from]` cannot overflow for the same reason as described in `_burn`:
            // `from`'s balance is the number of token held, which is at least one before the current
            // transfer.
            // `_balances[to]` could overflow in the conditions described in `_mint`. That would require
            // all 2**256 token ids to be minted, which in practice is impossible.
            _balances[from] -= 1;
            _balances[to] += 1;
        }
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId, 1);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits an {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Reverts if the `tokenId` has not been minted yet.
     */
    function _requireMinted(uint256 tokenId) internal view virtual {
        require(_exists(tokenId), "ERC721: invalid token ID");
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
                return retval == IERC721Receiver.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is
     * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.
     * - When `from` is zero, the tokens will be minted for `to`.
     * - When `to` is zero, ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     * - `batchSize` is non-zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256, /* firstTokenId */
        uint256 batchSize
    ) internal virtual {
        if (batchSize > 1) {
            if (from != address(0)) {
                _balances[from] -= batchSize;
            }
            if (to != address(0)) {
                _balances[to] += batchSize;
            }
        }
    }

    /**
     * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is
     * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.
     * - When `from` is zero, the tokens were minted for `to`.
     * - When `to` is zero, ``from``'s tokens were burned.
     * - `from` and `to` are never both zero.
     * - `batchSize` is non-zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 firstTokenId,
        uint256 batchSize
    ) internal virtual {}
}

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

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

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

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

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

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

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

Settings
{
  "remappings": [],
  "optimizer": {
    "enabled": true,
    "runs": 10000
  },
  "evmVersion": "london",
  "libraries": {},
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_lp","type":"address"},{"internalType":"address","name":"_vault","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"lpAmount","type":"uint256"},{"internalType":"uint256","name":"time","type":"uint256"}],"name":"calculateAllocatedRAVE","outputs":[{"internalType":"uint256","name":"raveAtTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"checkDetails","outputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"rave","type":"uint256"},{"internalType":"uint256","name":"unlock","type":"uint256"},{"internalType":"uint256","name":"time","type":"uint256"},{"internalType":"bool","name":"active","type":"bool"},{"internalType":"uint256","name":"amountLeftAtTime","type":"uint256"}],"internalType":"struct RaveLPLock.Lock","name":"","type":"tuple"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"checkPenalty","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"checkRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"claimRewards","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"lpAmount","type":"uint256"}],"name":"getValueOfLPInRAVE","outputs":[{"internalType":"uint256","name":"valueOfLP","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"time","type":"uint256"}],"name":"lock","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"recoverLostTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startMigration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"output","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"unlock","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"unlockEarly","outputs":[],"stateMutability":"payable","type":"function"}]

60c060405269152d02c7e14af6800000600c55600d805460ff191690553480156200002957600080fd5b5060405162004601380380620046018339810160408190526200004c91620000ed565b6040518060400160405280601281526020017104c6f636b656420524156452d46544d204c560741b815250604051806040016040528060058152602001646c5241564560d81b8152508160009081620000a69190620001ca565b506001620000b58282620001ca565b5050506001600160a01b039182166080521660a05262000296565b80516001600160a01b0381168114620000e857600080fd5b919050565b600080604083850312156200010157600080fd5b6200010c83620000d0565b91506200011c60208401620000d0565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200015057607f821691505b6020821081036200017157634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620001c557600081815260208120601f850160051c81016020861015620001a05750805b601f850160051c820191505b81811015620001c157828155600101620001ac565b5050505b505050565b81516001600160401b03811115620001e657620001e662000125565b620001fe81620001f784546200013b565b8462000177565b602080601f8311600181146200023657600084156200021d5750858301515b600019600386901b1c1916600185901b178555620001c1565b600085815260208120601f198616915b82811015620002675788860151825594840194600190910190840162000246565b5085821015620002865787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a0516142ea6200031760003960008181610c130152818161132a0152818161148c0152818161189a0152611961015260008181610b6b0152818161145301528181611a9a01528181611b9701528181611c1901528181611c9b015281816123bb015281816124410152818161253d01526125c301526142ea6000f3fe6080604052600436106101ac5760003560e01c80634fb50eea116100ec578063a22cb4651161008a578063c87b56dd11610064578063c87b56dd1461048b578063d2643d05146104ab578063d925f362146104cb578063e985e9c5146104eb57600080fd5b8063a22cb4651461042b578063b88d4fde1461044b578063b9e8ce2c1461046b57600080fd5b806370a08231116100c657806370a08231146103c35780637328896f146103e357806385245a06146103f657806395d89b411461041657600080fd5b80634fb50eea146103605780636198e339146103905780636352211e146103a357600080fd5b80631338736f1161015957806323b872dd1161013357806323b872dd146102e05780632f745c591461030057806342842e0e146103205780634f6ccce71461034057600080fd5b80631338736f146102a357806318160ddd146102b657806318264f33146102cb57600080fd5b8063095ea7b31161018a578063095ea7b3146102405780630962ef791461026257806310314ae51461027557600080fd5b806301ffc9a7146101b157806306fdde03146101e6578063081812fc14610208575b600080fd5b3480156101bd57600080fd5b506101d16101cc366004613724565b610534565b60405190151581526020015b60405180910390f35b3480156101f257600080fd5b506101fb610590565b6040516101dd9190613798565b34801561021457600080fd5b506102286102233660046137ab565b610622565b6040516001600160a01b0390911681526020016101dd565b34801561024c57600080fd5b5061026061025b3660046137d9565b610649565b005b6102606102703660046137ab565b61077f565b34801561028157600080fd5b506102956102903660046137ab565b610977565b6040519081526020016101dd565b6102606102b1366004613805565b610a27565b3480156102c257600080fd5b50600854610295565b3480156102d757600080fd5b50610260610d8c565b3480156102ec57600080fd5b506102606102fb366004613827565b610e9e565b34801561030c57600080fd5b5061029561031b3660046137d9565b610f25565b34801561032c57600080fd5b5061026061033b366004613827565b610fcd565b34801561034c57600080fd5b5061029561035b3660046137ab565b610fe8565b34801561036c57600080fd5b5061038061037b3660046137ab565b61108c565b6040516101dd9493929190613868565b61026061039e3660046137ab565b611173565b3480156103af57600080fd5b506102286103be3660046137ab565b6115c8565b3480156103cf57600080fd5b506102956103de3660046138de565b61162d565b6102606103f13660046137ab565b6116c7565b34801561040257600080fd5b506102956104113660046137ab565b611f47565b34801561042257600080fd5b506101fb612018565b34801561043757600080fd5b50610260610446366004613909565b612027565b34801561045757600080fd5b50610260610466366004613971565b612036565b34801561047757600080fd5b506102606104863660046138de565b6120c4565b34801561049757600080fd5b506101fb6104a63660046137ab565b612216565b3480156104b757600080fd5b506102956104c6366004613805565b6123b6565b3480156104d757600080fd5b506102956104e63660046137ab565b612538565b3480156104f757600080fd5b506101d1610506366004613a51565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f780e9d6300000000000000000000000000000000000000000000000000000000148061058a575061058a82612671565b92915050565b60606000805461059f90613a7f565b80601f01602080910402602001604051908101604052809291908181526020018280546105cb90613a7f565b80156106185780601f106105ed57610100808354040283529160200191610618565b820191906000526020600020905b8154815290600101906020018083116105fb57829003601f168201915b5050505050905090565b600061062d82612754565b506000908152600460205260409020546001600160a01b031690565b6000610654826115c8565b9050806001600160a01b0316836001600160a01b0316036106e25760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b336001600160a01b03821614806106fe57506106fe8133610506565b6107705760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c00000060648201526084016106d9565b61077a83836127b8565b505050565b6000818152600a6020908152604091829020825160e08101845281546001600160a01b0316815260018201549281019290925260028101549282019290925260038201546060820181905260048301546080830152600583015460ff16151560a083015260069092015460c082015290421061083d5760405162461bcd60e51b815260206004820152600e60248201527f546f6b656e20756e6c6f636b656400000000000000000000000000000000000060448201526064016106d9565b610846826115c8565b6001600160a01b0316336001600160a01b0316146108a65760405162461bcd60e51b815260206004820152601960248201527f4e6f7420746865206f776e6572206f6620746865206c6f636b0000000000000060448201526064016106d9565b6000828152600b602052604090205460ff16156109055760405162461bcd60e51b815260206004820181905260248201527f416c726561647920636c61696d656420666f72207468697320746f6b656e496460448201526064016106d9565b60008160c00151826040015161091b9190613b01565b905060006109294783613b3c565b6000858152600b6020526040808220805460ff1916600117905551919250339183156108fc0291849190818181858888f19350505050158015610970573d6000803e3d6000fd5b5050505050565b6000818152600a60209081526040808320815160e08101835281546001600160a01b0316815260018201549381019390935260028101549183018290526003810154606084015260048101546080840152600581015460ff16151560a08401526006015460c0830181905283916109ee9190613b01565b905060006109fc4783613b3c565b6000868152600b602052604090205490915060ff16610a1b5780610a1e565b60005b95945050505050565b6000610a3383836123b6565b9050600c548110610aac5760405162461bcd60e51b815260206004820152603c60248201527f5468652070726f6772616d2068617320656e6465642c206f7220796f7520617260448201527f65206c6f636b696e6720746f6f206d75636820524156452f46544d2e0000000060648201526084016106d9565b610abb600c6301dfe200613b01565b821015610b305760405162461bcd60e51b815260206004820152602260248201527f596f75206d757374206c6f636b20666f72206174206c656173742031206d6f6e60448201527f746800000000000000000000000000000000000000000000000000000000000060648201526084016106d9565b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018490527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906323b872dd906064016020604051808303816000875af1158015610bbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610be09190613b53565b506040517fb6b55f25000000000000000000000000000000000000000000000000000000008152600481018490526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b6b55f25906024016020604051808303816000875af1158015610c64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c889190613b70565b905081600c54610c989190613b89565b600c556000610ca74233613b9c565b90506040518060e00160405280336001600160a01b031681526020018381526020018481526020018542610cdb9190613b9c565b8152602080820187905260016040808401829052600c546060948501526000868152600a8452819020855181547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909116178155928501519183019190915583015160028201559082015160038201556080820151600482015560a082015160058201805460ff191691151591909117905560c090910151600690910155610970338261283e565b733e522051a9b1958aa1e828ac24afba4a551df37d3314610def5760405162461bcd60e51b815260206004820152601360248201527f4c504c6f636b65723a204e6f74206f776e65720000000000000000000000000060448201526064016106d9565b600d805460ff19166001179055600c546040517f23b872dd00000000000000000000000000000000000000000000000000000000815230600482015233602482015260448101919091527388888a335b1f65a79ec56a610d865b8b25b6060b906323b872dd906064016020604051808303816000875af1158015610e77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9b9190613b53565b50565b610ea833826129ef565b610f1a5760405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f7665640000000000000000000000000000000000000060648201526084016106d9565b61077a838383612a6d565b6000610f308361162d565b8210610fa45760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e647300000000000000000000000000000000000000000060648201526084016106d9565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b61077a83838360405180602001604052806000815250612036565b6000610ff360085490565b82106110675760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e6473000000000000000000000000000000000000000060648201526084016106d9565b6008828154811061107a5761107a613baf565b90600052602060002001549050919050565b6110d76040518060e0016040528060006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600015158152602001600081525090565b6000828152600a60209081526040808320600b9092528220548291829160ff1661110087611f47565b61110988610977565b6040805160e08101825285546001600160a01b03168152600186015460208201526002860154918101919091526003850154606082015260048501546080820152600585015460ff16151560a082015260069094015460c085015292989197509550909350915050565b6000818152600a6020908152604091829020825160e08101845281546001600160a01b0316815260018201549281019290925260028101549282019290925260038201546060820181905260048301546080830152600583015460ff16151560a083015260069092015460c0820152904210156112325760405162461bcd60e51b815260206004820152601260248201527f546f6b656e207374696c6c206c6f636b6564000000000000000000000000000060448201526064016106d9565b61123b826115c8565b6001600160a01b0316336001600160a01b03161461129b5760405162461bcd60e51b815260206004820152601960248201527f4e6f7420746865206f776e6572206f6620746865206c6f636b0000000000000060448201526064016106d9565b8060a001516112ec5760405162461bcd60e51b815260206004820152601460248201527f4c6f636b20686173206265656e20636c6f73656400000000000000000000000060448201526064016106d9565b6112f582612cd9565b60208101516040517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815260048101919091527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b15801561137657600080fd5b505af115801561138a573d6000803e3d6000fd5b505050507388888a335b1f65a79ec56a610d865b8b25b6060b6001600160a01b03166323b872dd306113bb856115c8565b60408086015190517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af115801561142c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114509190613b53565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166323b872dd3061148a856115c8565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166377c7b8fc6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061150c9190613b70565b856020015161151b9190613b3c565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015611587573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ab9190613b53565b50506000908152600a60205260409020600501805460ff19169055565b6000818152600260205260408120546001600160a01b03168061058a5760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e204944000000000000000060448201526064016106d9565b60006001600160a01b0382166116ab5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f74206120766160448201527f6c6964206f776e6572000000000000000000000000000000000000000000000060648201526084016106d9565b506001600160a01b031660009081526003602052604090205490565b6000818152600a6020908152604091829020825160e08101845281546001600160a01b0316815260018201549281019290925260028101549282019290925260038201546060820181905260048301546080830152600583015460ff16151560a083015260069092015460c08201529042106117855760405162461bcd60e51b815260206004820152600e60248201527f546f6b656e20756e6c6f636b656400000000000000000000000000000000000060448201526064016106d9565b61178e826115c8565b6001600160a01b0316336001600160a01b0316146117ee5760405162461bcd60e51b815260206004820152601960248201527f4e6f7420746865206f776e6572206f6620746865206c6f636b0000000000000060448201526064016106d9565b8060a0015161183f5760405162461bcd60e51b815260206004820152601460248201527f4c6f636b20686173206265656e20636c6f73656400000000000000000000000060448201526064016106d9565b6000816080015182606001516118559190613b89565b905060006118638242613b89565b600d5490915060009060ff166118915761188260026301dfe200613b01565b61188c9083613b01565b611894565b60015b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166377c7b8fc6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191a9190613b70565b85602001516119299190613b3c565b60208601516040517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081529192506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691632e1a7d4d916119989160040190815260200190565b600060405180830381600087803b1580156119b257600080fd5b505af11580156119c6573d6000803e3d6000fd5b505050507388888a335b1f65a79ec56a610d865b8b25b6060b6001600160a01b03166323b872dd306119f7896115c8565b858960400151611a079190613b3c565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015611a73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a979190613b53565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166323b872dd30611ad1896115c8565b858960200151611ae19190613b3c565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015611b4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b719190613b53565b50731a05eb736873485655f29a37def8a0aa87f5a4476001600160a01b0316630dede6c47f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611bf3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c179190613bde565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c999190613bde565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166322be3de16040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cf7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d1b9190613b53565b611d258787613b3c565b611d2f9087613b89565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e087901b1681526001600160a01b03948516600482015293909216602484015215156044830152606482015260006084820181905260a48201523060c48201524260e48201526101040160408051808303816000875af1158015611dbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611de09190613bfb565b50506000828660400151611df49190613b3c565b8660400151611e039190613b89565b6002611e1c611e128686613b3c565b6104e69086613b89565b611e269190613b01565b611e309190613b9c565b90507388888a335b1f65a79ec56a610d865b8b25b6060b6001600160a01b03166323b872dd307387f385d152944689f92ed523e9e5e9bd58ea62ef84878b60400151611e7c9190613b3c565b8b60400151611e8b9190613b89565b611e959190613b9c565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015611f01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f259190613b53565b50505060009485525050600a602052505060409020600501805460ff19169055565b6000818152600a60209081526040808320815160e08101835281546001600160a01b03168152600182015493810193909352600281015491830191909152600381015460608301819052600482015460808401819052600583015460ff16151560a085015260069092015460c08401528391611fc291613b89565b90506000611fd08242613b89565b600d5490915060009060ff16611ffe57611fef60026301dfe200613b01565b611ff99083613b01565b612001565b60015b905061200e816001613b89565b9695505050505050565b60606001805461059f90613a7f565b612032338383612db2565b5050565b61204033836129ef565b6120b25760405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f7665640000000000000000000000000000000000000060648201526084016106d9565b6120be84848484612e80565b50505050565b7387f385d152944689f92ed523e9e5e9bd58ea62ef33146120e457600080fd5b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482018190526001600160a01b038316916323b872dd91907387f385d152944689f92ed523e9e5e9bd58ea62ef9084906370a0823190602401602060405180830381865afa158015612162573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121869190613b70565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af11580156121f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120329190613b53565b606060405180610140016040528061010681526020016141af610106913990508061224083612f09565b604051602001612251929190613c1f565b60408051601f198184030181529181526000848152600a6020522060010154909150819061227e90612f09565b60405160200161228f929190613cc7565b60408051601f198184030181529181526000848152600a602052206003015490915081906122bc90612f09565b6040516020016122cd929190613d6f565b6040516020818303038152906040529050806122f06122eb84610977565b612f09565b604051602001612301929190613e13565b60408051601f198184030181529181526000848152600a6020522060020154909150819061232e90612f09565b60405160200161233f929190613eb7565b6040516020818303038152906040529050600061238c61235e84612f09565b61236784612fc7565b604051602001612378929190613f60565b604051602081830303815290604052612fc7565b90508060405160200161239f919061407d565b604051602081830303815290604052915050919050565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612417573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243b9190613b70565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa15801561249d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124c191906140c2565b50915060009050826124d4836002613b3c565b6124de9190613b01565b905060006124ec8288613b3c565b905060006124fd6103e8607d613b01565b6125079083613b3c565b905061251860026301dfe200613b01565b6125229088613b01565b61252c9082613b3c565b98975050505050505050565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612599573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125bd9190613b70565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa15801561261f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061264391906140c2565b50915084905082612655836002613b3c565b61265f9190613b01565b6126699190613b3c565b949350505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd00000000000000000000000000000000000000000000000000000000148061270457507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b8061058a57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461058a565b6000818152600260205260409020546001600160a01b0316610e9b5760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e204944000000000000000060448201526064016106d9565b600081815260046020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091558190612805826115c8565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6001600160a01b0382166128945760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106d9565b6000818152600260205260409020546001600160a01b0316156128f95760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106d9565b61290760008383600161311a565b6000818152600260205260409020546001600160a01b03161561296c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106d9565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000806129fb836115c8565b9050806001600160a01b0316846001600160a01b03161480612a4257506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b806126695750836001600160a01b0316612a5b84610622565b6001600160a01b031614949350505050565b826001600160a01b0316612a80826115c8565b6001600160a01b031614612afc5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e657200000000000000000000000000000000000000000000000000000060648201526084016106d9565b6001600160a01b038216612b775760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016106d9565b612b84838383600161311a565b826001600160a01b0316612b97826115c8565b6001600160a01b031614612c135760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e657200000000000000000000000000000000000000000000000000000060648201526084016106d9565b600081815260046020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081169091556001600160a01b038781168086526003855283862080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01905590871680865283862080546001019055868652600290945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000612ce4826115c8565b9050612cf481600084600161311a565b612cfd826115c8565b600083815260046020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081169091556001600160a01b0385168085526003845282852080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190558785526002909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b816001600160a01b0316836001600160a01b031603612e135760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106d9565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612e8b848484612a6d565b612e978484848461325b565b6120be5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016106d9565b60606000612f16836133fc565b600101905060008167ffffffffffffffff811115612f3657612f36613942565b6040519080825280601f01601f191660200182016040528015612f60576020820181803683370190505b5090508181016020015b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a8504945084612f6a57509392505050565b60608151600003612fe657505060408051602081019091526000815290565b600060405180606001604052806040815260200161416f60409139905060006003845160026130159190613b9c565b61301f9190613b01565b61302a906004613b3c565b67ffffffffffffffff81111561304257613042613942565b6040519080825280601f01601f19166020018201604052801561306c576020820181803683370190505b509050600182016020820185865187015b808210156130d8576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f811685015184535060018301925061307d565b50506003865106600181146130f457600281146131075761310f565b603d6001830353603d600283035361310f565b603d60018303535b509195945050505050565b613126848484846134de565b600181111561319d5760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e736563757469766520747260448201527f616e7366657273206e6f7420737570706f72746564000000000000000000000060648201526084016106d9565b816001600160a01b0385166131f9576131f481600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b61321c565b836001600160a01b0316856001600160a01b03161461321c5761321c8582613566565b6001600160a01b0384166132385761323381613603565b610970565b846001600160a01b0316846001600160a01b0316146109705761097084826136b2565b60006001600160a01b0384163b156133f1576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063150b7a02906132b89033908990889088906004016140f0565b6020604051808303816000875af19250505080156132f3575060408051601f3d908101601f191682019092526132f091810190614122565b60015b6133a6573d808015613321576040519150601f19603f3d011682016040523d82523d6000602084013e613326565b606091505b50805160000361339e5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016106d9565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a0200000000000000000000000000000000000000000000000000000000149050612669565b506001949350505050565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310613445577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef81000000008310613471576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061348f57662386f26fc10000830492506010015b6305f5e10083106134a7576305f5e100830492506008015b61271083106134bb57612710830492506004015b606483106134cd576064830492506002015b600a831061058a5760010192915050565b60018111156120be576001600160a01b03841615613524576001600160a01b0384166000908152600360205260408120805483929061351e908490613b89565b90915550505b6001600160a01b038316156120be576001600160a01b0383166000908152600360205260408120805483929061355b908490613b9c565b909155505050505050565b600060016135738461162d565b61357d9190613b89565b6000838152600760205260409020549091508082146135d0576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061361590600190613b89565b6000838152600960205260408120546008805493945090928490811061363d5761363d613baf565b90600052602060002001549050806008838154811061365e5761365e613baf565b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806136965761369661413f565b6001900381819060005260206000200160009055905550505050565b60006136bd8361162d565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b7fffffffff0000000000000000000000000000000000000000000000000000000081168114610e9b57600080fd5b60006020828403121561373657600080fd5b8135613741816136f6565b9392505050565b60005b8381101561376357818101518382015260200161374b565b50506000910152565b60008151808452613784816020860160208601613748565b601f01601f19169290920160200192915050565b602081526000613741602083018461376c565b6000602082840312156137bd57600080fd5b5035919050565b6001600160a01b0381168114610e9b57600080fd5b600080604083850312156137ec57600080fd5b82356137f7816137c4565b946020939093013593505050565b6000806040838503121561381857600080fd5b50508035926020909101359150565b60008060006060848603121561383c57600080fd5b8335613847816137c4565b92506020840135613857816137c4565b929592945050506040919091013590565b6000610140820190506001600160a01b0386511682526020860151602083015260408601516040830152606086015160608301526080860151608083015260a0860151151560a083015260c086015160c08301526138ca60e083018615159052565b610100820193909352610120015292915050565b6000602082840312156138f057600080fd5b8135613741816137c4565b8015158114610e9b57600080fd5b6000806040838503121561391c57600080fd5b8235613927816137c4565b91506020830135613937816138fb565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000806080858703121561398757600080fd5b8435613992816137c4565b935060208501356139a2816137c4565b925060408501359150606085013567ffffffffffffffff808211156139c657600080fd5b818701915087601f8301126139da57600080fd5b8135818111156139ec576139ec613942565b604051601f8201601f19908116603f01168101908382118183101715613a1457613a14613942565b816040528281528a6020848701011115613a2d57600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60008060408385031215613a6457600080fd5b8235613a6f816137c4565b91506020830135613937816137c4565b600181811c90821680613a9357607f821691505b602082108103613acc577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082613b37577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b808202811582820484141761058a5761058a613ad2565b600060208284031215613b6557600080fd5b8151613741816138fb565b600060208284031215613b8257600080fd5b5051919050565b8181038181111561058a5761058a613ad2565b8082018082111561058a5761058a613ad2565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215613bf057600080fd5b8151613741816137c4565b60008060408385031215613c0e57600080fd5b505080516020909101519092909150565b60008351613c31818460208801613748565b7f546f6b656e2049440000000000000000000000000000000000000000000000009083019081528351613c6b816008840160208801613748565b7f3c2f746578743e3c7465787420783d2231302220793d2234302220636c617373600892909101918201527f3d2262617365223e0000000000000000000000000000000000000000000000006028820152603001949350505050565b60008351613cd9818460208801613748565b7f4c6f636b6564204c502028313820646563696d616c73290000000000000000009083019081528351613d13816017840160208801613748565b7f3c2f746578743e3c7465787420783d2231302220793d2236302220636c617373601792909101918201527f3d2262617365223e0000000000000000000000000000000000000000000000006037820152603f01949350505050565b60008351613d81818460208801613748565b7f456e642054696d652000000000000000000000000000000000000000000000009083019081528351613dbb816009840160208801613748565b61200e6009828401017f3c2f746578743e3c7465787420783d2231302220793d2238302220636c61737381527f3d2262617365223e000000000000000000000000000000000000000000000000602082015260280190565b60008351613e25818460208801613748565b7f46544d20526577617264732028313820646563696d616c7329000000000000009083019081528351613e5f816019840160208801613748565b61200e6019828401017f3c2f746578743e3c7465787420783d2231302220793d2238302220636c61737381527f3d2262617365223e000000000000000000000000000000000000000000000000602082015260280190565b60008351613ec9818460208801613748565b80830190507f5241564520746f2062652072657761726465642028313820646563696d616c7381527f290000000000000000000000000000000000000000000000000000000000000060208201528351613f2a816021840160208801613748565b7f3c2f746578743e3c2f7376673e0000000000000000000000000000000000000060219290910191820152602e01949350505050565b7f7b226e616d65223a202252617665204c6f636b20230000000000000000000000815260008351613f98816015850160208801613748565b7f222c20226465736372697074696f6e223a2022524156452d46544d204c50206c6015918401918201527f6f636b73206561726e205241564520616e64206175746f636f6d706f756e642060358201527f457175616c697a6572206661726d20726577617264732e222c2022696d61676560558201527f223a2022646174613a696d6167652f7376672b786d6c3b6261736536342c000060758201528351614047816093840160208801613748565b7f227d00000000000000000000000000000000000000000000000000000000000060939290910191820152609501949350505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000008152600082516140b581601d850160208701613748565b91909101601d0192915050565b6000806000606084860312156140d757600080fd5b8351925060208401519150604084015190509250925092565b60006001600160a01b0380871683528086166020840152508360408301526080606083015261200e608083018461376c565b60006020828403121561413457600080fd5b8151613741816136f6565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f3c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323030302f73766722207072657365727665417370656374526174696f3d22784d696e594d696e206d656574222076696577426f783d223020302033353020333530223e3c7374796c653e2e62617365207b2066696c6c3a2077686974653b20666f6e742d66616d696c793a20566572616e64612c2073657269663b20666f6e742d73697a653a20313470783b207d3c2f7374796c653e3c726563742077696474683d223130302522206865696768743d2231303025222066696c6c3d22626c61636b22202f3e3c7465787420783d2231302220793d2232302220636c6173733d2262617365223ea2646970667358221220bcbd0e3b608f3501abc1d7d929523253ea503e1088668b9e3869d261145e979964736f6c63430008110033000000000000000000000000e117a5f40a5d28d3b2f103301c629617bfba5f61000000000000000000000000845b22ce834b100fc2ed4339375505c9715331fc

Deployed Bytecode

0x6080604052600436106101ac5760003560e01c80634fb50eea116100ec578063a22cb4651161008a578063c87b56dd11610064578063c87b56dd1461048b578063d2643d05146104ab578063d925f362146104cb578063e985e9c5146104eb57600080fd5b8063a22cb4651461042b578063b88d4fde1461044b578063b9e8ce2c1461046b57600080fd5b806370a08231116100c657806370a08231146103c35780637328896f146103e357806385245a06146103f657806395d89b411461041657600080fd5b80634fb50eea146103605780636198e339146103905780636352211e146103a357600080fd5b80631338736f1161015957806323b872dd1161013357806323b872dd146102e05780632f745c591461030057806342842e0e146103205780634f6ccce71461034057600080fd5b80631338736f146102a357806318160ddd146102b657806318264f33146102cb57600080fd5b8063095ea7b31161018a578063095ea7b3146102405780630962ef791461026257806310314ae51461027557600080fd5b806301ffc9a7146101b157806306fdde03146101e6578063081812fc14610208575b600080fd5b3480156101bd57600080fd5b506101d16101cc366004613724565b610534565b60405190151581526020015b60405180910390f35b3480156101f257600080fd5b506101fb610590565b6040516101dd9190613798565b34801561021457600080fd5b506102286102233660046137ab565b610622565b6040516001600160a01b0390911681526020016101dd565b34801561024c57600080fd5b5061026061025b3660046137d9565b610649565b005b6102606102703660046137ab565b61077f565b34801561028157600080fd5b506102956102903660046137ab565b610977565b6040519081526020016101dd565b6102606102b1366004613805565b610a27565b3480156102c257600080fd5b50600854610295565b3480156102d757600080fd5b50610260610d8c565b3480156102ec57600080fd5b506102606102fb366004613827565b610e9e565b34801561030c57600080fd5b5061029561031b3660046137d9565b610f25565b34801561032c57600080fd5b5061026061033b366004613827565b610fcd565b34801561034c57600080fd5b5061029561035b3660046137ab565b610fe8565b34801561036c57600080fd5b5061038061037b3660046137ab565b61108c565b6040516101dd9493929190613868565b61026061039e3660046137ab565b611173565b3480156103af57600080fd5b506102286103be3660046137ab565b6115c8565b3480156103cf57600080fd5b506102956103de3660046138de565b61162d565b6102606103f13660046137ab565b6116c7565b34801561040257600080fd5b506102956104113660046137ab565b611f47565b34801561042257600080fd5b506101fb612018565b34801561043757600080fd5b50610260610446366004613909565b612027565b34801561045757600080fd5b50610260610466366004613971565b612036565b34801561047757600080fd5b506102606104863660046138de565b6120c4565b34801561049757600080fd5b506101fb6104a63660046137ab565b612216565b3480156104b757600080fd5b506102956104c6366004613805565b6123b6565b3480156104d757600080fd5b506102956104e63660046137ab565b612538565b3480156104f757600080fd5b506101d1610506366004613a51565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f780e9d6300000000000000000000000000000000000000000000000000000000148061058a575061058a82612671565b92915050565b60606000805461059f90613a7f565b80601f01602080910402602001604051908101604052809291908181526020018280546105cb90613a7f565b80156106185780601f106105ed57610100808354040283529160200191610618565b820191906000526020600020905b8154815290600101906020018083116105fb57829003601f168201915b5050505050905090565b600061062d82612754565b506000908152600460205260409020546001600160a01b031690565b6000610654826115c8565b9050806001600160a01b0316836001600160a01b0316036106e25760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b336001600160a01b03821614806106fe57506106fe8133610506565b6107705760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c00000060648201526084016106d9565b61077a83836127b8565b505050565b6000818152600a6020908152604091829020825160e08101845281546001600160a01b0316815260018201549281019290925260028101549282019290925260038201546060820181905260048301546080830152600583015460ff16151560a083015260069092015460c082015290421061083d5760405162461bcd60e51b815260206004820152600e60248201527f546f6b656e20756e6c6f636b656400000000000000000000000000000000000060448201526064016106d9565b610846826115c8565b6001600160a01b0316336001600160a01b0316146108a65760405162461bcd60e51b815260206004820152601960248201527f4e6f7420746865206f776e6572206f6620746865206c6f636b0000000000000060448201526064016106d9565b6000828152600b602052604090205460ff16156109055760405162461bcd60e51b815260206004820181905260248201527f416c726561647920636c61696d656420666f72207468697320746f6b656e496460448201526064016106d9565b60008160c00151826040015161091b9190613b01565b905060006109294783613b3c565b6000858152600b6020526040808220805460ff1916600117905551919250339183156108fc0291849190818181858888f19350505050158015610970573d6000803e3d6000fd5b5050505050565b6000818152600a60209081526040808320815160e08101835281546001600160a01b0316815260018201549381019390935260028101549183018290526003810154606084015260048101546080840152600581015460ff16151560a08401526006015460c0830181905283916109ee9190613b01565b905060006109fc4783613b3c565b6000868152600b602052604090205490915060ff16610a1b5780610a1e565b60005b95945050505050565b6000610a3383836123b6565b9050600c548110610aac5760405162461bcd60e51b815260206004820152603c60248201527f5468652070726f6772616d2068617320656e6465642c206f7220796f7520617260448201527f65206c6f636b696e6720746f6f206d75636820524156452f46544d2e0000000060648201526084016106d9565b610abb600c6301dfe200613b01565b821015610b305760405162461bcd60e51b815260206004820152602260248201527f596f75206d757374206c6f636b20666f72206174206c656173742031206d6f6e60448201527f746800000000000000000000000000000000000000000000000000000000000060648201526084016106d9565b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018490527f000000000000000000000000e117a5f40a5d28d3b2f103301c629617bfba5f616001600160a01b0316906323b872dd906064016020604051808303816000875af1158015610bbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610be09190613b53565b506040517fb6b55f25000000000000000000000000000000000000000000000000000000008152600481018490526000907f000000000000000000000000845b22ce834b100fc2ed4339375505c9715331fc6001600160a01b03169063b6b55f25906024016020604051808303816000875af1158015610c64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c889190613b70565b905081600c54610c989190613b89565b600c556000610ca74233613b9c565b90506040518060e00160405280336001600160a01b031681526020018381526020018481526020018542610cdb9190613b9c565b8152602080820187905260016040808401829052600c546060948501526000868152600a8452819020855181547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909116178155928501519183019190915583015160028201559082015160038201556080820151600482015560a082015160058201805460ff191691151591909117905560c090910151600690910155610970338261283e565b733e522051a9b1958aa1e828ac24afba4a551df37d3314610def5760405162461bcd60e51b815260206004820152601360248201527f4c504c6f636b65723a204e6f74206f776e65720000000000000000000000000060448201526064016106d9565b600d805460ff19166001179055600c546040517f23b872dd00000000000000000000000000000000000000000000000000000000815230600482015233602482015260448101919091527388888a335b1f65a79ec56a610d865b8b25b6060b906323b872dd906064016020604051808303816000875af1158015610e77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9b9190613b53565b50565b610ea833826129ef565b610f1a5760405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f7665640000000000000000000000000000000000000060648201526084016106d9565b61077a838383612a6d565b6000610f308361162d565b8210610fa45760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e647300000000000000000000000000000000000000000060648201526084016106d9565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b61077a83838360405180602001604052806000815250612036565b6000610ff360085490565b82106110675760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e6473000000000000000000000000000000000000000060648201526084016106d9565b6008828154811061107a5761107a613baf565b90600052602060002001549050919050565b6110d76040518060e0016040528060006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600015158152602001600081525090565b6000828152600a60209081526040808320600b9092528220548291829160ff1661110087611f47565b61110988610977565b6040805160e08101825285546001600160a01b03168152600186015460208201526002860154918101919091526003850154606082015260048501546080820152600585015460ff16151560a082015260069094015460c085015292989197509550909350915050565b6000818152600a6020908152604091829020825160e08101845281546001600160a01b0316815260018201549281019290925260028101549282019290925260038201546060820181905260048301546080830152600583015460ff16151560a083015260069092015460c0820152904210156112325760405162461bcd60e51b815260206004820152601260248201527f546f6b656e207374696c6c206c6f636b6564000000000000000000000000000060448201526064016106d9565b61123b826115c8565b6001600160a01b0316336001600160a01b03161461129b5760405162461bcd60e51b815260206004820152601960248201527f4e6f7420746865206f776e6572206f6620746865206c6f636b0000000000000060448201526064016106d9565b8060a001516112ec5760405162461bcd60e51b815260206004820152601460248201527f4c6f636b20686173206265656e20636c6f73656400000000000000000000000060448201526064016106d9565b6112f582612cd9565b60208101516040517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815260048101919091527f000000000000000000000000845b22ce834b100fc2ed4339375505c9715331fc6001600160a01b031690632e1a7d4d90602401600060405180830381600087803b15801561137657600080fd5b505af115801561138a573d6000803e3d6000fd5b505050507388888a335b1f65a79ec56a610d865b8b25b6060b6001600160a01b03166323b872dd306113bb856115c8565b60408086015190517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af115801561142c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114509190613b53565b507f000000000000000000000000e117a5f40a5d28d3b2f103301c629617bfba5f616001600160a01b03166323b872dd3061148a856115c8565b7f000000000000000000000000845b22ce834b100fc2ed4339375505c9715331fc6001600160a01b03166377c7b8fc6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061150c9190613b70565b856020015161151b9190613b3c565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015611587573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ab9190613b53565b50506000908152600a60205260409020600501805460ff19169055565b6000818152600260205260408120546001600160a01b03168061058a5760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e204944000000000000000060448201526064016106d9565b60006001600160a01b0382166116ab5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f74206120766160448201527f6c6964206f776e6572000000000000000000000000000000000000000000000060648201526084016106d9565b506001600160a01b031660009081526003602052604090205490565b6000818152600a6020908152604091829020825160e08101845281546001600160a01b0316815260018201549281019290925260028101549282019290925260038201546060820181905260048301546080830152600583015460ff16151560a083015260069092015460c08201529042106117855760405162461bcd60e51b815260206004820152600e60248201527f546f6b656e20756e6c6f636b656400000000000000000000000000000000000060448201526064016106d9565b61178e826115c8565b6001600160a01b0316336001600160a01b0316146117ee5760405162461bcd60e51b815260206004820152601960248201527f4e6f7420746865206f776e6572206f6620746865206c6f636b0000000000000060448201526064016106d9565b8060a0015161183f5760405162461bcd60e51b815260206004820152601460248201527f4c6f636b20686173206265656e20636c6f73656400000000000000000000000060448201526064016106d9565b6000816080015182606001516118559190613b89565b905060006118638242613b89565b600d5490915060009060ff166118915761188260026301dfe200613b01565b61188c9083613b01565b611894565b60015b905060007f000000000000000000000000845b22ce834b100fc2ed4339375505c9715331fc6001600160a01b03166377c7b8fc6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191a9190613b70565b85602001516119299190613b3c565b60208601516040517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081529192506001600160a01b037f000000000000000000000000845b22ce834b100fc2ed4339375505c9715331fc1691632e1a7d4d916119989160040190815260200190565b600060405180830381600087803b1580156119b257600080fd5b505af11580156119c6573d6000803e3d6000fd5b505050507388888a335b1f65a79ec56a610d865b8b25b6060b6001600160a01b03166323b872dd306119f7896115c8565b858960400151611a079190613b3c565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015611a73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a979190613b53565b507f000000000000000000000000e117a5f40a5d28d3b2f103301c629617bfba5f616001600160a01b03166323b872dd30611ad1896115c8565b858960200151611ae19190613b3c565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015611b4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b719190613b53565b50731a05eb736873485655f29a37def8a0aa87f5a4476001600160a01b0316630dede6c47f000000000000000000000000e117a5f40a5d28d3b2f103301c629617bfba5f616001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611bf3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c179190613bde565b7f000000000000000000000000e117a5f40a5d28d3b2f103301c629617bfba5f616001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c999190613bde565b7f000000000000000000000000e117a5f40a5d28d3b2f103301c629617bfba5f616001600160a01b03166322be3de16040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cf7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d1b9190613b53565b611d258787613b3c565b611d2f9087613b89565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e087901b1681526001600160a01b03948516600482015293909216602484015215156044830152606482015260006084820181905260a48201523060c48201524260e48201526101040160408051808303816000875af1158015611dbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611de09190613bfb565b50506000828660400151611df49190613b3c565b8660400151611e039190613b89565b6002611e1c611e128686613b3c565b6104e69086613b89565b611e269190613b01565b611e309190613b9c565b90507388888a335b1f65a79ec56a610d865b8b25b6060b6001600160a01b03166323b872dd307387f385d152944689f92ed523e9e5e9bd58ea62ef84878b60400151611e7c9190613b3c565b8b60400151611e8b9190613b89565b611e959190613b9c565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015611f01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f259190613b53565b50505060009485525050600a602052505060409020600501805460ff19169055565b6000818152600a60209081526040808320815160e08101835281546001600160a01b03168152600182015493810193909352600281015491830191909152600381015460608301819052600482015460808401819052600583015460ff16151560a085015260069092015460c08401528391611fc291613b89565b90506000611fd08242613b89565b600d5490915060009060ff16611ffe57611fef60026301dfe200613b01565b611ff99083613b01565b612001565b60015b905061200e816001613b89565b9695505050505050565b60606001805461059f90613a7f565b612032338383612db2565b5050565b61204033836129ef565b6120b25760405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f7665640000000000000000000000000000000000000060648201526084016106d9565b6120be84848484612e80565b50505050565b7387f385d152944689f92ed523e9e5e9bd58ea62ef33146120e457600080fd5b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482018190526001600160a01b038316916323b872dd91907387f385d152944689f92ed523e9e5e9bd58ea62ef9084906370a0823190602401602060405180830381865afa158015612162573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121869190613b70565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af11580156121f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120329190613b53565b606060405180610140016040528061010681526020016141af610106913990508061224083612f09565b604051602001612251929190613c1f565b60408051601f198184030181529181526000848152600a6020522060010154909150819061227e90612f09565b60405160200161228f929190613cc7565b60408051601f198184030181529181526000848152600a602052206003015490915081906122bc90612f09565b6040516020016122cd929190613d6f565b6040516020818303038152906040529050806122f06122eb84610977565b612f09565b604051602001612301929190613e13565b60408051601f198184030181529181526000848152600a6020522060020154909150819061232e90612f09565b60405160200161233f929190613eb7565b6040516020818303038152906040529050600061238c61235e84612f09565b61236784612fc7565b604051602001612378929190613f60565b604051602081830303815290604052612fc7565b90508060405160200161239f919061407d565b604051602081830303815290604052915050919050565b6000807f000000000000000000000000e117a5f40a5d28d3b2f103301c629617bfba5f616001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612417573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243b9190613b70565b905060007f000000000000000000000000e117a5f40a5d28d3b2f103301c629617bfba5f616001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa15801561249d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124c191906140c2565b50915060009050826124d4836002613b3c565b6124de9190613b01565b905060006124ec8288613b3c565b905060006124fd6103e8607d613b01565b6125079083613b3c565b905061251860026301dfe200613b01565b6125229088613b01565b61252c9082613b3c565b98975050505050505050565b6000807f000000000000000000000000e117a5f40a5d28d3b2f103301c629617bfba5f616001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612599573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125bd9190613b70565b905060007f000000000000000000000000e117a5f40a5d28d3b2f103301c629617bfba5f616001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa15801561261f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061264391906140c2565b50915084905082612655836002613b3c565b61265f9190613b01565b6126699190613b3c565b949350505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd00000000000000000000000000000000000000000000000000000000148061270457507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b8061058a57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461058a565b6000818152600260205260409020546001600160a01b0316610e9b5760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e204944000000000000000060448201526064016106d9565b600081815260046020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091558190612805826115c8565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6001600160a01b0382166128945760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106d9565b6000818152600260205260409020546001600160a01b0316156128f95760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106d9565b61290760008383600161311a565b6000818152600260205260409020546001600160a01b03161561296c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106d9565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000806129fb836115c8565b9050806001600160a01b0316846001600160a01b03161480612a4257506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b806126695750836001600160a01b0316612a5b84610622565b6001600160a01b031614949350505050565b826001600160a01b0316612a80826115c8565b6001600160a01b031614612afc5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e657200000000000000000000000000000000000000000000000000000060648201526084016106d9565b6001600160a01b038216612b775760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016106d9565b612b84838383600161311a565b826001600160a01b0316612b97826115c8565b6001600160a01b031614612c135760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e657200000000000000000000000000000000000000000000000000000060648201526084016106d9565b600081815260046020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081169091556001600160a01b038781168086526003855283862080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01905590871680865283862080546001019055868652600290945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000612ce4826115c8565b9050612cf481600084600161311a565b612cfd826115c8565b600083815260046020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081169091556001600160a01b0385168085526003845282852080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190558785526002909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b816001600160a01b0316836001600160a01b031603612e135760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106d9565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612e8b848484612a6d565b612e978484848461325b565b6120be5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016106d9565b60606000612f16836133fc565b600101905060008167ffffffffffffffff811115612f3657612f36613942565b6040519080825280601f01601f191660200182016040528015612f60576020820181803683370190505b5090508181016020015b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a8504945084612f6a57509392505050565b60608151600003612fe657505060408051602081019091526000815290565b600060405180606001604052806040815260200161416f60409139905060006003845160026130159190613b9c565b61301f9190613b01565b61302a906004613b3c565b67ffffffffffffffff81111561304257613042613942565b6040519080825280601f01601f19166020018201604052801561306c576020820181803683370190505b509050600182016020820185865187015b808210156130d8576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f811685015184535060018301925061307d565b50506003865106600181146130f457600281146131075761310f565b603d6001830353603d600283035361310f565b603d60018303535b509195945050505050565b613126848484846134de565b600181111561319d5760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e736563757469766520747260448201527f616e7366657273206e6f7420737570706f72746564000000000000000000000060648201526084016106d9565b816001600160a01b0385166131f9576131f481600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b61321c565b836001600160a01b0316856001600160a01b03161461321c5761321c8582613566565b6001600160a01b0384166132385761323381613603565b610970565b846001600160a01b0316846001600160a01b0316146109705761097084826136b2565b60006001600160a01b0384163b156133f1576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063150b7a02906132b89033908990889088906004016140f0565b6020604051808303816000875af19250505080156132f3575060408051601f3d908101601f191682019092526132f091810190614122565b60015b6133a6573d808015613321576040519150601f19603f3d011682016040523d82523d6000602084013e613326565b606091505b50805160000361339e5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016106d9565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a0200000000000000000000000000000000000000000000000000000000149050612669565b506001949350505050565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310613445577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef81000000008310613471576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061348f57662386f26fc10000830492506010015b6305f5e10083106134a7576305f5e100830492506008015b61271083106134bb57612710830492506004015b606483106134cd576064830492506002015b600a831061058a5760010192915050565b60018111156120be576001600160a01b03841615613524576001600160a01b0384166000908152600360205260408120805483929061351e908490613b89565b90915550505b6001600160a01b038316156120be576001600160a01b0383166000908152600360205260408120805483929061355b908490613b9c565b909155505050505050565b600060016135738461162d565b61357d9190613b89565b6000838152600760205260409020549091508082146135d0576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061361590600190613b89565b6000838152600960205260408120546008805493945090928490811061363d5761363d613baf565b90600052602060002001549050806008838154811061365e5761365e613baf565b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806136965761369661413f565b6001900381819060005260206000200160009055905550505050565b60006136bd8361162d565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b7fffffffff0000000000000000000000000000000000000000000000000000000081168114610e9b57600080fd5b60006020828403121561373657600080fd5b8135613741816136f6565b9392505050565b60005b8381101561376357818101518382015260200161374b565b50506000910152565b60008151808452613784816020860160208601613748565b601f01601f19169290920160200192915050565b602081526000613741602083018461376c565b6000602082840312156137bd57600080fd5b5035919050565b6001600160a01b0381168114610e9b57600080fd5b600080604083850312156137ec57600080fd5b82356137f7816137c4565b946020939093013593505050565b6000806040838503121561381857600080fd5b50508035926020909101359150565b60008060006060848603121561383c57600080fd5b8335613847816137c4565b92506020840135613857816137c4565b929592945050506040919091013590565b6000610140820190506001600160a01b0386511682526020860151602083015260408601516040830152606086015160608301526080860151608083015260a0860151151560a083015260c086015160c08301526138ca60e083018615159052565b610100820193909352610120015292915050565b6000602082840312156138f057600080fd5b8135613741816137c4565b8015158114610e9b57600080fd5b6000806040838503121561391c57600080fd5b8235613927816137c4565b91506020830135613937816138fb565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000806080858703121561398757600080fd5b8435613992816137c4565b935060208501356139a2816137c4565b925060408501359150606085013567ffffffffffffffff808211156139c657600080fd5b818701915087601f8301126139da57600080fd5b8135818111156139ec576139ec613942565b604051601f8201601f19908116603f01168101908382118183101715613a1457613a14613942565b816040528281528a6020848701011115613a2d57600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60008060408385031215613a6457600080fd5b8235613a6f816137c4565b91506020830135613937816137c4565b600181811c90821680613a9357607f821691505b602082108103613acc577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082613b37577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b808202811582820484141761058a5761058a613ad2565b600060208284031215613b6557600080fd5b8151613741816138fb565b600060208284031215613b8257600080fd5b5051919050565b8181038181111561058a5761058a613ad2565b8082018082111561058a5761058a613ad2565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215613bf057600080fd5b8151613741816137c4565b60008060408385031215613c0e57600080fd5b505080516020909101519092909150565b60008351613c31818460208801613748565b7f546f6b656e2049440000000000000000000000000000000000000000000000009083019081528351613c6b816008840160208801613748565b7f3c2f746578743e3c7465787420783d2231302220793d2234302220636c617373600892909101918201527f3d2262617365223e0000000000000000000000000000000000000000000000006028820152603001949350505050565b60008351613cd9818460208801613748565b7f4c6f636b6564204c502028313820646563696d616c73290000000000000000009083019081528351613d13816017840160208801613748565b7f3c2f746578743e3c7465787420783d2231302220793d2236302220636c617373601792909101918201527f3d2262617365223e0000000000000000000000000000000000000000000000006037820152603f01949350505050565b60008351613d81818460208801613748565b7f456e642054696d652000000000000000000000000000000000000000000000009083019081528351613dbb816009840160208801613748565b61200e6009828401017f3c2f746578743e3c7465787420783d2231302220793d2238302220636c61737381527f3d2262617365223e000000000000000000000000000000000000000000000000602082015260280190565b60008351613e25818460208801613748565b7f46544d20526577617264732028313820646563696d616c7329000000000000009083019081528351613e5f816019840160208801613748565b61200e6019828401017f3c2f746578743e3c7465787420783d2231302220793d2238302220636c61737381527f3d2262617365223e000000000000000000000000000000000000000000000000602082015260280190565b60008351613ec9818460208801613748565b80830190507f5241564520746f2062652072657761726465642028313820646563696d616c7381527f290000000000000000000000000000000000000000000000000000000000000060208201528351613f2a816021840160208801613748565b7f3c2f746578743e3c2f7376673e0000000000000000000000000000000000000060219290910191820152602e01949350505050565b7f7b226e616d65223a202252617665204c6f636b20230000000000000000000000815260008351613f98816015850160208801613748565b7f222c20226465736372697074696f6e223a2022524156452d46544d204c50206c6015918401918201527f6f636b73206561726e205241564520616e64206175746f636f6d706f756e642060358201527f457175616c697a6572206661726d20726577617264732e222c2022696d61676560558201527f223a2022646174613a696d6167652f7376672b786d6c3b6261736536342c000060758201528351614047816093840160208801613748565b7f227d00000000000000000000000000000000000000000000000000000000000060939290910191820152609501949350505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000008152600082516140b581601d850160208701613748565b91909101601d0192915050565b6000806000606084860312156140d757600080fd5b8351925060208401519150604084015190509250925092565b60006001600160a01b0380871683528086166020840152508360408301526080606083015261200e608083018461376c565b60006020828403121561413457600080fd5b8151613741816136f6565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f3c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323030302f73766722207072657365727665417370656374526174696f3d22784d696e594d696e206d656574222076696577426f783d223020302033353020333530223e3c7374796c653e2e62617365207b2066696c6c3a2077686974653b20666f6e742d66616d696c793a20566572616e64612c2073657269663b20666f6e742d73697a653a20313470783b207d3c2f7374796c653e3c726563742077696474683d223130302522206865696768743d2231303025222066696c6c3d22626c61636b22202f3e3c7465787420783d2231302220793d2232302220636c6173733d2262617365223ea2646970667358221220bcbd0e3b608f3501abc1d7d929523253ea503e1088668b9e3869d261145e979964736f6c63430008110033

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

000000000000000000000000e117a5f40a5d28d3b2f103301c629617bfba5f61000000000000000000000000845b22ce834b100fc2ed4339375505c9715331fc

-----Decoded View---------------
Arg [0] : _lp (address): 0xe117a5f40A5D28d3b2F103301C629617bfBA5F61
Arg [1] : _vault (address): 0x845b22ce834b100FC2ED4339375505c9715331FC

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000e117a5f40a5d28d3b2f103301c629617bfba5f61
Arg [1] : 000000000000000000000000845b22ce834b100fc2ed4339375505c9715331fc


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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