ETH Price: $3,387.49 (-1.58%)
Gas: 2 Gwei

Token

xINV (XINV)
 

Overview

Max Total Supply

39,800.305903084160828325 XINV

Holders

698

Market

Onchain Market Cap

$0.00

Circulating Supply Market Cap

-

Other Info

Token Contract (WITH 18 Decimals)

Filtered by Token Holder
rsaudi.eth
Balance
0 XINV

Value
$0.00
0x5d0dacd2a9337f8e3b198aaffe8250ae23da2125
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information
# Exchange Pair Price  24H Volume % Volume

Contract Source Code Verified (Exact Match)

Contract Name:
XINV

Compiler Version
v0.5.16+commit.9c3226ce

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, BSD-3-Clause license
File 1 of 10 : CarefulMath.sol
pragma solidity ^0.5.16;

/**
  * @title Careful Math
  * @author Compound
  * @notice Derived from OpenZeppelin's SafeMath library
  *         https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol
  */
contract CarefulMath {

    /**
     * @dev Possible error codes that we can return
     */
    enum MathError {
        NO_ERROR,
        DIVISION_BY_ZERO,
        INTEGER_OVERFLOW,
        INTEGER_UNDERFLOW
    }

    /**
    * @dev Multiplies two numbers, returns an error on overflow.
    */
    function mulUInt(uint a, uint b) internal pure returns (MathError, uint) {
        if (a == 0) {
            return (MathError.NO_ERROR, 0);
        }

        uint c = a * b;

        if (c / a != b) {
            return (MathError.INTEGER_OVERFLOW, 0);
        } else {
            return (MathError.NO_ERROR, c);
        }
    }

    /**
    * @dev Integer division of two numbers, truncating the quotient.
    */
    function divUInt(uint a, uint b) internal pure returns (MathError, uint) {
        if (b == 0) {
            return (MathError.DIVISION_BY_ZERO, 0);
        }

        return (MathError.NO_ERROR, a / b);
    }

    /**
    * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).
    */
    function subUInt(uint a, uint b) internal pure returns (MathError, uint) {
        if (b <= a) {
            return (MathError.NO_ERROR, a - b);
        } else {
            return (MathError.INTEGER_UNDERFLOW, 0);
        }
    }

    /**
    * @dev Adds two numbers, returns an error on overflow.
    */
    function addUInt(uint a, uint b) internal pure returns (MathError, uint) {
        uint c = a + b;

        if (c >= a) {
            return (MathError.NO_ERROR, c);
        } else {
            return (MathError.INTEGER_OVERFLOW, 0);
        }
    }

    /**
    * @dev add a and b and then subtract c
    */
    function addThenSubUInt(uint a, uint b, uint c) internal pure returns (MathError, uint) {
        (MathError err0, uint sum) = addUInt(a, b);

        if (err0 != MathError.NO_ERROR) {
            return (err0, 0);
        }

        return subUInt(sum, c);
    }
}

File 2 of 10 : ComptrollerInterface.sol
pragma solidity ^0.5.16;

contract ComptrollerInterface {
    /// @notice Indicator that this is a Comptroller contract (for inspection)
    bool public constant isComptroller = true;

    /*** Assets You Are In ***/

    function enterMarkets(address[] calldata cTokens) external returns (uint[] memory);
    function exitMarket(address cToken) external returns (uint);

    /*** Policy Hooks ***/

    function mintAllowed(address cToken, address minter, uint mintAmount) external returns (uint);
    function mintVerify(address cToken, address minter, uint mintAmount, uint mintTokens) external;

    function redeemAllowed(address cToken, address redeemer, uint redeemTokens) external returns (uint);
    function redeemVerify(address cToken, address redeemer, uint redeemAmount, uint redeemTokens) external;

    function borrowAllowed(address cToken, address borrower, uint borrowAmount) external returns (uint);
    function borrowVerify(address cToken, address borrower, uint borrowAmount) external;

    function repayBorrowAllowed(
        address cToken,
        address payer,
        address borrower,
        uint repayAmount) external returns (uint);
    function repayBorrowVerify(
        address cToken,
        address payer,
        address borrower,
        uint repayAmount,
        uint borrowerIndex) external;

    function liquidateBorrowAllowed(
        address cTokenBorrowed,
        address cTokenCollateral,
        address liquidator,
        address borrower,
        uint repayAmount) external returns (uint);
    function liquidateBorrowVerify(
        address cTokenBorrowed,
        address cTokenCollateral,
        address liquidator,
        address borrower,
        uint repayAmount,
        uint seizeTokens) external;

    function seizeAllowed(
        address cTokenCollateral,
        address cTokenBorrowed,
        address liquidator,
        address borrower,
        uint seizeTokens) external returns (uint);
    function seizeVerify(
        address cTokenCollateral,
        address cTokenBorrowed,
        address liquidator,
        address borrower,
        uint seizeTokens) external;

    function transferAllowed(address cToken, address src, address dst, uint transferTokens) external returns (uint);
    function transferVerify(address cToken, address src, address dst, uint transferTokens) external;

    /*** Liquidity/Liquidation Calculations ***/

    function liquidateCalculateSeizeTokens(
        address cTokenBorrowed,
        address cTokenCollateral,
        uint repayAmount) external view returns (uint, uint);
}

File 3 of 10 : EIP20Interface.sol
pragma solidity ^0.5.16;

/**
 * @title ERC 20 Token Standard Interface
 *  https://eips.ethereum.org/EIPS/eip-20
 */
interface EIP20Interface {
    function name() external view returns (string memory);
    function symbol() external view returns (string memory);
    function decimals() external view returns (uint8);

    /**
      * @notice Get the total number of tokens in circulation
      * @return The supply of tokens
      */
    function totalSupply() external view returns (uint256);

    /**
     * @notice Gets the balance of the specified address
     * @param owner The address from which the balance will be retrieved
     * @return The balance
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
      * @notice Transfer `amount` tokens from `msg.sender` to `dst`
      * @param dst The address of the destination account
      * @param amount The number of tokens to transfer
      * @return Whether or not the transfer succeeded
      */
    function transfer(address dst, uint256 amount) external returns (bool success);

    /**
      * @notice Transfer `amount` tokens from `src` to `dst`
      * @param src The address of the source account
      * @param dst The address of the destination account
      * @param amount The number of tokens to transfer
      * @return Whether or not the transfer succeeded
      */
    function transferFrom(address src, address dst, uint256 amount) external returns (bool success);

    /**
      * @notice Approve `spender` to transfer up to `amount` from `src`
      * @dev This will overwrite the approval amount for `spender`
      *  and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)
      * @param spender The address of the account which may transfer tokens
      * @param amount The number of tokens that are approved (-1 means infinite)
      * @return Whether or not the approval succeeded
      */
    function approve(address spender, uint256 amount) external returns (bool success);

    /**
      * @notice Get the current allowance from `owner` for `spender`
      * @param owner The address of the account which owns the tokens to be spent
      * @param spender The address of the account which may transfer tokens
      * @return The number of tokens allowed to be spent (-1 means infinite)
      */
    function allowance(address owner, address spender) external view returns (uint256 remaining);

    event Transfer(address indexed from, address indexed to, uint256 amount);
    event Approval(address indexed owner, address indexed spender, uint256 amount);
}

File 4 of 10 : EIP20NonStandardInterface.sol
pragma solidity ^0.5.16;

/**
 * @title EIP20NonStandardInterface
 * @dev Version of ERC20 with no return values for `transfer` and `transferFrom`
 *  See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca
 */
interface EIP20NonStandardInterface {

    /**
     * @notice Get the total number of tokens in circulation
     * @return The supply of tokens
     */
    function totalSupply() external view returns (uint256);

    /**
     * @notice Gets the balance of the specified address
     * @param owner The address from which the balance will be retrieved
     * @return The balance
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    ///
    /// !!!!!!!!!!!!!!
    /// !!! NOTICE !!! `transfer` does not return a value, in violation of the ERC-20 specification
    /// !!!!!!!!!!!!!!
    ///

    /**
      * @notice Transfer `amount` tokens from `msg.sender` to `dst`
      * @param dst The address of the destination account
      * @param amount The number of tokens to transfer
      */
    function transfer(address dst, uint256 amount) external;

    ///
    /// !!!!!!!!!!!!!!
    /// !!! NOTICE !!! `transferFrom` does not return a value, in violation of the ERC-20 specification
    /// !!!!!!!!!!!!!!
    ///

    /**
      * @notice Transfer `amount` tokens from `src` to `dst`
      * @param src The address of the source account
      * @param dst The address of the destination account
      * @param amount The number of tokens to transfer
      */
    function transferFrom(address src, address dst, uint256 amount) external;

    /**
      * @notice Approve `spender` to transfer up to `amount` from `src`
      * @dev This will overwrite the approval amount for `spender`
      *  and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)
      * @param spender The address of the account which may transfer tokens
      * @param amount The number of tokens that are approved
      * @return Whether or not the approval succeeded
      */
    function approve(address spender, uint256 amount) external returns (bool success);

    /**
      * @notice Get the current allowance from `owner` for `spender`
      * @param owner The address of the account which owns the tokens to be spent
      * @param spender The address of the account which may transfer tokens
      * @return The number of tokens allowed to be spent
      */
    function allowance(address owner, address spender) external view returns (uint256 remaining);

    event Transfer(address indexed from, address indexed to, uint256 amount);
    event Approval(address indexed owner, address indexed spender, uint256 amount);
}

File 5 of 10 : ErrorReporter.sol
pragma solidity ^0.5.16;

contract ComptrollerErrorReporter {
    enum Error {
        NO_ERROR,
        UNAUTHORIZED,
        COMPTROLLER_MISMATCH,
        INSUFFICIENT_SHORTFALL,
        INSUFFICIENT_LIQUIDITY,
        INVALID_CLOSE_FACTOR,
        INVALID_COLLATERAL_FACTOR,
        INVALID_LIQUIDATION_INCENTIVE,
        MARKET_NOT_ENTERED, // no longer possible
        MARKET_NOT_LISTED,
        MARKET_ALREADY_LISTED,
        MATH_ERROR,
        NONZERO_BORROW_BALANCE,
        PRICE_ERROR,
        REJECTION,
        SNAPSHOT_ERROR,
        TOO_MANY_ASSETS,
        TOO_MUCH_REPAY
    }

    enum FailureInfo {
        ACCEPT_ADMIN_PENDING_ADMIN_CHECK,
        ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK,
        EXIT_MARKET_BALANCE_OWED,
        EXIT_MARKET_REJECTION,
        SET_CLOSE_FACTOR_OWNER_CHECK,
        SET_CLOSE_FACTOR_VALIDATION,
        SET_COLLATERAL_FACTOR_OWNER_CHECK,
        SET_COLLATERAL_FACTOR_NO_EXISTS,
        SET_COLLATERAL_FACTOR_VALIDATION,
        SET_COLLATERAL_FACTOR_WITHOUT_PRICE,
        SET_IMPLEMENTATION_OWNER_CHECK,
        SET_LIQUIDATION_INCENTIVE_OWNER_CHECK,
        SET_LIQUIDATION_INCENTIVE_VALIDATION,
        SET_MAX_ASSETS_OWNER_CHECK,
        SET_PENDING_ADMIN_OWNER_CHECK,
        SET_PENDING_IMPLEMENTATION_OWNER_CHECK,
        SET_PRICE_ORACLE_OWNER_CHECK,
        SUPPORT_MARKET_EXISTS,
        SUPPORT_MARKET_OWNER_CHECK,
        SET_PAUSE_GUARDIAN_OWNER_CHECK
    }

    /**
      * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary
      * contract-specific code that enables us to report opaque error codes from upgradeable contracts.
      **/
    event Failure(uint error, uint info, uint detail);

    /**
      * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator
      */
    function fail(Error err, FailureInfo info) internal returns (uint) {
        emit Failure(uint(err), uint(info), 0);

        return uint(err);
    }

    /**
      * @dev use this when reporting an opaque error from an upgradeable collaborator contract
      */
    function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {
        emit Failure(uint(err), uint(info), opaqueError);

        return uint(err);
    }
}

contract TokenErrorReporter {
    enum Error {
        NO_ERROR,
        UNAUTHORIZED,
        BAD_INPUT,
        COMPTROLLER_REJECTION,
        COMPTROLLER_CALCULATION_ERROR,
        INTEREST_RATE_MODEL_ERROR,
        INVALID_ACCOUNT_PAIR,
        INVALID_CLOSE_AMOUNT_REQUESTED,
        INVALID_COLLATERAL_FACTOR,
        MATH_ERROR,
        MARKET_NOT_FRESH,
        MARKET_NOT_LISTED,
        TOKEN_INSUFFICIENT_ALLOWANCE,
        TOKEN_INSUFFICIENT_BALANCE,
        TOKEN_INSUFFICIENT_CASH,
        TOKEN_TRANSFER_IN_FAILED,
        TOKEN_TRANSFER_OUT_FAILED
    }

    /*
     * Note: FailureInfo (but not Error) is kept in alphabetical order
     *       This is because FailureInfo grows significantly faster, and
     *       the order of Error has some meaning, while the order of FailureInfo
     *       is entirely arbitrary.
     */
    enum FailureInfo {
        ACCEPT_ADMIN_PENDING_ADMIN_CHECK,
        ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,
        ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED,
        ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,
        ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,
        ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,
        ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,
        BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,
        BORROW_ACCRUE_INTEREST_FAILED,
        BORROW_CASH_NOT_AVAILABLE,
        BORROW_FRESHNESS_CHECK,
        BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,
        BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,
        BORROW_MARKET_NOT_LISTED,
        BORROW_COMPTROLLER_REJECTION,
        LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED,
        LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED,
        LIQUIDATE_COLLATERAL_FRESHNESS_CHECK,
        LIQUIDATE_COMPTROLLER_REJECTION,
        LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED,
        LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX,
        LIQUIDATE_CLOSE_AMOUNT_IS_ZERO,
        LIQUIDATE_FRESHNESS_CHECK,
        LIQUIDATE_LIQUIDATOR_IS_BORROWER,
        LIQUIDATE_REPAY_BORROW_FRESH_FAILED,
        LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED,
        LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED,
        LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,
        LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER,
        LIQUIDATE_SEIZE_TOO_MUCH,
        MINT_ACCRUE_INTEREST_FAILED,
        MINT_COMPTROLLER_REJECTION,
        MINT_EXCHANGE_CALCULATION_FAILED,
        MINT_EXCHANGE_RATE_READ_FAILED,
        MINT_FRESHNESS_CHECK,
        MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,
        MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,
        MINT_TRANSFER_IN_FAILED,
        MINT_TRANSFER_IN_NOT_POSSIBLE,
        REDEEM_ACCRUE_INTEREST_FAILED,
        REDEEM_COMPTROLLER_REJECTION,
        REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,
        REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED,
        REDEEM_EXCHANGE_RATE_READ_FAILED,
        REDEEM_FRESHNESS_CHECK,
        REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED,
        REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED,
        REDEEM_TRANSFER_OUT_NOT_POSSIBLE,
        REDUCE_RESERVES_ACCRUE_INTEREST_FAILED,
        REDUCE_RESERVES_ADMIN_CHECK,
        REDUCE_RESERVES_CASH_NOT_AVAILABLE,
        REDUCE_RESERVES_FRESH_CHECK,
        REDUCE_RESERVES_VALIDATION,
        REPAY_BEHALF_ACCRUE_INTEREST_FAILED,
        REPAY_BORROW_ACCRUE_INTEREST_FAILED,
        REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,
        REPAY_BORROW_COMPTROLLER_REJECTION,
        REPAY_BORROW_FRESHNESS_CHECK,
        REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,
        REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,
        REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE,
        SET_COLLATERAL_FACTOR_OWNER_CHECK,
        SET_COLLATERAL_FACTOR_VALIDATION,
        SET_COMPTROLLER_OWNER_CHECK,
        SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED,
        SET_INTEREST_RATE_MODEL_FRESH_CHECK,
        SET_INTEREST_RATE_MODEL_OWNER_CHECK,
        SET_MAX_ASSETS_OWNER_CHECK,
        SET_ORACLE_MARKET_NOT_LISTED,
        SET_PENDING_ADMIN_OWNER_CHECK,
        SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED,
        SET_RESERVE_FACTOR_ADMIN_CHECK,
        SET_RESERVE_FACTOR_FRESH_CHECK,
        SET_RESERVE_FACTOR_BOUNDS_CHECK,
        TRANSFER_COMPTROLLER_REJECTION,
        TRANSFER_NOT_ALLOWED,
        TRANSFER_NOT_ENOUGH,
        TRANSFER_TOO_MUCH,
        ADD_RESERVES_ACCRUE_INTEREST_FAILED,
        ADD_RESERVES_FRESH_CHECK,
        ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE
    }

    /**
      * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary
      * contract-specific code that enables us to report opaque error codes from upgradeable contracts.
      **/
    event Failure(uint error, uint info, uint detail);

    /**
      * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator
      */
    function fail(Error err, FailureInfo info) internal returns (uint) {
        emit Failure(uint(err), uint(info), 0);

        return uint(err);
    }

    /**
      * @dev use this when reporting an opaque error from an upgradeable collaborator contract
      */
    function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {
        emit Failure(uint(err), uint(info), opaqueError);

        return uint(err);
    }
}

