Contract 0x0cf9f29d8705fc8ff1a1ef748aa9cc9070991617 5

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x89e95480e6d747677176cd6ccfa3a7fb14da14e443603ea01f37d828ebe2e6690x608060403319932022-02-03 10:50:48239 days 8 hrs ago0xc333a03e8040cad31993e02615fd1b3f88447d95 IN  Create: ComptrollerV0_040 GLMR0.5103161
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ComptrollerV0_04

Compiler Version
v0.5.16+commit.9c3226ce

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 17 : ComptrollerV0_04.sol
pragma solidity ^0.5.16;

import "../../OTokens/CToken.sol";
import "../../ErrorReporter/ErrorReporter.sol";
import "../../PriceOracle/PriceOracle.sol";
import "../../Comptroller/ComptrollerInterface.sol";
import "../../Comptroller/ComptrollerStorage.sol";
import "../../Comptroller/Unitroller.sol";
import "../../../../Peripheral/ComptrollerPeripherals/RainMaker/RainMakerInterface.sol";
import "../../../../Peripheral/ComptrollerPeripherals/Bouncer/IBouncer.sol";
import "../../../../Peripheral/ComptrollerPeripherals/IComptrollerPeripheral.sol";

interface RegistryForComptrollerV0_04 {
    function deployOToken(address underlying,
        bytes32 contractNameHash,
        bytes calldata params,
        address interestRateModel,
        address admin,
        bytes calldata becomeImplementationData) external returns (address);

    function deployPeripheralContract(bytes32 contractNameHash,
        bytes calldata params,
        address contractAdmin) external returns (address);

    function getPriceForUnderling(address cToken) external view returns (uint256);
}

interface IBouncerForComptroller {
    function isAccountApproved(address account) external view returns (bool);
}

/**
 * @title Ola's Comptroller Contract V0.02
 * @author Ola
 * -- Changes form V0.02 :
 * --- Same as V0.02
 */
