APE Price: $1.17 (+8.53%)

Contract

0xB1974B31b60C7134978e5574F5f1fC8A16535b5D

Overview

APE Balance

Apechain LogoApechain LogoApechain Logo12,559.651312809922153022 APE

APE Value

$14,719.73 (@ $1.17/APE)

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Mint49035532024-11-21 17:29:3734 mins ago1732210177IN
0xB1974B31...A16535b5D
0.95 APE0.0041229525.42069
Mint48896972024-11-21 15:06:592 hrs ago1732201619IN
0xB1974B31...A16535b5D
100.72948484 APE0.0036882625.42069
Mint48738352024-11-21 11:27:486 hrs ago1732188468IN
0xB1974B31...A16535b5D
1 APE0.0044831125.42069
Mint48700542024-11-21 10:37:427 hrs ago1732185462IN
0xB1974B31...A16535b5D
1 APE0.0044831125.42069
Mint48431522024-11-21 3:39:0214 hrs ago1732160342IN
0xB1974B31...A16535b5D
1 APE0.0044831125.42069
Mint48389592024-11-21 2:35:2815 hrs ago1732156528IN
0xB1974B31...A16535b5D
2.51075223 APE0.0041229525.42069
Mint48378712024-11-21 2:18:5515 hrs ago1732155535IN
0xB1974B31...A16535b5D
127.64602026 APE0.0036882325.42069
Mint48074222024-11-20 19:25:1722 hrs ago1732130717IN
0xB1974B31...A16535b5D
5 APE0.0044830925.42069
Redeem Underlyin...48053662024-11-20 19:00:1723 hrs ago1732129217IN
0xB1974B31...A16535b5D
0 APE0.0073038925.42069
Mint48051722024-11-20 18:58:4523 hrs ago1732129125IN
0xB1974B31...A16535b5D
41.9175851 APE0.0036882625.42069
Redeem Underlyin...48051652024-11-20 18:58:4123 hrs ago1732129121IN
0xB1974B31...A16535b5D
0 APE0.0073038925.42069
Redeem Underlyin...48051022024-11-20 18:58:0523 hrs ago1732129085IN
0xB1974B31...A16535b5D
0 APE0.005754625.42069
Mint48036552024-11-20 18:47:5023 hrs ago1732128470IN
0xB1974B31...A16535b5D
120.0751589 APE0.0036882625.42069
Mint47746002024-11-20 14:58:1727 hrs ago1732114697IN
0xB1974B31...A16535b5D
80 APE0.0036882825.42069
Mint47631052024-11-20 12:46:2829 hrs ago1732106788IN
0xB1974B31...A16535b5D
430.57062264 APE0.0041229525.42069
Mint47531082024-11-20 9:45:1232 hrs ago1732095912IN
0xB1974B31...A16535b5D
1 APE0.0036882625.42069
Mint47529652024-11-20 9:42:1532 hrs ago1732095735IN
0xB1974B31...A16535b5D
1 APE0.0041229525.42069
Redeem47501192024-11-20 8:44:2433 hrs ago1732092264IN
0xB1974B31...A16535b5D
0 APE0.0041666225.42069
Mint47440312024-11-20 6:48:5635 hrs ago1732085336IN
0xB1974B31...A16535b5D
315.55802817 APE0.0036882325.42069
Mint47333292024-11-20 3:37:3938 hrs ago1732073859IN
0xB1974B31...A16535b5D
24 APE0.0036882325.42069
Mint47331732024-11-20 3:34:3838 hrs ago1732073678IN
0xB1974B31...A16535b5D
45 APE0.0041229325.42069
Mint47328322024-11-20 3:27:5138 hrs ago1732073271IN
0xB1974B31...A16535b5D
100 APE0.0044830925.42069
Mint47312602024-11-20 3:00:2739 hrs ago1732071627IN
0xB1974B31...A16535b5D
1.2 APE0.0041229525.42069
Redeem Underlyin...47287112024-11-20 2:11:2239 hrs ago1732068682IN
0xB1974B31...A16535b5D
0 APE0.0073038925.42069
Repay Borrow47286832024-11-20 2:10:5739 hrs ago1732068657IN
0xB1974B31...A16535b5D
100.00003952 APE0.003686125.42069
View all transactions

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To
48053662024-11-20 19:00:1723 hrs ago1732129217
0xB1974B31...A16535b5D
60.00011524 APE
48051652024-11-20 18:58:4123 hrs ago1732129121
0xB1974B31...A16535b5D
20.00039736 APE
47501192024-11-20 8:44:2433 hrs ago1732092264
0xB1974B31...A16535b5D
68.0500113 APE
47287112024-11-20 2:11:2239 hrs ago1732068682
0xB1974B31...A16535b5D
200.00008353 APE
47286592024-11-20 2:10:3039 hrs ago1732068630
0xB1974B31...A16535b5D
480.00008249 APE
47282462024-11-20 2:04:3240 hrs ago1732068272
0xB1974B31...A16535b5D
100 APE
47280702024-11-20 2:02:1340 hrs ago1732068133
0xB1974B31...A16535b5D
500.00008546 APE
47162262024-11-19 22:31:5543 hrs ago1732055515
0xB1974B31...A16535b5D
475.58716006 APE
46587952024-11-19 12:15:242 days ago1732018524
0xB1974B31...A16535b5D
0.9987553 APE
46587542024-11-19 12:14:422 days ago1732018482
0xB1974B31...A16535b5D
99.87519738 APE
46537252024-11-19 10:40:102 days ago1732012810
0xB1974B31...A16535b5D
100.00000261 APE
46536792024-11-19 10:39:152 days ago1732012755
0xB1974B31...A16535b5D
49.99999999 APE
45660882024-11-18 9:02:373 days ago1731920557
0xB1974B31...A16535b5D
276.57770016 APE
45659672024-11-18 9:00:093 days ago1731920409
0xB1974B31...A16535b5D
651.55886642 APE
45286962024-11-17 21:44:283 days ago1731879868
0xB1974B31...A16535b5D
40.35698408 APE
45285792024-11-17 21:42:203 days ago1731879740
0xB1974B31...A16535b5D
18.55209603 APE
45285282024-11-17 21:41:163 days ago1731879676
0xB1974B31...A16535b5D
40.35684506 APE
45283632024-11-17 21:38:373 days ago1731879517
0xB1974B31...A16535b5D
18.55153782 APE
45283112024-11-17 21:37:563 days ago1731879476
0xB1974B31...A16535b5D
41.14573887 APE
45281412024-11-17 21:35:453 days ago1731879345
0xB1974B31...A16535b5D
19.28973824 APE
45280822024-11-17 21:35:083 days ago1731879308
0xB1974B31...A16535b5D
40.92041102 APE
45278982024-11-17 21:32:553 days ago1731879175
0xB1974B31...A16535b5D
19.50720192 APE
45278382024-11-17 21:32:113 days ago1731879131
0xB1974B31...A16535b5D
38.36289327 APE
45276602024-11-17 21:30:053 days ago1731879005
0xB1974B31...A16535b5D
18.57854927 APE
45276042024-11-17 21:29:093 days ago1731878949
0xB1974B31...A16535b5D
49.47318454 APE
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MEther

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 11 : MEther.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.19;

import "./MToken.sol";

/**
 * @title Compound's CEther Contract
 * @notice MToken which wraps Ether
 * @author Compound
 */
contract MEther is MToken {
    address public underlying = address(0);

    /**
     * @notice Construct a new CEther 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_ ERC-20 name of this token
     * @param symbol_ ERC-20 symbol of this token
     * @param decimals_ ERC-20 decimal precision of this token
     * @param admin_ Address of the administrator of this token
     */
    constructor(
        ComptrollerInterface comptroller_,
        InterestRateModel interestRateModel_,
        uint256 initialExchangeRateMantissa_,
        string memory name_,
        string memory symbol_,
        uint8 decimals_,
        address payable admin_
    ) {
        // Creator of the contract is admin during initialization
        admin = payable(msg.sender);

        initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_);

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

    /**
     * User Interface **
     */

    /**
     * @notice Sender supplies assets into the market and receives cTokens in exchange
     * @dev Reverts upon any failure
     */
    function mint() external payable {
        mintInternal(msg.value);
    }

    /**
     * @notice Sender redeems cTokens in exchange for the underlying asset
     * @dev Accrues interest whether or not the operation succeeds, unless reverted
     * @param redeemTokens The number of cTokens to redeem into underlying
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function redeem(uint256 redeemTokens) external returns (Error) {
        redeemInternal(redeemTokens);
        return Error.NO_ERROR;
    }

    /**
     * @notice Sender redeems cTokens 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
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function redeemUnderlying(uint256 redeemAmount) external returns (Error) {
        redeemUnderlyingInternal(redeemAmount);
        return 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 borrow(uint256 borrowAmount) external returns (Error) {
        borrowInternal(borrowAmount);
        return Error.NO_ERROR;
    }

    /**
     * @notice Sender repays their own borrow
     * @dev Reverts upon any failure
     */
    function repayBorrow() external payable {
        repayBorrowInternal(msg.value);
    }

    /// @notice Indicator that this is a ETH Derivative
    function isEthDerivative() public view virtual returns (bool) {
        return true;
    }

    /**
     * @notice Sender repays a borrow belonging to borrower
     * @dev Reverts upon any failure
     * @param borrower the account with the debt being payed off
     */
    function repayBorrowBehalf(address borrower) external payable {
        repayBorrowBehalfInternal(borrower, msg.value);
    }

    /**
     * @notice The sender liquidates the borrowers collateral.
     *  The collateral seized is transferred to the liquidator.
     * @dev Reverts upon any failure
     * @param borrower The borrower of this MToken to be liquidated
     * @param rfTokenCollateral The market in which to seize collateral from the borrower
     */
    function liquidateBorrow(address borrower, MToken rfTokenCollateral) external payable {
        liquidateBorrowInternal(borrower, msg.value, rfTokenCollateral);
    }

    /**
     * @notice The sender adds to reserves.
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function _addReserves() external payable returns (uint256) {
        return _addReservesInternal(msg.value);
    }

    /**
     * @notice Send Ether to CEther to mint
     */
    receive() external payable {
        mintInternal(msg.value);
    }

    /**
     * Safe Token **
     */

    /**
     * @notice Gets balance of this contract in terms of Ether, before this message
     * @dev This excludes the value of the current message, if any
     * @return The quantity of Ether owned by this contract
     */
    function getCashPrior() internal view override returns (uint256) {
        return address(this).balance - msg.value;
    }

    /**
     * @notice A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to admin (timelock)
     */
    // function sweepToken() external {
    //     require(msg.sender == admin, "MEther::sweepToken: only admin can sweep tokens");

    //     uint256 balance = address(this).balance;
    //     require(balance > 0, "No ether left to send");

    //     (bool sent,) = payable(admin).call{value: balance}("");

    //     require(sent, "Failed to send Ether");
    // }

    /**
     * @notice Perform the actual transfer in, which is a no-op
     * @param from Address sending the Ether
     * @param amount Amount of Ether being sent
     * @return The actual amount of Ether transferred
     */
    function doTransferIn(address from, uint256 amount) internal override returns (uint256) {
        // Sanity checks
        require(msg.sender == from, "sender mismatch");
        require(msg.value == amount, "value mismatch");
        return amount;
    }

    function doTransferOut(address payable to, uint256 amount) internal virtual override {
        /* Send the Ether, with minimal gas and revert on failure */
        to.transfer(amount);
    }
}

File 2 of 11 : CarefulMath.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.19;

/**
 * @title Careful Math
 * @author Moonwell
 * @notice Derived from OpenZeppelin's SafeMath library
 *         https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol
 */
contract CarefulMath {
    /**
     * @dev Possible error codes that we can return
     */
    enum MathError {
        NO_ERROR,
        DIVISION_BY_ZERO,
        INTEGER_OVERFLOW,
        INTEGER_UNDERFLOW
    }

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

        uint c = a * b;

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

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

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

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

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

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

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

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

        return subUInt(sum, c);
    }
}

File 3 of 11 : ComptrollerInterface.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.19;

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

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

    function enterMarkets(
        address[] calldata mTokens
    ) external virtual returns (uint[] memory);
    function exitMarket(address mToken) external virtual returns (uint);

    /*** Policy Hooks ***/

    function mintAllowed(
        address mToken,
        address minter,
        uint mintAmount
    ) external virtual returns (uint);

    function redeemAllowed(
        address mToken,
        address redeemer,
        uint redeemTokens
    ) external virtual returns (uint);

    // Do not remove, still used by MToken
    function redeemVerify(
        address mToken,
        address redeemer,
        uint redeemAmount,
        uint redeemTokens
    ) external pure virtual;

    function borrowAllowed(
        address mToken,
        address borrower,
        uint borrowAmount
    ) external virtual returns (uint);

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

    function liquidateBorrowAllowed(
        address mTokenBorrowed,
        address mTokenCollateral,
        address liquidator,
        address borrower,
        uint repayAmount
    ) external view virtual returns (uint);

    function seizeAllowed(
        address mTokenCollateral,
        address mTokenBorrowed,
        address liquidator,
        address borrower,
        uint seizeTokens
    ) external virtual returns (uint);

    function transferAllowed(
        address mToken,
        address src,
        address dst,
        uint transferTokens
    ) external virtual returns (uint);

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

    function liquidateCalculateSeizeTokens(
        address mTokenBorrowed,
        address mTokenCollateral,
        uint repayAmount
    ) external view virtual returns (uint, uint);
}

// The hooks that were patched out of the comptroller to make room for the supply caps, if we need them
abstract contract ComptrollerInterfaceWithAllVerificationHooks is
    ComptrollerInterface
{
    function mintVerify(
        address mToken,
        address minter,
        uint mintAmount,
        uint mintTokens
    ) external virtual;

    // Included in ComptrollerInterface already
    // function redeemVerify(address mToken, address redeemer, uint redeemAmount, uint redeemTokens) virtual external;

    function borrowVerify(
        address mToken,
        address borrower,
        uint borrowAmount
    ) external virtual;

    function repayBorrowVerify(
        address mToken,
        address payer,
        address borrower,
        uint repayAmount,
        uint borrowerIndex
    ) external virtual;

    function liquidateBorrowVerify(
        address mTokenBorrowed,
        address mTokenCollateral,
        address liquidator,
        address borrower,
        uint repayAmount,
        uint seizeTokens
    ) external virtual;

    function seizeVerify(
        address mTokenCollateral,
        address mTokenBorrowed,
        address liquidator,
        address borrower,
        uint seizeTokens
    ) external virtual;

    function transferVerify(
        address mToken,
        address src,
        address dst,
        uint transferTokens
    ) external virtual;
}

File 4 of 11 : EIP20Interface.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.19;

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

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

    /**
     * @notice Gets the balance of the specified address
     * @param owner The address from which the balance will be retrieved
     * @return 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 5 of 11 : EIP20NonStandardInterface.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.19;

/**
 * @title EIP20NonStandardInterface
 * @dev Version of ERC20 with no return values for `transfer` and `transferFrom`
 *  See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca
 */
interface EIP20NonStandardInterface {
    /**
     * @notice Get the total number of tokens in circulation
     * @return The supply of tokens
     */
    function totalSupply() external view returns (uint256);