File 6 of 10 : Exponential.sol
pragma solidity ^0.5.16;

import "./CarefulMath.sol";
import "./ExponentialNoError.sol";

/**
 * @title Exponential module for storing fixed-precision decimals
 * @author Compound
 * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError
 * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.
 *         Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:
 *         `Exp({mantissa: 5100000000000000000})`.
 */
contract Exponential is CarefulMath, ExponentialNoError {
    /**
     * @dev Creates an exponential from numerator and denominator values.
     *      Note: Returns an error if (`num` * 10e18) > MAX_INT,
     *            or if `denom` is zero.
     */
    function getExp(uint num, uint denom) pure internal returns (MathError, Exp memory) {
        (MathError err0, uint scaledNumerator) = mulUInt(num, expScale);
        if (err0 != MathError.NO_ERROR) {
            return (err0, Exp({mantissa: 0}));
        }

        (MathError err1, uint rational) = divUInt(scaledNumerator, denom);
        if (err1 != MathError.NO_ERROR) {
            return (err1, Exp({mantissa: 0}));
        }

        return (MathError.NO_ERROR, Exp({mantissa: rational}));
    }

    /**
     * @dev Adds two exponentials, returning a new exponential.
     */
    function addExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) {
        (MathError error, uint result) = addUInt(a.mantissa, b.mantissa);

        return (error, Exp({mantissa: result}));
    }

    /**
     * @dev Subtracts two exponentials, returning a new exponential.
     */
    function subExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) {
        (MathError error, uint result) = subUInt(a.mantissa, b.mantissa);

        return (error, Exp({mantissa: result}));
    }

    /**
     * @dev Multiply an Exp by a scalar, returning a new Exp.
     */
    function mulScalar(Exp memory a, uint scalar) pure internal returns (MathError, Exp memory) {
        (MathError err0, uint scaledMantissa) = mulUInt(a.mantissa, scalar);
        if (err0 != MathError.NO_ERROR) {
            return (err0, Exp({mantissa: 0}));
        }

        return (MathError.NO_ERROR, Exp({mantissa: scaledMantissa}));
    }

    /**
     * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.
     */
    function mulScalarTruncate(Exp memory a, uint scalar) pure internal returns (MathError, uint) {
        (MathError err, Exp memory product) = mulScalar(a, scalar);
        if (err != MathError.NO_ERROR) {
            return (err, 0);
        }

        return (MathError.NO_ERROR, truncate(product));
    }

    /**
     * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.
     */
    function mulScalarTruncateAddUInt(Exp memory a, uint scalar, uint addend) pure internal returns (MathError, uint) {
        (MathError err, Exp memory product) = mulScalar(a, scalar);
        if (err != MathError.NO_ERROR) {
            return (err, 0);
        }

        return addUInt(truncate(product), addend);
    }

    /**
     * @dev Divide an Exp by a scalar, returning a new Exp.
     */
    function divScalar(Exp memory a, uint scalar) pure internal returns (MathError, Exp memory) {
        (MathError err0, uint descaledMantissa) = divUInt(a.mantissa, scalar);
        if (err0 != MathError.NO_ERROR) {
            return (err0, Exp({mantissa: 0}));
        }

        return (MathError.NO_ERROR, Exp({mantissa: descaledMantissa}));
    }

    /**
     * @dev Divide a scalar by an Exp, returning a new Exp.
     */
    function divScalarByExp(uint scalar, Exp memory divisor) pure internal returns (MathError, Exp memory) {
        /*
          We are doing this as:
          getExp(mulUInt(expScale, scalar), divisor.mantissa)

          How it works:
          Exp = a / b;
          Scalar = s;
          `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale`
        */
        (MathError err0, uint numerator) = mulUInt(expScale, scalar);
        if (err0 != MathError.NO_ERROR) {
            return (err0, Exp({mantissa: 0}));
        }
        return getExp(numerator, divisor.mantissa);
    }

    /**
     * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer.
     */
    function divScalarByExpTruncate(uint scalar, Exp memory divisor) pure internal returns (MathError, uint) {
        (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor);
        if (err != MathError.NO_ERROR) {
            return (err, 0);
        }

        return (MathError.NO_ERROR, truncate(fraction));
    }

    /**
     * @dev Multiplies two exponentials, returning a new exponential.
     */
    function mulExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) {

        (MathError err0, uint doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa);
        if (err0 != MathError.NO_ERROR) {
            return (err0, Exp({mantissa: 0}));
        }

        // We add half the scale before dividing so that we get rounding instead of truncation.
        //  See "Listing 6" and text above it at https://accu.org/index.php/journals/1717
        // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18.
        (MathError err1, uint doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);
        if (err1 != MathError.NO_ERROR) {
            return (err1, Exp({mantissa: 0}));
        }

        (MathError err2, uint product) = divUInt(doubleScaledProductWithHalfScale, expScale);
        // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero.
        assert(err2 == MathError.NO_ERROR);

        return (MathError.NO_ERROR, Exp({mantissa: product}));
    }

    /**
     * @dev Multiplies two exponentials given their mantissas, returning a new exponential.
     */
    function mulExp(uint a, uint b) pure internal returns (MathError, Exp memory) {
        return mulExp(Exp({mantissa: a}), Exp({mantissa: b}));
    }

    /**
     * @dev Multiplies three exponentials, returning a new exponential.
     */
    function mulExp3(Exp memory a, Exp memory b, Exp memory c) pure internal returns (MathError, Exp memory) {
        (MathError err, Exp memory ab) = mulExp(a, b);
        if (err != MathError.NO_ERROR) {
            return (err, ab);
        }
        return mulExp(ab, c);
    }

    /**
     * @dev Divides two exponentials, returning a new exponential.
     *     (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b,
     *  which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)
     */
    function divExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) {
        return getExp(a.mantissa, b.mantissa);
    }
}

File 7 of 10 : ExponentialNoError.sol
pragma solidity ^0.5.16;

/**
 * @title Exponential module for storing fixed-precision decimals
 * @author Compound
 * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places.
 *         Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:
 *         `Exp({mantissa: 5100000000000000000})`.
 */
contract ExponentialNoError {
    uint constant expScale = 1e18;
    uint constant doubleScale = 1e36;
    uint constant halfExpScale = expScale/2;
    uint constant mantissaOne = expScale;

    struct Exp {
        uint mantissa;
    }

    struct Double {
        uint mantissa;
    }

    /**
     * @dev Truncates the given exp to a whole number value.
     *      For example, truncate(Exp{mantissa: 15 * expScale}) = 15
     */
    function truncate(Exp memory exp) pure internal returns (uint) {
        // Note: We are not using careful math here as we're performing a division that cannot fail
        return exp.mantissa / expScale;
    }

    /**
     * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer.
     */
    function mul_ScalarTruncate(Exp memory a, uint scalar) pure internal returns (uint) {
        Exp memory product = mul_(a, scalar);
        return truncate(product);
    }

    /**
     * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.
     */
    function mul_ScalarTruncateAddUInt(Exp memory a, uint scalar, uint addend) pure internal returns (uint) {
        Exp memory product = mul_(a, scalar);
        return add_(truncate(product), addend);
    }

    /**
     * @dev Checks if first Exp is less than second Exp.
     */
    function lessThanExp(Exp memory left, Exp memory right) pure internal returns (bool) {
        return left.mantissa < right.mantissa;
    }

    /**
     * @dev Checks if left Exp <= right Exp.
     */
    function lessThanOrEqualExp(Exp memory left, Exp memory right) pure internal returns (bool) {
        return left.mantissa <= right.mantissa;
    }

    /**
     * @dev Checks if left Exp > right Exp.
     */
    function greaterThanExp(Exp memory left, Exp memory right) pure internal returns (bool) {
        return left.mantissa > right.mantissa;
    }

    /**
     * @dev returns true if Exp is exactly zero
     */
    function isZeroExp(Exp memory value) pure internal returns (bool) {
        return value.mantissa == 0;
    }

    function safe224(uint n, string memory errorMessage) pure internal returns (uint224) {
        require(n < 2**224, errorMessage);
        return uint224(n);
    }

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

    function add_(Exp memory a, Exp memory b) pure internal returns (Exp memory) {
        return Exp({mantissa: add_(a.mantissa, b.mantissa)});
    }

    function add_(Double memory a, Double memory b) pure internal returns (Double memory) {
        return Double({mantissa: add_(a.mantissa, b.mantissa)});
    }

    function add_(uint a, uint b) pure internal returns (uint) {
        return add_(a, b, "addition overflow");
    }

    function add_(uint a, uint b, string memory errorMessage) pure internal returns (uint) {
        uint c = a + b;
        require(c >= a, errorMessage);
        return c;
    }

    function sub_(Exp memory a, Exp memory b) pure internal returns (Exp memory) {
        return Exp({mantissa: sub_(a.mantissa, b.mantissa)});
    }

    function sub_(Double memory a, Double memory b) pure internal returns (Double memory) {
        return Double({mantissa: sub_(a.mantissa, b.mantissa)});
    }

    function sub_(uint a, uint b) pure internal returns (uint) {
        return sub_(a, b, "subtraction underflow");
    }

    function sub_(uint a, uint b, string memory errorMessage) pure internal returns (uint) {
        require(b <= a, errorMessage);
        return a - b;
    }

    function mul_(Exp memory a, Exp memory b) pure internal returns (Exp memory) {
        return Exp({mantissa: mul_(a.mantissa, b.mantissa) / expScale});
    }

    function mul_(Exp memory a, uint b) pure internal returns (Exp memory) {
        return Exp({mantissa: mul_(a.mantissa, b)});
    }

    function mul_(uint a, Exp memory b) pure internal returns (uint) {
        return mul_(a, b.mantissa) / expScale;
    }

    function mul_(Double memory a, Double memory b) pure internal returns (Double memory) {
        return Double({mantissa: mul_(a.mantissa, b.mantissa) / doubleScale});
    }

    function mul_(Double memory a, uint b) pure internal returns (Double memory) {
        return Double({mantissa: mul_(a.mantissa, b)});
    }

    function mul_(uint a, Double memory b) pure internal returns (uint) {
        return mul_(a, b.mantissa) / doubleScale;
    }

    function mul_(uint a, uint b) pure internal returns (uint) {
        return mul_(a, b, "multiplication overflow");
    }

    function mul_(uint a, uint b, string memory errorMessage) pure internal returns (uint) {
        if (a == 0 || b == 0) {
            return 0;
        }
        uint c = a * b;
        require(c / a == b, errorMessage);
        return c;
    }

    function div_(Exp memory a, Exp memory b) pure internal returns (Exp memory) {
        return Exp({mantissa: div_(mul_(a.mantissa, expScale), b.mantissa)});
    }

    function div_(Exp memory a, uint b) pure internal returns (Exp memory) {
        return Exp({mantissa: div_(a.mantissa, b)});
    }

    function div_(uint a, Exp memory b) pure internal returns (uint) {
        return div_(mul_(a, expScale), b.mantissa);
    }

    function div_(Double memory a, Double memory b) pure internal returns (Double memory) {
        return Double({mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa)});
    }

    function div_(Double memory a, uint b) pure internal returns (Double memory) {
        return Double({mantissa: div_(a.mantissa, b)});
    }

    function div_(uint a, Double memory b) pure internal returns (uint) {
        return div_(mul_(a, doubleScale), b.mantissa);
    }

    function div_(uint a, uint b) pure internal returns (uint) {
        return div_(a, b, "divide by zero");
    }

    function div_(uint a, uint b, string memory errorMessage) pure internal returns (uint) {
        require(b > 0, errorMessage);
        return a / b;
    }

    function fraction(uint a, uint b) pure internal returns (Double memory) {
        return Double({mantissa: div_(mul_(a, doubleScale), b)});
    }
}

File 8 of 10 : IINV.sol
pragma solidity ^0.5.16;

interface IINV {
    function balanceOf(address) external view returns (uint);
    function transfer(address,uint) external returns (bool);
    function transferFrom(address,address,uint) external returns (bool);
    function allowance(address,address) external view returns (uint);
    function delegates(address) external view returns (address);
    function delegate(address) external;
}

File 9 of 10 : SafeMath.sol
pragma solidity ^0.5.16;

// From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/Math.sol
// Subject to the MIT license.

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

        return c;
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting with custom message on overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, errorMessage);

        return c;
    }

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

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

        return c;
    }

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

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

        return c;
    }

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

        uint256 c = a * b;
        require(c / a == b, errorMessage);

        return c;
    }

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

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

        return c;
    }

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

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

File 10 of 10 : XINV.sol
pragma solidity ^0.5.16;

import "./ComptrollerInterface.sol";
import "./ErrorReporter.sol";
import "./Exponential.sol";
import "./EIP20Interface.sol";
import "./EIP20NonStandardInterface.sol";
import "./SafeMath.sol";
import "./Governance/IINV.sol";
/**
 * @title xINV Core contract
 * @notice Abstract base for xINV
 * @author Inverse Finance
 */