contract ComptrollerV0_04 is ComptrollerStorageOlaV0_02, ComptrollerInterface, ComptrollerErrorReporter, ExponentialNoError {
    /// @notice Emitted when an admin supports a market
    event MarketListed(CToken cToken);

    /// @notice Emitted when an account enters a market
    event MarketEntered(CToken cToken, address account);

    /// @notice Emitted when an account exits a market
    event MarketExited(CToken cToken, address account);

    /// @notice Emitted when a collateral factor is changed by admin
    event NewCollateralFactor(CToken cToken, uint oldCollateralFactorMantissa, uint newCollateralFactorMantissa);

    /// @notice Emitted when a liquidation factor is changed by admin
    event NewLiquidationFactor(CToken cToken, uint oldLiquidationFactorMantissa, uint newLiquidationFactorMantissa);

    /// @notice Emitted when liquidation incentive is changed by admin
    /// OLA_ADDITIONS : Added 'cToken' to support 'liquidation incentive per market'
    event NewLiquidationIncentive(CToken ctoken, uint oldLiquidationIncentiveMantissa, uint newLiquidationIncentiveMantissa);

    // OLA_ADDITIONS : This event
    /// @notice Emitted when the Rain Maker is changed
    event NewRainMaker(address oldRainMaker, address newRainMaker);

    // OLA_ADDITIONS : This event
    /// @notice Emitted when the bouncer is changed
    event NewBouncer(address oldBouncer, address newBouncer);

    // OLA_ADDITIONS : This event
    /// @notice Emitted when the min borrow amount is changed
    event NewMinBorrowAmount(uint oldMinBorrowAmount, uint newMinBorrowAmount);

    /// @notice Emitted when pause guardian is changed
    event NewPauseGuardian(address oldPauseGuardian, address newPauseGuardian);

    /// @notice Emitted when an action is paused globally
    event ActionPaused(string action, bool pauseState);

    /// @notice Emitted when an action is paused on a market
    event ActionPaused(CToken cToken, string action, bool pauseState);

    /// @notice Emitted when borrow cap for a cToken is changed
    event NewBorrowCap(CToken indexed cToken, uint newBorrowCap);

    /// @notice Emitted when borrow cap guardian is changed
    event NewBorrowCapGuardian(address oldBorrowCapGuardian, address newBorrowCapGuardian);

    /// @notice Emitted when admin bank address is changed
    event NewAdminBankAddress(address oldAdminBankAddress, address newAdminBankAddress);

    /// @notice Emitted when active collateral cap for a cToken is changed
    event NewActiveCollateralCap(CToken indexed cToken, uint newActiveCollateralCap);

    /// @notice Emitted when active collateral usage for a cToken is changed
    event ActiveCollateralUsageChange(CToken indexed cToken, uint oldCollateralUsage, uint newCollateralUsage);

    // OLA_ADDITIONS : This event
    /// @notice Emitted when the 'Limit Minting' flag is changed
    event LimitMintingFlagChanged(bool newValue);

    // OLA_ADDITIONS : This event
    /// @notice Emitted when the 'Limit Borrowing' flag is changed
    event LimitBorrowingFlagChanged(bool newValue);

    // No collateralFactorMantissa may exceed this value
    uint internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9

    // No liquidationFactorMantissa may exceed this value
    uint internal constant liquidationFactorMaxMantissa = 0.9e18; // 0.9

    // liquidationIncentiveMantissa of any market must be strictly greater than this value
    // OLA_ADDITIONS: This field
    uint internal constant liquidationIncentiveMinMantissa = 1.05e18; // 1.05

    // liquidationIncentiveMantissa of any market must not exceed this value
    // OLA_ADDITIONS: This field
    uint internal constant liquidationIncentiveMaxMantissa = 1.3e18; // 1.3

    // Hard coded value to limit amount of asset in a single LN
    // OLA_ADDITIONS: This field
    uint internal constant maxAllowedAssets = 25;

    // Hard coded value for the liquidation close factor
    // OLA_ADDITIONS: This field
    uint internal constant fixedCloseFactorMantissa = 0.5e18;

    constructor() public {
        admin = msg.sender;
    }

    /*** Registry ***/

    function getRegistry() public view returns (address) {
        return address(registry);
    }

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

    /**
     * @notice Returns the assets an account has entered
     * @param account The address of the account to pull assets for
     * @return A dynamic list with the assets the account has entered
     */
    function getAssetsIn(address account) external view returns (CToken[] memory) {
        CToken[] memory assetsIn = accountAssets[account];

        return assetsIn;
    }

    /**
     * @notice Returns whether the given account is entered in the given asset
     * @param account The address of the account to check
     * @param cToken The cToken to check
     * @return True if the account is in the asset, otherwise false.
     */
    function checkMembership(address account, CToken cToken) external view returns (bool) {
        return markets[address(cToken)].accountMembership[account];
    }

    /**
     * @notice Add assets to be included in account liquidity calculation
     * @param cTokens The list of addresses of the cToken markets to be enabled
     * @return Success indicator for whether each corresponding market was entered
     */
    function enterMarkets(address[] memory cTokens) public returns (uint[] memory) {
        uint len = cTokens.length;

        uint[] memory results = new uint[](len);
        for (uint i = 0; i < len; i++) {
            CToken cToken = CToken(cTokens[i]);

            // OLA_ADDITIONS : Emitting Failure events
            Error error = addToMarketInternal(cToken, msg.sender);
            if (error != Error.NO_ERROR) {
                fail(error, FailureInfo.ENTER_MARKET_NOT_ALLOWED);
            }

            results[i] = uint(error);
        }

        return results;
    }

    /**
     * @notice Checks if the account should be allowed to activate this additional amount of collateral.
     * @param cToken The cToken to verify the active collateral cap against
     * @param market The market to verify the active collateral cap against (assumes the given market is listed)
     * @param cTokensToActivate The amount of cTokens being activated as collateral
     * @return 0 if the activation is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)
     */
    function collateralActivationAllowed(CToken cToken, Market memory market, uint256 cTokensToActivate) internal view returns (uint) {
        uint256 activeCollateralUSDCap = market.activeCollateralUSDCap;
        uint256 activeCTokenUsage = market.activeCollateralCTokenUsage;

        // 0 Means "No Cap"
        if (activeCollateralUSDCap == 0) {
            return uint(Error.NO_ERROR);
        }

        // No amount ? no problem
        if (cTokensToActivate == 0) {
            return uint(Error.NO_ERROR);
        }

        // Calculate new usage USD value
        uint newCTokenUsage = add_(activeCTokenUsage, cTokensToActivate);

        uint exchangeRateMantissa = cToken.exchangeRateStored();

        Exp memory exchangeRate = Exp({mantissa: exchangeRateMantissa});

        // Get the normalized price of the asset
        uint oraclePriceMantissa = getUnderlyingPriceForCToken(address(cToken));

        if (oraclePriceMantissa == 0) {
            return uint(Error.PRICE_ERROR);
        }

        Exp memory oraclePrice = Exp({mantissa: oraclePriceMantissa});

        uint newUnderlyingUsage = mul_(newCTokenUsage, exchangeRate);
        uint newUsageValueInUsd = mul_(newUnderlyingUsage, oraclePrice);

        // Is it within the allowed cap ?
        if (newUsageValueInUsd <= activeCollateralUSDCap) {
            // All good here
            return uint(Error.NO_ERROR);
        } else {
            return uint(Error.TOO_MUCH_COLLATERAL_ACTIVATION);
        }
    }

    /**
     * @notice Increases the underlying actively used as collateral.
     */
    function increaseActiveCollateralUsed(Market storage market, uint256 cTokensActivated, CToken cToken) internal {
        uint oldCTokenUsage = market.activeCollateralCTokenUsage;
        uint newCTokenUsage = add_(oldCTokenUsage, cTokensActivated);
        market.activeCollateralCTokenUsage = newCTokenUsage;
        emit ActiveCollateralUsageChange(cToken, oldCTokenUsage, newCTokenUsage);
    }

    /**
     * @notice Reduces the underlying actively used as collateral.
    */
    function reduceActiveCollateralUsed(Market storage market, uint256 cTokensDeactivated, CToken cToken) internal {
        uint oldCTokenUsage = market.activeCollateralCTokenUsage;
        uint newCTokenUsage = sub_(oldCTokenUsage, cTokensDeactivated);
        market.activeCollateralCTokenUsage = newCTokenUsage;
        emit ActiveCollateralUsageChange(cToken, oldCTokenUsage, newCTokenUsage);
    }

    /**
     * @notice Add the market to the borrower's "assets in" for liquidity calculations
     * @param cToken The market to enter
     * @param borrower The address of the account to modify
     * @return Success indicator for whether the market was entered
     */
    function addToMarketInternal(CToken cToken, address borrower) internal returns (Error) {
        Market storage marketToJoin = markets[address(cToken)];

        if (!marketToJoin.isListed) {
            // market is not listed, cannot join
            return Error.MARKET_NOT_LISTED;
        }

        if (marketToJoin.accountMembership[borrower] == true) {
            // already joined
            return Error.NO_ERROR;
        }


        // NOTE : This function call will
        uint cTokensToBeActivatedAsCollateral = cToken.balanceOf(borrower);
        uint collateralActivationError = collateralActivationAllowed(cToken, marketToJoin, cTokensToBeActivatedAsCollateral);

        // OLA_ADDITIONS : This test
        if (collateralActivationError != uint(Error.NO_ERROR)) {
            return Error(collateralActivationError);
        }

        // Increase active collateral used
        increaseActiveCollateralUsed(marketToJoin, cTokensToBeActivatedAsCollateral, cToken);

        // survived the gauntlet, add to list
        // NOTE: we store these somewhat redundantly as a significant optimization
        //  this avoids having to iterate through the list for the most common use cases
        //  that is, only when we need to perform liquidity checks
        //  and not whenever we want to check if an account is in a particular market
        marketToJoin.accountMembership[borrower] = true;
        accountAssets[borrower].push(cToken);

        emit MarketEntered(cToken, borrower);

        return Error.NO_ERROR;
    }

    /**
     * @notice Removes asset from sender's account liquidity calculation
     * @dev Sender must not have an outstanding borrow balance in the asset,
     *  or be providing necessary collateral for an outstanding borrow.
     * @param cTokenAddress The address of the asset to be removed
     * @return Whether or not the account successfully exited the market
     */
    function exitMarket(address cTokenAddress) external returns (uint) {
        CToken cToken = CToken(cTokenAddress);
        /* Get sender tokensHeld and amountOwed underlying from the cToken */
        (uint oErr, uint tokensHeld, uint amountOwed, ) = cToken.getAccountSnapshot(msg.sender);
        require(oErr == 0, "Snapshot failed"); // semi-opaque error code

        /* Fail if the sender has a borrow balance */
        if (amountOwed != 0) {
            return fail(Error.NONZERO_BORROW_BALANCE, FailureInfo.EXIT_MARKET_BALANCE_OWED);
        }

        /* Fail if the sender is not permitted to redeem all of their tokens */
        uint allowed = redeemAllowedInternal(cTokenAddress, msg.sender, tokensHeld);
        if (allowed != 0) {
            return failOpaque(Error.REJECTION, FailureInfo.EXIT_MARKET_REJECTION, allowed);
        }

        Market storage marketToExit = markets[cTokenAddress];

        /* Return true if the sender is not already ‘in’ the market */
        if (marketToExit.accountMembership[msg.sender]) {
            uint err = exitMarketInternal(marketToExit, address(cToken), msg.sender);

            // If no err, reduce
            if (err != uint(Error.NO_ERROR)) {
                return err;
            }

            // Reduce the active collateral usage - Only if removal from market
            reduceActiveCollateralUsed(marketToExit, tokensHeld, cToken);
            return uint(Error.NO_ERROR);
        }

        return uint(Error.NO_ERROR);
    }

    /**
     * @notice Checks if the account is done (no supply and no borrow at all) in the given market
     * and if so, exits the market for the user.
     * @dev .
     * @param cTokenAddress The address of the asset to be removed
     * @param account The account which would exit the market (if done with it)
     * @return If done - returns the result of 'exitMarketInternal' and if not done - "No error".
     */
    function exitMarketIfDone(address cTokenAddress, address account) internal returns (uint) {
        CToken cToken = CToken(cTokenAddress);
        (uint oErr, uint tokensHeld, uint amountOwed, ) = cToken.getAccountSnapshot(account);
        require(oErr == 0, "Snapshot failed"); // semi-opaque error code

        if (tokensHeld == 0 && amountOwed == 0) {
            Market storage marketToExit = markets[cTokenAddress];

            /* Return true if the sender is not already ‘in’ the market */
            if (marketToExit.accountMembership[account]) {
                return exitMarketInternal(marketToExit, cTokenAddress, account);
            } else {
                return uint(Error.NO_ERROR);
            }
        } else {
            return uint(Error.NO_ERROR);
        }
    }

    /**
      * @notice Performs the state change that Removes asset from sender's account liquidity calculation
      * @notice This function will revert if inconsistencies are found within the 'accountsAssets' mechanism
      * @dev This function should only be called after ensuring the user can exit the market (e.g no outstanding
      * debts or active collateral) AND only for users who are actually in the market.
      * @param cTokenAddress The address of the asset to be removed
      * @param account The account which would exit the market
      * @return Whether or not the account successfully exited the market
     */
    function exitMarketInternal(Market storage marketToExit, address cTokenAddress, address account) internal returns (uint) {
        /* Set cToken account membership to false */
        delete marketToExit.accountMembership[account];

        /* Delete cToken from the account’s list of assets */
        // load into memory for faster iteration
        CToken[] memory userAssetList = accountAssets[account];
        uint len = userAssetList.length;
        uint assetIndex = len;
        for (uint i = 0; i < len; i++) {
            if (userAssetList[i] == CToken(cTokenAddress)) {
                assetIndex = i;
                break;
            }
        }

        // We *must* have found the asset in the list or our redundant data structure is broken
        require(assetIndex < len);

        // copy last item in list to location of item to be removed, reduce length by 1
        CToken[] storage storedList = accountAssets[account];
        storedList[assetIndex] = storedList[storedList.length - 1];
        storedList.length--;

        emit MarketExited(CToken(cTokenAddress), account);

        return uint(Error.NO_ERROR);
    }

    /*** Policy Hooks ***/

    /**
     * @notice Checks if the account should be allowed to mint tokens in the given market
     * @param cToken The market to verify the mint against
     * @param minter The account which would get the minted tokens
     * @param mintAmount The amount of underlying being supplied to the market in exchange for tokens
     * @return 0 if the mint is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)
     */
    function mintAllowed(address cToken, address minter, uint mintAmount) external returns (uint) {
        // Pausing is a very serious situation - we revert to sound the alarms
        require(!mintGuardianPaused[cToken], "paused");

        // Shh - currently unused
        minter;
        mintAmount;

        if (!markets[cToken].isListed) {
            return uint(Error.MARKET_NOT_LISTED);
        }

        // OLA_ADDITIONS : Can limit minting
        // If borrowing is limited the account has to be approved
        if (limitMinting && !isAccountApprovedInternal(minter)) {
            return uint (Error.NOT_APPROVED_TO_MINT);
        }

        // Keep the flywheel moving
        if (hasRainMaker()) {
            RainMakerInterface(rainMaker).updateCompSupplyIndex(cToken);
            RainMakerInterface(rainMaker).distributeSupplierComp(cToken, minter);
        }

        return uint(Error.NO_ERROR);
    }

    /**
     * @notice Validates mint and reverts on rejection. May emit logs.
     * @param cToken Asset being minted
     * @param minter The address minting the tokens
     * @param actualMintAmount The amount of the underlying asset being minted
     * @param mintTokens The number of tokens being minted
     */
    function mintVerify(address cToken, address minter, uint actualMintAmount, uint mintTokens) external {
        // OLA_ADDITIONS : All from here
        // only cTokens may call 'mintVerify'
        require(msg.sender == cToken, "!cToken");

        // Get market + safety
        Market storage marketToMintIn = markets[address(cToken)];
        require(marketToMintIn.isListed, "!listed");

        // We only care about active collateral caps if the minter is part of the market
        if (marketToMintIn.accountMembership[minter]) {
            // Is activating that much new collateral allowed ?
            uint collateralActivationError = collateralActivationAllowed(CToken(cToken), marketToMintIn, mintTokens);
            require(collateralActivationError == uint(Error.NO_ERROR), "activation not allowed");

            // All seems to be ok, increase the usage count
            increaseActiveCollateralUsed(marketToMintIn, mintTokens, CToken(cToken));
        }
    }

    /**
     * @notice Checks if the account should be allowed to redeem tokens in the given market
     * @param cToken The market to verify the redeem against
     * @param redeemer The account which would redeem the tokens
     * @param redeemTokens The number of cTokens to exchange for the underlying asset in the market
     * @return 0 if the redeem is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)
     */
    function redeemAllowed(address cToken, address redeemer, uint redeemTokens) external returns (uint) {
        uint allowed = redeemAllowedInternal(cToken, redeemer, redeemTokens);
        if (allowed != uint(Error.NO_ERROR)) {
            return allowed;
        }

        if (hasRainMaker()) {
            // Keep the flywheel moving
            RainMakerInterface(rainMaker).updateCompSupplyIndex(cToken);
            RainMakerInterface(rainMaker).distributeSupplierComp(cToken, redeemer);
        }

        return uint(Error.NO_ERROR);
    }

    function redeemAllowedInternal(address cToken, address redeemer, uint redeemTokens) internal view returns (uint) {
        if (!markets[cToken].isListed) {
            return uint(Error.MARKET_NOT_LISTED);
        }

        /* If the redeemer is not 'in' the market, then we can bypass the liquidity check */
        if (!markets[cToken].accountMembership[redeemer]) {
            return uint(Error.NO_ERROR);
        }

        /* Otherwise, perform a hypothetical liquidity check to guard against shortfall */
        // OLA_ADDITIONS : added 'true' to keep using the default 'collateralFactor'
        (Error err, , uint shortfall, ) = getHypotheticalAccountLiquidityInternal(redeemer, CToken(cToken), redeemTokens, 0, true);
        if (err != Error.NO_ERROR) {
            return uint(err);
        }
        if (shortfall > 0) {
            return uint(Error.INSUFFICIENT_LIQUIDITY);
        }

        return uint(Error.NO_ERROR);
    }

    /**
     * @notice Validates redeem and reverts on rejection. May emit logs.
     * @param cToken Asset being redeemed
     * @param redeemer The address redeeming the tokens
     * @param redeemAmount The amount of the underlying asset being redeemed
     * @param redeemTokens The number of tokens being redeemed
     */
    function redeemVerify(address cToken, address redeemer, uint redeemAmount, uint redeemTokens) external {
        // Require tokens is zero or amount is also zero
        if (redeemTokens == 0 && redeemAmount > 0) {
            revert("redeemTokens zero");
        }

        // OLA_ADDITIONS : All from here
        // only cTokens may call 'redeemVerify'
        require(msg.sender == cToken, "!cToken");

        // Get market + safety
        Market storage marketToRedeemFrom = markets[address(cToken)];
        require(marketToRedeemFrom.isListed, "!listed");

        // We only care about active collateral caps if the minter is in the market
        if (marketToRedeemFrom.accountMembership[redeemer]) {
            // Some cleanups, if the user is done with this market
            require(exitMarketIfDone(cToken, redeemer) == uint(Error.NO_ERROR), "Exit failure");

            // The redeemer is reducing the collateral value in a market they are part of.
            // let's reduce the used active collateral.
            reduceActiveCollateralUsed(marketToRedeemFrom, redeemTokens, CToken(cToken));
        }
    }

    /**
     * @notice Checks if the account should be allowed to borrow the underlying asset of the given market
     * @param cToken The market to verify the borrow against
     * @param borrower The account which would borrow the asset
     * @param borrowAmount The amount of underlying the account would borrow
     * @return 0 if the borrow is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)
     */
    function borrowAllowed(address cToken, address borrower, uint borrowAmount) external returns (uint) {
        // Pausing is a very serious situation - we revert to sound the alarms
        require(!borrowGuardianPaused[cToken], "paused");


        if (!markets[cToken].isListed) {
            return uint(Error.MARKET_NOT_LISTED);
        }

        // OLA_ADDITIONS : Can limit borrow
        // If borrowing is limited the account has to be approved
        if (limitBorrowing && !isAccountApprovedInternal(borrower)) {
            return uint (Error.NOT_APPROVED_TO_BORROW);
        }

        if (!markets[cToken].accountMembership[borrower])
{
            // only cTokens may call borrowAllowed if borrower not in market
            require(msg.sender == cToken, "!cToken");

            // attempt to add borrower to the market
            Error err = addToMarketInternal(CToken(msg.sender), borrower);
            if (err != Error.NO_ERROR) {
                return uint(err);
            }

            // it should be impossible to break the important invariant
            assert(markets[cToken].accountMembership[borrower]);
        }

        if (getUnderlyingPriceForCToken(cToken) == 0) {
            return uint(Error.PRICE_ERROR);
        }

        uint borrowCap = borrowCaps[cToken];
        // Borrow cap of 0 corresponds to unlimited borrowing
        if (borrowCap != 0) {
            uint totalBorrows = CToken(cToken).totalBorrows();
            uint nextTotalBorrows = add_(totalBorrows, borrowAmount);
            require(nextTotalBorrows < borrowCap, "Borrow cap reached");
        }

        // OLA_ADDITIONS : added 'true' to keep using the default 'collateralFactor'
        (Error err, , uint shortfall, uint borrowAmountUsd) = getHypotheticalAccountLiquidityInternal(borrower, CToken(cToken), 0, borrowAmount, true);
        if (err != Error.NO_ERROR) {
            return uint(err);
        }
        if (shortfall > 0) {
            return uint(Error.INSUFFICIENT_LIQUIDITY);
        }

        // OLA_ADDITIONS : Adds 'min borrow usd' requirement
        if (borrowAmountUsd < minBorrowAmountUsd) {
            return uint(Error.TOO_LITTLE_BORROW);
        }

        if (hasRainMaker()) {
            // Keep the flywheel moving
            uint borrowIndex = CToken(cToken).borrowIndex();
            RainMakerInterface(rainMaker).updateCompBorrowIndex(cToken, borrowIndex);
            RainMakerInterface(rainMaker).distributeBorrowerComp(cToken, borrower, borrowIndex);
        }

        return uint(Error.NO_ERROR);
    }

    /**
     * @notice Validates borrow and reverts on rejection. May emit logs.
     * @param cToken Asset whose underlying is being borrowed
     * @param borrower The address borrowing the underlying
     * @param borrowAmount The amount of the underlying asset requested to borrow
     */
    function borrowVerify(address cToken, address borrower, uint borrowAmount) external {
        // Shh - currently unused
        cToken;
        borrower;
        borrowAmount;

        // Uncomment if adding logic
        // Only cTokens may call 'borrowVerify'
        // require(msg.sender == cToken, "sender must be cToken");

        // Shh - we don't ever want this hook to be marked pure
        if (false) {
            maxAssets = maxAssets;
        }
    }

    /**
     * @notice Checks if the account should be allowed to repay a borrow in the given market
     * @param cToken The market to verify the repay against
     * @param payer The account which would repay the asset
     * @param borrower The account which would borrowed the asset
     * @param repayAmount The amount of the underlying asset the account would repay
     * @return 0 if the repay is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)
     */
    function repayBorrowAllowed(
        address cToken,
        address payer,
        address borrower,
        uint repayAmount) external returns (uint) {
        // Shh - currently unused
        payer;
        borrower;
        repayAmount;

        if (!markets[cToken].isListed) {
            return uint(Error.MARKET_NOT_LISTED);
        }

        if (hasRainMaker()) {
            // Keep the flywheel moving
            uint borrowIndex = CToken(cToken).borrowIndex();
            RainMakerInterface(rainMaker).updateCompBorrowIndex(cToken, borrowIndex);
            RainMakerInterface(rainMaker).distributeBorrowerComp(cToken, borrower, borrowIndex);
        }

        return uint(Error.NO_ERROR);
    }

    /**
     * @notice Validates repayBorrow and reverts on rejection. May emit logs.
     * @param cToken Asset being repaid
     * @param payer The address repaying the borrow
     * @param borrower The address of the borrower
     * @param actualRepayAmount The amount of underlying being repaid
     */
    function repayBorrowVerify(
        address cToken,
        address payer,
        address borrower,
        uint actualRepayAmount,
        uint borrowerIndex) external {

        // Only cTokens may call 'repayBorrowVerify'
        require(msg.sender == cToken, "!cToken");

        // Some cleanups, if the user is done with this market
        require(exitMarketIfDone(cToken, borrower) == uint(Error.NO_ERROR), "Exit failure");
    }

    /**
     * @notice Checks if the liquidation should be allowed to occur
     * @param cTokenBorrowed Asset which was borrowed by the borrower
     * @param cTokenCollateral Asset which was used as collateral and will be seized
     * @param liquidator The address repaying the borrow and seizing the collateral
     * @param borrower The address of the borrower
     * @param repayAmount The amount of underlying being repaid
     */
    function liquidateBorrowAllowed(
        address cTokenBorrowed,
        address cTokenCollateral,
        address liquidator,
        address borrower,
        uint repayAmount) external returns (uint) {
        // Shh - currently unused
        liquidator;

        if (!markets[cTokenBorrowed].isListed || !markets[cTokenCollateral].isListed) {
            return uint(Error.MARKET_NOT_LISTED);
        }

        /* The borrower must have shortfall in order to be liquidateable */
        // OLA_ADDITIONS : Use liquidation factor for liquidation calculation
        (Error err, , uint shortfall) = getAccountLiquidityInternal(borrower, false);
        if (err != Error.NO_ERROR) {
            return uint(err);
        }
        if (shortfall == 0) {
            return uint(Error.INSUFFICIENT_SHORTFALL);
        }

        /* The liquidator may not repay more than what is allowed by the closeFactor */
        uint borrowBalance = CToken(cTokenBorrowed).borrowBalanceStored(borrower);
        // OLA_ADDITIONS : Using the constant value instead of the storage one ('closeFactorMantissa')
        uint maxClose = mul_ScalarTruncate(Exp({mantissa: fixedCloseFactorMantissa}), borrowBalance);
        if (repayAmount > maxClose) {
            return uint(Error.TOO_MUCH_REPAY);
        }

        return uint(Error.NO_ERROR);
    }

    /**
     * @notice Validates liquidateBorrow and reverts on rejection. May emit logs.
     * @param cTokenBorrowed Asset which was borrowed by the borrower
     * @param cTokenCollateral Asset which was used as collateral and will be seized
     * @param liquidator The address repaying the borrow and seizing the collateral
     * @param borrower The address of the borrower
     * @param actualRepayAmount The amount of underlying being repaid
     */
    function liquidateBorrowVerify(
        address cTokenBorrowed,
        address cTokenCollateral,
        address liquidator,
        address borrower,
        uint actualRepayAmount,
        uint seizeTokens) external {
        // Shh - currently unused
        cTokenBorrowed;
        cTokenCollateral;
        liquidator;
        borrower;
        actualRepayAmount;
        seizeTokens;

        // Uncomment if adding logic
        // Only cTokens may call 'liquidateBorrowVerify'
        // require(msg.sender == cToken, "sender must be cToken");

        // Shh - we don't ever want this hook to be marked pure
        if (false) {
            maxAssets = maxAssets;
        }
    }

    /**
     * @notice Checks if the seizing of assets should be allowed to occur
     * @param cTokenCollateral Asset which was used as collateral and will be seized
     * @param cTokenBorrowed Asset which was borrowed by the borrower
     * @param liquidator The address repaying the borrow and seizing the collateral
     * @param borrower The address of the borrower
     * @param seizeTokens The number of collateral tokens to seize
     */
    function seizeAllowed(
        address cTokenCollateral,
        address cTokenBorrowed,
        address liquidator,
        address borrower,
        uint seizeTokens) external returns (uint) {
        // OLA_ADDITIONS : Preventing LN admin from stopping liquidations (By removing the setter for the flag)
        // Pausing is a very serious situation - we revert to sound the alarms
        // require(!seizeGuardianPaused, "seize is paused");

        // Shh - currently unused
        seizeTokens;

        if (!markets[cTokenCollateral].isListed || !markets[cTokenBorrowed].isListed) {
            return uint(Error.MARKET_NOT_LISTED);
        }

        if (CToken(cTokenCollateral).comptroller() != CToken(cTokenBorrowed).comptroller()) {
            return uint(Error.COMPTROLLER_MISMATCH);
        }

        if (hasRainMaker()) {
            // Keep the flywheel moving
            RainMakerInterface(rainMaker).updateCompSupplyIndex(cTokenCollateral);
            RainMakerInterface(rainMaker).distributeSupplierComp(cTokenCollateral, borrower);
            RainMakerInterface(rainMaker).distributeSupplierComp(cTokenCollateral, liquidator);
        }

        return uint(Error.NO_ERROR);
    }

    /**
     * @notice Validates seize and reverts on rejection. May emit logs.
     * @param cTokenCollateral Asset which was used as collateral and will be seized
     * @param cTokenBorrowed Asset which was borrowed by the borrower
     * @param liquidator The address repaying the borrow and seizing the collateral
     * @param borrower The address of the borrower
     * @param seizeTokens The number of collateral tokens to seize
     */
    function seizeVerify(
        address cTokenCollateral,
        address cTokenBorrowed,
        address liquidator,
        address borrower,
        uint seizeTokens) external {
        // Shh - currently unused
        cTokenCollateral;
        cTokenBorrowed;
        liquidator;
        borrower;
        seizeTokens;

        // Uncomment if adding logic
        // Only cTokens may call 'seizeVerify'
        // require(msg.sender == cToken, "sender must be cToken");

        // Shh - we don't ever want this hook to be marked pure
        if (false) {
            maxAssets = maxAssets;
        }
    }

    /**
     * @notice Checks if the account should be allowed to transfer tokens in the given market
     * @param cToken The market to verify the transfer against
     * @param src The account which sources the tokens
     * @param dst The account which receives the tokens
     * @param transferTokens The number of cTokens to transfer
     * @return 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol)
     */
    function transferAllowed(address cToken, address src, address dst, uint transferTokens) external returns (uint) {
        // Pausing is a very serious situation - we revert to sound the alarms
        require(!transferGuardianPaused, "transfer paused");

        // Currently the only consideration is whether or not
        //  the src is allowed to redeem this many tokens
        uint allowed = redeemAllowedInternal(cToken, src, transferTokens);
        if (allowed != uint(Error.NO_ERROR)) {
            return allowed;
        }

        if (hasRainMaker()) {
            // Keep the flywheel moving
            RainMakerInterface(rainMaker).updateCompSupplyIndex(cToken);
            RainMakerInterface(rainMaker).distributeSupplierComp(cToken, src);
            RainMakerInterface(rainMaker).distributeSupplierComp(cToken, dst);
        }

        return uint(Error.NO_ERROR);
    }

    /**
     * @notice Validates transfer and reverts on rejection. May emit logs.
     * IMPORTANT : This function is also called from a cToken's 'seizeInternal', so, it is
     *             imperative to make sure that any change to this function is in line with
     *             the logic requirements of 'seizeInternal'.
     * @param cToken Asset being transferred
     * @param src The account which sources the tokens
     * @param dst The account which receives the tokens
     * @param transferTokens The number of cTokens to transfer
     */
    function transferVerify(address cToken, address src, address dst, uint transferTokens) external {
        // OLA_ADDITIONS : All from here
        // only cTokens may call 'transferVerify'
        require(msg.sender == cToken, "!cToken");

        // Get market + safety
        Market storage marketToTransferIn = markets[address(cToken)];
        require(marketToTransferIn.isListed, "!listed");

        bool srcMembership = marketToTransferIn.accountMembership[src];
        bool dstMembership = marketToTransferIn.accountMembership[dst];

        // If no side is in the market, the active collateral is not changed.
        // If both of them are in the market, the active collateral stays the same.
        if (srcMembership == dstMembership) {
            return;
        } else if (srcMembership) {
            // This is an easy one, active collateral usage only decreases
            return reduceActiveCollateralUsed(marketToTransferIn, transferTokens, CToken(cToken));
        } else if (dstMembership) {
            // This is a complex one. The dst might not be able to receive the transferred cTokens if
            // it will exceed the allowed active collateral cap.
            // So, let's check whether activating that much new collateral is allowed.
            uint collateralActivationError = collateralActivationAllowed(CToken(cToken), marketToTransferIn, transferTokens);
            require(collateralActivationError == uint(Error.NO_ERROR), "Collateral activation is not allowed");

            // All seems to be ok, increase the usage count
            increaseActiveCollateralUsed(marketToTransferIn, transferTokens, CToken(cToken));
        }
    }

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

    /**
     * @dev Local vars for avoiding stack-depth limits in calculating account liquidity.
     *  Note that `cTokenBalance` is the number of cTokens the account owns in the market,
     *  whereas `borrowBalance` is the amount of underlying that the account has borrowed.
     */
    struct AccountLiquidityLocalVars {
        uint sumCollateral;
        uint sumBorrowPlusEffects;
        uint cTokenBalance;
        uint borrowBalance;
        uint exchangeRateMantissa;
        uint oraclePriceMantissa;
        // OLA_ADDITIONS : Renamed from 'collateralFactor' to 'collateralOrLiquidationFactor'
        Exp collateralOrLiquidationFactor;
        Exp exchangeRate;
        Exp oraclePrice;
        Exp tokensToDenom;

        // OLA_ADDITIONS : Added 'borrowAmountUsd' for "min borrow usd check"
        uint borrowAmountUsd;
    }

    /**
     * @notice Determine the current account liquidity wrt collateral requirements
     * @return (possible error code (semi-opaque),
                account liquidity in excess of collateral requirements,
     *          account shortfall below collateral requirements)
     */
    function getAccountLiquidity(address account) public view returns (uint, uint, uint) {
        // OLA_ADDITIONS : added 'true' to keep using the default 'collateralFactor'
        (Error err, uint liquidity, uint shortfall, ) = getHypotheticalAccountLiquidityInternal(account, CToken(0), 0, 0, true);

        return (uint(err), liquidity, shortfall);
    }

    /**
     * OLA ADDITIONS : This function
     * @notice Determine the current account liquidity wrt liquidation requirements
     * @return (possible error code (semi-opaque),
                account liquidity in excess of liquidation requirements,
     *          account shortfall below liquidation requirements)
     */
    function getAccountLiquidityByLiquidationFactor(address account) public view returns (uint, uint, uint) {
        (Error err, uint liquidity, uint shortfall, ) = getHypotheticalAccountLiquidityInternal(account, CToken(0), 0, 0, false);

        return (uint(err), liquidity, shortfall);
    }

    /**
     * @notice Determine the current account liquidity wrt collateral requirements
     * @return (possible error code,
                account liquidity in excess of collateral requirements,
     *          account shortfall below collateral requirements)
     */
    function getAccountLiquidityInternal(address account, bool useCollateralFactor) internal view returns (Error, uint, uint) {
        // OLA_ADDITIONS : added 'useCollateralFactor' + changed from direct 'return' to 'de-construct and return'
        (Error err, uint liquidity, uint shortfall, ) = getHypotheticalAccountLiquidityInternal(account, CToken(0), 0, 0, useCollateralFactor);
        return (err, liquidity, shortfall);
    }

    /**
     * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed
     * @param cTokenModify The market to hypothetically redeem/borrow in
     * @param account The account to determine liquidity for
     * @param redeemTokens The number of tokens to hypothetically redeem
     * @param borrowAmount The amount of underlying to hypothetically borrow
     * @return (possible error code (semi-opaque),
                hypothetical account liquidity in excess of collateral requirements,
     *          hypothetical account shortfall below collateral requirements)
     */
    function getHypotheticalAccountLiquidity(
        address account,
        address cTokenModify,
        uint redeemTokens,
        uint borrowAmount) public view returns (uint, uint, uint) {
        // OLA_ADDITIONS : added 'true' to keep using the default 'collateralFactor'
        (Error err, uint liquidity, uint shortfall, ) = getHypotheticalAccountLiquidityInternal(account, CToken(cTokenModify), redeemTokens, borrowAmount, true);
        return (uint(err), liquidity, shortfall);
    }

    /**
     * OLA_ADDITIONS : This function
     * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed
     * @param cTokenModify The market to hypothetically redeem/borrow in
     * @param account The account to determine liquidity for
     * @param redeemTokens The number of tokens to hypothetically redeem
     * @param borrowAmount The amount of underlying to hypothetically borrow
     * @return (possible error code (semi-opaque),
                hypothetical account liquidity in excess of liquidation requirements,
     *          hypothetical account shortfall below liquidation requirements)
     */
    function getHypotheticalAccountLiquidityByLiquidationFactor(
        address account,
        address cTokenModify,
        uint redeemTokens,
        uint borrowAmount) public view returns (uint, uint, uint) {
        (Error err, uint liquidity, uint shortfall, ) = getHypotheticalAccountLiquidityInternal(account, CToken(cTokenModify), redeemTokens, borrowAmount, false);
        return (uint(err), liquidity, shortfall);
    }

    /**
     * @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed
     * @param cTokenModify The market to hypothetically redeem/borrow in
     * @param account The account to determine liquidity for
     * @param redeemTokens The number of tokens to hypothetically redeem
     * @param borrowAmount The amount of underlying to hypothetically borrow
     * @param useCollateralFactor True - use the "default" 'collateralFactorMantissa', False - use 'liquidationFactorMantissa'
     * @dev Note that we calculate the exchangeRateStored for each collateral cToken using stored data,
     *  without calculating accumulated interest.
     * @return (possible error code,
                hypothetical account liquidity in excess of collateral requirements,
     *          hypothetical account shortfall below collateral requirements,
     *          USD value of the given borrowAmount)
     */
    function getHypotheticalAccountLiquidityInternal(
        address account,
        CToken cTokenModify,
        uint redeemTokens,
        uint borrowAmount,
        // OLA_ADDITIONS : added 'useCollateralFactor'
        bool useCollateralFactor) internal view returns (Error, uint, uint, uint) {

        AccountLiquidityLocalVars memory vars; // Holds all our calculation results
        uint oErr;

        // For each asset the account is in
        CToken[] memory assets = accountAssets[account];
        for (uint i = 0; i < assets.length; i++) {
            CToken asset = assets[i];

            // Read the balances and exchange rate from the cToken
            (oErr, vars.cTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = asset.getAccountSnapshot(account);
            if (oErr != 0) { // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades
                return (Error.SNAPSHOT_ERROR, 0, 0, 0);
            }

            // OLA_ADDITIONS : Added the distinction between using collateralFactorMantissa and liquidationFactorMantissa
            if (useCollateralFactor) {
                vars.collateralOrLiquidationFactor = Exp({mantissa: markets[address(asset)].collateralFactorMantissa});
            } else {
                vars.collateralOrLiquidationFactor = Exp({mantissa: markets[address(asset)].liquidationFactorMantissa});
            }

            vars.exchangeRate = Exp({mantissa: vars.exchangeRateMantissa});

            // Get the normalized price of the asset
            vars.oraclePriceMantissa = getUnderlyingPriceForCToken(address(asset));

            if (vars.oraclePriceMantissa == 0) {
                return (Error.PRICE_ERROR, 0, 0, 0);
            }
            vars.oraclePrice = Exp({mantissa: vars.oraclePriceMantissa});

            // Pre-compute a conversion factor from tokens -> ether (normalized price value)
            vars.tokensToDenom = mul_(mul_(vars.collateralOrLiquidationFactor, vars.exchangeRate), vars.oraclePrice);
            // sumCollateral += tokensToDenom * cTokenBalance
            vars.sumCollateral = mul_ScalarTruncateAddUInt(vars.tokensToDenom, vars.cTokenBalance, vars.sumCollateral);

            // sumBorrowPlusEffects += oraclePrice * borrowBalance
            vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(vars.oraclePrice, vars.borrowBalance, vars.sumBorrowPlusEffects);

            // Calculate effects of interacting with cTokenModify
            if (asset == cTokenModify) {
                // redeem effect
                // sumBorrowPlusEffects += tokensToDenom * redeemTokens
                vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(vars.tokensToDenom, redeemTokens, vars.sumBorrowPlusEffects);

                // borrow effect
                // sumBorrowPlusEffects += oraclePrice * borrowAmount
                vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(vars.oraclePrice, borrowAmount, vars.sumBorrowPlusEffects);

                // OLA_ADDITIONS : Assigning value to the newly added 'borrowAmountUsd'
                // This will only have a non-zero value when the calculation is made for a 'borrow' action.
                vars.borrowAmountUsd = mul_ScalarTruncate(vars.oraclePrice, borrowAmount);
            }
        }

        // These are safe, as the underflow condition is checked first
        if (vars.sumCollateral > vars.sumBorrowPlusEffects) {
            return (Error.NO_ERROR, vars.sumCollateral - vars.sumBorrowPlusEffects, 0, vars.borrowAmountUsd);
        } else {
            return (Error.NO_ERROR, 0, vars.sumBorrowPlusEffects - vars.sumCollateral, vars.borrowAmountUsd);
        }
    }

    /**
     * @notice Calculate number of tokens of collateral asset to seize given an underlying amount
     * @dev Used in liquidation (called in cToken.liquidateBorrowFresh)
     * @param cTokenBorrowed The address of the borrowed cToken
     * @param cTokenCollateral The address of the collateral cToken
     * @param actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokens
     * @return (errorCode, number of cTokenCollateral tokens to be seized in a liquidation)
     */
    function liquidateCalculateSeizeTokens(address cTokenBorrowed, address cTokenCollateral, uint actualRepayAmount) external view returns (uint, uint) {
        /* Read oracle prices for borrowed and collateral markets */
        uint priceBorrowedMantissa = getUnderlyingPriceForCToken(cTokenBorrowed);
        uint priceCollateralMantissa = getUnderlyingPriceForCToken(cTokenCollateral);
        if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) {
            return (uint(Error.PRICE_ERROR), 0);
        }

        /*
         * Get the exchange rate and calculate the number of collateral tokens to seize:
         *  seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral
         *  seizeTokens = seizeAmount / exchangeRate
         *   = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate)
         */
        uint exchangeRateMantissa = CToken(cTokenCollateral).exchangeRateStored(); // Note: reverts on error
        uint seizeTokens;
        Exp memory numerator;
        Exp memory denominator;
        Exp memory ratio;

        // OLA_ADDITIONS : Added a direct read for the market 'liquidationIncentiveMantissa'.
        // notice: will be 0 for unsupported 'cTokenCollateral'
        numerator = mul_(Exp({mantissa: markets[cTokenCollateral].liquidationIncentiveMantissa}), Exp({mantissa: priceBorrowedMantissa}));
        denominator = mul_(Exp({mantissa: priceCollateralMantissa}), Exp({mantissa: exchangeRateMantissa}));
        ratio = div_(numerator, denominator);

        seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount);

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

    /*** Admin Functions ***/

    function _setRainMaker(bytes32 contractNameHash, bytes calldata deployParams, bytes calldata retireParams, bytes calldata connectParams) external returns (uint) {
        // Check caller is admin
        if (msg.sender != admin) {
            return fail(Error.UNAUTHORIZED, FailureInfo.SET_RAIN_MAKER_OWNER_CHECK);
        }

        // Before saying goodbye, run all retirement logic (e.g. ensure all of the indexes are updated)
        if (hasRainMaker()) {
            IComptrollerPeripheral(rainMaker).retire(retireParams);
        }

        // Track the old rain maker for the Comptroller
        address oldRainMaker = rainMaker;

        address newRainMaker = address(0);

        if (contractNameHash != bytes32(0)) {
            // Ask the ministry to deploy a new RainMaker for us
            newRainMaker = RegistryForComptrollerV0_04(registry).deployPeripheralContract(contractNameHash, deployParams, admin);

            // Sanity, ensure a rainMaker was deployed
            require(RainMakerInterface(newRainMaker).isRainMaker());

            // Call initialization hook
            IComptrollerPeripheral(newRainMaker).connect(connectParams);
        }

        // Set Comptroller's RainMaker to newRainMaker
        rainMaker = newRainMaker;

        // Emit NewRainMaker(oldRainMaker, newRainMaker)
        emit NewRainMaker(oldRainMaker, newRainMaker);

        return uint(Error.NO_ERROR);
    }

    /**
     * @notice Sets a new bouncer for the Comptroller (after asking the ministry to deploy one)
     * @dev deployParams Dynamic parameters to be used for the contract deployment.
     * @dev retireParams Dynamic parameters to be used for the retire function of the existing bouncer.
     * @dev connectParams Dynamic parameters to be used for the connection of the new bouncer.
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function _setBouncer(bytes32 contractNameHash, bytes calldata deployParams, bytes calldata retireParams, bytes calldata connectParams) external returns (uint) {
        // Check caller is admin
        if (msg.sender != admin) {
            return fail(Error.UNAUTHORIZED, FailureInfo.SET_BOUNCER_OWNER_CHECK);
        }

        // Track the bouncer for the Comptroller
        address oldBouncer = bouncer;
        address newBouncer = address(0);

        // Before saying goodbye, run all retirement logic
        if (hasBouncer()) {
            IComptrollerPeripheral(bouncer).retire(retireParams);
        }

        if (contractNameHash != bytes32(0)) {
            // Ask the ministry to deploy a new Bouncer for us
            newBouncer = RegistryForComptrollerV0_04(registry).deployPeripheralContract(contractNameHash, deployParams, admin);

            // Sanity, ensure a bouncer was deployed
            require(IBouncer(newBouncer).isBouncer());

            // Call initialization hook
            IComptrollerPeripheral(newBouncer).connect(connectParams);
        }

        // Set Comptroller's bouncer to newBouncer
        bouncer = newBouncer;

        emit NewBouncer(oldBouncer, bouncer);

        return uint(Error.NO_ERROR);
    }

    /**
     * @notice Sets the 'limit supplying' flag to the given value (if they are different)
     * @dev Admin function to set value for 'limitSupplying'
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function _setLimitMinting(bool flagValue) external returns (uint) {
        // Check caller is admin
        if (msg.sender != admin) {
            return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIMIT_MINTING_OWNER_CHECK);
        }

        if (limitMinting != flagValue) {
            limitMinting = flagValue;
            emit LimitMintingFlagChanged(flagValue);
        }

        return uint(Error.NO_ERROR);
    }

    /**
     * @notice Sets the 'limit borrowing' flag to the given value (if they are different)
     * @dev Admin function to set value for 'limitBorrowing'
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function _setLimitBorrowing(bool flagValue) external returns (uint) {
        // Check caller is admin
        if (msg.sender != admin) {
            return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIMIT_BORROWING_OWNER_CHECK);
        }

        if (limitBorrowing != flagValue) {
            limitBorrowing = flagValue;
            emit LimitBorrowingFlagChanged(flagValue);
        }

        return uint(Error.NO_ERROR);
    }

    /**
     * @notice Sets the 'minBorrowAmountUsd' (scaled by 18)
     * @dev Admin function to set value for 'minBorrowAmountUsd'
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function _setMinBorrowAmountUsd(uint minBorrowAmountUsd_) external returns (uint) {
        // Check caller is admin
        if (msg.sender != admin) {
            return fail(Error.UNAUTHORIZED, FailureInfo.SET_MIN_BORROW_AMOUNT_USD_OWNER_CHECK);
        }

        uint oldMinBorrowAmount = minBorrowAmountUsd;
        minBorrowAmountUsd = minBorrowAmountUsd_;

        emit NewMinBorrowAmount(oldMinBorrowAmount, minBorrowAmountUsd);

        return uint(Error.NO_ERROR);
    }

    /**
      * @notice Sets the collateralFactor for a market
      * @dev Admin function to set per-market collateralFactor
      * @param cToken The market to set the factor on
      * @param newCollateralFactorMantissa The new collateral factor, scaled by 1e18
      * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)
      */
    function _setCollateralFactor(CToken cToken, uint newCollateralFactorMantissa) external returns (uint) {
        // Check caller is admin
        if (msg.sender != admin) {
            return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK);
        }

        // Verify market is listed
        Market storage market = markets[address(cToken)];
        if (!market.isListed) {
            return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS);
        }

        Exp memory newCollateralFactorExp = Exp({mantissa: newCollateralFactorMantissa});

        // Check collateral factor <= 0.9
        Exp memory highLimit = Exp({mantissa: collateralFactorMaxMantissa});
        if (lessThanExp(highLimit, newCollateralFactorExp)) {
            return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION);
        }

        // Ensure liquidationFactor is greater or equal to the new collateralFactor
        uint marketLiquidationFactorMantissa = market.liquidationFactorMantissa;
        if (newCollateralFactorMantissa > marketLiquidationFactorMantissa) {
            return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_HIGHER_THAN_LIQUIDATION_FACTOR);
        }

        // If collateral factor != 0, fail if price == 0
        if (newCollateralFactorMantissa != 0 && getUnderlyingPriceForCToken(address(cToken)) == 0) {
            return fail(Error.PRICE_ERROR, FailureInfo.SET_COLLATERAL_FACTOR_WITHOUT_PRICE);
        }

        // Set market's collateral factor to new collateral factor, remember old value
        uint oldCollateralFactorMantissa = market.collateralFactorMantissa;
        market.collateralFactorMantissa = newCollateralFactorMantissa;

        // Emit event with asset, old collateral factor, and new collateral factor
        emit NewCollateralFactor(cToken, oldCollateralFactorMantissa, newCollateralFactorMantissa);

        return uint(Error.NO_ERROR);
    }

    /**
      * @notice Sets the liquidationFactor for a market.
      *         Important : In order to avoid the possibility of existing positions becoming liquidateable -
      *                     This value can only be increased.
      * @dev Admin function to set per-market liquidationFactor
      * @param cToken The market to set the factor on
      * @param newLiquidationFactorMantissa The new liquidation factor, scaled by 1e18
      * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)
      */
    function _setLiquidationFactor(CToken cToken, uint newLiquidationFactorMantissa) external returns (uint) {
        // Check caller is admin
        if (msg.sender != admin) {
            return fail(Error.UNAUTHORIZED, FailureInfo.SET_LIQUIDATION_FACTOR_OWNER_CHECK);
        }

        // Verify market is listed
        Market storage market = markets[address(cToken)];
        if (!market.isListed) {
            return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_LIQUIDATION_FACTOR_NO_EXISTS);
        }

        Exp memory newLiquidationFactorExp = Exp({mantissa: newLiquidationFactorMantissa});

        // Check liquidation factor <= 0.9
        Exp memory highLimit = Exp({mantissa: liquidationFactorMaxMantissa});
        if (lessThanExp(highLimit, newLiquidationFactorExp)) {
            return fail(Error.INVALID_LIQUIDATION_FACTOR, FailureInfo.SET_LIQUIDATION_FACTOR_VALIDATION);
        }

        // Ensure new liquidationFactor is greater or equal to the collateralFactor
        uint marketCollateralFactorMantissa = market.collateralFactorMantissa;
        if (newLiquidationFactorMantissa < marketCollateralFactorMantissa) {
            return fail(Error.INVALID_LIQUIDATION_FACTOR, FailureInfo.SET_LIQUIDATION_FACTOR_LOWER_THAN_COLLATERAL_FACTOR);
        }

        // Ensure new liquidation factor is strictly greater than the existing one
        uint oldLiquidationFactorMantissa = market.liquidationFactorMantissa;
        if (oldLiquidationFactorMantissa >= newLiquidationFactorMantissa) {
            return fail(Error.INVALID_LIQUIDATION_FACTOR, FailureInfo.SET_LIQUIDATION_FACTOR_LOWER_THAN_EXISTING_FACTOR);
        }

        // If liquidation factor != 0, fail if price == 0
        if (newLiquidationFactorMantissa != 0 && getUnderlyingPriceForCToken(address(cToken)) == 0) {
            return fail(Error.PRICE_ERROR, FailureInfo.SET_LIQUIDATION_FACTOR_WITHOUT_PRICE);
        }

        // Set market's liquidation factor to new liquidation factor, remember old value
        market.liquidationFactorMantissa = newLiquidationFactorMantissa;

        // Emit event with asset, old liquidation factor, and new liquidation factor
        emit NewCollateralFactor(cToken, oldLiquidationFactorMantissa, newLiquidationFactorMantissa);

        return uint(Error.NO_ERROR);
    }

    /**
      * OLA_ADDITIONS : Added 'cToken' to support 'incentive per market'
      * @notice Sets liquidationIncentive
      * @dev Admin function to set liquidationIncentive
      * @param cToken The market to set the factor on
      * @param newLiquidationIncentiveMantissa New liquidationIncentive scaled by 1e18
      * @return uint 0=success, otherwise a failure. (See ErrorReporter for details)
      */
    function _setLiquidationIncentive(CToken cToken, uint newLiquidationIncentiveMantissa) external returns (uint) {

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

        // Verify market is listed
        Market storage market = markets[address(cToken)];
        if (!market.isListed) {
            return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_LIQUIDATION_INCENTIVE_NO_EXISTS);
        }

        // OLA_ADDITIONS : All of the validations for 'newLiquidationIncentiveMantissa'
        Exp memory newLiquidationIncentiveExp = Exp({mantissa: newLiquidationIncentiveMantissa});

        // Check liquidation incentive <= 0.3 AND >= 0.05 [5,30]
        Exp memory highLimit = Exp({mantissa: liquidationIncentiveMaxMantissa});
        Exp memory lowLimit = Exp({mantissa: liquidationIncentiveMinMantissa});
        if (lessThanExp(highLimit, newLiquidationIncentiveExp) || lessThanExp(newLiquidationIncentiveExp, lowLimit)) {
            return fail(Error.INVALID_LIQUIDATION_INCENTIVE, FailureInfo.SET_LIQUIDATION_INCENTIVE_VALIDATION);
        }

        // If liquidation incentive != 0, fail if price == 0 (Extra safety check)
        if (newLiquidationIncentiveMantissa != 0 && getUnderlyingPriceForCToken(address(cToken)) == 0) {
            return fail(Error.PRICE_ERROR, FailureInfo.SET_LIQUIDATION_INCENTIVE_WITHOUT_PRICE);
        }

        // Save current value for use in log
        uint oldLiquidationIncentiveMantissa = market.liquidationIncentiveMantissa;

        // Set liquidation incentive to new incentive
        market.liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;

        // Emit event with old incentive, new incentive
        emit NewLiquidationIncentive(cToken, oldLiquidationIncentiveMantissa, newLiquidationIncentiveMantissa);

        return uint(Error.NO_ERROR);
    }

    /**
     * @notice Add the market to the markets mapping and set it as listed
     * @dev Admin function to deploy a new cTokens and then set isListed and add support for the market
     * @param underlying The address of the asset (token or native) to be used for the market
     * @return uint 0=success, otherwise a failure. (See enum Error for details)
     */
    function _supportNewMarket(address underlying,
        bytes32 contractNameHash,
        bytes calldata params,
        address interestRateModel,
        bytes calldata becomeImplementationData) external returns (uint) {
        if (msg.sender != admin) {
            return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_NEW_MARKET_OWNER_CHECK);
        }

        // We allow one instance of the same underlying-contractName combination
        if (existingMarketTypes[underlying][contractNameHash] != address(0)) {
            return fail(Error.UNAUTHORIZED, FailureInfo.SUPPORT_NEW_MARKET_COMBINATION_CHECK);
        }

        // IMPORTANT : No graceful failure after contract deployment !
        address deployedCToken = RegistryForComptrollerV0_04(registry).deployOToken(underlying, contractNameHash, params, interestRateModel, admin, becomeImplementationData);

        CToken(deployedCToken).isCToken(); // Sanity check to make sure its really a CToken

        // OLA_ADDITIONS : Changed to require
        // Legacy safety
        require(!markets[deployedCToken].isListed, "SUPPORT_MARKET_EXISTS");

        // Save asset - contract combination
        existingMarketTypes[underlying][contractNameHash] = deployedCToken;

        // OLA_ADDITIONS : Added 'liquidationFactorMantissa', 'liquidationIncentiveMantissa'
        markets[deployedCToken] = Market({isListed: true, collateralFactorMantissa: 0,
        liquidationFactorMantissa: 0, liquidationIncentiveMantissa: 0,
        activeCollateralUSDCap: 0, activeCollateralCTokenUsage: 0
        });

        _addMarketInternal(deployedCToken);

        emit MarketListed(CToken(deployedCToken));

        return uint(Error.NO_ERROR);
    }

    function _addMarketInternal(address cToken) internal {
        // OLA_ADDITIONS : Added this 'max assets' limitation
        require(allMarkets.length <= maxAllowedAssets, "Too many assets");

        for (uint i = 0; i < allMarkets.length; i ++) {
            require(allMarkets[i] != CToken(cToken), "Already added");
        }
        allMarkets.push(CToken(cToken));

        // OLA_ADDITIONS : Initializing the market at the RainMaker as well
        if (hasRainMaker()) {
            RainMakerInterface(rainMaker)._supportMarket(cToken);
        }
    }

    /**
      * OLA_ADDITIONS : This function
      * @notice Set the given active collateral caps (in USD) for the given cToken markets. Any action that brings total active collateral to or above borrow cap will revert.
      * @dev Admin function to set the active collateral caps. A active-collateral cap of 0 corresponds to unlimited active collateral.
      * @param cTokens The addresses of the markets (tokens) to change the active-collateral caps for
      * @param newActiveCollateralCaps The new active-collateral cap values in usd to be set. A value of 0 corresponds to unlimited borrowing.
      */
    function _setActiveCollateralCaps(CToken[] calldata cTokens, uint[] calldata newActiveCollateralCaps) external {
        require(msg.sender == admin, "!Admin");

        uint numMarkets = cTokens.length;
        uint numActiveCollateralCaps = newActiveCollateralCaps.length;

        require(numMarkets != 0 && numMarkets == numActiveCollateralCaps, "invalid input");

        for(uint i = 0; i < numMarkets; i++) {
            Market storage marketToJoin = markets[address(cTokens[i])];

            require(marketToJoin.isListed,"!listed");

            marketToJoin.activeCollateralUSDCap = newActiveCollateralCaps[i];

            emit NewActiveCollateralCap(cTokens[i], newActiveCollateralCaps[i]);
        }
    }

    /**
     * @notice Admin function to change the admin bank address
     * @param newAdminBankAddress The new admin bank address
     */
    function _setAdminBankAddress(address payable newAdminBankAddress) external {
        require(msg.sender == admin, "!admin");

        // Save current value for inclusion in log
        address oldAdminBankAddress = adminBankAddress;

        // Store adminBankAddress with value newAdminBankAddress
        adminBankAddress = newAdminBankAddress;

        // Emit NewAdminBankAddress(newAdminBankAddress, newAdminBankAddress)
        emit NewAdminBankAddress(oldAdminBankAddress, newAdminBankAddress);
    }

    /**
      * @notice Set the given borrow caps for the given cToken markets. Borrowing that brings total borrows to or above borrow cap will revert.
      * @dev Admin or borrowCapGuardian function to set the borrow caps. A borrow cap of 0 corresponds to unlimited borrowing.
      * @param cTokens The addresses of the markets (tokens) to change the borrow caps for
      * @param newBorrowCaps The new borrow cap values in underlying to be set. A value of 0 corresponds to unlimited borrowing.
      */
    function _setMarketBorrowCaps(CToken[] calldata cTokens, uint[] calldata newBorrowCaps) external {
    	require(msg.sender == admin || msg.sender == borrowCapGuardian, "!admin||borrow cap guardian");

        uint numMarkets = cTokens.length;
        uint numBorrowCaps = newBorrowCaps.length;

        require(numMarkets != 0 && numMarkets == numBorrowCaps, "invalid input");

        for(uint i = 0; i < numMarkets; i++) {
            borrowCaps[address(cTokens[i])] = newBorrowCaps[i];
            emit NewBorrowCap(cTokens[i], newBorrowCaps[i]);
        }
    }

    /**
     * @notice Admin function to change the Borrow Cap Guardian
     * @param newBorrowCapGuardian The address of the new Borrow Cap Guardian
     */
    function _setBorrowCapGuardian(address newBorrowCapGuardian) external {
        require(msg.sender == admin, "!admin");

        // Save current value for inclusion in log
        address oldBorrowCapGuardian = borrowCapGuardian;

        // Store borrowCapGuardian with value newBorrowCapGuardian
        borrowCapGuardian = newBorrowCapGuardian;

        // Emit NewBorrowCapGuardian(OldBorrowCapGuardian, NewBorrowCapGuardian)
        emit NewBorrowCapGuardian(oldBorrowCapGuardian, newBorrowCapGuardian);
    }

    /**
     * @notice Admin function to change the Pause Guardian
     * @param newPauseGuardian The address of the new Pause Guardian
     * @return uint 0=success, otherwise a failure. (See enum Error for details)
     */
    function _setPauseGuardian(address newPauseGuardian) public returns (uint) {
        if (msg.sender != admin) {
            return fail(Error.UNAUTHORIZED, FailureInfo.SET_PAUSE_GUARDIAN_OWNER_CHECK);
        }

        // Save current value for inclusion in log
        address oldPauseGuardian = pauseGuardian;

        // Store pauseGuardian with value newPauseGuardian
        pauseGuardian = newPauseGuardian;

        // Emit NewPauseGuardian(OldPauseGuardian, NewPauseGuardian)
        emit NewPauseGuardian(oldPauseGuardian, pauseGuardian);

        return uint(Error.NO_ERROR);
    }

    function _setMintPaused(CToken cToken, bool state) public returns (bool) {
        require(markets[address(cToken)].isListed, "!listed");
        require(msg.sender == pauseGuardian || msg.sender == admin, "!pause guardian||admin");
        require(msg.sender == admin || state == true, "!admin");

        mintGuardianPaused[address(cToken)] = state;
        emit ActionPaused(cToken, "Mint", state);
        return state;
    }

    function _setBorrowPaused(CToken cToken, bool state) public returns (bool) {
        require(markets[address(cToken)].isListed, "!listed");
        require(msg.sender == pauseGuardian || msg.sender == admin, "!pause guardian||admin");
        require(msg.sender == admin || state == true, "!admin");

        borrowGuardianPaused[address(cToken)] = state;
        emit ActionPaused(cToken, "Borrow", state);
        return state;
    }

    function _setTransferPaused(bool state) public returns (bool) {
        require(msg.sender == pauseGuardian || msg.sender == admin, "!pause guardian||admin");
        require(msg.sender == admin || state == true, "!admin");

        transferGuardianPaused = state;
        emit ActionPaused("Transfer", state);
        return state;
    }

    /**
     * @notice Checks caller is admin
     */
    function isAdmin() internal view returns (bool) {
        return msg.sender == admin;
    }

    /**
     * OLA_ADDITIONS : This function
     * @notice Ensures all markets are updating their implementation from the Registry
     */
    function updateDelegatedImplementations(bytes calldata becomeImplementationData) external {
        require(isAdmin(), "!admin");

        // Update all markets
        for (uint i = 0; i < allMarkets.length; i ++) {
            CToken oToken = allMarkets[i];
            require(CTokenDelegatorInterface(address(oToken)).updateImplementationFromRegistry(false, becomeImplementationData), "Update failed");
        }
    }

    /**
     * @notice Return all of the markets
     * @dev The automatic getter may be used to access an individual market.
     * @return The list of market addresses
     */
    function getAllMarkets() public view returns (CToken[] memory) {
        return allMarkets;
    }


    /**
     * Fetches the underlying price from the ministry.
     * 0 means an error.
     */
    function getUnderlyingPriceForCToken(address cToken) internal view returns (uint256) {
        return RegistryForComptrollerV0_04(registry).getPriceForUnderling(cToken);
    }

    function hasRainMaker() view public returns (bool) {
        return address(rainMaker) != address(0);
    }

    function hasBouncer() view public returns (bool) {
        return address(bouncer) != address(0);
    }

    function isAccountApproved(address account) view external returns (bool) {
        return isAccountApprovedInternal(account);
    }

    /**
     * @notice This function assumes that any account not actively approved is denied
     *         and so, if no bouncer is set, the response is always false.
     */
    function isAccountApprovedInternal(address account) view internal returns (bool) {
        if (hasBouncer()) {
            return IBouncerForComptroller(bouncer).isAccountApproved(account);
        } else {
            return false;
        }
    }
}

