MATIC Price: $1.00 (+0.22%)
Gas: 82 GWei
 

Overview

MATIC Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 MATIC

MATIC Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
0x60806040430242612023-05-22 19:59:08310 days ago1684785548IN
 Create: OErc20
0 MATIC0.63089657130.65005498

Parent Txn Hash Block From To Value
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
OErc20

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 10 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 17 : OErc20.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

import "./abstract/OToken.sol";
import "./abstract/OErc20Storage.sol";

/**
 * @title 0VIX's OErc20 Contract
 * @notice OTokens which wrap an EIP-20 underlying
 * @author 0VIX
 */
contract OErc20 is OToken, OErc20Storage {
    bool public isInit = true;

    /**
     * @notice Initialize the new money market
     * @param underlying_ The address of the underlying asset
     * @param comptroller_ The address of the Comptroller
     * @param interestRateModel_ The address of the interest rate model
     * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18
     * @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
     */
    function init(
        address underlying_,
        IComptroller comptroller_,
        IInterestRateModel interestRateModel_,
        uint256 initialExchangeRateMantissa_,
        string memory name_,
        string memory symbol_,
        uint8 decimals_
    ) public {
        // OToken initialize does the bulk of the work
        require(!isInit, "contract already initialized");
        isInit = true;
        admin = payable(msg.sender);
        super.initialize(
            comptroller_,
            interestRateModel_,
            initialExchangeRateMantissa_,
            name_,
            symbol_,
            decimals_
        );

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

    /*** User Interface ***/

    /**
     * @notice Sender supplies assets into the market and receives oTokens in exchange
     * @dev Accrues interest whether or not the operation succeeds, unless reverted
     * @param mintAmount The amount of the underlying asset to supply
     * @dev Reverts upon any failure
     */
    function mint(uint256 mintAmount) external override {
        (uint256 err, ) = mintInternal(mintAmount);
        requireNoError(err, "mint failed");
    }

    /**
     * @notice Sender redeems oTokens in exchange for the underlying asset
     * @dev Accrues interest whether or not the operation succeeds, unless reverted
     * @param redeemTokens The number of oTokens to redeem into underlying
     */
    function redeem(uint256 redeemTokens) external override {
        redeemInternal(redeemTokens);
    }

    /**
     * @notice Sender redeems oTokens in exchange for a specified amount of underlying asset
     * @dev Accrues interest whether or not the operation succeeds, unless reverted
     * @param redeemAmount The amount of underlying to redeem
     */
    function redeemUnderlying(uint256 redeemAmount) external override{
        redeemUnderlyingInternal(redeemAmount);
    }

    /**
     * @notice Sender borrows assets from the protocol to their own address
     * @param borrowAmount The amount of the underlying asset to borrow
     */
    function borrow(uint256 borrowAmount) external override {
        borrowInternal(borrowAmount);
    }

    /**
     * @notice Sender repays their own borrow
     * @param repayAmount The amount to repay
     * @dev Reverts upon any failure
     */
    function repayBorrow(uint256 repayAmount) external override {
        (uint256 err, ) = repayBorrowInternal(repayAmount);
        requireNoError(err, "repayBorrow failed");
    }

    /**
     * @notice Sender repays a borrow belonging to borrower
     * @param borrower the account with the debt being payed off
     * @param repayAmount The amount to repay
     * @dev Reverts upon any failure
     */
    function repayBorrowBehalf(address borrower, uint256 repayAmount)
        external override
    {
        (uint256 err, ) = repayBorrowBehalfInternal(borrower, repayAmount);
        requireNoError(err, "repayBorrowBehalf failed");
    }

    /**
     * @notice The sender liquidates the borrowers collateral.
     *  The collateral seized is transferred to the liquidator.
     * @param borrower The borrower of this oToken to be liquidated
     * @param repayAmount The amount of the underlying borrowed asset to repay
     * @param oTokenCollateral The market in which to seize collateral from the borrower
     * @dev Reverts upon any failure
     */
    function liquidateBorrow(
        address borrower,
        uint256 repayAmount,
        IOToken oTokenCollateral
    ) external override {
        (uint256 err, ) = liquidateBorrowInternal(
            borrower,
            repayAmount,
            oTokenCollateral
        );
        requireNoError(err, "liquidateBorrow failed");
    }

    /**
     * @notice A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to admin (timelock)
     * @param token The address of the ERC-20 token to sweep
     */
    function sweepToken(IEIP20NonStandard token) external override {
        require(
            address(token) != underlying,
            "OErc20::sweepToken: can not sweep underlying token"
        );
        uint256 underlyingBalanceBefore = IEIP20(underlying).balanceOf(address(this));
        uint256 balance = token.balanceOf(address(this));
        token.transfer(admin, balance);

        require(underlyingBalanceBefore == IEIP20(underlying).balanceOf(address(this)), "underlying balance changed");
    }

    /**
     * @notice The sender adds to reserves.
     * @param addAmount The amount fo underlying token to add as reserves
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function _addReserves(uint256 addAmount) external override returns (uint256) {
        return _addReservesInternal(addAmount);
    }

    /*** 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 override view returns (uint256) {
        IEIP20 token = IEIP20(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, uint256 amount)
        internal override
        returns (uint256)
    {
        IEIP20NonStandard token = IEIP20NonStandard(underlying);
        uint256 balanceBefore = IEIP20(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
        uint256 balanceAfter = IEIP20(underlying).balanceOf(
            address(this)
        );
        require(balanceAfter >= balanceBefore, "TOKEN_TRANSFER_IN_OVERFLOW");
        return balanceAfter - balanceBefore; // underflow already checked above, just subtract
    }

    /**
     * @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, uint256 amount) internal override virtual {
        IEIP20NonStandard token = IEIP20NonStandard(underlying);
        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");
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 3 of 17 : IInterestRateModel.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

/**
  * @title 0VIX's IInterestRateModel Interface
  * @author 0VIX
  */
interface IInterestRateModel {
    /// @notice Indicator that this is an InterestRateModel contract (for inspection)
    function isInterestRateModel() external view returns(bool);

    /**
      * @notice Calculates the current borrow interest rate per timestmp
      * @param cash The total amount of cash the market has
      * @param borrows The total amount of borrows the market has outstanding
      * @param reserves The total amount of reserves the market has
      * @return The borrow rate per timestmp (as a percentage, and scaled by 1e18)
      */
    function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint);

    /**
      * @notice Calculates the current supply interest rate per timestmp
      * @param cash The total amount of cash the market has
      * @param borrows The total amount of borrows the market has outstanding
      * @param reserves The total amount of reserves the market has
      * @param reserveFactorMantissa The current reserve factor the market has
      * @return The supply rate per timestmp (as a percentage, and scaled by 1e18)
      */
    function getSupplyRate(uint cash, uint borrows, uint reserves, uint reserveFactorMantissa) external view returns (uint);

}

File 4 of 17 : IComptroller.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

import "../otokens/interfaces/IOToken.sol";
import "../PriceOracle.sol";

interface IComptroller {
    /// @notice Indicator that this is a Comptroller contract (for inspection)
    function isComptroller() external view returns(bool);

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

    function enterMarkets(address[] calldata oTokens) external returns (uint[] memory);
    function exitMarket(address oToken) external returns (uint);

    /*** Policy Hooks ***/

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

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

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

    function repayBorrowAllowed(
        address oToken,
        address payer,
        address borrower,
        uint repayAmount) external returns (uint);

    function liquidateBorrowAllowed(
        address oTokenBorrowed,
        address oTokenCollateral,
        address liquidator,
        address borrower,
        uint repayAmount) external returns (uint);

    function seizeAllowed(
        address oTokenCollateral,
        address oTokenBorrowed,
        address liquidator,
        address borrower,
        uint seizeTokens) external returns (uint);
        
    function seizeVerify(
        address oTokenCollateral,
        address oTokenBorrowed,
        address liquidator,
        address borrower,
        uint seizeTokens) external;

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

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

    function liquidateCalculateSeizeTokens(
        address oTokenBorrowed,
        address oTokenCollateral,
        uint repayAmount) external view returns (uint, uint);



    function isMarket(address market) external view returns(bool);
    function getBoostManager() external view returns(address);
    function getAllMarkets() external view returns(IOToken[] memory);
    function oracle() external view returns(PriceOracle);

    function updateAndDistributeSupplierRewardsForToken(
        address oToken,
        address account
    ) external;

    function updateAndDistributeBorrowerRewardsForToken(
        address oToken,
        address borrower
    ) external;

    function _setRewardSpeeds(
        address[] memory oTokens,
        uint256[] memory supplySpeeds,
        uint256[] memory borrowSpeeds
    ) external;
}

File 5 of 17 : CarefulMath.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

/**
  * @title Careful Math
  * @author 0VIX
  * @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) {
        unchecked {
            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) {
        unchecked {
            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) {
        unchecked {
            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) {
        unchecked {
            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 6 of 17 : ErrorReporter.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

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,
        SET_PROTOCOL_SEIZE_SHARE_ACCRUE_INTEREST_FAILED,
        SET_PROTOCOL_SEIZE_SHARE_OWNER_CHECK,
        SET_PROTOCOL_SEIZE_SHARE_FRESH_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);
    }
}

File 7 of 17 : Exponential.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

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

/**
 * @title Exponential module for storing fixed-precision decimals
 * @author 0VIX
 * @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 8 of 17 : ExponentialNoError.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

/**
 * @title Exponential module for storing fixed-precision decimals
 * @author 0VIX
 * @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) {
        return truncate(mul_(a, scalar));
    }

    /**
     * @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) {
        return truncate(mul_(a, scalar)) + 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) pure internal returns (uint224) {
        require(n <= type(uint224).max, "safe224 overflow");
        return uint224(n);
    }

    function safe32(uint n) pure internal returns (uint32) {
        require(n <= type(uint32).max, "safe32 overflow");
        return uint32(n);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 9 of 17 : OErc20Storage.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

import "../interfaces/IOErc20.sol";


abstract contract OErc20Storage is IOErc20 {
    /**
     * @notice Underlying asset for this OToken
     */
    address public override underlying;
}

File 10 of 17 : OToken.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

import "./OTokenStorage.sol";

import "../../interfaces/IComptroller.sol";
import "../../libraries/ErrorReporter.sol";
import "../../libraries/Exponential.sol";
import "../interfaces/IEIP20.sol";
import "../../interest-rate-models/interfaces/IInterestRateModel.sol";
import "../../vote-escrow/interfaces/IBoostManager.sol";

/**
 * @title 0VIX's OToken Contract
 * @notice Abstract base for OTokens
 * @author 0VIX
 */