    /**
     * @notice Gets the balance of the specified address
     * @param owner The address from which the balance will be retrieved
     * @return 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 6 of 11 : ErrorReporter.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.19;

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,
        SET_GAS_AMOUNT_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 11 : Exponential.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.19;

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

/**
 * @title Exponential module for storing fixed-precision decimals
 * @author Moonwell
 * @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
    ) internal pure 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
    ) internal pure 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
    ) internal pure 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
    ) internal pure 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
    ) internal pure 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
    ) internal pure 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
    ) internal pure 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
    ) internal pure 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
    ) internal pure 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
    ) internal pure 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
    ) internal pure 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
    ) internal pure 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
    ) internal pure returns (MathError, Exp memory) {
        return getExp(a.mantissa, b.mantissa);
    }
}

File 8 of 11 : ExponentialNoError.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.19;

/**
 * @title Exponential module for storing fixed-precision decimals
 * @author Moonwell
 * @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) internal pure 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
    ) internal pure returns (uint) {
        Exp memory product = mul_(a, scalar);
        return truncate(product);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 9 of 11 : InterestRateModel.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.19;

/**
 * @title Moonwell's InterestRateModel Interface
 * @author Moonwell
 */
abstract contract InterestRateModel {
    /// @notice Indicator that this is an InterestRateModel contract (for inspection)
    bool public constant isInterestRateModel = true;

    /**
     * @notice Calculates the current borrow interest rate per timestamp
     * @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 timestamp (as a percentage, and scaled by 1e18)
     */
    function getBorrowRate(
        uint cash,
        uint borrows,
        uint reserves
    ) external view virtual returns (uint);

    /**
     * @notice Calculates the current supply interest rate per timestamp
     * @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 timestamp (as a percentage, and scaled by 1e18)
     */
    function getSupplyRate(
        uint cash,
        uint borrows,
        uint reserves,
        uint reserveFactorMantissa
    ) external view virtual returns (uint);
}

File 10 of 11 : MToken.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.19;

import "./ComptrollerInterface.sol";
import "./MTokenInterfaces.sol";
import "./ErrorReporter.sol";
import "./Exponential.sol";
import "./EIP20Interface.sol";
import "./InterestRateModel.sol";

/**
 * @title Moonwell's MToken Contract
 * @notice Abstract base for MTokens
 * @author Moonwell
 */
abstract contract MToken is MTokenInterface, 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(
        ComptrollerInterface comptroller_,
        InterestRateModel interestRateModel_,
        uint initialExchangeRateMantissa_,
        string memory name_,
        string memory symbol_,
        uint8 decimals_
    ) public {
        require(msg.sender == admin, "only admin may initialize the market");
        require(
            accrualBlockTimestamp == 0 && borrowIndex == 0,
            "market may only be initialized once"
        );

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

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

        // 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)
        err = _setInterestRateModelFresh(interestRateModel_);
        require(
            err == uint(Error.NO_ERROR),
            "setting 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;
    }

    /**
     * @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,
        uint tokens
    ) internal returns (uint) {
        /* Fail if transfer not allowed */
        uint allowed = comptroller.transferAllowed(
            address(this),
            src,
            dst,
            tokens
        );
        if (allowed != 0) {
            return
                failOpaque(
                    Error.COMPTROLLER_REJECTION,
                    FailureInfo.TRANSFER_COMPTROLLER_REJECTION,
                    allowed
                );
        }

        /* Do not allow self-transfers */
        if (src == dst) {
            return fail(Error.BAD_INPUT, FailureInfo.TRANSFER_NOT_ALLOWED);
        }

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

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

        (mathErr, allowanceNew) = subUInt(startingAllowance, tokens);
        if (mathErr != MathError.NO_ERROR) {
            return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ALLOWED);
        }