File 2 of 17 : CToken.sol
pragma solidity ^0.5.16;

import "../Comptroller/ComptrollerInterface.sol";
import "./CTokenInterfaces.sol";
import "../ErrorReporter/ErrorReporter.sol";
import "../../Math/Exponential.sol";
import "../../Interfaces/EIP20Interface.sol";
import "../../OlaPlatform/InterestRateModels/InterestRateModel.sol";

interface RegistryForOToken {
    function isSupportedInterestRateModel(address interestRateModel) external returns (bool);
    function olaBankAddress() external view returns (address payable);
    function blocksBased() external view returns (bool);
}

interface ComptrollerForOToken {
    function adminBankAddress() external view returns (address payable);
}

/**
 * @title Compound's CToken Contract
 * @notice Abstract base for CTokens
 * @author Compound
 */
contract CToken is CTokenStorage, CTokenInterface, CTokenViewInterface, 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(accrualBlockNumber == 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 number and borrow index (block number mocks depend on Comptroller being set)
        accrualBlockNumber = getBlockNumber();
        accrualBlockTimestamp = getBlockTimestamp();
        borrowIndex = mantissaOne;

        // Set the calculation based flag from the ministry
        RegistryForOToken ministry = RegistryForOToken(comptroller.getRegistry());
        blocksBased = ministry.blocksBased();

        // Set the interest rate model (depends on block number / 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 = uint(-1);
        } 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 != uint(-1)) {
            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 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 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 (-1 means infinite)
     * @return Whether or not the approval succeeded
     */
    function approve(address spender, uint256 amount) external returns (bool) {
        address src = msg.sender;
        transferAllowances[src][spender] = amount;
        emit Approval(src, spender, amount);
        return true;
    }

    /**
     * @notice Get the current allowance from `owner` for `spender`
     * @param owner The address of the account which owns the tokens to be spent
     * @param spender The address of the account which may transfer tokens
     * @return The number of tokens allowed to be spent (-1 means infinite)
     */
    function allowance(address owner, address spender) external view 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 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 returns (uint) {
        Exp memory exchangeRate = Exp({mantissa: exchangeRateCurrent()});
        (MathError mErr, uint balance) = mulScalarTruncate(exchangeRate, accountTokens[owner]);
        require(mErr == MathError.NO_ERROR, "balance could not be calculated");
        return balance;
    }

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

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

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

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

    /**
     * @notice Returns the current per-block supply interest rate for this cToken
     * @return The supply interest rate per block, scaled by 1e18
     */
    function supplyRatePerBlock() external view 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 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 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 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 nonReentrant returns (uint) {
        require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed");
        return exchangeRateStored();
    }

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

    /**
     * @notice Calculates the exchange rate from the underlying to the CToken
     * @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 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 cToken in the underlying asset
     * @return The quantity of underlying asset owned by this contract
     */
    function getCash() external view returns (uint) {
        return getCashPrior();
    }

    /**
     * @notice Get the accrual block number of this cToken
     * @return The accrual block number
     */
    function getAccrualBlockNumber() external view returns (uint) {
        return accrualBlockNumber;
    }

    /**
     * @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 returns (uint) {
        /* Remember the initial block number */
        uint currentBlockNumber = getBlockNumber();
        uint accrualBlockNumberPrior = accrualBlockNumber;
        uint currentBlockTimestamp = getBlockTimestamp();

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

        // OLA_ADDITIONS : Distinction between time and block based calculations
        /* Calculate the number of blocks elapsed since the last accrual */
        MathError mathErr;
        uint delta;

        if (blocksBased) {
            (mathErr, delta) = subUInt(currentBlockNumber, accrualBlockNumberPrior);
        } else {
            // This variable is defined here due to solidity limits
            uint accrualBlockTimestampPrior = accrualBlockTimestamp;

            /* Short-circuit accumulating 0 interest on time based chains + extra safety for weird timestamps */
            if (currentBlockTimestamp <= accrualBlockTimestampPrior) {
                return uint(Error.NO_ERROR);
            }

            (mathErr, delta) = subUInt(currentBlockTimestamp, accrualBlockTimestampPrior);
        }
        require(mathErr == MathError.NO_ERROR, "could not calculate delta");

        /* 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 interest accumulated into borrows and reserves and the new index:
         *  simpleInterestFactor = borrowRate * delta
         *  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}), delta);
        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 */
        accrualBlockNumber = currentBlockNumber;
        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 cTokens 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 cTokens 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 number equals current block number */
        if (accrualBlockNumber != getBlockNumber()) {
            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 cToken must handle variations between ERC-20 and ETH underlying.
         *  `doTransferIn` reverts if anything goes wrong, since we can't be sure if
         *  side-effects occurred. The function returns the amount actually transferred,
         *  in case of a fee. On success, the cToken holds an additional `actualMintAmount`
         *  of cash.
         */
        vars.actualMintAmount = doTransferIn(minter, mintAmount);

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

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

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

        (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 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 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(msg.sender, redeemTokens, 0);
    }

    /**
     * @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 receive from redeeming cTokens
     * @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(msg.sender, 0, redeemAmount);
    }

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

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

        RedeemLocalVars memory vars;

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

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

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

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

            vars.redeemAmount = redeemAmountIn;
        }

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

        /* Verify market's block number equals current block number */
        if (accrualBlockNumber != getBlockNumber()) {
            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 invoke doTransferOut for the redeemer and the redeemAmount.
         *  Note: The cToken must handle variations between ERC-20 and ETH underlying.
         *  On success, the cToken has redeemAmount less of cash.
         *  doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.
         */
        doTransferOut(redeemer, vars.redeemAmount);

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

        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(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 number equals current block number */
        if (accrualBlockNumber != getBlockNumber()) {
            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 invoke doTransferOut for the borrower and the borrowAmount.
         *  Note: The cToken must handle variations between ERC-20 and ETH underlying.
         *  On success, the cToken borrowAmount less of cash.
         *  doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.
         */
        doTransferOut(borrower, borrowAmount);

        /* 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 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 undelrying tokens being returned
     * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount.
     */
    function repayBorrowFresh(address payer, address borrower, 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 number equals current block number */
        if (accrualBlockNumber != getBlockNumber()) {
            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 == -1, repayAmount = accountBorrows */
        if (repayAmount == uint(-1)) {
            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 cToken must handle variations between ERC-20 and ETH underlying.
         *  On success, the cToken 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 cToken to be liquidated
     * @param cTokenCollateral 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, CTokenInterface cTokenCollateral) 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 = cTokenCollateral.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, cTokenCollateral);
    }

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

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

        /* Verify cTokenCollateral market's block number equals current block number */
        if (cTokenCollateral.getAccrualBlockNumber() != getBlockNumber()) {
            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 = -1 */
        if (repayAmount == uint(-1)) {
            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(cTokenCollateral), actualRepayAmount);
        require(amountSeizeError == uint(Error.NO_ERROR), "LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED");

        /* Revert if borrower collateral token balance < seizeTokens */
        require(cTokenCollateral.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(cTokenCollateral) == address(this)) {
            seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens);
        } else {
            seizeError = cTokenCollateral.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(cTokenCollateral), seizeTokens);

        /* We call the defense hook */
        // unused function
        // Comptroller.liquidateBorrowVerify(address(this), address(cTokenCollateral), 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 cToken during the process of liquidation.
     *  Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter.
     * @param liquidator The account receiving seized collateral
     * @param borrower The account having collateral seized
     * @param seizeTokens The number of cTokens to seize
     * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
     */
    function seize(address liquidator, address borrower, uint seizeTokens) external nonReentrant returns (uint) {
        return seizeInternal(msg.sender, liquidator, borrower, seizeTokens);
    }

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

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

        MathError mathErr;
        uint borrowerTokensNew;
        uint liquidatorTokensNew;

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

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

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

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

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

        /* We call the defense hook */
        // Transfer verify is required here due to tokens being transferred, and have to keep the
        // ACC accounting in check
        // This works, because the 'borrower' has to be in this market. and so, the active collateral usage can either remain unchanged
        // (if the liquidator is also in the market) or reduce (if the liquidator is not in the market)
        comptroller.transferVerify(address(this), borrower, liquidator, seizeTokens);

        /* 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 returns (uint) {
        // Check caller = admin
        if (msg.sender != admin) {
            return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);
        }

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

        // Store pendingAdmin with value newPendingAdmin
        pendingAdmin = newPendingAdmin;

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

        return uint(Error.NO_ERROR);
    }

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

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

        // Store admin with value pendingAdmin
        admin = pendingAdmin;

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

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

        return uint(Error.NO_ERROR);
    }

    /**
      * OLA_ADDITIONS : Made internal and removes Admin check.
      * @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) internal returns (uint) {
        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 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 number equals current block number
        if (accrualBlockNumber != getBlockNumber()) {
            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);
        }

        // OLA_ADDITIONS :This constraint
        // Check newReserveFactor >= minReserveFactor
        if (newReserveFactorMantissa < reserveFactorMinMantissa) {
            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 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 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 the LeN admin and to Ola bank their respective shares
     * @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;

        // OLA_ADDITIONS : Allowing anyone to reduce reserves
        // Check caller is admin
        // if (msg.sender != admin) {
        //     return fail(Error.UNAUTHORIZED, FailureInfo.REDUCE_RESERVES_ADMIN_CHECK);
        // }

        // We fail gracefully unless market's block number equals current block number
        if (accrualBlockNumber != getBlockNumber()) {
            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);
        }

        // OLA_ADDITIONS : Dividing the reduced amount between the Admin and Ola (+validations)
        //                 Important to notice that we have added Math calculations to this function.
        //                 Where as before, it only used pre-calculated numbers.
        MathError mathErr;
        uint adminPart;
        uint olaPart;
        uint olaReserveFactor = fetchOlaReserveFactorMantissa();
        address payable olaBankAddress = fetchOlaBankAddress();
        address payable adminBankAddress = fetchAdminBankAddress();

        // Calculate olaPart
        (mathErr, olaPart) = mulScalarTruncate(Exp({mantissa: olaReserveFactor}), reduceAmount);
        if (mathErr != MathError.NO_ERROR) {
            return failOpaque(Error.MATH_ERROR, FailureInfo.REDUCE_RESERVES_OLA_PART_CALCULATION_FAILED, uint(mathErr));
        }

        // Sanity check, should never be a problem in a well parameterized system
        if (olaPart >= reduceAmount) {
            return fail(Error.BAD_SYSTEM_PARAMS, FailureInfo.REDUCE_RESERVES_OLA_PART_CALCULATION_FAILED);
        }

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

        // Calculate admin part
        adminPart = reduceAmount - olaPart;
        // We checked olaPart < reduceAmount above, so this should never revert.
        require(adminPart < reduceAmount, "reduce reserves unexpected adminPart underflow");

        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;

        // OLA_ADDITIONS : Transfer reserves to both admin and Ola bank addresses
        // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.
        doTransferOut(adminBankAddress, adminPart);
        doTransferOut(olaBankAddress, olaPart);

        emit ReservesReduced(adminBankAddress, adminPart, olaBankAddress, olaPart, 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 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 number equals current block number
        if (accrualBlockNumber != getBlockNumber()) {
            return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK);
        }

        // Ensure interest rate model is an approved contracts
        RegistryForOToken registry = RegistryForOToken(comptroller.getRegistry());

        require(registry.isSupportedInterestRateModel(address(newInterestRateModel)), "Unapproved interest rate model");

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

    /*** Safe Token ***/

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

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

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

    /**
     * OLA_ADDITIONS: This function
     * @dev Returns the ola reserves factor.
     */
    function fetchOlaReserveFactorMantissa() internal pure returns (uint) {
        return olaReserveFactorMantissa;
    }

    /**
     * OLA_ADDITIONS: This function
     * @dev Fetches the ola bank address.
     */
    function fetchOlaBankAddress() internal returns (address payable) {
        return RegistryForOToken(comptroller.getRegistry()).olaBankAddress();
    }

    /**
     * OLA_ADDITIONS: This function
     * @dev Fetches the admin bank address.
     */
    function fetchAdminBankAddress() internal view returns (address payable) {
        return ComptrollerForOToken(address(comptroller)).adminBankAddress();
    }

    /*** 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 3 of 17 : ErrorReporter.sol
pragma solidity ^0.5.16;

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

        // OLA_ADDITIONS : All Enums from here
        NOT_IN_MARKET,
        TOO_LITTLE_BORROW,
        IN_FRESH_LIQUIDATION_LIMITED_PERIOD,
        INVALID_LIQUIDATION_FACTOR,
        BORROWED_AGAINST_FAILED,
        TOTAL_BORROWED_AGAINST_TOO_HIGH,
        TOO_MUCH_COLLATERAL_ACTIVATION,

        // V0.02
        NOT_APPROVED_TO_MINT,
        NOT_APPROVED_TO_BORROW
    }

    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,

        // OLA_ADDITIONS : All Enums from here
        SET_LIQUIDATION_INCENTIVE_NO_EXISTS,
        SET_LIQUIDATION_INCENTIVE_WITHOUT_PRICE,
        SET_LIQUIDATION_FACTOR_OWNER_CHECK,
        SET_LIQUIDATION_FACTOR_NO_EXISTS,
        SET_LIQUIDATION_FACTOR_VALIDATION,
        SET_LIQUIDATION_FACTOR_WITHOUT_PRICE,
        SET_LIQUIDATION_FACTOR_LOWER_THAN_COLLATERAL_FACTOR,
        SET_LIQUIDATION_FACTOR_LOWER_THAN_EXISTING_FACTOR,
        SET_COLLATERAL_FACTOR_HIGHER_THAN_LIQUIDATION_FACTOR,
        SET_RAIN_MAKER_OWNER_CHECK,
        ENTER_MARKET_NOT_ALLOWED,
        UPDATE_LN_VERSION_ADMIN_OWNER_CHECK,
        // V0.002
        SET_BOUNCER_OWNER_CHECK,
        SET_LIMIT_MINTING_OWNER_CHECK,
        SET_LIMIT_BORROWING_OWNER_CHECK,
        SET_MIN_BORROW_AMOUNT_USD_OWNER_CHECK,
        SUPPORT_NEW_MARKET_OWNER_CHECK,
        SUPPORT_NEW_MARKET_COMBINATION_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,

        // OLA_ADDITIONS : All Enums from here
        BAD_SYSTEM_PARAMS
    }

    /*
     * Notice: 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,

        // OLA_ADDITIONS : All Enums from here
        REDUCE_RESERVES_OLA_PART_CALCULATION_FAILED
    }

    /**
      * @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 4 of 17 : PriceOracle.sol
pragma solidity ^0.5.16;

import "../OTokens/CToken.sol";

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

    /**
     * OLA_ADDITIONS : This function
     * @notice Get the price an asset
     * @param asset The asset to get the price of
     * @return The asset price mantissa (scaled by 1e18).
     *  Zero means the price is unavailable.
     */
    function getAssetPrice(address asset) external view returns (uint);

    /**
     * OLA_ADDITIONS : This function
     * @notice Get the price update timestamp for the asset
     * @param asset The asset address for price update timestamp retrieval.
     * @return Last price update timestamp for the asset
     */
    function getAssetPriceUpdateTimestamp(address asset) external view returns (uint);

    /**
      * @notice Get the underlying price of a cToken asset
      * @param cToken The cToken to get the underlying price of
      * @return The underlying asset price mantissa (scaled by 1e(36 - assetDecimals)).
      *  Zero means the price is unavailable.
      */
    function getUnderlyingPrice(CToken cToken) external view returns (uint);

    /**
     * OLA_ADDITIONS : This function
     * @notice Get the price update timestamp for the cToken underlying
     * @param cToken The cToken address for price update timestamp retrieval.
     * @return Last price update timestamp for the cToken underlying asset
     */
    function getUnderlyingPriceUpdateTimestamp(address cToken) external view returns (uint);
}

File 5 of 17 : ComptrollerInterface.sol
pragma solidity ^0.5.16;

import "../OTokens/CToken.sol";

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

    /*** OLA_ADDITIONS : registry getter ***/
    /*** Registry ***/
    function getRegistry() external view returns (address);

    /*** Assets supported by the Comptroller ***/
    function getAllMarkets() public view returns (CToken[] memory);

    /*** OLA_ADDITIONS : peripheral checkers ***/
    /*** Peripherals ***/
    function hasRainMaker() view public returns (bool);
    function hasBouncer() view public returns (bool);

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

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

    /*** Policy Hooks ***/

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

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

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

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

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

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

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

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

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

File 6 of 17 : ComptrollerStorage.sol
pragma solidity ^0.5.16;

import "../OTokens/CToken.sol";
import "../PriceOracle/PriceOracle.sol";

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

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

    /**
    * @notice Registry address
    */
    address public registry;

    address public implementation;

    // OLA_ADDITIONS : This contract name hash
    bytes32 constant public unitrollerContractHash = keccak256("Unitroller");
}

contract ComptrollerV1Storage is UnitrollerAdminStorage {
    /**
     * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow
     */
    uint public closeFactorMantissa;

    /**
     * @notice Max number of assets a single account can participate in (borrow or use as collateral)
     */
    uint public maxAssets;

    /**
     * @notice Per-account mapping of "assets you are in", capped by maxAssets
     */
    mapping(address => CToken[]) public accountAssets;

}

contract ComptrollerV2Storage is ComptrollerV1Storage {
    struct Market {
        /// @notice Whether or not this market is listed
        bool isListed;

        /**
         * @notice Multiplier representing the most one can borrow against their collateral in this market.
         *  For instance, 0.9 to allow borrowing 90% of collateral value.
         *  Must be between 0 and 1, and stored as a mantissa.
         */
        uint collateralFactorMantissa;

        /**
         * OLA_ADDITIONS : Added the field liquidationFactorMantissa.
         * @notice Multiplier representing the borrow to collateral ratio from which liquidations can occur in this market.
         *  For instance, 0.9 indicates that liquidations can occur when the borrowed value reaches 90% (or more) of collateral value.
         *  Must be between 0 and 1, and stored as a mantissa.
         *  Must be greater or equal to 'collateralFactorMantissa'.
         */
        uint liquidationFactorMantissa;

        /**
         * @notice Multiplier representing the discount on collateral that a liquidator receives
         * OLA_ADDITIONS : Now supports incentives per market (Added this)
         */
        uint liquidationIncentiveMantissa;

        /// @notice Per-market mapping of "accounts in this asset"
        mapping(address => bool) accountMembership;

        // OLA_ADDITIONS : Fields after this line

        // @notice Active collateral caps enforced by  for each cToken address. Defaults to zero which corresponds to unlimited active collateral.
        uint activeCollateralUSDCap;

        // @notice Amount of cTokens actively used as collateral.
        uint activeCollateralCTokenUsage;
    }

    /**
     * @notice Official mapping of cTokens -> Market metadata
     * @dev Used e.g. to determine if a market is supported
     */
    mapping(address => Market) public markets;


    /**
     * @notice The Pause Guardian can pause certain actions as a safety mechanism.
     *  Actions which allow users to remove their own assets cannot be paused.
     *  Liquidation / seizing / transfer can only be paused globally, not by market.
     */
    address public pauseGuardian;
    bool public _mintGuardianPaused;
    bool public _borrowGuardianPaused;
    bool public transferGuardianPaused;

    bool public seizeGuardianPaused;
    mapping(address => bool) public mintGuardianPaused;
    mapping(address => bool) public borrowGuardianPaused;
}

contract ComptrollerV3Storage is ComptrollerV2Storage {
    /// @notice A list of all markets
    CToken[] public allMarkets;
}

contract ComptrollerV4Storage is ComptrollerV3Storage {
    // @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.
    address public borrowCapGuardian;

    // @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.
    mapping(address => uint) public borrowCaps;
}

contract ComptrollerV5Storage is ComptrollerV4Storage {

}

contract ComptrollerStorageOlaV0_01 is ComptrollerV5Storage {
    /// @notice Borrow requests for less than this USD amount will not be approved.
    uint public minBorrowAmountUsd;

    // @notice an address to turn to in order to distribute tokens for participation
    address public rainMaker;
}

contract ComptrollerStorageOlaV0_02 is ComptrollerStorageOlaV0_01 {
    // The address to send the 'Admin Part' when reducing reserves.
    address payable public adminBankAddress;

    // Underlying asset -> contractNameHash -> deployed oTokens
    mapping(address => mapping(bytes32 => address)) public existingMarketTypes;

    // @notice An address to turn to in order to check if an account is approved for specific actions.
    address public bouncer;

    // If on, supplying will be limited only to approved accounts
    bool public limitMinting;
    // If on, borrowing will be limited only to approved accounts
    bool public limitBorrowing;
}

/// @notice Time period (in seconds) in which liquidation is to be limited (e.g: 60 for one minute)
//    uint public freshLiquidationLimitedPeriod;

/// @notice The liquidators that are allowed to liquidate while still in the 'freshLiquidationLimitedPeriod'
//    mapping(address => bool) whitelistedLiquidators;

File 7 of 17 : Unitroller.sol
pragma solidity ^0.5.16;

import "../ErrorReporter/ErrorReporter.sol";
import "./ComptrollerStorage.sol";

interface RegistryForUnitroller {
    function getImplementationForLn(address lnUnitroller, bytes32 contractNameHash) external returns (address);
    function getLnVersion(address lnUnitroller) external returns (uint256);
    function updateLnVersion(uint256 newVersion) external returns (bool);
}

/**
 * @title ComptrollerCore
 * @dev Storage for the Comptroller is at this address, while execution is delegated to the `comptrollerImplementation`.
 * CTokens should reference this contract as their Comptroller.
 */
contract Unitroller is UnitrollerAdminStorage, ComptrollerErrorReporter {
    /**
     * @notice Emitted when pendingComptrollerImplementation is accepted, which means Comptroller implementation is updated
     */
    event NewImplementation(address indexed oldImplementation, address indexed newImplementation);

    /**
     * @notice Emitted when implementation is not changed under a system version update
     */
    event ImplementationDidNotChange(address indexed implementation);

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

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

    constructor(address registry_) public {
        // Set admin to caller
        admin = msg.sender;

        // Set once and do not change
        registry = registry_;
    }

    /**
     * OLA_ADDITIONS : This function.
     * Should be registered before calling this function.
     */
    function initialize() external {
        require(msg.sender == admin, "Not Admin");
        require(implementation == address(0), "Already initialized");

        address comptrollerImplementation = RegistryForUnitroller(address(registry)).getImplementationForLn(address(this), unitrollerContractHash);

        implementation = comptrollerImplementation;
    }

    /*** Admin Functions ***/

    /**
     * @notice Updates the LN to the given version. And then refreshes implementation addresses from the Registry
     * for this contract (unitroller) and for all markets (OTokenDelegators)
     * @dev Admin function to update version on LN
     * @return uint true=success, otherwise a failure (Will revert on failure)
     */
    function _upgradeLnSystemVersion(uint256 newSystemVersion, bytes calldata becomeImplementationData) external returns (uint) {
        // Check caller = admin
        if (msg.sender != admin) {
            return fail(Error.UNAUTHORIZED, FailureInfo.UPDATE_LN_VERSION_ADMIN_OWNER_CHECK);
        }

        // Update Version
        bool updateSuccessful = RegistryForUnitroller(registry).updateLnVersion(newSystemVersion);
        require(updateSuccessful, "Version update failed");

        // First, update the implementation used by the unitroller
        address comptrollerImplementation = RegistryForUnitroller(registry).getImplementationForLn(address(this), unitrollerContractHash);

        if (comptrollerImplementation != implementation) {
            address oldImplementation = implementation;
            implementation = comptrollerImplementation;
            emit NewImplementation(oldImplementation, implementation);
        } else {
            emit ImplementationDidNotChange(implementation);
        }

        // Update all of the implementation addresses
        delegateToImplementation(abi.encodeWithSignature("updateDelegatedImplementations(bytes)", becomeImplementationData));

        return uint(Error.NO_ERROR);
    }

    /**
      * @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 newPendingAdmin) public 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() public returns (uint) {
        // Check caller is pendingAdmin and pendingAdmin ≠ address(0)
        if (msg.sender != pendingAdmin || pendingAdmin == address(0)) {
            return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);
        }

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

        // Store admin with value pendingAdmin
        admin = pendingAdmin;

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

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

        return uint(Error.NO_ERROR);
    }

    /**
     * @notice Delegates execution to the implementation contract
     * @dev It returns to the external caller whatever the implementation returns or forwards reverts
     * @param data The raw data to delegatecall
     * @return The returned bytes from the delegatecall
     */
    function delegateToImplementation(bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returnData) = implementation.delegatecall(data);
        assembly {
            if eq(success, 0) {
                revert(add(returnData, 0x20), returndatasize)
            }
        }
        return returnData;
    }

    /**
     * @dev Delegates execution to an implementation contract.
     * It returns to the external caller whatever the implementation returns
     * or forwards reverts.
     */
    function () payable external {
        // delegate all other functions to current implementation
        (bool success, ) = implementation.delegatecall(msg.data);

        assembly {
              let free_mem_ptr := mload(0x40)
              returndatacopy(free_mem_ptr, 0, returndatasize)

              switch success
              case 0 { revert(free_mem_ptr, returndatasize) }
              default { return(free_mem_ptr, returndatasize) }
        }
    }
}

File 8 of 17 : RainMakerInterface.sol
pragma solidity ^0.5.16;

import "../../../Core/LendingNetwork/OTokens/CToken.sol";

contract RainMakerInterface {
    bool public isRainMaker = true;
    bytes32 public contractNameHash;

    /*** Market support ***/
    function _supportMarket(address cToken) external;

    /*** Comp Distribution ***/
    function updateCompSupplyIndex(address cToken) external;
    function updateCompBorrowIndex(address cToken, uint marketBorrowIndex_) external;
    function distributeSupplierComp(address cToken, address supplier) external;
    function distributeBorrowerComp(address cToken, address borrower, uint marketBorrowIndex_) external;
}

contract SingleAssetRainMakerInterface is RainMakerInterface {
    /*** Comp claiming ***/
    function claimComp(address holder) external;
    function claimComp(address holder, CToken[] calldata cTokens) external;
    function claimComp(address[] calldata holders, CToken[] calldata cTokens, bool borrowers, bool suppliers) external;
}

File 9 of 17 : IBouncer.sol
pragma solidity ^0.5.16;

contract IBouncer {
    bool public isBouncer = true;
    bytes32 public contractNameHash;

    function isAccountApproved(address account) external view returns (bool);
}

File 10 of 17 : IComptrollerPeripheral.sol
pragma solidity ^0.5.16;

interface IComptrollerPeripheral {
    /**
     * Called when the contract is connected to the comptroller
     */
    function connect(bytes calldata params) external;

    /**
     * Called when the contract is disconnected from the comptroller
     */
    function retire(bytes calldata params) external;
}

File 11 of 17 : CTokenInterfaces.sol
pragma solidity ^0.5.16;

import "../Comptroller/ComptrollerInterface.sol";
import "../../OlaPlatform/InterestRateModels/InterestRateModel.sol";
import "../../Interfaces/EIP20NonStandardInterface.sol";

/**
 * OLA_ADDITIONS : This base admin storage.
 */
contract CTokenAdminStorage {
    /**
     * @notice Administrator for this contract
     */
    address payable public admin;

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

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

    /**
     * @notice Implementation address for this contract
     */
    address public implementation;

    // OLA_ADDITIONS : Contract hash name
    bytes32 public contractNameHash;
}

/**
 * @notice DO NOT ADD ANY MORE STORAGE VARIABLES HERE (add them to their respective type storage)
 */
contract CTokenStorage is CTokenAdminStorage {
    /**
     * @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 Underlying asset for this CToken
     */
    address public underlying;

    // @notice Indicates if the calculations should be blocks or time based
    bool public blocksBased;

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

    /**
     * @notice Initial exchange rate used when minting the first CTokens (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 accrualBlockNumber;

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

    /**
     * OLA_ADDITIONS : Removed option to 'add reserves' as it makes no sense when reducing reserves
     *                 sends a part to Ola Bank.
     * @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;

    // IMPORTANT : DO NOT ADD ANY MORE STORAGE VARIABLES HERE (add them to their respective type storage)
}

contract CTokenDelegatorInterface {

    /*** Implementation Events ***/

    /**
     * @notice Emitted when implementation is changed
     */
    event NewImplementation(address indexed oldImplementation, address indexed newImplementation);

    /**
     * @notice Emitted when implementation is not changed under a system version update
     */
    event ImplementationDidNotChange(address indexed implementation);


    /*** Implementation functions ***/

    // OLA_ADDITIONS : Update implementation from the Registry
    function updateImplementationFromRegistry(bool allowResign, bytes calldata becomeImplementationData) external returns (bool);
}

contract CTokenInterface {
    // OLA_ADDITIONS : "Underlying field"
    address constant public nativeCoinUnderlying = address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);

    /**
     * OLA_ADDITIONS : This field
     * @notice This value is hard coded to 0.5 (50% for the Ola ecosystem and the LeN owner each)
     */
    uint constant public olaReserveFactorMantissa = 0.5e18;

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

    /**
     * @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 = 0.3e18;

    /**
     * OLA_ADDITIONS : This value
     * @notice Minimum fraction of interest that can be set aside for reserves
     */
    uint internal constant reserveFactorMinMantissa = 0.05e18;

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

    // TODO : Change to 'adminBank'
    /**
     * @notice Event emitted when the reserves are reduced
     */
    event ReservesReduced(address admin, uint adminPart, address olaBank, uint olaPart, 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);

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

    /*** User Interface ***/

    function transfer(address dst, uint amount) external returns (bool);
    function transferFrom(address src, address dst, uint amount) external returns (bool);
    function approve(address spender, uint amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function balanceOfUnderlying(address owner) external returns (uint);
    function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint);
    function borrowBalanceStored(address account) public view returns (uint);
    function exchangeRateStored() public view returns (uint);
    function getAccrualBlockNumber() external view returns (uint);
    function accrueInterest() public returns (uint);
    function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint);

    /*** Admin Functions ***/

    function _setPendingAdmin(address payable newPendingAdmin) external returns (uint);
    function _acceptAdmin() external returns (uint);
    function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint);
    function _reduceReserves(uint reduceAmount) external returns (uint);
    function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint);
}