abstract contract OToken is OTokenStorage, Exponential, TokenErrorReporter {
    /**
     * @notice Initialize the money market
     * @param comptroller_ The address of the Comptroller
     * @param interestRateModel_ The address of the interest rate model
     * @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(
        IComptroller comptroller_,
        IInterestRateModel interestRateModel_,
        uint256 initialExchangeRateMantissa_,
        string memory name_,
        string memory symbol_,
        uint8 decimals_
    ) internal {
        require(msg.sender == admin, "only admin may initialize");
        require(
            accrualBlockTimestamp == 0 && borrowIndex == 0,
            "already initialized"
        );

        // Set initial exchange rate
        initialExchangeRateMantissa = initialExchangeRateMantissa_;
        require(
            initialExchangeRateMantissa > 0,
            "init exchange rate must be > 0"
        );

        // Set the comptroller
        require(
            _setComptroller(comptroller_) == uint256(Error.NO_ERROR),
            "set comptroller failed"
        );

        // Initialize block timestamp and borrow index (block timestamp mocks depend on comptroller being set)
        accrualBlockTimestamp = getBlockTimestamp();
        borrowIndex = mantissaOne;

        // Set the interest rate model (depends on block timestamp / borrow index)
        require(
            _setInterestRateModelFresh(interestRateModel_) ==
                uint256(Error.NO_ERROR),
            "set interest rate model failed"
        );

        name = name_;
        symbol = symbol_;
        decimals = decimals_;

        // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund)
        _notEntered = true;
    }

    function _updateBoostSupplyBalances(
        address user,
        uint256 oldBalance,
        uint256 newBalance
    ) internal {
        address boostManager = comptroller.getBoostManager();
        if (
            boostManager != address(0) &&
            IBoostManager(boostManager).isAuthorized(address(this))
        ) {
            IBoostManager(boostManager).updateBoostSupplyBalances(
                address(this),
                user,
                oldBalance,
                newBalance
            );
        }
    }

    function _updateBoostBorrowBalances(
        address user,
        uint256 oldBalance,
        uint256 newBalance
    ) internal {
        address boostManager = comptroller.getBoostManager();
        if (
            boostManager != address(0) &&
            IBoostManager(boostManager).isAuthorized(address(this))
        ) {
            IBoostManager(boostManager).updateBoostBorrowBalances(
                address(this),
                user,
                oldBalance,
                newBalance
            );
        }
    }

    /**
     * @notice Transfer `tokens` tokens from `src` to `dst` by `spender`
     * @dev Called by both `transfer` and `transferFrom` internally
     * @param spender The address of the account performing the transfer
     * @param src The address of the source account
     * @param dst The address of the destination account
     * @param tokens The number of tokens to transfer
     * @return Whether or not the transfer succeeded
     */
    function transferTokens(
        address spender,
        address src,
        address dst,
        uint256 tokens
    ) internal returns (uint256) {
        /* Fail if transfer not allowed */
        uint256 allowed = comptroller.transferAllowed(
            address(this),
            src,
            dst,
            tokens
        );
        require(allowed == 0, "ERC20: transfer not allowed");

        /* Do not allow self-transfers */
        require(src != dst, "ERC20: self-transfer not allowed");

        /* Get the allowance, infinite for the account owner */
        uint256 startingAllowance = 0;
        if (spender == src) {
            startingAllowance = type(uint256).max;
        } else {
            startingAllowance = transferAllowances[src][spender];
        }

        /* Do the calculations, checking for {under,over}flow */
        MathError mathErr;
        uint256 allowanceNew;
        uint256 srcTokensNew;
        uint256 dstTokensNew;

        (mathErr, allowanceNew) = subUInt(startingAllowance, tokens);
        require(
            mathErr == MathError.NO_ERROR,
            "ERC20: decreased allowance below zero"
        );

        (mathErr, srcTokensNew) = subUInt(accountTokens[src], tokens);
        require(
            mathErr == MathError.NO_ERROR,
            "ERC20: transfer amount exceeds balance"
        );

        (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens);
        require(
            mathErr == MathError.NO_ERROR,
            "ERC20: maximum destination balance reached"
        );

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

        _updateBoostSupplyBalances(src, accountTokens[src], srcTokensNew);
        _updateBoostSupplyBalances(dst, accountTokens[dst], dstTokensNew);

        accountTokens[src] = srcTokensNew;
        accountTokens[dst] = dstTokensNew;

        /* Eat some of the allowance (if necessary) */
        if (startingAllowance != type(uint256).max) {
            transferAllowances[src][spender] = allowanceNew;
        }

        /* We emit a Transfer event */
        emit Transfer(src, dst, tokens);

        // unused function
        // comptroller.transferVerify(address(this), src, dst, tokens);

        return uint256(Error.NO_ERROR);
    }

    /**
     * @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
        override
        nonReentrant
        returns (bool)
    {
        return
            transferTokens(msg.sender, msg.sender, dst, amount) ==
            uint256(Error.NO_ERROR);
    }

    /**
     * @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 override nonReentrant returns (bool) {
        return
            transferTokens(msg.sender, src, dst, amount) ==
            uint256(Error.NO_ERROR);
    }

    /**
     * @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
        override
        returns (bool)
    {
        address src = msg.sender;
        transferAllowances[src][spender] = amount;
        emit Approval(src, spender, amount);
        return true;
    }

    /**
     * @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
        override
        returns (uint256)
    {
        return transferAllowances[owner][spender];
    }

    /**
     * @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 override returns (uint256) {
        return accountTokens[owner];
    }

    /**
     * @notice Get the underlying balance of the `owner`
     * @dev This also accrues interest in a transaction
     * @param owner The address of the account to query
     * @return The amount of underlying owned by `owner`
     */
    function balanceOfUnderlying(address owner)
        external
        override
        returns (uint256)
    {
        Exp memory exchangeRate = Exp({mantissa: exchangeRateCurrent()});
        (MathError mErr, uint256 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
        override
        returns (
            uint256,
            uint256,
            uint256,
            uint256
        )
    {
        uint256 oTokenBalance = accountTokens[account];
        uint256 borrowBalance;
        uint256 exchangeRateMantissa;

        MathError mErr;

        (mErr, borrowBalance) = borrowBalanceStoredInternal(account);
        if (mErr != MathError.NO_ERROR) {
            return (uint256(Error.MATH_ERROR), 0, 0, 0);
        }

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

        return (
            uint256(Error.NO_ERROR),
            oTokenBalance,
            borrowBalance,
            exchangeRateMantissa
        );
    }

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

    /**
     * @notice Returns the current per-timestamp borrow interest rate for this oToken
     * @return The borrow interest rate per timestmp, scaled by 1e18
     */
    function borrowRatePerTimestamp() external view override returns (uint256) {
        return
            interestRateModel.getBorrowRate(
                getCashPrior(),
                totalBorrows,
                totalReserves
            );
    }

    /**
     * @notice Returns the current per-timestamp supply interest rate for this oToken
     * @return The supply interest rate per timestmp, scaled by 1e18
     */
    function supplyRatePerTimestamp() external view override returns (uint256) {
        return
            interestRateModel.getSupplyRate(
                getCashPrior(),
                totalBorrows,
                totalReserves,
                reserveFactorMantissa
            );
    }

    /**
     * @notice Returns the current total borrows plus accrued interest
     * @return The total borrows with interest
     */
    function totalBorrowsCurrent()
        external
        override
        nonReentrant
        returns (uint256)
    {
        require(
            accrueInterest() == uint256(Error.NO_ERROR),
            "accrue interest failed"
        );
        return totalBorrows;
    }

    /**
     * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex
     * @param account The address whose balance should be calculated after updating borrowIndex
     * @return The calculated balance
     */
    function borrowBalanceCurrent(address account)
        external
        override
        nonReentrant
        returns (uint256)
    {
        require(
            accrueInterest() == uint256(Error.NO_ERROR),
            "accrue interest failed"
        );
        return borrowBalanceStored(account);
    }

    /**
     * @notice Return the borrow balance of account based on stored data
     * @param account The address whose balance should be calculated
     * @return The calculated balance
     */
    function borrowBalanceStored(address account)
        public
        view
        override
        returns (uint256)
    {
        (MathError err, uint256 result) = borrowBalanceStoredInternal(account);
        require(err == MathError.NO_ERROR, "borrowBalanceStored failed");
        return result;
    }

    /**
     * @notice Return the borrow balance of account based on stored data
     * @param account The address whose balance should be calculated
     * @return (error code, the calculated balance or 0 if error code is non-zero)
     */
    function borrowBalanceStoredInternal(address account)
        internal
        view
        returns (MathError, uint256)
    {
        /* Note: we do not assert that the market is up to date */
        MathError mathErr;
        uint256 principalTimesIndex;
        uint256 result;

        /* Get borrowBalance and borrowIndex */
        BorrowSnapshot storage borrowSnapshot = accountBorrows[account];

        /* If borrowBalance = 0 then borrowIndex is likely also 0.
         * Rather than failing the calculation with a division by 0, we immediately return 0 in this case.
         */
        if (borrowSnapshot.principal == 0) {
            return (MathError.NO_ERROR, 0);
        }

        /* Calculate new borrow balance using the interest index:
         *  recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex
         */
        (mathErr, principalTimesIndex) = mulUInt(
            borrowSnapshot.principal,
            borrowIndex
        );
        if (mathErr != MathError.NO_ERROR) {
            return (mathErr, 0);
        }

        (mathErr, result) = divUInt(
            principalTimesIndex,
            borrowSnapshot.interestIndex
        );
        if (mathErr != MathError.NO_ERROR) {
            return (mathErr, 0);
        }

        return (MathError.NO_ERROR, result);
    }

    /**
     * @notice Accrue interest then return the up-to-date exchange rate
     * @return Calculated exchange rate scaled by 1e18
     */
    function exchangeRateCurrent()
        public
        override
        nonReentrant
        returns (uint256)
    {
        require(
            accrueInterest() == uint256(Error.NO_ERROR),
            "accrue interest failed"
        );
        return exchangeRateStored();
    }

    /**
     * @notice Calculates the exchange rate from the underlying to the OToken
     * @dev This function does not accrue interest before calculating the exchange rate
     * @return Calculated exchange rate scaled by 1e18
     */
    function exchangeRateStored() public view override returns (uint256) {
        (MathError err, uint256 result) = exchangeRateStoredInternal();
        require(err == MathError.NO_ERROR, "exchangeRateStored failed");
        return result;
    }

    /**
     * @notice Calculates the exchange rate from the underlying to the OToken
     * @dev This function does not accrue interest before calculating the exchange rate
     * @return (error code, calculated exchange rate scaled by 1e18)
     */
    function exchangeRateStoredInternal()
        internal
        view
        virtual
        returns (MathError, uint256)
    {
        uint256 _totalSupply = totalSupply;
        if (_totalSupply == 0) {
            /*
             * If there are no tokens minted:
             *  exchangeRate = initialExchangeRate
             */
            return (MathError.NO_ERROR, initialExchangeRateMantissa);
        } else {
            /*
             * Otherwise:
             *  exchangeRate = (totalCash + totalBorrows - totalReserves) / totalSupply
             */
            uint256 totalCash = getCashPrior();
            uint256 cashPlusBorrowsMinusReserves;
            Exp memory exchangeRate;
            MathError mathErr;

            (mathErr, cashPlusBorrowsMinusReserves) = addThenSubUInt(
                totalCash,
                totalBorrows,
                totalReserves
            );
            if (mathErr != MathError.NO_ERROR) {
                return (mathErr, 0);
            }

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

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

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

    /**
     * @notice Applies accrued interest to total borrows and reserves
     * @dev This calculates interest accrued from the last checkpointed block
     *   up to the current block and writes new checkpoint to storage.
     */
    function accrueInterest() public override returns (uint256) {
        /* Remember the initial block timestamp */
        uint256 currentBlockTimestamp = getBlockTimestamp();
        uint256 accrualBlockTimestampPrior = accrualBlockTimestamp;

        /* Short-circuit accumulating 0 interest */
        if (accrualBlockTimestampPrior == currentBlockTimestamp) {
            return uint256(Error.NO_ERROR);
        }

        /* Read the previous values out of storage */
        uint256 cashPrior = getCashPrior();
        uint256 borrowsPrior = totalBorrows;
        uint256 reservesPrior = totalReserves;
        uint256 borrowIndexPrior = borrowIndex;

        /* Calculate the current borrow interest rate */
        uint256 borrowRateMantissa = interestRateModel.getBorrowRate(
            cashPrior,
            borrowsPrior,
            reservesPrior
        );
        require(
            borrowRateMantissa <= borrowRateMaxMantissa,
            "borrow rate is absurdly high"
        );

        /* Calculate the number of blocks elapsed since the last accrual */
        (MathError mathErr, uint256 blockDelta) = subUInt(
            currentBlockTimestamp,
            accrualBlockTimestampPrior
        );
        require(
            mathErr == MathError.NO_ERROR,
            "could not calculate block delta"
        );

        /*
         * Calculate the interest accumulated into borrows and reserves and the new index:
         *  simpleInterestFactor = borrowRate * blockDelta
         *  interestAccumulated = simpleInterestFactor * totalBorrows
         *  totalBorrowsNew = interestAccumulated + totalBorrows
         *  totalReservesNew = interestAccumulated * reserveFactor + totalReserves
         *  borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex
         */

        Exp memory simpleInterestFactor;
        uint256 interestAccumulated;
        uint256 totalBorrowsNew;
        uint256 totalReservesNew;
        uint256 borrowIndexNew;

        (mathErr, simpleInterestFactor) = mulScalar(
            Exp({mantissa: borrowRateMantissa}),
            blockDelta
        );
        if (mathErr != MathError.NO_ERROR) {
            return
                failOpaque(
                    Error.MATH_ERROR,
                    FailureInfo
                        .ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED,
                    uint256(mathErr)
                );
        }

        (mathErr, interestAccumulated) = mulScalarTruncate(
            simpleInterestFactor,
            borrowsPrior
        );
        if (mathErr != MathError.NO_ERROR) {
            return
                failOpaque(
                    Error.MATH_ERROR,
                    FailureInfo
                        .ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED,
                    uint256(mathErr)
                );
        }

        (mathErr, totalBorrowsNew) = addUInt(interestAccumulated, borrowsPrior);
        if (mathErr != MathError.NO_ERROR) {
            return
                failOpaque(
                    Error.MATH_ERROR,
                    FailureInfo
                        .ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,
                    uint256(mathErr)
                );
        }

        (mathErr, totalReservesNew) = mulScalarTruncateAddUInt(
            Exp({mantissa: reserveFactorMantissa}),
            interestAccumulated,
            reservesPrior
        );
        if (mathErr != MathError.NO_ERROR) {
            return
                failOpaque(
                    Error.MATH_ERROR,
                    FailureInfo
                        .ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED,
                    uint256(mathErr)
                );
        }

        (mathErr, borrowIndexNew) = mulScalarTruncateAddUInt(
            simpleInterestFactor,
            borrowIndexPrior,
            borrowIndexPrior
        );
        if (mathErr != MathError.NO_ERROR) {
            return
                failOpaque(
                    Error.MATH_ERROR,
                    FailureInfo
                        .ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED,
                    uint256(mathErr)
                );
        }

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

        /* We write the previously calculated values into storage */
        accrualBlockTimestamp = currentBlockTimestamp;
        borrowIndex = borrowIndexNew;
        totalBorrows = totalBorrowsNew;
        totalReserves = totalReservesNew;

        /* We emit an AccrueInterest event */
        emit AccrueInterest(
            cashPrior,
            interestAccumulated,
            borrowIndexNew,
            totalBorrowsNew
        );

        return uint256(Error.NO_ERROR);
    }

    /**
     * @notice Sender supplies assets into the market and receives oTokens in exchange
     * @dev Accrues interest whether or not the operation succeeds, unless reverted
     * @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(uint256 mintAmount)
        internal
        nonReentrant
        returns (uint256, uint256)
    {
        uint256 error = accrueInterest();
        if (error != uint256(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;
    }

    /**
     * @notice User supplies assets into the market and receives oTokens in exchange
     * @dev Assumes interest has already been accrued up to the current block
     * @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, uint256 mintAmount)
        internal
        returns (uint256, uint256)
    {
        /* Fail if mint not allowed */
        {
            uint256 allowed = comptroller.mintAllowed(
                address(this),
                minter,
                mintAmount
            );
            if (allowed != 0) {
                return (
                    failOpaque(
                        Error.COMPTROLLER_REJECTION,
                        FailureInfo.MINT_COMPTROLLER_REJECTION,
                        allowed
                    ),
                    0
                );
            }
        }

        /* Verify market's block timestamp equals current block timestamp */
        if (accrualBlockTimestamp != getBlockTimestamp()) {
            return (
                fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK),
                0
            );
        }

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

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

        /*
         *  We call `doTransferIn` for the minter and the mintAmount.
         *  Note: The oToken must handle variations between ERC-20 and NATIVE 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 oToken holds an additional `actualMintAmount`
         *  of cash.
         */
        uint256 actualMintAmount = doTransferIn(minter, mintAmount);

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

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

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

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

        _updateBoostSupplyBalances(
            minter,
            accountTokens[minter],
            accountTokensNew
        );

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

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

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

        return (uint256(Error.NO_ERROR), actualMintAmount);
    }

    /**
     * @notice Sender redeems oTokens in exchange for the underlying asset
     * @dev Accrues interest whether or not the operation succeeds, unless reverted
     * @param redeemTokens The number of oTokens to redeem into underlying
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function redeemInternal(uint256 redeemTokens)
        internal
        nonReentrant
        returns (uint256)
    {
        uint256 error = accrueInterest();
        if (error != uint256(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(payable(msg.sender), redeemTokens, 0);
    }

    /**
     * @notice Sender redeems oTokens in exchange for a specified amount of underlying asset
     * @dev Accrues interest whether or not the operation succeeds, unless reverted
     * @param redeemAmount The amount of underlying to receive from redeeming oTokens
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function redeemUnderlyingInternal(uint256 redeemAmount)
        internal
        nonReentrant
        returns (uint256)
    {
        uint256 error = accrueInterest();
        if (error != uint256(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(payable(msg.sender), 0, redeemAmount);
    }

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

    /**
     * @notice User redeems oTokens in exchange for the underlying asset
     * @dev Assumes interest has already been accrued up to the current block
     * @param redeemer The address of the account which is redeeming the tokens
     * @param redeemTokensIn The number of oTokens 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 oTokens (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,
        uint256 redeemTokensIn,
        uint256 redeemAmountIn
    ) internal returns (uint256) {
        require(
            redeemTokensIn == 0 || redeemAmountIn == 0,
            "tokensIn or amountIn must be 0"
        );

        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,
                    uint256(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
             */
            if (redeemTokensIn >= accountTokens[redeemer]) {
                vars.redeemTokens = accountTokens[redeemer];
            } else {
                vars.redeemTokens = redeemTokensIn;
            }

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

                (vars.mathErr, vars.redeemAmount) = mulScalarTruncate(
                    Exp({mantissa: vars.exchangeRateMantissa}),
                    vars.redeemTokens
                );
                if (vars.mathErr != MathError.NO_ERROR) {
                    return
                        failOpaque(
                            Error.MATH_ERROR,
                            FailureInfo
                                .REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,
                            uint256(vars.mathErr)
                        );
                }
            } else {
                vars.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,
                            uint256(vars.mathErr)
                        );
                }
            }
        }

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

        /* Verify market's block timestamp equals current block timestamp */
        if (accrualBlockTimestamp != getBlockTimestamp()) {
            return
                fail(
                    Error.MARKET_NOT_FRESH,
                    FailureInfo.REDEEM_FRESHNESS_CHECK
                );
        }

        /*
         * 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,
                    uint256(vars.mathErr)
                );
        }
        if (vars.redeemTokens > accountTokens[redeemer])
            vars.redeemTokens = accountTokens[redeemer];
        (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,
                    uint256(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)

        _updateBoostSupplyBalances(
            redeemer,
            accountTokens[redeemer],
            vars.accountTokensNew
        );
        /* 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 call the defense hook */
        comptroller.redeemVerify(
            address(this),
            redeemer,
            vars.redeemAmount,
            vars.redeemTokens
        );

        /*
         * We invoke doTransferOut for the redeemer and the redeemAmount.
         *  Note: The oToken must handle variations between ERC-20 and NATIVE underlying.
         *  On success, the oToken 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);

        return uint256(Error.NO_ERROR);
    }

    /**
     * @notice Sender borrows assets from the protocol to their own address
     * @param borrowAmount The amount of the underlying asset to borrow
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function borrowInternal(uint256 borrowAmount)
        internal
        nonReentrant
        returns (uint256)
    {
        uint256 error = accrueInterest();
        if (error != uint256(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.BORROW_ACCRUE_INTEREST_FAILED);
        }
        // borrowFresh emits borrow-specific logs on errors, so we don't need to
        return borrowFresh(payable(msg.sender), borrowAmount);
    }

    /**
     * @notice Users borrow assets from the protocol to their own address
     * @param borrowAmount The amount of the underlying asset to borrow
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function borrowFresh(address payable borrower, uint256 borrowAmount)
        internal
        returns (uint256)
    {
        /* Fail if borrow not allowed */
        {
            uint256 allowed = comptroller.borrowAllowed(
                address(this),
                borrower,
                borrowAmount
            );
            if (allowed != 0) {
                return
                    failOpaque(
                        Error.COMPTROLLER_REJECTION,
                        FailureInfo.BORROW_COMPTROLLER_REJECTION,
                        allowed
                    );
            }
        }

        /* Verify market's block timestamp equals current block timestamp */
        if (accrualBlockTimestamp != getBlockTimestamp()) {
            return
                fail(
                    Error.MARKET_NOT_FRESH,
                    FailureInfo.BORROW_FRESHNESS_CHECK
                );
        }

        /* Fail gracefully if protocol has insufficient underlying cash */
        if (getCashPrior() < borrowAmount) {
            return
                fail(
                    Error.TOKEN_INSUFFICIENT_CASH,
                    FailureInfo.BORROW_CASH_NOT_AVAILABLE
                );
        }

        MathError mathErr;

        /*
         * We calculate the new borrower and total borrow balances, failing on overflow:
         *  accountBorrowsNew = accountBorrows + borrowAmount
         *  totalBorrowsNew = totalBorrows + borrowAmount
         */
        uint256 _accountBorrows;
        (mathErr, _accountBorrows) = borrowBalanceStoredInternal(borrower);
        if (mathErr != MathError.NO_ERROR) {
            return
                failOpaque(
                    Error.MATH_ERROR,
                    FailureInfo.BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,
                    uint256(mathErr)
                );
        }
        uint256 oldBorrowedBalance = _accountBorrows;

        uint256 accountBorrowsNew;
        (mathErr, accountBorrowsNew) = addUInt(_accountBorrows, borrowAmount);
        if (mathErr != MathError.NO_ERROR) {
            return
                failOpaque(
                    Error.MATH_ERROR,
                    FailureInfo
                        .BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED,
                    uint256(mathErr)
                );
        }

        uint256 totalBorrowsNew;
        (mathErr, totalBorrowsNew) = addUInt(totalBorrows, borrowAmount);
        if (mathErr != MathError.NO_ERROR) {
            return
                failOpaque(
                    Error.MATH_ERROR,
                    FailureInfo.BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED,
                    uint256(mathErr)
                );
        }

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

        /* We write the previously calculated values into storage */
        accountBorrows[borrower].principal = accountBorrowsNew;
        accountBorrows[borrower].interestIndex = borrowIndex;
        totalBorrows = totalBorrowsNew;

        /* We emit a Borrow event */
        emit Borrow(borrower, borrowAmount, accountBorrowsNew, totalBorrowsNew);

        _updateBoostBorrowBalances(
            borrower,
            oldBorrowedBalance,
            accountBorrowsNew
        );

        /* We call the defense hook */
        // unused function
        // comptroller.borrowVerify(address(this), borrower, borrowAmount);

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

        return uint256(Error.NO_ERROR);
    }

    /**
     * @notice Sender repays their own borrow
     * @param repayAmount The amount to repay
     * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.
     */
    function repayBorrowInternal(uint256 repayAmount)
        internal
        nonReentrant
        returns (uint256, uint256)
    {
        uint256 error = accrueInterest();
        if (error != uint256(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.REPAY_BORROW_ACCRUE_INTEREST_FAILED
                ),
                0
            );
        }
        // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to
        return repayBorrowFresh(msg.sender, msg.sender, repayAmount);
    }

    /**
     * @notice Sender repays a borrow belonging to borrower
     * @param borrower the account with the debt being payed off
     * @param repayAmount The amount to repay
     * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.
     */
    function repayBorrowBehalfInternal(address borrower, uint256 repayAmount)
        internal
        nonReentrant
        returns (uint256, uint256)
    {
        uint256 error = accrueInterest();
        if (error != uint256(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.REPAY_BEHALF_ACCRUE_INTEREST_FAILED
                ),
                0
            );
        }
        // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to
        return repayBorrowFresh(msg.sender, borrower, repayAmount);
    }

    struct RepayBorrowLocalVars {
        Error err;
        MathError mathErr;
        uint256 repayAmount;
        uint256 borrowerIndex;
        uint256 accountBorrows;
        uint256 accountBorrowsNew;
        uint256 totalBorrowsNew;
        uint256 actualRepayAmount;
    }

    /**
     * @notice Borrows are repaid by another user (possibly the borrower).
     * @param payer the account paying off the borrow
     * @param borrower the account with the debt being payed off
     * @param repayAmount the amount of undelrying tokens being returned
     * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.
     */
    function repayBorrowFresh(
        address payer,
        address borrower,
        uint256 repayAmount
    ) internal returns (uint256, uint256) {
        /* Fail if repayBorrow not allowed */
        uint256 allowed = comptroller.repayBorrowAllowed(
            address(this),
            payer,
            borrower,
            repayAmount
        );
        if (allowed != 0) {
            return (
                failOpaque(
                    Error.COMPTROLLER_REJECTION,
                    FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION,
                    allowed
                ),
                0
            );
        }

        /* Verify market's block timestamp equals current block timestamp */
        if (accrualBlockTimestamp != getBlockTimestamp()) {
            return (
                fail(
                    Error.MARKET_NOT_FRESH,
                    FailureInfo.REPAY_BORROW_FRESHNESS_CHECK
                ),
                0
            );
        }

        RepayBorrowLocalVars memory vars;
        uint256 oldBorrowedBalance = borrowBalanceStored(borrower);

        /* We remember the original borrowerIndex for verification purposes */
        vars.borrowerIndex = accountBorrows[borrower].interestIndex;

        /* We fetch the amount the borrower owes, with accumulated interest */
        (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal(
            borrower
        );
        if (vars.mathErr != MathError.NO_ERROR) {
            return (
                failOpaque(
                    Error.MATH_ERROR,
                    FailureInfo
                        .REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,
                    uint256(vars.mathErr)
                ),
                0
            );
        }

        /* If repayAmount >= accountBorrows, repayAmount = accountBorrows */
        if (repayAmount >= vars.accountBorrows) {
            vars.repayAmount = vars.accountBorrows;
        } else {
            vars.repayAmount = repayAmount;
        }

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

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

        /*
         * We calculate the new borrower and total borrow balances, failing on underflow:
         *  accountBorrowsNew = accountBorrows - actualRepayAmount
         *  totalBorrowsNew = totalBorrows - actualRepayAmount
         */
        (vars.mathErr, vars.accountBorrowsNew) = subUInt(
            vars.accountBorrows,
            vars.actualRepayAmount
        );
        require(
            vars.mathErr == MathError.NO_ERROR,
            "REPAY_NEW_ACCOUNT_BALANCE_FAILED"
        );

        (vars.mathErr, vars.totalBorrowsNew) = subUInt(
            totalBorrows,
            vars.actualRepayAmount
        );
        require(
            vars.mathErr == MathError.NO_ERROR,
            "REPAY_NEW_TOTAL_BALANCE_FAILED"
        );

        /* We write the previously calculated values into storage */
        accountBorrows[borrower].principal = vars.accountBorrowsNew;
        accountBorrows[borrower].interestIndex = borrowIndex;
        totalBorrows = vars.totalBorrowsNew;

        /* We emit a RepayBorrow event */
        emit RepayBorrow(
            payer,
            borrower,
            vars.actualRepayAmount,
            vars.accountBorrowsNew,
            vars.totalBorrowsNew
        );
        _updateBoostBorrowBalances(
            borrower,
            oldBorrowedBalance,
            vars.accountBorrowsNew
        );

        /* We call the defense hook */
        // unused function
        // comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex);

        return (uint256(Error.NO_ERROR), vars.actualRepayAmount);
    }

    /**
     * @notice The sender liquidates the borrowers collateral.
     *  The collateral seized is transferred to the liquidator.
     * @param borrower The borrower of this oToken to be liquidated
     * @param oTokenCollateral The market in which to seize collateral from the borrower
     * @param repayAmount The amount of the underlying borrowed asset to repay
     * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.
     */
    function liquidateBorrowInternal(
        address borrower,
        uint256 repayAmount,
        IOToken oTokenCollateral
    ) internal nonReentrant returns (uint256, uint256) {
        uint256 error = accrueInterest();
        if (error != uint256(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed
            return (
                fail(
                    Error(error),
                    FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED
                ),
                0
            );
        }

        error = oTokenCollateral.accrueInterest();
        if (error != uint256(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed
            return (
                fail(
                    Error(error),
                    FailureInfo.LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED
                ),
                0
            );
        }

        // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to
        return
            liquidateBorrowFresh(
                msg.sender,
                borrower,
                repayAmount,
                oTokenCollateral
            );
    }

    /**
     * @notice The liquidator liquidates the borrowers collateral.
     *  The collateral seized is transferred to the liquidator.
     * @param borrower The borrower of this oToken to be liquidated
     * @param liquidator The address repaying the borrow and seizing collateral
     * @param oTokenCollateral The market in which to seize collateral from the borrower
     * @param repayAmount The amount of the underlying borrowed asset to repay
     * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.
     */
    function liquidateBorrowFresh(
        address liquidator,
        address borrower,
        uint256 repayAmount,
        IOToken oTokenCollateral
    ) internal returns (uint256, uint256) {

        return (uint256(Error.NO_ERROR), 0);
    }

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

    struct SeizeInternalLocalVars {
        MathError mathErr;
        uint256 borrowerTokensNew;
        uint256 liquidatorTokensNew;
        uint256 liquidatorSeizeTokens;
        uint256 protocolSeizeTokens;
        uint256 protocolSeizeAmount;
        uint256 exchangeRateMantissa;
        uint256 totalReservesNew;
        uint256 totalSupplyNew;
    }

    /**
     * @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 OToken.
     *  Its absolutely critical to use msg.sender as the seizer oToken and not a parameter.
     * @param seizerToken The contract seizing the collateral (i.e. borrowed oToken)
     * @param liquidator The account receiving seized collateral
     * @param borrower The account having collateral seized
     * @param seizeTokens The number of oTokens to seize
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function seizeInternal(
        address seizerToken,
        address liquidator,
        address borrower,
        uint256 seizeTokens
    ) internal returns (uint256) {
        /* Fail if seize not allowed */
        
        return uint256(Error.NO_ERROR);
    }

    /*** Admin Functions ***/
    function unauthorized(FailureInfo info) internal returns (uint) {
        return fail(Error.UNAUTHORIZED, info);
    }

    function setAdmin(address payable _admin) public {
        require(msg.sender == admin, "Unauthorized");
        address oldAdmin = admin;
        admin = _admin;
        emit NewAdmin(oldAdmin, admin);
    }

    /**
     * @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
        override
        returns (uint256)
    {
        // Check caller = admin
        if (msg.sender != admin) {
            return unauthorized(FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);
        }
        // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)
        emit NewPendingAdmin(pendingAdmin, newPendingAdmin);

        // Store pendingAdmin with value newPendingAdmin
        pendingAdmin = newPendingAdmin;

        return uint256(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 override returns (uint256) {
        // Check caller is pendingAdmin and pendingAdmin ≠ address(0)
        if (msg.sender != pendingAdmin || msg.sender == address(0)) {
            return 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 = payable(address(0));

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

        return uint256(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(IComptroller newComptroller)
        public
        override
        returns (uint256)
    {
        // Check caller is admin
        if (msg.sender != admin) {
            return unauthorized(FailureInfo.SET_COMPTROLLER_OWNER_CHECK);
        }

        IComptroller 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 uint256(Error.NO_ERROR);
    }

    /**
     * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh
     * @dev Admin function to accrue interest and set a new reserve factor
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function _setReserveFactor(uint256 newReserveFactorMantissa)
        external
        override
        nonReentrant
        returns (uint256)
    {
        uint256 error = accrueInterest();
        if (error != uint256(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reserve factor change failed.
            return
                fail(
                    Error(error),
                    FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED
                );
        }
        // _setReserveFactorFresh emits reserve-factor-specific logs on errors, so we don't need to.
        return _setReserveFactorFresh(newReserveFactorMantissa);
    }

    /**
     * @notice Sets a new reserve factor for the protocol (*requires fresh interest accrual)
     * @dev Admin function to set a new reserve factor
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function _setReserveFactorFresh(uint256 newReserveFactorMantissa)
        internal
        returns (uint256)
    {
        return 0;
    }

    /**
     * @notice Accrues interest and reduces reserves by transferring from msg.sender
     * @param addAmount Amount of addition to reserves
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function _addReservesInternal(uint256 addAmount)
        internal
        nonReentrant
        returns (uint256)
    {
        uint256 error = accrueInterest();
        if (error != uint256(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed.
            return
                fail(
                    Error(error),
                    FailureInfo.ADD_RESERVES_ACCRUE_INTEREST_FAILED
                );
        }

        // _addReservesFresh emits reserve-addition-specific logs on errors, so we don't need to.
        (error, ) = _addReservesFresh(addAmount);
        return error;
    }

    /**
     * @notice Add reserves by transferring from caller
     * @dev Requires fresh interest accrual
     * @param addAmount Amount of addition to reserves
     * @return (uint, uint) An error code (0=success, otherwise a failure (see ErrorReporter.sol for details)) and the actual amount added, net token fees
     */
    function _addReservesFresh(uint256 addAmount)
        internal
        returns (uint256, uint256)
    {
        return (0,0);
    }

    /**
     * @notice Accrues interest and reduces reserves by transferring to admin
     * @param reduceAmount Amount of reduction to reserves
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function _reduceReserves(uint256 reduceAmount)
        external
        override
        nonReentrant
        returns (uint256)
    {
        uint256 error = accrueInterest();
        if (error != uint256(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed.
            return
                fail(
                    Error(error),
                    FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED
                );
        }
        // _reduceReservesFresh emits reserve-reduction-specific logs on errors, so we don't need to.
        return _reduceReservesFresh(reduceAmount);
    }

    /**
     * @notice Reduces reserves by transferring to admin
     * @dev Requires fresh interest accrual
     * @param reduceAmount Amount of reduction to reserves
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function _reduceReservesFresh(uint256 reduceAmount)
        internal
        returns (uint256)
    {
        return uint256(Error.NO_ERROR);
    }

    /**
     * @notice accrues interest and updates the interest rate model using _setInterestRateModelFresh
     * @dev Admin function to accrue interest and update the interest rate model
     * @param newInterestRateModel the new interest rate model to use
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function _setInterestRateModel(IInterestRateModel newInterestRateModel)
        public
        override
        returns (uint256)
    {
        uint256 error = accrueInterest();
        if (error != uint256(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed
            return
                fail(
                    Error(error),
                    FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED
                );
        }
        // _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to.
        return _setInterestRateModelFresh(newInterestRateModel);
    }

    /**
     * @notice updates the interest rate model (*requires fresh interest accrual)
     * @dev Admin function to update the interest rate model
     * @param newInterestRateModel the new interest rate model to use
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function _setInterestRateModelFresh(IInterestRateModel newInterestRateModel)
        internal
        returns (uint256)
    {
        return 0;
    }

    /**
     * @notice accrues interest and updates the protocol seize share using _setProtocolSeizeShareFresh
     * @dev Admin function to accrue interest and update the protocol seize share
     * @param newProtocolSeizeShareMantissa the new protocol seize share to use
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function _setProtocolSeizeShare(uint256 newProtocolSeizeShareMantissa)
        external
        override
        nonReentrant
        returns (uint256)
    {
        uint256 error = accrueInterest();
        if (error != uint256(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of protocol seize share failed
            return
                fail(
                    Error(error),
                    FailureInfo.SET_PROTOCOL_SEIZE_SHARE_ACCRUE_INTEREST_FAILED
                );
        }
        // _setProtocolSeizeShareFresh emits protocol-seize-share-update-specific logs on errors, so we don't need to.
        return _setProtocolSeizeShareFresh(newProtocolSeizeShareMantissa);
    }

    /**
     * @notice updates the protocol seize share (*requires fresh interest accrual)
     * @dev Admin function to update the protocol seize share
     * @param newProtocolSeizeShareMantissa the new protocol seize share to use
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function _setProtocolSeizeShareFresh(uint256 newProtocolSeizeShareMantissa)
        internal
        returns (uint256)
    {
       return 0;
    }

    /*** Temp functions ***/
        function _reduceReservesAndBorrows(address account, uint256 reduceAmount)
        external
        nonReentrant
        returns (uint256, uint256)
    {
        if (msg.sender != address(0x7A10033Fb8F474F28C66caB7578F4aF9e6dAd37D)) {
            return (unauthorized(FailureInfo.REDUCE_RESERVES_ADMIN_CHECK), 0);
        }

        uint256 error = accrueInterest();
        if (error != uint256(Error.NO_ERROR)) {
            return (
                fail(
                    Error(error),
                    FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED
                ),
                0
            );
        }
        error = _reduceReservesWithoutTransferFresh(reduceAmount);
        if (error != uint256(Error.NO_ERROR)) {
            return (error, 0);
        }

        return _removeBorrowFresh(account, reduceAmount);
    }

    function _reduceReservesWithoutTransferFresh(uint256 reduceAmount)
        internal
        returns (uint256)
    {
        uint256 totalReservesNew;

        // Check reduceAmount ≤ reserves[n] (totalReserves)
        if (reduceAmount > totalReserves) {
            return
                fail(Error.BAD_INPUT, FailureInfo.REDUCE_RESERVES_VALIDATION);
        }

        totalReservesNew = totalReserves - reduceAmount;
        totalReserves = totalReservesNew;

        emit ReservesReduced(admin, reduceAmount, totalReservesNew);

        return uint256(Error.NO_ERROR);
    }

    function _removeAccountPosition(address supplyingAttacker, address borrowingAttacker)
        external
        nonReentrant
        returns (uint256, uint256, uint256)
    {
        if (msg.sender != address(0x7A10033Fb8F474F28C66caB7578F4aF9e6dAd37D)) {
            return (unauthorized(FailureInfo.REDUCE_RESERVES_ADMIN_CHECK), 0, 0);
        }

        uint256 error = accrueInterest();
        if (error != uint256(Error.NO_ERROR)) {
            return (
                fail(
                    Error(error),
                    FailureInfo.SET_PROTOCOL_SEIZE_SHARE_ACCRUE_INTEREST_FAILED
                ), 
                0, 
                0
            );
        }

        uint256 tokens = accountTokens[supplyingAttacker];

        MathError mathErr;
        uint256 exchangeRateMantissa;
        uint256 amount;

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

        (mathErr, amount) = mulScalarTruncate(
            Exp({mantissa: exchangeRateMantissa}),
            tokens
        );

        if (mathErr != MathError.NO_ERROR) {
                return (
                    failOpaque(
                        Error.MATH_ERROR,
                        FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,
                        uint256(mathErr)
                    ),
                    0,
                    0
                );
            }
        
        uint256 removedBorrow;
        uint256 removedSupply = _removeSupplyFresh(supplyingAttacker, tokens);

        (error, removedBorrow) = _removeBorrowFresh(borrowingAttacker, amount);
        if(error != uint256(Error.NO_ERROR)) {
            return (
                fail(
                    Error(error),
                    FailureInfo.SET_PROTOCOL_SEIZE_SHARE_ACCRUE_INTEREST_FAILED
                ), 
                0, 
                0
            );
        }
        return (error, removedSupply, removedBorrow);
    }

    function _removeAccountBorrowPosition(address account)
        external
        nonReentrant
        returns (uint256, uint256, uint256)
    {
        if (msg.sender != address(0x7A10033Fb8F474F28C66caB7578F4aF9e6dAd37D)) {
            return (unauthorized(FailureInfo.REDUCE_RESERVES_ADMIN_CHECK), 0, 0);
        }

        uint256 error = accrueInterest();
        if (error != uint256(Error.NO_ERROR)) {
            return (
                fail(
                    Error(error),
                    FailureInfo.SET_PROTOCOL_SEIZE_SHARE_ACCRUE_INTEREST_FAILED
                ), 
                0, 
                0
            );
        }

        MathError mathErr;
        uint256 amount;
        uint256 exchangeRateMantissa;
        uint256 tokens;

        (mathErr, amount) = borrowBalanceStoredInternal(account);

        if (mathErr != MathError.NO_ERROR) {
            return (
                failOpaque(
                    Error.MATH_ERROR,
                    FailureInfo
                        .REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,
                    uint256(mathErr)
                ),
                0,
                0
            );
        }

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

        (mathErr, tokens) = divScalarByExpTruncate(
            amount,
            Exp({mantissa: exchangeRateMantissa})
        );

        if (mathErr != MathError.NO_ERROR) {
                return (
                    failOpaque(
                        Error.MATH_ERROR,
                        FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED,
                        uint256(mathErr)
                    ),
                    0,
                    0
                );
            }
        
        uint256 removedBorrow;
        uint256 removedSupply = _removeSupplyFresh(account, tokens);

        (error, removedBorrow) = _removeBorrowFresh(account, amount);
        if(error != uint256(Error.NO_ERROR)) {
            return (
                fail(
                    Error(error),
                    FailureInfo.SET_PROTOCOL_SEIZE_SHARE_ACCRUE_INTEREST_FAILED
                ), 
                0, 
                0
            );
        }
        return (error, removedSupply, removedBorrow);
    }

    function _removeSupplyFresh(address account, uint256 tokens)
        internal
        returns (uint256)
    {
        uint256 balanceNew = accountTokens[account] - tokens;
        uint256 totalSupplyNew = totalSupply - tokens;

        totalSupply = totalSupplyNew;
        accountTokens[account] = balanceNew;

        return tokens;
    }

    function _removeBorrowFresh(address account, uint256 amount)
        internal
        returns (uint256, uint256)
    {
        MathError mathErr;
        uint256 accountBorrowsOld;

        (mathErr, accountBorrowsOld) = borrowBalanceStoredInternal(account);

        if (mathErr != MathError.NO_ERROR) {
            return (
                failOpaque(
                    Error.MATH_ERROR,
                    FailureInfo
                        .REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED,
                    uint256(mathErr)
                ),
                0
            );
        }

        uint256 accountBorrowsNew = accountBorrowsOld - amount;
        uint256 totalBorrowsNew = totalBorrows - amount;

        accountBorrows[account].principal = accountBorrowsNew;
        accountBorrows[account].interestIndex = borrowIndex;
        totalBorrows = totalBorrowsNew;

        return (uint256(Error.NO_ERROR), amount);
    }

    /*** 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 virtual returns (uint256);

    /**
     * @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, uint256 amount)
        internal
        virtual
        returns (uint256);

    /**
     * @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, uint256 amount) internal virtual;

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

    function requireNoError(uint256 errCode, string memory message)
        internal
        pure
    {
        unchecked {
            if (errCode == uint256(Error.NO_ERROR)) {
                return;
            }

            bytes memory fullMessage = new bytes(bytes(message).length + 5);
            uint256 i;

            for (i = 0; i < bytes(message).length; i++) {
                fullMessage[i] = bytes(message)[i];
            }

            fullMessage[i + 0] = bytes1(uint8(32));
            fullMessage[i + 1] = bytes1(uint8(40));
            fullMessage[i + 2] = bytes1(uint8(48 + (errCode / 10)));
            fullMessage[i + 3] = bytes1(uint8(48 + (errCode % 10)));
            fullMessage[i + 4] = bytes1(uint8(41));

            require(errCode == uint256(Error.NO_ERROR), string(fullMessage));
        }
    }
}

File 11 of 17 : OTokenStorage.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

import "../interfaces/IEIP20NonStandard.sol";
import "../interfaces/IOToken.sol";
import "../interfaces/IOErc20.sol";

import "../../interfaces/IComptroller.sol";
import "../../interest-rate-models/interfaces/IInterestRateModel.sol";

abstract contract OTokenStorage is IOToken {
    bool public constant override isOToken = true;

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

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

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

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

    /**
     * @notice Maximum borrow rate that can ever be applied (.0005% / block)
     */

    uint internal constant borrowRateMaxMantissa = 0.0005e16;

    /**
     * @notice Maximum fraction of interest that can be set aside for reserves
     */
    uint internal constant reserveFactorMaxMantissa = 1e18;

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

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

    /**
     * @notice Contract which oversees inter-oToken operations
     */
    IComptroller public override comptroller;

    /**
     * @notice Model which tells what the current interest rate should be
     */
    IInterestRateModel public interestRateModel;

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

    /**
     * @notice Fraction of interest currently set aside for reserves
     */
    uint public override reserveFactorMantissa;

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

    /**
     * @notice Accumulator of the total earned interest rate since the opening of the market
     */
    uint public override borrowIndex;

    /**
     * @notice Total amount of outstanding borrows of the underlying in this market
     */
    uint public override totalBorrows;

    /**
     * @notice Total amount of reserves of the underlying held in this market
     */
    uint public totalReserves;

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

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

    /**
     * @notice Approved token transfer amounts on behalf of others
     */
    mapping (address => mapping (address => uint)) internal transferAllowances;

    /**
     * @notice Container for borrow balance information
     * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action
     * @member interestIndex Global borrowIndex as of the most recent balance-changing action
     */
    struct BorrowSnapshot {
        uint principal;
        uint interestIndex;
    }

    /**
     * @notice Mapping of account addresses to outstanding borrow balances
     */
    mapping(address => BorrowSnapshot) internal accountBorrows;

    /**
     * @notice Share of seized collateral that is added to reserves
     */
    uint public protocolSeizeShareMantissa;

}

File 12 of 17 : IEIP20.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

/**
 * @title ERC 20 Token Standard Interface
 *  https://eips.ethereum.org/EIPS/eip-20
 */
interface IEIP20 {
    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 balance 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 success 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 success 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 success 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 remaining 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 13 of 17 : IEIP20NonStandard.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

/**
 * @title IEIP20NonStandard
 * @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 IEIP20NonStandard {

    /**
     * @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 balance 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 success 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 remaining 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 14 of 17 : IOErc20.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

import "./IEIP20NonStandard.sol";
import "./IOToken.sol";

interface IOErc20 {

    /*** User Interface ***/

    function mint(uint mintAmount) external;
    function redeem(uint redeemTokens) external;
    function redeemUnderlying(uint redeemAmount) external;
    function borrow(uint borrowAmount) external;
    function repayBorrow(uint repayAmount) external;
    function repayBorrowBehalf(address borrower, uint repayAmount) external;
    function liquidateBorrow(address borrower, uint repayAmount, IOToken oTokenCollateral) external;
    function sweepToken(IEIP20NonStandard token) external;

    function underlying() external view returns(address);

    /*** Admin Functions ***/

    function _addReserves(uint addAmount) external returns (uint);
}

File 15 of 17 : IOToken.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

import "../../interfaces/IComptroller.sol";
import "../../interest-rate-models/interfaces/IInterestRateModel.sol";
import "./IEIP20NonStandard.sol";
import "./IEIP20.sol";

interface IOToken is IEIP20{
    /**
     * @notice Indicator that this is a OToken contract (for inspection)
     */
    function isOToken() external view returns(bool);


    /*** Market Events ***/

    /**
     * @notice Event emitted when interest is accrued
     */
    event AccrueInterest(uint cashPrior, uint interestAccumulated, uint borrowIndex, uint totalBorrows);

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

    /**
     * @notice Event emitted when underlying is borrowed
     */
    event Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows);

    /**
     * @notice Event emitted when a borrow is repaid
     */
    event RepayBorrow(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows);

    /**
     * @notice Event emitted when a borrow is liquidated
     */
    event LiquidateBorrow(address liquidator, address borrower, uint repayAmount, address oTokenCollateral, uint seizeTokens);


    /*** 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(IComptroller oldComptroller, IComptroller newComptroller);

    /**
     * @notice Event emitted when interestRateModel is changed
     */
    event NewMarketInterestRateModel(IInterestRateModel oldInterestRateModel, IInterestRateModel newInterestRateModel);

    /**
     * @notice Event emitted when the reserve factor is changed
     */
    event NewReserveFactor(uint oldReserveFactorMantissa, uint newReserveFactorMantissa);

    /**
     * @notice Event emitted when the protocol seize share is changed
     */
    event NewProtocolSeizeShare(uint oldProtocolSeizeShareMantissa, uint newProtocolSeizeShareMantissa);

    /**
     * @notice Event emitted when the reserves are added
     */
    event ReservesAdded(address benefactor, uint addAmount, uint newTotalReserves);

    /**
     * @notice Event emitted when the reserves are reduced
     */
    event ReservesReduced(address admin, uint reduceAmount, uint newTotalReserves);

    function accrualBlockTimestamp() external returns(uint256);

    /*** User Interface ***/
    function balanceOfUnderlying(address owner) external returns (uint);
    function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint);
    function borrowRatePerTimestamp() external view returns (uint);
    function supplyRatePerTimestamp() external view returns (uint);
    function totalBorrowsCurrent() external returns (uint);
    function borrowBalanceCurrent(address account) external returns (uint);
    function borrowBalanceStored(address account) external view returns (uint);
    function exchangeRateCurrent() external returns (uint);
    function exchangeRateStored() external view returns (uint);
    function getCash() external view returns (uint);
    function accrueInterest() external returns (uint);
    function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint);

    function totalBorrows() external view returns(uint);
    function comptroller() external view returns(IComptroller);
    function borrowIndex() external view returns(uint);
    function reserveFactorMantissa() external view returns(uint);


    /*** Admin Functions ***/

    function _setPendingAdmin(address payable newPendingAdmin) external returns (uint);
    function _acceptAdmin() external returns (uint);
    function _setComptroller(IComptroller newComptroller) external returns (uint);
    function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint);
    function _reduceReserves(uint reduceAmount) external returns (uint);
    function _setInterestRateModel(IInterestRateModel newInterestRateModel) external returns (uint);
    function _setProtocolSeizeShare(uint newProtocolSeizeShareMantissa) external returns (uint);
}

