MNT Price: $0.84 (-6.73%)

Contract

0x423bB7577BCf594df986D9646B44D3144b3329FD
 

Overview

MNT Balance

Mantle Mainnet Network LogoMantle Mainnet Network LogoMantle Mainnet Network Logo0 MNT

MNT Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Age:90D
Reset Filter

Transaction Hash
Block
From
To

There are no matching entries

Update your filters to view other transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:

Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
LendingPool

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

import '../common/library/InitErrors.sol';
import {UnderACM} from '../common/UnderACM.sol';
import {ILendingPool} from '../interfaces/lending_pool/ILendingPool.sol';
import {IIRM} from '../interfaces/lending_pool/IIRM.sol';

import {ERC20Upgradeable} from '@openzeppelin-contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol';
import {IERC20Metadata} from '@openzeppelin-contracts/token/ERC20/extensions/IERC20Metadata.sol';
import {SafeERC20} from '@openzeppelin-contracts/token/ERC20/utils/SafeERC20.sol';
import {IERC20} from '@openzeppelin-contracts/token/ERC20/IERC20.sol';
import {MathUpgradeable} from '@openzeppelin-contracts-upgradeable/utils/math/MathUpgradeable.sol';

contract LendingPool is ERC20Upgradeable, ILendingPool, UnderACM {
    using SafeERC20 for IERC20;
    using MathUpgradeable for uint;

    // constants
    uint private constant ONE_E18 = 1e18;
    uint8 private constant VIRTUAL_SHARE_DECIMALS = 8;
    uint private constant VIRTUAL_SHARES = 10 ** VIRTUAL_SHARE_DECIMALS;
    uint private constant VIRTUAL_ASSETS = 1;
    bytes32 private constant GUARDIAN = keccak256('guardian');
    bytes32 private constant GOVERNOR = keccak256('governor');

    // immutables
    address public immutable core;

    // storages
    address public underlyingToken; // underlying tokens
    uint public cash; // total cash
    uint public totalDebt; // total debt
    uint public totalDebtShares; // total debt shares
    address public irm; // interest rate model
    uint public lastAccruedTime; // last accrued timestamp
    uint public reserveFactor_e18; // reserve factor
    address public treasury; // treasury address

    // modifiers
    modifier onlyGuardian() {
        ACM.checkRole(GUARDIAN, msg.sender);
        _;
    }

    modifier onlyGovernor() {
        ACM.checkRole(GOVERNOR, msg.sender);
        _;
    }

    modifier onlyCore() {
        _require(msg.sender == core, Errors.NOT_INIT_CORE);
        _;
    }

    modifier accrue() {
        accrueInterest();
        _;
    }

    // constructor
    constructor(address _core, address _acm) UnderACM(_acm) {
        _disableInitializers();
        core = _core;
    }

    // initializer
    /// @dev initialize contract and setup underlying token, name, symbol
    ///     interest rate model, reserver factor and treasury
    /// @param _underlyingToken underlying token address
    /// @param _name lending pool's name
    /// @param _symbol lending pool's symbol
    /// @param _irm interest rate model address
    /// @param _reserveFactor_e18 reserve factor in 1e18 (1e18 = 100%)
    /// @param _treasury treasury address
    function initialize(
        address _underlyingToken,
        string calldata _name,
        string calldata _symbol,
        address _irm,
        uint _reserveFactor_e18,
        address _treasury
    ) external initializer {
        underlyingToken = _underlyingToken;
        __ERC20_init(_name, _symbol);
        irm = _irm;
        treasury = _treasury;
        lastAccruedTime = block.timestamp;
        reserveFactor_e18 = _reserveFactor_e18;
        // approve core to enable flashloan
        IERC20(_underlyingToken).safeApprove(core, type(uint).max);
    }

    // functions
    /// @inheritdoc ERC20Upgradeable
    function decimals() public view override returns (uint8) {
        return IERC20Metadata(underlyingToken).decimals() + VIRTUAL_SHARE_DECIMALS;
    }

    /// @inheritdoc ILendingPool
    function mint(address _receiver) external onlyCore accrue returns (uint shares) {
        uint _cash = cash;
        uint newCash = IERC20(underlyingToken).balanceOf(address(this));
        uint amt = newCash - _cash;
        shares = _toShares(amt, _cash + totalDebt, totalSupply());
        _require(shares != 0, Errors.ZERO_VALUE);
        _mint(_receiver, shares);
        cash = newCash;
    }

    /// @inheritdoc ILendingPool
    function burn(address _receiver) external onlyCore accrue returns (uint amt) {
        uint sharesToBurn = balanceOf(address(this));
        uint _cash = cash;
        _require(sharesToBurn != 0, Errors.ZERO_VALUE);
        amt = _toAmt(sharesToBurn, _cash + totalDebt, totalSupply());
        _require(amt <= _cash, Errors.NOT_ENOUGH_CASH);
        unchecked {
            cash = _cash - amt;
        }
        _burn(address(this), sharesToBurn);
        IERC20(underlyingToken).safeTransfer(_receiver, amt);
    }

    /// @inheritdoc ILendingPool
    function borrow(address _receiver, uint _amt) external onlyCore accrue returns (uint shares) {
        _require(_amt <= cash, Errors.NOT_ENOUGH_CASH);
        uint _totalDebt = totalDebt;
        shares = _totalDebt > 0 ? _amt.mulDiv(totalDebtShares, _totalDebt, MathUpgradeable.Rounding.Up) : _amt;
        totalDebtShares += shares;
        totalDebt = _totalDebt + _amt;
        unchecked {
            cash -= _amt;
        }
        IERC20(underlyingToken).safeTransfer(_receiver, _amt);
    }

    /// @inheritdoc ILendingPool
    function repay(uint _shares) external onlyCore accrue returns (uint amt) {
        uint _totalDebtShares = totalDebtShares;
        uint _totalDebt = totalDebt;
        amt = _shares.mulDiv(_totalDebt, _totalDebtShares, MathUpgradeable.Rounding.Up);
        uint newCash = IERC20(underlyingToken).balanceOf(address(this));
        _require(amt <= newCash - cash, Errors.INVALID_AMOUNT_TO_REPAY);
        totalDebtShares = _totalDebtShares - _shares;
        totalDebt = _totalDebt > amt ? _totalDebt - amt : 0;
        cash = newCash;
    }

    /// @inheritdoc ILendingPool
    function accrueInterest() public {
        uint _lastAccruedTime = lastAccruedTime;
        if (block.timestamp != _lastAccruedTime) {
            uint _totalDebt = totalDebt;
            uint _cash = cash;
            uint borrowRate_e18 = IIRM(irm).getBorrowRate_e18(_cash, _totalDebt);
            uint accruedInterest = (borrowRate_e18 * (block.timestamp - _lastAccruedTime) * _totalDebt) / ONE_E18;
            uint reserve = (accruedInterest * reserveFactor_e18) / ONE_E18;
            if (reserve > 0) {
                _mint(treasury, _toShares(reserve, _cash + _totalDebt + accruedInterest - reserve, totalSupply()));
            }
            totalDebt = _totalDebt + accruedInterest;
            lastAccruedTime = block.timestamp;
        }
    }

    /// @inheritdoc ILendingPool
    function debtAmtToShareStored(uint _amt) public view returns (uint shares) {
        shares = totalDebt > 0 ? _amt.mulDiv(totalDebtShares, totalDebt, MathUpgradeable.Rounding.Up) : _amt;
    }

    /// @inheritdoc ILendingPool
    function debtAmtToShareCurrent(uint _amt) external accrue returns (uint shares) {
        shares = debtAmtToShareStored(_amt);
    }

    /// @inheritdoc ILendingPool
    function debtShareToAmtStored(uint _shares) public view returns (uint amt) {
        amt = totalDebtShares > 0 ? _shares.mulDiv(totalDebt, totalDebtShares, MathUpgradeable.Rounding.Up) : 0;
    }

    /// @inheritdoc ILendingPool
    function debtShareToAmtCurrent(uint _shares) external accrue returns (uint amt) {
        amt = debtShareToAmtStored(_shares);
    }

    /// @inheritdoc ILendingPool
    function toShares(uint _amt) public view returns (uint shares) {
        shares = _toShares(_amt, totalAssets(), totalSupply());
    }

    /// @inheritdoc ILendingPool
    function toAmt(uint _shares) public view returns (uint amt) {
        amt = _toAmt(_shares, totalAssets(), totalSupply());
    }

    /// @inheritdoc ILendingPool
    function toSharesCurrent(uint _amt) external accrue returns (uint shares) {
        shares = toShares(_amt);
    }

    /// @inheritdoc ILendingPool
    function toAmtCurrent(uint _shares) external accrue returns (uint amt) {
        amt = toAmt(_shares);
    }

    /// @inheritdoc ILendingPool
    function getSupplyRate_e18() external view returns (uint supplyRate_e18) {
        uint _totalDebt = totalDebt;
        uint _cash = cash;
        uint borrowRate_e18 = IIRM(irm).getBorrowRate_e18(_cash, _totalDebt);
        // supply rate = borrow rate * (1 - reserve factor) * totalDebt / (cash + totalDebt)
        supplyRate_e18 = _cash + _totalDebt > 0
            ? (borrowRate_e18 * (ONE_E18 - reserveFactor_e18) * _totalDebt) / ((_cash + _totalDebt) * ONE_E18)
            : 0;
    }

    /// @inheritdoc ILendingPool
    function getBorrowRate_e18() external view returns (uint borrowRate_e18) {
        borrowRate_e18 = IIRM(irm).getBorrowRate_e18(cash, totalDebt);
    }

    /// @inheritdoc ILendingPool
    function totalAssets() public view returns (uint) {
        return cash + totalDebt;
    }

    /// @inheritdoc ILendingPool
    function setIrm(address _irm) external accrue onlyGuardian {
        irm = _irm;
        emit SetIrm(_irm);
    }

    /// @inheritdoc ILendingPool
    function setReserveFactor_e18(uint _reserveFactor_e18) external accrue onlyGuardian {
        _require(_reserveFactor_e18 <= ONE_E18, Errors.INPUT_TOO_HIGH);
        reserveFactor_e18 = _reserveFactor_e18;
        emit SetReserveFactor_e18(_reserveFactor_e18);
    }

    /// @inheritdoc ILendingPool
    function setTreasury(address _treasury) external accrue onlyGovernor {
        treasury = _treasury;
        emit SetTreasury(_treasury);
    }

    /// @dev This implementation mitigates share price manipulations, using OpenZeppelin's method of virtual shares:
    /// https://docs.openzeppelin.com/contracts/4.x/erc4626#inflation-attack.
    /// @param _amt The amount of assets to convert to shares.
    /// @param _totalAssets The total amount of assets in the pool.
    /// @param _totalShares The total amount of shares in the pool.
    /// @return shares the amount of shares
    function _toShares(uint _amt, uint _totalAssets, uint _totalShares) internal pure returns (uint shares) {
        return _amt.mulDiv(_totalShares + VIRTUAL_SHARES, _totalAssets + VIRTUAL_ASSETS);
    }

    /// @dev This implementation mitigates share price manipulations, using OpenZeppelin's method of virtual shares:
    /// https://docs.openzeppelin.com/contracts/4.x/erc4626#inflation-attack.
    /// @param _shares The amount of shares to convert to assets.
    /// @param _totalAssets The total amount of assets in the pool.
    /// @param _totalShares The total amount of shares in the pool.
    /// @return amt the token amount
    function _toAmt(uint _shares, uint _totalAssets, uint _totalShares) internal pure returns (uint amt) {
        return _shares.mulDiv(_totalAssets + VIRTUAL_ASSETS, _totalShares + VIRTUAL_SHARES);
    }
}