contract xInvCore is Exponential, TokenErrorReporter {

    /**
     * @dev Guard variable for re-entrancy checks
     */
    bool internal _notEntered;

    /**
     * @notice EIP-20 token name for this token
     */
    string public name;

    /**
     * @notice EIP-20 token symbol for this token
     */
    string public symbol;

    /**
     * @notice EIP-20 token decimals for this token
     */
    uint8 public decimals;

    /**
     * @notice Administrator for this contract
     */
    address payable public admin;

    /**
     * @notice Pending administrator for this contract
     */
    address payable public pendingAdmin;

    /**
     * @notice Contract which oversees inter-cToken operations
     */
    ComptrollerInterface public comptroller;

    /**
     * @notice Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)
     */
    uint internal initialExchangeRateMantissa;

    /**
     * @notice Block number that interest was last accrued at
     */
    uint public accrualBlockNumber;

    /**
     * @notice Total number of tokens in circulation
     */
    uint public totalSupply;

    uint public rewardPerBlock;

    address public rewardTreasury;

    uint public constant borrowIndex = 1 ether; // for compatibility with Comptroller

    /**
     * @notice Official record of token balances for each account
     */
    mapping (address => uint) internal accountTokens;

    /**
     * @notice Indicator that this is a CToken contract (for inspection)
     */
    bool public constant isCToken = true;

    /*** Market Events ***/

    /**
     * @notice Event emitted when tokens are minted
     */
    event Mint(address minter, uint mintAmount, uint mintTokens);

    /**
     * @notice Event emitted when tokens are redeemed
     */
    event Redeem(address redeemer, uint redeemAmount, uint redeemTokens);

    /*** Admin Events ***/

    /**
     * @notice Event emitted when pendingAdmin is changed
     */
    event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);

    /**
     * @notice Event emitted when pendingAdmin is accepted, which means admin is updated
     */
    event NewAdmin(address oldAdmin, address newAdmin);

    /**
     * @notice Event emitted when comptroller is changed
     */
    event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller);

    /**
     * @notice Event emitted when reward treasury is changed
     */
    event NewRewardTreasury(address oldRewardTreasury, address newRewardTreasury);

    /**
     * @notice Event emitted when reward per block is changed
     */
    event NewRewardPerBlock(uint oldRewardPerBlock, uint newRewardPerBlock);

    /**
     * @notice EIP20 Transfer event
     */
    event Transfer(address indexed from, address indexed to, uint amount);

    /**
     * @notice Failure event
     */
    event Failure(uint error, uint info, uint detail);

    /**
     * @notice Initialize the money market
     * @param comptroller_ The address of the Comptroller
     * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18
     * @param name_ EIP-20 name of this token
     * @param symbol_ EIP-20 symbol of this token
     * @param decimals_ EIP-20 decimal precision of this token
     */
    function initialize(ComptrollerInterface comptroller_,
                        uint initialExchangeRateMantissa_,
                        uint rewardPerBlock_,
                        address rewardTreasury_,
                        string memory name_,
                        string memory symbol_,
                        uint8 decimals_) internal {
        require(msg.sender == admin, "only admin may initialize the market");
        require(accrualBlockNumber == 0, "market may only be initialized once");

        // Set initial exchange rate
        initialExchangeRateMantissa = initialExchangeRateMantissa_;
        require(initialExchangeRateMantissa > 0, "initial exchange rate must be greater than zero.");

        // Set the comptroller
        uint err = _setComptroller(comptroller_);
        require(err == uint(Error.NO_ERROR), "setting comptroller failed");

        name = name_;
        symbol = symbol_;
        decimals = decimals_;
        accrualBlockNumber = getBlockNumber();
        rewardPerBlock = rewardPerBlock_;
        rewardTreasury = rewardTreasury_;

        // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund)
        _notEntered = true;
    }
    
    /**
     * @notice Get the token balance of the `owner`
     * @param owner The address of the account to query
     * @return The number of tokens owned by `owner`
     */
    function balanceOf(address owner) external view returns (uint256) {
        return accountTokens[owner];
    }

    /**
     * @notice Get the underlying balance of the `owner`
     * @param owner The address of the account to query
     * @return The amount of underlying owned by `owner`
     */
    function balanceOfUnderlying(address owner) external returns (uint) {
        Exp memory exchangeRate = Exp({mantissa: exchangeRateCurrent()});
        (MathError mErr, uint balance) = mulScalarTruncate(exchangeRate, accountTokens[owner]);
        require(mErr == MathError.NO_ERROR, "balance could not be calculated");
        return balance;
    }

    /**
     * @notice Get a snapshot of the account's balances, and the cached exchange rate
     * @dev This is used by comptroller to more efficiently perform liquidity checks.
     * @param account Address of the account to snapshot
     * @return (possible error, token balance, borrow balance, exchange rate mantissa)
     */
    function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) {
        uint cTokenBalance = accountTokens[account];
        uint exchangeRateMantissa;

        MathError mErr;

        (mErr, exchangeRateMantissa) = exchangeRateStoredInternal();
        if (mErr != MathError.NO_ERROR) {
            return (uint(Error.MATH_ERROR), 0, 0, 0);
        }

        return (uint(Error.NO_ERROR), cTokenBalance, 0, exchangeRateMantissa);
    }

    /**
     * @dev Function to simply retrieve block number
     *  This exists mainly for inheriting test contracts to stub this result.
     */
    function getBlockNumber() internal view returns (uint) {
        return block.number;
    }

    /**
     * @return Calculated exchange rate scaled by 1e18
     */
    function exchangeRateCurrent() public nonReentrant returns (uint) {
        require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed");
        return exchangeRateStored();
    }

    /**
     * @notice Calculates the exchange rate from the underlying to the CToken
     * @return Calculated exchange rate scaled by 1e18
     */
    function exchangeRateStored() public view returns (uint) {
        (MathError err, uint result) = exchangeRateStoredInternal();
        require(err == MathError.NO_ERROR, "exchangeRateStored: exchangeRateStoredInternal failed");
        return result;
    }

    /**
     * @notice Calculates the exchange rate from the underlying to the CToken
     * @return (error code, calculated exchange rate scaled by 1e18)
     */
    function exchangeRateStoredInternal() internal view returns (MathError, uint) {
        uint _totalSupply = totalSupply;
        if (_totalSupply == 0) {
            /*
             * If there are no tokens minted:
             *  exchangeRate = initialExchangeRate
             */
            return (MathError.NO_ERROR, initialExchangeRateMantissa);
        } else {
            /*
             * Otherwise:
             *  exchangeRate = totalCash / totalSupply
             */
            uint totalCash = getCashPrior();
            Exp memory exchangeRate;
            MathError mathErr;

            (mathErr, exchangeRate) = getExp(totalCash, _totalSupply);
            if (mathErr != MathError.NO_ERROR) {
                return (mathErr, 0);
            }

            return (MathError.NO_ERROR, exchangeRate.mantissa);
        }
    }

    /**
     * @notice Get cash balance of this cToken in the underlying asset
     * @return The quantity of underlying asset owned by this contract
     */
    function getCash() external view returns (uint) {
        return getCashPrior();
    }

    // brings rewards from treasury into this contract
    function accrueInterest() public returns (uint) {
        /* Remember the initial block number */
        uint currentBlockNumber = getBlockNumber();
        uint accrualBlockNumberPrior = accrualBlockNumber;

        /* Short-circuit accumulating 0 interest */
        if (accrualBlockNumberPrior == currentBlockNumber) {
            return uint(Error.NO_ERROR);
        }

        /* Calculate the number of blocks elapsed since the last accrual */
        (MathError mathErr, uint blockDelta) = subUInt(currentBlockNumber, accrualBlockNumberPrior);
        require(mathErr == MathError.NO_ERROR, "could not calculate block delta");
        
        /* Calculate accumulated reward amount */
        uint reward;
        
        (mathErr, reward) = mulUInt(rewardPerBlock, blockDelta);
        require(mathErr == MathError.NO_ERROR, "could not calculate reward");

        if(totalSupply > 0 && rewardTreasury != address(0) && canTransferIn(rewardTreasury, reward)) {
            doTransferIn(rewardTreasury, reward);
        }

        /////////////////////////
        // EFFECTS & INTERACTIONS
        // (No safe failures beyond this point)

        accrualBlockNumber = currentBlockNumber;

        return uint(Error.NO_ERROR);
    }

    /**
     * @notice Sender supplies assets into the market and receives cTokens in exchange
     * @param mintAmount The amount of the underlying asset to supply
     * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.
     */
    function mintInternal(uint mintAmount) internal nonReentrant returns (uint, uint) {
        uint error = accrueInterest();
        if (error != uint(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed
            return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0);
        }
        // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to
        return mintFresh(msg.sender, mintAmount);
    }

    struct MintLocalVars {
        Error err;
        MathError mathErr;
        uint exchangeRateMantissa;
        uint mintTokens;
        uint totalSupplyNew;
        uint accountTokensNew;
        uint actualMintAmount;
    }

    /**
     * @notice User supplies assets into the market and receives cTokens in exchange
     * @param minter The address of the account which is supplying the assets
     * @param mintAmount The amount of the underlying asset to supply
     * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount.
     */
    function mintFresh(address minter, uint mintAmount) internal returns (uint, uint) {
        /* Fail if mint not allowed */
        uint allowed = comptroller.mintAllowed(address(this), minter, mintAmount);
        if (allowed != 0) {
            return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0);
        }

        MintLocalVars memory vars;

        (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();
        if (vars.mathErr != MathError.NO_ERROR) {
            return (failOpaque(Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)), 0);
        }

        /////////////////////////
        // EFFECTS & INTERACTIONS
        // (No safe failures beyond this point)

        /*
         *  We call `doTransferIn` for the minter and the mintAmount.
         *  Note: The cToken must handle variations between ERC-20 and ETH underlying.
         *  `doTransferIn` reverts if anything goes wrong, since we can't be sure if
         *  side-effects occurred. The function returns the amount actually transferred,
         *  in case of a fee. On success, the cToken holds an additional `actualMintAmount`
         *  of cash.
         */
        vars.actualMintAmount = doTransferIn(minter, mintAmount);

        /*
         * We get the current exchange rate and calculate the number of cTokens to be minted:
         *  mintTokens = actualMintAmount / exchangeRate
         */

        (vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(vars.actualMintAmount, Exp({mantissa: vars.exchangeRateMantissa}));
        require(vars.mathErr == MathError.NO_ERROR, "MINT_EXCHANGE_CALCULATION_FAILED");

        /*
         * We calculate the new total supply of cTokens and minter token balance, checking for overflow:
         *  totalSupplyNew = totalSupply + mintTokens
         *  accountTokensNew = accountTokens[minter] + mintTokens
         */
        (vars.mathErr, vars.totalSupplyNew) = addUInt(totalSupply, vars.mintTokens);
        require(vars.mathErr == MathError.NO_ERROR, "MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED");
        require(vars.totalSupplyNew < 2**96, "MINT_NEW_TOTAL_SUPPLY_OVER_CAPACITY");

        (vars.mathErr, vars.accountTokensNew) = addUInt(accountTokens[minter], vars.mintTokens);
        require(vars.mathErr == MathError.NO_ERROR, "MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED");

        /* We write previously calculated values into storage */
        totalSupply = vars.totalSupplyNew;
        accountTokens[minter] = vars.accountTokensNew;

        /* We emit a Mint event, and a Transfer event */
        emit Mint(minter, vars.actualMintAmount, vars.mintTokens);
        emit Transfer(address(this), minter, vars.mintTokens);

        /* we move delegates */
        _moveDelegates(address(0), delegates[minter], uint96(vars.mintTokens)); // NOTE: Check for potential overflows due to conversion from uint256 to uint96

        /* We call the defense hook */
        comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens);

        return (uint(Error.NO_ERROR), vars.actualMintAmount);
    }

    /**
     * @notice Sender redeems cTokens in exchange for the underlying asset
     * @param redeemTokens The number of cTokens to redeem into underlying
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function redeemInternal(uint redeemTokens, bool useEscrow) internal nonReentrant returns (uint) {
        uint error = accrueInterest();
        if (error != uint(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed
            return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED);
        }
        // redeemFresh emits redeem-specific logs on errors, so we don't need to
        return redeemFresh(msg.sender, redeemTokens, 0, useEscrow);
    }

    /**
     * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset
     * @param redeemAmount The amount of underlying to receive from redeeming cTokens
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function redeemUnderlyingInternal(uint redeemAmount, bool useEscrow) internal nonReentrant returns (uint) {
        uint error = accrueInterest();
        if (error != uint(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed
            return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED);
        }
        // redeemFresh emits redeem-specific logs on errors, so we don't need to
        return redeemFresh(msg.sender, 0, redeemAmount, useEscrow);
    }

    struct RedeemLocalVars {
        Error err;
        MathError mathErr;
        uint exchangeRateMantissa;
        uint redeemTokens;
        uint redeemAmount;
        uint totalSupplyNew;
        uint accountTokensNew;
    }

    /**
     * @notice User redeems cTokens in exchange for the underlying asset
     * @param redeemer The address of the account which is redeeming the tokens
     * @param redeemTokensIn The number of cTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero)
     * @param redeemAmountIn The number of underlying tokens to receive from redeeming cTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero)
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function redeemFresh(address payable redeemer, uint redeemTokensIn, uint redeemAmountIn, bool useEscrow) internal returns (uint) {
        require(redeemTokensIn == 0 || redeemAmountIn == 0, "one of redeemTokensIn or redeemAmountIn must be zero");

        RedeemLocalVars memory vars;

        /* exchangeRate = invoke Exchange Rate Stored() */
        (vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();
        if (vars.mathErr != MathError.NO_ERROR) {
            return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr));
        }

        /* If redeemTokensIn > 0: */
        if (redeemTokensIn > 0) {
            /*
             * We calculate the exchange rate and the amount of underlying to be redeemed:
             *  redeemTokens = redeemTokensIn
             *  redeemAmount = redeemTokensIn x exchangeRateCurrent
             */
            vars.redeemTokens = redeemTokensIn;

            (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(Exp({mantissa: vars.exchangeRateMantissa}), redeemTokensIn);
            if (vars.mathErr != MathError.NO_ERROR) {
                return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint(vars.mathErr));
            }
        } else {
            /*
             * We get the current exchange rate and calculate the amount to be redeemed:
             *  redeemTokens = redeemAmountIn / exchangeRate
             *  redeemAmount = redeemAmountIn
             */

            (vars.mathErr, vars.redeemTokens) = divScalarByExpTruncate(redeemAmountIn, Exp({mantissa: vars.exchangeRateMantissa}));
            if (vars.mathErr != MathError.NO_ERROR) {
                return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED, uint(vars.mathErr));
            }

            vars.redeemAmount = redeemAmountIn;
        }

        /* Fail if redeem not allowed */
        uint allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens);
        if (allowed != 0) {
            return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REDEEM_COMPTROLLER_REJECTION, allowed);
        }

        /*
         * We calculate the new total supply and redeemer balance, checking for underflow:
         *  totalSupplyNew = totalSupply - redeemTokens
         *  accountTokensNew = accountTokens[redeemer] - redeemTokens
         */
        (vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens);
        if (vars.mathErr != MathError.NO_ERROR) {
            return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, uint(vars.mathErr));
        }

        (vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens);
        if (vars.mathErr != MathError.NO_ERROR) {
            return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, uint(vars.mathErr));
        }

        /* Fail gracefully if protocol has insufficient cash */
        if (getCashPrior() < vars.redeemAmount) {
            return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE);
        }

        /////////////////////////
        // EFFECTS & INTERACTIONS
        // (No safe failures beyond this point)

        /*
         * We invoke doTransferOut for the redeemer and the redeemAmount.
         *  Note: The cToken must handle variations between ERC-20 and ETH underlying.
         *  On success, the cToken has redeemAmount less of cash.
         *  doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.
         */
        doTransferOut(redeemer, vars.redeemAmount, useEscrow);

        /* We write previously calculated values into storage */
        totalSupply = vars.totalSupplyNew;
        accountTokens[redeemer] = vars.accountTokensNew;

        /* We emit a Transfer event, and a Redeem event */
        emit Transfer(redeemer, address(this), vars.redeemTokens);
        emit Redeem(redeemer, vars.redeemAmount, vars.redeemTokens);

        /* We move delegates */
        _moveDelegates(delegates[redeemer], address(0), uint96(vars.redeemTokens)); // NOTE: Check for potential overflows due to conversion from uint256 to uint96

        /* We call the defense hook */
        comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens);

        return uint(Error.NO_ERROR);
    }

    /**
     * @notice Transfers collateral tokens (this market) to the liquidator.
     * @dev Will fail unless called by another cToken during the process of liquidation.
     *  Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter.
     * @param liquidator The account receiving seized collateral
     * @param borrower The account having collateral seized
     * @param seizeTokens The number of cTokens to seize
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function seize(address liquidator, address borrower, uint seizeTokens) external nonReentrant returns (uint) {
        return seizeInternal(msg.sender, liquidator, borrower, seizeTokens);
    }

    /**
     * @notice Transfers collateral tokens (this market) to the liquidator.
     * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken.
     *  Its absolutely critical to use msg.sender as the seizer cToken and not a parameter.
     * @param seizerToken The contract seizing the collateral (i.e. borrowed cToken)
     * @param liquidator The account receiving seized collateral
     * @param borrower The account having collateral seized
     * @param seizeTokens The number of cTokens to seize
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function seizeInternal(address seizerToken, address liquidator, address borrower, uint seizeTokens) internal returns (uint) {
        /* Fail if seize not allowed */
        uint allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens);
        if (allowed != 0) {
            return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed);
        }

        /* Fail if borrower = liquidator */
        if (borrower == liquidator) {
            return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER);
        }

        MathError mathErr;
        uint borrowerTokensNew;
        uint liquidatorTokensNew;

        /*
         * We calculate the new borrower and liquidator token balances, failing on underflow/overflow:
         *  borrowerTokensNew = accountTokens[borrower] - seizeTokens
         *  liquidatorTokensNew = accountTokens[liquidator] + seizeTokens
         */
        (mathErr, borrowerTokensNew) = subUInt(accountTokens[borrower], seizeTokens);
        if (mathErr != MathError.NO_ERROR) {
            return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint(mathErr));
        }

        (mathErr, liquidatorTokensNew) = addUInt(accountTokens[liquidator], seizeTokens);
        if (mathErr != MathError.NO_ERROR) {
            return failOpaque(Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint(mathErr));
        }

        /////////////////////////
        // EFFECTS & INTERACTIONS
        // (No safe failures beyond this point)

        /* We write the previously calculated values into storage */
        accountTokens[borrower] = borrowerTokensNew;
        accountTokens[liquidator] = liquidatorTokensNew;

        /* Emit a Transfer event */
        emit Transfer(borrower, liquidator, seizeTokens);

        /* We move delegates to liquidator although they'll be burned in the redeemFresh call after */
        _moveDelegates(delegates[borrower], delegates[liquidator], uint96(seizeTokens)); // NOTE: Check for potential overflows due to conversion from uint256 to uint96

        /* We call the defense hook */
        comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens);

        // Auto-redeem liquidator and skip escrow (cast liquidator to payable)
        redeemFresh(address(uint160(liquidator)), seizeTokens, 0, false);

        return uint(Error.NO_ERROR);
    }


    /*** Admin Functions ***/

    /**
      * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
      * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
      * @param newPendingAdmin New pending admin.
      * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
      */
    function _setPendingAdmin(address payable newPendingAdmin) external returns (uint) {
        // Check caller = admin
        if (msg.sender != admin) {
            return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);
        }

        // Save current value, if any, for inclusion in log
        address oldPendingAdmin = pendingAdmin;

        // Store pendingAdmin with value newPendingAdmin
        pendingAdmin = newPendingAdmin;

        // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)
        emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);

        return uint(Error.NO_ERROR);
    }

    /**
      * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin
      * @dev Admin function for pending admin to accept role and update admin
      * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
      */
    function _acceptAdmin() external returns (uint) {
        // Check caller is pendingAdmin and pendingAdmin ≠ address(0)
        if (msg.sender != pendingAdmin || msg.sender == address(0)) {
            return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);
        }

        // Save current values for inclusion in log
        address oldAdmin = admin;
        address oldPendingAdmin = pendingAdmin;

        // Store admin with value pendingAdmin
        admin = pendingAdmin;

        // Clear the pending value
        pendingAdmin = address(0);

        emit NewAdmin(oldAdmin, admin);
        emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);

        return uint(Error.NO_ERROR);
    }

    /**
      * @notice Sets a new comptroller for the market
      * @dev Admin function to set a new comptroller
      * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
      */
    function _setComptroller(ComptrollerInterface newComptroller) public returns (uint) {
        // Check caller is admin
        if (msg.sender != admin) {
            return fail(Error.UNAUTHORIZED, FailureInfo.SET_COMPTROLLER_OWNER_CHECK);
        }

        ComptrollerInterface oldComptroller = comptroller;
        // Ensure invoke comptroller.isComptroller() returns true
        require(newComptroller.isComptroller(), "marker method returned false");

        // Set market's comptroller to newComptroller
        comptroller = newComptroller;

        // Emit NewComptroller(oldComptroller, newComptroller)
        emit NewComptroller(oldComptroller, newComptroller);

        return uint(Error.NO_ERROR);
    }

    function _setRewardTreasury(address newRewardTreasury) public returns (uint) {
        // Check caller is admin
        if (msg.sender != admin) {
            return fail(Error.UNAUTHORIZED, FailureInfo.SET_COMPTROLLER_OWNER_CHECK);
        }
        
        address oldRewardTreasury = rewardTreasury;
        rewardTreasury = newRewardTreasury; // it's acceptable to set it as address(0)

        emit NewRewardTreasury(oldRewardTreasury, newRewardTreasury);
    }

    function _setRewardPerBlock(uint newRewardPerBlock) public returns (uint) {
        // Check caller is admin
        if (msg.sender != admin) {
            return fail(Error.UNAUTHORIZED, FailureInfo.SET_COMPTROLLER_OWNER_CHECK);
        }

        uint oldRewardPerBlock = rewardPerBlock;
        rewardPerBlock = newRewardPerBlock; // it's acceptable to set it as 0

        emit NewRewardPerBlock(oldRewardPerBlock, newRewardPerBlock);

    }

    /*** Safe Token ***/

    /**
     * @notice Gets balance of this contract in terms of the underlying
     * @dev This excludes the value of the current message, if any
     * @return The quantity of underlying owned by this contract
     */
    function getCashPrior() internal view returns (uint);

    /**
     * @dev Performs a transfer in, reverting upon failure. Returns the amount actually transferred to the protocol, in case of a fee.
     *  This may revert due to insufficient balance or insufficient allowance.
     */
    function doTransferIn(address from, uint amount) internal returns (uint);

    function canTransferIn(address from, uint amount) internal view returns (bool);
    
    /**
     * @dev Performs a transfer out, ideally returning an explanatory error code upon failure tather than reverting.
     *  If caller has not called checked protocol's balance, may revert due to insufficient cash held in the contract.
     *  If caller has checked protocol's balance, and verified it is >= amount, this should not revert in normal conditions.
     */
    function doTransferOut(address payable to, uint amount, bool useEscrow) internal;


    /*** Reentrancy Guard ***/

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     */
    modifier nonReentrant() {
        require(_notEntered, "re-entered");
        _notEntered = false;
        _;
        _notEntered = true; // get a gas-refund post-Istanbul
    }

    /*** Delegation ***/
    
    /// @notice A record of each accounts delegate
    mapping (address => address) public delegates;

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

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

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

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

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

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

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

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

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

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

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

    function _delegate(address delegator, address delegatee) internal {
        address currentDelegate = delegates[delegator];
        uint96 delegatorBalance = uint96(accountTokens[delegator]); // NOTE: Check for potential overflows due to conversion from uint256 to uint96
        delegates[delegator] = delegatee;

        emit DelegateChanged(delegator, currentDelegate, delegatee);

        _moveDelegates(currentDelegate, delegatee, delegatorBalance);
    }

    function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal {
        if (srcRep != dstRep && amount > 0) {
            if (srcRep != address(0)) {
                uint32 srcRepNum = numCheckpoints[srcRep];
                uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
                uint96 srcRepNew = sub96(srcRepOld, amount, "INV::_moveVotes: vote amount underflows");
                _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
            }

            if (dstRep != address(0)) {
                uint32 dstRepNum = numCheckpoints[dstRep];
                uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
                uint96 dstRepNew = add96(dstRepOld, amount, "INV::_moveVotes: vote amount overflows");
                _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
            }
        }
    }

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

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

      emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
    }

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

    function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {
        uint96 c = a + b;
        require(c >= a, errorMessage);
        return c;
    }

    function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {
        require(b <= a, errorMessage);
        return a - b;
    }
}