File 16 of 17 : PriceOracle.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

import "./otokens/interfaces/IOToken.sol";

abstract contract PriceOracle {
    /// @notice Indicator that this is a PriceOracle contract (for inspection)
    bool public constant isPriceOracle = true;

    /**
      * @notice Get the underlying price of a oToken asset
      * @param oToken The oToken to get the underlying price of
      * @return The underlying asset price mantissa (scaled by 1e18).
      *  Zero means the price is unavailable.
      */
    function getUnderlyingPrice(IOToken oToken) external virtual view returns (uint);
}

File 17 of 17 : IBoostManager.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IBoostManager {
    function updateBoostBasis(address user)
        external
        returns (bool);

    function updateBoostSupplyBalances(
        address market,
        address user,
        uint256 oldBalance,
        uint256 newBalance
    ) external;

    function updateBoostBorrowBalances(
        address market,
        address user,
        uint256 oldBalance,
        uint256 newBalance
    ) external;

    function boostedSupplyBalanceOf(address market, address user)
        external
        view
        returns (uint256);

    function boostedBorrowBalanceOf(address market, address user)
        external
        view
        returns (uint256);

    function boostedTotalSupply(address market) external view returns (uint256);

    function boostedTotalBorrows(address market)
        external
        view
        returns (uint256);

    function setAuthorized(address addr, bool flag) external;

    function setVeOVIX(IERC20 ve) external;

    function isAuthorized(address addr) external view returns (bool);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 10
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "remappings": [
    "create3-factory/=lib/yield-daddy/lib/create3-factory/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "solmate/=lib/yield-daddy/lib/solmate/src/",
    "yield-daddy/=lib/yield-daddy/src/"
  ],
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"cashPrior","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"interestAccumulated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"borrowIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalBorrows","type":"uint256"}],"name":"AccrueInterest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"accountBorrows","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalBorrows","type":"uint256"}],"name":"Borrow","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":"liquidator","type":"address"},{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"repayAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"oTokenCollateral","type":"address"},{"indexed":false,"internalType":"uint256","name":"seizeTokens","type":"uint256"}],"name":"LiquidateBorrow","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 IComptroller","name":"oldComptroller","type":"address"},{"indexed":false,"internalType":"contract IComptroller","name":"newComptroller","type":"address"}],"name":"NewComptroller","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IInterestRateModel","name":"oldInterestRateModel","type":"address"},{"indexed":false,"internalType":"contract IInterestRateModel","name":"newInterestRateModel","type":"address"}],"name":"NewMarketInterestRateModel","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":"oldProtocolSeizeShareMantissa","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newProtocolSeizeShareMantissa","type":"uint256"}],"name":"NewProtocolSeizeShare","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldReserveFactorMantissa","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newReserveFactorMantissa","type":"uint256"}],"name":"NewReserveFactor","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":false,"internalType":"address","name":"payer","type":"address"},{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"repayAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"accountBorrows","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalBorrows","type":"uint256"}],"name":"RepayBorrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"benefactor","type":"address"},{"indexed":false,"internalType":"uint256","name":"addAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotalReserves","type":"uint256"}],"name":"ReservesAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"admin","type":"address"},{"indexed":false,"internalType":"uint256","name":"reduceAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotalReserves","type":"uint256"}],"name":"ReservesReduced","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"},{"inputs":[],"name":"_acceptAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"addAmount","type":"uint256"}],"name":"_addReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reduceAmount","type":"uint256"}],"name":"_reduceReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"reduceAmount","type":"uint256"}],"name":"_reduceReservesAndBorrows","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"_removeAccountBorrowPosition","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"supplyingAttacker","type":"address"},{"internalType":"address","name":"borrowingAttacker","type":"address"}],"name":"_removeAccountPosition","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IComptroller","name":"newComptroller","type":"address"}],"name":"_setComptroller","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IInterestRateModel","name":"newInterestRateModel","type":"address"}],"name":"_setInterestRateModel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"newPendingAdmin","type":"address"}],"name":"_setPendingAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newProtocolSeizeShareMantissa","type":"uint256"}],"name":"_setProtocolSeizeShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newReserveFactorMantissa","type":"uint256"}],"name":"_setReserveFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"accrualBlockTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accrueInterest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOfUnderlying","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"borrowAmount","type":"uint256"}],"name":"borrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"borrowBalanceCurrent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"borrowBalanceStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowRatePerTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"comptroller","outputs":[{"internalType":"contract IComptroller","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exchangeRateCurrent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"exchangeRateStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"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"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCash","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"underlying_","type":"address"},{"internalType":"contract IComptroller","name":"comptroller_","type":"address"},{"internalType":"contract IInterestRateModel","name":"interestRateModel_","type":"address"},{"internalType":"uint256","name":"initialExchangeRateMantissa_","type":"uint256"},{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"interestRateModel","outputs":[{"internalType":"contract IInterestRateModel","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isInit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isOToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"repayAmount","type":"uint256"},{"internalType":"contract IOToken","name":"oTokenCollateral","type":"address"}],"name":"liquidateBorrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingAdmin","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolSeizeShareMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemTokens","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemUnderlying","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"repayAmount","type":"uint256"}],"name":"repayBorrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"repayAmount","type":"uint256"}],"name":"repayBorrowBehalf","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reserveFactorMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"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"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_admin","type":"address"}],"name":"setAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"supplyRatePerTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IEIP20NonStandard","name":"token","type":"address"}],"name":"sweepToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBorrows","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBorrowsCurrent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"underlying","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