File 2 of 18 : UnderACM.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

import {IAccessControlManager} from '../interfaces/common/IAccessControlManager.sol';

abstract contract UnderACM {
    // immutables
    IAccessControlManager public immutable ACM; // access control manager

    // constructor
    constructor(address _acm) {
        ACM = IAccessControlManager(_acm);
    }
}

File 3 of 18 : InitErrors.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma solidity >=0.7.1 <0.9.0;

// solhint-disable

/**
 * @dev Reverts if `condition` is false, with a revert reason containing `errorCode`. Only codes up to 999 are
 * supported.
 * Uses the default 'INC' prefix for the error code
 */
function _require(bool condition, uint errorCode) pure {
    if (!condition) _revert(errorCode);
}

/**
 * @dev Reverts if `condition` is false, with a revert reason containing `errorCode`. Only codes up to 999 are
 * supported.
 */
function _require(bool condition, uint errorCode, bytes3 prefix) pure {
    if (!condition) _revert(errorCode, prefix);
}

/**
 * @dev Reverts with a revert reason containing `errorCode`. Only codes up to 999 are supported.
 * Uses the default 'INC' prefix for the error code
 */
function _revert(uint errorCode) pure {
    _revert(errorCode, 0x494e43); // This is the raw byte representation of "INC"
}

/**
 * @dev Reverts with a revert reason containing `errorCode`. Only codes up to 999 are supported.
 */
function _revert(uint errorCode, bytes3 prefix) pure {
    uint prefixUint = uint(uint24(prefix));
    // We're going to dynamically create a revert string based on the error code, with the following format:
    // 'INC#{errorCode}'
    // where the code is left-padded with zeroes to three digits (so they range from 000 to 999).
    //
    // We don't have revert strings embedded in the contract to save bytecode size: it takes much less space to store a
    // number (8 to 16 bits) than the individual string characters.
    //
    // The dynamic string creation algorithm that follows could be implemented in Solidity, but assembly allows for a
    // much denser implementation, again saving bytecode size. Given this function unconditionally reverts, this is a
    // safe place to rely on it without worrying about how its usage might affect e.g. memory contents.
    assembly {
        // First, we need to compute the ASCII representation of the error code. We assume that it is in the 0-999
        // range, so we only need to convert three digits. To convert the digits to ASCII, we add 0x30, the value for
        // the '0' character.

        let units := add(mod(errorCode, 10), 0x30)

        errorCode := div(errorCode, 10)
        let tenths := add(mod(errorCode, 10), 0x30)

        errorCode := div(errorCode, 10)
        let hundreds := add(mod(errorCode, 10), 0x30)

        // With the individual characters, we can now construct the full string.
        // We first append the '#' character (0x23) to the prefix. In the case of 'INC', it results in 0x42414c23 ('INC#')
        // Then, we shift this by 24 (to provide space for the 3 bytes of the error code), and add the
        // characters to it, each shifted by a multiple of 8.
        // The revert reason is then shifted left by 200 bits (256 minus the length of the string, 7 characters * 8 bits
        // per character = 56) to locate it in the most significant part of the 256 slot (the beginning of a byte
        // array).
        let formattedPrefix := shl(24, add(0x23, shl(8, prefixUint)))

        let revertReason := shl(200, add(formattedPrefix, add(add(units, shl(8, tenths)), shl(16, hundreds))))

        // We can now encode the reason in memory, which can be safely overwritten as we're about to revert. The encoded
        // message will have the following layout:
        // [ revert reason identifier ] [ string location offset ] [ string length ] [ string contents ]

        // The Solidity revert reason identifier is 0x08c739a0, the function selector of the Error(string) function. We
        // also write zeroes to the next 28 bytes of memory, but those are about to be overwritten.
        mstore(0x0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
        // Next is the offset to the location of the string, which will be placed immediately after (20 bytes away).
        mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020)
        // The string length is fixed: 7 characters.
        mstore(0x24, 7)
        // Finally, the string itself is stored.
        mstore(0x44, revertReason)

        // Even if the string is only 7 bytes long, we need to return a full 32 byte slot containing it. The length of
        // the encoded message is therefore 4 + 32 + 32 + 32 = 100.
        revert(0, 100)
    }
}