/**
 * View functions that are not used by the core contracts.
 */
contract CTokenViewInterface {
    /*** View Interface ***/
    function borrowRatePerBlock() external view returns (uint);
    function supplyRatePerBlock() external view returns (uint);
    function totalBorrowsCurrent() external returns (uint);

    /**
     * @notice Used by the Maximilion
     */
    function borrowBalanceCurrent(address account) external returns (uint);
    function exchangeRateCurrent() public returns (uint);
    function getCash() external view returns (uint);
}

contract CErc20Interface {
    /*** User Interface ***/

    function mint(uint mintAmount) external returns (uint);
    function redeem(uint redeemTokens) external returns (uint);
    function redeemUnderlying(uint redeemAmount) external returns (uint);
    function borrow(uint borrowAmount) external returns (uint);
    function repayBorrow(uint repayAmount) external returns (uint);
    function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint);
    function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external returns (uint);
    function sweepToken(EIP20NonStandardInterface token) external;
}

contract CErc20StorageV0_01 {}

contract CErc20StorageV0_02 is CErc20StorageV0_01 {}

contract ONativeInterface {
    /*** User Interface ***/

    function mint() external payable;
    function redeem(uint redeemTokens) external returns (uint);
    function redeemUnderlying(uint redeemAmount) external returns (uint);
    function borrow(uint borrowAmount) external returns (uint);
    function repayBorrow() external payable;
    function repayBorrowBehalf(address borrower) external payable;
    function liquidateBorrow(address borrower, CTokenInterface cTokenCollateral) external payable;
    function sweepToken(EIP20NonStandardInterface token) external;
}