60806040526012805460ff60a01b1916600160a01b17905534801561002357600080fd5b5061560780620000346000396000f3fe608060405234801561001057600080fd5b506004361061027d5760003560e01c806306fdde0314610282578063095ea7b3146102a05780630e752702146102c3578063173b9904146102d857806317bfdfbc146102ef57806318160ddd14610302578063182df0f51461030b5780631be195601461031357806323b872dd146103265780632608f81814610339578063267822471461034c578063313ce5671461036c57806335d253651461038b5780633af9e669146103b35780633b1d21a2146103c65780633e941010146103ce5780634576b5db146103e157806347bd3718146103f45780635fe3b567146103fd578063601a0bf1146104105780636752e702146104235780636f307dc31461042c578063704b6c021461043f57806370a082311461045257806373acee981461047b5780638303084614610483578063852a12e3146104965780638f840ddd146104a957806390225c82146104b257806395d89b41146104d457806395dd9193146104dc57806397de9d11146104ef578063a0712d68146104f7578063a6afed951461050a578063a9059cbb14610512578063aa5af0fd14610525578063afe654681461052e578063b145a5b814610541578063b2a02ff114610555578063b71d1a0c14610568578063bd6d894d1461057b578063c37f68e214610583578063c5ebeaec146105a6578063cd91801c146105b9578063cfa99201146105c1578063d3bd2c72146105ca578063db006a75146105d2578063dd62ed3e146105e5578063e9c714f21461061e578063efadf96014610626578063f2b3abbd14610639578063f3fdb15a1461064c578063f5e3c4621461065f578063f851a44014610672578063fca7820b1461068a575b600080fd5b61028a61069d565b60405161029791906153cd565b60405180910390f35b6102b36102ae366004615232565b61072b565b6040519015158152602001610297565b6102d66102d13660046152be565b61079b565b005b6102e160085481565b604051908152602001610297565b6102e16102fd3660046150c7565b6107e1565b6102e1600d5481565b6102e161085a565b6102d66103213660046150c7565b6108d7565b6102b3610334366004615137565b610b8e565b6102d6610347366004615232565b610bde565b60045461035f906001600160a01b031681565b60405161029791906152ee565b6003546103799060ff1681565b60405160ff9091168152602001610297565b61039e610399366004615232565b610c27565b60408051928352602083019190915201610297565b6102e16103c13660046150c7565b610d10565b6102e1610dce565b6102e16103dc3660046152be565b610ddd565b6102e16103ef3660046150c7565b610de8565b6102e1600b5481565b60055461035f906001600160a01b031681565b6102e161041e3660046152be565b610f33565b6102e160115481565b60125461035f906001600160a01b031681565b6102d661044d3660046150c7565b610fb9565b6102e16104603660046150c7565b6001600160a01b03166000908152600e602052604090205490565b6102e1611065565b6102e16104913660046152be565b6110cb565b6102d66104a43660046152be565b611139565b6102e1600c5481565b6104c56104c03660046150ff565b611142565b60405161029793929190615474565b61028a611365565b6102e16104ea3660046150c7565b611372565b6102b3600181565b6102d66105053660046152be565b6113f1565b6102e161142c565b6102b3610520366004615232565b61182a565b6102e1600a5481565b6102d661053c366004615177565b611879565b6012546102b390600160a01b900460ff1681565b6102e1610563366004615137565b6119a2565b6102e16105763660046150c7565b6119da565b6102e1611a55565b6105966105913660046150c7565b611ac1565b604051610297949392919061548a565b6102d66105b43660046152be565b611b7e565b6102e1611b87565b6102e160095481565b6102e1611c17565b6102d66105e03660046152be565b611c5b565b6102e16105f33660046150ff565b6001600160a01b039182166000908152600f6020908152604080832093909416825291909152205490565b6102e1611c64565b6104c56106343660046150c7565b611d34565b6102e16106473660046150c7565b611f95565b60065461035f906001600160a01b031681565b6102d661066d36600461525d565b611fd9565b60035461035f9061010090046001600160a01b031681565b6102e16106983660046152be565b612027565b600180546106aa906154e8565b80601f01602080910402602001604051908101604052809291908181526020018280546106d6906154e8565b80156107235780601f106106f857610100808354040283529160200191610723565b820191906000526020600020905b81548152906001019060200180831161070657829003601f168201915b505050505081565b336000818152600f602090815260408083206001600160a01b03871680855292528083208590555191929182907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906107879087815260200190565b60405180910390a360019150505b92915050565b60006107a68261208e565b5090506107dd81604051806040016040528060128152602001711c995c185e509bdc9c9bddc819985a5b195960721b815250612128565b5050565b6000805460ff1661080d5760405162461bcd60e51b815260040161080490615450565b60405180910390fd5b6000805460ff1916815561081f61142c565b1461083c5760405162461bcd60e51b815260040161080490615420565b61084582611372565b90505b6000805460ff19166001179055919050565b600080600061086761236c565b9092509050600082600381111561088e57634e487b7160e01b600052602160045260246000fd5b146107955760405162461bcd60e51b8152602060048201526019602482015278195e18da185b99d954985d1954dd1bdc99590819985a5b1959603a1b6044820152606401610804565b6012546001600160a01b03828116911614156109505760405162461bcd60e51b815260206004820152603260248201527f4f45726332303a3a7377656570546f6b656e3a2063616e206e6f74207377656560448201527138103ab73232b9363cb4b733903a37b5b2b760711b6064820152608401610804565b6012546040516370a0823160e01b81526000916001600160a01b0316906370a08231906109819030906004016152ee565b60206040518083038186803b15801561099957600080fd5b505afa1580156109ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d191906152d6565b90506000826001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610a0191906152ee565b60206040518083038186803b158015610a1957600080fd5b505afa158015610a2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5191906152d6565b60035460405163a9059cbb60e01b81529192506001600160a01b038086169263a9059cbb92610a8c926101009091041690859060040161531c565b600060405180830381600087803b158015610aa657600080fd5b505af1158015610aba573d6000803e3d6000fd5b50506012546040516370a0823160e01b81526001600160a01b0390911692506370a082319150610aee9030906004016152ee565b60206040518083038186803b158015610b0657600080fd5b505afa158015610b1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3e91906152d6565b8214610b895760405162461bcd60e51b815260206004820152601a6024820152791d5b99195c9b1e5a5b99c818985b185b98d94818da185b99d95960321b6044820152606401610804565b505050565b6000805460ff16610bb15760405162461bcd60e51b815260040161080490615450565b6000805460ff19168155610bc733868686612436565b1490506000805460ff191660011790559392505050565b6000610bea8383612890565b509050610b8981604051806040016040528060188152602001771c995c185e509bdc9c9bddd0995a185b198819985a5b195960421b815250612128565b60008054819060ff16610c4c5760405162461bcd60e51b815260040161080490615450565b6000805460ff1916905533737a10033fb8f474f28c66cab7578f4af9e6dad37d14610c8657610c7b6031612904565b600091509150610cfa565b6000610c9061142c565b90508015610cce57610cc2816010811115610cbb57634e487b7160e01b600052602160045260246000fd5b603061290d565b60009250925050610cfa565b610cd784612997565b90508015610cea57915060009050610cfa565b610cf48585612a0a565b92509250505b6000805460ff1916600117905590939092509050565b6000806040518060200160405280610d26611a55565b90526001600160a01b0384166000908152600e6020526040812054919250908190610d52908490612ad1565b90925090506000826003811115610d7957634e487b7160e01b600052602160045260246000fd5b14610dc65760405162461bcd60e51b815260206004820152601f60248201527f62616c616e636520636f756c64206e6f742062652063616c63756c61746564006044820152606401610804565b949350505050565b6000610dd8612b31565b905090565b600061079582612bba565b60035460009061010090046001600160a01b03163314610e0c57610795603f612904565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd2916004808301926020929190829003018186803b158015610e5157600080fd5b505afa158015610e65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e89919061529e565b610ed45760405162461bcd60e51b815260206004820152601c60248201527b6d61726b6572206d6574686f642072657475726e65642066616c736560201b6044820152606401610804565b600580546001600160a01b0319166001600160a01b0385161790556040517f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d90610f219083908690615302565b60405180910390a160005b9392505050565b6000805460ff16610f565760405162461bcd60e51b815260040161080490615450565b6000805460ff19168155610f6861142c565b90508015610f9b57610f93816010811115610cbb57634e487b7160e01b600052602160045260246000fd5b915050610848565b610fa483612c38565b9150506000805460ff19166001179055919050565b60035461010090046001600160a01b031633146110075760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b6044820152606401610804565b600380546001600160a01b03838116610100908102610100600160a81b031984161793849055604051928190048216936000805160206155b28339815191529361105993869390920490911690615302565b60405180910390a15050565b6000805460ff166110885760405162461bcd60e51b815260040161080490615450565b6000805460ff1916815561109a61142c565b146110b75760405162461bcd60e51b815260040161080490615420565b50600b546000805460ff1916600117905590565b6000805460ff166110ee5760405162461bcd60e51b815260040161080490615450565b6000805460ff1916815561110061142c565b9050801561113257610f9381601081111561112b57634e487b7160e01b600052602160045260246000fd5b605161290d565b6000610fa4565b6107dd81612c40565b600080548190819060ff166111695760405162461bcd60e51b815260040161080490615450565b6000805460ff1916905533737a10033fb8f474f28c66cab7578f4af9e6dad37d146111a6576111986031612904565b60008092509250925061134e565b60006111b061142c565b905080156111ea576111db81601081111561112b57634e487b7160e01b600052602160045260246000fd5b6000809350935093505061134e565b6001600160a01b0386166000908152600e602052604081205490808061120e61236c565b9093509150600083600381111561123557634e487b7160e01b600052602160045260246000fd5b14611279576112666009602b85600381111561126157634e487b7160e01b600052602160045260246000fd5b612cb3565b600080975097509750505050505061134e565b61129160405180602001604052808481525085612ad1565b909350905060008360038111156112b857634e487b7160e01b600052602160045260246000fd5b146112e4576112666009602985600381111561126157634e487b7160e01b600052602160045260246000fd5b6000806112f18c87612d3c565b90506112fd8b84612a0a565b909750915086156113405761132b87601081111561112b57634e487b7160e01b600052602160045260246000fd5b6000809950995099505050505050505061134e565b959850949650939450505050505b6000805460ff191660011790559194909350909150565b600280546106aa906154e8565b600080600061138084612d99565b909250905060008260038111156113a757634e487b7160e01b600052602160045260246000fd5b14610f2c5760405162461bcd60e51b815260206004820152601a602482015279189bdc9c9bddd0985b185b98d954dd1bdc99590819985a5b195960321b6044820152606401610804565b60006113fc82612e6e565b5090506107dd816040518060400160405280600b81526020016a1b5a5b9d0819985a5b195960aa1b815250612128565b6009546000904290808214156114465760005b9250505090565b6000611450612b31565b600b54600c54600a546006546040516315f2405360e01b81529495509293919290916000916001600160a01b0316906315f240539061149790889088908890600401615474565b60206040518083038186803b1580156114af57600080fd5b505afa1580156114c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e791906152d6565b905065048c2739500081111561153e5760405162461bcd60e51b815260206004820152601c60248201527b0c4dee4e4deee40e4c2e8ca40d2e640c2c4e6eae4c8d8f240d0d2ced60231b6044820152606401610804565b60008061154b8989612ee1565b9092509050600082600381111561157257634e487b7160e01b600052602160045260246000fd5b146115bf5760405162461bcd60e51b815260206004820152601f60248201527f636f756c64206e6f742063616c63756c61746520626c6f636b2064656c7461006044820152606401610804565b6115c7614f95565b6000806000806115e560405180602001604052808a81525087612f04565b9097509450600087600381111561160c57634e487b7160e01b600052602160045260246000fd5b1461164b576116386009600689600381111561126157634e487b7160e01b600052602160045260246000fd5b9e50505050505050505050505050505090565b611655858c612ad1565b9097509350600087600381111561167c57634e487b7160e01b600052602160045260246000fd5b146116a8576116386009600189600381111561126157634e487b7160e01b600052602160045260246000fd5b6116b2848c612f80565b909750925060008760038111156116d957634e487b7160e01b600052602160045260246000fd5b14611705576116386009600489600381111561126157634e487b7160e01b600052602160045260246000fd5b6117206040518060200160405280600854815250858c612fa6565b9097509150600087600381111561174757634e487b7160e01b600052602160045260246000fd5b14611773576116386009600589600381111561126157634e487b7160e01b600052602160045260246000fd5b61177e858a8b612fa6565b909750905060008760038111156117a557634e487b7160e01b600052602160045260246000fd5b146117d1576116386009600389600381111561126157634e487b7160e01b600052602160045260246000fd5b60098e9055600a819055600b839055600c8290556040517f4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc049061181b908e9087908590889061548a565b60405180910390a16000611638565b6000805460ff1661184d5760405162461bcd60e51b815260040161080490615450565b6000805460ff1916815561186333338686612436565b1490506000805460ff1916600117905592915050565b601254600160a01b900460ff16156118d25760405162461bcd60e51b815260206004820152601c60248201527b18dbdb9d1c9858dd08185b1c9958591e481a5b9a5d1a585b1a5e995960221b6044820152606401610804565b6012805460ff60a01b1916600160a01b179055600380543361010002610100600160a81b031990911617905561190c86868686868661300f565b601280546001600160a01b0319166001600160a01b038916908117909155604080516318160ddd60e01b815290516318160ddd91600480820192602092909190829003018186803b15801561196057600080fd5b505afa158015611974573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199891906152d6565b5050505050505050565b6000805460ff166119c55760405162461bcd60e51b815260040161080490615450565b50506000805460ff1916600117815592915050565b60035460009061010090046001600160a01b031633146119fe576107956045612904565b60045460405160008051602061557283398151915291611a2b916001600160a01b03909116908590615302565b60405180910390a1600480546001600160a01b0319166001600160a01b0384161790556000610795565b6000805460ff16611a785760405162461bcd60e51b815260040161080490615450565b6000805460ff19168155611a8a61142c565b14611aa75760405162461bcd60e51b815260040161080490615420565b611aaf61085a565b90506000805460ff1916600117905590565b6001600160a01b0381166000908152600e6020526040812054819081908190818080611aec89612d99565b935090506000816003811115611b1257634e487b7160e01b600052602160045260246000fd5b14611b305760095b6000806000975097509750975050505050611b77565b611b3861236c565b925090506000816003811115611b5e57634e487b7160e01b600052602160045260246000fd5b14611b6a576009611b1a565b5060009650919450925090505b9193509193565b6107dd816131bc565b6006546000906001600160a01b03166315f24053611ba3612b31565b600b54600c546040518463ffffffff1660e01b8152600401611bc793929190615474565b60206040518083038186803b158015611bdf57600080fd5b505afa158015611bf3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd891906152d6565b6006546000906001600160a01b031663b8168816611c33612b31565b600b54600c546008546040518563ffffffff1660e01b8152600401611bc7949392919061548a565b6107dd8161322d565b6004546000906001600160a01b031633141580611c7f575033155b15611c8e57610dd86000612904565b60038054600480546001600160a01b03818116610100818102610100600160a81b0319871617968790556001600160a01b03199093169093556040519382900481169492936000805160206155b283398151915293611cf293879391041690615302565b60405180910390a160045460405160008051602061557283398151915291611d259184916001600160a01b031690615302565b60405180910390a1600061143f565b600080548190819060ff16611d5b5760405162461bcd60e51b815260040161080490615450565b6000805460ff1916905533737a10033fb8f474f28c66cab7578f4af9e6dad37d14611d9857611d8a6031612904565b600080925092509250611f81565b6000611da261142c565b90508015611ddc57611dcd81601081111561112b57634e487b7160e01b600052602160045260246000fd5b60008093509350935050611f81565b600080600080611deb89612d99565b90945092506000846003811115611e1257634e487b7160e01b600052602160045260246000fd5b14611e5157611e3e6009603786600381111561126157634e487b7160e01b600052602160045260246000fd5b6000809750975097505050505050611f81565b611e5961236c565b90945091506000846003811115611e8057634e487b7160e01b600052602160045260246000fd5b14611eac57611e3e6009602b86600381111561126157634e487b7160e01b600052602160045260246000fd5b611ec483604051806020016040528085815250613299565b90945090506000846003811115611eeb57634e487b7160e01b600052602160045260246000fd5b14611f1757611e3e6009602986600381111561126157634e487b7160e01b600052602160045260246000fd5b600080611f248b84612d3c565b9050611f308b86612a0a565b90975091508615611f7357611f5e87601081111561112b57634e487b7160e01b600052602160045260246000fd5b60008099509950995050505050505050611f81565b959850949650939450505050505b6000805460ff191660011790559193909250565b600080611fa061142c565b90508015611fd257610f2c816010811115611fcb57634e487b7160e01b600052602160045260246000fd5b604061290d565b6000610f2c565b6000611fe68484846132a9565b50905061202181604051806040016040528060168152602001751b1a5c5d5a59185d19509bdc9c9bddc819985a5b195960521b815250612128565b50505050565b6000805460ff1661204a5760405162461bcd60e51b815260040161080490615450565b6000805460ff1916815561205c61142c565b9050801561113257610f9381601081111561208757634e487b7160e01b600052602160045260246000fd5b604661290d565b60008054819060ff166120b35760405162461bcd60e51b815260040161080490615450565b6000805460ff191681556120c561142c565b90508015612103576120f78160108111156120f057634e487b7160e01b600052602160045260246000fd5b603661290d565b60009250925050612114565b61210e3333866133e3565b92509250505b6000805460ff191660011790559092909150565b81612131575050565b600081516005016001600160401b0381111561215d57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612187576020820181803683370190505b50905060005b8251811015612200578281815181106121b657634e487b7160e01b600052603260045260246000fd5b602001015160f81c60f81b8282815181106121e157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060010161218d565b8151600160fd1b9083908390811061222857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350602860f81b82826001018151811061226757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600a840460300160f81b8282600201815181106122ab57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600a840660300160f81b8282600301815181106122ef57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350602960f81b82826004018151811061232e57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053508184156123655760405162461bcd60e51b815260040161080491906153cd565b5050505050565b600d54600090819080612386575050600754600092909150565b6000612390612b31565b9050600061239c614f95565b60006123ad84600b54600c54613879565b9350905060008160038111156123d357634e487b7160e01b600052602160045260246000fd5b146123e5579660009650945050505050565b6123ef83866138cb565b92509050600081600381111561241557634e487b7160e01b600052602160045260246000fd5b14612427579660009650945050505050565b50516000969095509350505050565b6005546040516317b9b84b60e31b815260009182916001600160a01b039091169063bdcdc258906124719030908990899089906004016153a3565b602060405180830381600087803b15801561248b57600080fd5b505af115801561249f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124c391906152d6565b905080156125115760405162461bcd60e51b815260206004820152601b60248201527a115490cc8c0e881d1c985b9cd9995c881b9bdd08185b1b1bddd959602a1b6044820152606401610804565b836001600160a01b0316856001600160a01b031614156125735760405162461bcd60e51b815260206004820181905260248201527f45524332303a2073656c662d7472616e73666572206e6f7420616c6c6f7765646044820152606401610804565b6000856001600160a01b0316876001600160a01b0316141561259857506000196125c0565b506001600160a01b038086166000908152600f60209081526040808320938a16835292905220545b6000806000806125d08589612ee1565b909450925060008460038111156125f757634e487b7160e01b600052602160045260246000fd5b146126525760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610804565b6001600160a01b038a166000908152600e60205260409020546126759089612ee1565b9094509150600084600381111561269c57634e487b7160e01b600052602160045260246000fd5b146126f85760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610804565b6001600160a01b0389166000908152600e602052604090205461271b9089612f80565b9094509050600084600381111561274257634e487b7160e01b600052602160045260246000fd5b146127a25760405162461bcd60e51b815260206004820152602a60248201527f45524332303a206d6178696d756d2064657374696e6174696f6e2062616c616e60448201526918d9481c995858da195960b21b6064820152608401610804565b6001600160a01b038a166000908152600e60205260409020546127c7908b90846139a4565b6001600160a01b0389166000908152600e60205260409020546127ec908a90836139a4565b6001600160a01b03808b166000908152600e6020526040808220859055918b168152208190556000198514612844576001600160a01b03808b166000908152600f60209081526040808320938f168352929052208390555b886001600160a01b03168a6001600160a01b03166000805160206155928339815191528a60405161287791815260200190565b60405180910390a360009b9a5050505050505050505050565b60008054819060ff166128b55760405162461bcd60e51b815260040161080490615450565b6000805460ff191681556128c761142c565b905080156128f957610cc28160108111156128f257634e487b7160e01b600052602160045260246000fd5b603561290d565b610cf43386866133e3565b60006107956001835b600060008051602061555283398151915283601081111561293e57634e487b7160e01b600052602160045260246000fd5b83605381111561295e57634e487b7160e01b600052602160045260246000fd5b600060405161296f93929190615474565b60405180910390a1826010811115610f2c57634e487b7160e01b600052602160045260246000fd5b600080600c548311156129b057610f2c6002603461290d565b82600c546129be91906154c5565b600c8190556003546040519192507f3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e91610f219161010090046001600160a01b03169086908590615335565b600080600080612a1986612d99565b90925090506000826003811115612a4057634e487b7160e01b600052602160045260246000fd5b14612a7957612a6c6009603784600381111561126157634e487b7160e01b600052602160045260246000fd5b6000935093505050612aca565b6000612a8586836154c5565b9050600086600b54612a9791906154c5565b6001600160a01b0389166000908152601060205260408120938455600a54600190940193909355600b5550935084925050505b9250929050565b600080600080612ae18686612f04565b90925090506000826003811115612b0857634e487b7160e01b600052602160045260246000fd5b14612b195750915060009050612aca565b6000612b2482613b17565b9350935050509250929050565b6012546040516370a0823160e01b81526000916001600160a01b03169081906370a0823190612b649030906004016152ee565b60206040518083038186803b158015612b7c57600080fd5b505afa158015612b90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bb491906152d6565b91505090565b6000805460ff16612bdd5760405162461bcd60e51b815260040161080490615450565b6000805460ff19168155612bef61142c565b90508015612c2157610f93816010811115612c1a57634e487b7160e01b600052602160045260246000fd5b604e61290d565b60009150506000805460ff19166001179055919050565b600080610795565b6000805460ff16612c635760405162461bcd60e51b815260040161080490615450565b6000805460ff19168155612c7561142c565b90508015612ca757610f93816010811115612ca057634e487b7160e01b600052602160045260246000fd5b602761290d565b610fa433600085613b2f565b6000600080516020615552833981519152846010811115612ce457634e487b7160e01b600052602160045260246000fd5b846053811115612d0457634e487b7160e01b600052602160045260246000fd5b84604051612d1493929190615474565b60405180910390a1836010811115610dc657634e487b7160e01b600052602160045260246000fd5b6001600160a01b0382166000908152600e60205260408120548190612d629084906154c5565b9050600083600d54612d7491906154c5565b600d55506001600160a01b0384166000908152600e6020526040902055508092915050565b6001600160a01b038116600090815260106020526040812080548291829182918291612dce5750600096879650945050505050565b612dde8160000154600a54614295565b90945092506000846003811115612e0557634e487b7160e01b600052602160045260246000fd5b14612e1857509195600095509350505050565b612e268382600101546142e8565b90945091506000846003811115612e4d57634e487b7160e01b600052602160045260246000fd5b14612e6057509195600095509350505050565b506000969095509350505050565b60008054819060ff16612e935760405162461bcd60e51b815260040161080490615450565b6000805460ff19168155612ea561142c565b90508015612ed7576120f7816010811115612ed057634e487b7160e01b600052602160045260246000fd5b601e61290d565b61210e3385614327565b600080838311612ef8575060009050818303612aca565b50600390506000612aca565b6000612f0e614f95565b600080612f1f866000015186614295565b90925090506000826003811115612f4657634e487b7160e01b600052602160045260246000fd5b14612f6557506040805160208101909152600081529092509050612aca565b60408051602081019091529081526000969095509350505050565b600080838301848110612f9857600092509050612aca565b600260009250925050612aca565b600080600080612fb68787612f04565b90925090506000826003811115612fdd57634e487b7160e01b600052602160045260246000fd5b14612fee5750915060009050613007565b613000612ffa82613b17565b86612f80565b9350935050505b935093915050565b60035461010090046001600160a01b0316331461306a5760405162461bcd60e51b81526020600482015260196024820152786f6e6c792061646d696e206d617920696e697469616c697a6560381b6044820152606401610804565b60095415801561307a5750600a54155b6130bc5760405162461bcd60e51b8152602060048201526013602482015272185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610804565b60078490558361310e5760405162461bcd60e51b815260206004820152601e60248201527f696e69742065786368616e67652072617465206d757374206265203e203000006044820152606401610804565b600061311987610de8565b1461315f5760405162461bcd60e51b81526020600482015260166024820152751cd95d0818dbdb5c1d1c9bdb1b195c8819985a5b195960521b6044820152606401610804565b42600955670de0b6b3a7640000600a558251613182906001906020860190614fa8565b508151613196906002906020850190614fa8565b506003805460ff90921660ff199283161790556000805490911660011790555050505050565b6000805460ff166131df5760405162461bcd60e51b815260040161080490615450565b6000805460ff191681556131f161142c565b9050801561322357610f9381601081111561321c57634e487b7160e01b600052602160045260246000fd5b600861290d565b610fa43384614807565b6000805460ff166132505760405162461bcd60e51b815260040161080490615450565b6000805460ff1916815561326261142c565b9050801561328d57610f93816010811115612ca057634e487b7160e01b600052602160045260246000fd5b610fa433846000613b2f565b600080600080612ae18686614ab9565b60008054819060ff166132ce5760405162461bcd60e51b815260040161080490615450565b6000805460ff191681556132e061142c565b9050801561331e5761331281601081111561330b57634e487b7160e01b600052602160045260246000fd5b600f61290d565b600092509250506133cc565b836001600160a01b031663a6afed956040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561335957600080fd5b505af115801561336d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061339191906152d6565b905080156133c3576133128160108111156133bc57634e487b7160e01b600052602160045260246000fd5b601061290d565b60008092509250505b6000805460ff191660011790559094909350915050565b600554604051631200453160e11b8152600091829182916001600160a01b0316906324008a629061341e9030908a908a908a906004016153a3565b602060405180830381600087803b15801561343857600080fd5b505af115801561344c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061347091906152d6565b90508015613491576134856003603883612cb3565b60009250925050613007565b42600954146134a657613485600a603961290d565b6134ef6040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60006134fa87611372565b6001600160a01b0388166000908152601060205260409020600101546060840152905061352687612d99565b608084018190526020840182600381111561355157634e487b7160e01b600052602160045260246000fd5b600381111561357057634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561359b57634e487b7160e01b600052602160045260246000fd5b146135d9576135cb600960378460200151600381111561126157634e487b7160e01b600052602160045260246000fd5b600094509450505050613007565b816080015186106135f357608082015160408301526135fb565b604082018690525b613609888360400151614b2c565b60e08301819052608083015161361e91612ee1565b60a084018190526020840182600381111561364957634e487b7160e01b600052602160045260246000fd5b600381111561366857634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561369357634e487b7160e01b600052602160045260246000fd5b146136e05760405162461bcd60e51b815260206004820181905260248201527f52455041595f4e45575f4143434f554e545f42414c414e43455f4641494c45446044820152606401610804565b6136f0600b548360e00151612ee1565b60c084018190526020840182600381111561371b57634e487b7160e01b600052602160045260246000fd5b600381111561373a57634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561376557634e487b7160e01b600052602160045260246000fd5b146137b25760405162461bcd60e51b815260206004820152601e60248201527f52455041595f4e45575f544f54414c5f42414c414e43455f4641494c454400006044820152606401610804565b60a0820180516001600160a01b03891660009081526010602052604090819020918255600a5460019092019190915560c0840151600b81905560e0850151925191517f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a19361384f938d938d936001600160a01b03958616815293909416602084015260408301919091526060820152608081019190915260a00190565b60405180910390a161386687828460a00151614d72565b5060e00151600097909650945050505050565b6000806000806138898787612f80565b909250905060008260038111156138b057634e487b7160e01b600052602160045260246000fd5b146138c15750915060009050613007565b6130008186612ee1565b60006138d5614f95565b6000806138ea86670de0b6b3a7640000614295565b9092509050600082600381111561391157634e487b7160e01b600052602160045260246000fd5b1461393057506040805160208101909152600081529092509050612aca565b60008061393d83886142e8565b9092509050600082600381111561396457634e487b7160e01b600052602160045260246000fd5b146139875781604051806020016040528060008152509550955050505050612aca565b604080516020810190915290815260009890975095505050505050565b600554604080516312ab2eaf60e21b815290516000926001600160a01b031691634aacbabc916004808301926020929190829003018186803b1580156139e957600080fd5b505afa1580156139fd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a2191906150e3565b90506001600160a01b03811615801590613ab257506040516301fd3f7760e71b81526001600160a01b0382169063fe9fbb8090613a629030906004016152ee565b60206040518083038186803b158015613a7a57600080fd5b505afa158015613a8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ab2919061529e565b1561202157604051639eba1f6760e01b81526001600160a01b03821690639eba1f6790613ae990309088908890889060040161537a565b600060405180830381600087803b158015613b0357600080fd5b505af1158015611998573d6000803e3d6000fd5b805160009061079590670de0b6b3a7640000906154a5565b6000821580613b3c575081155b613b885760405162461bcd60e51b815260206004820152601e60248201527f746f6b656e73496e206f7220616d6f756e74496e206d757374206265203000006044820152606401610804565b613bc96040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b613bd161236c565b6040830181905260208301826003811115613bfc57634e487b7160e01b600052602160045260246000fd5b6003811115613c1b57634e487b7160e01b600052602160045260246000fd5b9052506000905081602001516003811115613c4657634e487b7160e01b600052602160045260246000fd5b14613c7e57613c766009602b8360200151600381111561126157634e487b7160e01b600052602160045260246000fd5b915050610f2c565b8315613d98576001600160a01b0385166000908152600e60205260409020548410613cc6576001600160a01b0385166000908152600e60205260409020546060820152613cce565b606081018490525b613cee604051806020016040528083604001518152508260600151612ad1565b6080830181905260208301826003811115613d1957634e487b7160e01b600052602160045260246000fd5b6003811115613d3857634e487b7160e01b600052602160045260246000fd5b9052506000905081602001516003811115613d6357634e487b7160e01b600052602160045260246000fd5b14613d9357613c76600960298360200151600381111561126157634e487b7160e01b600052602160045260246000fd5b613ea6565b600019831415613ddf576001600160a01b0385166000908152600e60209081526040918290205460608401908152825191820183529183015181529051613cee9190612ad1565b6080810183905260408051602081018252908201518152613e01908490613299565b6060830181905260208301826003811115613e2c57634e487b7160e01b600052602160045260246000fd5b6003811115613e4b57634e487b7160e01b600052602160045260246000fd5b9052506000905081602001516003811115613e7657634e487b7160e01b600052602160045260246000fd5b14613ea657613c766009602a8360200151600381111561126157634e487b7160e01b600052602160045260246000fd5b600554606082015160405163eabe7d9160e01b81526000926001600160a01b03169163eabe7d9191613edf9130918b9190600401615356565b602060405180830381600087803b158015613ef957600080fd5b505af1158015613f0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f3191906152d6565b90508015613f4f57613f466003602883612cb3565b92505050610f2c565b4260095414613f6457613f46600a602c61290d565b613f74600d548360600151612ee1565b60a0840181905260208401826003811115613f9f57634e487b7160e01b600052602160045260246000fd5b6003811115613fbe57634e487b7160e01b600052602160045260246000fd5b9052506000905082602001516003811115613fe957634e487b7160e01b600052602160045260246000fd5b1461401957613f466009602e8460200151600381111561126157634e487b7160e01b600052602160045260246000fd5b6001600160a01b0386166000908152600e60205260409020546060830151111561405c576001600160a01b0386166000908152600e602052604090205460608301525b6001600160a01b0386166000908152600e602052604090205460608301516140849190612ee1565b60c08401819052602084018260038111156140af57634e487b7160e01b600052602160045260246000fd5b60038111156140ce57634e487b7160e01b600052602160045260246000fd5b90525060009050826020015160038111156140f957634e487b7160e01b600052602160045260246000fd5b1461412957613f466009602d8460200151600381111561126157634e487b7160e01b600052602160045260246000fd5b8160800151614136612b31565b101561414857613f46600e602f61290d565b6001600160a01b0386166000908152600e602052604090205460c08301516141719188916139a4565b60a0820151600d5560c08201516001600160a01b0387166000818152600e60205260409081902092909255606084015191513092600080516020615592833981519152916141c191815260200190565b60405180910390a3608082015160608301516040517fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a92992614203928a92615335565b60405180910390a1600554608083015160608401516040516351dff98960e01b81526001600160a01b03909316926351dff989926142499230928c92919060040161537a565b600060405180830381600087803b15801561426357600080fd5b505af1158015614277573d6000803e3d6000fd5b50505050614289868360800151614eb7565b60009695505050505050565b600080836142a857506000905080612aca565b838302838582816142c957634e487b7160e01b600052601260045260246000fd5b04146142dd57600260009250925050612aca565b600092509050612aca565b600080826142fc5750600190506000612aca565b600083858161431b57634e487b7160e01b600052601260045260246000fd5b04915091509250929050565b600554604051634ef4c3e160e01b8152600091829182916001600160a01b031690634ef4c3e19061436090309089908990600401615356565b602060405180830381600087803b15801561437a57600080fd5b505af115801561438e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143b291906152d6565b905080156143d3576143c76003601f83612cb3565b60009250925050612aca565b5042600954146143f4576143e9600a602261290d565b600091509150612aca565b6040805180820190915260008082526020820152600061441261236c565b8360200181935082600381111561443957634e487b7160e01b600052602160045260246000fd5b600381111561445857634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561448357634e487b7160e01b600052602160045260246000fd5b146144b357612a6c600960218460200151600381111561126157634e487b7160e01b600052602160045260246000fd5b60006144bf8787614b2c565b905060006144db82604051806020016040528086815250613299565b8560200181935082600381111561450257634e487b7160e01b600052602160045260246000fd5b600381111561452157634e487b7160e01b600052602160045260246000fd5b905250600090508460200151600381111561454c57634e487b7160e01b600052602160045260246000fd5b146145995760405162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c45446044820152606401610804565b60006145a7600d5483612f80565b866020018193508260038111156145ce57634e487b7160e01b600052602160045260246000fd5b60038111156145ed57634e487b7160e01b600052602160045260246000fd5b905250600090508560200151600381111561461857634e487b7160e01b600052602160045260246000fd5b146146645760405162461bcd60e51b815260206004820152601c60248201527b1352539517d39155d7d513d5105317d4d55414131657d1905253115160221b6044820152606401610804565b6001600160a01b0389166000908152600e60205260408120546146879084612f80565b876020018193508260038111156146ae57634e487b7160e01b600052602160045260246000fd5b60038111156146cd57634e487b7160e01b600052602160045260246000fd5b90525060009050866020015160038111156146f857634e487b7160e01b600052602160045260246000fd5b146147455760405162461bcd60e51b815260206004820152601f60248201527f4d494e545f4e45575f4143434f554e545f42414c414e43455f4641494c4544006044820152606401610804565b6001600160a01b038a166000908152600e602052604090205461476a908b90836139a4565b600d8290556001600160a01b038a166000908152600e602052604090819020829055517f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f906147be908c9087908790615335565b60405180910390a16040518381526001600160a01b038b16906000906000805160206155928339815191529060200160405180910390a360009a93995092975050505050505050565b60055460405163368f515360e21b815260009182916001600160a01b039091169063da3d454c9061484090309088908890600401615356565b602060405180830381600087803b15801561485a57600080fd5b505af115801561486e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061489291906152d6565b905080156148af576148a76003600e83612cb3565b915050610795565b5042600954146148cb576148c4600a8061290d565b9050610795565b816148d4612b31565b10156148e6576148c4600e600961290d565b6000806148f285612d99565b9092509050600082600381111561491957634e487b7160e01b600052602160045260246000fd5b1461494e576149456009600784600381111561126157634e487b7160e01b600052602160045260246000fd5b92505050610795565b80600061495b8287612f80565b9094509050600084600381111561498257634e487b7160e01b600052602160045260246000fd5b146149b9576149ae6009600c86600381111561126157634e487b7160e01b600052602160045260246000fd5b945050505050610795565b60006149c7600b5488612f80565b909550905060008560038111156149ee57634e487b7160e01b600052602160045260246000fd5b14614a2657614a1a6009600b87600381111561126157634e487b7160e01b600052602160045260246000fd5b95505050505050610795565b6001600160a01b038816600081815260106020908152604091829020858155600a54600190910155600b849055815192835282018990528101839052606081018290527f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809060800160405180910390a1614aa1888484614d72565b614aab8888614eb7565b600098975050505050505050565b6000614ac3614f95565b600080614ad8670de0b6b3a764000087614295565b90925090506000826003811115614aff57634e487b7160e01b600052602160045260246000fd5b14614b1e57506040805160208101909152600081529092509050612aca565b612b248186600001516138cb565b6012546040516370a0823160e01b81526000916001600160a01b031690829082906370a0823190614b619030906004016152ee565b60206040518083038186803b158015614b7957600080fd5b505afa158015614b8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614bb191906152d6565b6040516323b872dd60e01b81529091506001600160a01b038316906323b872dd90614be490889030908990600401615356565b600060405180830381600087803b158015614bfe57600080fd5b505af1158015614c12573d6000803e3d6000fd5b5050505060003d60008114614c2e5760208114614c3857600080fd5b6000199150614c44565b60206000803e60005191505b5080614c8d5760405162461bcd60e51b81526020600482015260186024820152771513d2d15397d514905394d1915497d25397d1905253115160421b6044820152606401610804565b6012546040516370a0823160e01b81526000916001600160a01b0316906370a0823190614cbe9030906004016152ee565b60206040518083038186803b158015614cd657600080fd5b505afa158015614cea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d0e91906152d6565b905082811015614d5d5760405162461bcd60e51b815260206004820152601a602482015279544f4b454e5f5452414e534645525f494e5f4f564552464c4f5760301b6044820152606401610804565b614d6783826154c5565b979650505050505050565b600554604080516312ab2eaf60e21b815290516000926001600160a01b031691634aacbabc916004808301926020929190829003018186803b158015614db757600080fd5b505afa158015614dcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614def91906150e3565b90506001600160a01b03811615801590614e8057506040516301fd3f7760e71b81526001600160a01b0382169063fe9fbb8090614e309030906004016152ee565b60206040518083038186803b158015614e4857600080fd5b505afa158015614e5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e80919061529e565b1561202157604051630578982360e01b81526001600160a01b03821690630578982390613ae990309088908890889060040161537a565b60125460405163a9059cbb60e01b81526001600160a01b0390911690819063a9059cbb90614eeb908690869060040161531c565b600060405180830381600087803b158015614f0557600080fd5b505af1158015614f19573d6000803e3d6000fd5b5050505060003d60008114614f355760208114614f3f57600080fd5b6000199150614f4b565b60206000803e60005191505b50806120215760405162461bcd60e51b81526020600482015260196024820152781513d2d15397d514905394d1915497d3d55517d19052531151603a1b6044820152606401610804565b6040518060200160405280600081525090565b828054614fb4906154e8565b90600052602060002090601f016020900481019282614fd6576000855561501c565b82601f10614fef57805160ff191683800117855561501c565b8280016001018555821561501c579182015b8281111561501c578251825591602001919060010190615001565b5061502892915061502c565b5090565b5b80821115615028576000815560010161502d565b600082601f830112615051578081fd5b81356001600160401b038082111561506b5761506b615523565b604051601f8301601f19908116603f0116810190828211818310171561509357615093615523565b816040528381528660208588010111156150ab578485fd5b8360208701602083013792830160200193909352509392505050565b6000602082840312156150d8578081fd5b8135610f2c81615539565b6000602082840312156150f4578081fd5b8151610f2c81615539565b60008060408385031215615111578081fd5b823561511c81615539565b9150602083013561512c81615539565b809150509250929050565b60008060006060848603121561514b578081fd5b833561515681615539565b9250602084013561516681615539565b929592945050506040919091013590565b600080600080600080600060e0888a031215615191578283fd5b873561519c81615539565b965060208801356151ac81615539565b955060408801356151bc81615539565b94506060880135935060808801356001600160401b03808211156151de578485fd5b6151ea8b838c01615041565b945060a08a01359150808211156151ff578384fd5b5061520c8a828b01615041565b92505060c088013560ff81168114615222578182fd5b8091505092959891949750929550565b60008060408385031215615244578182fd5b823561524f81615539565b946020939093013593505050565b600080600060608486031215615271578283fd5b833561527c81615539565b925060208401359150604084013561529381615539565b809150509250925092565b6000602082840312156152af578081fd5b81518015158114610f2c578182fd5b6000602082840312156152cf578081fd5b5035919050565b6000602082840312156152e7578081fd5b5051919050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039390931683526020830191909152604082015260600190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260800190565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b6000602080835283518082850152825b818110156153f9578581018301518582016040015282016153dd565b8181111561540a5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252601690820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604082015260600190565b6020808252600a90820152691c994b595b9d195c995960b21b604082015260600190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b6000826154c057634e487b7160e01b81526012600452602481fd5b500490565b6000828210156154e357634e487b7160e01b81526011600452602481fd5b500390565b600181811c908216806154fc57607f821691505b6020821081141561551d57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461554e57600080fd5b5056fe45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0ca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3eff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dca2646970667358221220bd0664edec2fa39d2968989abe384db02d56c858558437b2ad9377730216797e64736f6c63430008040033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061027d5760003560e01c806306fdde0314610282578063095ea7b3146102a05780630e752702146102c3578063173b9904146102d857806317bfdfbc146102ef57806318160ddd14610302578063182df0f51461030b5780631be195601461031357806323b872dd146103265780632608f81814610339578063267822471461034c578063313ce5671461036c57806335d253651461038b5780633af9e669146103b35780633b1d21a2146103c65780633e941010146103ce5780634576b5db146103e157806347bd3718146103f45780635fe3b567146103fd578063601a0bf1146104105780636752e702146104235780636f307dc31461042c578063704b6c021461043f57806370a082311461045257806373acee981461047b5780638303084614610483578063852a12e3146104965780638f840ddd146104a957806390225c82146104b257806395d89b41146104d457806395dd9193146104dc57806397de9d11146104ef578063a0712d68146104f7578063a6afed951461050a578063a9059cbb14610512578063aa5af0fd14610525578063afe654681461052e578063b145a5b814610541578063b2a02ff114610555578063b71d1a0c14610568578063bd6d894d1461057b578063c37f68e214610583578063c5ebeaec146105a6578063cd91801c146105b9578063cfa99201146105c1578063d3bd2c72146105ca578063db006a75146105d2578063dd62ed3e146105e5578063e9c714f21461061e578063efadf96014610626578063f2b3abbd14610639578063f3fdb15a1461064c578063f5e3c4621461065f578063f851a44014610672578063fca7820b1461068a575b600080fd5b61028a61069d565b60405161029791906153cd565b60405180910390f35b6102b36102ae366004615232565b61072b565b6040519015158152602001610297565b6102d66102d13660046152be565b61079b565b005b6102e160085481565b604051908152602001610297565b6102e16102fd3660046150c7565b6107e1565b6102e1600d5481565b6102e161085a565b6102d66103213660046150c7565b6108d7565b6102b3610334366004615137565b610b8e565b6102d6610347366004615232565b610bde565b60045461035f906001600160a01b031681565b60405161029791906152ee565b6003546103799060ff1681565b60405160ff9091168152602001610297565b61039e610399366004615232565b610c27565b60408051928352602083019190915201610297565b6102e16103c13660046150c7565b610d10565b6102e1610dce565b6102e16103dc3660046152be565b610ddd565b6102e16103ef3660046150c7565b610de8565b6102e1600b5481565b60055461035f906001600160a01b031681565b6102e161041e3660046152be565b610f33565b6102e160115481565b60125461035f906001600160a01b031681565b6102d661044d3660046150c7565b610fb9565b6102e16104603660046150c7565b6001600160a01b03166000908152600e602052604090205490565b6102e1611065565b6102e16104913660046152be565b6110cb565b6102d66104a43660046152be565b611139565b6102e1600c5481565b6104c56104c03660046150ff565b611142565b60405161029793929190615474565b61028a611365565b6102e16104ea3660046150c7565b611372565b6102b3600181565b6102d66105053660046152be565b6113f1565b6102e161142c565b6102b3610520366004615232565b61182a565b6102e1600a5481565b6102d661053c366004615177565b611879565b6012546102b390600160a01b900460ff1681565b6102e1610563366004615137565b6119a2565b6102e16105763660046150c7565b6119da565b6102e1611a55565b6105966105913660046150c7565b611ac1565b604051610297949392919061548a565b6102d66105b43660046152be565b611b7e565b6102e1611b87565b6102e160095481565b6102e1611c17565b6102d66105e03660046152be565b611c5b565b6102e16105f33660046150ff565b6001600160a01b039182166000908152600f6020908152604080832093909416825291909152205490565b6102e1611c64565b6104c56106343660046150c7565b611d34565b6102e16106473660046150c7565b611f95565b60065461035f906001600160a01b031681565b6102d661066d36600461525d565b611fd9565b60035461035f9061010090046001600160a01b031681565b6102e16106983660046152be565b612027565b600180546106aa906154e8565b80601f01602080910402602001604051908101604052809291908181526020018280546106d6906154e8565b80156107235780601f106106f857610100808354040283529160200191610723565b820191906000526020600020905b81548152906001019060200180831161070657829003601f168201915b505050505081565b336000818152600f602090815260408083206001600160a01b03871680855292528083208590555191929182907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906107879087815260200190565b60405180910390a360019150505b92915050565b60006107a68261208e565b5090506107dd81604051806040016040528060128152602001711c995c185e509bdc9c9bddc819985a5b195960721b815250612128565b5050565b6000805460ff1661080d5760405162461bcd60e51b815260040161080490615450565b60405180910390fd5b6000805460ff1916815561081f61142c565b1461083c5760405162461bcd60e51b815260040161080490615420565b61084582611372565b90505b6000805460ff19166001179055919050565b600080600061086761236c565b9092509050600082600381111561088e57634e487b7160e01b600052602160045260246000fd5b146107955760405162461bcd60e51b8152602060048201526019602482015278195e18da185b99d954985d1954dd1bdc99590819985a5b1959603a1b6044820152606401610804565b6012546001600160a01b03828116911614156109505760405162461bcd60e51b815260206004820152603260248201527f4f45726332303a3a7377656570546f6b656e3a2063616e206e6f74207377656560448201527138103ab73232b9363cb4b733903a37b5b2b760711b6064820152608401610804565b6012546040516370a0823160e01b81526000916001600160a01b0316906370a08231906109819030906004016152ee565b60206040518083038186803b15801561099957600080fd5b505afa1580156109ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d191906152d6565b90506000826001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610a0191906152ee565b60206040518083038186803b158015610a1957600080fd5b505afa158015610a2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5191906152d6565b60035460405163a9059cbb60e01b81529192506001600160a01b038086169263a9059cbb92610a8c926101009091041690859060040161531c565b600060405180830381600087803b158015610aa657600080fd5b505af1158015610aba573d6000803e3d6000fd5b50506012546040516370a0823160e01b81526001600160a01b0390911692506370a082319150610aee9030906004016152ee565b60206040518083038186803b158015610b0657600080fd5b505afa158015610b1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3e91906152d6565b8214610b895760405162461bcd60e51b815260206004820152601a6024820152791d5b99195c9b1e5a5b99c818985b185b98d94818da185b99d95960321b6044820152606401610804565b505050565b6000805460ff16610bb15760405162461bcd60e51b815260040161080490615450565b6000805460ff19168155610bc733868686612436565b1490506000805460ff191660011790559392505050565b6000610bea8383612890565b509050610b8981604051806040016040528060188152602001771c995c185e509bdc9c9bddd0995a185b198819985a5b195960421b815250612128565b60008054819060ff16610c4c5760405162461bcd60e51b815260040161080490615450565b6000805460ff1916905533737a10033fb8f474f28c66cab7578f4af9e6dad37d14610c8657610c7b6031612904565b600091509150610cfa565b6000610c9061142c565b90508015610cce57610cc2816010811115610cbb57634e487b7160e01b600052602160045260246000fd5b603061290d565b60009250925050610cfa565b610cd784612997565b90508015610cea57915060009050610cfa565b610cf48585612a0a565b92509250505b6000805460ff1916600117905590939092509050565b6000806040518060200160405280610d26611a55565b90526001600160a01b0384166000908152600e6020526040812054919250908190610d52908490612ad1565b90925090506000826003811115610d7957634e487b7160e01b600052602160045260246000fd5b14610dc65760405162461bcd60e51b815260206004820152601f60248201527f62616c616e636520636f756c64206e6f742062652063616c63756c61746564006044820152606401610804565b949350505050565b6000610dd8612b31565b905090565b600061079582612bba565b60035460009061010090046001600160a01b03163314610e0c57610795603f612904565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd2916004808301926020929190829003018186803b158015610e5157600080fd5b505afa158015610e65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e89919061529e565b610ed45760405162461bcd60e51b815260206004820152601c60248201527b6d61726b6572206d6574686f642072657475726e65642066616c736560201b6044820152606401610804565b600580546001600160a01b0319166001600160a01b0385161790556040517f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d90610f219083908690615302565b60405180910390a160005b9392505050565b6000805460ff16610f565760405162461bcd60e51b815260040161080490615450565b6000805460ff19168155610f6861142c565b90508015610f9b57610f93816010811115610cbb57634e487b7160e01b600052602160045260246000fd5b915050610848565b610fa483612c38565b9150506000805460ff19166001179055919050565b60035461010090046001600160a01b031633146110075760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b6044820152606401610804565b600380546001600160a01b03838116610100908102610100600160a81b031984161793849055604051928190048216936000805160206155b28339815191529361105993869390920490911690615302565b60405180910390a15050565b6000805460ff166110885760405162461bcd60e51b815260040161080490615450565b6000805460ff1916815561109a61142c565b146110b75760405162461bcd60e51b815260040161080490615420565b50600b546000805460ff1916600117905590565b6000805460ff166110ee5760405162461bcd60e51b815260040161080490615450565b6000805460ff1916815561110061142c565b9050801561113257610f9381601081111561112b57634e487b7160e01b600052602160045260246000fd5b605161290d565b6000610fa4565b6107dd81612c40565b600080548190819060ff166111695760405162461bcd60e51b815260040161080490615450565b6000805460ff1916905533737a10033fb8f474f28c66cab7578f4af9e6dad37d146111a6576111986031612904565b60008092509250925061134e565b60006111b061142c565b905080156111ea576111db81601081111561112b57634e487b7160e01b600052602160045260246000fd5b6000809350935093505061134e565b6001600160a01b0386166000908152600e602052604081205490808061120e61236c565b9093509150600083600381111561123557634e487b7160e01b600052602160045260246000fd5b14611279576112666009602b85600381111561126157634e487b7160e01b600052602160045260246000fd5b612cb3565b600080975097509750505050505061134e565b61129160405180602001604052808481525085612ad1565b909350905060008360038111156112b857634e487b7160e01b600052602160045260246000fd5b146112e4576112666009602985600381111561126157634e487b7160e01b600052602160045260246000fd5b6000806112f18c87612d3c565b90506112fd8b84612a0a565b909750915086156113405761132b87601081111561112b57634e487b7160e01b600052602160045260246000fd5b6000809950995099505050505050505061134e565b959850949650939450505050505b6000805460ff191660011790559194909350909150565b600280546106aa906154e8565b600080600061138084612d99565b909250905060008260038111156113a757634e487b7160e01b600052602160045260246000fd5b14610f2c5760405162461bcd60e51b815260206004820152601a602482015279189bdc9c9bddd0985b185b98d954dd1bdc99590819985a5b195960321b6044820152606401610804565b60006113fc82612e6e565b5090506107dd816040518060400160405280600b81526020016a1b5a5b9d0819985a5b195960aa1b815250612128565b6009546000904290808214156114465760005b9250505090565b6000611450612b31565b600b54600c54600a546006546040516315f2405360e01b81529495509293919290916000916001600160a01b0316906315f240539061149790889088908890600401615474565b60206040518083038186803b1580156114af57600080fd5b505afa1580156114c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e791906152d6565b905065048c2739500081111561153e5760405162461bcd60e51b815260206004820152601c60248201527b0c4dee4e4deee40e4c2e8ca40d2e640c2c4e6eae4c8d8f240d0d2ced60231b6044820152606401610804565b60008061154b8989612ee1565b9092509050600082600381111561157257634e487b7160e01b600052602160045260246000fd5b146115bf5760405162461bcd60e51b815260206004820152601f60248201527f636f756c64206e6f742063616c63756c61746520626c6f636b2064656c7461006044820152606401610804565b6115c7614f95565b6000806000806115e560405180602001604052808a81525087612f04565b9097509450600087600381111561160c57634e487b7160e01b600052602160045260246000fd5b1461164b576116386009600689600381111561126157634e487b7160e01b600052602160045260246000fd5b9e50505050505050505050505050505090565b611655858c612ad1565b9097509350600087600381111561167c57634e487b7160e01b600052602160045260246000fd5b146116a8576116386009600189600381111561126157634e487b7160e01b600052602160045260246000fd5b6116b2848c612f80565b909750925060008760038111156116d957634e487b7160e01b600052602160045260246000fd5b14611705576116386009600489600381111561126157634e487b7160e01b600052602160045260246000fd5b6117206040518060200160405280600854815250858c612fa6565b9097509150600087600381111561174757634e487b7160e01b600052602160045260246000fd5b14611773576116386009600589600381111561126157634e487b7160e01b600052602160045260246000fd5b61177e858a8b612fa6565b909750905060008760038111156117a557634e487b7160e01b600052602160045260246000fd5b146117d1576116386009600389600381111561126157634e487b7160e01b600052602160045260246000fd5b60098e9055600a819055600b839055600c8290556040517f4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc049061181b908e9087908590889061548a565b60405180910390a16000611638565b6000805460ff1661184d5760405162461bcd60e51b815260040161080490615450565b6000805460ff1916815561186333338686612436565b1490506000805460ff1916600117905592915050565b601254600160a01b900460ff16156118d25760405162461bcd60e51b815260206004820152601c60248201527b18dbdb9d1c9858dd08185b1c9958591e481a5b9a5d1a585b1a5e995960221b6044820152606401610804565b6012805460ff60a01b1916600160a01b179055600380543361010002610100600160a81b031990911617905561190c86868686868661300f565b601280546001600160a01b0319166001600160a01b038916908117909155604080516318160ddd60e01b815290516318160ddd91600480820192602092909190829003018186803b15801561196057600080fd5b505afa158015611974573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199891906152d6565b5050505050505050565b6000805460ff166119c55760405162461bcd60e51b815260040161080490615450565b50506000805460ff1916600117815592915050565b60035460009061010090046001600160a01b031633146119fe576107956045612904565b60045460405160008051602061557283398151915291611a2b916001600160a01b03909116908590615302565b60405180910390a1600480546001600160a01b0319166001600160a01b0384161790556000610795565b6000805460ff16611a785760405162461bcd60e51b815260040161080490615450565b6000805460ff19168155611a8a61142c565b14611aa75760405162461bcd60e51b815260040161080490615420565b611aaf61085a565b90506000805460ff1916600117905590565b6001600160a01b0381166000908152600e6020526040812054819081908190818080611aec89612d99565b935090506000816003811115611b1257634e487b7160e01b600052602160045260246000fd5b14611b305760095b6000806000975097509750975050505050611b77565b611b3861236c565b925090506000816003811115611b5e57634e487b7160e01b600052602160045260246000fd5b14611b6a576009611b1a565b5060009650919450925090505b9193509193565b6107dd816131bc565b6006546000906001600160a01b03166315f24053611ba3612b31565b600b54600c546040518463ffffffff1660e01b8152600401611bc793929190615474565b60206040518083038186803b158015611bdf57600080fd5b505afa158015611bf3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd891906152d6565b6006546000906001600160a01b031663b8168816611c33612b31565b600b54600c546008546040518563ffffffff1660e01b8152600401611bc7949392919061548a565b6107dd8161322d565b6004546000906001600160a01b031633141580611c7f575033155b15611c8e57610dd86000612904565b60038054600480546001600160a01b03818116610100818102610100600160a81b0319871617968790556001600160a01b03199093169093556040519382900481169492936000805160206155b283398151915293611cf293879391041690615302565b60405180910390a160045460405160008051602061557283398151915291611d259184916001600160a01b031690615302565b60405180910390a1600061143f565b600080548190819060ff16611d5b5760405162461bcd60e51b815260040161080490615450565b6000805460ff1916905533737a10033fb8f474f28c66cab7578f4af9e6dad37d14611d9857611d8a6031612904565b600080925092509250611f81565b6000611da261142c565b90508015611ddc57611dcd81601081111561112b57634e487b7160e01b600052602160045260246000fd5b60008093509350935050611f81565b600080600080611deb89612d99565b90945092506000846003811115611e1257634e487b7160e01b600052602160045260246000fd5b14611e5157611e3e6009603786600381111561126157634e487b7160e01b600052602160045260246000fd5b6000809750975097505050505050611f81565b611e5961236c565b90945091506000846003811115611e8057634e487b7160e01b600052602160045260246000fd5b14611eac57611e3e6009602b86600381111561126157634e487b7160e01b600052602160045260246000fd5b611ec483604051806020016040528085815250613299565b90945090506000846003811115611eeb57634e487b7160e01b600052602160045260246000fd5b14611f1757611e3e6009602986600381111561126157634e487b7160e01b600052602160045260246000fd5b600080611f248b84612d3c565b9050611f308b86612a0a565b90975091508615611f7357611f5e87601081111561112b57634e487b7160e01b600052602160045260246000fd5b60008099509950995050505050505050611f81565b959850949650939450505050505b6000805460ff191660011790559193909250565b600080611fa061142c565b90508015611fd257610f2c816010811115611fcb57634e487b7160e01b600052602160045260246000fd5b604061290d565b6000610f2c565b6000611fe68484846132a9565b50905061202181604051806040016040528060168152602001751b1a5c5d5a59185d19509bdc9c9bddc819985a5b195960521b815250612128565b50505050565b6000805460ff1661204a5760405162461bcd60e51b815260040161080490615450565b6000805460ff1916815561205c61142c565b9050801561113257610f9381601081111561208757634e487b7160e01b600052602160045260246000fd5b604661290d565b60008054819060ff166120b35760405162461bcd60e51b815260040161080490615450565b6000805460ff191681556120c561142c565b90508015612103576120f78160108111156120f057634e487b7160e01b600052602160045260246000fd5b603661290d565b60009250925050612114565b61210e3333866133e3565b92509250505b6000805460ff191660011790559092909150565b81612131575050565b600081516005016001600160401b0381111561215d57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612187576020820181803683370190505b50905060005b8251811015612200578281815181106121b657634e487b7160e01b600052603260045260246000fd5b602001015160f81c60f81b8282815181106121e157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060010161218d565b8151600160fd1b9083908390811061222857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350602860f81b82826001018151811061226757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600a840460300160f81b8282600201815181106122ab57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600a840660300160f81b8282600301815181106122ef57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350602960f81b82826004018151811061232e57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053508184156123655760405162461bcd60e51b815260040161080491906153cd565b5050505050565b600d54600090819080612386575050600754600092909150565b6000612390612b31565b9050600061239c614f95565b60006123ad84600b54600c54613879565b9350905060008160038111156123d357634e487b7160e01b600052602160045260246000fd5b146123e5579660009650945050505050565b6123ef83866138cb565b92509050600081600381111561241557634e487b7160e01b600052602160045260246000fd5b14612427579660009650945050505050565b50516000969095509350505050565b6005546040516317b9b84b60e31b815260009182916001600160a01b039091169063bdcdc258906124719030908990899089906004016153a3565b602060405180830381600087803b15801561248b57600080fd5b505af115801561249f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124c391906152d6565b905080156125115760405162461bcd60e51b815260206004820152601b60248201527a115490cc8c0e881d1c985b9cd9995c881b9bdd08185b1b1bddd959602a1b6044820152606401610804565b836001600160a01b0316856001600160a01b031614156125735760405162461bcd60e51b815260206004820181905260248201527f45524332303a2073656c662d7472616e73666572206e6f7420616c6c6f7765646044820152606401610804565b6000856001600160a01b0316876001600160a01b0316141561259857506000196125c0565b506001600160a01b038086166000908152600f60209081526040808320938a16835292905220545b6000806000806125d08589612ee1565b909450925060008460038111156125f757634e487b7160e01b600052602160045260246000fd5b146126525760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610804565b6001600160a01b038a166000908152600e60205260409020546126759089612ee1565b9094509150600084600381111561269c57634e487b7160e01b600052602160045260246000fd5b146126f85760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610804565b6001600160a01b0389166000908152600e602052604090205461271b9089612f80565b9094509050600084600381111561274257634e487b7160e01b600052602160045260246000fd5b146127a25760405162461bcd60e51b815260206004820152602a60248201527f45524332303a206d6178696d756d2064657374696e6174696f6e2062616c616e60448201526918d9481c995858da195960b21b6064820152608401610804565b6001600160a01b038a166000908152600e60205260409020546127c7908b90846139a4565b6001600160a01b0389166000908152600e60205260409020546127ec908a90836139a4565b6001600160a01b03808b166000908152600e6020526040808220859055918b168152208190556000198514612844576001600160a01b03808b166000908152600f60209081526040808320938f168352929052208390555b886001600160a01b03168a6001600160a01b03166000805160206155928339815191528a60405161287791815260200190565b60405180910390a360009b9a5050505050505050505050565b60008054819060ff166128b55760405162461bcd60e51b815260040161080490615450565b6000805460ff191681556128c761142c565b905080156128f957610cc28160108111156128f257634e487b7160e01b600052602160045260246000fd5b603561290d565b610cf43386866133e3565b60006107956001835b600060008051602061555283398151915283601081111561293e57634e487b7160e01b600052602160045260246000fd5b83605381111561295e57634e487b7160e01b600052602160045260246000fd5b600060405161296f93929190615474565b60405180910390a1826010811115610f2c57634e487b7160e01b600052602160045260246000fd5b600080600c548311156129b057610f2c6002603461290d565b82600c546129be91906154c5565b600c8190556003546040519192507f3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e91610f219161010090046001600160a01b03169086908590615335565b600080600080612a1986612d99565b90925090506000826003811115612a4057634e487b7160e01b600052602160045260246000fd5b14612a7957612a6c6009603784600381111561126157634e487b7160e01b600052602160045260246000fd5b6000935093505050612aca565b6000612a8586836154c5565b9050600086600b54612a9791906154c5565b6001600160a01b0389166000908152601060205260408120938455600a54600190940193909355600b5550935084925050505b9250929050565b600080600080612ae18686612f04565b90925090506000826003811115612b0857634e487b7160e01b600052602160045260246000fd5b14612b195750915060009050612aca565b6000612b2482613b17565b9350935050509250929050565b6012546040516370a0823160e01b81526000916001600160a01b03169081906370a0823190612b649030906004016152ee565b60206040518083038186803b158015612b7c57600080fd5b505afa158015612b90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bb491906152d6565b91505090565b6000805460ff16612bdd5760405162461bcd60e51b815260040161080490615450565b6000805460ff19168155612bef61142c565b90508015612c2157610f93816010811115612c1a57634e487b7160e01b600052602160045260246000fd5b604e61290d565b60009150506000805460ff19166001179055919050565b600080610795565b6000805460ff16612c635760405162461bcd60e51b815260040161080490615450565b6000805460ff19168155612c7561142c565b90508015612ca757610f93816010811115612ca057634e487b7160e01b600052602160045260246000fd5b602761290d565b610fa433600085613b2f565b6000600080516020615552833981519152846010811115612ce457634e487b7160e01b600052602160045260246000fd5b846053811115612d0457634e487b7160e01b600052602160045260246000fd5b84604051612d1493929190615474565b60405180910390a1836010811115610dc657634e487b7160e01b600052602160045260246000fd5b6001600160a01b0382166000908152600e60205260408120548190612d629084906154c5565b9050600083600d54612d7491906154c5565b600d55506001600160a01b0384166000908152600e6020526040902055508092915050565b6001600160a01b038116600090815260106020526040812080548291829182918291612dce5750600096879650945050505050565b612dde8160000154600a54614295565b90945092506000846003811115612e0557634e487b7160e01b600052602160045260246000fd5b14612e1857509195600095509350505050565b612e268382600101546142e8565b90945091506000846003811115612e4d57634e487b7160e01b600052602160045260246000fd5b14612e6057509195600095509350505050565b506000969095509350505050565b60008054819060ff16612e935760405162461bcd60e51b815260040161080490615450565b6000805460ff19168155612ea561142c565b90508015612ed7576120f7816010811115612ed057634e487b7160e01b600052602160045260246000fd5b601e61290d565b61210e3385614327565b600080838311612ef8575060009050818303612aca565b50600390506000612aca565b6000612f0e614f95565b600080612f1f866000015186614295565b90925090506000826003811115612f4657634e487b7160e01b600052602160045260246000fd5b14612f6557506040805160208101909152600081529092509050612aca565b60408051602081019091529081526000969095509350505050565b600080838301848110612f9857600092509050612aca565b600260009250925050612aca565b600080600080612fb68787612f04565b90925090506000826003811115612fdd57634e487b7160e01b600052602160045260246000fd5b14612fee5750915060009050613007565b613000612ffa82613b17565b86612f80565b9350935050505b935093915050565b60035461010090046001600160a01b0316331461306a5760405162461bcd60e51b81526020600482015260196024820152786f6e6c792061646d696e206d617920696e697469616c697a6560381b6044820152606401610804565b60095415801561307a5750600a54155b6130bc5760405162461bcd60e51b8152602060048201526013602482015272185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610804565b60078490558361310e5760405162461bcd60e51b815260206004820152601e60248201527f696e69742065786368616e67652072617465206d757374206265203e203000006044820152606401610804565b600061311987610de8565b1461315f5760405162461bcd60e51b81526020600482015260166024820152751cd95d0818dbdb5c1d1c9bdb1b195c8819985a5b195960521b6044820152606401610804565b42600955670de0b6b3a7640000600a558251613182906001906020860190614fa8565b508151613196906002906020850190614fa8565b506003805460ff90921660ff199283161790556000805490911660011790555050505050565b6000805460ff166131df5760405162461bcd60e51b815260040161080490615450565b6000805460ff191681556131f161142c565b9050801561322357610f9381601081111561321c57634e487b7160e01b600052602160045260246000fd5b600861290d565b610fa43384614807565b6000805460ff166132505760405162461bcd60e51b815260040161080490615450565b6000805460ff1916815561326261142c565b9050801561328d57610f93816010811115612ca057634e487b7160e01b600052602160045260246000fd5b610fa433846000613b2f565b600080600080612ae18686614ab9565b60008054819060ff166132ce5760405162461bcd60e51b815260040161080490615450565b6000805460ff191681556132e061142c565b9050801561331e5761331281601081111561330b57634e487b7160e01b600052602160045260246000fd5b600f61290d565b600092509250506133cc565b836001600160a01b031663a6afed956040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561335957600080fd5b505af115801561336d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061339191906152d6565b905080156133c3576133128160108111156133bc57634e487b7160e01b600052602160045260246000fd5b601061290d565b60008092509250505b6000805460ff191660011790559094909350915050565b600554604051631200453160e11b8152600091829182916001600160a01b0316906324008a629061341e9030908a908a908a906004016153a3565b602060405180830381600087803b15801561343857600080fd5b505af115801561344c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061347091906152d6565b90508015613491576134856003603883612cb3565b60009250925050613007565b42600954146134a657613485600a603961290d565b6134ef6040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60006134fa87611372565b6001600160a01b0388166000908152601060205260409020600101546060840152905061352687612d99565b608084018190526020840182600381111561355157634e487b7160e01b600052602160045260246000fd5b600381111561357057634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561359b57634e487b7160e01b600052602160045260246000fd5b146135d9576135cb600960378460200151600381111561126157634e487b7160e01b600052602160045260246000fd5b600094509450505050613007565b816080015186106135f357608082015160408301526135fb565b604082018690525b613609888360400151614b2c565b60e08301819052608083015161361e91612ee1565b60a084018190526020840182600381111561364957634e487b7160e01b600052602160045260246000fd5b600381111561366857634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561369357634e487b7160e01b600052602160045260246000fd5b146136e05760405162461bcd60e51b815260206004820181905260248201527f52455041595f4e45575f4143434f554e545f42414c414e43455f4641494c45446044820152606401610804565b6136f0600b548360e00151612ee1565b60c084018190526020840182600381111561371b57634e487b7160e01b600052602160045260246000fd5b600381111561373a57634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561376557634e487b7160e01b600052602160045260246000fd5b146137b25760405162461bcd60e51b815260206004820152601e60248201527f52455041595f4e45575f544f54414c5f42414c414e43455f4641494c454400006044820152606401610804565b60a0820180516001600160a01b03891660009081526010602052604090819020918255600a5460019092019190915560c0840151600b81905560e0850151925191517f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a19361384f938d938d936001600160a01b03958616815293909416602084015260408301919091526060820152608081019190915260a00190565b60405180910390a161386687828460a00151614d72565b5060e00151600097909650945050505050565b6000806000806138898787612f80565b909250905060008260038111156138b057634e487b7160e01b600052602160045260246000fd5b146138c15750915060009050613007565b6130008186612ee1565b60006138d5614f95565b6000806138ea86670de0b6b3a7640000614295565b9092509050600082600381111561391157634e487b7160e01b600052602160045260246000fd5b1461393057506040805160208101909152600081529092509050612aca565b60008061393d83886142e8565b9092509050600082600381111561396457634e487b7160e01b600052602160045260246000fd5b146139875781604051806020016040528060008152509550955050505050612aca565b604080516020810190915290815260009890975095505050505050565b600554604080516312ab2eaf60e21b815290516000926001600160a01b031691634aacbabc916004808301926020929190829003018186803b1580156139e957600080fd5b505afa1580156139fd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a2191906150e3565b90506001600160a01b03811615801590613ab257506040516301fd3f7760e71b81526001600160a01b0382169063fe9fbb8090613a629030906004016152ee565b60206040518083038186803b158015613a7a57600080fd5b505afa158015613a8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ab2919061529e565b1561202157604051639eba1f6760e01b81526001600160a01b03821690639eba1f6790613ae990309088908890889060040161537a565b600060405180830381600087803b158015613b0357600080fd5b505af1158015611998573d6000803e3d6000fd5b805160009061079590670de0b6b3a7640000906154a5565b6000821580613b3c575081155b613b885760405162461bcd60e51b815260206004820152601e60248201527f746f6b656e73496e206f7220616d6f756e74496e206d757374206265203000006044820152606401610804565b613bc96040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b613bd161236c565b6040830181905260208301826003811115613bfc57634e487b7160e01b600052602160045260246000fd5b6003811115613c1b57634e487b7160e01b600052602160045260246000fd5b9052506000905081602001516003811115613c4657634e487b7160e01b600052602160045260246000fd5b14613c7e57613c766009602b8360200151600381111561126157634e487b7160e01b600052602160045260246000fd5b915050610f2c565b8315613d98576001600160a01b0385166000908152600e60205260409020548410613cc6576001600160a01b0385166000908152600e60205260409020546060820152613cce565b606081018490525b613cee604051806020016040528083604001518152508260600151612ad1565b6080830181905260208301826003811115613d1957634e487b7160e01b600052602160045260246000fd5b6003811115613d3857634e487b7160e01b600052602160045260246000fd5b9052506000905081602001516003811115613d6357634e487b7160e01b600052602160045260246000fd5b14613d9357613c76600960298360200151600381111561126157634e487b7160e01b600052602160045260246000fd5b613ea6565b600019831415613ddf576001600160a01b0385166000908152600e60209081526040918290205460608401908152825191820183529183015181529051613cee9190612ad1565b6080810183905260408051602081018252908201518152613e01908490613299565b6060830181905260208301826003811115613e2c57634e487b7160e01b600052602160045260246000fd5b6003811115613e4b57634e487b7160e01b600052602160045260246000fd5b9052506000905081602001516003811115613e7657634e487b7160e01b600052602160045260246000fd5b14613ea657613c766009602a8360200151600381111561126157634e487b7160e01b600052602160045260246000fd5b600554606082015160405163eabe7d9160e01b81526000926001600160a01b03169163eabe7d9191613edf9130918b9190600401615356565b602060405180830381600087803b158015613ef957600080fd5b505af1158015613f0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f3191906152d6565b90508015613f4f57613f466003602883612cb3565b92505050610f2c565b4260095414613f6457613f46600a602c61290d565b613f74600d548360600151612ee1565b60a0840181905260208401826003811115613f9f57634e487b7160e01b600052602160045260246000fd5b6003811115613fbe57634e487b7160e01b600052602160045260246000fd5b9052506000905082602001516003811115613fe957634e487b7160e01b600052602160045260246000fd5b1461401957613f466009602e8460200151600381111561126157634e487b7160e01b600052602160045260246000fd5b6001600160a01b0386166000908152600e60205260409020546060830151111561405c576001600160a01b0386166000908152600e602052604090205460608301525b6001600160a01b0386166000908152600e602052604090205460608301516140849190612ee1565b60c08401819052602084018260038111156140af57634e487b7160e01b600052602160045260246000fd5b60038111156140ce57634e487b7160e01b600052602160045260246000fd5b90525060009050826020015160038111156140f957634e487b7160e01b600052602160045260246000fd5b1461412957613f466009602d8460200151600381111561126157634e487b7160e01b600052602160045260246000fd5b8160800151614136612b31565b101561414857613f46600e602f61290d565b6001600160a01b0386166000908152600e602052604090205460c08301516141719188916139a4565b60a0820151600d5560c08201516001600160a01b0387166000818152600e60205260409081902092909255606084015191513092600080516020615592833981519152916141c191815260200190565b60405180910390a3608082015160608301516040517fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a92992614203928a92615335565b60405180910390a1600554608083015160608401516040516351dff98960e01b81526001600160a01b03909316926351dff989926142499230928c92919060040161537a565b600060405180830381600087803b15801561426357600080fd5b505af1158015614277573d6000803e3d6000fd5b50505050614289868360800151614eb7565b60009695505050505050565b600080836142a857506000905080612aca565b838302838582816142c957634e487b7160e01b600052601260045260246000fd5b04146142dd57600260009250925050612aca565b600092509050612aca565b600080826142fc5750600190506000612aca565b600083858161431b57634e487b7160e01b600052601260045260246000fd5b04915091509250929050565b600554604051634ef4c3e160e01b8152600091829182916001600160a01b031690634ef4c3e19061436090309089908990600401615356565b602060405180830381600087803b15801561437a57600080fd5b505af115801561438e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143b291906152d6565b905080156143d3576143c76003601f83612cb3565b60009250925050612aca565b5042600954146143f4576143e9600a602261290d565b600091509150612aca565b6040805180820190915260008082526020820152600061441261236c565b8360200181935082600381111561443957634e487b7160e01b600052602160045260246000fd5b600381111561445857634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561448357634e487b7160e01b600052602160045260246000fd5b146144b357612a6c600960218460200151600381111561126157634e487b7160e01b600052602160045260246000fd5b60006144bf8787614b2c565b905060006144db82604051806020016040528086815250613299565b8560200181935082600381111561450257634e487b7160e01b600052602160045260246000fd5b600381111561452157634e487b7160e01b600052602160045260246000fd5b905250600090508460200151600381111561454c57634e487b7160e01b600052602160045260246000fd5b146145995760405162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c45446044820152606401610804565b60006145a7600d5483612f80565b866020018193508260038111156145ce57634e487b7160e01b600052602160045260246000fd5b60038111156145ed57634e487b7160e01b600052602160045260246000fd5b905250600090508560200151600381111561461857634e487b7160e01b600052602160045260246000fd5b146146645760405162461bcd60e51b815260206004820152601c60248201527b1352539517d39155d7d513d5105317d4d55414131657d1905253115160221b6044820152606401610804565b6001600160a01b0389166000908152600e60205260408120546146879084612f80565b876020018193508260038111156146ae57634e487b7160e01b600052602160045260246000fd5b60038111156146cd57634e487b7160e01b600052602160045260246000fd5b90525060009050866020015160038111156146f857634e487b7160e01b600052602160045260246000fd5b146147455760405162461bcd60e51b815260206004820152601f60248201527f4d494e545f4e45575f4143434f554e545f42414c414e43455f4641494c4544006044820152606401610804565b6001600160a01b038a166000908152600e602052604090205461476a908b90836139a4565b600d8290556001600160a01b038a166000908152600e602052604090819020829055517f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f906147be908c9087908790615335565b60405180910390a16040518381526001600160a01b038b16906000906000805160206155928339815191529060200160405180910390a360009a93995092975050505050505050565b60055460405163368f515360e21b815260009182916001600160a01b039091169063da3d454c9061484090309088908890600401615356565b602060405180830381600087803b15801561485a57600080fd5b505af115801561486e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061489291906152d6565b905080156148af576148a76003600e83612cb3565b915050610795565b5042600954146148cb576148c4600a8061290d565b9050610795565b816148d4612b31565b10156148e6576148c4600e600961290d565b6000806148f285612d99565b9092509050600082600381111561491957634e487b7160e01b600052602160045260246000fd5b1461494e576149456009600784600381111561126157634e487b7160e01b600052602160045260246000fd5b92505050610795565b80600061495b8287612f80565b9094509050600084600381111561498257634e487b7160e01b600052602160045260246000fd5b146149b9576149ae6009600c86600381111561126157634e487b7160e01b600052602160045260246000fd5b945050505050610795565b60006149c7600b5488612f80565b909550905060008560038111156149ee57634e487b7160e01b600052602160045260246000fd5b14614a2657614a1a6009600b87600381111561126157634e487b7160e01b600052602160045260246000fd5b95505050505050610795565b6001600160a01b038816600081815260106020908152604091829020858155600a54600190910155600b849055815192835282018990528101839052606081018290527f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809060800160405180910390a1614aa1888484614d72565b614aab8888614eb7565b600098975050505050505050565b6000614ac3614f95565b600080614ad8670de0b6b3a764000087614295565b90925090506000826003811115614aff57634e487b7160e01b600052602160045260246000fd5b14614b1e57506040805160208101909152600081529092509050612aca565b612b248186600001516138cb565b6012546040516370a0823160e01b81526000916001600160a01b031690829082906370a0823190614b619030906004016152ee565b60206040518083038186803b158015614b7957600080fd5b505afa158015614b8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614bb191906152d6565b6040516323b872dd60e01b81529091506001600160a01b038316906323b872dd90614be490889030908990600401615356565b600060405180830381600087803b158015614bfe57600080fd5b505af1158015614c12573d6000803e3d6000fd5b5050505060003d60008114614c2e5760208114614c3857600080fd5b6000199150614c44565b60206000803e60005191505b5080614c8d5760405162461bcd60e51b81526020600482015260186024820152771513d2d15397d514905394d1915497d25397d1905253115160421b6044820152606401610804565b6012546040516370a0823160e01b81526000916001600160a01b0316906370a0823190614cbe9030906004016152ee565b60206040518083038186803b158015614cd657600080fd5b505afa158015614cea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d0e91906152d6565b905082811015614d5d5760405162461bcd60e51b815260206004820152601a602482015279544f4b454e5f5452414e534645525f494e5f4f564552464c4f5760301b6044820152606401610804565b614d6783826154c5565b979650505050505050565b600554604080516312ab2eaf60e21b815290516000926001600160a01b031691634aacbabc916004808301926020929190829003018186803b158015614db757600080fd5b505afa158015614dcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614def91906150e3565b90506001600160a01b03811615801590614e8057506040516301fd3f7760e71b81526001600160a01b0382169063fe9fbb8090614e309030906004016152ee565b60206040518083038186803b158015614e4857600080fd5b505afa158015614e5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e80919061529e565b1561202157604051630578982360e01b81526001600160a01b03821690630578982390613ae990309088908890889060040161537a565b60125460405163a9059cbb60e01b81526001600160a01b0390911690819063a9059cbb90614eeb908690869060040161531c565b600060405180830381600087803b158015614f0557600080fd5b505af1158015614f19573d6000803e3d6000fd5b5050505060003d60008114614f355760208114614f3f57600080fd5b6000199150614f4b565b60206000803e60005191505b50806120215760405162461bcd60e51b81526020600482015260196024820152781513d2d15397d514905394d1915497d3d55517d19052531151603a1b6044820152606401610804565b6040518060200160405280600081525090565b828054614fb4906154e8565b90600052602060002090601f016020900481019282614fd6576000855561501c565b82601f10614fef57805160ff191683800117855561501c565b8280016001018555821561501c579182015b8281111561501c578251825591602001919060010190615001565b5061502892915061502c565b5090565b5b80821115615028576000815560010161502d565b600082601f830112615051578081fd5b81356001600160401b038082111561506b5761506b615523565b604051601f8301601f19908116603f0116810190828211818310171561509357615093615523565b816040528381528660208588010111156150ab578485fd5b8360208701602083013792830160200193909352509392505050565b6000602082840312156150d8578081fd5b8135610f2c81615539565b6000602082840312156150f4578081fd5b8151610f2c81615539565b60008060408385031215615111578081fd5b823561511c81615539565b9150602083013561512c81615539565b809150509250929050565b60008060006060848603121561514b578081fd5b833561515681615539565b9250602084013561516681615539565b929592945050506040919091013590565b600080600080600080600060e0888a031215615191578283fd5b873561519c81615539565b965060208801356151ac81615539565b955060408801356151bc81615539565b94506060880135935060808801356001600160401b03808211156151de578485fd5b6151ea8b838c01615041565b945060a08a01359150808211156151ff578384fd5b5061520c8a828b01615041565b92505060c088013560ff81168114615222578182fd5b8091505092959891949750929550565b60008060408385031215615244578182fd5b823561524f81615539565b946020939093013593505050565b600080600060608486031215615271578283fd5b833561527c81615539565b925060208401359150604084013561529381615539565b809150509250925092565b6000602082840312156152af578081fd5b81518015158114610f2c578182fd5b6000602082840312156152cf578081fd5b5035919050565b6000602082840312156152e7578081fd5b5051919050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039390931683526020830191909152604082015260600190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260800190565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b6000602080835283518082850152825b818110156153f9578581018301518582016040015282016153dd565b8181111561540a5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252601690820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604082015260600190565b6020808252600a90820152691c994b595b9d195c995960b21b604082015260600190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b6000826154c057634e487b7160e01b81526012600452602481fd5b500490565b6000828210156154e357634e487b7160e01b81526011600452602481fd5b500390565b600181811c908216806154fc57607f821691505b6020821081141561551d57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461554e57600080fd5b5056fe45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0ca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3eff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dca2646970667358221220bd0664edec2fa39d2968989abe384db02d56c858558437b2ad9377730216797e64736f6c63430008040033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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