library Errors {
    // Common
    uint internal constant ZERO_VALUE = 100;
    uint internal constant NOT_INIT_CORE = 101;
    uint internal constant SLIPPAGE_CONTROL = 102;
    uint internal constant CALL_FAILED = 103;
    uint internal constant NOT_OWNER = 104;
    uint internal constant NOT_WNATIVE = 105;
    uint internal constant ALREADY_SET = 106;
    uint internal constant NOT_WHITELISTED = 107;

    // Input
    uint internal constant ARRAY_LENGTH_MISMATCHED = 200;
    uint internal constant INPUT_TOO_LOW = 201;
    uint internal constant INPUT_TOO_HIGH = 202;
    uint internal constant INVALID_INPUT = 203;
    uint internal constant INVALID_TOKEN_IN = 204;
    uint internal constant INVALID_TOKEN_OUT = 205;
    uint internal constant NOT_SORTED_OR_DUPLICATED_INPUT = 206;

    // Core
    uint internal constant POSITION_NOT_HEALTHY = 300;
    uint internal constant POSITION_NOT_FOUND = 301;
    uint internal constant LOCKED_MULTICALL = 302;
    uint internal constant POSITION_HEALTHY = 303;
    uint internal constant INVALID_HEALTH_AFTER_LIQUIDATION = 304;
    uint internal constant FLASH_PAUSED = 305;
    uint internal constant INVALID_FLASHLOAN = 306;
    uint internal constant NOT_AUTHORIZED = 307;
    uint internal constant INVALID_CALLBACK_ADDRESS = 308;

    // Lending Pool
    uint internal constant MINT_PAUSED = 400;
    uint internal constant REDEEM_PAUSED = 401;
    uint internal constant BORROW_PAUSED = 402;
    uint internal constant REPAY_PAUSED = 403;
    uint internal constant NOT_ENOUGH_CASH = 404;
    uint internal constant INVALID_AMOUNT_TO_REPAY = 405;
    uint internal constant SUPPLY_CAP_REACHED = 406;
    uint internal constant BORROW_CAP_REACHED = 407;

    // Config
    uint internal constant INVALID_MODE = 500;
    uint internal constant TOKEN_NOT_WHITELISTED = 501;
    uint internal constant INVALID_FACTOR = 502;

    // Position Manager
    uint internal constant COLLATERALIZE_PAUSED = 600;
    uint internal constant DECOLLATERALIZE_PAUSED = 601;
    uint internal constant MAX_COLLATERAL_COUNT_REACHED = 602;
    uint internal constant NOT_CONTAIN = 603;
    uint internal constant ALREADY_COLLATERALIZED = 604;

    // Oracle
    uint internal constant NO_VALID_SOURCE = 700;
    uint internal constant TOO_MUCH_DEVIATION = 701;
    uint internal constant MAX_PRICE_DEVIATION_TOO_LOW = 702;
    uint internal constant NO_PRICE_ID = 703;
    uint internal constant PYTH_CONFIG_NOT_SET = 704;
    uint internal constant DATAFEED_ID_NOT_SET = 705;
    uint internal constant MAX_STALETIME_NOT_SET = 706;
    uint internal constant MAX_STALETIME_EXCEEDED = 707;
    uint internal constant PRIMARY_SOURCE_NOT_SET = 708;

    // Risk Manager
    uint internal constant DEBT_CEILING_EXCEEDED = 800;

    // Misc
    uint internal constant UNIMPLEMENTED = 999;
}

// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

/// @title Access Control Manager Interface
interface IAccessControlManager {
    /// @dev check the role of the user, revert against an unauthorized user.
    /// @param _role keccak256 hash of role name
    /// @param _user user address to check for the role
    function checkRole(bytes32 _role, address _user) external;
}

// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

/// @title Interest Rate Model Interface
interface IIRM {
    /// @notice borrow rate is rate per second in 1e18
    /// @dev get the borrow rate from the interest rate model
    /// @param _cash total cash
    /// @param _debt total debt
    /// @return borrowRate_e18 borrow rate per second in 1e18
    function getBorrowRate_e18(uint _cash, uint _debt) external view returns (uint borrowRate_e18);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

/// @title Lending Pool Interface
/// @notice rebase token is not supported
interface ILendingPool {
    event SetIrm(address _irm);
    event SetReserveFactor_e18(uint _reserveFactor_e18);
    event SetTreasury(address _treasury);

    /// @dev get core address
    function core() external view returns (address core);

    /// @dev get the interest rate model address
    function irm() external view returns (address model);

    /// @dev get the reserve factor in 1e18 (1e18 = 100%)
    function reserveFactor_e18() external view returns (uint factor_e18);

    /// @dev get the pool's underlying token
    function underlyingToken() external view returns (address token);

    /// @notice total assets = cash + total debts
    function totalAssets() external view returns (uint amt);

    /// @dev get the pool total debt (underlying token)
    function totalDebt() external view returns (uint debt);

    /// @dev get the pool total debt shares
    function totalDebtShares() external view returns (uint shares);

    /// @dev calaculate the debt share from debt amount (without interest accrual)
    /// @param _amt the amount of debt
    /// @return shares amount of debt shares (rounded up)
    function debtAmtToShareStored(uint _amt) external view returns (uint shares);

    /// @dev calaculate the debt share from debt amount (with interest accrual)
    /// @param _amt the amount of debt
    /// @return shares current amount of debt shares (rounded up)
    function debtAmtToShareCurrent(uint _amt) external returns (uint shares);

    /// @dev calculate the corresponding debt amount from debt share (without interest accrual)
    /// @param _shares the amount of debt shares
    /// @return amt corresponding debt amount (rounded up)
    function debtShareToAmtStored(uint _shares) external view returns (uint amt);

    /// @notice this is NOT a view function
    /// @dev calculate the corresponding debt amount from debt share (with interest accrual)
    /// @param _shares the amount of debt shares
    /// @return amt corresponding current debt amount (rounded up)
    function debtShareToAmtCurrent(uint _shares) external returns (uint amt);

    /// @dev get current supply rate per sec in 1e18
    function getSupplyRate_e18() external view returns (uint supplyRate_e18);

    /// @dev get current borrow rate per sec in 1e18
    function getBorrowRate_e18() external view returns (uint borrowRate_e18);

    /// @dev get the pool total cash (underlying token)
    function cash() external view returns (uint amt);

    /// @dev get the latest timestamp of interest accrual
    /// @return lastAccruedTime last accrued time unix timestamp
    function lastAccruedTime() external view returns (uint lastAccruedTime);

    /// @dev get the treasury address
    function treasury() external view returns (address treasury);