contract TimelockEscrow {
    using SafeMath for uint;

    address public underlying;
    address public governance;
    address public market;
    uint public duration = 10 days;
    mapping (address => EscrowData) public pendingWithdrawals;

    struct EscrowData {
        uint withdrawalTimestamp;
        uint amount;
    }

    constructor(address underlying_, address governance_) public {
        underlying = underlying_;
        governance = governance_;
        market = msg.sender;
    }

    // set to 0 to send funds directly to users
    function _setEscrowDuration(uint duration_) public {
        require(msg.sender == governance, "only governance can set escrow duration");
        duration = duration_;
    }

    function _setGov(address governance_) public {
        require(msg.sender == governance, "only governance can set its new address");
        governance = governance_;
    }

    /**
     * @notice assumes funds were already sent to this contract by the market. Resets escrow timelock on each withdrawal
     */
    function escrow(address user, uint amount) public {
        require(msg.sender == market, "only market can escrow");
        if(duration > 0) {
            EscrowData memory withdrawal = pendingWithdrawals[user];
            pendingWithdrawals[user] = EscrowData({
                // we set the future withdrawal timestamp based on current `duration` to avoid applying future `duration` changes to existing withdrawals in the event of a governance attack
                withdrawalTimestamp: block.timestamp + duration,
                amount: withdrawal.amount.add(amount)
            });
            emit Escrow(user, block.timestamp + duration, amount);
        } else { // if duration is 0, we send the funds directly to the user
            EIP20Interface token = EIP20Interface(underlying);
            token.transfer(user, amount);
        }
    }

    /**
     * @notice returns user withdrawable amount
     */
    function withdrawable(address user) public view returns (uint amount) {
        EscrowData memory withdrawal = pendingWithdrawals[user];
        if(withdrawal.withdrawalTimestamp <= block.timestamp) {
            amount = withdrawal.amount;
        }
    }

    function withdraw() public {
        uint amount = withdrawable(msg.sender);
        require(amount > 0, "Nothing to withdraw");
        EIP20Interface token = EIP20Interface(underlying);
        delete pendingWithdrawals[msg.sender];
        token.transfer(msg.sender, amount);
        emit Withdraw(msg.sender, amount);
    }

    event Escrow(address to, uint withdrawalTimestamp, uint amount);
    event Withdraw(address to, uint amount);
}

/**
 * @title xINV contract
 * @notice wraps INV token
 * @author Inverse Finance
 */