contract CEtherStorageV0_01 {}

contract CEtherStorageV0_02 is CEtherStorageV0_01 {}

contract CDelegateInterface {
    /**
     * @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) public;

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

contract OTokenCompoundingDepositStorage {

}

contract OTokenCompoundingDepositStorageV0_05 is OTokenCompoundingDepositStorage {

}

contract CLPStakingStorageV0_05 {

    /**
     * @notice The token that is distributed via the farm
     */
    address public rewardToken;

    /**
     * @notice The farm contract
     */
    address public farmAddress;

    /**
     * @notice The pool id in the farm
     */
    uint public pid;

    /**
     * @notice The market's last updated staking index
     */
    uint public marketStakingIndex;

    /// @notice The Reward Token index for each supplier as of the last time they accrued rewards
    mapping(address => uint) public supplierStakingIndex;

    /// @notice The Reward Token accrued but not yet transferred to each supplier
    mapping(address => uint) public rewardsAccrued;
}

contract CLPStakingInterfaceV0_05 {
    /**
     * @notice Event emitted when rewards-interest is accrued
     */
    event AccrueRewardsInterest(uint oldStakingIndex, uint newStakingIndex, uint oldReserves, uint newReserves);

    event DistributeSupplierRewards(address supplier, uint supplierDelta, uint marketStakignIndex);
}