    /// @notice only core can call this function
    /// @dev mint shares to the receiver from the transfered assets
    /// @param _receiver address to receive shares
    /// @return mintShares amount of shares minted
    function mint(address _receiver) external returns (uint mintShares);

    /// @notice only core can call this function
    /// @dev burn shares and send the underlying assets to the receiver
    /// @param _receiver address to receive the underlying tokens
    /// @return amt amount of underlying assets transferred
    function burn(address _receiver) external returns (uint amt);

    /// @notice only core can call this function
    /// @dev borrow the asset from the lending pool
    /// @param _receiver address to receive the borrowed asset
    /// @param _amt amount of asset to borrow
    /// @return debtShares debt shares amount recorded from borrowing
    function borrow(address _receiver, uint _amt) external returns (uint debtShares);

    /// @notice only core can call this function
    /// @dev repay the borrowed assets
    /// @param _shares the amount of debt shares to repay
    /// @return amt assets amount used for repay
    function repay(uint _shares) external returns (uint amt);

    /// @dev accrue interest from the last accrual
    function accrueInterest() external;

    /// @dev get the share amounts from underlying asset amt
    /// @param _amt the amount of asset to convert to shares
    /// @return shares amount of shares (rounded down)
    function toShares(uint _amt) external view returns (uint shares);

    /// @dev get the asset amount from shares
    /// @param _shares the amount of shares to convert to underlying asset amt
    /// @return amt amount of underlying asset (rounded down)
    function toAmt(uint _shares) external view returns (uint amt);

    /// @dev get the share amounts from underlying asset amt (with interest accrual)
    /// @param _amt the amount of asset to convert to shares
    /// @return shares current amount of shares (rounded down)
    function toSharesCurrent(uint _amt) external returns (uint shares);

    /// @dev get the asset amount from shares (with interest accrual)
    /// @param _shares the amount of shares to convert to underlying asset amt
    /// @return amt current amount of underlying asset (rounded down)
    function toAmtCurrent(uint _shares) external returns (uint amt);

    /// @dev set the interest rate model
    /// @param _irm new interest rate model address
    function setIrm(address _irm) external;

    /// @dev set the pool's reserve factor in 1e18
    /// @param _reserveFactor_e18 new reserver factor in 1e18
    function setReserveFactor_e18(uint _reserveFactor_e18) external;

    /// @dev set the pool's treasury address
    /// @param _treasury new treasury address
    function setTreasury(address _treasury) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized != type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20Upgradeable.sol";
import "./extensions/IERC20MetadataUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {
    mapping(address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
        __ERC20_init_unchained(name_, symbol_);
    }

    function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
        _name = name_;
        _symbol = symbol_;
    }

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

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

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

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

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

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

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

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

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

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

        return true;
    }

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

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
            // decrementing then incrementing.
            _balances[to] += amount;
        }

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

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

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

        _totalSupply += amount;
        unchecked {
            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
            _balances[account] += amount;
        }
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

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

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

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
            // Overflow not possible: amount <= accountBalance <= totalSupply.
            _totalSupply -= amount;
        }

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

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

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

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

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

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[45] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20MetadataUpgradeable is IERC20Upgradeable {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

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

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

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

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

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

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

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

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

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

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

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

Settings
{
  "evmVersion": "paris",
  "libraries": {},
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "remappings": [
    "@forge-std/=lib/forge-std/src/",
    "@openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
    "@openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts copy/=lib/openzeppelin-contracts copy/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/"
  ]
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_core","type":"address"},{"internalType":"address","name":"_acm","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_irm","type":"address"}],"name":"SetIrm","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_reserveFactor_e18","type":"uint256"}],"name":"SetReserveFactor_e18","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_treasury","type":"address"}],"name":"SetTreasury","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"ACM","outputs":[{"internalType":"contract IAccessControlManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accrueInterest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amt","type":"uint256"}],"name":"borrow","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"}],"name":"burn","outputs":[{"internalType":"uint256","name":"amt","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cash","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"core","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amt","type":"uint256"}],"name":"debtAmtToShareCurrent","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amt","type":"uint256"}],"name":"debtAmtToShareStored","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"}],"name":"debtShareToAmtCurrent","outputs":[{"internalType":"uint256","name":"amt","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"}],"name":"debtShareToAmtStored","outputs":[{"internalType":"uint256","name":"amt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBorrowRate_e18","outputs":[{"internalType":"uint256","name":"borrowRate_e18","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSupplyRate_e18","outputs":[{"internalType":"uint256","name":"supplyRate_e18","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_underlyingToken","type":"address"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"address","name":"_irm","type":"address"},{"internalType":"uint256","name":"_reserveFactor_e18","type":"uint256"},{"internalType":"address","name":"_treasury","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"irm","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastAccruedTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"}],"name":"repay","outputs":[{"internalType":"uint256","name":"amt","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reserveFactor_e18","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_irm","type":"address"}],"name":"setIrm","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_reserveFactor_e18","type":"uint256"}],"name":"setReserveFactor_e18","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"}],"name":"toAmt","outputs":[{"internalType":"uint256","name":"amt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"}],"name":"toAmtCurrent","outputs":[{"internalType":"uint256","name":"amt","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amt","type":"uint256"}],"name":"toShares","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amt","type":"uint256"}],"name":"toSharesCurrent","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDebtShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlyingToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