contract XINV is xInvCore {

    address public underlying;
    TimelockEscrow public escrow;

    /**
     * @notice Construct the xINV market
     * @param underlying_ The address of the underlying asset
     * @param comptroller_ The address of the Comptroller
     * @param name_ ERC-20 name of this token
     * @param symbol_ ERC-20 symbol of this token
     * @param decimals_ ERC-20 decimal precision of this token
     * @param admin_ Address of the administrator of this token
     */
    constructor(address underlying_,
                ComptrollerInterface comptroller_,
                uint rewardPerBlock_,        
                address rewardTreasury_,
                string memory name_,
                string memory symbol_,
                uint8 decimals_,
                address payable admin_) public {
        // Creator of the contract is admin during initialization
        admin = msg.sender;

        // CToken initialize does the bulk of the work
        super.initialize(comptroller_, 1e18, rewardPerBlock_, rewardTreasury_, name_, symbol_, decimals_);

        // Set underlying and sanity check it
        underlying = underlying_;
        EIP20Interface(underlying).totalSupply();

        // Set the proper admin now that initialization is done
        admin = admin_;

        // Create escrow contract
        escrow = new TimelockEscrow(underlying_, admin_);
    }

    /*** User Interface ***/

    /**
     * @notice Sync user delegate from INV
     * @param user Address to sync
     */
    function syncDelegate(address user) public {
        address invDelegate = IINV(underlying).delegates(user);
        _delegate(user, invDelegate);
    }

    /**
     * @notice Sender supplies assets into the market and receives cTokens in exchange
     * @param mintAmount The amount of the underlying asset to supply
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function mint(uint mintAmount) external returns (uint) {
        (uint err,) = mintInternal(mintAmount);
        
        /* we inherit delegate from INV */
        address invDelegate = IINV(underlying).delegates(msg.sender);
        if(delegates[msg.sender] != invDelegate) {
            _delegate(msg.sender, invDelegate);
        }
        return err;
    }

    /**
     * @notice Sender redeems cTokens in exchange for the underlying asset
     * @param redeemTokens The number of cTokens to redeem into underlying
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function redeem(uint redeemTokens) external returns (uint) {
        return redeemInternal(redeemTokens, true);
    }

    /**
     * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset
     * @param redeemAmount The amount of underlying to redeem
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function redeemUnderlying(uint redeemAmount) external returns (uint) {
        return redeemUnderlyingInternal(redeemAmount, true);
    }

    /*** Safe Token ***/

    /**
     * @notice Gets balance of this contract in terms of the underlying
     * @dev This excludes the value of the current message, if any
     * @return The quantity of underlying tokens owned by this contract
     */
    function getCashPrior() internal view returns (uint) {
        EIP20Interface token = EIP20Interface(underlying);
        return token.balanceOf(address(this));
    }

    /**
     * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case.
     *      This will revert due to insufficient balance or insufficient allowance.
     *      This function returns the actual amount received,
     *      which may be less than `amount` if there is a fee attached to the transfer.
     *
     *      Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.
     *            See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca
     */
    function doTransferIn(address from, uint amount) internal returns (uint) {
        EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying);
        uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this));
        token.transferFrom(from, address(this), amount);

        bool success;
        assembly {
            switch returndatasize()
                case 0 {                       // This is a non-standard ERC-20
                    success := not(0)          // set success to true
                }
                case 32 {                      // This is a compliant ERC-20
                    returndatacopy(0, 0, 32)
                    success := mload(0)        // Set `success = returndata` of external call
                }
                default {                      // This is an excessively non-compliant ERC-20, revert.
                    revert(0, 0)
                }
        }
        require(success, "TOKEN_TRANSFER_IN_FAILED");

        // Calculate the amount that was *actually* transferred
        uint balanceAfter = EIP20Interface(underlying).balanceOf(address(this));
        require(balanceAfter >= balanceBefore, "TOKEN_TRANSFER_IN_OVERFLOW");
        return balanceAfter - balanceBefore;   // underflow already checked above, just subtract
    }

    /**
     * @dev returns true if `from` has sufficient allowance and balance to to send `amount` to this address
     */
    function canTransferIn(address from, uint amount) internal view returns (bool) {
        EIP20Interface token = EIP20Interface(underlying);
        uint balance = token.balanceOf(from);
        uint allowance = token.allowance(from, address(this));
        return balance >= amount && allowance >= amount;
    }

    /**
     * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory
     *      error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to
     *      insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified
     *      it is >= amount, this should not revert in normal conditions.
     *
     *      Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value.
     *            See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca
     */
    function doTransferOut(address payable to, uint amount, bool useEscrow) internal {
        EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying);
        if(useEscrow) {
            token.transfer(address(escrow), amount);
        } else {
            token.transfer(to, amount);
        }

        bool success;
        assembly {
            switch returndatasize()
                case 0 {                      // This is a non-standard ERC-20
                    success := not(0)          // set success to true
                }
                case 32 {                     // This is a complaint ERC-20
                    returndatacopy(0, 0, 32)
                    success := mload(0)        // Set `success = returndata` of external call
                }
                default {                     // This is an excessively non-compliant ERC-20, revert.
                    revert(0, 0)
                }
        }
        require(success, "TOKEN_TRANSFER_OUT_FAILED");
        if(useEscrow) {
            escrow.escrow(to, amount);
        }
    }

    function _setTimelockEscrow(TimelockEscrow newTimelockEscrow) public returns (uint) {
        require(newTimelockEscrow.market() == address(this), "sanity check: newTimelockEscrow must use this market");
        // Check caller is admin
        if (msg.sender != admin) {
            return fail(Error.UNAUTHORIZED, FailureInfo.SET_COMPTROLLER_OWNER_CHECK);
        }
        
        TimelockEscrow oldTimelockEscrow = escrow;
        escrow = newTimelockEscrow;

        emit NewTimelockEscrow(oldTimelockEscrow, newTimelockEscrow);
    }

    event NewTimelockEscrow(TimelockEscrow oldTimelockEscrow, TimelockEscrow newTimelockEscrow);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"underlying_","type":"address"},{"internalType":"contract ComptrollerInterface","name":"comptroller_","type":"address"},{"internalType":"uint256","name":"rewardPerBlock_","type":"uint256"},{"internalType":"address","name":"rewardTreasury_","type":"address"},{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"},{"internalType":"address payable","name":"admin_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"fromDelegate","type":"address"},{"indexed":true,"internalType":"address","name":"toDelegate","type":"address"}],"name":"DelegateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"indexed":false,"internalType":"uint256","name":"previousBalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newBalance","type":"uint256"}],"name":"DelegateVotesChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"error","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"info","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"detail","type":"uint256"}],"name":"Failure","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"minter","type":"address"},{"indexed":false,"internalType":"uint256","name":"mintAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mintTokens","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"NewAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract ComptrollerInterface","name":"oldComptroller","type":"address"},{"indexed":false,"internalType":"contract ComptrollerInterface","name":"newComptroller","type":"address"}],"name":"NewComptroller","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldPendingAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newPendingAdmin","type":"address"}],"name":"NewPendingAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldRewardPerBlock","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newRewardPerBlock","type":"uint256"}],"name":"NewRewardPerBlock","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldRewardTreasury","type":"address"},{"indexed":false,"internalType":"address","name":"newRewardTreasury","type":"address"}],"name":"NewRewardTreasury","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract TimelockEscrow","name":"oldTimelockEscrow","type":"address"},{"indexed":false,"internalType":"contract TimelockEscrow","name":"newTimelockEscrow","type":"address"}],"name":"NewTimelockEscrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"redeemer","type":"address"},{"indexed":false,"internalType":"uint256","name":"redeemAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemTokens","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":false,"inputs":[],"name":"_acceptAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract ComptrollerInterface","name":"newComptroller","type":"address"}],"name":"_setComptroller","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address payable","name":"newPendingAdmin","type":"address"}],"name":"_setPendingAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"newRewardPerBlock","type":"uint256"}],"name":"_setRewardPerBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newRewardTreasury","type":"address"}],"name":"_setRewardTreasury","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract TimelockEscrow","name":"newTimelockEscrow","type":"address"}],"name":"_setTimelockEscrow","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"accrualBlockNumber","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"accrueInterest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"admin","outputs":[{"internalType":"address payable","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOfUnderlying","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"borrowIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint32","name":"","type":"uint32"}],"name":"checkpoints","outputs":[{"internalType":"uint32","name":"fromBlock","type":"uint32"},{"internalType":"uint96","name":"votes","type":"uint96"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"comptroller","outputs":[{"internalType":"contract ComptrollerInterface","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"delegates","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"escrow","outputs":[{"internalType":"contract TimelockEscrow","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"exchangeRateCurrent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"exchangeRateStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getAccountSnapshot","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getCash","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getCurrentVotes","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"getPriorVotes","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isCToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"numCheckpoints","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"pendingAdmin","outputs":[{"internalType":"address payable","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"redeemTokens","type":"uint256"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemUnderlying","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"rewardPerBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rewardTreasury","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"liquidator","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"seizeTokens","type":"uint256"}],"name":"seize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"syncDelegate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"underlying","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}]

60806040523480156200001157600080fd5b50604051620048073803806200480783398181016040526101008110156200003857600080fd5b81516020830151604080850151606086015160808701805193519597949692959194919392820192846401000000008211156200007457600080fd5b9083019060208201858111156200008a57600080fd5b8251640100000000811182820188101715620000a557600080fd5b82525081516020918201929091019080838360005b83811015620000d4578181015183820152602001620000ba565b50505050905090810190601f168015620001025780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200012657600080fd5b9083019060208201858111156200013c57600080fd5b82516401000000008111828201881017156200015757600080fd5b82525081516020918201929091019080838360005b83811015620001865781810151838201526020016200016c565b50505050905090810190601f168015620001b45780820380516001836020036101000a031916815260200191505b506040908152602082810151929091015160038054610100600160a81b03191633610100021790559193509091506200020c908890670de0b6b3a764000090899089908990899089906200032d811b620033b417901c565b600f80546001600160a01b0319166001600160a01b038a81169190911791829055604080516318160ddd60e01b8152905192909116916318160ddd91600480820192602092909190829003018186803b1580156200026957600080fd5b505afa1580156200027e573d6000803e3d6000fd5b505050506040513d60208110156200029557600080fd5b505060038054610100600160a81b0319166101006001600160a01b0384160217905560405188908290620002c990620006cc565b6001600160a01b03928316815291166020820152604080519182900301906000f080158015620002fd573d6000803e3d6000fd5b50601080546001600160a01b0319166001600160a01b0392909216919091179055506200077c9650505050505050565b60035461010090046001600160a01b031633146200037d5760405162461bcd60e51b8152600401808060200182810382526024815260200180620047906024913960400191505060405180910390fd5b60075415620003be5760405162461bcd60e51b8152600401808060200182810382526023815260200180620047b46023913960400191505060405180910390fd5b600686905585620004015760405162461bcd60e51b8152600401808060200182810382526030815260200180620047d76030913960400191505060405180910390fd5b600062000417886001600160e01b03620004f016565b905080156200046d576040805162461bcd60e51b815260206004820152601a60248201527f73657474696e6720636f6d7074726f6c6c6572206661696c6564000000000000604482015290519081900360640190fd5b835162000482906001906020870190620006da565b50825162000498906002906020860190620006da565b506003805460ff191660ff8416179055620004b262000657565b600755505050600992909255600a80546001600160a01b0319166001600160a01b039290921691909117905550506000805460ff1916600117905550565b60035460009061010090046001600160a01b031633146200052a57620005226001603f6001600160e01b036200065c16565b905062000652565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd2916004808301926020929190829003018186803b1580156200057057600080fd5b505afa15801562000585573d6000803e3d6000fd5b505050506040513d60208110156200059c57600080fd5b5051620005f0576040805162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c736500000000604482015290519081900360640190fd5b600580546001600160a01b0319166001600160a01b03858116918217909255604080519284168352602083019190915280517f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d9281900390910190a160009150505b919050565b435b90565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa08360108111156200068c57fe5b8360508111156200069957fe5b604080519283526020830191909152600082820152519081900360600190a1826010811115620006c557fe5b9392505050565b6107a88062003fe883390190565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200071d57805160ff19168380011785556200074d565b828001600101855582156200074d579182015b828111156200074d57825182559160200191906001019062000730565b506200075b9291506200075f565b5090565b6200065991905b808211156200075b576000815560010162000766565b61385c806200078c6000396000f3fe608060405234801561001057600080fd5b50600436106102275760003560e01c8063852a12e311610130578063b71d1a0c116100b8578063e2fdcc171161007c578063e2fdcc1714610632578063e9c714f21461063a578063f1127ed814610642578063f851a4401461069c578063fe9c44ae146106a457610227565b8063b71d1a0c14610593578063bd6d894d146105b9578063c37f68e2146105c1578063c7c934a11461060d578063db006a751461061557610227565b8063a0712d68116100ff578063a0712d681461050a578063a6afed9514610527578063aa5af0fd1461052f578063b2a02ff114610537578063b4b5ea571461056d57610227565b8063852a12e3146104c05780638aa1c05f146104dd5780638ae39cac146104fa57806395d89b411461050257610227565b80633b1d21a2116101b35780636c540baf116101825780636c540baf146104035780636f307dc31461040b5780636fcfff451461041357806370a0823114610452578063782d6fe11461047857610227565b80633b1d21a2146103a75780634576b5db146103af578063587cde1e146103d55780635fe3b567146103fb57610227565b8063182df0f5116101fa578063182df0f51461030f5780631e756d0f14610317578063267822471461033f578063313ce567146103635780633af9e6691461038157610227565b806306fdde031461022c5780630c19dc3a146102a957806317c50d06146102e157806318160ddd14610307575b600080fd5b6102346106c0565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561026e578181015183820152602001610256565b50505050905090810190601f16801561029b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102cf600480360360208110156102bf57600080fd5b50356001600160a01b031661074d565b60408051918252519081900360200190f35b6102cf600480360360208110156102f757600080fd5b50356001600160a01b0316610893565b6102cf61091e565b6102cf610924565b61033d6004803603602081101561032d57600080fd5b50356001600160a01b0316610987565b005b610347610a14565b604080516001600160a01b039092168252519081900360200190f35b61036b610a23565b6040805160ff9092168252519081900360200190f35b6102cf6004803603602081101561039757600080fd5b50356001600160a01b0316610a2c565b6102cf610ae2565b6102cf600480360360208110156103c557600080fd5b50356001600160a01b0316610af1565b610347600480360360208110156103eb57600080fd5b50356001600160a01b0316610c3f565b610347610c5a565b6102cf610c69565b610347610c6f565b6104396004803603602081101561042957600080fd5b50356001600160a01b0316610c7e565b6040805163ffffffff9092168252519081900360200190f35b6102cf6004803603602081101561046857600080fd5b50356001600160a01b0316610c96565b6104a46004803603604081101561048e57600080fd5b506001600160a01b038135169060200135610cb1565b604080516001600160601b039092168252519081900360200190f35b6102cf600480360360208110156104d657600080fd5b5035610edf565b6102cf600480360360208110156104f357600080fd5b5035610eec565b6102cf610f5b565b610234610f61565b6102cf6004803603602081101561052057600080fd5b5035610fb9565b6102cf611079565b6102cf6111e9565b6102cf6004803603606081101561054d57600080fd5b506001600160a01b038135811691602081013590911690604001356111f5565b6104a46004803603602081101561058357600080fd5b50356001600160a01b0316611266565b6102cf600480360360208110156105a957600080fd5b50356001600160a01b03166112d8565b6102cf611364565b6105e7600480360360208110156105d757600080fd5b50356001600160a01b0316611420565b604080519485526020850193909352838301919091526060830152519081900360800190f35b61034761148d565b6102cf6004803603602081101561062b57600080fd5b503561149c565b6103476114a9565b6102cf6114b8565b6106746004803603604081101561065857600080fd5b5080356001600160a01b0316906020013563ffffffff166115bb565b6040805163ffffffff90931683526001600160601b0390911660208301528051918290030190f35b6103476115f0565b6106ac611604565b604080519115158252519081900360200190f35b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156107455780601f1061071a57610100808354040283529160200191610745565b820191906000526020600020905b81548152906001019060200180831161072857829003601f168201915b505050505081565b6000306001600160a01b0316826001600160a01b03166380f556056040518163ffffffff1660e01b815260040160206040518083038186803b15801561079257600080fd5b505afa1580156107a6573d6000803e3d6000fd5b505050506040513d60208110156107bc57600080fd5b50516001600160a01b0316146108035760405162461bcd60e51b81526004018080602001828103825260348152602001806136e66034913960400191505060405180910390fd5b60035461010090046001600160a01b0316331461082d576108266001603f611609565b905061088e565b601080546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517f8a0324ea550ac953d4515436f05889f90a816b559ca26ee450b104d4d5a248fa929181900390910190a1505b919050565b60035460009061010090046001600160a01b031633146108b9576108266001603f611609565b600a80546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517f2856afeddd63e06a55f7d242638b9ce830a95d17f6ac86997a9acd7de2761628929181900390910190a150919050565b60085481565b600080600061093161166f565b9092509050600082600381111561094457fe5b146109805760405162461bcd60e51b815260040180806020018281038252603581526020018061374d6035913960400191505060405180910390fd5b9150505b90565b600f5460408051632c3e6f0f60e11b81526001600160a01b0384811660048301529151600093929092169163587cde1e91602480820192602092909190829003018186803b1580156109d857600080fd5b505afa1580156109ec573d6000803e3d6000fd5b505050506040513d6020811015610a0257600080fd5b50519050610a1082826116e4565b5050565b6004546001600160a01b031681565b60035460ff1681565b6000610a3661334c565b6040518060200160405280610a49611364565b90526001600160a01b0384166000908152600b6020526040812054919250908190610a75908490611764565b90925090506000826003811115610a8857fe5b14610ada576040805162461bcd60e51b815260206004820152601f60248201527f62616c616e636520636f756c64206e6f742062652063616c63756c6174656400604482015290519081900360640190fd5b949350505050565b6000610aec6117b8565b905090565b60035460009061010090046001600160a01b03163314610b17576108266001603f611609565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd2916004808301926020929190829003018186803b158015610b5c57600080fd5b505afa158015610b70573d6000803e3d6000fd5b505050506040513d6020811015610b8657600080fd5b5051610bd9576040805162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c736500000000604482015290519081900360640190fd5b600580546001600160a01b0319166001600160a01b03858116918217909255604080519284168352602083019190915280517f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d9281900390910190a160005b9392505050565b600c602052600090815260409020546001600160a01b031681565b6005546001600160a01b031681565b60075481565b600f546001600160a01b031681565b600e6020526000908152604090205463ffffffff1681565b6001600160a01b03166000908152600b602052604090205490565b6000438210610cf15760405162461bcd60e51b815260040180806020018281038252602681526020018061363f6026913960400191505060405180910390fd5b6001600160a01b0383166000908152600e602052604090205463ffffffff1680610d1f576000915050610ed9565b6001600160a01b0384166000908152600d6020908152604080832063ffffffff600019860181168552925290912054168310610d9b576001600160a01b0384166000908152600d602090815260408083206000199490940163ffffffff1683529290522054600160201b90046001600160601b03169050610ed9565b6001600160a01b0384166000908152600d6020908152604080832083805290915290205463ffffffff16831015610dd6576000915050610ed9565b600060001982015b8163ffffffff168163ffffffff161115610e9957600282820363ffffffff16048103610e0861335f565b506001600160a01b0387166000908152600d6020908152604080832063ffffffff858116855290835292819020815180830190925254928316808252600160201b9093046001600160601b03169181019190915290871415610e7457602001519450610ed99350505050565b805163ffffffff16871115610e8b57819350610e92565b6001820392505b5050610dde565b506001600160a01b0385166000908152600d6020908152604080832063ffffffff909416835292905220546001600160601b03600160201b909104169150505b92915050565b6000610ed9826001611838565b60035460009061010090046001600160a01b03163314610f12576108266001603f611609565b6009805490839055604080518281526020810185905281517f3b7a406bf2b66d0f83f6b1cf4c39edf1269cad80712b94cd80a44d13f61f1357929181900390910190a150919050565b60095481565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156107455780601f1061071a57610100808354040283529160200191610745565b600080610fc5836118d9565b50600f5460408051632c3e6f0f60e11b815233600482015290519293506000926001600160a01b039092169163587cde1e91602480820192602092909190829003018186803b15801561101757600080fd5b505afa15801561102b573d6000803e3d6000fd5b505050506040513d602081101561104157600080fd5b5051336000908152600c60205260409020549091506001600160a01b038083169116146110725761107233826116e4565b5092915050565b600080611084611981565b6007549091508082141561109d57600092505050610984565b6000806110aa8484611985565b909250905060008260038111156110bd57fe5b1461110f576040805162461bcd60e51b815260206004820152601f60248201527f636f756c64206e6f742063616c63756c61746520626c6f636b2064656c746100604482015290519081900360640190fd5b600061111d600954836119a8565b9093509050600083600381111561113057fe5b14611182576040805162461bcd60e51b815260206004820152601a60248201527f636f756c64206e6f742063616c63756c61746520726577617264000000000000604482015290519081900360640190fd5b600060085411801561119e5750600a546001600160a01b031615155b80156111bb5750600a546111bb906001600160a01b0316826119e7565b156111d857600a546111d6906001600160a01b031682611b06565b505b600785905560009550505050505090565b670de0b6b3a764000081565b6000805460ff1661123a576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916905561125033858585611d50565b90506000805460ff191660011790559392505050565b6001600160a01b0381166000908152600e602052604081205463ffffffff1680611291576000610c38565b6001600160a01b0383166000908152600d6020908152604080832063ffffffff60001986011684529091529020546001600160601b03600160201b90910416915050919050565b60035460009061010090046001600160a01b031633146112fe5761082660016045611609565b600480546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a16000610c38565b6000805460ff166113a9576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556113bb611079565b14611406576040805162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604482015290519081900360640190fd5b61140e610924565b90506000805460ff1916600117905590565b6001600160a01b0381166000908152600b6020526040812054819081908190818061144961166f565b92509050600081600381111561145b57fe5b1461147757600996506000955085945084935061148692505050565b60009650919450600093509150505b9193509193565b600a546001600160a01b031681565b6000610ed982600161200e565b6010546001600160a01b031681565b6004546000906001600160a01b0316331415806114d3575033155b156114eb576114e460016000611609565b9050610984565b60038054600480546001600160a01b03818116610100818102610100600160a81b0319871617968790556001600160a01b031990931690935560408051948390048216808652929095041660208401528351909391927ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc92908290030190a1600454604080516001600160a01b038085168252909216602083015280517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99281900390910190a160009250505090565b600d60209081526000928352604080842090915290825290205463ffffffff811690600160201b90046001600160601b031682565b60035461010090046001600160a01b031681565b600181565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa083601081111561163857fe5b83605081111561164457fe5b604080519283526020830191909152600082820152519081900360600190a1826010811115610c3857fe5b60085460009081908061168a575050600654600091506116e0565b60006116946117b8565b905061169e61334c565b60006116aa8385612089565b9250905060008160038111156116bc57fe5b146116d0579450600093506116e092505050565b50516000945092506116e0915050565b9091565b6001600160a01b038083166000818152600c602081815260408084208054600b845282862054949093528787166001600160a01b03198416811790915590519190951694919391928592917f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a461175e828483612139565b50505050565b600080600061177161334c565b61177b86866122d4565b9092509050600082600381111561178e57fe5b1461179f57509150600090506117b1565b60006117aa8261233c565b9350935050505b9250929050565b600f54604080516370a0823160e01b815230600482015290516000926001600160a01b03169182916370a0823191602480820192602092909190829003018186803b15801561180657600080fd5b505afa15801561181a573d6000803e3d6000fd5b505050506040513d602081101561183057600080fd5b505191505090565b6000805460ff1661187d576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916815561188f611079565b905080156118b5576118ad8160108111156118a657fe5b6027611609565b9150506118c6565b6118c2336000868661234b565b9150505b6000805460ff1916600117905592915050565b60008054819060ff16611920576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155611932611079565b9050801561195d5761195081601081111561194957fe5b601e611609565b92506000915061196d9050565b6119673385612830565b92509250505b6000805460ff191660011790559092909150565b4390565b60008083831161199c5750600090508183036117b1565b506003905060006117b1565b600080836119bb575060009050806117b1565b838302838582816119c857fe5b04146119dc575060029150600090506117b1565b6000925090506117b1565b600f54604080516370a0823160e01b81526001600160a01b03858116600483015291516000939290921691839183916370a0823191602480820192602092909190829003018186803b158015611a3c57600080fd5b505afa158015611a50573d6000803e3d6000fd5b505050506040513d6020811015611a6657600080fd5b505160408051636eb1769f60e11b81526001600160a01b03888116600483015230602483015291519293506000929185169163dd62ed3e91604480820192602092909190829003018186803b158015611abe57600080fd5b505afa158015611ad2573d6000803e3d6000fd5b505050506040513d6020811015611ae857600080fd5b50519050848210801590611afc5750848110155b9695505050505050565b600f54604080516370a0823160e01b815230600482015290516000926001600160a01b031691839183916370a08231916024808301926020929190829003018186803b158015611b5557600080fd5b505afa158015611b69573d6000803e3d6000fd5b505050506040513d6020811015611b7f57600080fd5b5051604080516323b872dd60e01b81526001600160a01b038881166004830152306024830152604482018890529151929350908416916323b872dd9160648082019260009290919082900301818387803b158015611bdc57600080fd5b505af1158015611bf0573d6000803e3d6000fd5b5050505060003d60008114611c0c5760208114611c1657600080fd5b6000199150611c22565b60206000803e60005191505b5080611c75576040805162461bcd60e51b815260206004820152601860248201527f544f4b454e5f5452414e534645525f494e5f4641494c45440000000000000000604482015290519081900360640190fd5b600f54604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015611cc057600080fd5b505afa158015611cd4573d6000803e3d6000fd5b505050506040513d6020811015611cea57600080fd5b5051905082811015611d43576040805162461bcd60e51b815260206004820152601a60248201527f544f4b454e5f5452414e534645525f494e5f4f564552464c4f57000000000000604482015290519081900360640190fd5b9190910395945050505050565b6005546040805163d02f735160e01b81523060048201526001600160a01b038781166024830152868116604483015285811660648301526084820185905291516000938493169163d02f73519160a480830192602092919082900301818787803b158015611dbd57600080fd5b505af1158015611dd1573d6000803e3d6000fd5b505050506040513d6020811015611de757600080fd5b505190508015611e0657611dfe6003601b83612cf8565b915050610ada565b846001600160a01b0316846001600160a01b03161415611e2c57611dfe6006601c611609565b6001600160a01b0384166000908152600b602052604081205481908190611e539087611985565b90935091506000836003811115611e6657fe5b14611e8e57611e836009601a856003811115611e7e57fe5b612cf8565b945050505050610ada565b6001600160a01b0388166000908152600b6020526040902054611eb19087612d5e565b90935090506000836003811115611ec457fe5b14611edc57611e8360096019856003811115611e7e57fe5b6001600160a01b038088166000818152600b60209081526040808320879055938c168083529184902085905583518a8152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a36001600160a01b038088166000908152600c6020526040808220548b84168352912054611f6e92918216911688612139565b60055460408051636d35bf9160e01b81523060048201526001600160a01b038c811660248301528b811660448301528a81166064830152608482018a905291519190921691636d35bf919160a480830192600092919082900301818387803b158015611fd957600080fd5b505af1158015611fed573d6000803e3d6000fd5b50505050611ffe888760008061234b565b5060009998505050505050505050565b6000805460ff16612053576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155612065611079565b9050801561207c576118ad8160108111156118a657fe5b6118c2338560008661234b565b600061209361334c565b6000806120a886670de0b6b3a76400006119a8565b909250905060008260038111156120bb57fe5b146120da575060408051602081019091526000815290925090506117b1565b6000806120e78388612d84565b909250905060008260038111156120fa57fe5b1461211c575060408051602081019091526000815290945092506117b1915050565b604080516020810190915290815260009890975095505050505050565b816001600160a01b0316836001600160a01b03161415801561216457506000816001600160601b0316115b156122cf576001600160a01b0383161561221c576001600160a01b0383166000908152600e602052604081205463ffffffff1690816121a45760006121e3565b6001600160a01b0385166000908152600d60209081526040808320600019860163ffffffff168452909152902054600160201b90046001600160601b03165b9050600061220a828560405180606001604052806027815260200161380160279139612daf565b905061221886848484612e59565b5050505b6001600160a01b038216156122cf576001600160a01b0382166000908152600e602052604081205463ffffffff169081612257576000612296565b6001600160a01b0384166000908152600d60209081526040808320600019860163ffffffff168452909152902054600160201b90046001600160601b03165b905060006122bd828560405180606001604052806026815260200161366560269139613018565b90506122cb85848484612e59565b5050505b505050565b60006122de61334c565b6000806122ef8660000151866119a8565b9092509050600082600381111561230257fe5b14612321575060408051602081019091526000815290925090506117b1565b60408051602081019091529081526000969095509350505050565b51670de0b6b3a7640000900490565b6000831580612358575082155b6123935760405162461bcd60e51b81526004018080602001828103825260348152602001806137aa6034913960400191505060405180910390fd5b61239b613376565b6123a361166f565b60408301819052602083018260038111156123ba57fe5b60038111156123c557fe5b90525060009050816020015160038111156123dc57fe5b146123f857611dfe6009602b83602001516003811115611e7e57fe5b841561247957606081018590526040805160208101825290820151815261241f9086611764565b608083018190526020830182600381111561243657fe5b600381111561244157fe5b905250600090508160200151600381111561245857fe5b1461247457611dfe6009602983602001516003811115611e7e57fe5b6124f2565b6124958460405180602001604052808460400151815250613082565b60608301819052602083018260038111156124ac57fe5b60038111156124b757fe5b90525060009050816020015160038111156124ce57fe5b146124ea57611dfe6009602a83602001516003811115611e7e57fe5b608081018490525b60055460608201516040805163eabe7d9160e01b81523060048201526001600160a01b038a8116602483015260448201939093529051600093929092169163eabe7d919160648082019260209290919082900301818787803b15801561255757600080fd5b505af115801561256b573d6000803e3d6000fd5b505050506040513d602081101561258157600080fd5b5051905080156125a1576125986003602883612cf8565b92505050610ada565b6125b16008548360600151611985565b60a08401819052602084018260038111156125c857fe5b60038111156125d357fe5b90525060009050826020015160038111156125ea57fe5b14612606576125986009602e84602001516003811115611e7e57fe5b6001600160a01b0387166000908152600b6020526040902054606083015161262e9190611985565b60c084018190526020840182600381111561264557fe5b600381111561265057fe5b905250600090508260200151600381111561266757fe5b14612683576125986009602d84602001516003811115611e7e57fe5b81608001516126906117b8565b10156126a257612598600e602f611609565b6126b187836080015186613099565b60a082015160085560c08201516001600160a01b0388166000818152600b60209081526040918290209390935560608501518151908152905130937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef928290030190a36080820151606080840151604080516001600160a01b038c168152602081019490945283810191909152517fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a9299281900390910190a16001600160a01b038088166000908152600c6020526040812054606085015161279793919091169190612139565b60055460808301516060840151604080516351dff98960e01b81523060048201526001600160a01b038c81166024830152604482019490945260648101929092525191909216916351dff98991608480830192600092919082900301818387803b15801561280457600080fd5b505af1158015612818573d6000803e3d6000fd5b5060009250612825915050565b979650505050505050565b60055460408051634ef4c3e160e01b81523060048201526001600160a01b03858116602483015260448201859052915160009384938493911691634ef4c3e19160648082019260209290919082900301818787803b15801561289157600080fd5b505af11580156128a5573d6000803e3d6000fd5b505050506040513d60208110156128bb57600080fd5b5051905080156128df576128d26003601f83612cf8565b9250600091506117b19050565b6128e7613376565b6128ef61166f565b604083018190526020830182600381111561290657fe5b600381111561291157fe5b905250600090508160200151600381111561292857fe5b14612952576129446009602183602001516003811115611e7e57fe5b9350600092506117b1915050565b61295c8686611b06565b60c082018190526040805160208101825290830151815261297d9190613082565b606083018190526020830182600381111561299457fe5b600381111561299f57fe5b90525060009050816020015160038111156129b657fe5b14612a08576040805162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c4544604482015290519081900360640190fd5b612a186008548260600151612d5e565b6080830181905260208301826003811115612a2f57fe5b6003811115612a3a57fe5b9052506000905081602001516003811115612a5157fe5b14612a8d5760405162461bcd60e51b81526004018080602001828103825260288152602001806137826028913960400191505060405180910390fd5b600160601b816080015110612ad35760405162461bcd60e51b81526004018080602001828103825260238152602001806137de6023913960400191505060405180910390fd5b6001600160a01b0386166000908152600b60205260409020546060820151612afb9190612d5e565b60a0830181905260208301826003811115612b1257fe5b6003811115612b1d57fe5b9052506000905081602001516003811115612b3457fe5b14612b705760405162461bcd60e51b815260040180806020018281038252602b8152602001806136bb602b913960400191505060405180910390fd5b608081015160085560a08101516001600160a01b0387166000818152600b60209081526040918290209390935560c084015160608086015183519485529484019190915282820193909352517f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f929181900390910190a1606081015160408051918252516001600160a01b0388169130917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a36001600160a01b038087166000908152600c60205260408120546060840151612c58939190911690612139565b60055460c08201516060830151604080516341c728b960e01b81523060048201526001600160a01b038b81166024830152604482019490945260648101929092525191909216916341c728b991608480830192600092919082900301818387803b158015612cc557600080fd5b505af1158015612cd9573d6000803e3d6000fd5b5060009250612ce6915050565b8160c001519350935050509250929050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0846010811115612d2757fe5b846050811115612d3357fe5b604080519283526020830191909152818101859052519081900360600190a1836010811115610ada57fe5b600080838301848110612d76576000925090506117b1565b5060029150600090506117b1565b60008082612d9857506001905060006117b1565b6000838581612da357fe5b04915091509250929050565b6000836001600160601b0316836001600160601b031611158290612e515760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612e16578181015183820152602001612dfe565b50505050905090810190601f168015612e435780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000612e7d4360405180606001604052806033815260200161371a60339139613290565b905060008463ffffffff16118015612ec657506001600160a01b0385166000908152600d6020908152604080832063ffffffff6000198901811685529252909120548282169116145b15612f25576001600160a01b0385166000908152600d60209081526040808320600019880163ffffffff168452909152902080546fffffffffffffffffffffffff000000001916600160201b6001600160601b03851602179055612fc4565b60408051808201825263ffffffff80841682526001600160601b0380861660208085019182526001600160a01b038b166000818152600d83528781208c871682528352878120965187549451909516600160201b026fffffffffffffffffffffffff000000001995871663ffffffff19958616179590951694909417909555938252600e90935292909220805460018801909316929091169190911790555b604080516001600160601b0380861682528416602082015281516001600160a01b038816927fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724928290030190a25050505050565b6000838301826001600160601b0380871690831610156130795760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612e16578181015183820152602001612dfe565b50949350505050565b600080600061308f61334c565b61177b86866132ed565b600f546001600160a01b0316811561311d576010546040805163a9059cbb60e01b81526001600160a01b0392831660048201526024810186905290519183169163a9059cbb9160448082019260009290919082900301818387803b15801561310057600080fd5b505af1158015613114573d6000803e3d6000fd5b50505050613196565b806001600160a01b031663a9059cbb85856040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561317d57600080fd5b505af1158015613191573d6000803e3d6000fd5b505050505b60003d80156131ac57602081146131b657600080fd5b60001991506131c2565b60206000803e60005191505b5080613215576040805162461bcd60e51b815260206004820152601960248201527f544f4b454e5f5452414e534645525f4f55545f4641494c454400000000000000604482015290519081900360640190fd5b8215613289576010546040805163177ead8360e11b81526001600160a01b0388811660048301526024820188905291519190921691632efd5b0691604480830192600092919082900301818387803b15801561327057600080fd5b505af1158015613284573d6000803e3d6000fd5b505050505b5050505050565b600081600160201b84106132e55760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612e16578181015183820152602001612dfe565b509192915050565b60006132f761334c565b60008061330c670de0b6b3a7640000876119a8565b9092509050600082600381111561331f57fe5b1461333e575060408051602081019091526000815290925090506117b1565b6117aa818660000151612089565b6040518060200160405280600081525090565b604080518082019091526000808252602082015290565b6040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60035461010090046001600160a01b031633146134025760405162461bcd60e51b81526004018080602001828103825260248152602001806135f86024913960400191505060405180910390fd5b600754156134415760405162461bcd60e51b815260040180806020018281038252602381526020018061361c6023913960400191505060405180910390fd5b6006869055856134825760405162461bcd60e51b815260040180806020018281038252603081526020018061368b6030913960400191505060405180910390fd5b600061348d88610af1565b905080156134e2576040805162461bcd60e51b815260206004820152601a60248201527f73657474696e6720636f6d7074726f6c6c6572206661696c6564000000000000604482015290519081900360640190fd5b83516134f590600190602087019061355f565b50825161350990600290602086019061355f565b506003805460ff191660ff8416179055613521611981565b600755505050600992909255600a80546001600160a01b0319166001600160a01b039290921691909117905550506000805460ff1916600117905550565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106135a057805160ff19168380011785556135cd565b828001600101855582156135cd579182015b828111156135cd5782518255916020019190600101906135b2565b506135d99291506135dd565b5090565b61098491905b808211156135d957600081556001016135e356fe6f6e6c792061646d696e206d617920696e697469616c697a6520746865206d61726b65746d61726b6574206d6179206f6e6c7920626520696e697469616c697a6564206f6e6365494e563a3a6765745072696f72566f7465733a206e6f74207965742064657465726d696e6564494e563a3a5f6d6f7665566f7465733a20766f746520616d6f756e74206f766572666c6f7773696e697469616c2065786368616e67652072617465206d7573742062652067726561746572207468616e207a65726f2e4d494e545f4e45575f4143434f554e545f42414c414e43455f43414c43554c4154494f4e5f4641494c454473616e69747920636865636b3a206e657754696d656c6f636b457363726f77206d757374207573652074686973206d61726b6574494e563a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d6265722065786365656473203332206269747365786368616e67655261746553746f7265643a2065786368616e67655261746553746f726564496e7465726e616c206661696c65644d494e545f4e45575f544f54414c5f535550504c595f43414c43554c4154494f4e5f4641494c45446f6e65206f662072656465656d546f6b656e73496e206f722072656465656d416d6f756e74496e206d757374206265207a65726f4d494e545f4e45575f544f54414c5f535550504c595f4f5645525f4341504143495459494e563a3a5f6d6f7665566f7465733a20766f746520616d6f756e7420756e646572666c6f7773a265627a7a723158200fc92ea42071de51439db4ca006aaa0efd82c3c9775d952e80eb572e8cf4e0c264736f6c634300051000326080604052620d2f0060035534801561001757600080fd5b506040516107a83803806107a88339818101604052604081101561003a57600080fd5b508051602090910151600080546001600160a01b039384166001600160a01b0319918216179091556001805493909216928116929092179055600280549091163317905561071b8061008d6000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c80636f307dc3116100665780636f307dc31461013457806380f556051461013c578063ce513b6f14610144578063d215f3181461016a578063f3f43703146101905761009e565b80630fb5a6b4146100a35780631c411df3146100bd5780632efd5b06146100dc5780633ccfd60b146101085780635aa6e67514610110575b600080fd5b6100ab6101cf565b60408051918252519081900360200190f35b6100da600480360360208110156100d357600080fd5b50356101d5565b005b6100da600480360360408110156100f257600080fd5b506001600160a01b038135169060200135610223565b6100da6103e8565b610118610517565b604080516001600160a01b039092168252519081900360200190f35b610118610526565b610118610535565b6100ab6004803603602081101561015a57600080fd5b50356001600160a01b0316610544565b6100da6004803603602081101561018057600080fd5b50356001600160a01b0316610599565b6101b6600480360360208110156101a657600080fd5b50356001600160a01b0316610604565b6040805192835260208301919091528051918290030190f35b60035481565b6001546001600160a01b0316331461021e5760405162461bcd60e51b81526004018080602001828103825260278152602001806106c06027913960400191505060405180910390fd5b600355565b6002546001600160a01b0316331461027b576040805162461bcd60e51b81526020600482015260166024820152756f6e6c79206d61726b65742063616e20657363726f7760501b604482015290519081900360640190fd5b6003541561035d5761028b61067e565b506001600160a01b0382166000908152600460209081526040918290208251808401845281548152600190910154818301908152835180850190945260035442018452519092918201906102e5908563ffffffff61061d16565b90526001600160a01b0384166000818152600460209081526040918290208451815593810151600190940193909355600354815192835242019282019290925280820184905290517fdbe3ea2036231446c1c0e4706a5d2a242036540e5708cb7972a396fad591606d9181900360600190a1506103e4565b600080546040805163a9059cbb60e01b81526001600160a01b0386811660048301526024820186905291519190921692839263a9059cbb9260448083019360209383900390910190829087803b1580156103b657600080fd5b505af11580156103ca573d6000803e3d6000fd5b505050506040513d60208110156103e057600080fd5b5050505b5050565b60006103f333610544565b905060008111610440576040805162461bcd60e51b81526020600482015260136024820152724e6f7468696e6720746f20776974686472617760681b604482015290519081900360640190fd5b6000805433808352600460208181526040808620868155600101869055805163a9059cbb60e01b8152928301939093526024820186905291516001600160a01b0390931693849363a9059cbb936044808501949193918390030190829087803b1580156104ac57600080fd5b505af11580156104c0573d6000803e3d6000fd5b505050506040513d60208110156104d657600080fd5b5050604080513381526020810184905281517f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364929181900390910190a15050565b6001546001600160a01b031681565b6000546001600160a01b031681565b6002546001600160a01b031681565b600061054e61067e565b506001600160a01b0382166000908152600460209081526040918290208251808401909352805480845260019091015491830191909152421061059357806020015191505b50919050565b6001546001600160a01b031633146105e25760405162461bcd60e51b81526004018080602001828103825260278152602001806106996027913960400191505060405180910390fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6004602052600090815260409020805460019091015482565b600082820183811015610677576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b60405180604001604052806000815260200160008152509056fe6f6e6c7920676f7665726e616e63652063616e2073657420697473206e657720616464726573736f6e6c7920676f7665726e616e63652063616e2073657420657363726f77206475726174696f6ea265627a7a72315820651c69ffc90968b768d73057a59c1bd68151ced3d95f1d641ff10cf25204e10d64736f6c634300051000326f6e6c792061646d696e206d617920696e697469616c697a6520746865206d61726b65746d61726b6574206d6179206f6e6c7920626520696e697469616c697a6564206f6e6365696e697469616c2065786368616e67652072617465206d7573742062652067726561746572207468616e207a65726f2e00000000000000000000000041d5d79431a913c4ae7d69a668ecdfe5ff9dfb680000000000000000000000004dcf7407ae5c07f8681e1659f626e114a7667339000000000000000000000000000000000000000000000000001772aa3f848000000000000000000000000000926df14a23be491164dcf93f4c468a50ef659d5b000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000012000000000000000000000000926df14a23be491164dcf93f4c468a50ef659d5b000000000000000000000000000000000000000000000000000000000000000478494e5600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000458494e5600000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102275760003560e01c8063852a12e311610130578063b71d1a0c116100b8578063e2fdcc171161007c578063e2fdcc1714610632578063e9c714f21461063a578063f1127ed814610642578063f851a4401461069c578063fe9c44ae146106a457610227565b8063b71d1a0c14610593578063bd6d894d146105b9578063c37f68e2146105c1578063c7c934a11461060d578063db006a751461061557610227565b8063a0712d68116100ff578063a0712d681461050a578063a6afed9514610527578063aa5af0fd1461052f578063b2a02ff114610537578063b4b5ea571461056d57610227565b8063852a12e3146104c05780638aa1c05f146104dd5780638ae39cac146104fa57806395d89b411461050257610227565b80633b1d21a2116101b35780636c540baf116101825780636c540baf146104035780636f307dc31461040b5780636fcfff451461041357806370a0823114610452578063782d6fe11461047857610227565b80633b1d21a2146103a75780634576b5db146103af578063587cde1e146103d55780635fe3b567146103fb57610227565b8063182df0f5116101fa578063182df0f51461030f5780631e756d0f14610317578063267822471461033f578063313ce567146103635780633af9e6691461038157610227565b806306fdde031461022c5780630c19dc3a146102a957806317c50d06146102e157806318160ddd14610307575b600080fd5b6102346106c0565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561026e578181015183820152602001610256565b50505050905090810190601f16801561029b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102cf600480360360208110156102bf57600080fd5b50356001600160a01b031661074d565b60408051918252519081900360200190f35b6102cf600480360360208110156102f757600080fd5b50356001600160a01b0316610893565b6102cf61091e565b6102cf610924565b61033d6004803603602081101561032d57600080fd5b50356001600160a01b0316610987565b005b610347610a14565b604080516001600160a01b039092168252519081900360200190f35b61036b610a23565b6040805160ff9092168252519081900360200190f35b6102cf6004803603602081101561039757600080fd5b50356001600160a01b0316610a2c565b6102cf610ae2565b6102cf600480360360208110156103c557600080fd5b50356001600160a01b0316610af1565b610347600480360360208110156103eb57600080fd5b50356001600160a01b0316610c3f565b610347610c5a565b6102cf610c69565b610347610c6f565b6104396004803603602081101561042957600080fd5b50356001600160a01b0316610c7e565b6040805163ffffffff9092168252519081900360200190f35b6102cf6004803603602081101561046857600080fd5b50356001600160a01b0316610c96565b6104a46004803603604081101561048e57600080fd5b506001600160a01b038135169060200135610cb1565b604080516001600160601b039092168252519081900360200190f35b6102cf600480360360208110156104d657600080fd5b5035610edf565b6102cf600480360360208110156104f357600080fd5b5035610eec565b6102cf610f5b565b610234610f61565b6102cf6004803603602081101561052057600080fd5b5035610fb9565b6102cf611079565b6102cf6111e9565b6102cf6004803603606081101561054d57600080fd5b506001600160a01b038135811691602081013590911690604001356111f5565b6104a46004803603602081101561058357600080fd5b50356001600160a01b0316611266565b6102cf600480360360208110156105a957600080fd5b50356001600160a01b03166112d8565b6102cf611364565b6105e7600480360360208110156105d757600080fd5b50356001600160a01b0316611420565b604080519485526020850193909352838301919091526060830152519081900360800190f35b61034761148d565b6102cf6004803603602081101561062b57600080fd5b503561149c565b6103476114a9565b6102cf6114b8565b6106746004803603604081101561065857600080fd5b5080356001600160a01b0316906020013563ffffffff166115bb565b6040805163ffffffff90931683526001600160601b0390911660208301528051918290030190f35b6103476115f0565b6106ac611604565b604080519115158252519081900360200190f35b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156107455780601f1061071a57610100808354040283529160200191610745565b820191906000526020600020905b81548152906001019060200180831161072857829003601f168201915b505050505081565b6000306001600160a01b0316826001600160a01b03166380f556056040518163ffffffff1660e01b815260040160206040518083038186803b15801561079257600080fd5b505afa1580156107a6573d6000803e3d6000fd5b505050506040513d60208110156107bc57600080fd5b50516001600160a01b0316146108035760405162461bcd60e51b81526004018080602001828103825260348152602001806136e66034913960400191505060405180910390fd5b60035461010090046001600160a01b0316331461082d576108266001603f611609565b905061088e565b601080546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517f8a0324ea550ac953d4515436f05889f90a816b559ca26ee450b104d4d5a248fa929181900390910190a1505b919050565b60035460009061010090046001600160a01b031633146108b9576108266001603f611609565b600a80546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517f2856afeddd63e06a55f7d242638b9ce830a95d17f6ac86997a9acd7de2761628929181900390910190a150919050565b60085481565b600080600061093161166f565b9092509050600082600381111561094457fe5b146109805760405162461bcd60e51b815260040180806020018281038252603581526020018061374d6035913960400191505060405180910390fd5b9150505b90565b600f5460408051632c3e6f0f60e11b81526001600160a01b0384811660048301529151600093929092169163587cde1e91602480820192602092909190829003018186803b1580156109d857600080fd5b505afa1580156109ec573d6000803e3d6000fd5b505050506040513d6020811015610a0257600080fd5b50519050610a1082826116e4565b5050565b6004546001600160a01b031681565b60035460ff1681565b6000610a3661334c565b6040518060200160405280610a49611364565b90526001600160a01b0384166000908152600b6020526040812054919250908190610a75908490611764565b90925090506000826003811115610a8857fe5b14610ada576040805162461bcd60e51b815260206004820152601f60248201527f62616c616e636520636f756c64206e6f742062652063616c63756c6174656400604482015290519081900360640190fd5b949350505050565b6000610aec6117b8565b905090565b60035460009061010090046001600160a01b03163314610b17576108266001603f611609565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd2916004808301926020929190829003018186803b158015610b5c57600080fd5b505afa158015610b70573d6000803e3d6000fd5b505050506040513d6020811015610b8657600080fd5b5051610bd9576040805162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c736500000000604482015290519081900360640190fd5b600580546001600160a01b0319166001600160a01b03858116918217909255604080519284168352602083019190915280517f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d9281900390910190a160005b9392505050565b600c602052600090815260409020546001600160a01b031681565b6005546001600160a01b031681565b60075481565b600f546001600160a01b031681565b600e6020526000908152604090205463ffffffff1681565b6001600160a01b03166000908152600b602052604090205490565b6000438210610cf15760405162461bcd60e51b815260040180806020018281038252602681526020018061363f6026913960400191505060405180910390fd5b6001600160a01b0383166000908152600e602052604090205463ffffffff1680610d1f576000915050610ed9565b6001600160a01b0384166000908152600d6020908152604080832063ffffffff600019860181168552925290912054168310610d9b576001600160a01b0384166000908152600d602090815260408083206000199490940163ffffffff1683529290522054600160201b90046001600160601b03169050610ed9565b6001600160a01b0384166000908152600d6020908152604080832083805290915290205463ffffffff16831015610dd6576000915050610ed9565b600060001982015b8163ffffffff168163ffffffff161115610e9957600282820363ffffffff16048103610e0861335f565b506001600160a01b0387166000908152600d6020908152604080832063ffffffff858116855290835292819020815180830190925254928316808252600160201b9093046001600160601b03169181019190915290871415610e7457602001519450610ed99350505050565b805163ffffffff16871115610e8b57819350610e92565b6001820392505b5050610dde565b506001600160a01b0385166000908152600d6020908152604080832063ffffffff909416835292905220546001600160601b03600160201b909104169150505b92915050565b6000610ed9826001611838565b60035460009061010090046001600160a01b03163314610f12576108266001603f611609565b6009805490839055604080518281526020810185905281517f3b7a406bf2b66d0f83f6b1cf4c39edf1269cad80712b94cd80a44d13f61f1357929181900390910190a150919050565b60095481565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156107455780601f1061071a57610100808354040283529160200191610745565b600080610fc5836118d9565b50600f5460408051632c3e6f0f60e11b815233600482015290519293506000926001600160a01b039092169163587cde1e91602480820192602092909190829003018186803b15801561101757600080fd5b505afa15801561102b573d6000803e3d6000fd5b505050506040513d602081101561104157600080fd5b5051336000908152600c60205260409020549091506001600160a01b038083169116146110725761107233826116e4565b5092915050565b600080611084611981565b6007549091508082141561109d57600092505050610984565b6000806110aa8484611985565b909250905060008260038111156110bd57fe5b1461110f576040805162461bcd60e51b815260206004820152601f60248201527f636f756c64206e6f742063616c63756c61746520626c6f636b2064656c746100604482015290519081900360640190fd5b600061111d600954836119a8565b9093509050600083600381111561113057fe5b14611182576040805162461bcd60e51b815260206004820152601a60248201527f636f756c64206e6f742063616c63756c61746520726577617264000000000000604482015290519081900360640190fd5b600060085411801561119e5750600a546001600160a01b031615155b80156111bb5750600a546111bb906001600160a01b0316826119e7565b156111d857600a546111d6906001600160a01b031682611b06565b505b600785905560009550505050505090565b670de0b6b3a764000081565b6000805460ff1661123a576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916905561125033858585611d50565b90506000805460ff191660011790559392505050565b6001600160a01b0381166000908152600e602052604081205463ffffffff1680611291576000610c38565b6001600160a01b0383166000908152600d6020908152604080832063ffffffff60001986011684529091529020546001600160601b03600160201b90910416915050919050565b60035460009061010090046001600160a01b031633146112fe5761082660016045611609565b600480546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a16000610c38565b6000805460ff166113a9576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556113bb611079565b14611406576040805162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604482015290519081900360640190fd5b61140e610924565b90506000805460ff1916600117905590565b6001600160a01b0381166000908152600b6020526040812054819081908190818061144961166f565b92509050600081600381111561145b57fe5b1461147757600996506000955085945084935061148692505050565b60009650919450600093509150505b9193509193565b600a546001600160a01b031681565b6000610ed982600161200e565b6010546001600160a01b031681565b6004546000906001600160a01b0316331415806114d3575033155b156114eb576114e460016000611609565b9050610984565b60038054600480546001600160a01b03818116610100818102610100600160a81b0319871617968790556001600160a01b031990931690935560408051948390048216808652929095041660208401528351909391927ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc92908290030190a1600454604080516001600160a01b038085168252909216602083015280517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99281900390910190a160009250505090565b600d60209081526000928352604080842090915290825290205463ffffffff811690600160201b90046001600160601b031682565b60035461010090046001600160a01b031681565b600181565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa083601081111561163857fe5b83605081111561164457fe5b604080519283526020830191909152600082820152519081900360600190a1826010811115610c3857fe5b60085460009081908061168a575050600654600091506116e0565b60006116946117b8565b905061169e61334c565b60006116aa8385612089565b9250905060008160038111156116bc57fe5b146116d0579450600093506116e092505050565b50516000945092506116e0915050565b9091565b6001600160a01b038083166000818152600c602081815260408084208054600b845282862054949093528787166001600160a01b03198416811790915590519190951694919391928592917f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a461175e828483612139565b50505050565b600080600061177161334c565b61177b86866122d4565b9092509050600082600381111561178e57fe5b1461179f57509150600090506117b1565b60006117aa8261233c565b9350935050505b9250929050565b600f54604080516370a0823160e01b815230600482015290516000926001600160a01b03169182916370a0823191602480820192602092909190829003018186803b15801561180657600080fd5b505afa15801561181a573d6000803e3d6000fd5b505050506040513d602081101561183057600080fd5b505191505090565b6000805460ff1661187d576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916815561188f611079565b905080156118b5576118ad8160108111156118a657fe5b6027611609565b9150506118c6565b6118c2336000868661234b565b9150505b6000805460ff1916600117905592915050565b60008054819060ff16611920576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155611932611079565b9050801561195d5761195081601081111561194957fe5b601e611609565b92506000915061196d9050565b6119673385612830565b92509250505b6000805460ff191660011790559092909150565b4390565b60008083831161199c5750600090508183036117b1565b506003905060006117b1565b600080836119bb575060009050806117b1565b838302838582816119c857fe5b04146119dc575060029150600090506117b1565b6000925090506117b1565b600f54604080516370a0823160e01b81526001600160a01b03858116600483015291516000939290921691839183916370a0823191602480820192602092909190829003018186803b158015611a3c57600080fd5b505afa158015611a50573d6000803e3d6000fd5b505050506040513d6020811015611a6657600080fd5b505160408051636eb1769f60e11b81526001600160a01b03888116600483015230602483015291519293506000929185169163dd62ed3e91604480820192602092909190829003018186803b158015611abe57600080fd5b505afa158015611ad2573d6000803e3d6000fd5b505050506040513d6020811015611ae857600080fd5b50519050848210801590611afc5750848110155b9695505050505050565b600f54604080516370a0823160e01b815230600482015290516000926001600160a01b031691839183916370a08231916024808301926020929190829003018186803b158015611b5557600080fd5b505afa158015611b69573d6000803e3d6000fd5b505050506040513d6020811015611b7f57600080fd5b5051604080516323b872dd60e01b81526001600160a01b038881166004830152306024830152604482018890529151929350908416916323b872dd9160648082019260009290919082900301818387803b158015611bdc57600080fd5b505af1158015611bf0573d6000803e3d6000fd5b5050505060003d60008114611c0c5760208114611c1657600080fd5b6000199150611c22565b60206000803e60005191505b5080611c75576040805162461bcd60e51b815260206004820152601860248201527f544f4b454e5f5452414e534645525f494e5f4641494c45440000000000000000604482015290519081900360640190fd5b600f54604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015611cc057600080fd5b505afa158015611cd4573d6000803e3d6000fd5b505050506040513d6020811015611cea57600080fd5b5051905082811015611d43576040805162461bcd60e51b815260206004820152601a60248201527f544f4b454e5f5452414e534645525f494e5f4f564552464c4f57000000000000604482015290519081900360640190fd5b9190910395945050505050565b6005546040805163d02f735160e01b81523060048201526001600160a01b038781166024830152868116604483015285811660648301526084820185905291516000938493169163d02f73519160a480830192602092919082900301818787803b158015611dbd57600080fd5b505af1158015611dd1573d6000803e3d6000fd5b505050506040513d6020811015611de757600080fd5b505190508015611e0657611dfe6003601b83612cf8565b915050610ada565b846001600160a01b0316846001600160a01b03161415611e2c57611dfe6006601c611609565b6001600160a01b0384166000908152600b602052604081205481908190611e539087611985565b90935091506000836003811115611e6657fe5b14611e8e57611e836009601a856003811115611e7e57fe5b612cf8565b945050505050610ada565b6001600160a01b0388166000908152600b6020526040902054611eb19087612d5e565b90935090506000836003811115611ec457fe5b14611edc57611e8360096019856003811115611e7e57fe5b6001600160a01b038088166000818152600b60209081526040808320879055938c168083529184902085905583518a8152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a36001600160a01b038088166000908152600c6020526040808220548b84168352912054611f6e92918216911688612139565b60055460408051636d35bf9160e01b81523060048201526001600160a01b038c811660248301528b811660448301528a81166064830152608482018a905291519190921691636d35bf919160a480830192600092919082900301818387803b158015611fd957600080fd5b505af1158015611fed573d6000803e3d6000fd5b50505050611ffe888760008061234b565b5060009998505050505050505050565b6000805460ff16612053576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155612065611079565b9050801561207c576118ad8160108111156118a657fe5b6118c2338560008661234b565b600061209361334c565b6000806120a886670de0b6b3a76400006119a8565b909250905060008260038111156120bb57fe5b146120da575060408051602081019091526000815290925090506117b1565b6000806120e78388612d84565b909250905060008260038111156120fa57fe5b1461211c575060408051602081019091526000815290945092506117b1915050565b604080516020810190915290815260009890975095505050505050565b816001600160a01b0316836001600160a01b03161415801561216457506000816001600160601b0316115b156122cf576001600160a01b0383161561221c576001600160a01b0383166000908152600e602052604081205463ffffffff1690816121a45760006121e3565b6001600160a01b0385166000908152600d60209081526040808320600019860163ffffffff168452909152902054600160201b90046001600160601b03165b9050600061220a828560405180606001604052806027815260200161380160279139612daf565b905061221886848484612e59565b5050505b6001600160a01b038216156122cf576001600160a01b0382166000908152600e602052604081205463ffffffff169081612257576000612296565b6001600160a01b0384166000908152600d60209081526040808320600019860163ffffffff168452909152902054600160201b90046001600160601b03165b905060006122bd828560405180606001604052806026815260200161366560269139613018565b90506122cb85848484612e59565b5050505b505050565b60006122de61334c565b6000806122ef8660000151866119a8565b9092509050600082600381111561230257fe5b14612321575060408051602081019091526000815290925090506117b1565b60408051602081019091529081526000969095509350505050565b51670de0b6b3a7640000900490565b6000831580612358575082155b6123935760405162461bcd60e51b81526004018080602001828103825260348152602001806137aa6034913960400191505060405180910390fd5b61239b613376565b6123a361166f565b60408301819052602083018260038111156123ba57fe5b60038111156123c557fe5b90525060009050816020015160038111156123dc57fe5b146123f857611dfe6009602b83602001516003811115611e7e57fe5b841561247957606081018590526040805160208101825290820151815261241f9086611764565b608083018190526020830182600381111561243657fe5b600381111561244157fe5b905250600090508160200151600381111561245857fe5b1461247457611dfe6009602983602001516003811115611e7e57fe5b6124f2565b6124958460405180602001604052808460400151815250613082565b60608301819052602083018260038111156124ac57fe5b60038111156124b757fe5b90525060009050816020015160038111156124ce57fe5b146124ea57611dfe6009602a83602001516003811115611e7e57fe5b608081018490525b60055460608201516040805163eabe7d9160e01b81523060048201526001600160a01b038a8116602483015260448201939093529051600093929092169163eabe7d919160648082019260209290919082900301818787803b15801561255757600080fd5b505af115801561256b573d6000803e3d6000fd5b505050506040513d602081101561258157600080fd5b5051905080156125a1576125986003602883612cf8565b92505050610ada565b6125b16008548360600151611985565b60a08401819052602084018260038111156125c857fe5b60038111156125d357fe5b90525060009050826020015160038111156125ea57fe5b14612606576125986009602e84602001516003811115611e7e57fe5b6001600160a01b0387166000908152600b6020526040902054606083015161262e9190611985565b60c084018190526020840182600381111561264557fe5b600381111561265057fe5b905250600090508260200151600381111561266757fe5b14612683576125986009602d84602001516003811115611e7e57fe5b81608001516126906117b8565b10156126a257612598600e602f611609565b6126b187836080015186613099565b60a082015160085560c08201516001600160a01b0388166000818152600b60209081526040918290209390935560608501518151908152905130937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef928290030190a36080820151606080840151604080516001600160a01b038c168152602081019490945283810191909152517fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a9299281900390910190a16001600160a01b038088166000908152600c6020526040812054606085015161279793919091169190612139565b60055460808301516060840151604080516351dff98960e01b81523060048201526001600160a01b038c81166024830152604482019490945260648101929092525191909216916351dff98991608480830192600092919082900301818387803b15801561280457600080fd5b505af1158015612818573d6000803e3d6000fd5b5060009250612825915050565b979650505050505050565b60055460408051634ef4c3e160e01b81523060048201526001600160a01b03858116602483015260448201859052915160009384938493911691634ef4c3e19160648082019260209290919082900301818787803b15801561289157600080fd5b505af11580156128a5573d6000803e3d6000fd5b505050506040513d60208110156128bb57600080fd5b5051905080156128df576128d26003601f83612cf8565b9250600091506117b19050565b6128e7613376565b6128ef61166f565b604083018190526020830182600381111561290657fe5b600381111561291157fe5b905250600090508160200151600381111561292857fe5b14612952576129446009602183602001516003811115611e7e57fe5b9350600092506117b1915050565b61295c8686611b06565b60c082018190526040805160208101825290830151815261297d9190613082565b606083018190526020830182600381111561299457fe5b600381111561299f57fe5b90525060009050816020015160038111156129b657fe5b14612a08576040805162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c4544604482015290519081900360640190fd5b612a186008548260600151612d5e565b6080830181905260208301826003811115612a2f57fe5b6003811115612a3a57fe5b9052506000905081602001516003811115612a5157fe5b14612a8d5760405162461bcd60e51b81526004018080602001828103825260288152602001806137826028913960400191505060405180910390fd5b600160601b816080015110612ad35760405162461bcd60e51b81526004018080602001828103825260238152602001806137de6023913960400191505060405180910390fd5b6001600160a01b0386166000908152600b60205260409020546060820151612afb9190612d5e565b60a0830181905260208301826003811115612b1257fe5b6003811115612b1d57fe5b9052506000905081602001516003811115612b3457fe5b14612b705760405162461bcd60e51b815260040180806020018281038252602b8152602001806136bb602b913960400191505060405180910390fd5b608081015160085560a08101516001600160a01b0387166000818152600b60209081526040918290209390935560c084015160608086015183519485529484019190915282820193909352517f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f929181900390910190a1606081015160408051918252516001600160a01b0388169130917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a36001600160a01b038087166000908152600c60205260408120546060840151612c58939190911690612139565b60055460c08201516060830151604080516341c728b960e01b81523060048201526001600160a01b038b81166024830152604482019490945260648101929092525191909216916341c728b991608480830192600092919082900301818387803b158015612cc557600080fd5b505af1158015612cd9573d6000803e3d6000fd5b5060009250612ce6915050565b8160c001519350935050509250929050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0846010811115612d2757fe5b846050811115612d3357fe5b604080519283526020830191909152818101859052519081900360600190a1836010811115610ada57fe5b600080838301848110612d76576000925090506117b1565b5060029150600090506117b1565b60008082612d9857506001905060006117b1565b6000838581612da357fe5b04915091509250929050565b6000836001600160601b0316836001600160601b031611158290612e515760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612e16578181015183820152602001612dfe565b50505050905090810190601f168015612e435780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000612e7d4360405180606001604052806033815260200161371a60339139613290565b905060008463ffffffff16118015612ec657506001600160a01b0385166000908152600d6020908152604080832063ffffffff6000198901811685529252909120548282169116145b15612f25576001600160a01b0385166000908152600d60209081526040808320600019880163ffffffff168452909152902080546fffffffffffffffffffffffff000000001916600160201b6001600160601b03851602179055612fc4565b60408051808201825263ffffffff80841682526001600160601b0380861660208085019182526001600160a01b038b166000818152600d83528781208c871682528352878120965187549451909516600160201b026fffffffffffffffffffffffff000000001995871663ffffffff19958616179590951694909417909555938252600e90935292909220805460018801909316929091169190911790555b604080516001600160601b0380861682528416602082015281516001600160a01b038816927fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724928290030190a25050505050565b6000838301826001600160601b0380871690831610156130795760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612e16578181015183820152602001612dfe565b50949350505050565b600080600061308f61334c565b61177b86866132ed565b600f546001600160a01b0316811561311d576010546040805163a9059cbb60e01b81526001600160a01b0392831660048201526024810186905290519183169163a9059cbb9160448082019260009290919082900301818387803b15801561310057600080fd5b505af1158015613114573d6000803e3d6000fd5b50505050613196565b806001600160a01b031663a9059cbb85856040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561317d57600080fd5b505af1158015613191573d6000803e3d6000fd5b505050505b60003d80156131ac57602081146131b657600080fd5b60001991506131c2565b60206000803e60005191505b5080613215576040805162461bcd60e51b815260206004820152601960248201527f544f4b454e5f5452414e534645525f4f55545f4641494c454400000000000000604482015290519081900360640190fd5b8215613289576010546040805163177ead8360e11b81526001600160a01b0388811660048301526024820188905291519190921691632efd5b0691604480830192600092919082900301818387803b15801561327057600080fd5b505af1158015613284573d6000803e3d6000fd5b505050505b5050505050565b600081600160201b84106132e55760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612e16578181015183820152602001612dfe565b509192915050565b60006132f761334c565b60008061330c670de0b6b3a7640000876119a8565b9092509050600082600381111561331f57fe5b1461333e575060408051602081019091526000815290925090506117b1565b6117aa818660000151612089565b6040518060200160405280600081525090565b604080518082019091526000808252602082015290565b6040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60035461010090046001600160a01b031633146134025760405162461bcd60e51b81526004018080602001828103825260248152602001806135f86024913960400191505060405180910390fd5b600754156134415760405162461bcd60e51b815260040180806020018281038252602381526020018061361c6023913960400191505060405180910390fd5b6006869055856134825760405162461bcd60e51b815260040180806020018281038252603081526020018061368b6030913960400191505060405180910390fd5b600061348d88610af1565b905080156134e2576040805162461bcd60e51b815260206004820152601a60248201527f73657474696e6720636f6d7074726f6c6c6572206661696c6564000000000000604482015290519081900360640190fd5b83516134f590600190602087019061355f565b50825161350990600290602086019061355f565b506003805460ff191660ff8416179055613521611981565b600755505050600992909255600a80546001600160a01b0319166001600160a01b039290921691909117905550506000805460ff1916600117905550565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106135a057805160ff19168380011785556135cd565b828001600101855582156135cd579182015b828111156135cd5782518255916020019190600101906135b2565b506135d99291506135dd565b5090565b61098491905b808211156135d957600081556001016135e356fe6f6e6c792061646d696e206d617920696e697469616c697a6520746865206d61726b65746d61726b6574206d6179206f6e6c7920626520696e697469616c697a6564206f6e6365494e563a3a6765745072696f72566f7465733a206e6f74207965742064657465726d696e6564494e563a3a5f6d6f7665566f7465733a20766f746520616d6f756e74206f766572666c6f7773696e697469616c2065786368616e67652072617465206d7573742062652067726561746572207468616e207a65726f2e4d494e545f4e45575f4143434f554e545f42414c414e43455f43414c43554c4154494f4e5f4641494c454473616e69747920636865636b3a206e657754696d656c6f636b457363726f77206d757374207573652074686973206d61726b6574494e563a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d6265722065786365656473203332206269747365786368616e67655261746553746f7265643a2065786368616e67655261746553746f726564496e7465726e616c206661696c65644d494e545f4e45575f544f54414c5f535550504c595f43414c43554c4154494f4e5f4641494c45446f6e65206f662072656465656d546f6b656e73496e206f722072656465656d416d6f756e74496e206d757374206265207a65726f4d494e545f4e45575f544f54414c5f535550504c595f4f5645525f4341504143495459494e563a3a5f6d6f7665566f7465733a20766f746520616d6f756e7420756e646572666c6f7773a265627a7a723158200fc92ea42071de51439db4ca006aaa0efd82c3c9775d952e80eb572e8cf4e0c264736f6c63430005100032

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

00000000000000000000000041d5d79431a913c4ae7d69a668ecdfe5ff9dfb680000000000000000000000004dcf7407ae5c07f8681e1659f626e114a7667339000000000000000000000000000000000000000000000000001772aa3f848000000000000000000000000000926df14a23be491164dcf93f4c468a50ef659d5b000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000012000000000000000000000000926df14a23be491164dcf93f4c468a50ef659d5b000000000000000000000000000000000000000000000000000000000000000478494e5600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000458494e5600000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : underlying_ (address): 0x41D5D79431A913C4aE7d69a668ecdfE5fF9DFB68
Arg [1] : comptroller_ (address): 0x4dCf7407AE5C07f8681e1659f626E114A7667339
Arg [2] : rewardPerBlock_ (uint256): 6600000000000000
Arg [3] : rewardTreasury_ (address): 0x926dF14a23BE491164dCF93f4c468A50ef659D5B
Arg [4] : name_ (string): xINV
Arg [5] : symbol_ (string): XINV
Arg [6] : decimals_ (uint8): 18
Arg [7] : admin_ (address): 0x926dF14a23BE491164dCF93f4c468A50ef659D5B

-----Encoded View---------------
12 Constructor Arguments found :
Arg [0] : 00000000000000000000000041d5d79431a913c4ae7d69a668ecdfe5ff9dfb68
Arg [1] : 0000000000000000000000004dcf7407ae5c07f8681e1659f626e114a7667339
Arg [2] : 000000000000000000000000000000000000000000000000001772aa3f848000
Arg [3] : 000000000000000000000000926df14a23be491164dcf93f4c468a50ef659d5b
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000100
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000140
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000012
Arg [7] : 000000000000000000000000926df14a23be491164dcf93f4c468a50ef659d5b
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [9] : 78494e5600000000000000000000000000000000000000000000000000000000
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [11] : 58494e5600000000000000000000000000000000000000000000000000000000


Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.