        (mathErr, srcTokensNew) = subUInt(accountTokens[src], tokens);
        if (mathErr != MathError.NO_ERROR) {
            return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ENOUGH);
        }

        (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens);
        if (mathErr != MathError.NO_ERROR) {
            return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_TOO_MUCH);
        }

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

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

        /* Eat some of the allowance (if necessary) */
        if (startingAllowance != type(uint).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 uint(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) ==
            uint(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) ==
            uint(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 (uint.max 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 (uint.max 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 (uint) {
        Exp memory exchangeRate = Exp({mantissa: exchangeRateCurrent()});
        (MathError mErr, uint balance) = mulScalarTruncate(
            exchangeRate,
            accountTokens[owner]
        );
        require(mErr == MathError.NO_ERROR, "balance could not be calculated");
        return balance;
    }

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

        MathError mErr;

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

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

        return (
            uint(Error.NO_ERROR),
            mTokenBalance,
            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 (uint) {
        return block.timestamp;
    }

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

    /**
     * @notice Returns the current per-timestamp supply interest rate for this mToken
     * @return The supply interest rate per timestamp, scaled by 1e18
     */
    function supplyRatePerTimestamp() external view override returns (uint) {
        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 (uint)
    {
        require(
            accrueInterest() == uint(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 (uint) {
        require(
            accrueInterest() == uint(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 (uint) {
        (MathError err, uint result) = borrowBalanceStoredInternal(account);
        require(
            err == MathError.NO_ERROR,
            "borrowBalanceStored: borrowBalanceStoredInternal 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, uint) {
        /* Note: we do not assert that the market is up to date */
        MathError mathErr;
        uint principalTimesIndex;
        uint 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 (uint) {
        require(
            accrueInterest() == uint(Error.NO_ERROR),
            "accrue interest failed"
        );
        return exchangeRateStored();
    }

    /**
     * @notice Calculates the exchange rate from the underlying to the MToken
     * @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 (uint) {
        (MathError err, uint result) = exchangeRateStoredInternal();
        require(
            err == MathError.NO_ERROR,
            "exchangeRateStored: exchangeRateStoredInternal failed"
        );
        return result;
    }

    /**
     * @notice Calculates the exchange rate from the underlying to the MToken
     * @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, uint)
    {
        uint _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
             */
            uint totalCash = getCashPrior();
            uint 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 mToken in the underlying asset
     * @return The quantity of underlying asset owned by this contract
     */
    function getCash() external view override returns (uint) {
        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 virtual override returns (uint) {
        /* Remember the initial block timestamp */
        uint currentBlockTimestamp = getBlockTimestamp();
        uint accrualBlockTimestampPrior = accrualBlockTimestamp;

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

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

        /* Calculate the current borrow interest rate */
        uint 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, uint 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;
        uint interestAccumulated;
        uint totalBorrowsNew;
        uint totalReservesNew;
        uint 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,
                    uint(mathErr)
                );
        }

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

        (mathErr, totalBorrowsNew) = addUInt(interestAccumulated, borrowsPrior);
        if (mathErr != MathError.NO_ERROR) {
            return
                failOpaque(
                    Error.MATH_ERROR,
                    FailureInfo
                        .ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED,
                    uint(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,
                    uint(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,
                    uint(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 uint(Error.NO_ERROR);
    }

    /**
     * @notice Sender supplies assets into the market and receives mTokens 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(
        uint mintAmount
    ) internal nonReentrant returns (uint, uint) {
        uint error = accrueInterest();
        if (error != uint(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed
            return (
                fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED),
                0
            );
        }
        // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to
        return mintFresh(msg.sender, mintAmount);
    }

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

    /**
     * @notice User supplies assets into the market and receives mTokens 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,
        uint mintAmount
    ) internal returns (uint, uint) {
        /* Fail if mint not allowed */
        uint allowed = comptroller.mintAllowed(
            address(this),
            minter,
            mintAmount
        );
        if (allowed != 0) {
            return (
                failOpaque(
                    Error.COMPTROLLER_REJECTION,
                    FailureInfo.MINT_COMPTROLLER_REJECTION,
                    allowed
                ),
                0
            );
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @notice Sender redeems mTokens 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 mTokens
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function redeemUnderlyingInternal(
        uint redeemAmount
    ) internal nonReentrant returns (uint) {
        uint error = accrueInterest();
        if (error != uint(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed
            return
                fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED);
        }
        // redeemFresh emits redeem-specific logs on errors, so we don't need to
        return redeemFresh(payable(msg.sender), 0, redeemAmount);
    }

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

    /**
     * @notice User redeems mTokens 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 mTokens 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 mTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero)
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function redeemFresh(
        address payable redeemer,
        uint redeemTokensIn,
        uint redeemAmountIn
    ) internal returns (uint) {
        require(
            redeemTokensIn == 0 || redeemAmountIn == 0,
            "one of redeemTokensIn or redeemAmountIn must be zero"
        );

        RedeemLocalVars memory vars;

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

        /* If redeemTokensIn > 0: */
        if (redeemTokensIn > 0) {
            /*
             * We calculate the exchange rate and the amount of underlying to be redeemed:
             *  redeemTokens = redeemTokensIn
             *  redeemAmount = redeemTokensIn x exchangeRateCurrent
             */
            if (redeemTokensIn == type(uint).max) {
                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,
                        uint(vars.mathErr)
                    );
            }
        } else {
            /*
             * We get the current exchange rate and calculate the amount to be redeemed:
             *  redeemTokens = redeemAmountIn / exchangeRate
             *  redeemAmount = redeemAmountIn
             */
            if (redeemAmountIn == type(uint).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,
                            uint(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,
                            uint(vars.mathErr)
                        );
                }
            }
        }

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

        /* 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,
                    uint(vars.mathErr)
                );
        }

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

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

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

        /* We 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 mToken must handle variations between ERC-20 and GLMR underlying.
         *  On success, the mToken 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 uint(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(
        uint borrowAmount
    ) internal nonReentrant returns (uint) {
        uint error = accrueInterest();
        if (error != uint(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but we still want to log the fact that an attempted 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);
    }

    struct BorrowLocalVars {
        MathError mathErr;
        uint accountBorrows;
        uint accountBorrowsNew;
        uint totalBorrowsNew;
    }

    /**
     * @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,
        uint borrowAmount
    ) internal returns (uint) {
        /* Fail if borrow not allowed */
        uint 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
                );
        }

        BorrowLocalVars memory vars;

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

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

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

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

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

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

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

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

        return uint(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(
        uint repayAmount
    ) internal nonReentrant returns (uint, uint) {
        uint error = accrueInterest();
        if (error != uint(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed
            return (
                fail(
                    Error(error),
                    FailureInfo.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,
        uint repayAmount
    ) internal nonReentrant returns (uint, uint) {
        uint error = accrueInterest();
        if (error != uint(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed
            return (
                fail(
                    Error(error),
                    FailureInfo.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;
        uint repayAmount;
        uint borrowerIndex;
        uint accountBorrows;
        uint accountBorrowsNew;
        uint totalBorrowsNew;
        uint 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 underlying 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,
        uint repayAmount
    ) internal returns (uint, uint) {
        /* Fail if repayBorrow not allowed */
        uint 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;

        /* 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,
                    uint(vars.mathErr)
                ),
                0
            );
        }

        /* If repayAmount == uint.max, repayAmount = accountBorrows */
        if (repayAmount == type(uint).max) {
            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 mToken must handle variations between ERC-20 and GLMR underlying.
         *  On success, the mToken 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_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED"
        );

        (vars.mathErr, vars.totalBorrowsNew) = subUInt(
            totalBorrows,
            vars.actualRepayAmount
        );
        require(
            vars.mathErr == MathError.NO_ERROR,
            "REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_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
        );

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

        return (uint(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 mToken to be liquidated
     * @param mTokenCollateral 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,
        uint repayAmount,
        MTokenInterface mTokenCollateral
    ) internal nonReentrant returns (uint, uint) {
        uint error = accrueInterest();
        if (error != uint(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed
            return (
                fail(
                    Error(error),
                    FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED
                ),
                0
            );
        }

        error = mTokenCollateral.accrueInterest();
        if (error != uint(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,
                mTokenCollateral
            );
    }

    /**
     * @notice The liquidator liquidates the borrowers collateral.
     *  The collateral seized is transferred to the liquidator.
     * @param borrower The borrower of this mToken to be liquidated
     * @param liquidator The address repaying the borrow and seizing collateral
     * @param mTokenCollateral 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,
        uint repayAmount,
        MTokenInterface mTokenCollateral
    ) internal returns (uint, uint) {
        /* Fail if liquidate not allowed */
        uint allowed = comptroller.liquidateBorrowAllowed(
            address(this),
            address(mTokenCollateral),
            liquidator,
            borrower,
            repayAmount
        );
        if (allowed != 0) {
            return (
                failOpaque(
                    Error.COMPTROLLER_REJECTION,
                    FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION,
                    allowed
                ),
                0
            );
        }

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

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

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

        /* Fail if repayAmount = 0 */
        if (repayAmount == 0) {
            return (
                fail(
                    Error.INVALID_CLOSE_AMOUNT_REQUESTED,
                    FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO
                ),
                0
            );
        }

        /* Fail if repayAmount = uint.max */
        if (repayAmount == type(uint).max) {
            return (
                fail(
                    Error.INVALID_CLOSE_AMOUNT_REQUESTED,
                    FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX
                ),
                0
            );
        }

        /* Fail if repayBorrow fails */
        (uint repayBorrowError, uint actualRepayAmount) = repayBorrowFresh(
            liquidator,
            borrower,
            repayAmount
        );
        if (repayBorrowError != uint(Error.NO_ERROR)) {
            return (
                fail(
                    Error(repayBorrowError),
                    FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED
                ),
                0
            );
        }

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

        /* We calculate the number of collateral tokens that will be seized */
        (uint amountSeizeError, uint seizeTokens) = comptroller
            .liquidateCalculateSeizeTokens(
                address(this),
                address(mTokenCollateral),
                actualRepayAmount
            );
        require(
            amountSeizeError == uint(Error.NO_ERROR),
            "LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED"
        );

        /* Revert if borrower collateral token balance < seizeTokens */
        require(
            mTokenCollateral.balanceOf(borrower) >= seizeTokens,
            "LIQUIDATE_SEIZE_TOO_MUCH"
        );

        // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call
        uint seizeError;
        if (address(mTokenCollateral) == address(this)) {
            seizeError = seizeInternal(
                address(this),
                liquidator,
                borrower,
                seizeTokens
            );
        } else {
            seizeError = mTokenCollateral.seize(
                liquidator,
                borrower,
                seizeTokens
            );
        }

        /* Revert if seize tokens fails (since we cannot be sure of side effects) */
        require(seizeError == uint(Error.NO_ERROR), "token seizure failed");

        /* We emit a LiquidateBorrow event */
        emit LiquidateBorrow(
            liquidator,
            borrower,
            actualRepayAmount,
            address(mTokenCollateral),
            seizeTokens
        );

        /* We call the defense hook */
        // unused function
        // comptroller.liquidateBorrowVerify(address(this), address(mTokenCollateral), liquidator, borrower, actualRepayAmount, seizeTokens);

        return (uint(Error.NO_ERROR), actualRepayAmount);
    }

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

    struct SeizeInternalLocalVars {
        MathError mathErr;
        uint borrowerTokensNew;
        uint liquidatorTokensNew;
        uint liquidatorSeizeTokens;
        uint protocolSeizeTokens;
        uint protocolSeizeAmount;
        uint exchangeRateMantissa;
        uint totalReservesNew;
        uint 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 MToken.
     *  Its absolutely critical to use msg.sender as the seizer mToken and not a parameter.
     * @param seizerToken The contract seizing the collateral (i.e. borrowed mToken)
     * @param liquidator The account receiving seized collateral
     * @param borrower The account having collateral seized
     * @param seizeTokens The number of mTokens to seize
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function seizeInternal(
        address seizerToken,
        address liquidator,
        address borrower,
        uint seizeTokens
    ) internal returns (uint) {
        /* Fail if seize not allowed */
        uint allowed = comptroller.seizeAllowed(
            address(this),
            seizerToken,
            liquidator,
            borrower,
            seizeTokens
        );
        if (allowed != 0) {
            return
                failOpaque(
                    Error.COMPTROLLER_REJECTION,
                    FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION,
                    allowed
                );
        }

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

        SeizeInternalLocalVars memory vars;

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

        vars.protocolSeizeTokens = mul_(
            seizeTokens,
            Exp({mantissa: protocolSeizeShareMantissa})
        );
        vars.liquidatorSeizeTokens = sub_(
            seizeTokens,
            vars.protocolSeizeTokens
        );

        (
            vars.mathErr,
            vars.exchangeRateMantissa
        ) = exchangeRateStoredInternal();
        require(vars.mathErr == MathError.NO_ERROR, "exchange rate math error");

        vars.protocolSeizeAmount = mul_ScalarTruncate(
            Exp({mantissa: vars.exchangeRateMantissa}),
            vars.protocolSeizeTokens
        );

        vars.totalReservesNew = add_(totalReserves, vars.protocolSeizeAmount);
        vars.totalSupplyNew = sub_(totalSupply, vars.protocolSeizeTokens);

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

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

        /* We write the previously calculated values into storage */
        totalReserves = vars.totalReservesNew;
        totalSupply = vars.totalSupplyNew;
        accountTokens[borrower] = vars.borrowerTokensNew;
        accountTokens[liquidator] = vars.liquidatorTokensNew;

        /* Emit a Transfer event */
        emit Transfer(borrower, liquidator, vars.liquidatorSeizeTokens);
        emit Transfer(borrower, address(this), vars.protocolSeizeTokens);
        emit ReservesAdded(
            address(this),
            vars.protocolSeizeAmount,
            vars.totalReservesNew
        );

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

        return uint(Error.NO_ERROR);
    }

    /*** Admin Functions ***/

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

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

        // Store pendingAdmin with value newPendingAdmin
        pendingAdmin = newPendingAdmin;

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

        return uint(Error.NO_ERROR);
    }

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

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

        // Store admin with value pendingAdmin
        admin = pendingAdmin;

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

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

        return uint(Error.NO_ERROR);
    }

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

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

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

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

        return uint(Error.NO_ERROR);
    }

    /**
     * @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(
        uint newReserveFactorMantissa
    ) external override nonReentrant returns (uint) {
        uint error = accrueInterest();
        if (error != uint(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(
        uint newReserveFactorMantissa
    ) internal returns (uint) {
        // Check caller is admin
        if (msg.sender != admin) {
            return
                fail(
                    Error.UNAUTHORIZED,
                    FailureInfo.SET_RESERVE_FACTOR_ADMIN_CHECK
                );
        }

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

        // Check newReserveFactor �� maxReserveFactor
        if (newReserveFactorMantissa > reserveFactorMaxMantissa) {
            return
                fail(
                    Error.BAD_INPUT,
                    FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK
                );
        }

        uint oldReserveFactorMantissa = reserveFactorMantissa;
        reserveFactorMantissa = newReserveFactorMantissa;

        emit NewReserveFactor(
            oldReserveFactorMantissa,
            newReserveFactorMantissa
        );

        return uint(Error.NO_ERROR);
    }

    /**
     * @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(
        uint addAmount
    ) internal nonReentrant returns (uint) {
        uint error = accrueInterest();
        if (error != uint(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(uint addAmount) internal returns (uint, uint) {
        // totalReserves + actualAddAmount
        uint totalReservesNew;
        uint actualAddAmount;

        // We fail gracefully unless market's block timestamp equals current block timestamp
        if (accrualBlockTimestamp != getBlockTimestamp()) {
            return (
                fail(
                    Error.MARKET_NOT_FRESH,
                    FailureInfo.ADD_RESERVES_FRESH_CHECK
                ),
                actualAddAmount
            );
        }

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

        /*
         * We call doTransferIn for the caller and the addAmount
         *  Note: The mToken must handle variations between ERC-20 and GLMR underlying.
         *  On success, the mToken holds an additional addAmount 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.
         */

        actualAddAmount = doTransferIn(msg.sender, addAmount);

        totalReservesNew = totalReserves + actualAddAmount;

        /* Revert on overflow */
        require(
            totalReservesNew >= totalReserves,
            "add reserves unexpected overflow"
        );

        // Store reserves[n+1] = reserves[n] + actualAddAmount
        totalReserves = totalReservesNew;

        /* Emit NewReserves(admin, actualAddAmount, reserves[n+1]) */
        emit ReservesAdded(msg.sender, actualAddAmount, totalReservesNew);

        /* Return (NO_ERROR, actualAddAmount) */
        return (uint(Error.NO_ERROR), actualAddAmount);
    }

    /**
     * @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(
        uint reduceAmount
    ) external override nonReentrant returns (uint) {
        uint error = accrueInterest();
        if (error != uint(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(uint reduceAmount) internal returns (uint) {
        // totalReserves - reduceAmount
        uint totalReservesNew;

        // Check caller is admin
        if (msg.sender != admin) {
            return
                fail(
                    Error.UNAUTHORIZED,
                    FailureInfo.REDUCE_RESERVES_ADMIN_CHECK
                );
        }

        // We fail gracefully unless market's block timestamp equals current block timestamp
        if (accrualBlockTimestamp != getBlockTimestamp()) {
            return
                fail(
                    Error.MARKET_NOT_FRESH,
                    FailureInfo.REDUCE_RESERVES_FRESH_CHECK
                );
        }

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

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

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

        totalReservesNew = totalReserves - reduceAmount;
        // We checked reduceAmount <= totalReserves above, so this should never revert.
        require(
            totalReservesNew <= totalReserves,
            "reduce reserves unexpected underflow"
        );

        // Store reserves[n+1] = reserves[n] - reduceAmount
        totalReserves = totalReservesNew;

        // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.
        doTransferOut(admin, reduceAmount);

        emit ReservesReduced(admin, reduceAmount, totalReservesNew);

        return uint(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(
        InterestRateModel newInterestRateModel
    ) public override returns (uint) {
        uint error = accrueInterest();
        if (error != uint(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(
        InterestRateModel newInterestRateModel
    ) internal returns (uint) {
        // Used to store old model for use in the event that is emitted on success
        InterestRateModel oldInterestRateModel;

        // Check caller is admin
        if (msg.sender != admin) {
            return
                fail(
                    Error.UNAUTHORIZED,
                    FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK
                );
        }

        // We fail gracefully unless market's block timestamp equals current block timestamp
        if (accrualBlockTimestamp != getBlockTimestamp()) {
            return
                fail(
                    Error.MARKET_NOT_FRESH,
                    FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK
                );
        }

        // Track the market's current interest rate model
        oldInterestRateModel = interestRateModel;

        // Ensure invoke newInterestRateModel.isInterestRateModel() returns true
        require(
            newInterestRateModel.isInterestRateModel(),
            "marker method returned false"
        );

        // Set the interest rate model to newInterestRateModel
        interestRateModel = newInterestRateModel;

        // Emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel)
        emit NewMarketInterestRateModel(
            oldInterestRateModel,
            newInterestRateModel
        );

        return uint(Error.NO_ERROR);
    }

    /**
     * @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(
        uint newProtocolSeizeShareMantissa
    ) external override nonReentrant returns (uint) {
        uint error = accrueInterest();
        if (error != uint(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(
        uint newProtocolSeizeShareMantissa
    ) internal returns (uint) {
        // Used to store old share for use in the event that is emitted on success
        uint oldProtocolSeizeShareMantissa;

        // Check caller is admin
        if (msg.sender != admin) {
            return
                fail(
                    Error.UNAUTHORIZED,
                    FailureInfo.SET_PROTOCOL_SEIZE_SHARE_OWNER_CHECK
                );
        }

        // We fail gracefully unless market's block timestamp equals current block timestamp
        if (accrualBlockTimestamp != getBlockTimestamp()) {
            return
                fail(
                    Error.MARKET_NOT_FRESH,
                    FailureInfo.SET_PROTOCOL_SEIZE_SHARE_FRESH_CHECK
                );
        }

        // Track the market's current protocol seize share
        oldProtocolSeizeShareMantissa = protocolSeizeShareMantissa;

        // Set the protocol seize share to newProtocolSeizeShareMantissa
        protocolSeizeShareMantissa = newProtocolSeizeShareMantissa;

        // Emit NewProtocolSeizeShareMantissa(oldProtocolSeizeShareMantissa, newProtocolSeizeShareMantissa)
        emit NewProtocolSeizeShare(
            oldProtocolSeizeShareMantissa,
            newProtocolSeizeShareMantissa
        );

        return uint(Error.NO_ERROR);
    }

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

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

    /**
     * @dev Performs a transfer out, ideally returning an explanatory error code upon failure tather than reverting.
     *  If caller has not called checked protocol's balance, may revert due to insufficient cash held in the contract.
     *  If caller has checked protocol's balance, and verified it is >= amount, this should not revert in normal conditions.
     */
    function doTransferOut(address payable to, uint amount) 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
    }
}

File 11 of 11 : MTokenInterfaces.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.19;

import "./ComptrollerInterface.sol";
import "./InterestRateModel.sol";
import "./EIP20NonStandardInterface.sol";
import "./ErrorReporter.sol";

contract MTokenStorage {
    /// @dev Guard variable for re-entrancy checks
    bool internal _notEntered;

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

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

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

    /// @notice 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-mToken operations
    ComptrollerInterface public comptroller;

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

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

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

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

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

    /// @notice Total amount of outstanding borrows of the underlying in this market
    uint public 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 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;
}

abstract contract MTokenInterface is MTokenStorage {
    /// @notice Indicator that this is a MToken contract (for inspection)
    bool public constant isMToken = true;

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

    /// @notice Event emitted when interestRateModel is changed
    event NewMarketInterestRateModel(
        InterestRateModel oldInterestRateModel,
        InterestRateModel 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
    );

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

    /// @notice EIP20 Approval event
    event Approval(address indexed owner, address indexed spender, uint amount);

    /*** User Interface ***/

    function transfer(address dst, uint amount) external virtual returns (bool);
    function transferFrom(
        address src,
        address dst,
        uint amount
    ) external virtual returns (bool);
    function approve(
        address spender,
        uint amount
    ) external virtual returns (bool);
    function allowance(
        address owner,
        address spender
    ) external view virtual returns (uint);
    function balanceOf(address owner) external view virtual returns (uint);
    function balanceOfUnderlying(address owner) external virtual returns (uint);
    function getAccountSnapshot(
        address account
    ) external view virtual returns (uint, uint, uint, uint);
    function borrowRatePerTimestamp() external view virtual returns (uint);
    function supplyRatePerTimestamp() external view virtual returns (uint);
    function totalBorrowsCurrent() external virtual returns (uint);
    function borrowBalanceCurrent(
        address account
    ) external virtual returns (uint);
    function borrowBalanceStored(
        address account
    ) external view virtual returns (uint);
    function exchangeRateCurrent() external virtual returns (uint);
    function exchangeRateStored() external view virtual returns (uint);
    function getCash() external view virtual returns (uint);
    function accrueInterest() external virtual returns (uint);
    function seize(
        address liquidator,
        address borrower,
        uint seizeTokens
    ) external virtual returns (uint);

    /*** Admin Functions ***/

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

contract MErc20Storage {
    /// @notice Underlying asset for this MToken
    address public underlying;
}

abstract contract MErc20Interface is MErc20Storage {
    /*** User Interface ***/

    function mint(uint mintAmount) external virtual returns (uint);
    function mintWithPermit(
        uint mintAmount,
        uint deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external virtual returns (uint);
    function redeem(uint redeemTokens) external virtual returns (uint);
    function redeemUnderlying(
        uint redeemAmount
    ) external virtual returns (uint);
    function borrow(uint borrowAmount) external virtual returns (uint);
    function repayBorrow(uint repayAmount) external virtual returns (uint);
    function repayBorrowBehalf(
        address borrower,
        uint repayAmount
    ) external virtual returns (uint);
    function liquidateBorrow(
        address borrower,
        uint repayAmount,
        MTokenInterface mTokenCollateral
    ) external virtual returns (uint);
    function sweepToken(EIP20NonStandardInterface token) external virtual;

    /*** Admin Functions ***/

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

contract MDelegationStorage {
    /// @notice Implementation address for this contract
    address public implementation;
}

abstract contract MDelegatorInterface is MDelegationStorage {
    /// @notice Emitted when implementation is changed
    event NewImplementation(
        address oldImplementation,
        address newImplementation
    );

    /**
     * @notice Called by the admin to update the implementation of the delegator
     * @param implementation_ The address of the new implementation for delegation
     * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation
     * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation
     */
    function _setImplementation(
        address implementation_,
        bool allowResign,
        bytes memory becomeImplementationData
    ) external virtual;
}

abstract contract MDelegateInterface is MDelegationStorage {
    /**
     * @notice Called by the delegator on a delegate to initialize it for duty
     * @dev Should revert if any issues arise which make it unfit for delegation
     * @param data The encoded bytes data for any initialization
     */
    function _becomeImplementation(bytes memory data) external virtual;

    /// @notice Called by the delegator on a delegate to forfeit its responsibility
    function _resignImplementation() external virtual;
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract ComptrollerInterface","name":"comptroller_","type":"address"},{"internalType":"contract InterestRateModel","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"},{"internalType":"address payable","name":"admin_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"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":"mTokenCollateral","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 ComptrollerInterface","name":"oldComptroller","type":"address"},{"indexed":false,"internalType":"contract ComptrollerInterface","name":"newComptroller","type":"address"}],"name":"NewComptroller","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract InterestRateModel","name":"oldInterestRateModel","type":"address"},{"indexed":false,"internalType":"contract InterestRateModel","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":[],"name":"_addReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reduceAmount","type":"uint256"}],"name":"_reduceReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ComptrollerInterface","name":"newComptroller","type":"address"}],"name":"_setComptroller","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract InterestRateModel","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":[{"internalType":"enum TokenErrorReporter.Error","name":"","type":"uint8"}],"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 ComptrollerInterface","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":"contract ComptrollerInterface","name":"comptroller_","type":"address"},{"internalType":"contract InterestRateModel","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":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"interestRateModel","outputs":[{"internalType":"contract InterestRateModel","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isEthDerivative","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isMToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"contract MToken","name":"rfTokenCollateral","type":"address"}],"name":"liquidateBorrow","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"mint","outputs":[],"stateMutability":"payable","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":[{"internalType":"enum TokenErrorReporter.Error","name":"","type":"uint8"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemUnderlying","outputs":[{"internalType":"enum TokenErrorReporter.Error","name":"","type":"uint8"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"repayBorrow","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"}],"name":"repayBorrowBehalf","outputs":[],"stateMutability":"payable","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":[],"name":"supplyRatePerTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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"},{"stateMutability":"payable","type":"receive"}]

6080604052601280546001600160a01b03191690553480156200002157600080fd5b50604051620057e0380380620057e083398101604081905262000044916200072f565b60038054610100600160a81b03191633610100021790556200006b8787878787876200009e565b600380546001600160a01b0390921661010002610100600160a81b0319909216919091179055506200098f945050505050565b60035461010090046001600160a01b031633146200010f5760405162461bcd60e51b8152602060048201526024808201527f6f6e6c792061646d696e206d617920696e697469616c697a6520746865206d616044820152631c9ad95d60e21b60648201526084015b60405180910390fd5b600954158015620001205750600a54155b6200017a5760405162461bcd60e51b815260206004820152602360248201527f6d61726b6574206d6179206f6e6c7920626520696e697469616c697a6564206f6044820152626e636560e81b606482015260840162000106565b600784905583620001e75760405162461bcd60e51b815260206004820152603060248201527f696e697469616c2065786368616e67652072617465206d75737420626520677260448201526f32b0ba32b9103a3430b7103d32b9379760811b606482015260840162000106565b6000620001f48762000302565b90508015620002465760405162461bcd60e51b815260206004820152601a60248201527f73657474696e6720636f6d7074726f6c6c6572206661696c6564000000000000604482015260640162000106565b42600955670de0b6b3a7640000600a55620002618662000456565b90508015620002be5760405162461bcd60e51b815260206004820152602260248201527f73657474696e6720696e7465726573742072617465206d6f64656c206661696c604482015261195960f21b606482015260840162000106565b6001620002cc85826200089f565b506002620002db84826200089f565b50506003805460ff90921660ff199283161790556000805490911660011790555050505050565b60035460009061010090046001600160a01b0316331462000331576200032b6001603f620005bd565b92915050565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd29160048083019260209291908290030181865afa1580156200037c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003a291906200096b565b620003f05760405162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c736500000000604482015260640162000106565b600580546001600160a01b0319166001600160a01b0385811691821790925560408051928416835260208301919091527f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d91015b60405180910390a160005b9392505050565b600354600090819061010090046001600160a01b0316331462000481576200044f60016042620005bd565b426009541462000499576200044f600a6041620005bd565b600660009054906101000a90046001600160a01b03169050826001600160a01b0316632191f92a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620004f0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200051691906200096b565b620005645760405162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c736500000000604482015260640162000106565b600680546001600160a01b0319166001600160a01b0385811691821790925560408051928416835260208301919091527fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f926910162000444565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0836010811115620005f557620005f5620007fa565b8360538111156200060a576200060a620007fa565b60408051928352602083019190915260009082015260600160405180910390a18260108111156200044f576200044f620007fa565b6001600160a01b03811681146200065557600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200068057600080fd5b81516001600160401b03808211156200069d576200069d62000658565b604051601f8301601f19908116603f01168101908282118183101715620006c857620006c862000658565b81604052838152602092508683858801011115620006e557600080fd5b600091505b83821015620007095785820183015181830184015290820190620006ea565b600093810190920192909252949350505050565b80516200072a816200063f565b919050565b600080600080600080600060e0888a0312156200074b57600080fd5b875162000758816200063f565b60208901519097506200076b816200063f565b604089015160608a015191975095506001600160401b03808211156200079057600080fd5b6200079e8b838c016200066e565b955060808a0151915080821115620007b557600080fd5b50620007c48a828b016200066e565b93505060a088015160ff81168114620007dc57600080fd5b9150620007ec60c089016200071d565b905092959891949750929550565b634e487b7160e01b600052602160045260246000fd5b600181811c908216806200082557607f821691505b6020821081036200084657634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200089a57600081815260208120601f850160051c81016020861015620008755750805b601f850160051c820191505b81811015620008965782815560010162000881565b5050505b505050565b81516001600160401b03811115620008bb57620008bb62000658565b620008d381620008cc845462000810565b846200084c565b602080601f8311600181146200090b5760008415620008f25750858301515b600019600386901b1c1916600185901b17855562000896565b600085815260208120601f198616915b828110156200093c578886015182559484019460019091019084016200091b565b50858210156200095b5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6000602082840312156200097e57600080fd5b815180151581146200044f57600080fd5b614e41806200099f6000396000f3fe6080604052600436106102cd5760003560e01c80638f840ddd11610175578063c5ebeaec116100dc578063e597461911610095578063f3fdb15a1161006f578063f3fdb15a1461084e578063f851a4401461086e578063fca7820b14610893578063fcb64147146108b357600080fd5b8063e597461914610806578063e9c714f214610819578063f2b3abbd1461082e57600080fd5b8063c5ebeaec14610740578063cd91801c14610760578063cfa9920114610775578063d3bd2c721461078b578063db006a75146107a0578063dd62ed3e146107c057600080fd5b8063aa5af0fd1161012e578063aa5af0fd14610682578063aae40a2a14610698578063b2a02ff1146106ab578063b71d1a0c146106cb578063bd6d894d146106eb578063c37f68e21461070057600080fd5b80638f840ddd146105e257806395d89b41146105f857806395dd91931461060d57806399d8c1b41461062d578063a6afed951461064d578063a9059cbb1461066257600080fd5b80634576b5db11610234578063699cd5e2116101ed57806373acee98116101c757806373acee981461056c5780638303084614610581578063852a12e3146105a1578063895dabad146105ce57600080fd5b8063699cd5e2146105015780636f307dc31461051657806370a082311461053657600080fd5b80634576b5db1461046d57806347bd37181461048d5780634e4d9fea146104a35780635fe3b567146104ab578063601a0bf1146104cb5780636752e702146104eb57600080fd5b8063182df0f511610286578063182df0f51461039f57806323b872dd146103b457806326782247146103d4578063313ce5671461040c5780633af9e669146104385780633b1d21a21461045857600080fd5b806306fdde03146102e2578063095ea7b31461030d5780631249c58b1461033d578063173b99041461034557806317bfdfbc1461036957806318160ddd1461038957600080fd5b366102dd576102db346108bb565b005b600080fd5b3480156102ee57600080fd5b506102f761094f565b604051610304919061486d565b60405180910390f35b34801561031957600080fd5b5061032d6103283660046148d3565b6109dd565b6040519015158152602001610304565b6102db610a4d565b34801561035157600080fd5b5061035b60085481565b604051908152602001610304565b34801561037557600080fd5b5061035b6103843660046148ff565b610a5a565b34801561039557600080fd5b5061035b600d5481565b3480156103ab57600080fd5b5061035b610aca565b3480156103c057600080fd5b5061032d6103cf36600461491c565b610b5b565b3480156103e057600080fd5b506004546103f4906001600160a01b031681565b6040516001600160a01b039091168152602001610304565b34801561041857600080fd5b506003546104269060ff1681565b60405160ff9091168152602001610304565b34801561044457600080fd5b5061035b6104533660046148ff565b610bab565b34801561046457600080fd5b5061035b610c5b565b34801561047957600080fd5b5061035b6104883660046148ff565b610c6a565b34801561049957600080fd5b5061035b600b5481565b6102db610db0565b3480156104b757600080fd5b506005546103f4906001600160a01b031681565b3480156104d757600080fd5b5061035b6104e636600461495d565b610db9565b3480156104f757600080fd5b5061035b60115481565b34801561050d57600080fd5b5061032d600181565b34801561052257600080fd5b506012546103f4906001600160a01b031681565b34801561054257600080fd5b5061035b6105513660046148ff565b6001600160a01b03166000908152600e602052604090205490565b34801561057857600080fd5b5061035b610e38565b34801561058d57600080fd5b5061035b61059c36600461495d565b610e9e565b3480156105ad57600080fd5b506105c16105bc36600461495d565b610f00565b604051610304919061498c565b3480156105da57600080fd5b50600161032d565b3480156105ee57600080fd5b5061035b600c5481565b34801561060457600080fd5b506102f7610f14565b34801561061957600080fd5b5061035b6106283660046148ff565b610f21565b34801561063957600080fd5b506102db610648366004614a57565b610fbb565b34801561065957600080fd5b5061035b611208565b34801561066e57600080fd5b5061032d61067d3660046148d3565b611579565b34801561068e57600080fd5b5061035b600a5481565b6102db6106a6366004614b03565b6115c8565b3480156106b757600080fd5b5061035b6106c636600461491c565b6115d9565b3480156106d757600080fd5b5061035b6106e63660046148ff565b611628565b3480156106f757600080fd5b5061035b6116a8565b34801561070c57600080fd5b5061072061071b3660046148ff565b611714565b604080519485526020850193909352918301526060820152608001610304565b34801561074c57600080fd5b506105c161075b36600461495d565b6117b5565b34801561076c57600080fd5b5061035b6117c0565b34801561078157600080fd5b5061035b60095481565b34801561079757600080fd5b5061035b611850565b3480156107ac57600080fd5b506105c16107bb36600461495d565b6118ab565b3480156107cc57600080fd5b5061035b6107db366004614b03565b6001600160a01b039182166000908152600f6020908152604080832093909416825291909152205490565b6102db6108143660046148ff565b6118b6565b34801561082557600080fd5b5061035b6118c5565b34801561083a57600080fd5b5061035b6108493660046148ff565b6119bd565b34801561085a57600080fd5b506006546103f4906001600160a01b031681565b34801561087a57600080fd5b506003546103f49061010090046001600160a01b031681565b34801561089f57600080fd5b5061035b6108ae36600461495d565b6119f5565b61035b611a57565b60008054819060ff166108e95760405162461bcd60e51b81526004016108e090614b3c565b60405180910390fd5b6000805460ff191681556108fb611208565b9050801561092b5761091f81601081111561091857610918614976565b601e611a62565b6000925092505061093b565b6109353385611adb565b92509250505b6000805460ff191660011790559092909150565b6001805461095c90614b60565b80601f016020809104026020016040519081016040528092919081815260200182805461098890614b60565b80156109d55780601f106109aa576101008083540402835291602001916109d5565b820191906000526020600020905b8154815290600101906020018083116109b857829003601f168201915b505050505081565b336000818152600f602090815260408083206001600160a01b03871680855292528083208590555191929182907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610a399087815260200190565b60405180910390a360019150505b92915050565b610a56346108bb565b5050565b6000805460ff16610a7d5760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155610a8f611208565b14610aac5760405162461bcd60e51b81526004016108e090614b94565b610ab582610f21565b90505b6000805460ff19166001179055919050565b6000806000610ad7611f61565b90925090506000826003811115610af057610af0614976565b14610a475760405162461bcd60e51b815260206004820152603560248201527f65786368616e67655261746553746f7265643a2065786368616e67655261746560448201527414dd1bdc9959125b9d195c9b985b0819985a5b1959605a1b60648201526084016108e0565b6000805460ff16610b7e5760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155610b943386868661201f565b1490506000805460ff191660011790559392505050565b6000806040518060200160405280610bc16116a8565b90526001600160a01b0384166000908152600e6020526040812054919250908190610bed9084906122bb565b90925090506000826003811115610c0657610c06614976565b14610c535760405162461bcd60e51b815260206004820152601f60248201527f62616c616e636520636f756c64206e6f742062652063616c63756c617465640060448201526064016108e0565b949350505050565b6000610c6561230d565b905090565b60035460009061010090046001600160a01b03163314610c9057610a476001603f611a62565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd29160048083019260209291908290030181865afa158015610cda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cfe9190614bc4565b610d4a5760405162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c73650000000060448201526064016108e0565b600580546001600160a01b0319166001600160a01b0385811691821790925560408051928416835260208301919091527f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d91015b60405180910390a160005b9392505050565b610a5634612319565b6000805460ff16610ddc5760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155610dee611208565b90508015610e1a57610e12816010811115610e0b57610e0b614976565b6030611a62565b915050610ab8565b610e238361237f565b9150506000805460ff19166001179055919050565b6000805460ff16610e5b5760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155610e6d611208565b14610e8a5760405162461bcd60e51b81526004016108e090614b94565b50600b546000805460ff1916600117905590565b6000805460ff16610ec15760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155610ed3611208565b90508015610ef757610e12816010811115610ef057610ef0614976565b6051611a62565b610e23836124c3565b6000610f0b8261253f565b50600092915050565b6002805461095c90614b60565b6000806000610f2f846125a4565b90925090506000826003811115610f4857610f48614976565b14610da95760405162461bcd60e51b815260206004820152603760248201527f626f72726f7742616c616e636553746f7265643a20626f72726f7742616c616e60448201527f636553746f726564496e7465726e616c206661696c656400000000000000000060648201526084016108e0565b60035461010090046001600160a01b031633146110265760405162461bcd60e51b8152602060048201526024808201527f6f6e6c792061646d696e206d617920696e697469616c697a6520746865206d616044820152631c9ad95d60e21b60648201526084016108e0565b6009541580156110365750600a54155b61108e5760405162461bcd60e51b815260206004820152602360248201527f6d61726b6574206d6179206f6e6c7920626520696e697469616c697a6564206f6044820152626e636560e81b60648201526084016108e0565b6007849055836110f95760405162461bcd60e51b815260206004820152603060248201527f696e697469616c2065786368616e67652072617465206d75737420626520677260448201526f32b0ba32b9103a3430b7103d32b9379760811b60648201526084016108e0565b600061110487610c6a565b905080156111545760405162461bcd60e51b815260206004820152601a60248201527f73657474696e6720636f6d7074726f6c6c6572206661696c656400000000000060448201526064016108e0565b42600955670de0b6b3a7640000600a5561116d8661265f565b905080156111c85760405162461bcd60e51b815260206004820152602260248201527f73657474696e6720696e7465726573742072617465206d6f64656c206661696c604482015261195960f21b60648201526084016108e0565b60016111d48582614c34565b5060026111e18482614c34565b50506003805460ff90921660ff199283161790556000805490911660011790555050505050565b60095460009042908181036112215760005b9250505090565b600061122b61230d565b600b54600c54600a546006546040516315f2405360e01b81526004810186905260248101859052604481018490529495509293919290916000916001600160a01b0316906315f2405390606401602060405180830381865afa158015611295573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b99190614cf4565b905065048c273950008111156113115760405162461bcd60e51b815260206004820152601c60248201527f626f72726f772072617465206973206162737572646c7920686967680000000060448201526064016108e0565b60008061131e89896127ba565b9092509050600082600381111561133757611337614976565b146113845760405162461bcd60e51b815260206004820152601f60248201527f636f756c64206e6f742063616c63756c61746520626c6f636b2064656c74610060448201526064016108e0565b6040805160208101909152600081526000806000806113b160405180602001604052808a815250876127e5565b909750945060008760038111156113ca576113ca614976565b14611400576113ed600960068960038111156113e8576113e8614976565b612861565b9e50505050505050505050505050505090565b61140a858c6122bb565b9097509350600087600381111561142357611423614976565b14611441576113ed600960018960038111156113e8576113e8614976565b61144b848c6128d9565b9097509250600087600381111561146457611464614976565b14611482576113ed600960048960038111156113e8576113e8614976565b61149d6040518060200160405280600854815250858c612909565b909750915060008760038111156114b6576114b6614976565b146114d4576113ed600960058960038111156113e8576113e8614976565b6114df858a8b612909565b909750905060008760038111156114f8576114f8614976565b14611516576113ed600960038960038111156113e8576113e8614976565b60098e9055600a819055600b839055600c829055604080518d815260208101869052908101829052606081018490527f4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc049060800160405180910390a160006113ed565b6000805460ff1661159c5760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff191681556115b23333868661201f565b1490506000805460ff1916600117905592915050565b6115d3823483612964565b50505050565b6000805460ff166115fc5760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff1916905561161233858585612a7c565b90506000805460ff191660011790559392505050565b60035460009061010090046001600160a01b0316331461164e57610a4760016045611a62565b600480546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99101610d9e565b6000805460ff166116cb5760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff191681556116dd611208565b146116fa5760405162461bcd60e51b81526004016108e090614b94565b611702610aca565b90506000805460ff1916600117905590565b6001600160a01b0381166000908152600e602052604081205481908190819081808061173f896125a4565b93509050600081600381111561175757611757614976565b146117755760095b60008060009750975097509750505050506117ae565b61177d611f61565b92509050600081600381111561179557611795614976565b146117a157600961175f565b5060009650919450925090505b9193509193565b6000610f0b82612ecf565b6006546000906001600160a01b03166315f240536117dc61230d565b600b54600c546040516001600160e01b031960e086901b1681526004810193909352602483019190915260448201526064015b602060405180830381865afa15801561182c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c659190614cf4565b6006546000906001600160a01b031663b816881661186c61230d565b600b54600c546008546040516001600160e01b031960e087901b168152600481019490945260248401929092526044830152606482015260840161180f565b6000610f0b82612f32565b6118c08134612f90565b505050565b6004546000906001600160a01b0316331415806118e0575033155b156118f157610c6560016000611a62565b60038054600480546001600160a01b03808216610100818102610100600160a81b0319871617968790556001600160a01b031990931690935560408051948390048216808652929095041660208401529290917ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc910160405180910390a1600454604080516001600160a01b03808516825290921660208301527fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9910160405180910390a1600061121a565b6000806119c8611208565b905080156119ec57610da98160108111156119e5576119e5614976565b6040611a62565b610da98361265f565b6000805460ff16611a185760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155611a2a611208565b90508015611a4e57610e12816010811115611a4757611a47614976565b6046611a62565b610e238361301e565b6000610c65346130b3565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0836010811115611a9757611a97614976565b836053811115611aa957611aa9614976565b60408051928352602083019190915260009082015260600160405180910390a1826010811115610da957610da9614976565b600554604051634ef4c3e160e01b8152600091829182916001600160a01b031690634ef4c3e190611b1490309089908990600401614d0d565b6020604051808303816000875af1158015611b33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b579190614cf4565b90508015611b7857611b6c6003601f83612861565b60009250925050611f5a565b4260095414611b8d57611b6c600a6022611a62565b611bce6040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b611bd6611f61565b6040830181905260208301826003811115611bf357611bf3614976565b6003811115611c0457611c04614976565b9052506000905081602001516003811115611c2157611c21614976565b14611c5057611c4360096021836020015160038111156113e8576113e8614976565b6000935093505050611f5a565b611c5a868661312b565b60c0820181905260408051602081018252908301518152611c7b91906131bd565b6060830181905260208301826003811115611c9857611c98614976565b6003811115611ca957611ca9614976565b9052506000905081602001516003811115611cc657611cc6614976565b14611d135760405162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c454460448201526064016108e0565b611d23600d5482606001516128d9565b6080830181905260208301826003811115611d4057611d40614976565b6003811115611d5157611d51614976565b9052506000905081602001516003811115611d6e57611d6e614976565b14611dcc5760405162461bcd60e51b815260206004820152602860248201527f4d494e545f4e45575f544f54414c5f535550504c595f43414c43554c4154494f6044820152671397d1905253115160c21b60648201526084016108e0565b6001600160a01b0386166000908152600e60205260409020546060820151611df491906128d9565b60a0830181905260208301826003811115611e1157611e11614976565b6003811115611e2257611e22614976565b9052506000905081602001516003811115611e3f57611e3f614976565b14611ea05760405162461bcd60e51b815260206004820152602b60248201527f4d494e545f4e45575f4143434f554e545f42414c414e43455f43414c43554c4160448201526a151253d397d1905253115160aa1b60648201526084016108e0565b6080810151600d5560a08101516001600160a01b0387166000908152600e6020526040908190209190915560c0820151606083015191517f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f92611f07928a92909190614d31565b60405180910390a1856001600160a01b0316306001600160a01b0316600080516020614dec8339815191528360600151604051611f4691815260200190565b60405180910390a360c00151600093509150505b9250929050565b600d546000908190808203611f7d575050600754600092909150565b6000611f8761230d565b90506000611fa16040518060200160405280600081525090565b6000611fb284600b54600c546131cd565b935090506000816003811115611fca57611fca614976565b14611fdc579660009650945050505050565b611fe68386613211565b925090506000816003811115611ffe57611ffe614976565b14612010579660009650945050505050565b50516000969095509350505050565b6005546040516317b9b84b60e31b81523060048201526001600160a01b038581166024830152848116604483015260648201849052600092839291169063bdcdc258906084016020604051808303816000875af1158015612084573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120a89190614cf4565b905080156120c5576120bd6003604a83612861565b915050610c53565b836001600160a01b0316856001600160a01b0316036120ea576120bd6002604b611a62565b6000856001600160a01b0316876001600160a01b03160361210e5750600019612136565b506001600160a01b038086166000908152600f60209081526040808320938a16835292905220545b60008060008061214685896127ba565b9094509250600084600381111561215f5761215f614976565b1461217d576121706009604b611a62565b9650505050505050610c53565b6001600160a01b038a166000908152600e60205260409020546121a090896127ba565b909450915060008460038111156121b9576121b9614976565b146121ca576121706009604c611a62565b6001600160a01b0389166000908152600e60205260409020546121ed90896128d9565b9094509050600084600381111561220657612206614976565b14612217576121706009604d611a62565b6001600160a01b03808b166000908152600e6020526040808220859055918b16815220819055600019851461226f576001600160a01b03808b166000908152600f60209081526040808320938f168352929052208390555b886001600160a01b03168a6001600160a01b0316600080516020614dec8339815191528a6040516122a291815260200190565b60405180910390a35060009a9950505050505050505050565b6000806000806122cb86866127e5565b909250905060008260038111156122e4576122e4614976565b146122f55750915060009050611f5a565b6000612300826132dc565b9350935050509250929050565b6000610c653447614d68565b60008054819060ff1661233e5760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155612350611208565b905080156123745761091f81601081111561236d5761236d614976565b6036611a62565b6109353333866132f4565b600354600090819061010090046001600160a01b031633146123a757610da960016031611a62565b42600954146123bc57610da9600a6033611a62565b826123c561230d565b10156123d757610da9600e6032611a62565b600c548311156123ed57610da960026034611a62565b82600c546123fb9190614d68565b9050600c5481111561245b5760405162461bcd60e51b8152602060048201526024808201527f72656475636520726573657276657320756e657870656374656420756e646572604482015263666c6f7760e01b60648201526084016108e0565b600c81905560035461247b9061010090046001600160a01b03168461370b565b7f3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e600360019054906101000a90046001600160a01b03168483604051610d9e93929190614d31565b600354600090819061010090046001600160a01b031633146124eb57610da960016052611a62565b426009541461250057610da9600a6053611a62565b50601180549083905560408051828152602081018590527ff5815f353a60e815cce7553e4f60c533a59d26b1b5504ea4b6db8d60da3e4da29101610d9e565b6000805460ff166125625760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155612574611208565b9050801561259857610e1281601081111561259157612591614976565b6027611a62565b610e2333600085613741565b6001600160a01b03811660009081526010602052604081208054829182918291829182036125db5750600096879650945050505050565b6125eb8160000154600a54613d26565b9094509250600084600381111561260457612604614976565b1461261757509195600095509350505050565b612625838260010154613d73565b9094509150600084600381111561263e5761263e614976565b1461265157509195600095509350505050565b506000969095509350505050565b600354600090819061010090046001600160a01b0316331461268757610da960016042611a62565b426009541461269c57610da9600a6041611a62565b600660009054906101000a90046001600160a01b03169050826001600160a01b0316632191f92a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127169190614bc4565b6127625760405162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c73650000000060448201526064016108e0565b600680546001600160a01b0319166001600160a01b0385811691821790925560408051928416835260208301919091527fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f9269101610d9e565b6000808383116127d95760006127d08486614d68565b91509150611f5a565b50600390506000611f5a565b60006127fd6040518060200160405280600081525090565b60008061280e866000015186613d26565b9092509050600082600381111561282757612827614976565b1461284657506040805160208101909152600081529092509050611f5a565b60408051602081019091529081526000969095509350505050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa084601081111561289657612896614976565b8460538111156128a8576128a8614976565b604080519283526020830191909152810184905260600160405180910390a1836010811115610c5357610c53614976565b600080806128e78486614d7b565b90508481106128fb57600092509050611f5a565b600260009250925050611f5a565b60008060008061291987876127e5565b9092509050600082600381111561293257612932614976565b14612943575091506000905061295c565b61295561294f826132dc565b866128d9565b9350935050505b935093915050565b60008054819060ff166129895760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff1916815561299b611208565b905080156129cb576129bf8160108111156129b8576129b8614976565b600f611a62565b60009250925050612a65565b836001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612a0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a2f9190614cf4565b90508015612a53576129bf816010811115612a4c57612a4c614976565b6010611a62565b612a5f33878787613da1565b92509250505b6000805460ff191660011790559094909350915050565b60055460405163d02f735160e01b81523060048201526001600160a01b0386811660248301528581166044830152848116606483015260848201849052600092839291169063d02f73519060a4016020604051808303816000875af1158015612ae9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b0d9190614cf4565b90508015612b22576120bd6003601b83612861565b846001600160a01b0316846001600160a01b031603612b47576120bd6006601c611a62565b612b97604080516101208101909152806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0385166000908152600e6020526040902054612bba90856127ba565b6020830181905282826003811115612bd457612bd4614976565b6003811115612be557612be5614976565b9052506000905081516003811115612bff57612bff614976565b14612c2a57612c216009601a836000015160038111156113e8576113e8614976565b92505050610c53565b612c44846040518060200160405280601154815250614260565b60808201819052612c56908590614283565b6060820152612c63611f61565b60c0830181905282826003811115612c7d57612c7d614976565b6003811115612c8e57612c8e614976565b9052506000905081516003811115612ca857612ca8614976565b14612cf55760405162461bcd60e51b815260206004820152601860248201527f65786368616e67652072617465206d617468206572726f72000000000000000060448201526064016108e0565b612d1560405180602001604052808360c0015181525082608001516142bd565b60a08201819052600c54612d28916142d5565b60e0820152600d546080820151612d3f9190614283565b6101008201526001600160a01b0386166000908152600e60205260409020546060820151612d6d91906128d9565b6040830181905282826003811115612d8757612d87614976565b6003811115612d9857612d98614976565b9052506000905081516003811115612db257612db2614976565b14612dd457612c2160096019836000015160038111156113e8576113e8614976565b60e0810151600c55610100810151600d556020808201516001600160a01b038781166000818152600e855260408082209490945583860151928b1680825290849020929092556060850151925192835290929091600080516020614dec833981519152910160405180910390a3306001600160a01b0316856001600160a01b0316600080516020614dec8339815191528360800151604051612e7891815260200190565b60405180910390a360a081015160e08201516040517fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc592612eba923092614d31565b60405180910390a16000979650505050505050565b6000805460ff16612ef25760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155612f04611208565b90508015612f2857610e12816010811115612f2157612f21614976565b6008611a62565b610e23338461430b565b6000805460ff16612f555760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155612f67611208565b90508015612f8457610e1281601081111561259157612591614976565b610e2333846000613741565b60008054819060ff16612fb55760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155612fc7611208565b90508015612ff757612feb816010811115612fe457612fe4614976565b6035611a62565b60009250925050613008565b6130023386866132f4565b92509250505b6000805460ff1916600117905590939092509050565b60035460009061010090046001600160a01b0316331461304457610a4760016047611a62565b426009541461305957610a47600a6048611a62565b670de0b6b3a764000082111561307557610a4760026049611a62565b600880549083905560408051828152602081018590527faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f8214609101610d9e565b6000805460ff166130d65760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff191681556130e8611208565b9050801561310c57610e1281601081111561310557613105614976565b604e611a62565b613115836145f5565b509150506000805460ff19166001179055919050565b6000336001600160a01b038416146131775760405162461bcd60e51b815260206004820152600f60248201526e0e6cadcc8cae440dad2e6dac2e8c6d608b1b60448201526064016108e0565b8134146131b75760405162461bcd60e51b815260206004820152600e60248201526d0ecc2d8eaca40dad2e6dac2e8c6d60931b60448201526064016108e0565b50919050565b6000806000806122cb86866146cf565b6000806000806131dd87876128d9565b909250905060008260038111156131f6576131f6614976565b14613207575091506000905061295c565b61295581866127ba565b60006132296040518060200160405280600081525090565b60008061323e86670de0b6b3a7640000613d26565b9092509050600082600381111561325757613257614976565b1461327657506040805160208101909152600081529092509050611f5a565b6000806132838388613d73565b9092509050600082600381111561329c5761329c614976565b146132bf5781604051806020016040528060008152509550955050505050611f5a565b604080516020810190915290815260009890975095505050505050565b8051600090610a4790670de0b6b3a764000090614d8e565b600554604051631200453160e11b81523060048201526001600160a01b03858116602483015284811660448301526064820184905260009283928392909116906324008a62906084016020604051808303816000875af115801561335c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133809190614cf4565b905080156133a1576133956003603883612861565b6000925092505061295c565b42600954146133b657613395600a6039611a62565b6133ff6040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0386166000908152601060205260409020600101546060820152613429866125a4565b608083018190526020830182600381111561344657613446614976565b600381111561345757613457614976565b905250600090508160200151600381111561347457613474614976565b146134a35761349660096037836020015160038111156113e8576113e8614976565b600093509350505061295c565b60001985036134bb57608081015160408201526134c3565b604081018590525b6134d187826040015161312b565b60e0820181905260808201516134e6916127ba565b60a083018190526020830182600381111561350357613503614976565b600381111561351457613514614976565b905250600090508160200151600381111561353157613531614976565b146135a45760405162461bcd60e51b815260206004820152603a60248201527f52455041595f424f52524f575f4e45575f4143434f554e545f424f52524f575f60448201527f42414c414e43455f43414c43554c4154494f4e5f4641494c454400000000000060648201526084016108e0565b6135b4600b548260e001516127ba565b60c08301819052602083018260038111156135d1576135d1614976565b60038111156135e2576135e2614976565b90525060009050816020015160038111156135ff576135ff614976565b146136665760405162461bcd60e51b815260206004820152603160248201527f52455041595f424f52524f575f4e45575f544f54414c5f42414c414e43455f43604482015270105310d55310551253d397d19052531151607a1b60648201526084016108e0565b60a081810180516001600160a01b03898116600081815260106020908152604091829020948555600a5460019095019490945560c0870151600b81905560e088015195518251948f16855294840192909252820193909352606081019190915260808101919091527f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1910160405180910390a160e00151600097909650945050505050565b6040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156118c0573d6000803e3d6000fd5b600082158061374e575081155b6137b75760405162461bcd60e51b815260206004820152603460248201527f6f6e65206f662072656465656d546f6b656e73496e206f722072656465656d416044820152736d6f756e74496e206d757374206265207a65726f60601b60648201526084016108e0565b6137f86040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b613800611f61565b604083018190526020830182600381111561381d5761381d614976565b600381111561382e5761382e614976565b905250600090508160200151600381111561384b5761384b614976565b146138755761386d6009602b836020015160038111156113e8576113e8614976565b915050610da9565b83156139415760001984036138a7576001600160a01b0385166000908152600e602052604090205460608201526138af565b606081018490525b6138cf6040518060200160405280836040015181525082606001516122bb565b60808301819052602083018260038111156138ec576138ec614976565b60038111156138fd576138fd614976565b905250600090508160200151600381111561391a5761391a614976565b1461393c5761386d60096029836020015160038111156113e8576113e8614976565b613a16565b6000198303613987576001600160a01b0385166000908152600e602090815260409182902054606084019081528251918201835291830151815290516138cf91906122bb565b60808101839052604080516020810182529082015181526139a99084906131bd565b60608301819052602083018260038111156139c6576139c6614976565b60038111156139d7576139d7614976565b90525060009050816020015160038111156139f4576139f4614976565b14613a165761386d6009602a836020015160038111156113e8576113e8614976565b600554606082015160405163eabe7d9160e01b81526000926001600160a01b03169163eabe7d9191613a4f9130918b9190600401614d0d565b6020604051808303816000875af1158015613a6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a929190614cf4565b90508015613ab057613aa76003602883612861565b92505050610da9565b4260095414613ac557613aa7600a602c611a62565b613ad5600d5483606001516127ba565b60a0840181905260208401826003811115613af257613af2614976565b6003811115613b0357613b03614976565b9052506000905082602001516003811115613b2057613b20614976565b14613b4257613aa76009602e846020015160038111156113e8576113e8614976565b6001600160a01b0386166000908152600e60205260409020546060830151613b6a91906127ba565b60c0840181905260208401826003811115613b8757613b87614976565b6003811115613b9857613b98614976565b9052506000905082602001516003811115613bb557613bb5614976565b14613bd757613aa76009602d846020015160038111156113e8576113e8614976565b8160800151613be461230d565b1015613bf657613aa7600e602f611a62565b60a0820151600d5560c08201516001600160a01b0387166000818152600e60205260409081902092909255606084015191513092600080516020614dec83398151915291613c4691815260200190565b60405180910390a3608082015160608301516040517fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a92992613c88928a92614d31565b60405180910390a1600554608083015160608401516040516351dff98960e01b81523060048201526001600160a01b038a81166024830152604482019390935260648101919091529116906351dff9899060840160006040518083038186803b158015613cf457600080fd5b505afa158015613d08573d6000803e3d6000fd5b50505050613d1a86836080015161370b565b60009695505050505050565b60008083600003613d3c57506000905080611f5a565b6000613d488486614db0565b905083613d558683614d8e565b14613d6857600260009250925050611f5a565b600092509050611f5a565b60008082600003613d8a5750600190506000611f5a565b6000613d968486614d8e565b915091509250929050565b600554604051632fe3f38f60e11b81523060048201526001600160a01b03838116602483015286811660448301528581166064830152608482018590526000928392839290911690635fc7e71e9060a401602060405180830381865afa158015613e0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e339190614cf4565b90508015613e5457613e486003601283612861565b60009250925050614257565b4260095414613e6957613e48600a6016611a62565b42846001600160a01b031663cfa992016040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ea8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ecc9190614cf4565b14613edd57613e48600a6011611a62565b866001600160a01b0316866001600160a01b031603613f0257613e4860066017611a62565b84600003613f1657613e4860076015611a62565b6000198503613f2b57613e4860076014611a62565b600080613f398989896132f4565b90925090508115613f6e57613f60826010811115613f5957613f59614976565b6018611a62565b600094509450505050614257565b60055460405163c488847b60e01b815260009182916001600160a01b039091169063c488847b90613fa79030908c908890600401614d0d565b6040805180830381865afa158015613fc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fe79190614dc7565b909250905081156140565760405162461bcd60e51b815260206004820152603360248201527f4c49515549444154455f434f4d5054524f4c4c45525f43414c43554c4154455f604482015272105353d5539517d4d152569157d19052531151606a1b60648201526084016108e0565b6040516370a0823160e01b81526001600160a01b038b811660048301528291908a16906370a0823190602401602060405180830381865afa15801561409f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140c39190614cf4565b10156141115760405162461bcd60e51b815260206004820152601860248201527f4c49515549444154455f5345495a455f544f4f5f4d554348000000000000000060448201526064016108e0565b6000306001600160a01b038a16036141365761412f308d8d85612a7c565b90506141ac565b60405163b2a02ff160e01b81526001600160a01b038a169063b2a02ff190614166908f908f908790600401614d0d565b6020604051808303816000875af1158015614185573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141a99190614cf4565b90505b80156141f15760405162461bcd60e51b81526020600482015260146024820152731d1bdad95b881cd95a5e9d5c994819985a5b195960621b60448201526064016108e0565b604080516001600160a01b038e811682528d811660208301528183018790528b1660608201526080810184905290517f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb529181900360a00190a16000975092955050505050505b94509492505050565b6000670de0b6b3a7640000614279848460000151614742565b610da99190614d8e565b6000610da98383604051806040016040528060158152602001747375627472616374696f6e20756e646572666c6f7760581b815250614784565b6000806142ca84846147b3565b9050610c53816132dc565b6000610da98383604051806040016040528060118152602001706164646974696f6e206f766572666c6f7760781b8152506147e4565b60055460405163368f515360e21b815260009182916001600160a01b039091169063da3d454c9061434490309088908890600401614d0d565b6020604051808303816000875af1158015614363573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143879190614cf4565b905080156143a45761439c6003600e83612861565b915050610a47565b42600954146143b85761439c600a80611a62565b826143c161230d565b10156143d35761439c600e6009611a62565b6143ff604080516080810190915280600081526020016000815260200160008152602001600081525090565b614408856125a4565b602083018190528282600381111561442257614422614976565b600381111561443357614433614976565b905250600090508151600381111561444d5761444d614976565b146144785761446f60096007836000015160038111156113e8576113e8614976565b92505050610a47565b6144868160200151856128d9565b60408301819052828260038111156144a0576144a0614976565b60038111156144b1576144b1614976565b90525060009050815160038111156144cb576144cb614976565b146144ed5761446f6009600c836000015160038111156113e8576113e8614976565b6144f9600b54856128d9565b606083018190528282600381111561451357614513614976565b600381111561452457614524614976565b905250600090508151600381111561453e5761453e614976565b146145605761446f6009600b836000015160038111156113e8576113e8614976565b604081810180516001600160a01b03881660008181526010602090815290859020928355600a54600190930192909255606080860151600b8190559351855192835292820189905293810191909152918201527f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809060800160405180910390a16145ea858561370b565b600095945050505050565b600080808042600954146146195761460f600a604f611a62565b9590945092505050565b614623338661312b565b905080600c546146339190614d7b565b9150600c548210156146875760405162461bcd60e51b815260206004820181905260248201527f61646420726573657276657320756e6578706563746564206f766572666c6f7760448201526064016108e0565b600c8290556040517fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc5906146c090339084908690614d31565b60405180910390a1600061460f565b60006146e76040518060200160405280600081525090565b6000806146fc670de0b6b3a764000087613d26565b9092509050600082600381111561471557614715614976565b1461473457506040805160208101909152600081529092509050611f5a565b612300818660000151613211565b6000610da983836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f7700000000000000000081525061481e565b600081848411156147a85760405162461bcd60e51b81526004016108e0919061486d565b50610c538385614d68565b60408051602081019091526000815260405180602001604052806147db856000015185614742565b90529392505050565b6000806147f18486614d7b565b905082858210156148155760405162461bcd60e51b81526004016108e0919061486d565b50949350505050565b600083158061482b575082155b1561483857506000610da9565b60006148448486614db0565b9050836148518683614d8e565b1483906148155760405162461bcd60e51b81526004016108e091905b600060208083528351808285015260005b8181101561489a5785810183015185820160400152820161487e565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b03811681146148d057600080fd5b50565b600080604083850312156148e657600080fd5b82356148f1816148bb565b946020939093013593505050565b60006020828403121561491157600080fd5b8135610da9816148bb565b60008060006060848603121561493157600080fd5b833561493c816148bb565b9250602084013561494c816148bb565b929592945050506040919091013590565b60006020828403121561496f57600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b60208101601183106149ae57634e487b7160e01b600052602160045260246000fd5b91905290565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126149db57600080fd5b813567ffffffffffffffff808211156149f6576149f66149b4565b604051601f8301601f19908116603f01168101908282118183101715614a1e57614a1e6149b4565b81604052838152866020858801011115614a3757600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060008060008060c08789031215614a7057600080fd5b8635614a7b816148bb565b95506020870135614a8b816148bb565b945060408701359350606087013567ffffffffffffffff80821115614aaf57600080fd5b614abb8a838b016149ca565b94506080890135915080821115614ad157600080fd5b50614ade89828a016149ca565b92505060a087013560ff81168114614af557600080fd5b809150509295509295509295565b60008060408385031215614b1657600080fd5b8235614b21816148bb565b91506020830135614b31816148bb565b809150509250929050565b6020808252600a90820152691c994b595b9d195c995960b21b604082015260600190565b600181811c90821680614b7457607f821691505b6020821081036131b757634e487b7160e01b600052602260045260246000fd5b6020808252601690820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604082015260600190565b600060208284031215614bd657600080fd5b81518015158114610da957600080fd5b601f8211156118c057600081815260208120601f850160051c81016020861015614c0d5750805b601f850160051c820191505b81811015614c2c57828155600101614c19565b505050505050565b815167ffffffffffffffff811115614c4e57614c4e6149b4565b614c6281614c5c8454614b60565b84614be6565b602080601f831160018114614c975760008415614c7f5750858301515b600019600386901b1c1916600185901b178555614c2c565b600085815260208120601f198616915b82811015614cc657888601518255948401946001909101908401614ca7565b5085821015614ce45787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208284031215614d0657600080fd5b5051919050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b039390931683526020830191909152604082015260600190565b634e487b7160e01b600052601160045260246000fd5b81810381811115610a4757610a47614d52565b80820180821115610a4757610a47614d52565b600082614dab57634e487b7160e01b600052601260045260246000fd5b500490565b8082028115828204841417610a4757610a47614d52565b60008060408385031215614dda57600080fd5b50508051602090910151909290915056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212205f3826bdeb4ef7ece10c0c5d27fc3b017d66fb3b572bb1a930c2a834b1c9082c64736f6c63430008130033000000000000000000000000d11443b079d62700061f7311fc48c40b30bcea910000000000000000000000000b19823ef1f4a6b1f7c52336f428f1a92e9f645e000000000000000000000000000000000000000000a56fa5b99019a5c800000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000008000000000000000000000000665b8b669b199ecf9f2bb5a5636e2e95d31f60b2000000000000000000000000000000000000000000000000000000000000000c466973634c656e6420415045000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046641504500000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x6080604052600436106102cd5760003560e01c80638f840ddd11610175578063c5ebeaec116100dc578063e597461911610095578063f3fdb15a1161006f578063f3fdb15a1461084e578063f851a4401461086e578063fca7820b14610893578063fcb64147146108b357600080fd5b8063e597461914610806578063e9c714f214610819578063f2b3abbd1461082e57600080fd5b8063c5ebeaec14610740578063cd91801c14610760578063cfa9920114610775578063d3bd2c721461078b578063db006a75146107a0578063dd62ed3e146107c057600080fd5b8063aa5af0fd1161012e578063aa5af0fd14610682578063aae40a2a14610698578063b2a02ff1146106ab578063b71d1a0c146106cb578063bd6d894d146106eb578063c37f68e21461070057600080fd5b80638f840ddd146105e257806395d89b41146105f857806395dd91931461060d57806399d8c1b41461062d578063a6afed951461064d578063a9059cbb1461066257600080fd5b80634576b5db11610234578063699cd5e2116101ed57806373acee98116101c757806373acee981461056c5780638303084614610581578063852a12e3146105a1578063895dabad146105ce57600080fd5b8063699cd5e2146105015780636f307dc31461051657806370a082311461053657600080fd5b80634576b5db1461046d57806347bd37181461048d5780634e4d9fea146104a35780635fe3b567146104ab578063601a0bf1146104cb5780636752e702146104eb57600080fd5b8063182df0f511610286578063182df0f51461039f57806323b872dd146103b457806326782247146103d4578063313ce5671461040c5780633af9e669146104385780633b1d21a21461045857600080fd5b806306fdde03146102e2578063095ea7b31461030d5780631249c58b1461033d578063173b99041461034557806317bfdfbc1461036957806318160ddd1461038957600080fd5b366102dd576102db346108bb565b005b600080fd5b3480156102ee57600080fd5b506102f761094f565b604051610304919061486d565b60405180910390f35b34801561031957600080fd5b5061032d6103283660046148d3565b6109dd565b6040519015158152602001610304565b6102db610a4d565b34801561035157600080fd5b5061035b60085481565b604051908152602001610304565b34801561037557600080fd5b5061035b6103843660046148ff565b610a5a565b34801561039557600080fd5b5061035b600d5481565b3480156103ab57600080fd5b5061035b610aca565b3480156103c057600080fd5b5061032d6103cf36600461491c565b610b5b565b3480156103e057600080fd5b506004546103f4906001600160a01b031681565b6040516001600160a01b039091168152602001610304565b34801561041857600080fd5b506003546104269060ff1681565b60405160ff9091168152602001610304565b34801561044457600080fd5b5061035b6104533660046148ff565b610bab565b34801561046457600080fd5b5061035b610c5b565b34801561047957600080fd5b5061035b6104883660046148ff565b610c6a565b34801561049957600080fd5b5061035b600b5481565b6102db610db0565b3480156104b757600080fd5b506005546103f4906001600160a01b031681565b3480156104d757600080fd5b5061035b6104e636600461495d565b610db9565b3480156104f757600080fd5b5061035b60115481565b34801561050d57600080fd5b5061032d600181565b34801561052257600080fd5b506012546103f4906001600160a01b031681565b34801561054257600080fd5b5061035b6105513660046148ff565b6001600160a01b03166000908152600e602052604090205490565b34801561057857600080fd5b5061035b610e38565b34801561058d57600080fd5b5061035b61059c36600461495d565b610e9e565b3480156105ad57600080fd5b506105c16105bc36600461495d565b610f00565b604051610304919061498c565b3480156105da57600080fd5b50600161032d565b3480156105ee57600080fd5b5061035b600c5481565b34801561060457600080fd5b506102f7610f14565b34801561061957600080fd5b5061035b6106283660046148ff565b610f21565b34801561063957600080fd5b506102db610648366004614a57565b610fbb565b34801561065957600080fd5b5061035b611208565b34801561066e57600080fd5b5061032d61067d3660046148d3565b611579565b34801561068e57600080fd5b5061035b600a5481565b6102db6106a6366004614b03565b6115c8565b3480156106b757600080fd5b5061035b6106c636600461491c565b6115d9565b3480156106d757600080fd5b5061035b6106e63660046148ff565b611628565b3480156106f757600080fd5b5061035b6116a8565b34801561070c57600080fd5b5061072061071b3660046148ff565b611714565b604080519485526020850193909352918301526060820152608001610304565b34801561074c57600080fd5b506105c161075b36600461495d565b6117b5565b34801561076c57600080fd5b5061035b6117c0565b34801561078157600080fd5b5061035b60095481565b34801561079757600080fd5b5061035b611850565b3480156107ac57600080fd5b506105c16107bb36600461495d565b6118ab565b3480156107cc57600080fd5b5061035b6107db366004614b03565b6001600160a01b039182166000908152600f6020908152604080832093909416825291909152205490565b6102db6108143660046148ff565b6118b6565b34801561082557600080fd5b5061035b6118c5565b34801561083a57600080fd5b5061035b6108493660046148ff565b6119bd565b34801561085a57600080fd5b506006546103f4906001600160a01b031681565b34801561087a57600080fd5b506003546103f49061010090046001600160a01b031681565b34801561089f57600080fd5b5061035b6108ae36600461495d565b6119f5565b61035b611a57565b60008054819060ff166108e95760405162461bcd60e51b81526004016108e090614b3c565b60405180910390fd5b6000805460ff191681556108fb611208565b9050801561092b5761091f81601081111561091857610918614976565b601e611a62565b6000925092505061093b565b6109353385611adb565b92509250505b6000805460ff191660011790559092909150565b6001805461095c90614b60565b80601f016020809104026020016040519081016040528092919081815260200182805461098890614b60565b80156109d55780601f106109aa576101008083540402835291602001916109d5565b820191906000526020600020905b8154815290600101906020018083116109b857829003601f168201915b505050505081565b336000818152600f602090815260408083206001600160a01b03871680855292528083208590555191929182907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610a399087815260200190565b60405180910390a360019150505b92915050565b610a56346108bb565b5050565b6000805460ff16610a7d5760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155610a8f611208565b14610aac5760405162461bcd60e51b81526004016108e090614b94565b610ab582610f21565b90505b6000805460ff19166001179055919050565b6000806000610ad7611f61565b90925090506000826003811115610af057610af0614976565b14610a475760405162461bcd60e51b815260206004820152603560248201527f65786368616e67655261746553746f7265643a2065786368616e67655261746560448201527414dd1bdc9959125b9d195c9b985b0819985a5b1959605a1b60648201526084016108e0565b6000805460ff16610b7e5760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155610b943386868661201f565b1490506000805460ff191660011790559392505050565b6000806040518060200160405280610bc16116a8565b90526001600160a01b0384166000908152600e6020526040812054919250908190610bed9084906122bb565b90925090506000826003811115610c0657610c06614976565b14610c535760405162461bcd60e51b815260206004820152601f60248201527f62616c616e636520636f756c64206e6f742062652063616c63756c617465640060448201526064016108e0565b949350505050565b6000610c6561230d565b905090565b60035460009061010090046001600160a01b03163314610c9057610a476001603f611a62565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd29160048083019260209291908290030181865afa158015610cda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cfe9190614bc4565b610d4a5760405162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c73650000000060448201526064016108e0565b600580546001600160a01b0319166001600160a01b0385811691821790925560408051928416835260208301919091527f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d91015b60405180910390a160005b9392505050565b610a5634612319565b6000805460ff16610ddc5760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155610dee611208565b90508015610e1a57610e12816010811115610e0b57610e0b614976565b6030611a62565b915050610ab8565b610e238361237f565b9150506000805460ff19166001179055919050565b6000805460ff16610e5b5760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155610e6d611208565b14610e8a5760405162461bcd60e51b81526004016108e090614b94565b50600b546000805460ff1916600117905590565b6000805460ff16610ec15760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155610ed3611208565b90508015610ef757610e12816010811115610ef057610ef0614976565b6051611a62565b610e23836124c3565b6000610f0b8261253f565b50600092915050565b6002805461095c90614b60565b6000806000610f2f846125a4565b90925090506000826003811115610f4857610f48614976565b14610da95760405162461bcd60e51b815260206004820152603760248201527f626f72726f7742616c616e636553746f7265643a20626f72726f7742616c616e60448201527f636553746f726564496e7465726e616c206661696c656400000000000000000060648201526084016108e0565b60035461010090046001600160a01b031633146110265760405162461bcd60e51b8152602060048201526024808201527f6f6e6c792061646d696e206d617920696e697469616c697a6520746865206d616044820152631c9ad95d60e21b60648201526084016108e0565b6009541580156110365750600a54155b61108e5760405162461bcd60e51b815260206004820152602360248201527f6d61726b6574206d6179206f6e6c7920626520696e697469616c697a6564206f6044820152626e636560e81b60648201526084016108e0565b6007849055836110f95760405162461bcd60e51b815260206004820152603060248201527f696e697469616c2065786368616e67652072617465206d75737420626520677260448201526f32b0ba32b9103a3430b7103d32b9379760811b60648201526084016108e0565b600061110487610c6a565b905080156111545760405162461bcd60e51b815260206004820152601a60248201527f73657474696e6720636f6d7074726f6c6c6572206661696c656400000000000060448201526064016108e0565b42600955670de0b6b3a7640000600a5561116d8661265f565b905080156111c85760405162461bcd60e51b815260206004820152602260248201527f73657474696e6720696e7465726573742072617465206d6f64656c206661696c604482015261195960f21b60648201526084016108e0565b60016111d48582614c34565b5060026111e18482614c34565b50506003805460ff90921660ff199283161790556000805490911660011790555050505050565b60095460009042908181036112215760005b9250505090565b600061122b61230d565b600b54600c54600a546006546040516315f2405360e01b81526004810186905260248101859052604481018490529495509293919290916000916001600160a01b0316906315f2405390606401602060405180830381865afa158015611295573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b99190614cf4565b905065048c273950008111156113115760405162461bcd60e51b815260206004820152601c60248201527f626f72726f772072617465206973206162737572646c7920686967680000000060448201526064016108e0565b60008061131e89896127ba565b9092509050600082600381111561133757611337614976565b146113845760405162461bcd60e51b815260206004820152601f60248201527f636f756c64206e6f742063616c63756c61746520626c6f636b2064656c74610060448201526064016108e0565b6040805160208101909152600081526000806000806113b160405180602001604052808a815250876127e5565b909750945060008760038111156113ca576113ca614976565b14611400576113ed600960068960038111156113e8576113e8614976565b612861565b9e50505050505050505050505050505090565b61140a858c6122bb565b9097509350600087600381111561142357611423614976565b14611441576113ed600960018960038111156113e8576113e8614976565b61144b848c6128d9565b9097509250600087600381111561146457611464614976565b14611482576113ed600960048960038111156113e8576113e8614976565b61149d6040518060200160405280600854815250858c612909565b909750915060008760038111156114b6576114b6614976565b146114d4576113ed600960058960038111156113e8576113e8614976565b6114df858a8b612909565b909750905060008760038111156114f8576114f8614976565b14611516576113ed600960038960038111156113e8576113e8614976565b60098e9055600a819055600b839055600c829055604080518d815260208101869052908101829052606081018490527f4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc049060800160405180910390a160006113ed565b6000805460ff1661159c5760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff191681556115b23333868661201f565b1490506000805460ff1916600117905592915050565b6115d3823483612964565b50505050565b6000805460ff166115fc5760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff1916905561161233858585612a7c565b90506000805460ff191660011790559392505050565b60035460009061010090046001600160a01b0316331461164e57610a4760016045611a62565b600480546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99101610d9e565b6000805460ff166116cb5760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff191681556116dd611208565b146116fa5760405162461bcd60e51b81526004016108e090614b94565b611702610aca565b90506000805460ff1916600117905590565b6001600160a01b0381166000908152600e602052604081205481908190819081808061173f896125a4565b93509050600081600381111561175757611757614976565b146117755760095b60008060009750975097509750505050506117ae565b61177d611f61565b92509050600081600381111561179557611795614976565b146117a157600961175f565b5060009650919450925090505b9193509193565b6000610f0b82612ecf565b6006546000906001600160a01b03166315f240536117dc61230d565b600b54600c546040516001600160e01b031960e086901b1681526004810193909352602483019190915260448201526064015b602060405180830381865afa15801561182c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c659190614cf4565b6006546000906001600160a01b031663b816881661186c61230d565b600b54600c546008546040516001600160e01b031960e087901b168152600481019490945260248401929092526044830152606482015260840161180f565b6000610f0b82612f32565b6118c08134612f90565b505050565b6004546000906001600160a01b0316331415806118e0575033155b156118f157610c6560016000611a62565b60038054600480546001600160a01b03808216610100818102610100600160a81b0319871617968790556001600160a01b031990931690935560408051948390048216808652929095041660208401529290917ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc910160405180910390a1600454604080516001600160a01b03808516825290921660208301527fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9910160405180910390a1600061121a565b6000806119c8611208565b905080156119ec57610da98160108111156119e5576119e5614976565b6040611a62565b610da98361265f565b6000805460ff16611a185760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155611a2a611208565b90508015611a4e57610e12816010811115611a4757611a47614976565b6046611a62565b610e238361301e565b6000610c65346130b3565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0836010811115611a9757611a97614976565b836053811115611aa957611aa9614976565b60408051928352602083019190915260009082015260600160405180910390a1826010811115610da957610da9614976565b600554604051634ef4c3e160e01b8152600091829182916001600160a01b031690634ef4c3e190611b1490309089908990600401614d0d565b6020604051808303816000875af1158015611b33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b579190614cf4565b90508015611b7857611b6c6003601f83612861565b60009250925050611f5a565b4260095414611b8d57611b6c600a6022611a62565b611bce6040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b611bd6611f61565b6040830181905260208301826003811115611bf357611bf3614976565b6003811115611c0457611c04614976565b9052506000905081602001516003811115611c2157611c21614976565b14611c5057611c4360096021836020015160038111156113e8576113e8614976565b6000935093505050611f5a565b611c5a868661312b565b60c0820181905260408051602081018252908301518152611c7b91906131bd565b6060830181905260208301826003811115611c9857611c98614976565b6003811115611ca957611ca9614976565b9052506000905081602001516003811115611cc657611cc6614976565b14611d135760405162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c454460448201526064016108e0565b611d23600d5482606001516128d9565b6080830181905260208301826003811115611d4057611d40614976565b6003811115611d5157611d51614976565b9052506000905081602001516003811115611d6e57611d6e614976565b14611dcc5760405162461bcd60e51b815260206004820152602860248201527f4d494e545f4e45575f544f54414c5f535550504c595f43414c43554c4154494f6044820152671397d1905253115160c21b60648201526084016108e0565b6001600160a01b0386166000908152600e60205260409020546060820151611df491906128d9565b60a0830181905260208301826003811115611e1157611e11614976565b6003811115611e2257611e22614976565b9052506000905081602001516003811115611e3f57611e3f614976565b14611ea05760405162461bcd60e51b815260206004820152602b60248201527f4d494e545f4e45575f4143434f554e545f42414c414e43455f43414c43554c4160448201526a151253d397d1905253115160aa1b60648201526084016108e0565b6080810151600d5560a08101516001600160a01b0387166000908152600e6020526040908190209190915560c0820151606083015191517f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f92611f07928a92909190614d31565b60405180910390a1856001600160a01b0316306001600160a01b0316600080516020614dec8339815191528360600151604051611f4691815260200190565b60405180910390a360c00151600093509150505b9250929050565b600d546000908190808203611f7d575050600754600092909150565b6000611f8761230d565b90506000611fa16040518060200160405280600081525090565b6000611fb284600b54600c546131cd565b935090506000816003811115611fca57611fca614976565b14611fdc579660009650945050505050565b611fe68386613211565b925090506000816003811115611ffe57611ffe614976565b14612010579660009650945050505050565b50516000969095509350505050565b6005546040516317b9b84b60e31b81523060048201526001600160a01b038581166024830152848116604483015260648201849052600092839291169063bdcdc258906084016020604051808303816000875af1158015612084573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120a89190614cf4565b905080156120c5576120bd6003604a83612861565b915050610c53565b836001600160a01b0316856001600160a01b0316036120ea576120bd6002604b611a62565b6000856001600160a01b0316876001600160a01b03160361210e5750600019612136565b506001600160a01b038086166000908152600f60209081526040808320938a16835292905220545b60008060008061214685896127ba565b9094509250600084600381111561215f5761215f614976565b1461217d576121706009604b611a62565b9650505050505050610c53565b6001600160a01b038a166000908152600e60205260409020546121a090896127ba565b909450915060008460038111156121b9576121b9614976565b146121ca576121706009604c611a62565b6001600160a01b0389166000908152600e60205260409020546121ed90896128d9565b9094509050600084600381111561220657612206614976565b14612217576121706009604d611a62565b6001600160a01b03808b166000908152600e6020526040808220859055918b16815220819055600019851461226f576001600160a01b03808b166000908152600f60209081526040808320938f168352929052208390555b886001600160a01b03168a6001600160a01b0316600080516020614dec8339815191528a6040516122a291815260200190565b60405180910390a35060009a9950505050505050505050565b6000806000806122cb86866127e5565b909250905060008260038111156122e4576122e4614976565b146122f55750915060009050611f5a565b6000612300826132dc565b9350935050509250929050565b6000610c653447614d68565b60008054819060ff1661233e5760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155612350611208565b905080156123745761091f81601081111561236d5761236d614976565b6036611a62565b6109353333866132f4565b600354600090819061010090046001600160a01b031633146123a757610da960016031611a62565b42600954146123bc57610da9600a6033611a62565b826123c561230d565b10156123d757610da9600e6032611a62565b600c548311156123ed57610da960026034611a62565b82600c546123fb9190614d68565b9050600c5481111561245b5760405162461bcd60e51b8152602060048201526024808201527f72656475636520726573657276657320756e657870656374656420756e646572604482015263666c6f7760e01b60648201526084016108e0565b600c81905560035461247b9061010090046001600160a01b03168461370b565b7f3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e600360019054906101000a90046001600160a01b03168483604051610d9e93929190614d31565b600354600090819061010090046001600160a01b031633146124eb57610da960016052611a62565b426009541461250057610da9600a6053611a62565b50601180549083905560408051828152602081018590527ff5815f353a60e815cce7553e4f60c533a59d26b1b5504ea4b6db8d60da3e4da29101610d9e565b6000805460ff166125625760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155612574611208565b9050801561259857610e1281601081111561259157612591614976565b6027611a62565b610e2333600085613741565b6001600160a01b03811660009081526010602052604081208054829182918291829182036125db5750600096879650945050505050565b6125eb8160000154600a54613d26565b9094509250600084600381111561260457612604614976565b1461261757509195600095509350505050565b612625838260010154613d73565b9094509150600084600381111561263e5761263e614976565b1461265157509195600095509350505050565b506000969095509350505050565b600354600090819061010090046001600160a01b0316331461268757610da960016042611a62565b426009541461269c57610da9600a6041611a62565b600660009054906101000a90046001600160a01b03169050826001600160a01b0316632191f92a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127169190614bc4565b6127625760405162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c73650000000060448201526064016108e0565b600680546001600160a01b0319166001600160a01b0385811691821790925560408051928416835260208301919091527fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f9269101610d9e565b6000808383116127d95760006127d08486614d68565b91509150611f5a565b50600390506000611f5a565b60006127fd6040518060200160405280600081525090565b60008061280e866000015186613d26565b9092509050600082600381111561282757612827614976565b1461284657506040805160208101909152600081529092509050611f5a565b60408051602081019091529081526000969095509350505050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa084601081111561289657612896614976565b8460538111156128a8576128a8614976565b604080519283526020830191909152810184905260600160405180910390a1836010811115610c5357610c53614976565b600080806128e78486614d7b565b90508481106128fb57600092509050611f5a565b600260009250925050611f5a565b60008060008061291987876127e5565b9092509050600082600381111561293257612932614976565b14612943575091506000905061295c565b61295561294f826132dc565b866128d9565b9350935050505b935093915050565b60008054819060ff166129895760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff1916815561299b611208565b905080156129cb576129bf8160108111156129b8576129b8614976565b600f611a62565b60009250925050612a65565b836001600160a01b031663a6afed956040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612a0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a2f9190614cf4565b90508015612a53576129bf816010811115612a4c57612a4c614976565b6010611a62565b612a5f33878787613da1565b92509250505b6000805460ff191660011790559094909350915050565b60055460405163d02f735160e01b81523060048201526001600160a01b0386811660248301528581166044830152848116606483015260848201849052600092839291169063d02f73519060a4016020604051808303816000875af1158015612ae9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b0d9190614cf4565b90508015612b22576120bd6003601b83612861565b846001600160a01b0316846001600160a01b031603612b47576120bd6006601c611a62565b612b97604080516101208101909152806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0385166000908152600e6020526040902054612bba90856127ba565b6020830181905282826003811115612bd457612bd4614976565b6003811115612be557612be5614976565b9052506000905081516003811115612bff57612bff614976565b14612c2a57612c216009601a836000015160038111156113e8576113e8614976565b92505050610c53565b612c44846040518060200160405280601154815250614260565b60808201819052612c56908590614283565b6060820152612c63611f61565b60c0830181905282826003811115612c7d57612c7d614976565b6003811115612c8e57612c8e614976565b9052506000905081516003811115612ca857612ca8614976565b14612cf55760405162461bcd60e51b815260206004820152601860248201527f65786368616e67652072617465206d617468206572726f72000000000000000060448201526064016108e0565b612d1560405180602001604052808360c0015181525082608001516142bd565b60a08201819052600c54612d28916142d5565b60e0820152600d546080820151612d3f9190614283565b6101008201526001600160a01b0386166000908152600e60205260409020546060820151612d6d91906128d9565b6040830181905282826003811115612d8757612d87614976565b6003811115612d9857612d98614976565b9052506000905081516003811115612db257612db2614976565b14612dd457612c2160096019836000015160038111156113e8576113e8614976565b60e0810151600c55610100810151600d556020808201516001600160a01b038781166000818152600e855260408082209490945583860151928b1680825290849020929092556060850151925192835290929091600080516020614dec833981519152910160405180910390a3306001600160a01b0316856001600160a01b0316600080516020614dec8339815191528360800151604051612e7891815260200190565b60405180910390a360a081015160e08201516040517fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc592612eba923092614d31565b60405180910390a16000979650505050505050565b6000805460ff16612ef25760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155612f04611208565b90508015612f2857610e12816010811115612f2157612f21614976565b6008611a62565b610e23338461430b565b6000805460ff16612f555760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155612f67611208565b90508015612f8457610e1281601081111561259157612591614976565b610e2333846000613741565b60008054819060ff16612fb55760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff19168155612fc7611208565b90508015612ff757612feb816010811115612fe457612fe4614976565b6035611a62565b60009250925050613008565b6130023386866132f4565b92509250505b6000805460ff1916600117905590939092509050565b60035460009061010090046001600160a01b0316331461304457610a4760016047611a62565b426009541461305957610a47600a6048611a62565b670de0b6b3a764000082111561307557610a4760026049611a62565b600880549083905560408051828152602081018590527faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f8214609101610d9e565b6000805460ff166130d65760405162461bcd60e51b81526004016108e090614b3c565b6000805460ff191681556130e8611208565b9050801561310c57610e1281601081111561310557613105614976565b604e611a62565b613115836145f5565b509150506000805460ff19166001179055919050565b6000336001600160a01b038416146131775760405162461bcd60e51b815260206004820152600f60248201526e0e6cadcc8cae440dad2e6dac2e8c6d608b1b60448201526064016108e0565b8134146131b75760405162461bcd60e51b815260206004820152600e60248201526d0ecc2d8eaca40dad2e6dac2e8c6d60931b60448201526064016108e0565b50919050565b6000806000806122cb86866146cf565b6000806000806131dd87876128d9565b909250905060008260038111156131f6576131f6614976565b14613207575091506000905061295c565b61295581866127ba565b60006132296040518060200160405280600081525090565b60008061323e86670de0b6b3a7640000613d26565b9092509050600082600381111561325757613257614976565b1461327657506040805160208101909152600081529092509050611f5a565b6000806132838388613d73565b9092509050600082600381111561329c5761329c614976565b146132bf5781604051806020016040528060008152509550955050505050611f5a565b604080516020810190915290815260009890975095505050505050565b8051600090610a4790670de0b6b3a764000090614d8e565b600554604051631200453160e11b81523060048201526001600160a01b03858116602483015284811660448301526064820184905260009283928392909116906324008a62906084016020604051808303816000875af115801561335c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133809190614cf4565b905080156133a1576133956003603883612861565b6000925092505061295c565b42600954146133b657613395600a6039611a62565b6133ff6040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0386166000908152601060205260409020600101546060820152613429866125a4565b608083018190526020830182600381111561344657613446614976565b600381111561345757613457614976565b905250600090508160200151600381111561347457613474614976565b146134a35761349660096037836020015160038111156113e8576113e8614976565b600093509350505061295c565b60001985036134bb57608081015160408201526134c3565b604081018590525b6134d187826040015161312b565b60e0820181905260808201516134e6916127ba565b60a083018190526020830182600381111561350357613503614976565b600381111561351457613514614976565b905250600090508160200151600381111561353157613531614976565b146135a45760405162461bcd60e51b815260206004820152603a60248201527f52455041595f424f52524f575f4e45575f4143434f554e545f424f52524f575f60448201527f42414c414e43455f43414c43554c4154494f4e5f4641494c454400000000000060648201526084016108e0565b6135b4600b548260e001516127ba565b60c08301819052602083018260038111156135d1576135d1614976565b60038111156135e2576135e2614976565b90525060009050816020015160038111156135ff576135ff614976565b146136665760405162461bcd60e51b815260206004820152603160248201527f52455041595f424f52524f575f4e45575f544f54414c5f42414c414e43455f43604482015270105310d55310551253d397d19052531151607a1b60648201526084016108e0565b60a081810180516001600160a01b03898116600081815260106020908152604091829020948555600a5460019095019490945560c0870151600b81905560e088015195518251948f16855294840192909252820193909352606081019190915260808101919091527f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1910160405180910390a160e00151600097909650945050505050565b6040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156118c0573d6000803e3d6000fd5b600082158061374e575081155b6137b75760405162461bcd60e51b815260206004820152603460248201527f6f6e65206f662072656465656d546f6b656e73496e206f722072656465656d416044820152736d6f756e74496e206d757374206265207a65726f60601b60648201526084016108e0565b6137f86040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b613800611f61565b604083018190526020830182600381111561381d5761381d614976565b600381111561382e5761382e614976565b905250600090508160200151600381111561384b5761384b614976565b146138755761386d6009602b836020015160038111156113e8576113e8614976565b915050610da9565b83156139415760001984036138a7576001600160a01b0385166000908152600e602052604090205460608201526138af565b606081018490525b6138cf6040518060200160405280836040015181525082606001516122bb565b60808301819052602083018260038111156138ec576138ec614976565b60038111156138fd576138fd614976565b905250600090508160200151600381111561391a5761391a614976565b1461393c5761386d60096029836020015160038111156113e8576113e8614976565b613a16565b6000198303613987576001600160a01b0385166000908152600e602090815260409182902054606084019081528251918201835291830151815290516138cf91906122bb565b60808101839052604080516020810182529082015181526139a99084906131bd565b60608301819052602083018260038111156139c6576139c6614976565b60038111156139d7576139d7614976565b90525060009050816020015160038111156139f4576139f4614976565b14613a165761386d6009602a836020015160038111156113e8576113e8614976565b600554606082015160405163eabe7d9160e01b81526000926001600160a01b03169163eabe7d9191613a4f9130918b9190600401614d0d565b6020604051808303816000875af1158015613a6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a929190614cf4565b90508015613ab057613aa76003602883612861565b92505050610da9565b4260095414613ac557613aa7600a602c611a62565b613ad5600d5483606001516127ba565b60a0840181905260208401826003811115613af257613af2614976565b6003811115613b0357613b03614976565b9052506000905082602001516003811115613b2057613b20614976565b14613b4257613aa76009602e846020015160038111156113e8576113e8614976565b6001600160a01b0386166000908152600e60205260409020546060830151613b6a91906127ba565b60c0840181905260208401826003811115613b8757613b87614976565b6003811115613b9857613b98614976565b9052506000905082602001516003811115613bb557613bb5614976565b14613bd757613aa76009602d846020015160038111156113e8576113e8614976565b8160800151613be461230d565b1015613bf657613aa7600e602f611a62565b60a0820151600d5560c08201516001600160a01b0387166000818152600e60205260409081902092909255606084015191513092600080516020614dec83398151915291613c4691815260200190565b60405180910390a3608082015160608301516040517fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a92992613c88928a92614d31565b60405180910390a1600554608083015160608401516040516351dff98960e01b81523060048201526001600160a01b038a81166024830152604482019390935260648101919091529116906351dff9899060840160006040518083038186803b158015613cf457600080fd5b505afa158015613d08573d6000803e3d6000fd5b50505050613d1a86836080015161370b565b60009695505050505050565b60008083600003613d3c57506000905080611f5a565b6000613d488486614db0565b905083613d558683614d8e565b14613d6857600260009250925050611f5a565b600092509050611f5a565b60008082600003613d8a5750600190506000611f5a565b6000613d968486614d8e565b915091509250929050565b600554604051632fe3f38f60e11b81523060048201526001600160a01b03838116602483015286811660448301528581166064830152608482018590526000928392839290911690635fc7e71e9060a401602060405180830381865afa158015613e0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e339190614cf4565b90508015613e5457613e486003601283612861565b60009250925050614257565b4260095414613e6957613e48600a6016611a62565b42846001600160a01b031663cfa992016040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ea8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ecc9190614cf4565b14613edd57613e48600a6011611a62565b866001600160a01b0316866001600160a01b031603613f0257613e4860066017611a62565b84600003613f1657613e4860076015611a62565b6000198503613f2b57613e4860076014611a62565b600080613f398989896132f4565b90925090508115613f6e57613f60826010811115613f5957613f59614976565b6018611a62565b600094509450505050614257565b60055460405163c488847b60e01b815260009182916001600160a01b039091169063c488847b90613fa79030908c908890600401614d0d565b6040805180830381865afa158015613fc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fe79190614dc7565b909250905081156140565760405162461bcd60e51b815260206004820152603360248201527f4c49515549444154455f434f4d5054524f4c4c45525f43414c43554c4154455f604482015272105353d5539517d4d152569157d19052531151606a1b60648201526084016108e0565b6040516370a0823160e01b81526001600160a01b038b811660048301528291908a16906370a0823190602401602060405180830381865afa15801561409f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140c39190614cf4565b10156141115760405162461bcd60e51b815260206004820152601860248201527f4c49515549444154455f5345495a455f544f4f5f4d554348000000000000000060448201526064016108e0565b6000306001600160a01b038a16036141365761412f308d8d85612a7c565b90506141ac565b60405163b2a02ff160e01b81526001600160a01b038a169063b2a02ff190614166908f908f908790600401614d0d565b6020604051808303816000875af1158015614185573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141a99190614cf4565b90505b80156141f15760405162461bcd60e51b81526020600482015260146024820152731d1bdad95b881cd95a5e9d5c994819985a5b195960621b60448201526064016108e0565b604080516001600160a01b038e811682528d811660208301528183018790528b1660608201526080810184905290517f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb529181900360a00190a16000975092955050505050505b94509492505050565b6000670de0b6b3a7640000614279848460000151614742565b610da99190614d8e565b6000610da98383604051806040016040528060158152602001747375627472616374696f6e20756e646572666c6f7760581b815250614784565b6000806142ca84846147b3565b9050610c53816132dc565b6000610da98383604051806040016040528060118152602001706164646974696f6e206f766572666c6f7760781b8152506147e4565b60055460405163368f515360e21b815260009182916001600160a01b039091169063da3d454c9061434490309088908890600401614d0d565b6020604051808303816000875af1158015614363573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143879190614cf4565b905080156143a45761439c6003600e83612861565b915050610a47565b42600954146143b85761439c600a80611a62565b826143c161230d565b10156143d35761439c600e6009611a62565b6143ff604080516080810190915280600081526020016000815260200160008152602001600081525090565b614408856125a4565b602083018190528282600381111561442257614422614976565b600381111561443357614433614976565b905250600090508151600381111561444d5761444d614976565b146144785761446f60096007836000015160038111156113e8576113e8614976565b92505050610a47565b6144868160200151856128d9565b60408301819052828260038111156144a0576144a0614976565b60038111156144b1576144b1614976565b90525060009050815160038111156144cb576144cb614976565b146144ed5761446f6009600c836000015160038111156113e8576113e8614976565b6144f9600b54856128d9565b606083018190528282600381111561451357614513614976565b600381111561452457614524614976565b905250600090508151600381111561453e5761453e614976565b146145605761446f6009600b836000015160038111156113e8576113e8614976565b604081810180516001600160a01b03881660008181526010602090815290859020928355600a54600190930192909255606080860151600b8190559351855192835292820189905293810191909152918201527f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809060800160405180910390a16145ea858561370b565b600095945050505050565b600080808042600954146146195761460f600a604f611a62565b9590945092505050565b614623338661312b565b905080600c546146339190614d7b565b9150600c548210156146875760405162461bcd60e51b815260206004820181905260248201527f61646420726573657276657320756e6578706563746564206f766572666c6f7760448201526064016108e0565b600c8290556040517fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc5906146c090339084908690614d31565b60405180910390a1600061460f565b60006146e76040518060200160405280600081525090565b6000806146fc670de0b6b3a764000087613d26565b9092509050600082600381111561471557614715614976565b1461473457506040805160208101909152600081529092509050611f5a565b612300818660000151613211565b6000610da983836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f7700000000000000000081525061481e565b600081848411156147a85760405162461bcd60e51b81526004016108e0919061486d565b50610c538385614d68565b60408051602081019091526000815260405180602001604052806147db856000015185614742565b90529392505050565b6000806147f18486614d7b565b905082858210156148155760405162461bcd60e51b81526004016108e0919061486d565b50949350505050565b600083158061482b575082155b1561483857506000610da9565b60006148448486614db0565b9050836148518683614d8e565b1483906148155760405162461bcd60e51b81526004016108e091905b600060208083528351808285015260005b8181101561489a5785810183015185820160400152820161487e565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b03811681146148d057600080fd5b50565b600080604083850312156148e657600080fd5b82356148f1816148bb565b946020939093013593505050565b60006020828403121561491157600080fd5b8135610da9816148bb565b60008060006060848603121561493157600080fd5b833561493c816148bb565b9250602084013561494c816148bb565b929592945050506040919091013590565b60006020828403121561496f57600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b60208101601183106149ae57634e487b7160e01b600052602160045260246000fd5b91905290565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126149db57600080fd5b813567ffffffffffffffff808211156149f6576149f66149b4565b604051601f8301601f19908116603f01168101908282118183101715614a1e57614a1e6149b4565b81604052838152866020858801011115614a3757600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060008060008060c08789031215614a7057600080fd5b8635614a7b816148bb565b95506020870135614a8b816148bb565b945060408701359350606087013567ffffffffffffffff80821115614aaf57600080fd5b614abb8a838b016149ca565b94506080890135915080821115614ad157600080fd5b50614ade89828a016149ca565b92505060a087013560ff81168114614af557600080fd5b809150509295509295509295565b60008060408385031215614b1657600080fd5b8235614b21816148bb565b91506020830135614b31816148bb565b809150509250929050565b6020808252600a90820152691c994b595b9d195c995960b21b604082015260600190565b600181811c90821680614b7457607f821691505b6020821081036131b757634e487b7160e01b600052602260045260246000fd5b6020808252601690820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604082015260600190565b600060208284031215614bd657600080fd5b81518015158114610da957600080fd5b601f8211156118c057600081815260208120601f850160051c81016020861015614c0d5750805b601f850160051c820191505b81811015614c2c57828155600101614c19565b505050505050565b815167ffffffffffffffff811115614c4e57614c4e6149b4565b614c6281614c5c8454614b60565b84614be6565b602080601f831160018114614c975760008415614c7f5750858301515b600019600386901b1c1916600185901b178555614c2c565b600085815260208120601f198616915b82811015614cc657888601518255948401946001909101908401614ca7565b5085821015614ce45787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208284031215614d0657600080fd5b5051919050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b039390931683526020830191909152604082015260600190565b634e487b7160e01b600052601160045260246000fd5b81810381811115610a4757610a47614d52565b80820180821115610a4757610a47614d52565b600082614dab57634e487b7160e01b600052601260045260246000fd5b500490565b8082028115828204841417610a4757610a47614d52565b60008060408385031215614dda57600080fd5b50508051602090910151909290915056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212205f3826bdeb4ef7ece10c0c5d27fc3b017d66fb3b572bb1a930c2a834b1c9082c64736f6c63430008130033

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

000000000000000000000000d11443b079d62700061f7311fc48c40b30bcea910000000000000000000000000b19823ef1f4a6b1f7c52336f428f1a92e9f645e000000000000000000000000000000000000000000a56fa5b99019a5c800000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000008000000000000000000000000665b8b669b199ecf9f2bb5a5636e2e95d31f60b2000000000000000000000000000000000000000000000000000000000000000c466973634c656e6420415045000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046641504500000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : comptroller_ (address): 0xd11443B079D62700061F7311fC48C40B30BCEA91
Arg [1] : interestRateModel_ (address): 0x0B19823EF1F4a6B1f7c52336F428F1a92e9f645E
Arg [2] : initialExchangeRateMantissa_ (uint256): 200000000000000000000000000
Arg [3] : name_ (string): FiscLend APE
Arg [4] : symbol_ (string): fAPE
Arg [5] : decimals_ (uint8): 8
Arg [6] : admin_ (address): 0x665B8B669B199eCf9F2bb5A5636e2e95d31f60b2

-----Encoded View---------------
11 Constructor Arguments found :
Arg [0] : 000000000000000000000000d11443b079d62700061f7311fc48c40b30bcea91
Arg [1] : 0000000000000000000000000b19823ef1f4a6b1f7c52336f428f1a92e9f645e
Arg [2] : 000000000000000000000000000000000000000000a56fa5b99019a5c8000000
Arg [3] : 00000000000000000000000000000000000000000000000000000000000000e0
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000120
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000008
Arg [6] : 000000000000000000000000665b8b669b199ecf9f2bb5a5636e2e95d31f60b2
Arg [7] : 000000000000000000000000000000000000000000000000000000000000000c
Arg [8] : 466973634c656e64204150450000000000000000000000000000000000000000
Arg [9] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [10] : 6641504500000000000000000000000000000000000000000000000000000000


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

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

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