60c06040523480156200001157600080fd5b50604051620026fc380380620026fc83398101604081905262000034916200013c565b6001600160a01b0381166080526200004b6200005e565b506001600160a01b031660a05262000174565b600054610100900460ff1615620000cb5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff908116146200011d576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b80516001600160a01b03811681146200013757600080fd5b919050565b600080604083850312156200015057600080fd5b6200015b836200011f565b91506200016b602084016200011f565b90509250929050565b60805160a05161252a620001d260003960008181610521015281816108340152818161097f01528181610bbd01528181610c450152610d550152600081816105480152818161068f015281816111fb01526112f1015261252a6000f3fe608060405234801561001057600080fd5b50600436106102535760003560e01c806370a0823111610146578063a6afed95116100c3578063dd62ed3e11610087578063dd62ed3e146104e3578063ee466846146104f6578063f0f4426014610509578063f2f4eb261461051c578063f9b80da114610543578063fc7b9c181461056a57600080fd5b8063a6afed95146104a4578063a9059cbb146104ac578063bea205a2146104bf578063c1f4a4d2146104c7578063cef03044146104d057600080fd5b806395d89b411161010a57806395d89b411461045a578063961be3911461046257806398e8c7ec1461046b5780639e57c9751461047e578063a457c2d71461049157600080fd5b806370a08231146103fa57806374554c66146104235780637ffc93b11461043657806389afcb441461043f5780638d80c3441461045257600080fd5b8063313ce567116101d45780633950935111610198578063395093511461039b5780634b8a3529146103ae57806361d027b3146103c1578063650b4f8b146103d45780636a627842146103e757600080fd5b8063313ce5671461033557806331a86fe11461034f57806331bb587214610362578063371fd8e614610375578063377136f21461038857600080fd5b80631859367b1161021b5780631859367b146102c65780631b859e41146102db57806323b872dd146102e45780632495a599146102f757806328e8fe7d1461032257600080fd5b806301e1d1141461025857806306fdde0314610273578063095ea7b31461028857806318160ddd146102ab578063183c268e146102b3575b600080fd5b610260610573565b6040519081526020015b60405180910390f35b61027b61058a565b60405161026a9190611f14565b61029b610296366004611f63565b61061c565b604051901515815260200161026a565b603554610260565b6102606102c1366004611f8d565b610636565b6102d96102d4366004611f8d565b61064c565b005b61026060685481565b61029b6102f2366004611fa6565b610745565b60655461030a906001600160a01b031681565b6040516001600160a01b03909116815260200161026a565b60695461030a906001600160a01b031681565b61033d61076b565b60405160ff909116815260200161026a565b61026061035d366004611f8d565b6107f0565b610260610370366004611f8d565b6107ff565b610260610383366004611f8d565b610824565b610260610396366004611f8d565b61093a565b61029b6103a9366004611f63565b61094d565b6102606103bc366004611f63565b61096f565b606c5461030a906001600160a01b031681565b6102d96103e236600461202b565b610a2d565b6102606103f53660046120d6565b610c35565b6102606104083660046120d6565b6001600160a01b031660009081526033602052604090205490565b610260610431366004611f8d565b610d32565b610260606a5481565b61026061044d3660046120d6565b610d45565b610260610df6565b61027b610e75565b61026060665481565b610260610479366004611f8d565b610e84565b61026061048c366004611f8d565b610e97565b61029b61049f366004611f63565b610ea5565b6102d9610f2b565b61029b6104ba366004611f63565b611066565b610260611074565b610260606b5481565b6102606104de366004611f8d565b611169565b6102606104f13660046120f1565b61118d565b6102d96105043660046120d6565b6111b8565b6102d96105173660046120d6565b6112ae565b61030a7f000000000000000000000000000000000000000000000000000000000000000081565b61030a7f000000000000000000000000000000000000000000000000000000000000000081565b61026060675481565b6000606754606654610585919061213a565b905090565b6060603680546105999061214d565b80601f01602080910402602001604051908101604052809291908181526020018280546105c59061214d565b80156106125780601f106105e757610100808354040283529160200191610612565b820191906000526020600020905b8154815290600101906020018083116105f557829003601f168201915b5050505050905090565b60003361062a8185856113a4565b60019150505b92915050565b600061063082610644610573565b6035546114c8565b610654610f2b565b6040516312d9a6ad60e01b81527f8fbcb4375b910093bcf636b6b2f26b26eda2a29ef5a8ee7de44b5743c3bf9a2860048201523360248201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906312d9a6ad90604401600060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b50505050610709670de0b6b3a764000082111560ca6114fe565b606b8190556040518181527f736670393983044c1dbf122d61e03af1ab342873e283b60b60d55026c2817a3e906020015b60405180910390a150565b600033610753858285611510565b61075e85858561158a565b60019150505b9392505050565b60006008606560009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e69190612187565b61058591906121aa565b60006107fa610f2b565b610630825b60008060685411610811576000610630565b6067546068546106309184916001611735565b600061085c336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161460656114fe565b610864610f2b565b6068546067546108778482846001611735565b6065546040516370a0823160e01b81523060048201529194506000916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156108c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e991906121c3565b9050610907606654826108fc91906121dc565b8511156101956114fe565b61091185846121dc565b60685583821161092257600061092c565b61092c84836121dc565b606755606655509092915050565b6000610944610f2b565b61063082610e97565b60003361062a818585610960838361118d565b61096a919061213a565b6113a4565b60006109a7336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161460656114fe565b6109af610f2b565b6109c06066548311156101946114fe565b606754806109ce57826109df565b6068546109df908490836001611735565b915081606860008282546109f3919061213a565b90915550610a039050838261213a565b606755606680548490039055606554610a26906001600160a01b03168585611792565b5092915050565b600054610100900460ff1615808015610a4d5750600054600160ff909116105b80610a675750303b158015610a67575060005460ff166001145b610acf5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff191660011790558015610af2576000805461ff0019166101001790555b606580546001600160a01b0319166001600160a01b038b16179055604080516020601f8a01819004810282018101909252888152610b7e918a908a908190840183828082843760009201919091525050604080516020601f8c018190048102820181019092528a815292508a91508990819084018382808284376000920191909152506117fa92505050565b606980546001600160a01b038087166001600160a01b031992831617909255606c8054858416921691909117905542606a55606b849055610be4908a167f000000000000000000000000000000000000000000000000000000000000000060001961182b565b8015610c2a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b6000610c6d336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161460656114fe565b610c75610f2b565b6066546065546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015610cc1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce591906121c3565b90506000610cf383836121dc565b9050610d0f8160675485610d07919061213a565b603554611940565b9350610d1e84151560646114fe565b610d288585611966565b5060665550919050565b6000610d3c610f2b565b61063082611169565b6000610d7d336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161460656114fe565b610d85610f2b565b30600090815260336020526040902054606654610da582151560646114fe565b610db78260675483610644919061213a565b9250610dc8818411156101946114fe565b828103606655610dd83083611a27565b606554610def906001600160a01b03168585611792565b5050919050565b60695460665460675460405163145ae3b160e11b81526000936001600160a01b0316926328b5c76292610e3492600401918252602082015260400190565b602060405180830381865afa158015610e51573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061058591906121c3565b6060603780546105999061214d565b6000610e8e610f2b565b61063082610636565b600061063082610d07610573565b60003381610eb3828661118d565b905083811015610f135760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610ac6565b610f2082868684036113a4565b506001949350505050565b606a544281146110635760675460665460695460405163145ae3b160e11b815260048101839052602481018490526000916001600160a01b0316906328b5c76290604401602060405180830381865afa158015610f8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb091906121c3565b90506000670de0b6b3a764000084610fc887426121dc565b610fd290856121ef565b610fdc91906121ef565b610fe6919061221c565b90506000670de0b6b3a7640000606b548361100191906121ef565b61100b919061221c565b9050801561104c57606c5461104c906001600160a01b03166110478380866110338b8b61213a565b61103d919061213a565b610d0791906121dc565b611966565b611056828661213a565b606755505042606a555050505b50565b60003361062a81858561158a565b60675460665460695460405163145ae3b160e11b81526004810183905260248101849052600093929184916001600160a01b03909116906328b5c76290604401602060405180830381865afa1580156110d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f591906121c3565b90506000611103848461213a565b1161110f576000611161565b670de0b6b3a7640000611122848461213a565b61112c91906121ef565b83606b54670de0b6b3a764000061114391906121dc565b61114d90846121ef565b61115791906121ef565b611161919061221c565b935050505090565b6000806067541161117a5781610630565b6068546067546106309184916001611735565b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b6111c0610f2b565b6040516312d9a6ad60e01b81527f8fbcb4375b910093bcf636b6b2f26b26eda2a29ef5a8ee7de44b5743c3bf9a2860048201523360248201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906312d9a6ad90604401600060405180830381600087803b15801561124757600080fd5b505af115801561125b573d6000803e3d6000fd5b5050606980546001600160a01b0319166001600160a01b0385169081179091556040519081527f227a01dbb2d854c302234dbf95d143f42a9d4bb174ea8b188f813c4f45ac78e29250602001905061073a565b6112b6610f2b565b6040516312d9a6ad60e01b81527f1e46cebd6689d8c64011118478db0c61a89aa2646c860df401de476fbf37898360048201523360248201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906312d9a6ad90604401600060405180830381600087803b15801561133d57600080fd5b505af1158015611351573d6000803e3d6000fd5b5050606c80546001600160a01b0319166001600160a01b0385169081179091556040519081527fcb7ef3e545f5cdb893f5c568ba710fe08f336375a2d9fd66e161033f8fc09ef39250602001905061073a565b6001600160a01b0383166114065760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610ac6565b6001600160a01b0382166114675760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610ac6565b6001600160a01b0383811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006114f66114d860018561213a565b6114e46008600a612322565b6114ee908561213a565b869190611b5b565b949350505050565b8161150c5761150c81611c45565b5050565b600061151c848461118d565b9050600019811461158457818110156115775760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610ac6565b61158484848484036113a4565b50505050565b6001600160a01b0383166115ee5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610ac6565b6001600160a01b0382166116505760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610ac6565b6001600160a01b038316600090815260336020526040902054818110156116c85760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610ac6565b6001600160a01b0380851660008181526033602052604080822086860390559286168082529083902080548601905591517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906117289086815260200190565b60405180910390a3611584565b600080611743868686611b5b565b9050600183600281111561175957611759612331565b14801561177657506000848061177157611771612206565b868809115b156117895761178660018261213a565b90505b95945050505050565b6040516001600160a01b0383166024820152604481018290526117f590849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611c55565b505050565b600054610100900460ff166118215760405162461bcd60e51b8152600401610ac690612347565b61150c8282611d2a565b8015806118a55750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa15801561187f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118a391906121c3565b155b6119105760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610ac6565b6040516001600160a01b0383166024820152604481018290526117f590849063095ea7b360e01b906064016117be565b60006114f66119516008600a612322565b61195b908461213a565b6114ee60018661213a565b6001600160a01b0382166119bc5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610ac6565b80603560008282546119ce919061213a565b90915550506001600160a01b0382166000818152603360209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6001600160a01b038216611a875760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610ac6565b6001600160a01b03821660009081526033602052604090205481811015611afb5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610ac6565b6001600160a01b03831660008181526033602090815260408083208686039055603580548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b6000808060001985870985870292508281108382030391505080600003611b9557838281611b8b57611b8b612206565b0492505050610764565b808411611bdc5760405162461bcd60e51b81526020600482015260156024820152744d6174683a206d756c446976206f766572666c6f7760581b6044820152606401610ac6565b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b6110638162494e4360e81b611d6a565b6000611caa826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611dcd9092919063ffffffff16565b9050805160001480611ccb575080806020019051810190611ccb9190612392565b6117f55760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610ac6565b600054610100900460ff16611d515760405162461bcd60e51b8152600401610ac690612347565b6036611d5d8382612418565b5060376117f58282612418565b62461bcd60e51b600090815260206004526007602452600a808404818106603090810160081b958390069590950190829004918206850160101b01602363ffffff0060e086901c160160181b0190930160c81b604481905260e883901c91606490fd5b60606114f6848460008585600080866001600160a01b03168587604051611df491906124d8565b60006040518083038185875af1925050503d8060008114611e31576040519150601f19603f3d011682016040523d82523d6000602084013e611e36565b606091505b5091509150611e4787838387611e52565b979650505050505050565b60608315611ec1578251600003611eba576001600160a01b0385163b611eba5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610ac6565b50816114f6565b6114f68383815115611ed65781518083602001fd5b8060405162461bcd60e51b8152600401610ac69190611f14565b60005b83811015611f0b578181015183820152602001611ef3565b50506000910152565b6020815260008251806020840152611f33816040850160208701611ef0565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114611f5e57600080fd5b919050565b60008060408385031215611f7657600080fd5b611f7f83611f47565b946020939093013593505050565b600060208284031215611f9f57600080fd5b5035919050565b600080600060608486031215611fbb57600080fd5b611fc484611f47565b9250611fd260208501611f47565b9150604084013590509250925092565b60008083601f840112611ff457600080fd5b50813567ffffffffffffffff81111561200c57600080fd5b60208301915083602082850101111561202457600080fd5b9250929050565b60008060008060008060008060c0898b03121561204757600080fd5b61205089611f47565b9750602089013567ffffffffffffffff8082111561206d57600080fd5b6120798c838d01611fe2565b909950975060408b013591508082111561209257600080fd5b5061209f8b828c01611fe2565b90965094506120b2905060608a01611f47565b9250608089013591506120c760a08a01611f47565b90509295985092959890939650565b6000602082840312156120e857600080fd5b61076482611f47565b6000806040838503121561210457600080fd5b61210d83611f47565b915061211b60208401611f47565b90509250929050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561063057610630612124565b600181811c9082168061216157607f821691505b60208210810361218157634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561219957600080fd5b815160ff8116811461076457600080fd5b60ff818116838216019081111561063057610630612124565b6000602082840312156121d557600080fd5b5051919050565b8181038181111561063057610630612124565b808202811582820484141761063057610630612124565b634e487b7160e01b600052601260045260246000fd5b60008261223957634e487b7160e01b600052601260045260246000fd5b500490565b600181815b8085111561227957816000190482111561225f5761225f612124565b8085161561226c57918102915b93841c9390800290612243565b509250929050565b60008261229057506001610630565b8161229d57506000610630565b81600181146122b357600281146122bd576122d9565b6001915050610630565b60ff8411156122ce576122ce612124565b50506001821b610630565b5060208310610133831016604e8410600b84101617156122fc575081810a610630565b612306838361223e565b806000190482111561231a5761231a612124565b029392505050565b600061076460ff841683612281565b634e487b7160e01b600052602160045260246000fd5b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000602082840312156123a457600080fd5b8151801515811461076457600080fd5b634e487b7160e01b600052604160045260246000fd5b601f8211156117f557600081815260208120601f850160051c810160208610156123f15750805b601f850160051c820191505b81811015612410578281556001016123fd565b505050505050565b815167ffffffffffffffff811115612432576124326123b4565b61244681612440845461214d565b846123ca565b602080601f83116001811461247b57600084156124635750858301515b600019600386901b1c1916600185901b178555612410565b600085815260208120601f198616915b828110156124aa5788860151825594840194600190910190840161248b565b50858210156124c85787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600082516124ea818460208701611ef0565b919091019291505056fea2646970667358221220913b5bd3ff1f1a1e302a06bf3c3d071543388c660eeae4d0106a06013cb07c2b64736f6c63430008130033000000000000000000000000972bcb0284cca0152527c4f70f8f689852bcafc5000000000000000000000000ce3292ca5abbdfa1db02142a67cffc708530675a

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102535760003560e01c806370a0823111610146578063a6afed95116100c3578063dd62ed3e11610087578063dd62ed3e146104e3578063ee466846146104f6578063f0f4426014610509578063f2f4eb261461051c578063f9b80da114610543578063fc7b9c181461056a57600080fd5b8063a6afed95146104a4578063a9059cbb146104ac578063bea205a2146104bf578063c1f4a4d2146104c7578063cef03044146104d057600080fd5b806395d89b411161010a57806395d89b411461045a578063961be3911461046257806398e8c7ec1461046b5780639e57c9751461047e578063a457c2d71461049157600080fd5b806370a08231146103fa57806374554c66146104235780637ffc93b11461043657806389afcb441461043f5780638d80c3441461045257600080fd5b8063313ce567116101d45780633950935111610198578063395093511461039b5780634b8a3529146103ae57806361d027b3146103c1578063650b4f8b146103d45780636a627842146103e757600080fd5b8063313ce5671461033557806331a86fe11461034f57806331bb587214610362578063371fd8e614610375578063377136f21461038857600080fd5b80631859367b1161021b5780631859367b146102c65780631b859e41146102db57806323b872dd146102e45780632495a599146102f757806328e8fe7d1461032257600080fd5b806301e1d1141461025857806306fdde0314610273578063095ea7b31461028857806318160ddd146102ab578063183c268e146102b3575b600080fd5b610260610573565b6040519081526020015b60405180910390f35b61027b61058a565b60405161026a9190611f14565b61029b610296366004611f63565b61061c565b604051901515815260200161026a565b603554610260565b6102606102c1366004611f8d565b610636565b6102d96102d4366004611f8d565b61064c565b005b61026060685481565b61029b6102f2366004611fa6565b610745565b60655461030a906001600160a01b031681565b6040516001600160a01b03909116815260200161026a565b60695461030a906001600160a01b031681565b61033d61076b565b60405160ff909116815260200161026a565b61026061035d366004611f8d565b6107f0565b610260610370366004611f8d565b6107ff565b610260610383366004611f8d565b610824565b610260610396366004611f8d565b61093a565b61029b6103a9366004611f63565b61094d565b6102606103bc366004611f63565b61096f565b606c5461030a906001600160a01b031681565b6102d96103e236600461202b565b610a2d565b6102606103f53660046120d6565b610c35565b6102606104083660046120d6565b6001600160a01b031660009081526033602052604090205490565b610260610431366004611f8d565b610d32565b610260606a5481565b61026061044d3660046120d6565b610d45565b610260610df6565b61027b610e75565b61026060665481565b610260610479366004611f8d565b610e84565b61026061048c366004611f8d565b610e97565b61029b61049f366004611f63565b610ea5565b6102d9610f2b565b61029b6104ba366004611f63565b611066565b610260611074565b610260606b5481565b6102606104de366004611f8d565b611169565b6102606104f13660046120f1565b61118d565b6102d96105043660046120d6565b6111b8565b6102d96105173660046120d6565b6112ae565b61030a7f000000000000000000000000972bcb0284cca0152527c4f70f8f689852bcafc581565b61030a7f000000000000000000000000ce3292ca5abbdfa1db02142a67cffc708530675a81565b61026060675481565b6000606754606654610585919061213a565b905090565b6060603680546105999061214d565b80601f01602080910402602001604051908101604052809291908181526020018280546105c59061214d565b80156106125780601f106105e757610100808354040283529160200191610612565b820191906000526020600020905b8154815290600101906020018083116105f557829003601f168201915b5050505050905090565b60003361062a8185856113a4565b60019150505b92915050565b600061063082610644610573565b6035546114c8565b610654610f2b565b6040516312d9a6ad60e01b81527f8fbcb4375b910093bcf636b6b2f26b26eda2a29ef5a8ee7de44b5743c3bf9a2860048201523360248201527f000000000000000000000000ce3292ca5abbdfa1db02142a67cffc708530675a6001600160a01b0316906312d9a6ad90604401600060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b50505050610709670de0b6b3a764000082111560ca6114fe565b606b8190556040518181527f736670393983044c1dbf122d61e03af1ab342873e283b60b60d55026c2817a3e906020015b60405180910390a150565b600033610753858285611510565b61075e85858561158a565b60019150505b9392505050565b60006008606560009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e69190612187565b61058591906121aa565b60006107fa610f2b565b610630825b60008060685411610811576000610630565b6067546068546106309184916001611735565b600061085c336001600160a01b037f000000000000000000000000972bcb0284cca0152527c4f70f8f689852bcafc5161460656114fe565b610864610f2b565b6068546067546108778482846001611735565b6065546040516370a0823160e01b81523060048201529194506000916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156108c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e991906121c3565b9050610907606654826108fc91906121dc565b8511156101956114fe565b61091185846121dc565b60685583821161092257600061092c565b61092c84836121dc565b606755606655509092915050565b6000610944610f2b565b61063082610e97565b60003361062a818585610960838361118d565b61096a919061213a565b6113a4565b60006109a7336001600160a01b037f000000000000000000000000972bcb0284cca0152527c4f70f8f689852bcafc5161460656114fe565b6109af610f2b565b6109c06066548311156101946114fe565b606754806109ce57826109df565b6068546109df908490836001611735565b915081606860008282546109f3919061213a565b90915550610a039050838261213a565b606755606680548490039055606554610a26906001600160a01b03168585611792565b5092915050565b600054610100900460ff1615808015610a4d5750600054600160ff909116105b80610a675750303b158015610a67575060005460ff166001145b610acf5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff191660011790558015610af2576000805461ff0019166101001790555b606580546001600160a01b0319166001600160a01b038b16179055604080516020601f8a01819004810282018101909252888152610b7e918a908a908190840183828082843760009201919091525050604080516020601f8c018190048102820181019092528a815292508a91508990819084018382808284376000920191909152506117fa92505050565b606980546001600160a01b038087166001600160a01b031992831617909255606c8054858416921691909117905542606a55606b849055610be4908a167f000000000000000000000000972bcb0284cca0152527c4f70f8f689852bcafc560001961182b565b8015610c2a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b6000610c6d336001600160a01b037f000000000000000000000000972bcb0284cca0152527c4f70f8f689852bcafc5161460656114fe565b610c75610f2b565b6066546065546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015610cc1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce591906121c3565b90506000610cf383836121dc565b9050610d0f8160675485610d07919061213a565b603554611940565b9350610d1e84151560646114fe565b610d288585611966565b5060665550919050565b6000610d3c610f2b565b61063082611169565b6000610d7d336001600160a01b037f000000000000000000000000972bcb0284cca0152527c4f70f8f689852bcafc5161460656114fe565b610d85610f2b565b30600090815260336020526040902054606654610da582151560646114fe565b610db78260675483610644919061213a565b9250610dc8818411156101946114fe565b828103606655610dd83083611a27565b606554610def906001600160a01b03168585611792565b5050919050565b60695460665460675460405163145ae3b160e11b81526000936001600160a01b0316926328b5c76292610e3492600401918252602082015260400190565b602060405180830381865afa158015610e51573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061058591906121c3565b6060603780546105999061214d565b6000610e8e610f2b565b61063082610636565b600061063082610d07610573565b60003381610eb3828661118d565b905083811015610f135760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610ac6565b610f2082868684036113a4565b506001949350505050565b606a544281146110635760675460665460695460405163145ae3b160e11b815260048101839052602481018490526000916001600160a01b0316906328b5c76290604401602060405180830381865afa158015610f8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb091906121c3565b90506000670de0b6b3a764000084610fc887426121dc565b610fd290856121ef565b610fdc91906121ef565b610fe6919061221c565b90506000670de0b6b3a7640000606b548361100191906121ef565b61100b919061221c565b9050801561104c57606c5461104c906001600160a01b03166110478380866110338b8b61213a565b61103d919061213a565b610d0791906121dc565b611966565b611056828661213a565b606755505042606a555050505b50565b60003361062a81858561158a565b60675460665460695460405163145ae3b160e11b81526004810183905260248101849052600093929184916001600160a01b03909116906328b5c76290604401602060405180830381865afa1580156110d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f591906121c3565b90506000611103848461213a565b1161110f576000611161565b670de0b6b3a7640000611122848461213a565b61112c91906121ef565b83606b54670de0b6b3a764000061114391906121dc565b61114d90846121ef565b61115791906121ef565b611161919061221c565b935050505090565b6000806067541161117a5781610630565b6068546067546106309184916001611735565b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b6111c0610f2b565b6040516312d9a6ad60e01b81527f8fbcb4375b910093bcf636b6b2f26b26eda2a29ef5a8ee7de44b5743c3bf9a2860048201523360248201527f000000000000000000000000ce3292ca5abbdfa1db02142a67cffc708530675a6001600160a01b0316906312d9a6ad90604401600060405180830381600087803b15801561124757600080fd5b505af115801561125b573d6000803e3d6000fd5b5050606980546001600160a01b0319166001600160a01b0385169081179091556040519081527f227a01dbb2d854c302234dbf95d143f42a9d4bb174ea8b188f813c4f45ac78e29250602001905061073a565b6112b6610f2b565b6040516312d9a6ad60e01b81527f1e46cebd6689d8c64011118478db0c61a89aa2646c860df401de476fbf37898360048201523360248201527f000000000000000000000000ce3292ca5abbdfa1db02142a67cffc708530675a6001600160a01b0316906312d9a6ad90604401600060405180830381600087803b15801561133d57600080fd5b505af1158015611351573d6000803e3d6000fd5b5050606c80546001600160a01b0319166001600160a01b0385169081179091556040519081527fcb7ef3e545f5cdb893f5c568ba710fe08f336375a2d9fd66e161033f8fc09ef39250602001905061073a565b6001600160a01b0383166114065760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610ac6565b6001600160a01b0382166114675760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610ac6565b6001600160a01b0383811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006114f66114d860018561213a565b6114e46008600a612322565b6114ee908561213a565b869190611b5b565b949350505050565b8161150c5761150c81611c45565b5050565b600061151c848461118d565b9050600019811461158457818110156115775760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610ac6565b61158484848484036113a4565b50505050565b6001600160a01b0383166115ee5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610ac6565b6001600160a01b0382166116505760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610ac6565b6001600160a01b038316600090815260336020526040902054818110156116c85760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610ac6565b6001600160a01b0380851660008181526033602052604080822086860390559286168082529083902080548601905591517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906117289086815260200190565b60405180910390a3611584565b600080611743868686611b5b565b9050600183600281111561175957611759612331565b14801561177657506000848061177157611771612206565b868809115b156117895761178660018261213a565b90505b95945050505050565b6040516001600160a01b0383166024820152604481018290526117f590849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611c55565b505050565b600054610100900460ff166118215760405162461bcd60e51b8152600401610ac690612347565b61150c8282611d2a565b8015806118a55750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa15801561187f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118a391906121c3565b155b6119105760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610ac6565b6040516001600160a01b0383166024820152604481018290526117f590849063095ea7b360e01b906064016117be565b60006114f66119516008600a612322565b61195b908461213a565b6114ee60018661213a565b6001600160a01b0382166119bc5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610ac6565b80603560008282546119ce919061213a565b90915550506001600160a01b0382166000818152603360209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6001600160a01b038216611a875760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610ac6565b6001600160a01b03821660009081526033602052604090205481811015611afb5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610ac6565b6001600160a01b03831660008181526033602090815260408083208686039055603580548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b6000808060001985870985870292508281108382030391505080600003611b9557838281611b8b57611b8b612206565b0492505050610764565b808411611bdc5760405162461bcd60e51b81526020600482015260156024820152744d6174683a206d756c446976206f766572666c6f7760581b6044820152606401610ac6565b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b6110638162494e4360e81b611d6a565b6000611caa826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611dcd9092919063ffffffff16565b9050805160001480611ccb575080806020019051810190611ccb9190612392565b6117f55760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610ac6565b600054610100900460ff16611d515760405162461bcd60e51b8152600401610ac690612347565b6036611d5d8382612418565b5060376117f58282612418565b62461bcd60e51b600090815260206004526007602452600a808404818106603090810160081b958390069590950190829004918206850160101b01602363ffffff0060e086901c160160181b0190930160c81b604481905260e883901c91606490fd5b60606114f6848460008585600080866001600160a01b03168587604051611df491906124d8565b60006040518083038185875af1925050503d8060008114611e31576040519150601f19603f3d011682016040523d82523d6000602084013e611e36565b606091505b5091509150611e4787838387611e52565b979650505050505050565b60608315611ec1578251600003611eba576001600160a01b0385163b611eba5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610ac6565b50816114f6565b6114f68383815115611ed65781518083602001fd5b8060405162461bcd60e51b8152600401610ac69190611f14565b60005b83811015611f0b578181015183820152602001611ef3565b50506000910152565b6020815260008251806020840152611f33816040850160208701611ef0565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114611f5e57600080fd5b919050565b60008060408385031215611f7657600080fd5b611f7f83611f47565b946020939093013593505050565b600060208284031215611f9f57600080fd5b5035919050565b600080600060608486031215611fbb57600080fd5b611fc484611f47565b9250611fd260208501611f47565b9150604084013590509250925092565b60008083601f840112611ff457600080fd5b50813567ffffffffffffffff81111561200c57600080fd5b60208301915083602082850101111561202457600080fd5b9250929050565b60008060008060008060008060c0898b03121561204757600080fd5b61205089611f47565b9750602089013567ffffffffffffffff8082111561206d57600080fd5b6120798c838d01611fe2565b909950975060408b013591508082111561209257600080fd5b5061209f8b828c01611fe2565b90965094506120b2905060608a01611f47565b9250608089013591506120c760a08a01611f47565b90509295985092959890939650565b6000602082840312156120e857600080fd5b61076482611f47565b6000806040838503121561210457600080fd5b61210d83611f47565b915061211b60208401611f47565b90509250929050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561063057610630612124565b600181811c9082168061216157607f821691505b60208210810361218157634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561219957600080fd5b815160ff8116811461076457600080fd5b60ff818116838216019081111561063057610630612124565b6000602082840312156121d557600080fd5b5051919050565b8181038181111561063057610630612124565b808202811582820484141761063057610630612124565b634e487b7160e01b600052601260045260246000fd5b60008261223957634e487b7160e01b600052601260045260246000fd5b500490565b600181815b8085111561227957816000190482111561225f5761225f612124565b8085161561226c57918102915b93841c9390800290612243565b509250929050565b60008261229057506001610630565b8161229d57506000610630565b81600181146122b357600281146122bd576122d9565b6001915050610630565b60ff8411156122ce576122ce612124565b50506001821b610630565b5060208310610133831016604e8410600b84101617156122fc575081810a610630565b612306838361223e565b806000190482111561231a5761231a612124565b029392505050565b600061076460ff841683612281565b634e487b7160e01b600052602160045260246000fd5b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000602082840312156123a457600080fd5b8151801515811461076457600080fd5b634e487b7160e01b600052604160045260246000fd5b601f8211156117f557600081815260208120601f850160051c810160208610156123f15750805b601f850160051c820191505b81811015612410578281556001016123fd565b505050505050565b815167ffffffffffffffff811115612432576124326123b4565b61244681612440845461214d565b846123ca565b602080601f83116001811461247b57600084156124635750858301515b600019600386901b1c1916600185901b178555612410565b600085815260208120601f198616915b828110156124aa5788860151825594840194600190910190840161248b565b50858210156124c85787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600082516124ea818460208701611ef0565b919091019291505056fea2646970667358221220913b5bd3ff1f1a1e302a06bf3c3d071543388c660eeae4d0106a06013cb07c2b64736f6c63430008130033

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

000000000000000000000000972bcb0284cca0152527c4f70f8f689852bcafc5000000000000000000000000ce3292ca5abbdfa1db02142a67cffc708530675a

-----Decoded View---------------
Arg [0] : _core (address): 0x972BcB0284cca0152527c4f70f8F689852bCAFc5
Arg [1] : _acm (address): 0xCE3292cA5AbbdFA1Db02142A67CFFc708530675a

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000972bcb0284cca0152527c4f70f8f689852bcafc5
Arg [1] : 000000000000000000000000ce3292ca5abbdfa1db02142a67cffc708530675a


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

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