File 12 of 17 : Exponential.sol
pragma solidity ^0.5.16;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 13 of 17 : EIP20Interface.sol
pragma solidity ^0.5.16;

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

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

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

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

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

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

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

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

File 14 of 17 : InterestRateModel.sol
pragma solidity ^0.5.16;

/**
  * @title Compound's InterestRateModel Interface
  * @author Compound
  */
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 block
      * @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 block (as a percentage, and scaled by 1e18)
      */
    function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint);

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

}

File 15 of 17 : EIP20NonStandardInterface.sol
pragma solidity ^0.5.16;

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

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

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

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

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

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

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

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

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

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

File 16 of 17 : CarefulMath.sol
pragma solidity ^0.5.16;

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

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

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

        uint c = a * b;

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

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

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

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

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

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

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

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

        return subUInt(sum, c);
    }
}

File 17 of 17 : ExponentialNoError.sol
pragma solidity ^0.5.16;

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

    struct Exp {
        uint mantissa;
    }

    struct Double {
        uint mantissa;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Contract ABI

[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"action","type":"string"},{"indexed":false,"internalType":"bool","name":"pauseState","type":"bool"}],"name":"ActionPaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract CToken","name":"cToken","type":"address"},{"indexed":false,"internalType":"string","name":"action","type":"string"},{"indexed":false,"internalType":"bool","name":"pauseState","type":"bool"}],"name":"ActionPaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract CToken","name":"cToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"oldCollateralUsage","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newCollateralUsage","type":"uint256"}],"name":"ActiveCollateralUsageChange","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":"bool","name":"newValue","type":"bool"}],"name":"LimitBorrowingFlagChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"newValue","type":"bool"}],"name":"LimitMintingFlagChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract CToken","name":"cToken","type":"address"},{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"MarketEntered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract CToken","name":"cToken","type":"address"},{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"MarketExited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract CToken","name":"cToken","type":"address"}],"name":"MarketListed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract CToken","name":"cToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"newActiveCollateralCap","type":"uint256"}],"name":"NewActiveCollateralCap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAdminBankAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newAdminBankAddress","type":"address"}],"name":"NewAdminBankAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract CToken","name":"cToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"newBorrowCap","type":"uint256"}],"name":"NewBorrowCap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldBorrowCapGuardian","type":"address"},{"indexed":false,"internalType":"address","name":"newBorrowCapGuardian","type":"address"}],"name":"NewBorrowCapGuardian","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldBouncer","type":"address"},{"indexed":false,"internalType":"address","name":"newBouncer","type":"address"}],"name":"NewBouncer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract CToken","name":"cToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"oldCollateralFactorMantissa","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newCollateralFactorMantissa","type":"uint256"}],"name":"NewCollateralFactor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract CToken","name":"cToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"oldLiquidationFactorMantissa","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newLiquidationFactorMantissa","type":"uint256"}],"name":"NewLiquidationFactor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract CToken","name":"ctoken","type":"address"},{"indexed":false,"internalType":"uint256","name":"oldLiquidationIncentiveMantissa","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newLiquidationIncentiveMantissa","type":"uint256"}],"name":"NewLiquidationIncentive","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldMinBorrowAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMinBorrowAmount","type":"uint256"}],"name":"NewMinBorrowAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldPauseGuardian","type":"address"},{"indexed":false,"internalType":"address","name":"newPauseGuardian","type":"address"}],"name":"NewPauseGuardian","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldRainMaker","type":"address"},{"indexed":false,"internalType":"address","name":"newRainMaker","type":"address"}],"name":"NewRainMaker","type":"event"},{"constant":true,"inputs":[],"name":"_borrowGuardianPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_mintGuardianPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"contract CToken[]","name":"cTokens","type":"address[]"},{"internalType":"uint256[]","name":"newActiveCollateralCaps","type":"uint256[]"}],"name":"_setActiveCollateralCaps","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address payable","name":"newAdminBankAddress","type":"address"}],"name":"_setAdminBankAddress","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newBorrowCapGuardian","type":"address"}],"name":"_setBorrowCapGuardian","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract CToken","name":"cToken","type":"address"},{"internalType":"bool","name":"state","type":"bool"}],"name":"_setBorrowPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"contractNameHash","type":"bytes32"},{"internalType":"bytes","name":"deployParams","type":"bytes"},{"internalType":"bytes","name":"retireParams","type":"bytes"},{"internalType":"bytes","name":"connectParams","type":"bytes"}],"name":"_setBouncer","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract CToken","name":"cToken","type":"address"},{"internalType":"uint256","name":"newCollateralFactorMantissa","type":"uint256"}],"name":"_setCollateralFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bool","name":"flagValue","type":"bool"}],"name":"_setLimitBorrowing","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bool","name":"flagValue","type":"bool"}],"name":"_setLimitMinting","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract CToken","name":"cToken","type":"address"},{"internalType":"uint256","name":"newLiquidationFactorMantissa","type":"uint256"}],"name":"_setLiquidationFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract CToken","name":"cToken","type":"address"},{"internalType":"uint256","name":"newLiquidationIncentiveMantissa","type":"uint256"}],"name":"_setLiquidationIncentive","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract CToken[]","name":"cTokens","type":"address[]"},{"internalType":"uint256[]","name":"newBorrowCaps","type":"uint256[]"}],"name":"_setMarketBorrowCaps","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"minBorrowAmountUsd_","type":"uint256"}],"name":"_setMinBorrowAmountUsd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract CToken","name":"cToken","type":"address"},{"internalType":"bool","name":"state","type":"bool"}],"name":"_setMintPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newPauseGuardian","type":"address"}],"name":"_setPauseGuardian","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"contractNameHash","type":"bytes32"},{"internalType":"bytes","name":"deployParams","type":"bytes"},{"internalType":"bytes","name":"retireParams","type":"bytes"},{"internalType":"bytes","name":"connectParams","type":"bytes"}],"name":"_setRainMaker","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bool","name":"state","type":"bool"}],"name":"_setTransferPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"underlying","type":"address"},{"internalType":"bytes32","name":"contractNameHash","type":"bytes32"},{"internalType":"bytes","name":"params","type":"bytes"},{"internalType":"address","name":"interestRateModel","type":"address"},{"internalType":"bytes","name":"becomeImplementationData","type":"bytes"}],"name":"_supportNewMarket","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"accountAssets","outputs":[{"internalType":"contract CToken","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"adminBankAddress","outputs":[{"internalType":"address payable","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allMarkets","outputs":[{"internalType":"contract CToken","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"cToken","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"borrowAmount","type":"uint256"}],"name":"borrowAllowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"borrowCapGuardian","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"borrowCaps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"borrowGuardianPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"cToken","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"borrowAmount","type":"uint256"}],"name":"borrowVerify","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"bouncer","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"contract CToken","name":"cToken","type":"address"}],"name":"checkMembership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"closeFactorMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address[]","name":"cTokens","type":"address[]"}],"name":"enterMarkets","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"existingMarketTypes","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"cTokenAddress","type":"address"}],"name":"exitMarket","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getAccountLiquidity","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getAccountLiquidityByLiquidationFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getAllMarkets","outputs":[{"internalType":"contract CToken[]","name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getAssetsIn","outputs":[{"internalType":"contract CToken[]","name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"cTokenModify","type":"address"},{"internalType":"uint256","name":"redeemTokens","type":"uint256"},{"internalType":"uint256","name":"borrowAmount","type":"uint256"}],"name":"getHypotheticalAccountLiquidity","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"cTokenModify","type":"address"},{"internalType":"uint256","name":"redeemTokens","type":"uint256"},{"internalType":"uint256","name":"borrowAmount","type":"uint256"}],"name":"getHypotheticalAccountLiquidityByLiquidationFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"hasBouncer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"hasRainMaker","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isAccountApproved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isComptroller","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"limitBorrowing","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"limitMinting","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"cTokenBorrowed","type":"address"},{"internalType":"address","name":"cTokenCollateral","type":"address"},{"internalType":"address","name":"liquidator","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"repayAmount","type":"uint256"}],"name":"liquidateBorrowAllowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"cTokenBorrowed","type":"address"},{"internalType":"address","name":"cTokenCollateral","type":"address"},{"internalType":"address","name":"liquidator","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"actualRepayAmount","type":"uint256"},{"internalType":"uint256","name":"seizeTokens","type":"uint256"}],"name":"liquidateBorrowVerify","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"cTokenBorrowed","type":"address"},{"internalType":"address","name":"cTokenCollateral","type":"address"},{"internalType":"uint256","name":"actualRepayAmount","type":"uint256"}],"name":"liquidateCalculateSeizeTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"markets","outputs":[{"internalType":"bool","name":"isListed","type":"bool"},{"internalType":"uint256","name":"collateralFactorMantissa","type":"uint256"},{"internalType":"uint256","name":"liquidationFactorMantissa","type":"uint256"},{"internalType":"uint256","name":"liquidationIncentiveMantissa","type":"uint256"},{"internalType":"uint256","name":"activeCollateralUSDCap","type":"uint256"},{"internalType":"uint256","name":"activeCollateralCTokenUsage","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"maxAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"minBorrowAmountUsd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"cToken","type":"address"},{"internalType":"address","name":"minter","type":"address"},{"internalType":"uint256","name":"mintAmount","type":"uint256"}],"name":"mintAllowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"mintGuardianPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"cToken","type":"address"},{"internalType":"address","name":"minter","type":"address"},{"internalType":"uint256","name":"actualMintAmount","type":"uint256"},{"internalType":"uint256","name":"mintTokens","type":"uint256"}],"name":"mintVerify","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"pauseGuardian","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"pendingAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rainMaker","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"cToken","type":"address"},{"internalType":"address","name":"redeemer","type":"address"},{"internalType":"uint256","name":"redeemTokens","type":"uint256"}],"name":"redeemAllowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"cToken","type":"address"},{"internalType":"address","name":"redeemer","type":"address"},{"internalType":"uint256","name":"redeemAmount","type":"uint256"},{"internalType":"uint256","name":"redeemTokens","type":"uint256"}],"name":"redeemVerify","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registry","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"cToken","type":"address"},{"internalType":"address","name":"payer","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"repayAmount","type":"uint256"}],"name":"repayBorrowAllowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"cToken","type":"address"},{"internalType":"address","name":"payer","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"actualRepayAmount","type":"uint256"},{"internalType":"uint256","name":"borrowerIndex","type":"uint256"}],"name":"repayBorrowVerify","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"cTokenCollateral","type":"address"},{"internalType":"address","name":"cTokenBorrowed","type":"address"},{"internalType":"address","name":"liquidator","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"seizeTokens","type":"uint256"}],"name":"seizeAllowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"seizeGuardianPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"cTokenCollateral","type":"address"},{"internalType":"address","name":"cTokenBorrowed","type":"address"},{"internalType":"address","name":"liquidator","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"seizeTokens","type":"uint256"}],"name":"seizeVerify","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"cToken","type":"address"},{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"transferTokens","type":"uint256"}],"name":"transferAllowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"transferGuardianPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"cToken","type":"address"},{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"transferTokens","type":"uint256"}],"name":"transferVerify","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"unitrollerContractHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"becomeImplementationData","type":"bytes"}],"name":"updateDelegatedImplementations","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50600080546001600160a01b03191633179055615af880620000336000396000f3fe608060405234801561001057600080fd5b50600436106104325760003560e01c8063731f0c2b11610236578063bdcdc2581161013b578063dce15449116100c3578063eabe7d9111610087578063eabe7d91146112b4578063ede4edd0146112ea578063f6f5013914611310578063f851a4401461133c578063fd1db8e81461134457610432565b8063dce154491461122d578063e38c5d4114611259578063e4028eee14611278578063e6653f3d146112a4578063e8755446146112ac57610432565b8063c53368351161010a578063c533683514611184578063cdb726591461118c578063d02f735114611194578063d50e3693146111da578063da3d454c146111f757610432565b8063bdcdc2581461102c578063c229b0d014611068578063c299823814611094578063c488847b1461113557610432565b806394b2294b116101be578063ac0b0bb71161018d578063ac0b0bb714610fd0578063b0772d0b14610fd8578063b17ca09614610fe0578063b5da8a4f1461101c578063b62ba9701461102457610432565b806394b2294b14610f2457806398a1889014610f2c578063a4a9592b14610f34578063abfceffc14610f5a57610432565b80638a7054ca116102055780638a7054ca14610e485780638e8f294b14610e505780638ebf636414610eab578063903e679c14610eca578063929fe9a114610ef657610432565b8063731f0c2b14610cfd578063736a581214610d235780637b10399914610e3857806387f7630314610e4057610432565b80634cfd09561161033c5780635d8d6281116102c4578063607ef6c111610293578063607ef6c114610b715780636a56947e14610c2f5780636d154ea514610c6b5780636d35bf9114610c915780636fe5150f14610cd757610432565b80635d8d628114610ad75780635ec88c7914610adf5780635f5af1aa14610b055780635fc7e71e14610b2b57610432565b806352d84d1e1161030b57806352d84d1e14610a4e5780635513dd4514610a6b5780635ab1bd5314610a915780635c60da1b14610a995780635c77860514610aa157610432565b80634cfd0956146109145780634e79238f146109825780634ef4c3e1146109dc57806351dff98914610a1257610432565b80632729aedb116103bf5780633c94786f1161038e5780633c94786f14610856578063414b749a1461085e57806341c728b91461086657806347ef3b3b146108a25780634a584432146108ee57610432565b80632729aedb146106e55780633449b070146106ed578063391957d7146108025780633bcf7ec11461082857610432565b80631ededc91116104065780631ededc911461063357806321af45691461067557806324008a621461069957806324a3d622146106d557806326782247146106dd57610432565b80627e3dd2146104375780630be2f17e146104535780631585f0d91461054557806318c882a514610605575b600080fd5b61043f611363565b604080519115158252519081900360200190f35b610533600480360360a081101561046957600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b81111561049857600080fd5b8201836020820111156104aa57600080fd5b803590602001918460018302840111600160201b831117156104cb57600080fd5b919390926001600160a01b0383351692604081019060200135600160201b8111156104f557600080fd5b82018360208201111561050757600080fd5b803590602001918460018302840111600160201b8311171561052857600080fd5b509092509050611368565b60408051918252519081900360200190f35b6106036004803603604081101561055b57600080fd5b810190602081018135600160201b81111561057557600080fd5b82018360208201111561058757600080fd5b803590602001918460208302840111600160201b831117156105a857600080fd5b919390929091602081019035600160201b8111156105c557600080fd5b8201836020820111156105d757600080fd5b803590602001918460208302840111600160201b831117156105f857600080fd5b509092509050611696565b005b61043f6004803603604081101561061b57600080fd5b506001600160a01b038135169060200135151561184b565b610603600480360360a081101561064957600080fd5b506001600160a01b038135811691602081013582169160408201351690606081013590608001356119ea565b61067d611a85565b604080516001600160a01b039092168252519081900360200190f35b610533600480360360808110156106af57600080fd5b506001600160a01b03813581169160208101358216916040820135169060600135611a94565b61067d611c22565b61067d611c31565b61043f611c40565b6105336004803603608081101561070357600080fd5b81359190810190604081016020820135600160201b81111561072457600080fd5b82018360208201111561073657600080fd5b803590602001918460018302840111600160201b8311171561075757600080fd5b919390929091602081019035600160201b81111561077457600080fd5b82018360208201111561078657600080fd5b803590602001918460018302840111600160201b831117156107a757600080fd5b919390929091602081019035600160201b8111156107c457600080fd5b8201836020820111156107d657600080fd5b803590602001918460018302840111600160201b831117156107f757600080fd5b509092509050611c52565b6106036004803603602081101561081857600080fd5b50356001600160a01b0316611f52565b61043f6004803603604081101561083e57600080fd5b506001600160a01b0381351690602001351515611ffd565b61043f612197565b61043f6121a7565b6106036004803603608081101561087c57600080fd5b506001600160a01b038135811691602081013590911690604081013590606001356121b8565b610603600480360360c08110156108b857600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359091169060808101359060a00135612331565b6105336004803603602081101561090457600080fd5b50356001600160a01b0316612336565b6106036004803603602081101561092a57600080fd5b810190602081018135600160201b81111561094457600080fd5b82018360208201111561095657600080fd5b803590602001918460018302840111600160201b8311171561097757600080fd5b509092509050612348565b6109be6004803603608081101561099857600080fd5b506001600160a01b038135811691602081013590911690604081013590606001356124ac565b60408051938452602084019290925282820152519081900360600190f35b610533600480360360608110156109f257600080fd5b506001600160a01b038135811691602081013590911690604001356124e5565b61060360048036036080811015610a2857600080fd5b506001600160a01b03813581169160208101359091169060408101359060600135612680565b61067d60048036036020811015610a6457600080fd5b50356127ee565b6109be60048036036020811015610a8157600080fd5b50356001600160a01b0316612815565b61067d61284c565b61067d61285b565b61060360048036036060811015610ab757600080fd5b506001600160a01b0381358116916020810135909116906040013561286a565b61067d61286f565b6109be60048036036020811015610af557600080fd5b50356001600160a01b031661287e565b61053360048036036020811015610b1b57600080fd5b50356001600160a01b0316612897565b610533600480360360a0811015610b4157600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359091169060800135612927565b61060360048036036040811015610b8757600080fd5b810190602081018135600160201b811115610ba157600080fd5b820183602082011115610bb357600080fd5b803590602001918460208302840111600160201b83111715610bd457600080fd5b919390929091602081019035600160201b811115610bf157600080fd5b820183602082011115610c0357600080fd5b803590602001918460208302840111600160201b83111715610c2457600080fd5b509092509050612a94565b61060360048036036080811015610c4557600080fd5b506001600160a01b03813581169160208101358216916040820135169060600135612c31565b61043f60048036036020811015610c8157600080fd5b50356001600160a01b0316612dda565b610603600480360360a0811015610ca757600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359091169060800135612def565b61060360048036036020811015610ced57600080fd5b50356001600160a01b0316612df4565b61043f60048036036020811015610d1357600080fd5b50356001600160a01b0316612e9f565b61053360048036036080811015610d3957600080fd5b81359190810190604081016020820135600160201b811115610d5a57600080fd5b820183602082011115610d6c57600080fd5b803590602001918460018302840111600160201b83111715610d8d57600080fd5b919390929091602081019035600160201b811115610daa57600080fd5b820183602082011115610dbc57600080fd5b803590602001918460018302840111600160201b83111715610ddd57600080fd5b919390929091602081019035600160201b811115610dfa57600080fd5b820183602082011115610e0c57600080fd5b803590602001918460018302840111600160201b83111715610e2d57600080fd5b509092509050612eb4565b61067d6131ad565b61043f6131bc565b6105336131cc565b610e7660048036036020811015610e6657600080fd5b50356001600160a01b03166131ee565b6040805196151587526020870195909552858501939093526060850191909152608084015260a0830152519081900360c00190f35b61043f60048036036020811015610ec157600080fd5b50351515613227565b61053360048036036040811015610ee057600080fd5b506001600160a01b038135169060200135613360565b61043f60048036036040811015610f0c57600080fd5b506001600160a01b03813581169160200135166134ce565b610533613501565b610533613507565b61043f60048036036020811015610f4a57600080fd5b50356001600160a01b031661350d565b610f8060048036036020811015610f7057600080fd5b50356001600160a01b0316613518565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610fbc578181015183820152602001610fa4565b505050509050019250505060405180910390f35b61043f6135a1565b610f806135b1565b6109be60048036036080811015610ff657600080fd5b506001600160a01b03813581169160208101359091169060408101359060600135613613565b61043f61362a565b61043f61363a565b6105336004803603608081101561104257600080fd5b506001600160a01b0381358116916020810135821691604082013516906060013561364a565b61067d6004803603604081101561107e57600080fd5b506001600160a01b038135169060200135613816565b610f80600480360360208110156110aa57600080fd5b810190602081018135600160201b8111156110c457600080fd5b8201836020820111156110d657600080fd5b803590602001918460208302840111600160201b831117156110f757600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061383c945050505050565b61116b6004803603606081101561114b57600080fd5b506001600160a01b038135811691602081013590911690604001356138f9565b6040805192835260208301919091528051918290030190f35b61067d613a4a565b61067d613a59565b610533600480360360a08110156111aa57600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359091169060800135613a68565b610533600480360360208110156111f057600080fd5b5035613c68565b6105336004803603606081101561120d57600080fd5b506001600160a01b03813581169160208101359091169060400135613cd1565b61067d6004803603604081101561124357600080fd5b506001600160a01b038135169060200135614120565b6105336004803603602081101561126f57600080fd5b50351515614155565b6105336004803603604081101561128e57600080fd5b506001600160a01b0381351690602001356141e4565b61043f614324565b610533614334565b610533600480360360608110156112ca57600080fd5b506001600160a01b0381358116916020810135909116906040013561433a565b6105336004803603602081101561130057600080fd5b50356001600160a01b0316614444565b6105336004803603604081101561132657600080fd5b506001600160a01b0381351690602001356145e4565b61067d61473b565b6105336004803603602081101561135a57600080fd5b5035151561474a565b600181565b600080546001600160a01b0316331461138e57611387600160246147d8565b905061168b565b6001600160a01b0388811660009081526011602090815260408083208b845290915290205416156113c557611387600160256147d8565b6002546000805460405163a8c60e8d60e01b81526001600160a01b038c811660048301908152602483018d905289821660648401529281166084830181905260c06044840190815260c484018c90529495919091169363a8c60e8d938e938e938e938e938e938e928e929160a481019060e401898980828437600083820152601f01601f191690910184810383528581526020019050858580828437600081840152601f19601f8201169050808301925050509a5050505050505050505050602060405180830381600087803b15801561149e57600080fd5b505af11580156114b2573d6000803e3d6000fd5b505050506040513d60208110156114c857600080fd5b505160408051637f4e225760e11b815290519192506001600160a01b0383169163fe9c44ae91600480820192602092909190829003018186803b15801561150e57600080fd5b505afa158015611522573d6000803e3d6000fd5b505050506040513d602081101561153857600080fd5b50506001600160a01b03811660009081526007602052604090205460ff16156115a0576040805162461bcd60e51b8152602060048201526015602482015274535550504f52545f4d41524b45545f45584953545360581b604482015290519081900360640190fd5b6001600160a01b0389811660009081526011602090815260408083208c8452825280832080546001600160a01b0319169486169485179055805160c0810182526001808252818401858152828401868152606084018781526080850188815260a086018981529989526007909752949096209251835460ff191690151517835551908201559251600284015551600383015551600582015590516006909101556116498161483e565b604080516001600160a01b038316815290517fcf583bb0c569eb967f806b11601c4cb93c10310485c67add5f8362c2f212321f9181900360200190a160009150505b979650505050505050565b6000546001600160a01b031633146116de576040805162461bcd60e51b815260206004820152600660248201526510a0b236b4b760d11b604482015290519081900360640190fd5b828181158015906116ee57508082145b61172f576040805162461bcd60e51b815260206004820152600d60248201526c1a5b9d985b1a59081a5b9c1d5d609a1b604482015290519081900360640190fd5b60005b828110156118425760006007600089898581811061174c57fe5b602090810292909201356001600160a01b0316835250810191909152604001600020805490915060ff166117b1576040805162461bcd60e51b8152602060048201526007602482015266085b1a5cdd195960ca1b604482015290519081900360640190fd5b8585838181106117bd57fe5b60200291909101356005830155508787838181106117d757fe5b905060200201356001600160a01b03166001600160a01b03167f15c142b2105636ffdf9d0aa8b10932973971c613aef1052b26d0c793c363242b87878581811061181d57fe5b905060200201356040518082815260200191505060405180910390a250600101611732565b50505050505050565b6001600160a01b03821660009081526007602052604081205460ff166118a2576040805162461bcd60e51b8152602060048201526007602482015266085b1a5cdd195960ca1b604482015290519081900360640190fd5b6008546001600160a01b03163314806118c557506000546001600160a01b031633145b61190f576040805162461bcd60e51b815260206004820152601660248201527510b830bab9b29033bab0b93234b0b73e3e30b236b4b760511b604482015290519081900360640190fd5b6000546001600160a01b031633148061192a57506001821515145b611964576040805162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b604482015290519081900360640190fd5b6001600160a01b0383166000818152600a6020908152604091829020805486151560ff199091168117909155825193845283830152606090830181905260069083015265426f72726f7760d01b6080830152517f71aec636243f9709bb0007ae15e9afb8150ab01716d75fd7573be5cc096e03b09181900360a00190a150805b92915050565b336001600160a01b03861614611a31576040805162461bcd60e51b815260206004820152600760248201526610b1aa37b5b2b760c91b604482015290519081900360640190fd5b6000611a3d86856149ca565b14611a7e576040805162461bcd60e51b815260206004820152600c60248201526b45786974206661696c75726560a01b604482015290519081900360640190fd5b5050505050565b600c546001600160a01b031681565b6001600160a01b03841660009081526007602052604081205460ff16611abc57506009611c1a565b611ac4611c40565b15611c16576000856001600160a01b031663aa5af0fd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611b0457600080fd5b505afa158015611b18573d6000803e3d6000fd5b505050506040513d6020811015611b2e57600080fd5b5051600f546040805163e3f96ae760e01b81526001600160a01b038a8116600483015260248201859052915193945091169163e3f96ae79160448082019260009290919082900301818387803b158015611b8757600080fd5b505af1158015611b9b573d6000803e3d6000fd5b5050600f54604080516310802a8760e11b81526001600160a01b038b811660048301528981166024830152604482018790529151919092169350632100550e9250606480830192600092919082900301818387803b158015611bfc57600080fd5b505af1158015611c10573d6000803e3d6000fd5b50505050505b5060005b949350505050565b6008546001600160a01b031681565b6001546001600160a01b031681565b600f546001600160a01b031615155b90565b600080546001600160a01b03163314611c71576113876001601d6147d8565b611c79611c40565b15611d0e57600f5460405163343b286f60e01b8152602060048201908152602482018790526001600160a01b039092169163343b286f91889188918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b158015611cf557600080fd5b505af1158015611d09573d6000803e3d6000fd5b505050505b600f546001600160a01b031660008915611ee5576002546000546040516320f429f760e01b8152600481018d81526001600160a01b0392831660448301819052606060248401908152606484018e905293909416936320f429f7938f938f938f93929091608401858580828437600081840152601f19601f82011690508083019250505095505050505050602060405180830381600087803b158015611db357600080fd5b505af1158015611dc7573d6000803e3d6000fd5b505050506040513d6020811015611ddd57600080fd5b50516040805163641cbbcd60e01b815290519192506001600160a01b0383169163641cbbcd91600480820192602092909190829003018186803b158015611e2357600080fd5b505afa158015611e37573d6000803e3d6000fd5b505050506040513d6020811015611e4d57600080fd5b5051611e5857600080fd5b60405163139a8e2560e31b8152602060048201908152602482018690526001600160a01b03831691639cd471289188918891908190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b158015611ecc57600080fd5b505af1158015611ee0573d6000803e3d6000fd5b505050505b600f80546001600160a01b0319166001600160a01b03838116918217909255604080519285168352602083019190915280517f0bddc3ac39ad20369cbe38e69142fbb9b4aff0b725a91ec33a1543a4509b9d6c9281900390910190a160005b9a9950505050505050505050565b6000546001600160a01b03163314611f9a576040805162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b604482015290519081900360640190fd5b600c80546001600160a01b038381166001600160a01b0319831681179093556040805191909216808252602082019390935281517feda98690e518e9a05f8ec6837663e188211b2da8f4906648b323f2c1d4434e29929181900390910190a15050565b6001600160a01b03821660009081526007602052604081205460ff16612054576040805162461bcd60e51b8152602060048201526007602482015266085b1a5cdd195960ca1b604482015290519081900360640190fd5b6008546001600160a01b031633148061207757506000546001600160a01b031633145b6120c1576040805162461bcd60e51b815260206004820152601660248201527510b830bab9b29033bab0b93234b0b73e3e30b236b4b760511b604482015290519081900360640190fd5b6000546001600160a01b03163314806120dc57506001821515145b612116576040805162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b604482015290519081900360640190fd5b6001600160a01b038316600081815260096020908152604091829020805486151560ff199091168117909155825193845283830152606090830181905260049083015263135a5b9d60e21b6080830152517f71aec636243f9709bb0007ae15e9afb8150ab01716d75fd7573be5cc096e03b09181900360a00190a150919050565b600854600160a01b900460ff1681565b6012546001600160a01b0316151590565b336001600160a01b038516146121ff576040805162461bcd60e51b815260206004820152600760248201526610b1aa37b5b2b760c91b604482015290519081900360640190fd5b6001600160a01b0384166000908152600760205260409020805460ff16612257576040805162461bcd60e51b8152602060048201526007602482015266085b1a5cdd195960ca1b604482015290519081900360640190fd5b6001600160a01b038416600090815260048201602052604090205460ff1615611a7e576040805160c081018252825460ff1615158152600183015460208201526002830154918101919091526003820154606082015260058201546080820152600682015460a08201526000906122d090879085614b0d565b9050801561231e576040805162461bcd60e51b81526020600482015260166024820152751858dd1a5d985d1a5bdb881b9bdd08185b1b1bddd95960521b604482015290519081900360640190fd5b612329828488614c3b565b505050505050565b612329565b600d6020526000908152604090205481565b612350614ca3565b61238a576040805162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b604482015290519081900360640190fd5b60005b600b548110156124a7576000600b82815481106123a657fe5b60009182526020822001546040805163bc3246d960e01b81526004810184815260248201928352604482018890526001600160a01b039093169450849363bc3246d9939092899289929190606401848480828437600081840152601f19601f820116905080830192505050945050505050602060405180830381600087803b15801561243157600080fd5b505af1158015612445573d6000803e3d6000fd5b505050506040513d602081101561245b57600080fd5b505161249e576040805162461bcd60e51b815260206004820152600d60248201526c155c19185d194819985a5b1959609a1b604482015290519081900360640190fd5b5060010161238d565b505050565b6000806000806000806124c38a8a8a8a6001614cb4565b5092509250925082601a8111156124d657fe5b9a919950975095505050505050565b6001600160a01b03831660009081526009602052604081205460ff161561253c576040805162461bcd60e51b81526020600482015260066024820152651c185d5cd95960d21b604482015290519081900360640190fd5b6001600160a01b03841660009081526007602052604090205460ff166125665760095b9050612679565b601254600160a01b900460ff168015612585575061258383615000565b155b1561259157601961255f565b612599611c40565b1561267357600f546040805163082bc0ab60e01b81526001600160a01b0387811660048301529151919092169163082bc0ab91602480830192600092919082900301818387803b1580156125ec57600080fd5b505af1158015612600573d6000803e3d6000fd5b5050600f546040805163013d52cf60e61b81526001600160a01b03898116600483015288811660248301529151919092169350634f54b3c09250604480830192600092919082900301818387803b15801561265a57600080fd5b505af115801561266e573d6000803e3d6000fd5b505050505b60005b90505b9392505050565b8015801561268e5750600082115b156126d4576040805162461bcd60e51b815260206004820152601160248201527072656465656d546f6b656e73207a65726f60781b604482015290519081900360640190fd5b336001600160a01b0385161461271b576040805162461bcd60e51b815260206004820152600760248201526610b1aa37b5b2b760c91b604482015290519081900360640190fd5b6001600160a01b0384166000908152600760205260409020805460ff16612773576040805162461bcd60e51b8152602060048201526007602482015266085b1a5cdd195960ca1b604482015290519081900360640190fd5b6001600160a01b038416600090815260048201602052604090205460ff1615611a7e5760006127a286866149ca565b146127e3576040805162461bcd60e51b815260206004820152600c60248201526b45786974206661696c75726560a01b604482015290519081900360640190fd5b611a7e818387615097565b600b81815481106127fb57fe5b6000918252602090912001546001600160a01b0316905081565b60008060008060008061282d87600080600080614cb4565b5092509250925082601a81111561284057fe5b97919650945092505050565b6002546001600160a01b031690565b6003546001600160a01b031681565b6124a7565b6010546001600160a01b031681565b60008060008060008061282d8760008060006001614cb4565b600080546001600160a01b031633146128bd576128b6600160136147d8565b9050612922565b600880546001600160a01b038481166001600160a01b0319831617928390556040805192821680845293909116602083015280517f0613b6ee6a04f0d09f390e4d9318894b9f6ac7fd83897cd8d18896ba579c401e9281900390910190a160005b9150505b919050565b6001600160a01b03851660009081526007602052604081205460ff16158061296857506001600160a01b03851660009081526007602052604090205460ff16155b156129775760095b9050612a8b565b6000806129858560006150a8565b9193509091506000905082601a81111561299b57fe5b146129b55781601a8111156129ac57fe5b92505050612a8b565b806129c15760036129ac565b6000886001600160a01b03166395dd9193876040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015612a1957600080fd5b505afa158015612a2d573d6000803e3d6000fd5b505050506040513d6020811015612a4357600080fd5b505160408051602081019091526706f05b59d3b200008152909150600090612a6b90836150d2565b905080861115612a82576011945050505050612a8b565b60009450505050505b95945050505050565b6000546001600160a01b0316331480612ab75750600c546001600160a01b031633145b612b08576040805162461bcd60e51b815260206004820152601b60248201527f2161646d696e7c7c626f72726f772063617020677561726469616e0000000000604482015290519081900360640190fd5b82818115801590612b1857508082145b612b59576040805162461bcd60e51b815260206004820152600d60248201526c1a5b9d985b1a59081a5b9c1d5d609a1b604482015290519081900360640190fd5b60005b8281101561184257848482818110612b7057fe5b90506020020135600d6000898985818110612b8757fe5b905060200201356001600160a01b03166001600160a01b03166001600160a01b0316815260200190815260200160002081905550868682818110612bc757fe5b905060200201356001600160a01b03166001600160a01b03167f6f1951b2aad10f3fc81b86d91105b413a5b3f847a34bbc5ce1904201b14438f6868684818110612c0d57fe5b905060200201356040518082815260200191505060405180910390a2600101612b5c565b336001600160a01b03851614612c78576040805162461bcd60e51b815260206004820152600760248201526610b1aa37b5b2b760c91b604482015290519081900360640190fd5b6001600160a01b0384166000908152600760205260409020805460ff16612cd0576040805162461bcd60e51b8152602060048201526007602482015266085b1a5cdd195960ca1b604482015290519081900360640190fd5b6001600160a01b03808516600090815260048301602052604080822054928616825290205460ff91821691168115158115151415612d1057505050612dd4565b8115612d2957612d21838589615097565b505050612dd4565b8015611842576040805160c081018252845460ff1615158152600185015460208201526002850154918101919091526003840154606082015260058401546080820152600684015460a0820152600090612d8590899087614b0d565b90508015612dc45760405162461bcd60e51b8152600401808060200182810382526024815260200180615aa06024913960400191505060405180910390fd5b612dcf84868a614c3b565b505050505b50505050565b600a6020526000908152604090205460ff1681565b611a7e565b6000546001600160a01b03163314612e3c576040805162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b604482015290519081900360640190fd5b601080546001600160a01b038381166001600160a01b0319831681179093556040805191909216808252602082019390935281517f28c64e943e75106f97d3eb36ac861e9e5a6a505f02844b600839c616bd621b93929181900390910190a15050565b60096020526000908152604090205460ff1681565b600080546001600160a01b03163314612ed357611387600160206147d8565b6012546001600160a01b03166000612ee96121a7565b15612f7e5760125460405163343b286f60e01b8152602060048201908152602482018990526001600160a01b039092169163343b286f918a918a918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b158015612f6557600080fd5b505af1158015612f79573d6000803e3d6000fd5b505050505b8915613147576002546000546040516320f429f760e01b8152600481018d81526001600160a01b0392831660448301819052606060248401908152606484018e905293909416936320f429f7938f938f938f93929091608401858580828437600081840152601f19601f82011690508083019250505095505050505050602060405180830381600087803b15801561301557600080fd5b505af1158015613029573d6000803e3d6000fd5b505050506040513d602081101561303f57600080fd5b505160408051630dcbcf6160e11b815290519192506001600160a01b03831691631b979ec291600480820192602092909190829003018186803b15801561308557600080fd5b505afa158015613099573d6000803e3d6000fd5b505050506040513d60208110156130af57600080fd5b50516130ba57600080fd5b60405163139a8e2560e31b8152602060048201908152602482018690526001600160a01b03831691639cd471289188918891908190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b15801561312e57600080fd5b505af1158015613142573d6000803e3d6000fd5b505050505b601280546001600160a01b0319166001600160a01b03838116919091179182905560408051858316815292909116602083015280517fa51edf6e828645dee840b3226b1d377ed0b995c202e66555a5f4960d808b509a9281900390910190a16000611f44565b6002546001600160a01b031681565b600854600160b01b900460ff1681565b60408051692ab734ba3937b63632b960b11b8152905190819003600a01902081565b60076020526000908152604090208054600182015460028301546003840154600585015460069095015460ff9094169492939192909186565b6008546000906001600160a01b031633148061324d57506000546001600160a01b031633145b613297576040805162461bcd60e51b815260206004820152601660248201527510b830bab9b29033bab0b93234b0b73e3e30b236b4b760511b604482015290519081900360640190fd5b6000546001600160a01b03163314806132b257506001821515145b6132ec576040805162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b604482015290519081900360640190fd5b60088054831515600160b01b810260ff60b01b1990921691909117825560408051602081019290925280825281810192909252672a3930b739b332b960c11b606082015290517fef159d9a32b2472e32b098f954f3ce62d232939f1c207070b584df1814de2de09181900360800190a15090565b600080546001600160a01b031633146133865761337f6001600b6147d8565b90506119e4565b6001600160a01b0383166000908152600760205260409020805460ff166133bb576133b3600960146147d8565b9150506119e4565b6133c36159dd565b5060408051602081019091528381526133da6159dd565b50604080516020810190915267120a871cc002000081526133f96159dd565b506040805160208101909152670e92596fd6290000815261341a82846150f1565b8061342a575061342a83826150f1565b156134465761343b6007600c6147d8565b9450505050506119e4565b851580159061345b5750613459876150f8565b155b1561346c5761343b600d60156147d8565b60038401805490879055604080516001600160a01b038a1681526020810183905280820189905290517f27341352c0a718639d6e997adf9031500037bcdf0e1a0396469ea59fdd815ed89181900360600190a160005b98975050505050505050565b6001600160a01b038082166000908152600760209081526040808320938616835260049093019052205460ff1692915050565b60055481565b600e5481565b60006119e482615000565b60608060066000846001600160a01b03166001600160a01b0316815260200190815260200160002080548060200260200160405190810160405280929190818152602001828054801561359457602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311613576575b5093979650505050505050565b600854600160b81b900460ff1681565b6060600b80548060200260200160405190810160405280929190818152602001828054801561360957602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116135eb575b5050505050905090565b6000806000806000806124c38a8a8a8a6000614cb4565b601254600160a81b900460ff1681565b601254600160a01b900460ff1681565b600854600090600160b01b900460ff161561369e576040805162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c881c185d5cd959608a1b604482015290519081900360640190fd5b60006136ab86868561517b565b905080156136ba579050611c1a565b6136c2611c40565b1561380a57600f546040805163082bc0ab60e01b81526001600160a01b0389811660048301529151919092169163082bc0ab91602480830192600092919082900301818387803b15801561371557600080fd5b505af1158015613729573d6000803e3d6000fd5b5050600f546040805163013d52cf60e61b81526001600160a01b038b811660048301528a811660248301529151919092169350634f54b3c09250604480830192600092919082900301818387803b15801561378357600080fd5b505af1158015613797573d6000803e3d6000fd5b5050600f546040805163013d52cf60e61b81526001600160a01b038b8116600483015289811660248301529151919092169350634f54b3c09250604480830192600092919082900301818387803b1580156137f157600080fd5b505af1158015613805573d6000803e3d6000fd5b505050505b60009695505050505050565b60116020908152600092835260408084209091529082529020546001600160a01b031681565b6060600082519050606081604051908082528060200260200182016040528015613870578160200160208202803883390190505b50905060005b828110156138f157600085828151811061388c57fe5b6020026020010151905060006138a28233615221565b9050600081601a8111156138b257fe5b146138c4576138c281601e6147d8565b505b80601a8111156138d057fe5b8484815181106138dc57fe5b60209081029190910101525050600101613876565b509392505050565b6000806000613907866150f8565b90506000613914866150f8565b9050811580613921575080155b1561393657600d935060009250613a42915050565b6000866001600160a01b031663182df0f56040518163ffffffff1660e01b815260040160206040518083038186803b15801561397157600080fd5b505afa158015613985573d6000803e3d6000fd5b505050506040513d602081101561399b57600080fd5b5051905060006139a96159dd565b6139b16159dd565b6139b96159dd565b60408051602080820183526001600160a01b038e1660009081526007825283902060030154825282519081019092528882526139f491615415565b9250613a1c604051806020016040528088815250604051806020016040528088815250615415565b9150613a288383615454565b9050613a34818b6150d2565b600099509750505050505050505b935093915050565b6012546001600160a01b031681565b600f546001600160a01b031681565b6001600160a01b03851660009081526007602052604081205460ff161580613aa957506001600160a01b03851660009081526007602052604090205460ff16155b15613ab5576009612970565b846001600160a01b0316635fe3b5676040518163ffffffff1660e01b815260040160206040518083038186803b158015613aee57600080fd5b505afa158015613b02573d6000803e3d6000fd5b505050506040513d6020811015613b1857600080fd5b505160408051635fe3b56760e01b815290516001600160a01b0392831692891691635fe3b567916004808301926020929190829003018186803b158015613b5e57600080fd5b505afa158015613b72573d6000803e3d6000fd5b505050506040513d6020811015613b8857600080fd5b50516001600160a01b031614613b9f576002612970565b613ba7611c40565b1561380a57600f546040805163082bc0ab60e01b81526001600160a01b0389811660048301529151919092169163082bc0ab91602480830192600092919082900301818387803b158015613bfa57600080fd5b505af1158015613c0e573d6000803e3d6000fd5b5050600f546040805163013d52cf60e61b81526001600160a01b038b8116600483015288811660248301529151919092169350634f54b3c09250604480830192600092919082900301818387803b15801561378357600080fd5b600080546001600160a01b03163314613c87576128b6600160236147d8565b600e805490839055604080518281526020810185905281517f0d1cec2fe7161ad8390aae24dcb735b68842b59ffc4898ee5865a7577d1663f8929181900390910190a1600061291e565b6001600160a01b0383166000908152600a602052604081205460ff1615613d28576040805162461bcd60e51b81526020600482015260066024820152651c185d5cd95960d21b604482015290519081900360640190fd5b6001600160a01b03841660009081526007602052604090205460ff16613d4f57600961255f565b601254600160a81b900460ff168015613d6e5750613d6c83615000565b155b15613d7a57601a61255f565b6001600160a01b038085166000908152600760209081526040808320938716835260049093019052205460ff16613e5c57336001600160a01b03851614613df2576040805162461bcd60e51b815260206004820152600760248201526610b1aa37b5b2b760c91b604482015290519081900360640190fd5b6000613dfe3385615221565b9050600081601a811115613e0e57fe5b14613e275780601a811115613e1f57fe5b915050612679565b6001600160a01b038086166000908152600760209081526040808320938816835260049093019052205460ff16613e5a57fe5b505b613e65846150f8565b613e7057600d61255f565b6001600160a01b0384166000908152600d60205260409020548015613f52576000856001600160a01b03166347bd37186040518163ffffffff1660e01b815260040160206040518083038186803b158015613eca57600080fd5b505afa158015613ede573d6000803e3d6000fd5b505050506040513d6020811015613ef457600080fd5b505190506000613f048286615490565b9050828110613f4f576040805162461bcd60e51b8152602060048201526012602482015271109bdc9c9bddc818d85c081c995858da195960721b604482015290519081900360640190fd5b50505b6000806000613f6687896000896001614cb4565b92955093509091506000905083601a811115613f7e57fe5b14613f9a5782601a811115613f8f57fe5b945050505050612679565b8115613fa7576004613f8f565b600e54811015613fb8576013613f8f565b613fc0611c40565b15614112576000886001600160a01b031663aa5af0fd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561400057600080fd5b505afa158015614014573d6000803e3d6000fd5b505050506040513d602081101561402a57600080fd5b5051600f546040805163e3f96ae760e01b81526001600160a01b038d8116600483015260248201859052915193945091169163e3f96ae79160448082019260009290919082900301818387803b15801561408357600080fd5b505af1158015614097573d6000803e3d6000fd5b5050600f54604080516310802a8760e11b81526001600160a01b038e811660048301528d81166024830152604482018790529151919092169350632100550e9250606480830192600092919082900301818387803b1580156140f857600080fd5b505af115801561410c573d6000803e3d6000fd5b50505050505b600098975050505050505050565b6006602052816000526040600020818154811061413957fe5b6000918252602090912001546001600160a01b03169150829050565b600080546001600160a01b03163314614174576128b6600160216147d8565b60125460ff600160a01b909104161515821515146141dd5760128054831515600160a01b810260ff60a01b199092169190911790915560408051918252517f0f2b33907466abbbfdd67603d9c300ddd6ca665d28046df8df4b5f525be5f3029181900360200190a15b60006119e4565b600080546001600160a01b031633146142035761337f600160066147d8565b6001600160a01b0383166000908152600760205260409020805460ff16614230576133b3600960076147d8565b6142386159dd565b50604080516020810190915283815261424f6159dd565b506040805160208101909152670c7d713b49da0000815261427081836150f1565b1561428b57614281600660086147d8565b93505050506119e4565b6002830154808611156142a45761343b6006601c6147d8565b85158015906142b957506142b7876150f8565b155b156142ca5761343b600d60096147d8565b60018401805490879055604080516001600160a01b038a1681526020810183905280820189905290517f70483e6592cd5182d45ac970e05bc62cdcc90e9d8ef2c2dbe686cf383bcd7fc59181900360600190a160006134c2565b600854600160a81b900460ff1681565b60045481565b60008061434885858561517b565b90508015614357579050612679565b61435f611c40565b1561443957600f546040805163082bc0ab60e01b81526001600160a01b0388811660048301529151919092169163082bc0ab91602480830192600092919082900301818387803b1580156143b257600080fd5b505af11580156143c6573d6000803e3d6000fd5b5050600f546040805163013d52cf60e61b81526001600160a01b038a8116600483015289811660248301529151919092169350634f54b3c09250604480830192600092919082900301818387803b15801561442057600080fd5b505af1158015614434573d6000803e3d6000fd5b505050505b600095945050505050565b6000808290506000806000836001600160a01b031663c37f68e2336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060806040518083038186803b1580156144a557600080fd5b505afa1580156144b9573d6000803e3d6000fd5b505050506040513d60808110156144cf57600080fd5b50805160208201516040909201519094509092509050821561452a576040805162461bcd60e51b815260206004820152600f60248201526e14db985c1cda1bdd0819985a5b1959608a1b604482015290519081900360640190fd5b80156145475761453c600c60026147d8565b945050505050612922565b600061455487338561517b565b9050801561457557614569600e6003836154c6565b95505050505050612922565b6001600160a01b0387166000908152600760209081526040808320338452600481019092529091205460ff16156141125760006145b382883361552c565b905080156145c957965061292295505050505050565b6145d4828689615097565b6000975050505050505050612922565b600080546001600160a01b031633146146035761337f600160166147d8565b6001600160a01b0383166000908152600760205260409020805460ff16614630576133b3600960176147d8565b6146386159dd565b50604080516020810190915283815261464f6159dd565b506040805160208101909152670c7d713b49da0000815261467081836150f1565b1561468157614281601560186147d8565b60018301548086101561469a5761343b6015601a6147d8565b60028401548681106146be576146b26015601b6147d8565b955050505050506119e4565b86158015906146d357506146d1886150f8565b155b156146e4576146b2600d60196147d8565b60028501879055604080516001600160a01b038a1681526020810183905280820189905290517f70483e6592cd5182d45ac970e05bc62cdcc90e9d8ef2c2dbe686cf383bcd7fc59181900360600190a160006134c2565b6000546001600160a01b031681565b600080546001600160a01b03163314614769576128b6600160226147d8565b60125460ff600160a81b909104161515821515146141dd5760128054831515600160a81b810260ff60a81b199092169190911790915560408051918252517f184d49ac9ba8757ec2d7e6149ea0548d75fd263fb34d2d8fa67a989e9dc45f209181900360200190a160006119e4565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa083601a81111561480757fe5b83602581111561481357fe5b604080519283526020830191909152600082820152519081900360600190a182601a81111561267957fe5b600b5460191015614888576040805162461bcd60e51b815260206004820152600f60248201526e546f6f206d616e792061737365747360881b604482015290519081900360640190fd5b60005b600b5481101561490c57816001600160a01b0316600b82815481106148ac57fe5b6000918252602090912001546001600160a01b03161415614904576040805162461bcd60e51b815260206004820152600d60248201526c105b1c9958591e481859191959609a1b604482015290519081900360640190fd5b60010161488b565b50600b80546001810182556000919091527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db90180546001600160a01b0319166001600160a01b038316179055614960611c40565b156149c757600f54604080516353b59fed60e11b81526001600160a01b0384811660048301529151919092169163a76b3fda91602480830192600092919082900301818387803b1580156149b357600080fd5b505af1158015611a7e573d6000803e3d6000fd5b50565b6000808390506000806000836001600160a01b031663c37f68e2876040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060806040518083038186803b158015614a2b57600080fd5b505afa158015614a3f573d6000803e3d6000fd5b505050506040513d6080811015614a5557600080fd5b508051602082015160409092015190945090925090508215614ab0576040805162461bcd60e51b815260206004820152600f60248201526e14db985c1cda1bdd0819985a5b1959608a1b604482015290519081900360640190fd5b81158015614abc575080155b15614b06576001600160a01b038088166000908152600760209081526040808320938a1683526004840190915290205460ff1615614aff576146b281898961552c565b60006146b2565b600061343b565b608082015160a08301516000919081614b2c5760005b92505050612679565b83614b38576000614b23565b6000614b448286615490565b90506000876001600160a01b031663182df0f56040518163ffffffff1660e01b815260040160206040518083038186803b158015614b8157600080fd5b505afa158015614b95573d6000803e3d6000fd5b505050506040513d6020811015614bab57600080fd5b50519050614bb76159dd565b5060408051602081019091528181526000614bd18a6150f8565b905080614be757600d9650505050505050612679565b614bef6159dd565b5060408051602081019091528181526000614c0a86856156e1565b90506000614c1882846156e1565b9050888111614c345760005b9950505050505050505050612679565b6018614c24565b60068301546000614c4c8285615490565b60068601819055604080518481526020810183905281519293506001600160a01b038616927fd6546a453e5baf961a119a10c0c930e1e420dd5111b9a6ddc8a9b5947c4eda71929181900390910190a25050505050565b6000546001600160a01b0316331490565b600080600080614cc26159f0565b6001600160a01b038a1660009081526006602090815260408083208054825181850281018501909352808352606093830182828015614d2a57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311614d0c575b50939450600093505050505b8151811015614fa6576000828281518110614d4d57fe5b60200260200101519050806001600160a01b031663c37f68e28f6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060806040518083038186803b158015614dad57600080fd5b505afa158015614dc1573d6000803e3d6000fd5b505050506040513d6080811015614dd757600080fd5b508051602082015160408084015160609485015160808b0152938901939093529187019190915293508315614e1f5750600f975060009650869550859450614ff49350505050565b8915614e585760408051602080820183526001600160a01b038416600090815260079091529190912060010154815260c0860152614e87565b60408051602080820183526001600160a01b038416600090815260079091529190912060020154815260c08601525b60408051602081019091526080860151815260e0860152614ea7816150f8565b60a08601819052614ecb5750600d975060009650869550859450614ff49350505050565b604080516020810190915260a0860151815261010086015260c085015160e0860151614f0591614efa91615415565b866101000151615415565b610120860181905260408601518651614f1f929190615709565b855261010085015160608601516020870151614f3c929190615709565b60208601526001600160a01b03818116908e161415614f9d57614f698561012001518d8760200151615709565b60208601819052610100860151614f81918d90615709565b6020860152610100850151614f96908c6150d2565b6101408601525b50600101614d36565b50602083015183511115614fd6575050602081015181516101409092015160009650910393508492509050614ff4565b50508051602082015161014090920151600096508695509103925090505b95509550955095915050565b600061500a6121a7565b1561508f576012546040805163a4a9592b60e01b81526001600160a01b0385811660048301529151919092169163a4a9592b916024808301926020929190829003018186803b15801561505c57600080fd5b505afa158015615070573d6000803e3d6000fd5b505050506040513d602081101561508657600080fd5b50519050612922565b506000612922565b60068301546000614c4c8285615731565b6000806000806000806150c08860008060008b614cb4565b50919750955093505050509250925092565b60006150dc6159dd565b6150e6848461576b565b9050611c1a8161578c565b5190511090565b60025460408051632640b63f60e11b81526001600160a01b03848116600483015291516000939290921691634c816c7e91602480820192602092909190829003018186803b15801561514957600080fd5b505afa15801561515d573d6000803e3d6000fd5b505050506040513d602081101561517357600080fd5b505192915050565b6001600160a01b03831660009081526007602052604081205460ff166151a257600961255f565b6001600160a01b038085166000908152600760209081526040808320938716835260049093019052205460ff166151da57600061255f565b6000806151ec85878660006001614cb4565b509193509091506000905082601a81111561520357fe5b146152145781601a811115614b2357fe5b801561380a576004614b23565b6001600160a01b0382166000908152600760205260408120805460ff1661524c5760099150506119e4565b6001600160a01b038316600090815260048201602052604090205460ff1615156001141561527e5760009150506119e4565b6000846001600160a01b03166370a08231856040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156152d657600080fd5b505afa1580156152ea573d6000803e3d6000fd5b505050506040513d602081101561530057600080fd5b50516040805160c081018252845460ff1615158152600185015460208201526002850154918101919091526003840154606082015260058401546080820152600684015460a082015290915060009061535b90879084614b0d565b9050801561536f5780601a81111561428157fe5b61537a838388614c3b565b6001600160a01b0380861660008181526004860160209081526040808320805460ff1916600190811790915560068352818420805491820181558452928290209092018054948b166001600160a01b031990951685179055815193845283019190915280517f3ab23ab0d51cccc0c3085aec51f99228625aa1a922b3a8ca89a26b0f2027a1a59281900390910190a150600095945050505050565b61541d6159dd565b6040518060200160405280670de0b6b3a76400006154438660000151866000015161579b565b8161544a57fe5b0490529392505050565b61545c6159dd565b60405180602001604052806154876154808660000151670de0b6b3a764000061579b565b85516157dd565b90529392505050565b60006126798383604051806040016040528060118152602001706164646974696f6e206f766572666c6f7760781b815250615810565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa084601a8111156154f557fe5b84602581111561550157fe5b604080519283526020830191909152818101859052519081900360600190a183601a81111561267657fe5b6001600160a01b03811660009081526004840160209081526040808320805460ff191690556006825280832080548251818502810185019093528083526060938301828280156155a557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311615587575b5050835193945083925060009150505b828110156155fa57866001600160a01b03168482815181106155d357fe5b60200260200101516001600160a01b031614156155f2578091506155fa565b6001016155b5565b5081811061560757600080fd5b6001600160a01b038516600090815260066020526040902080548190600019810190811061563157fe5b9060005260206000200160009054906101000a90046001600160a01b031681838154811061565b57fe5b600091825260209091200180546001600160a01b0319166001600160a01b03929092169190911790558054615694826000198301615a62565b50604080516001600160a01b03808a1682528816602082015281517fe699a64c18b07ac5b7301aa273f36a2287239eb9501d81950672794afba29a0d929181900390910190a160006134c2565b6000670de0b6b3a76400006156fa84846000015161579b565b8161570157fe5b049392505050565b60006157136159dd565b61571d858561576b565b9050612a8b61572b8261578c565b84615490565b60006126798383604051806040016040528060158152602001747375627472616374696f6e20756e646572666c6f7760581b8152506158ab565b6157736159dd565b604051806020016040528061548785600001518561579b565b51670de0b6b3a7640000900490565b600061267983836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f77000000000000000000815250615905565b600061267983836040518060400160405280600e81526020016d646976696465206279207a65726f60901b81525061597b565b600083830182858210156158a25760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561586757818101518382015260200161584f565b50505050905090810190601f1680156158945780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50949350505050565b600081848411156158fd5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561586757818101518382015260200161584f565b505050900390565b6000831580615912575082155b1561591f57506000612679565b8383028385828161592c57fe5b041483906158a25760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561586757818101518382015260200161584f565b600081836159ca5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561586757818101518382015260200161584f565b508284816159d457fe5b04949350505050565b6040518060200160405280600081525090565b604051806101600160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001615a2e6159dd565b8152602001615a3b6159dd565b8152602001615a486159dd565b8152602001615a556159dd565b8152602001600081525090565b8154818355818111156124a7576000838152602090206124a7918101908301611c4f91905b80821115615a9b5760008155600101615a87565b509056fe436f6c6c61746572616c2061637469766174696f6e206973206e6f7420616c6c6f776564a265627a7a72315820cfa8a113365c036b515c57205fe3d33170de4b155e2bf2308c8bb83de926e0a664736f6c63430005100032

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.