ETH Price: $3,217.41 (-3.83%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PETHNFTVault

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 800 runs

Other Settings:
default evmVersion
File 1 of 18 : PETHNFTVault.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;

import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";

import "../interfaces/IAggregatorV3Interface.sol";
import "../interfaces/IStableCoin.sol";
import "../interfaces/INFTValueProvider.sol";
import "../interfaces/INFTStrategy.sol";

/// @title NFT lending vault
/// @notice This contracts allows users to borrow PETH using NFTs as collateral.
/// The floor price of the NFT collection is fetched using a chainlink oracle, while some other more valuable traits
/// can have an higher price set by the DAO. Users can also increase the price (and thus the borrow limit) of their
/// NFT by submitting a governance proposal. If the proposal is approved the user can lock a percentage of the new price
/// worth of JPEG to make it effective
contract PETHNFTVault is AccessControlUpgradeable, ReentrancyGuardUpgradeable {
    using SafeERC20Upgradeable for IERC20Upgradeable;
    using SafeERC20Upgradeable for IStableCoin;
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet;
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;

    error InvalidNFT(uint256 nftIndex);
    error InvalidRate(Rate rate);
    error InvalidNFTType(bytes32 nftType);
    error InvalidUnlockTime(uint256 unlockTime);
    error InvalidAmount(uint256 amount);
    error InvalidPosition(uint256 nftIndex);
    error PositionLiquidated(uint256 nftIndex);
    error Unauthorized();
    error DebtCapReached();
    error InvalidInsuranceMode();
    error NoDebt();
    error NonZeroDebt(uint256 debtAmount);
    error PositionInsuranceExpired(uint256 nftIndex);
    error PositionInsuranceNotExpired(uint256 nftIndex);
    error ZeroAddress();
    error InvalidOracleResults();
    error UnknownAction(uint8 action);
    error InvalidLength();
    error InvalidStrategy();

    event PositionOpened(address indexed owner, uint256 indexed index);
    event Borrowed(
        address indexed owner,
        uint256 indexed index,
        uint256 amount
    );
    event Repaid(address indexed owner, uint256 indexed index, uint256 amount);
    event PositionClosed(address indexed owner, uint256 indexed index);
    event Liquidated(
        address indexed liquidator,
        address indexed owner,
        uint256 indexed index,
        bool insured
    );
    event Repurchased(address indexed owner, uint256 indexed index);
    event InsuranceExpired(address indexed owner, uint256 indexed index);
    event StrategyDeposit(uint256 indexed nftIndex, address indexed strategy, bool isStandard);
    event StrategyWithdrawal(uint256 indexed nftIndex, address indexed strategy);

    enum BorrowType {
        NOT_CONFIRMED,
        NON_INSURANCE,
        USE_INSURANCE
    }

    struct Position {
        BorrowType borrowType;
        uint256 debtPrincipal;
        uint256 debtPortion;
        uint256 debtAmountForRepurchase;
        uint256 liquidatedAt;
        address liquidator;
        INFTStrategy strategy;
    }

    struct Rate {
        uint128 numerator;
        uint128 denominator;
    }

    /// @custom:oz-renamed-from JPEGLock
    struct Unused13 {
        address owner;
        uint256 unlockAt;
        uint256 lockedValue;
    }

    struct VaultSettings {
        Rate debtInterestApr;
        /// @custom:oz-renamed-from creditLimitRate
        Rate unused15;
        /// @custom:oz-renamed-from liquidationLimitRate
        Rate unused16;
        /// @custom:oz-renamed-from cigStakedCreditLimitRate
        Rate unused17;
        /// @custom:oz-renamed-from cigStakedLiquidationLimitRate
        Rate unused18;
        /// @custom:oz-renamed-from valueIncreaseLockRate
        Rate unused12;
        Rate organizationFeeRate;
        Rate insurancePurchaseRate;
        Rate insuranceLiquidationPenaltyRate;
        uint256 insuranceRepurchaseTimeLimit;
        uint256 borrowAmountCap;
    }

    bytes32 private constant DAO_ROLE = keccak256("DAO_ROLE");
    bytes32 private constant LIQUIDATOR_ROLE = keccak256("LIQUIDATOR_ROLE");
    bytes32 private constant SETTER_ROLE = keccak256("SETTER_ROLE");

    //accrue required
    uint8 private constant ACTION_BORROW = 0;
    uint8 private constant ACTION_REPAY = 1;
    uint8 private constant ACTION_CLOSE_POSITION = 2;
    uint8 private constant ACTION_LIQUIDATE = 3;
    //no accrue required
    uint8 private constant ACTION_REPURCHASE = 100;
    uint8 private constant ACTION_CLAIM_NFT = 101;

    IStableCoin public stablecoin;
    /// @notice The JPEG trait boost locker contract
    /// @custom:oz-renamed-from jpegOracle
    INFTValueProvider public nftValueProvider;
    /// @custom:oz-retyped-from IAggregatorV3Interface
    /// @custom:oz-renamed-from floorOracle
    address private unused8;
    /// @custom:oz-retyped-from IAggregatorV3Interface
    /// @custom:oz-renamed-from fallbackOracle
    address private unused9;
    /// @custom:oz-retyped-from IERC20Upgradeable
    /// @custom:oz-renamed-from jpeg
    address private unused3; //Unused after upgrade
    /// @custom:oz-renamed-from cigStaking
    address public unused14;

    IERC721Upgradeable public nftContract;

    /// @custom:oz-renamed-from daoFloorOverride
    bool private unused10;
    /// @custom:oz-renamed-from useFallbackOracle
    bool private unused11;
    /// @notice Total outstanding debt
    uint256 public totalDebtAmount;
    /// @dev Last time debt was accrued. See {accrue} for more info
    uint256 private totalDebtAccruedAt;
    uint256 public totalFeeCollected;
    uint256 private totalDebtPortion;

    VaultSettings public settings;

    /// @dev Keeps track of all the NFTs used as collateral for positions
    EnumerableSetUpgradeable.UintSet private positionIndexes;

    mapping(uint256 => Position) public positions;
    mapping(uint256 => address) public positionOwner;
    /// @custom:oz-renamed-from nftTypeValueETH
    mapping(bytes32 => uint256) private unused1; //unused after upgrade
    /// @custom:oz-renamed-from nftValueETH
    mapping(uint256 => uint256) private unused2; //unused after upgrade
    /// @custom:oz-renamed-from nftTypes
    mapping(uint256 => bytes32) private unused4; //unused after upgrade

     /// @custom:oz-renamed-from overriddenFloorValueETH
    uint256 private unused5;
    /// @custom:oz-renamed-from minJPEGToLock
    uint256 private unused6;
    /// @custom:oz-renamed-from nftTypeValueMultiplier
    mapping(bytes32 => Rate) private unused7;
    /// @custom:oz-renamed-from lockPositions
    mapping(uint256 => Unused13) private unused13;

    EnumerableSetUpgradeable.AddressSet private nftStrategies;

    /// @dev Checks if the provided NFT index is valid
    /// @param nftIndex The index to check
    modifier validNFTIndex(uint256 nftIndex) {
        //The standard OZ ERC721 implementation of ownerOf reverts on a non existing nft isntead of returning address(0)
        if (nftContract.ownerOf(nftIndex) == address(0))
            revert InvalidNFT(nftIndex);
        _;
    }

    /// @notice This function is only called once during deployment of the proxy contract. It's not called after upgrades.
    /// @param _stablecoin PETH address
    /// @param _nftContract The NFT contract address. It could also be the address of an helper contract
    /// if the target NFT isn't an ERC721 (CryptoPunks as an example)
    /// @param _settings Initial settings used by the contract
    function initialize(
        IStableCoin _stablecoin,
        IERC721Upgradeable _nftContract,
        INFTValueProvider _nftValueProvider,
        VaultSettings calldata _settings
    ) external initializer {
        __AccessControl_init();
        __ReentrancyGuard_init();

        _setupRole(DAO_ROLE, msg.sender);
        _setRoleAdmin(LIQUIDATOR_ROLE, DAO_ROLE);
        _setRoleAdmin(SETTER_ROLE, DAO_ROLE);
        _setRoleAdmin(DAO_ROLE, DAO_ROLE);

        _validateRateBelowOne(_settings.debtInterestApr);
        _validateRateBelowOne(_settings.organizationFeeRate);
        _validateRateBelowOne(_settings.insurancePurchaseRate);
        _validateRateBelowOne(_settings.insuranceLiquidationPenaltyRate);

        stablecoin = _stablecoin;
        nftContract = _nftContract;
        nftValueProvider = _nftValueProvider;
        
        settings = _settings;
    }

    /// @notice Returns the number of open positions
    /// @return The number of open positions
    function totalPositions() external view returns (uint256) {
        return positionIndexes.length();
    }

    /// @notice Returns all open position NFT indexes
    /// @return The open position NFT indexes
    function openPositionsIndexes() external view returns (uint256[] memory) {
        return positionIndexes.values();
    }

    /// @param _nftIndex The NFT to return the credit limit of
    /// @return The PETH credit limit of the NFT at index `_nftIndex`.
    function getCreditLimit(address _owner, uint256 _nftIndex) external view returns (uint256) {
        return _getCreditLimit(_owner, _nftIndex);
    }

    /// @param _nftIndex The NFT to return the liquidation limit of
    /// @return The PETH liquidation limit of the NFT at index `_nftIndex`.
    function getLiquidationLimit(address _owner, uint256 _nftIndex)
        public
        view
        returns (uint256)
    {
        return _getLiquidationLimit(_owner, _nftIndex);
    }

    /// @param _nftIndex The NFT to check
    /// @return Whether the NFT at index `_nftIndex` is liquidatable.
    function isLiquidatable(uint256 _nftIndex) external view returns (bool) {
        Position storage position = positions[_nftIndex];
        if (position.borrowType == BorrowType.NOT_CONFIRMED) return false;
        if (position.liquidatedAt > 0) return false;

        uint256 principal = position.debtPrincipal;
        return
            principal + getDebtInterest(_nftIndex) >=
            getLiquidationLimit(positionOwner[_nftIndex], _nftIndex);
    }

    /// @param _nftIndex The NFT to check
    /// @return The PETH debt interest accumulated by the NFT at index `_nftIndex`.
    function getDebtInterest(uint256 _nftIndex) public view returns (uint256) {
        Position storage position = positions[_nftIndex];
        uint256 principal = position.debtPrincipal;
        uint256 debt = position.liquidatedAt != 0
            ? position.debtAmountForRepurchase
            : _calculateDebt(
                totalDebtAmount + _calculateAdditionalInterest(),
                position.debtPortion,
                totalDebtPortion
            );

        //_calculateDebt is prone to rounding errors that may cause
        //the calculated debt amount to be 1 or 2 units less than
        //the debt principal if no time has elapsed in between the first borrow
        //and the _calculateDebt call.
        if (principal > debt) debt = principal;

        unchecked {
            return debt - principal;
        }
    }

    /// @return The whitelisted strategies for this vault.
    function getStrategies() external view returns (address[] memory) {
        return nftStrategies.values();
    }

    /// @dev The {accrue} function updates the contract's state by calculating
    /// the additional interest accrued since the last state update
    function accrue() public {
        uint256 additionalInterest = _calculateAdditionalInterest();

        totalDebtAccruedAt = block.timestamp;

        totalDebtAmount += additionalInterest;
        totalFeeCollected += additionalInterest;
    }

    /// @notice Allows to execute multiple actions in a single transaction.
    /// @param _actions The actions to execute.
    /// @param _datas The abi encoded parameters for the actions to execute.
    function doActions(uint8[] calldata _actions, bytes[] calldata _datas)
        external
        nonReentrant
    {
        if (_actions.length != _datas.length) revert();
        bool accrueCalled;
        for (uint256 i; i < _actions.length; ++i) {
            uint8 action = _actions[i];
            if (!accrueCalled && action < 100) {
                accrue();
                accrueCalled = true;
            }

            if (action == ACTION_BORROW) {
                (uint256 nftIndex, uint256 amount, bool useInsurance) = abi
                    .decode(_datas[i], (uint256, uint256, bool));
                _borrow(nftIndex, amount, useInsurance);
            } else if (action == ACTION_REPAY) {
                (uint256 nftIndex, uint256 amount) = abi.decode(
                    _datas[i],
                    (uint256, uint256)
                );
                _repay(nftIndex, amount);
            } else if (action == ACTION_CLOSE_POSITION) {
                uint256 nftIndex = abi.decode(_datas[i], (uint256));
                _closePosition(nftIndex);
            } else if (action == ACTION_LIQUIDATE) {
                (uint256 nftIndex, address recipient) = abi.decode(
                    _datas[i],
                    (uint256, address)
                );
                _liquidate(nftIndex, recipient);
            } else if (action == ACTION_REPURCHASE) {
                uint256 nftIndex = abi.decode(_datas[i], (uint256));
                _repurchase(nftIndex);
            } else if (action == ACTION_CLAIM_NFT) {
                (uint256 nftIndex, address recipient) = abi.decode(
                    _datas[i],
                    (uint256, address)
                );
                _claimExpiredInsuranceNFT(nftIndex, recipient);
            } else {
                revert UnknownAction(action);
            }
        }
    }

    /// @notice Allows users to open positions and borrow using an NFT
    /// @dev emits a {Borrowed} event
    /// @param _nftIndex The index of the NFT to be used as collateral
    /// @param _amount The amount of PETH to be borrowed. Note that the user will receive less than the amount requested,
    /// the borrow fee and insurance automatically get removed from the amount borrowed
    /// @param _useInsurance Whereter to open an insured position. In case the position has already been opened previously,
    /// this parameter needs to match the previous insurance mode. To change insurance mode, a user needs to close and reopen the position
    function borrow(
        uint256 _nftIndex,
        uint256 _amount,
        bool _useInsurance
    ) external nonReentrant {
        accrue();
        _borrow(_nftIndex, _amount, _useInsurance);
    }

    /// @notice Allows users to repay a portion/all of their debt. Note that since interest increases every second,
    /// a user wanting to repay all of their debt should repay for an amount greater than their current debt to account for the
    /// additional interest while the repay transaction is pending, the contract will only take what's necessary to repay all the debt
    /// @dev Emits a {Repaid} event
    /// @param _nftIndex The NFT used as collateral for the position
    /// @param _amount The amount of debt to repay. If greater than the position's outstanding debt, only the amount necessary to repay all the debt will be taken
    function repay(uint256 _nftIndex, uint256 _amount) external nonReentrant {
        accrue();
        _repay(_nftIndex, _amount);
    }

    /// @notice Allows a user to close a position and get their collateral back, if the position's outstanding debt is 0
    /// @dev Emits a {PositionClosed} event
    /// @param _nftIndex The index of the NFT used as collateral
    function closePosition(uint256 _nftIndex) external nonReentrant {
        accrue();
        _closePosition(_nftIndex);
    }

    /// @notice Allows members of the `LIQUIDATOR_ROLE` to liquidate a position. Positions can only be liquidated
    /// once their debt amount exceeds the minimum liquidation debt to collateral value rate.
    /// In order to liquidate a position, the liquidator needs to repay the user's outstanding debt.
    /// If the position is not insured, it's closed immediately and the collateral is sent to `_recipient`.
    /// If the position is insured, the position remains open (interest doesn't increase) and the owner of the position has a certain amount of time
    /// (`insuranceRepurchaseTimeLimit`) to fully repay the liquidator and pay an additional liquidation fee (`insuranceLiquidationPenaltyRate`), if this
    /// is done in time the user gets back their collateral and their position is automatically closed. If the user doesn't repurchase their collateral
    /// before the time limit passes, the liquidator can claim the liquidated NFT and the position is closed
    /// @dev Emits a {Liquidated} event
    /// @param _nftIndex The NFT to liquidate
    /// @param _recipient The address to send the NFT to
    function liquidate(uint256 _nftIndex, address _recipient)
        external
        nonReentrant
    {
        accrue();
        _liquidate(_nftIndex, _recipient);
    }

    /// @notice Allows liquidated users who purchased insurance to repurchase their collateral within the time limit
    /// defined with the `insuranceRepurchaseTimeLimit`. The user needs to pay the liquidator the total amount of debt
    /// the position had at the time of liquidation, plus an insurance liquidation fee defined with `insuranceLiquidationPenaltyRate`
    /// @dev Emits a {Repurchased} event
    /// @param _nftIndex The NFT to repurchase
    function repurchase(uint256 _nftIndex) external nonReentrant {
        _repurchase(_nftIndex);
    }

    /// @notice Allows the liquidator who liquidated the insured position with NFT at index `_nftIndex` to claim the position's collateral
    /// after the time period defined with `insuranceRepurchaseTimeLimit` has expired and the position owner has not repurchased the collateral.
    /// @dev Emits an {InsuranceExpired} event
    /// @param _nftIndex The NFT to claim
    /// @param _recipient The address to send the NFT to
    function claimExpiredInsuranceNFT(uint256 _nftIndex, address _recipient)
        external
        nonReentrant
    {
        _claimExpiredInsuranceNFT(_nftIndex, _recipient);
    }

    /// @notice Allows borrowers to deposit NFTs to a whitelisted strategy. Strategies may be used to claim airdrops, stake NFTs for rewards and more.
    /// @dev Emits multiple {StrategyDeposit} events
    /// @param _nftIndexes The indexes of the NFTs to deposit
    /// @param _strategyIndex The index of the strategy to deposit the NFTs into, see {getStrategies}
    /// @param _additionalData Additional data to send to the strategy.
    function depositInStrategy(
        uint256[] calldata _nftIndexes,
        uint256 _strategyIndex,
        bytes calldata _additionalData
    ) external nonReentrant {
        _depositInStrategy(_nftIndexes, _strategyIndex, _additionalData);
    }

    /// @notice Allows users to withdraw NFTs from strategies
    /// @dev Emits multiple {StrategyWithdrawal} events
    /// @param _nftIndexes The indexes of the NFTs to withdraw
    function withdrawFromStrategy(uint256[] calldata _nftIndexes)
        external
        nonReentrant
    {
        _withdrawFromStrategy(_nftIndexes);
    }

    /// @notice Allows the DAO to collect interest and fees before they are repaid
    function collect() external nonReentrant onlyRole(DAO_ROLE) {
        accrue();
        stablecoin.mint(msg.sender, totalFeeCollected);
        totalFeeCollected = 0;
    }

    /// @notice Allows the DAO to withdraw _amount of an ERC20
    function rescueToken(IERC20Upgradeable _token, uint256 _amount)
        external
        nonReentrant
        onlyRole(DAO_ROLE)
    {
        _token.safeTransfer(msg.sender, _amount);
    }

    /// @notice Allows the DAO to whitelist a strategy
    function addStrategy(address _strategy) external onlyRole(DAO_ROLE) {
        if (_strategy == address(0)) revert ZeroAddress();

        if (!nftStrategies.add(_strategy)) revert InvalidStrategy();
    }

    /// @notice Allows the DAO to remove a strategy from the whitelist
    function removeStrategy(address _strategy) external onlyRole(DAO_ROLE) {
        if (_strategy == address(0)) revert ZeroAddress();

        if (!nftStrategies.remove(_strategy)) revert InvalidStrategy();
    }


    /// @notice Allows the setter contract to change fields in the `VaultSettings` struct.
    /// @dev Validation and single field setting is handled by an external contract with the
    /// `SETTER_ROLE`. This was done to reduce the contract's size.
    function setSettings(VaultSettings calldata _settings)
        external
        onlyRole(SETTER_ROLE)
    {
        settings = _settings;
    }

    /// @dev Opens a position
    /// Emits a {PositionOpened} event
    /// @param _owner The owner of the position to open
    /// @param _nftIndex The NFT used as collateral for the position
    function _openPosition(address _owner, uint256 _nftIndex) internal {
        positionOwner[_nftIndex] = _owner;
        positionIndexes.add(_nftIndex);

        nftContract.transferFrom(_owner, address(this), _nftIndex);

        emit PositionOpened(_owner, _nftIndex);
    }

    /// @dev See {borrow}
    function _borrow(
        uint256 _nftIndex,
        uint256 _amount,
        bool _useInsurance
    ) internal validNFTIndex(_nftIndex) {
        address owner = positionOwner[_nftIndex];
        if (owner != msg.sender && owner != address(0)) revert Unauthorized();

        if (_amount == 0) revert InvalidAmount(_amount);

        if (totalDebtAmount + _amount > settings.borrowAmountCap)
            revert DebtCapReached();

        Position storage position = positions[_nftIndex];
        if (position.liquidatedAt != 0) revert PositionLiquidated(_nftIndex);

        BorrowType borrowType = position.borrowType;
        BorrowType targetBorrowType = _useInsurance
            ? BorrowType.USE_INSURANCE
            : BorrowType.NON_INSURANCE;

        if (borrowType == BorrowType.NOT_CONFIRMED)
            position.borrowType = targetBorrowType;
        else if (borrowType != targetBorrowType) revert InvalidInsuranceMode();

        uint256 creditLimit = _getCreditLimit(msg.sender, _nftIndex);
        uint256 debtAmount = _getDebtAmount(_nftIndex);
        if (debtAmount + _amount > creditLimit) revert InvalidAmount(_amount);

        //calculate the borrow fee
        uint256 organizationFee = (_amount *
            settings.organizationFeeRate.numerator) /
            settings.organizationFeeRate.denominator;

        uint256 feeAmount = organizationFee;
        //if the position is insured, calculate the insurance fee
        if (targetBorrowType == BorrowType.USE_INSURANCE) {
            feeAmount +=
                (_amount * settings.insurancePurchaseRate.numerator) /
                settings.insurancePurchaseRate.denominator;
        }
        totalFeeCollected += feeAmount;

        uint256 debtPortion = totalDebtPortion;
        // update debt portion
        if (debtPortion == 0) {
            totalDebtPortion = _amount;
            position.debtPortion = _amount;
        } else {
            uint256 plusPortion = (debtPortion * _amount) / totalDebtAmount;
            totalDebtPortion = debtPortion + plusPortion;
            position.debtPortion += plusPortion;
        }
        position.debtPrincipal += _amount;
        totalDebtAmount += _amount;

        if (positionOwner[_nftIndex] == address(0)) {
            _openPosition(msg.sender, _nftIndex);
        }

        //subtract the fee from the amount borrowed
        stablecoin.mint(msg.sender, _amount - feeAmount);

        emit Borrowed(msg.sender, _nftIndex, _amount);
    }

    /// @dev See {repay}
    function _repay(uint256 _nftIndex, uint256 _amount)
        internal
        validNFTIndex(_nftIndex)
    {
        if (msg.sender != positionOwner[_nftIndex]) revert Unauthorized();

        if (_amount == 0) revert InvalidAmount(_amount);

        Position storage position = positions[_nftIndex];
        if (position.liquidatedAt > 0) revert PositionLiquidated(_nftIndex);

        uint256 debtAmount = _getDebtAmount(_nftIndex);
        if (debtAmount == 0) revert NoDebt();

        uint256 debtPrincipal = position.debtPrincipal;
        uint256 debtInterest = debtAmount - debtPrincipal;

        _amount = _amount > debtAmount ? debtAmount : _amount;

        // burn all payment, the interest is sent to the DAO using the {collect} function
        stablecoin.burnFrom(msg.sender, _amount);

        uint256 paidPrincipal;

        unchecked {
            paidPrincipal = _amount > debtInterest ? _amount - debtInterest : 0;
        }

        uint256 totalPortion = totalDebtPortion;
        uint256 totalDebt = totalDebtAmount;
        uint256 minusPortion = paidPrincipal == debtPrincipal
            ? position.debtPortion
            : (totalPortion * _amount) / totalDebt;

        totalDebtPortion = totalPortion - minusPortion;
        position.debtPortion -= minusPortion;
        position.debtPrincipal -= paidPrincipal;
        totalDebtAmount = totalDebt - _amount;

        emit Repaid(msg.sender, _nftIndex, _amount);
    }

    /// @dev See {closePosition}
    function _closePosition(uint256 _nftIndex)
        internal
        validNFTIndex(_nftIndex)
    {
        if (msg.sender != positionOwner[_nftIndex]) revert Unauthorized();

        Position storage position = positions[_nftIndex];
        if (position.liquidatedAt > 0) revert PositionLiquidated(_nftIndex);

        uint256 debt = _getDebtAmount(_nftIndex);
        if (debt > 0) revert NonZeroDebt(debt);

        INFTStrategy strategy = position.strategy;
        positionOwner[_nftIndex] = address(0);
        delete positions[_nftIndex];
        positionIndexes.remove(_nftIndex);

        if (address(strategy) == address(0))
            nftContract.safeTransferFrom(address(this), msg.sender, _nftIndex);
        else strategy.withdraw(msg.sender, msg.sender, _nftIndex);

        emit PositionClosed(msg.sender, _nftIndex);
    }

    /// @dev See {liquidate}
    function _liquidate(uint256 _nftIndex, address _recipient)
        internal
        onlyRole(LIQUIDATOR_ROLE)
        validNFTIndex(_nftIndex)
    {
        address posOwner = positionOwner[_nftIndex];
        if (posOwner == address(0)) revert InvalidPosition(_nftIndex);

        Position storage position = positions[_nftIndex];
        if (position.liquidatedAt > 0) revert PositionLiquidated(_nftIndex);

        uint256 debtAmount = _getDebtAmount(_nftIndex);
        if (debtAmount < _getLiquidationLimit(posOwner, _nftIndex))
            revert InvalidPosition(_nftIndex);

        // burn all payment
        stablecoin.burnFrom(msg.sender, debtAmount);

        // update debt portion
        totalDebtPortion -= position.debtPortion;
        totalDebtAmount -= debtAmount;
        position.debtPortion = 0;

        INFTStrategy strategy = position.strategy;
        bool insured = position.borrowType == BorrowType.USE_INSURANCE;
        if (insured) {
            position.debtAmountForRepurchase = debtAmount;
            position.liquidatedAt = block.timestamp;
            position.liquidator = msg.sender;

            if (address(strategy) != address(0)) {
                strategy.withdraw(posOwner, address(this), _nftIndex);
                delete position.strategy;
            }
        } else {
            // transfer nft to liquidator
            positionOwner[_nftIndex] = address(0);
            delete positions[_nftIndex];
            positionIndexes.remove(_nftIndex);
            if (address(strategy) == address(0))
                nftContract.transferFrom(address(this), _recipient, _nftIndex);
            else strategy.withdraw(posOwner, _recipient, _nftIndex);
        }

        emit Liquidated(msg.sender, posOwner, _nftIndex, insured);
    }

    /// @dev See {repurchase}
    function _repurchase(uint256 _nftIndex) internal validNFTIndex(_nftIndex) {
        Position memory position = positions[_nftIndex];
        if (msg.sender != positionOwner[_nftIndex]) revert Unauthorized();
        if (position.liquidatedAt == 0) revert InvalidPosition(_nftIndex);
        if (position.borrowType != BorrowType.USE_INSURANCE)
            revert InvalidPosition(_nftIndex);
        if (
            block.timestamp >=
            position.liquidatedAt + settings.insuranceRepurchaseTimeLimit
        ) revert PositionInsuranceExpired(_nftIndex);

        uint256 debtAmount = position.debtAmountForRepurchase;
        uint256 penalty = (debtAmount *
            settings.insuranceLiquidationPenaltyRate.numerator) /
            settings.insuranceLiquidationPenaltyRate.denominator;

        // transfer nft to user
        positionOwner[_nftIndex] = address(0);
        delete positions[_nftIndex];
        positionIndexes.remove(_nftIndex);

        // transfer payment to liquidator
        stablecoin.safeTransferFrom(
            msg.sender,
            position.liquidator,
            debtAmount + penalty
        );

        nftContract.safeTransferFrom(address(this), msg.sender, _nftIndex);

        emit Repurchased(msg.sender, _nftIndex);
    }

    /// @dev See {claimExpiredInsuranceNFT}
    function _claimExpiredInsuranceNFT(uint256 _nftIndex, address _recipient)
        internal
        validNFTIndex(_nftIndex)
    {
        if (_recipient == address(0)) revert ZeroAddress();
        Position memory position = positions[_nftIndex];
        address owner = positionOwner[_nftIndex];
        if (owner == address(0)) revert InvalidPosition(_nftIndex);
        if (position.liquidatedAt == 0) revert InvalidPosition(_nftIndex);
        if (
            position.liquidatedAt + settings.insuranceRepurchaseTimeLimit >
            block.timestamp
        ) revert PositionInsuranceNotExpired(_nftIndex);
        if (position.liquidator != msg.sender) revert Unauthorized();

        positionOwner[_nftIndex] = address(0);
        delete positions[_nftIndex];
        positionIndexes.remove(_nftIndex);

        nftContract.transferFrom(address(this), _recipient, _nftIndex);

        emit InsuranceExpired(owner, _nftIndex);
    }

    /// @dev See {depositInStrategy}
    function _depositInStrategy(
        uint256[] calldata _nftIndexes,
        uint256 _strategyIndex,
        bytes calldata _additionalData
    ) internal {
        uint256 length = _nftIndexes.length;
        if (length == 0) revert InvalidLength();
        if (_strategyIndex >= nftStrategies.length()) revert InvalidStrategy();

        INFTStrategy strategy = INFTStrategy(nftStrategies.at(_strategyIndex));

        IERC721Upgradeable nft = nftContract;
        bool isStandard = INFTStrategy(strategy).kind() ==
            INFTStrategy.Kind.STANDARD;
        address depositAddress = strategy.depositAddress(msg.sender);
        for (uint256 i; i < length; ++i) {
            uint256 index = _nftIndexes[i];

            if (positionOwner[index] != msg.sender) revert Unauthorized();

            Position storage position = positions[index];
            if (position.liquidatedAt > 0) revert PositionLiquidated(index);

            if (address(position.strategy) != address(0)) revert InvalidPosition(index);

            if (isStandard) position.strategy = strategy;
            nft.transferFrom(address(this), depositAddress, index);

            emit StrategyDeposit(index, address(strategy), isStandard);
        }

        strategy.afterDeposit(msg.sender, _nftIndexes, _additionalData);

        if (!isStandard) {
            for (uint256 i; i < length; ++i) {
                if (nft.ownerOf(_nftIndexes[i]) != address(this))
                    revert InvalidStrategy();
            }
        }


    }

    /// @dev See {withdrawFromStrategy}
    function _withdrawFromStrategy(uint256[] calldata _nftIndexes) internal {
        uint256 length = _nftIndexes.length;
        if (length == 0) revert InvalidLength();

        IERC721Upgradeable nft = nftContract;
        for (uint256 i; i < length; ++i) {
            uint256 index = _nftIndexes[i];

            if (positionOwner[index] != msg.sender) revert Unauthorized();

            Position storage position = positions[index];
            INFTStrategy strategy = position.strategy;
            if (address(strategy) != address(0)) {
                strategy.withdraw(msg.sender, address(this), index);

                if (nft.ownerOf(index) != address(this))
                    revert InvalidStrategy();

                delete position.strategy;

                emit StrategyWithdrawal(index, address(strategy));
            }
        }
    }

    /// @dev Returns the credit limit of an NFT
    /// @param _owner The owner of the NFT
    /// @param _nftIndex The NFT to return credit limit of
    /// @return The NFT credit limit
    function _getCreditLimit(address _owner, uint256 _nftIndex)
        internal
        view
        returns (uint256)
    {
        return nftValueProvider.getCreditLimitETH(_owner, _nftIndex);
    }

    /// @dev Returns the minimum amount of debt necessary to liquidate an NFT
    /// @param _owner The owner of the NFT
    /// @param _nftIndex The index of the NFT
    /// @return The minimum amount of debt to liquidate the NFT
    function _getLiquidationLimit(address _owner, uint256 _nftIndex)
        internal
        view
        returns (uint256)
    {
        return nftValueProvider.getLiquidationLimitETH(_owner, _nftIndex);
    }

    /// @dev Calculates current outstanding debt of an NFT
    /// @param _nftIndex The NFT to calculate the outstanding debt of
    /// @return The outstanding debt value
    function _getDebtAmount(uint256 _nftIndex) internal view returns (uint256) {
        uint256 calculatedDebt = _calculateDebt(
            totalDebtAmount,
            positions[_nftIndex].debtPortion,
            totalDebtPortion
        );

        uint256 principal = positions[_nftIndex].debtPrincipal;

        //_calculateDebt is prone to rounding errors that may cause
        //the calculated debt amount to be 1 or 2 units less than
        //the debt principal when the accrue() function isn't called
        //in between the first borrow and the _calculateDebt call.
        return principal > calculatedDebt ? principal : calculatedDebt;
    }

    /// @dev Calculates the total debt of a position given the global debt, the user's portion of the debt and the total user portions
    /// @param total The global outstanding debt
    /// @param userPortion The user's portion of debt
    /// @param totalPortion The total user portions of debt
    /// @return The outstanding debt of the position
    function _calculateDebt(
        uint256 total,
        uint256 userPortion,
        uint256 totalPortion
    ) internal pure returns (uint256) {
        return totalPortion == 0 ? 0 : (total * userPortion) / totalPortion;
    }

    /// @dev Calculates the additional global interest since last time the contract's state was updated by calling {accrue}
    /// @return The additional interest value
    function _calculateAdditionalInterest() internal view returns (uint256) {
        // Number of seconds since {accrue} was called
        uint256 elapsedTime = block.timestamp - totalDebtAccruedAt;
        if (elapsedTime == 0) {
            return 0;
        }

        uint256 totalDebt = totalDebtAmount;
        if (totalDebt == 0) {
            return 0;
        }

        // Accrue interest
        return
            (elapsedTime * totalDebt * settings.debtInterestApr.numerator) /
            settings.debtInterestApr.denominator /
            365 days;
    }

    /// @dev Validates a rate. The denominator must be greater than zero and greater than or equal to the numerator.
    /// @param _rate The rate to validate
    function _validateRateBelowOne(Rate memory _rate) internal pure {
        if (_rate.denominator == 0 || _rate.denominator < _rate.numerator)
            revert InvalidRate(_rate);
    }
}

File 2 of 18 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
    function __AccessControl_init() internal onlyInitializing {
    }

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        StringsUpgradeable.toHexString(uint160(account), 20),
                        " is missing role ",
                        StringsUpgradeable.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }

    /**
     * @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[49] private __gap;
}

File 3 of 18 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

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

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuardUpgradeable is Initializable {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

    /**
     * @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[49] private __gap;
}

File 4 of 18 : IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165Upgradeable.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721Upgradeable is IERC165Upgradeable {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;
}

File 5 of 18 : EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSetUpgradeable {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastvalue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastvalue;
                // Update the index for the moved value
                set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        return _values(set._inner);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        assembly {
            result := store
        }

        return result;
    }
}

File 6 of 18 : SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";
import "../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {
    using AddressUpgradeable for address;

    function safeTransfer(
        IERC20Upgradeable token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20Upgradeable 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(
        IERC20Upgradeable 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));
    }

    function safeIncreaseAllowance(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @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(IERC20Upgradeable 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");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 7 of 18 : IAggregatorV3Interface.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;

interface IAggregatorV3Interface {
    function decimals() external view returns (uint8);

    function latestRoundData()
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );
}

File 8 of 18 : IStableCoin.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;

import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";

interface IStableCoin is IERC20Upgradeable {
    function mint(address _to, uint256 _value) external;

    function burn(uint256 _value) external;

    function burnFrom(address _from, uint256 _value) external;
}

File 9 of 18 : INFTValueProvider.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;

interface INFTValueProvider {
    function getCreditLimitETH(address _owner, uint256 _nftIndex) external view returns (uint256);
    function getLiquidationLimitETH(address _owner, uint256 _nftIndex) external view returns (uint256);
}

File 10 of 18 : INFTStrategy.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;

interface INFTStrategy {

    enum Kind {
        STANDARD,
        FLASH
    }

    function kind() external view returns (Kind);
    function depositAddress(address _account) external view returns (address);
    function afterDeposit(address _owner, uint256[] calldata _nftIndexes, bytes calldata _data) external;
    function withdraw(address _owner, address _recipient, uint256 _nftIndex) external;
}

File 11 of 18 : IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControlUpgradeable {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 12 of 18 : ContextUpgradeable.sol
// 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;
}

File 13 of 18 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 14 of 18 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }

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

File 15 of 18 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

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.
 *
 * 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 initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

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

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 16 of 18 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.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
     * ====
     *
     * [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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, "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");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // 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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 17 of 18 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165Upgradeable {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

Contract Security Audit

Contract ABI

[{"inputs":[],"name":"DebtCapReached","type":"error"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidInsuranceMode","type":"error"},{"inputs":[],"name":"InvalidLength","type":"error"},{"inputs":[{"internalType":"uint256","name":"nftIndex","type":"uint256"}],"name":"InvalidNFT","type":"error"},{"inputs":[{"internalType":"bytes32","name":"nftType","type":"bytes32"}],"name":"InvalidNFTType","type":"error"},{"inputs":[],"name":"InvalidOracleResults","type":"error"},{"inputs":[{"internalType":"uint256","name":"nftIndex","type":"uint256"}],"name":"InvalidPosition","type":"error"},{"inputs":[{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"rate","type":"tuple"}],"name":"InvalidRate","type":"error"},{"inputs":[],"name":"InvalidStrategy","type":"error"},{"inputs":[{"internalType":"uint256","name":"unlockTime","type":"uint256"}],"name":"InvalidUnlockTime","type":"error"},{"inputs":[],"name":"NoDebt","type":"error"},{"inputs":[{"internalType":"uint256","name":"debtAmount","type":"uint256"}],"name":"NonZeroDebt","type":"error"},{"inputs":[{"internalType":"uint256","name":"nftIndex","type":"uint256"}],"name":"PositionInsuranceExpired","type":"error"},{"inputs":[{"internalType":"uint256","name":"nftIndex","type":"uint256"}],"name":"PositionInsuranceNotExpired","type":"error"},{"inputs":[{"internalType":"uint256","name":"nftIndex","type":"uint256"}],"name":"PositionLiquidated","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[{"internalType":"uint8","name":"action","type":"uint8"}],"name":"UnknownAction","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Borrowed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"index","type":"uint256"}],"name":"InsuranceExpired","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"liquidator","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"index","type":"uint256"},{"indexed":false,"internalType":"bool","name":"insured","type":"bool"}],"name":"Liquidated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"index","type":"uint256"}],"name":"PositionClosed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"index","type":"uint256"}],"name":"PositionOpened","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Repaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"index","type":"uint256"}],"name":"Repurchased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nftIndex","type":"uint256"},{"indexed":true,"internalType":"address","name":"strategy","type":"address"},{"indexed":false,"internalType":"bool","name":"isStandard","type":"bool"}],"name":"StrategyDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nftIndex","type":"uint256"},{"indexed":true,"internalType":"address","name":"strategy","type":"address"}],"name":"StrategyWithdrawal","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accrue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_strategy","type":"address"}],"name":"addStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nftIndex","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bool","name":"_useInsurance","type":"bool"}],"name":"borrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nftIndex","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"claimExpiredInsuranceNFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nftIndex","type":"uint256"}],"name":"closePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collect","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_nftIndexes","type":"uint256[]"},{"internalType":"uint256","name":"_strategyIndex","type":"uint256"},{"internalType":"bytes","name":"_additionalData","type":"bytes"}],"name":"depositInStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8[]","name":"_actions","type":"uint8[]"},{"internalType":"bytes[]","name":"_datas","type":"bytes[]"}],"name":"doActions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_nftIndex","type":"uint256"}],"name":"getCreditLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nftIndex","type":"uint256"}],"name":"getDebtInterest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_nftIndex","type":"uint256"}],"name":"getLiquidationLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStrategies","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IStableCoin","name":"_stablecoin","type":"address"},{"internalType":"contract IERC721Upgradeable","name":"_nftContract","type":"address"},{"internalType":"contract INFTValueProvider","name":"_nftValueProvider","type":"address"},{"components":[{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"debtInterestApr","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"unused15","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"unused16","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"unused17","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"unused18","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"unused12","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"organizationFeeRate","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"insurancePurchaseRate","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"insuranceLiquidationPenaltyRate","type":"tuple"},{"internalType":"uint256","name":"insuranceRepurchaseTimeLimit","type":"uint256"},{"internalType":"uint256","name":"borrowAmountCap","type":"uint256"}],"internalType":"struct PETHNFTVault.VaultSettings","name":"_settings","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nftIndex","type":"uint256"}],"name":"isLiquidatable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nftIndex","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"liquidate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nftContract","outputs":[{"internalType":"contract IERC721Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftValueProvider","outputs":[{"internalType":"contract INFTValueProvider","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"openPositionsIndexes","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"positionOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"positions","outputs":[{"internalType":"enum PETHNFTVault.BorrowType","name":"borrowType","type":"uint8"},{"internalType":"uint256","name":"debtPrincipal","type":"uint256"},{"internalType":"uint256","name":"debtPortion","type":"uint256"},{"internalType":"uint256","name":"debtAmountForRepurchase","type":"uint256"},{"internalType":"uint256","name":"liquidatedAt","type":"uint256"},{"internalType":"address","name":"liquidator","type":"address"},{"internalType":"contract INFTStrategy","name":"strategy","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_strategy","type":"address"}],"name":"removeStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nftIndex","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"repay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nftIndex","type":"uint256"}],"name":"repurchase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20Upgradeable","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"rescueToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"debtInterestApr","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"unused15","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"unused16","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"unused17","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"unused18","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"unused12","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"organizationFeeRate","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"insurancePurchaseRate","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"insuranceLiquidationPenaltyRate","type":"tuple"},{"internalType":"uint256","name":"insuranceRepurchaseTimeLimit","type":"uint256"},{"internalType":"uint256","name":"borrowAmountCap","type":"uint256"}],"internalType":"struct PETHNFTVault.VaultSettings","name":"_settings","type":"tuple"}],"name":"setSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"settings","outputs":[{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"debtInterestApr","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"unused15","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"unused16","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"unused17","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"unused18","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"unused12","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"organizationFeeRate","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"insurancePurchaseRate","type":"tuple"},{"components":[{"internalType":"uint128","name":"numerator","type":"uint128"},{"internalType":"uint128","name":"denominator","type":"uint128"}],"internalType":"struct PETHNFTVault.Rate","name":"insuranceLiquidationPenaltyRate","type":"tuple"},{"internalType":"uint256","name":"insuranceRepurchaseTimeLimit","type":"uint256"},{"internalType":"uint256","name":"borrowAmountCap","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stablecoin","outputs":[{"internalType":"contract IStableCoin","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDebtAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalFeeCollected","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalPositions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unused14","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_nftIndexes","type":"uint256[]"}],"name":"withdrawFromStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b5061497e806100206000396000f3fe608060405234801561001057600080fd5b50600436106102ad5760003560e01c8063857632c11161017b578063d547741f116100d8578063e9cbd8221161008c578063f8ba4cff11610071578063f8ba4cff1461072d578063f8cd13ad14610735578063fda1fa5f1461074857600080fd5b8063e9cbd82214610707578063f80046751461071a57600080fd5b8063d8aed145116100bd578063d8aed145146105c8578063e06174e4146105db578063e5225381146106ff57600080fd5b8063d547741f146105a2578063d56d229d146105b557600080fd5b8063b3060d361161012f578063b9b2b5cd11610114578063b9b2b5cd1461057d578063bb3be86e14610586578063c8dffa951461059957600080fd5b8063b3060d361461053f578063b49a60bb1461056857600080fd5b806399fbab881161016057806399fbab88146104b6578063a126d60114610524578063a217fddf1461053757600080fd5b8063857632c11461046a57806391d148541461047d57600080fd5b806333f3d628116102295780635fae8b3d116101dd57806364c96f85116101c257806364c96f8514610419578063676e52591461042c5780636c3354041461045757600080fd5b80635fae8b3d146103f35780636423faf41461040657600080fd5b80634284e9de1161020e5780634284e9de146103ba5780634ddfb955146103cd5780634f81650a146103e057600080fd5b806333f3d6281461039457806336568abe146103a757600080fd5b8063175188e811610280578063223e547911610265578063223e54791461033d578063248a9ca3146103505780632f2ff15d1461038157600080fd5b8063175188e814610317578063211a44431461032a57600080fd5b806301ffc9a7146102b25780630f6f2833146102da578063164730d1146102ef5780631698c3bd14610302575b600080fd5b6102c56102c03660046141c0565b610750565b60405190151581526020015b60405180910390f35b6102ed6102e8366004614333565b610787565b005b6102ed6102fd3660046140f4565b6107ef565b61030a610b1b565b6040516102d19190614505565b6102ed610325366004613fb3565b610b2c565b6102c5610338366004614179565b610baa565b6102ed61034b366004613fb3565b610c43565b61037361035e366004614179565b60009081526065602052604090206001015490565b6040519081526020016102d1565b6102ed61038f366004614191565b610ca0565b6102ed6103a23660046141e8565b610ccb565b6102ed6103b5366004614191565b610d50565b6102ed6103c83660046141fa565b610dd8565b6102ed6103db366004614056565b611041565b6103736103ee366004614179565b6110a0565b6102ed610401366004614191565b611103565b6102ed610414366004614016565b611164565b6102ed610427366004614179565b6111b4565b60ce5461043f906001600160a01b031681565b6040516001600160a01b0390911681526020016102d1565b610373610465366004613feb565b61120b565b610373610478366004613feb565b61121e565b6102c561048b366004614191565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6105116104c4366004614179565b60e160205260009081526040902080546001820154600283015460038401546004850154600586015460069096015460ff9095169593949293919290916001600160a01b03908116911687565b6040516102d1979695949392919061453d565b6102ed610532366004614179565b61122a565b610373600081565b61043f61054d366004614179565b60e2602052600090815260409020546001600160a01b031681565b610570611281565b6040516102d191906144b8565b61037360d25481565b60ca5461043f906001600160a01b031681565b61037360d05481565b6102ed6105b0366004614191565b61128d565b60cf5461043f906001600160a01b031681565b6102ed6105d6366004614312565b6112b3565b60408051808201825260d4546001600160801b038082168352600160801b9182900481166020808501919091528451808601865260d55480841682528490048316818301528551808701875260d65480851682528590048416818401528651808801885260d75480861682528690048516818501528751808901895260d85480871682528790048616818601528851808a018a5260d95480881682528890048716818701528951808b018b5260da5480891682528990048816818801528a51808c018c5260db54808a1682528a90048916818901528b51808d01909c5260dc54808a168d5299909904909716958a019590955260dd5460de546106e89a959894979396929592949291908b565b6040516102d19b9a999897969594939291906145f0565b6102ed61130b565b60c95461043f906001600160a01b031681565b6102ed610728366004614191565b6113f9565b6102ed611449565b6102ed6107433660046142de565b61148f565b6103736114cd565b60006001600160e01b03198216637965db0b60e01b148061078157506301ffc9a760e01b6001600160e01b03198316145b92915050565b600260975414156107cd5760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064015b60405180910390fd5b60026097556107da611449565b6107e58383836114d9565b5050600160975550565b600260975414156108305760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b600260975582811461084157600080fd5b6000805b84811015610b0e57600086868381811061086f57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610884919061436b565b905082158015610897575060648160ff16105b156108a9576108a4611449565b600192505b60ff811661090e5760008060008787868181106108d657634e487b7160e01b600052603260045260246000fd5b90506020028101906108e891906146e0565b8101906108f59190614333565b9250925092506109068383836114d9565b505050610afd565b60ff8116600114156109715760008086868581811061093d57634e487b7160e01b600052603260045260246000fd5b905060200281019061094f91906146e0565b81019061095c9190614312565b9150915061096a82826119a5565b5050610afd565b60ff8116600214156109cf57600085858481811061099f57634e487b7160e01b600052603260045260246000fd5b90506020028101906109b191906146e0565b8101906109be9190614179565b90506109c981611c6c565b50610afd565b60ff811660031415610a2b576000808686858181106109fe57634e487b7160e01b600052603260045260246000fd5b9050602002810190610a1091906146e0565b810190610a1d9190614191565b9150915061096a8282611f46565b60ff811660641415610a83576000858584818110610a5957634e487b7160e01b600052603260045260246000fd5b9050602002810190610a6b91906146e0565b810190610a789190614179565b90506109c981612407565b60ff811660651415610adf57600080868685818110610ab257634e487b7160e01b600052603260045260246000fd5b9050602002810190610ac491906146e0565b810190610ad19190614191565b9150915061096a828261279e565b6040516360df9f8760e01b815260ff821660048201526024016107c4565b50610b0781614816565b9050610845565b5050600160975550505050565b6060610b2760df612af6565b905090565b7f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b2603610b578133612b03565b6001600160a01b038216610b7e5760405163d92e233d60e01b815260040160405180910390fd5b610b8960ea83612b83565b610ba657604051632711b74d60e11b815260040160405180910390fd5b5050565b600081815260e16020526040812081815460ff166002811115610bdd57634e487b7160e01b600052602160045260246000fd5b1415610bec5750600092915050565b600481015415610bff5750600092915050565b6001810154600084815260e26020526040902054610c26906001600160a01b03168561121e565b610c2f856110a0565b610c399083614725565b1015949350505050565b7f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b2603610c6e8133612b03565b6001600160a01b038216610c955760405163d92e233d60e01b815260040160405180910390fd5b610b8960ea83612b98565b600082815260656020526040902060010154610cbc8133612b03565b610cc68383612bad565b505050565b60026097541415610d0c5760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b60026097557f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b2603610d3c8133612b03565b6107e56001600160a01b0384163384612c4f565b6001600160a01b0381163314610dce5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084016107c4565b610ba68282612cc7565b600054610100900460ff16610df35760005460ff1615610df7565b303b155b610e695760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016107c4565b600054610100900460ff16158015610e8b576000805461ffff19166101011790555b610e93612d4a565b610e9b612db7565b610ec57f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b260333612e2a565b610f0f7f5e17fc5225d4a099df75359ce1f405503ca79498a8dc46a7d583235a0ee45c167f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b2603612e34565b610f597f61c92169ef077349011ff0b1383c894d86c5f0b41d986366b58a6cf31e93beda7f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b2603612e34565b610f837f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b260380612e34565b610f9a610f9536849003840184614274565b612e7f565b610fb0610f953684900384016101808501614274565b610fc6610f953684900384016101c08501614274565b610fdc610f953684900384016102008501614274565b60c980546001600160a01b038088166001600160a01b03199283161790925560cf805487841690831617905560ca8054928616929091169190911790558160d46110268282614847565b5050801561103a576000805461ff00191690555b5050505050565b600260975414156110825760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b60026097556110948585858585612ed5565b50506001609755505050565b600081815260e1602052604081206001810154600482015483906110e8576110e36110c9613366565b60d0546110d69190614725565b846002015460d3546133e2565b6110ee565b82600301545b9050808211156110fb5750805b039392505050565b600260975414156111445760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b6002609755611151611449565b61115b8282611f46565b50506001609755565b600260975414156111a55760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b600260975561115b828261340f565b600260975414156111f55760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b600260975561120381612407565b506001609755565b60006112178383613632565b9392505050565b600061121783836136b8565b6002609754141561126b5760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b6002609755611278611449565b61120381611c6c565b6060610b2760ea612af6565b6000828152606560205260409020600101546112a98133612b03565b610cc68383612cc7565b600260975414156112f45760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b6002609755611301611449565b61115b82826119a5565b6002609754141561134c5760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b60026097557f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b260361137c8133612b03565b611384611449565b60c95460d2546040516340c10f1960e01b815233600482015260248101919091526001600160a01b03909116906340c10f1990604401600060405180830381600087803b1580156113d457600080fd5b505af11580156113e8573d6000803e3d6000fd5b5050600060d2555050600160975550565b6002609754141561143a5760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b600260975561115b828261279e565b6000611453613366565b90504260d1819055508060d0600082825461146e9190614725565b925050819055508060d260008282546114879190614725565b909155505050565b7f61c92169ef077349011ff0b1383c894d86c5f0b41d986366b58a6cf31e93beda6114ba8133612b03565b8160d46114c78282614847565b50505050565b6000610b2760df6136f2565b60cf546040516331a9108f60e11b81526004810185905284916000916001600160a01b0390911690636352211e9060240160206040518083038186803b15801561152257600080fd5b505afa158015611536573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155a9190613fcf565b6001600160a01b0316141561158557604051632d9e959b60e21b8152600481018290526024016107c4565b600084815260e260205260409020546001600160a01b03163381148015906115b557506001600160a01b03811615155b156115d2576040516282b42960e81b815260040160405180910390fd5b836115f357604051633728b83d60e01b8152600481018590526024016107c4565b60de5460d054611604908690614725565b111561162357604051633b60212960e01b815260040160405180910390fd5b600085815260e16020526040902060048101541561165657604051624483ab60e91b8152600481018790526024016107c4565b805460ff1660008561166957600161166c565b60025b9050600082600281111561169057634e487b7160e01b600052602160045260246000fd5b14156116cc5782548190849060ff191660018360028111156116c257634e487b7160e01b600052602160045260246000fd5b021790555061172a565b8060028111156116ec57634e487b7160e01b600052602160045260246000fd5b82600281111561170c57634e487b7160e01b600052602160045260246000fd5b1461172a5760405163a46b186960e01b815260040160405180910390fd5b6000611736338a613632565b905060006117438a6136fc565b9050816117508a83614725565b111561177257604051633728b83d60e01b8152600481018a90526024016107c4565b60da546000906001600160801b03600160801b820481169161179591168c61475d565b61179f919061473d565b90508060028560028111156117c457634e487b7160e01b600052602160045260246000fd5b14156118015760db546001600160801b03600160801b82048116916117ea91168d61475d565b6117f4919061473d565b6117fe9082614725565b90505b8060d260008282546118139190614725565b909155505060d354806118315760d38c9055600288018c9055611878565b60d0546000906118418e8461475d565b61184b919061473d565b90506118578183614725565b60d381905550808960020160008282546118719190614725565b9091555050505b8b88600101600082825461188c9190614725565b925050819055508b60d060008282546118a59190614725565b909155505060008d815260e260205260409020546001600160a01b03166118d0576118d0338e613746565b60c960009054906101000a90046001600160a01b03166001600160a01b03166340c10f1933848f611901919061477c565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561194757600080fd5b505af115801561195b573d6000803e3d6000fd5b50506040518e81528f92503391507feae9cfbc77fdd40ca899f36b608256063b2bc9d8178b0220f7ad513e178d67309060200160405180910390a350505050505050505050505050565b60cf546040516331a9108f60e11b81526004810184905283916000916001600160a01b0390911690636352211e9060240160206040518083038186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a269190613fcf565b6001600160a01b03161415611a5157604051632d9e959b60e21b8152600481018290526024016107c4565b600083815260e260205260409020546001600160a01b03163314611a87576040516282b42960e81b815260040160405180910390fd5b81611aa857604051633728b83d60e01b8152600481018390526024016107c4565b600083815260e160205260409020600481015415611adb57604051624483ab60e91b8152600481018590526024016107c4565b6000611ae6856136fc565b905080611b06576040516308d1fde360e11b815260040160405180910390fd5b60018201546000611b17828461477c565b9050828611611b265785611b28565b825b60c95460405163079cc67960e41b8152336004820152602481018390529197506001600160a01b0316906379cc679090604401600060405180830381600087803b158015611b7557600080fd5b505af1158015611b89573d6000803e3d6000fd5b505050506000818711611b9d576000611ba1565b8187035b60d35460d054919250906000858414611bce5781611bbf8b8561475d565b611bc9919061473d565b611bd4565b87600201545b9050611be0818461477c565b60d38190555080886002016000828254611bfa919061477c565b9250508190555083886001016000828254611c15919061477c565b90915550611c2590508a8361477c565b60d0556040518a81528b9033907f1b8cd61ed43bec7c6bdad3a18ffee613f99c853d16c50678d248d879e1b434389060200160405180910390a35050505050505050505050565b60cf546040516331a9108f60e11b81526004810183905282916000916001600160a01b0390911690636352211e9060240160206040518083038186803b158015611cb557600080fd5b505afa158015611cc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ced9190613fcf565b6001600160a01b03161415611d1857604051632d9e959b60e21b8152600481018290526024016107c4565b600082815260e260205260409020546001600160a01b03163314611d4e576040516282b42960e81b815260040160405180910390fd5b600082815260e160205260409020600481015415611d8157604051624483ab60e91b8152600481018490526024016107c4565b6000611d8c846136fc565b90508015611db057604051630314a45960e11b8152600481018290526024016107c4565b600680830154600086815260e26020908152604080832080546001600160a01b031990811690915560e19092528220805460ff19168155600181018390556002810183905560038101839055600481019290925560058201805482169055920180549092169091556001600160a01b0316611e2c60df8661381f565b506001600160a01b038116611eaa5760cf54604051632142170760e11b8152306004820152336024820152604481018790526001600160a01b03909116906342842e0e90606401600060405180830381600087803b158015611e8d57600080fd5b505af1158015611ea1573d6000803e3d6000fd5b50505050611f12565b604051636ce5768960e11b815233600482018190526024820152604481018690526001600160a01b0382169063d9caed1290606401600060405180830381600087803b158015611ef957600080fd5b505af1158015611f0d573d6000803e3d6000fd5b505050505b604051859033907fa9e0cdf27a7965d21573ebb808fbcb2c2a1cfd656e1ecf3f82549437b474067790600090a35050505050565b7f5e17fc5225d4a099df75359ce1f405503ca79498a8dc46a7d583235a0ee45c16611f718133612b03565b60cf546040516331a9108f60e11b81526004810185905284916000916001600160a01b0390911690636352211e9060240160206040518083038186803b158015611fba57600080fd5b505afa158015611fce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ff29190613fcf565b6001600160a01b0316141561201d57604051632d9e959b60e21b8152600481018290526024016107c4565b600084815260e260205260409020546001600160a01b03168061205657604051631b1862a360e21b8152600481018690526024016107c4565b600085815260e16020526040902060048101541561208957604051624483ab60e91b8152600481018790526024016107c4565b6000612094876136fc565b90506120a083886136b8565b8110156120c357604051631b1862a360e21b8152600481018890526024016107c4565b60c95460405163079cc67960e41b8152336004820152602481018390526001600160a01b03909116906379cc679090604401600060405180830381600087803b15801561210f57600080fd5b505af1158015612123573d6000803e3d6000fd5b50505050816002015460d3600082825461213d919061477c565b925050819055508060d06000828254612156919061477c565b90915550506000600280840182905560068401546001600160a01b03169190845460ff16600281111561219957634e487b7160e01b600052602160045260246000fd5b149050801561225257600384018390554260048501556005840180546001600160a01b031916331790556001600160a01b0382161561224d57604051636ce5768960e11b81526001600160a01b038681166004830152306024830152604482018b905283169063d9caed1290606401600060405180830381600087803b15801561222257600080fd5b505af1158015612236573d6000803e3d6000fd5b5050506006850180546001600160a01b0319169055505b6123ac565b600089815260e26020908152604080832080546001600160a01b031990811690915560e19092528220805460ff191681556001810183905560028101839055600381018390556004810192909255600582018054821690556006909101805490911690556122c160df8a61381f565b506001600160a01b0382166123415760cf546040516323b872dd60e01b81523060048201526001600160a01b038a81166024830152604482018c9052909116906323b872dd90606401600060405180830381600087803b15801561232457600080fd5b505af1158015612338573d6000803e3d6000fd5b505050506123ac565b604051636ce5768960e11b81526001600160a01b0386811660048301528981166024830152604482018b905283169063d9caed1290606401600060405180830381600087803b15801561239357600080fd5b505af11580156123a7573d6000803e3d6000fd5b505050505b88856001600160a01b0316336001600160a01b03167f5e22e2eb4089b9fdb1a9fc6b284c2c42fae3b9d2c5182f4db03ef64d0f4891c3846040516123f4911515815260200190565b60405180910390a4505050505050505050565b60cf546040516331a9108f60e11b81526004810183905282916000916001600160a01b0390911690636352211e9060240160206040518083038186803b15801561245057600080fd5b505afa158015612464573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124889190613fcf565b6001600160a01b031614156124b357604051632d9e959b60e21b8152600481018290526024016107c4565b600082815260e16020526040808220815160e081019092528054829060ff1660028111156124f157634e487b7160e01b600052602160045260246000fd5b600281111561251057634e487b7160e01b600052602160045260246000fd5b815260018201546020808301919091526002830154604080840191909152600384015460608401526004840154608084015260058401546001600160a01b0390811660a0850152600690940154841660c090930192909252600087815260e29091522054919250163314612596576040516282b42960e81b815260040160405180910390fd5b60808101516125bb57604051631b1862a360e21b8152600481018490526024016107c4565b6002815160028111156125de57634e487b7160e01b600052602160045260246000fd5b146125ff57604051631b1862a360e21b8152600481018490526024016107c4565b60dd5460808201516126119190614725565b421061263357604051634d4efb5d60e01b8152600481018490526024016107c4565b606081015160dc546000906001600160801b03600160801b820481169161265b91168461475d565b612665919061473d565b600086815260e26020908152604080832080546001600160a01b031990811690915560e19092528220805460ff1916815560018101839055600281018390556003810183905560048101929092556005820180548216905560069091018054909116905590506126d660df8661381f565b50612700338460a0015183856126ec9190614725565b60c9546001600160a01b031692919061382b565b60cf54604051632142170760e11b8152306004820152336024820152604481018790526001600160a01b03909116906342842e0e90606401600060405180830381600087803b15801561275257600080fd5b505af1158015612766573d6000803e3d6000fd5b50506040518792503391507f7e429d711326cac95915db88feaa3038695e458f3a1819539c4bc0440c4114a190600090a35050505050565b60cf546040516331a9108f60e11b81526004810184905283916000916001600160a01b0390911690636352211e9060240160206040518083038186803b1580156127e757600080fd5b505afa1580156127fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061281f9190613fcf565b6001600160a01b0316141561284a57604051632d9e959b60e21b8152600481018290526024016107c4565b6001600160a01b0382166128715760405163d92e233d60e01b815260040160405180910390fd5b600083815260e16020526040808220815160e081019092528054829060ff1660028111156128af57634e487b7160e01b600052602160045260246000fd5b60028111156128ce57634e487b7160e01b600052602160045260246000fd5b815260018201546020808301919091526002830154604080840191909152600384015460608401526004840154608084015260058401546001600160a01b0390811660a0850152600690940154841660c090930192909252600088815260e29091522054919250168061295757604051631b1862a360e21b8152600481018690526024016107c4565b608082015161297c57604051631b1862a360e21b8152600481018690526024016107c4565b60dd546080830151429161298f91614725565b11156129b157604051630e66022360e41b8152600481018690526024016107c4565b60a08201516001600160a01b031633146129dd576040516282b42960e81b815260040160405180910390fd5b600085815260e26020908152604080832080546001600160a01b031990811690915560e19092528220805460ff19168155600181018390556002810183905560038101839055600481019290925560058201805482169055600690910180549091169055612a4c60df8661381f565b5060cf546040516323b872dd60e01b81523060048201526001600160a01b03868116602483015260448201889052909116906323b872dd90606401600060405180830381600087803b158015612aa157600080fd5b505af1158015612ab5573d6000803e3d6000fd5b50506040518792506001600160a01b03841691507fc562af1795c62a4a7f5c911a79cd1a4b2ccfe5f5d013dfc48f8a7add15b09d6d90600090a35050505050565b6060600061121783613863565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff16610ba657612b41816001600160a01b031660146138bf565b612b4c8360206138bf565b604051602001612b5d9291906143a8565b60408051601f198184030181529082905262461bcd60e51b82526107c491600401614599565b6000611217836001600160a01b038416613aae565b6000611217836001600160a01b038416613bcb565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff16610ba65760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612c0b3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6040516001600160a01b038316602482015260448101829052610cc690849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b031990931692909217909152613c1a565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff1615610ba65760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600054610100900460ff16612db55760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016107c4565b565b600054610100900460ff16612e225760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016107c4565b612db5613cff565b610ba68282612bad565b600082815260656020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b60208101516001600160801b03161580612eb2575080600001516001600160801b031681602001516001600160801b0316105b15612ed25780604051639259c66b60e01b81526004016107c491906145cc565b50565b8380612ef45760405163251f56a160e21b815260040160405180910390fd5b612efe60ea6136f2565b8410612f1d57604051632711b74d60e11b815260040160405180910390fd5b6000612f2a60ea86613d71565b60cf549091506001600160a01b0316600080836001600160a01b03166304baa00b6040518163ffffffff1660e01b815260040160206040518083038186803b158015612f7557600080fd5b505afa158015612f89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fad9190614255565b6001811115612fcc57634e487b7160e01b600052602160045260246000fd5b60405163b00425e160e01b8152336004820152911491506000906001600160a01b0385169063b00425e19060240160206040518083038186803b15801561301257600080fd5b505afa158015613026573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061304a9190613fcf565b905060005b858110156132055760008b8b8381811061307957634e487b7160e01b600052603260045260246000fd5b60209081029290920135600081815260e2909352604090922054919250506001600160a01b031633146130be576040516282b42960e81b815260040160405180910390fd5b600081815260e1602052604090206004810154156130f157604051624483ab60e91b8152600481018390526024016107c4565b60068101546001600160a01b03161561312057604051631b1862a360e21b8152600481018390526024016107c4565b8415613144576006810180546001600160a01b0319166001600160a01b0389161790555b6040516323b872dd60e01b81523060048201526001600160a01b038581166024830152604482018490528716906323b872dd90606401600060405180830381600087803b15801561319457600080fd5b505af11580156131a8573d6000803e3d6000fd5b50505050866001600160a01b0316827ffca1cdad9bd2f8cd7cc527480a93b98dc8dc0ea7d9b31a4c45cbea085504e960876040516131ea911515815260200190565b60405180910390a35050806131fe90614816565b905061304f565b506040516334b38b8f60e01b81526001600160a01b038516906334b38b8f9061323a9033908e908e908d908d90600401614429565b600060405180830381600087803b15801561325457600080fd5b505af1158015613268573d6000803e3d6000fd5b505050508161335a5760005b8581101561335857306001600160a01b038516636352211e8d8d858181106132ac57634e487b7160e01b600052603260045260246000fd5b905060200201356040518263ffffffff1660e01b81526004016132d191815260200190565b60206040518083038186803b1580156132e957600080fd5b505afa1580156132fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133219190613fcf565b6001600160a01b03161461334857604051632711b74d60e11b815260040160405180910390fd5b61335181614816565b9050613274565b505b50505050505050505050565b60008060d15442613377919061477c565b90508061338657600091505090565b60d054806133975760009250505090565b60d4546301e13380906001600160801b03600160801b8204811691166133bd848661475d565b6133c7919061475d565b6133d1919061473d565b6133db919061473d565b9250505090565b6000811561340457816133f5848661475d565b6133ff919061473d565b613407565b60005b949350505050565b808061342e5760405163251f56a160e21b815260040160405180910390fd5b60cf546001600160a01b031660005b8281101561103a57600085858381811061346757634e487b7160e01b600052603260045260246000fd5b60209081029290920135600081815260e2909352604090922054919250506001600160a01b031633146134ac576040516282b42960e81b815260040160405180910390fd5b600081815260e16020526040902060068101546001600160a01b0316801561361e57604051636ce5768960e11b8152336004820152306024820152604481018490526001600160a01b0382169063d9caed1290606401600060405180830381600087803b15801561351c57600080fd5b505af1158015613530573d6000803e3d6000fd5b50506040516331a9108f60e11b8152600481018690523092506001600160a01b0388169150636352211e9060240160206040518083038186803b15801561357657600080fd5b505afa15801561358a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135ae9190613fcf565b6001600160a01b0316146135d557604051632711b74d60e11b815260040160405180910390fd5b6006820180546001600160a01b03191690556040516001600160a01b0382169084907f39bb2cce248c9a900b42facd5d0b3ba203e1e8e997476bc41eeb28c11f30b84690600090a35b5050508061362b90614816565b905061343d565b60ca546040516329e463c960e01b81526001600160a01b0384811660048301526024820184905260009216906329e463c9906044015b60206040518083038186803b15801561368057600080fd5b505afa158015613694573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061121791906142fa565b60ca54604051632ebeaa8f60e11b81526001600160a01b038481166004830152602482018490526000921690635d7d551e90604401613668565b6000610781825490565b60008061372460d05460e160008681526020019081526020016000206002015460d3546133e2565b600084815260e160205260409020600101549091508181116112175781613407565b600081815260e26020526040902080546001600160a01b0319166001600160a01b03841617905561377860df82613d7d565b5060cf546040516323b872dd60e01b81526001600160a01b03848116600483015230602483015260448201849052909116906323b872dd90606401600060405180830381600087803b1580156137cd57600080fd5b505af11580156137e1573d6000803e3d6000fd5b50506040518392506001600160a01b03851691507f7033b91d43234ea7f0b72ec01052e5285ce842c91dcf6ab963fa44a54874172090600090a35050565b60006112178383613aae565b6040516001600160a01b03808516602483015283166044820152606481018290526114c79085906323b872dd60e01b90608401612c7b565b6060816000018054806020026020016040519081016040528092919081815260200182805480156138b357602002820191906000526020600020905b81548152602001906001019080831161389f575b50505050509050919050565b606060006138ce83600261475d565b6138d9906002614725565b67ffffffffffffffff8111156138ff57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015613929576020820181803683370190505b509050600360fc1b8160008151811061395257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061398f57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006139b384600261475d565b6139be906001614725565b90505b6001811115613a5f577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110613a0d57634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110613a3157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93613a58816147ff565b90506139c1565b5083156112175760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016107c4565b60008181526001830160205260408120548015613bc1576000613ad260018361477c565b8554909150600090613ae69060019061477c565b9050818114613b67576000866000018281548110613b1457634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080876000018481548110613b4557634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613b8657634e487b7160e01b600052603160045260246000fd5b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610781565b6000915050610781565b6000818152600183016020526040812054613c1257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610781565b506000610781565b6000613c6f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613d899092919063ffffffff16565b805190915015610cc65780806020019051810190613c8d919061415d565b610cc65760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016107c4565b600054610100900460ff16613d6a5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016107c4565b6001609755565b60006112178383613d98565b60006112178383613bcb565b60606134078484600085613dd0565b6000826000018281548110613dbd57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b606082471015613e485760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016107c4565b6001600160a01b0385163b613e9f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107c4565b600080866001600160a01b03168587604051613ebb919061438c565b60006040518083038185875af1925050503d8060008114613ef8576040519150601f19603f3d011682016040523d82523d6000602084013e613efd565b606091505b5091509150613f0d828286613f18565b979650505050505050565b60608315613f27575081611217565b825115613f375782518084602001fd5b8160405162461bcd60e51b81526004016107c49190614599565b60008083601f840112613f62578182fd5b50813567ffffffffffffffff811115613f79578182fd5b6020830191508360208260051b8501011115613f9457600080fd5b9250929050565b60006102808284031215613fad578081fd5b50919050565b600060208284031215613fc4578081fd5b8135611217816148f0565b600060208284031215613fe0578081fd5b8151611217816148f0565b60008060408385031215613ffd578081fd5b8235614008816148f0565b946020939093013593505050565b60008060208385031215614028578182fd5b823567ffffffffffffffff81111561403e578283fd5b61404a85828601613f51565b90969095509350505050565b60008060008060006060868803121561406d578081fd5b853567ffffffffffffffff80821115614084578283fd5b61409089838a01613f51565b90975095506020880135945060408801359150808211156140af578283fd5b818801915088601f8301126140c2578283fd5b8135818111156140d0578384fd5b8960208285010111156140e1578384fd5b9699959850939650602001949392505050565b60008060008060408587031215614109578384fd5b843567ffffffffffffffff80821115614120578586fd5b61412c88838901613f51565b90965094506020870135915080821115614144578384fd5b5061415187828801613f51565b95989497509550505050565b60006020828403121561416e578081fd5b815161121781614905565b60006020828403121561418a578081fd5b5035919050565b600080604083850312156141a3578182fd5b8235915060208301356141b5816148f0565b809150509250929050565b6000602082840312156141d1578081fd5b81356001600160e01b031981168114611217578182fd5b60008060408385031215613ffd578182fd5b6000806000806102e08587031215614210578182fd5b843561421b816148f0565b9350602085013561422b816148f0565b9250604085013561423b816148f0565b915061424a8660608701613f9b565b905092959194509250565b600060208284031215614266578081fd5b815160028110611217578182fd5b600060408284031215614285578081fd5b6040516040810181811067ffffffffffffffff821117156142b457634e487b7160e01b83526041600452602483fd5b60405282356142c281614913565b815260208301356142d281614913565b60208201529392505050565b600061028082840312156142f0578081fd5b6112178383613f9b565b60006020828403121561430b578081fd5b5051919050565b60008060408385031215614324578182fd5b50508035926020909101359150565b600080600060608486031215614347578081fd5b8335925060208401359150604084013561436081614905565b809150509250925092565b60006020828403121561437c578081fd5b813560ff81168114611217578182fd5b6000825161439e818460208701614793565b9190910192915050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516143e0816017850160208801614793565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161441d816028840160208801614793565b01602801949350505050565b6001600160a01b03861681526060602082015283606082015260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff851115614470578081fd5b8460051b808760808501378201828103608090810160408501528101849052838560a08301378160a0858301015260a0601f19601f8601168201019150509695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156144f95783516001600160a01b0316835292840192918401916001016144d4565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156144f957835183529284019291840191600101614521565b60e081016003891061455f57634e487b7160e01b600052602160045260246000fd5b97815260208101969096526040860194909452606085019290925260808401526001600160a01b0390811660a08401521660c09091015290565b60208152600082518060208401526145b8816040850160208701614793565b601f01601f19169190910160400192915050565b60408101610781828480516001600160801b03908116835260209182015116910152565b6102808101614615828e80516001600160801b03908116835260209182015116910152565b8b516001600160801b03908116604084015260209c8d0151811660608401528b51811660808401529a8c01518b1660a083015289518b1660c0830152988b01518a1660e082015287518a16610100820152968a0151891661012088015285518916610140880152948901518816610160870152835188166101808701529288015187166101a0860152815187166101c08601529087015186166101e0850152805186166102008501529095015190931661022082015261024081019390935261026090920152919050565b6000808335601e198436030181126146f6578283fd5b83018035915067ffffffffffffffff821115614710578283fd5b602001915036819003821315613f9457600080fd5b6000821982111561473857614738614831565b500190565b60008261475857634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561477757614777614831565b500290565b60008282101561478e5761478e614831565b500390565b60005b838110156147ae578181015183820152602001614796565b838111156114c75750506000910152565b81356147ca81614913565b6001600160801b03811690506001600160801b0319818184541617835560208401356147f581614913565b60801b1617905550565b60008161480e5761480e614831565b506000190190565b600060001982141561482a5761482a614831565b5060010190565b634e487b7160e01b600052601160045260246000fd5b61485182826147bf565b61486160408301600183016147bf565b61487160808301600283016147bf565b61488160c08301600383016147bf565b6148926101008301600483016147bf565b6148a36101408301600583016147bf565b6148b46101808301600683016147bf565b6148c56101c08301600783016147bf565b6148d66102008301600883016147bf565b6102408201356009820155610260820135600a8201555050565b6001600160a01b0381168114612ed257600080fd5b8015158114612ed257600080fd5b6001600160801b0381168114612ed257600080fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00a2646970667358221220f3538e41cb5460ea1eaba4a3af7823cb5a154cc828c5a54196c0e012ac872ee164736f6c63430008040033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102ad5760003560e01c8063857632c11161017b578063d547741f116100d8578063e9cbd8221161008c578063f8ba4cff11610071578063f8ba4cff1461072d578063f8cd13ad14610735578063fda1fa5f1461074857600080fd5b8063e9cbd82214610707578063f80046751461071a57600080fd5b8063d8aed145116100bd578063d8aed145146105c8578063e06174e4146105db578063e5225381146106ff57600080fd5b8063d547741f146105a2578063d56d229d146105b557600080fd5b8063b3060d361161012f578063b9b2b5cd11610114578063b9b2b5cd1461057d578063bb3be86e14610586578063c8dffa951461059957600080fd5b8063b3060d361461053f578063b49a60bb1461056857600080fd5b806399fbab881161016057806399fbab88146104b6578063a126d60114610524578063a217fddf1461053757600080fd5b8063857632c11461046a57806391d148541461047d57600080fd5b806333f3d628116102295780635fae8b3d116101dd57806364c96f85116101c257806364c96f8514610419578063676e52591461042c5780636c3354041461045757600080fd5b80635fae8b3d146103f35780636423faf41461040657600080fd5b80634284e9de1161020e5780634284e9de146103ba5780634ddfb955146103cd5780634f81650a146103e057600080fd5b806333f3d6281461039457806336568abe146103a757600080fd5b8063175188e811610280578063223e547911610265578063223e54791461033d578063248a9ca3146103505780632f2ff15d1461038157600080fd5b8063175188e814610317578063211a44431461032a57600080fd5b806301ffc9a7146102b25780630f6f2833146102da578063164730d1146102ef5780631698c3bd14610302575b600080fd5b6102c56102c03660046141c0565b610750565b60405190151581526020015b60405180910390f35b6102ed6102e8366004614333565b610787565b005b6102ed6102fd3660046140f4565b6107ef565b61030a610b1b565b6040516102d19190614505565b6102ed610325366004613fb3565b610b2c565b6102c5610338366004614179565b610baa565b6102ed61034b366004613fb3565b610c43565b61037361035e366004614179565b60009081526065602052604090206001015490565b6040519081526020016102d1565b6102ed61038f366004614191565b610ca0565b6102ed6103a23660046141e8565b610ccb565b6102ed6103b5366004614191565b610d50565b6102ed6103c83660046141fa565b610dd8565b6102ed6103db366004614056565b611041565b6103736103ee366004614179565b6110a0565b6102ed610401366004614191565b611103565b6102ed610414366004614016565b611164565b6102ed610427366004614179565b6111b4565b60ce5461043f906001600160a01b031681565b6040516001600160a01b0390911681526020016102d1565b610373610465366004613feb565b61120b565b610373610478366004613feb565b61121e565b6102c561048b366004614191565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6105116104c4366004614179565b60e160205260009081526040902080546001820154600283015460038401546004850154600586015460069096015460ff9095169593949293919290916001600160a01b03908116911687565b6040516102d1979695949392919061453d565b6102ed610532366004614179565b61122a565b610373600081565b61043f61054d366004614179565b60e2602052600090815260409020546001600160a01b031681565b610570611281565b6040516102d191906144b8565b61037360d25481565b60ca5461043f906001600160a01b031681565b61037360d05481565b6102ed6105b0366004614191565b61128d565b60cf5461043f906001600160a01b031681565b6102ed6105d6366004614312565b6112b3565b60408051808201825260d4546001600160801b038082168352600160801b9182900481166020808501919091528451808601865260d55480841682528490048316818301528551808701875260d65480851682528590048416818401528651808801885260d75480861682528690048516818501528751808901895260d85480871682528790048616818601528851808a018a5260d95480881682528890048716818701528951808b018b5260da5480891682528990048816818801528a51808c018c5260db54808a1682528a90048916818901528b51808d01909c5260dc54808a168d5299909904909716958a019590955260dd5460de546106e89a959894979396929592949291908b565b6040516102d19b9a999897969594939291906145f0565b6102ed61130b565b60c95461043f906001600160a01b031681565b6102ed610728366004614191565b6113f9565b6102ed611449565b6102ed6107433660046142de565b61148f565b6103736114cd565b60006001600160e01b03198216637965db0b60e01b148061078157506301ffc9a760e01b6001600160e01b03198316145b92915050565b600260975414156107cd5760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064015b60405180910390fd5b60026097556107da611449565b6107e58383836114d9565b5050600160975550565b600260975414156108305760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b600260975582811461084157600080fd5b6000805b84811015610b0e57600086868381811061086f57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610884919061436b565b905082158015610897575060648160ff16105b156108a9576108a4611449565b600192505b60ff811661090e5760008060008787868181106108d657634e487b7160e01b600052603260045260246000fd5b90506020028101906108e891906146e0565b8101906108f59190614333565b9250925092506109068383836114d9565b505050610afd565b60ff8116600114156109715760008086868581811061093d57634e487b7160e01b600052603260045260246000fd5b905060200281019061094f91906146e0565b81019061095c9190614312565b9150915061096a82826119a5565b5050610afd565b60ff8116600214156109cf57600085858481811061099f57634e487b7160e01b600052603260045260246000fd5b90506020028101906109b191906146e0565b8101906109be9190614179565b90506109c981611c6c565b50610afd565b60ff811660031415610a2b576000808686858181106109fe57634e487b7160e01b600052603260045260246000fd5b9050602002810190610a1091906146e0565b810190610a1d9190614191565b9150915061096a8282611f46565b60ff811660641415610a83576000858584818110610a5957634e487b7160e01b600052603260045260246000fd5b9050602002810190610a6b91906146e0565b810190610a789190614179565b90506109c981612407565b60ff811660651415610adf57600080868685818110610ab257634e487b7160e01b600052603260045260246000fd5b9050602002810190610ac491906146e0565b810190610ad19190614191565b9150915061096a828261279e565b6040516360df9f8760e01b815260ff821660048201526024016107c4565b50610b0781614816565b9050610845565b5050600160975550505050565b6060610b2760df612af6565b905090565b7f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b2603610b578133612b03565b6001600160a01b038216610b7e5760405163d92e233d60e01b815260040160405180910390fd5b610b8960ea83612b83565b610ba657604051632711b74d60e11b815260040160405180910390fd5b5050565b600081815260e16020526040812081815460ff166002811115610bdd57634e487b7160e01b600052602160045260246000fd5b1415610bec5750600092915050565b600481015415610bff5750600092915050565b6001810154600084815260e26020526040902054610c26906001600160a01b03168561121e565b610c2f856110a0565b610c399083614725565b1015949350505050565b7f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b2603610c6e8133612b03565b6001600160a01b038216610c955760405163d92e233d60e01b815260040160405180910390fd5b610b8960ea83612b98565b600082815260656020526040902060010154610cbc8133612b03565b610cc68383612bad565b505050565b60026097541415610d0c5760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b60026097557f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b2603610d3c8133612b03565b6107e56001600160a01b0384163384612c4f565b6001600160a01b0381163314610dce5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084016107c4565b610ba68282612cc7565b600054610100900460ff16610df35760005460ff1615610df7565b303b155b610e695760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016107c4565b600054610100900460ff16158015610e8b576000805461ffff19166101011790555b610e93612d4a565b610e9b612db7565b610ec57f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b260333612e2a565b610f0f7f5e17fc5225d4a099df75359ce1f405503ca79498a8dc46a7d583235a0ee45c167f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b2603612e34565b610f597f61c92169ef077349011ff0b1383c894d86c5f0b41d986366b58a6cf31e93beda7f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b2603612e34565b610f837f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b260380612e34565b610f9a610f9536849003840184614274565b612e7f565b610fb0610f953684900384016101808501614274565b610fc6610f953684900384016101c08501614274565b610fdc610f953684900384016102008501614274565b60c980546001600160a01b038088166001600160a01b03199283161790925560cf805487841690831617905560ca8054928616929091169190911790558160d46110268282614847565b5050801561103a576000805461ff00191690555b5050505050565b600260975414156110825760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b60026097556110948585858585612ed5565b50506001609755505050565b600081815260e1602052604081206001810154600482015483906110e8576110e36110c9613366565b60d0546110d69190614725565b846002015460d3546133e2565b6110ee565b82600301545b9050808211156110fb5750805b039392505050565b600260975414156111445760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b6002609755611151611449565b61115b8282611f46565b50506001609755565b600260975414156111a55760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b600260975561115b828261340f565b600260975414156111f55760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b600260975561120381612407565b506001609755565b60006112178383613632565b9392505050565b600061121783836136b8565b6002609754141561126b5760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b6002609755611278611449565b61120381611c6c565b6060610b2760ea612af6565b6000828152606560205260409020600101546112a98133612b03565b610cc68383612cc7565b600260975414156112f45760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b6002609755611301611449565b61115b82826119a5565b6002609754141561134c5760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b60026097557f3b5d4cc60d3ec3516ee8ae083bd60934f6eb2a6c54b1229985c41bfb092b260361137c8133612b03565b611384611449565b60c95460d2546040516340c10f1960e01b815233600482015260248101919091526001600160a01b03909116906340c10f1990604401600060405180830381600087803b1580156113d457600080fd5b505af11580156113e8573d6000803e3d6000fd5b5050600060d2555050600160975550565b6002609754141561143a5760405162461bcd60e51b815260206004820152601f602482015260008051602061492983398151915260448201526064016107c4565b600260975561115b828261279e565b6000611453613366565b90504260d1819055508060d0600082825461146e9190614725565b925050819055508060d260008282546114879190614725565b909155505050565b7f61c92169ef077349011ff0b1383c894d86c5f0b41d986366b58a6cf31e93beda6114ba8133612b03565b8160d46114c78282614847565b50505050565b6000610b2760df6136f2565b60cf546040516331a9108f60e11b81526004810185905284916000916001600160a01b0390911690636352211e9060240160206040518083038186803b15801561152257600080fd5b505afa158015611536573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155a9190613fcf565b6001600160a01b0316141561158557604051632d9e959b60e21b8152600481018290526024016107c4565b600084815260e260205260409020546001600160a01b03163381148015906115b557506001600160a01b03811615155b156115d2576040516282b42960e81b815260040160405180910390fd5b836115f357604051633728b83d60e01b8152600481018590526024016107c4565b60de5460d054611604908690614725565b111561162357604051633b60212960e01b815260040160405180910390fd5b600085815260e16020526040902060048101541561165657604051624483ab60e91b8152600481018790526024016107c4565b805460ff1660008561166957600161166c565b60025b9050600082600281111561169057634e487b7160e01b600052602160045260246000fd5b14156116cc5782548190849060ff191660018360028111156116c257634e487b7160e01b600052602160045260246000fd5b021790555061172a565b8060028111156116ec57634e487b7160e01b600052602160045260246000fd5b82600281111561170c57634e487b7160e01b600052602160045260246000fd5b1461172a5760405163a46b186960e01b815260040160405180910390fd5b6000611736338a613632565b905060006117438a6136fc565b9050816117508a83614725565b111561177257604051633728b83d60e01b8152600481018a90526024016107c4565b60da546000906001600160801b03600160801b820481169161179591168c61475d565b61179f919061473d565b90508060028560028111156117c457634e487b7160e01b600052602160045260246000fd5b14156118015760db546001600160801b03600160801b82048116916117ea91168d61475d565b6117f4919061473d565b6117fe9082614725565b90505b8060d260008282546118139190614725565b909155505060d354806118315760d38c9055600288018c9055611878565b60d0546000906118418e8461475d565b61184b919061473d565b90506118578183614725565b60d381905550808960020160008282546118719190614725565b9091555050505b8b88600101600082825461188c9190614725565b925050819055508b60d060008282546118a59190614725565b909155505060008d815260e260205260409020546001600160a01b03166118d0576118d0338e613746565b60c960009054906101000a90046001600160a01b03166001600160a01b03166340c10f1933848f611901919061477c565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561194757600080fd5b505af115801561195b573d6000803e3d6000fd5b50506040518e81528f92503391507feae9cfbc77fdd40ca899f36b608256063b2bc9d8178b0220f7ad513e178d67309060200160405180910390a350505050505050505050505050565b60cf546040516331a9108f60e11b81526004810184905283916000916001600160a01b0390911690636352211e9060240160206040518083038186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a269190613fcf565b6001600160a01b03161415611a5157604051632d9e959b60e21b8152600481018290526024016107c4565b600083815260e260205260409020546001600160a01b03163314611a87576040516282b42960e81b815260040160405180910390fd5b81611aa857604051633728b83d60e01b8152600481018390526024016107c4565b600083815260e160205260409020600481015415611adb57604051624483ab60e91b8152600481018590526024016107c4565b6000611ae6856136fc565b905080611b06576040516308d1fde360e11b815260040160405180910390fd5b60018201546000611b17828461477c565b9050828611611b265785611b28565b825b60c95460405163079cc67960e41b8152336004820152602481018390529197506001600160a01b0316906379cc679090604401600060405180830381600087803b158015611b7557600080fd5b505af1158015611b89573d6000803e3d6000fd5b505050506000818711611b9d576000611ba1565b8187035b60d35460d054919250906000858414611bce5781611bbf8b8561475d565b611bc9919061473d565b611bd4565b87600201545b9050611be0818461477c565b60d38190555080886002016000828254611bfa919061477c565b9250508190555083886001016000828254611c15919061477c565b90915550611c2590508a8361477c565b60d0556040518a81528b9033907f1b8cd61ed43bec7c6bdad3a18ffee613f99c853d16c50678d248d879e1b434389060200160405180910390a35050505050505050505050565b60cf546040516331a9108f60e11b81526004810183905282916000916001600160a01b0390911690636352211e9060240160206040518083038186803b158015611cb557600080fd5b505afa158015611cc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ced9190613fcf565b6001600160a01b03161415611d1857604051632d9e959b60e21b8152600481018290526024016107c4565b600082815260e260205260409020546001600160a01b03163314611d4e576040516282b42960e81b815260040160405180910390fd5b600082815260e160205260409020600481015415611d8157604051624483ab60e91b8152600481018490526024016107c4565b6000611d8c846136fc565b90508015611db057604051630314a45960e11b8152600481018290526024016107c4565b600680830154600086815260e26020908152604080832080546001600160a01b031990811690915560e19092528220805460ff19168155600181018390556002810183905560038101839055600481019290925560058201805482169055920180549092169091556001600160a01b0316611e2c60df8661381f565b506001600160a01b038116611eaa5760cf54604051632142170760e11b8152306004820152336024820152604481018790526001600160a01b03909116906342842e0e90606401600060405180830381600087803b158015611e8d57600080fd5b505af1158015611ea1573d6000803e3d6000fd5b50505050611f12565b604051636ce5768960e11b815233600482018190526024820152604481018690526001600160a01b0382169063d9caed1290606401600060405180830381600087803b158015611ef957600080fd5b505af1158015611f0d573d6000803e3d6000fd5b505050505b604051859033907fa9e0cdf27a7965d21573ebb808fbcb2c2a1cfd656e1ecf3f82549437b474067790600090a35050505050565b7f5e17fc5225d4a099df75359ce1f405503ca79498a8dc46a7d583235a0ee45c16611f718133612b03565b60cf546040516331a9108f60e11b81526004810185905284916000916001600160a01b0390911690636352211e9060240160206040518083038186803b158015611fba57600080fd5b505afa158015611fce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ff29190613fcf565b6001600160a01b0316141561201d57604051632d9e959b60e21b8152600481018290526024016107c4565b600084815260e260205260409020546001600160a01b03168061205657604051631b1862a360e21b8152600481018690526024016107c4565b600085815260e16020526040902060048101541561208957604051624483ab60e91b8152600481018790526024016107c4565b6000612094876136fc565b90506120a083886136b8565b8110156120c357604051631b1862a360e21b8152600481018890526024016107c4565b60c95460405163079cc67960e41b8152336004820152602481018390526001600160a01b03909116906379cc679090604401600060405180830381600087803b15801561210f57600080fd5b505af1158015612123573d6000803e3d6000fd5b50505050816002015460d3600082825461213d919061477c565b925050819055508060d06000828254612156919061477c565b90915550506000600280840182905560068401546001600160a01b03169190845460ff16600281111561219957634e487b7160e01b600052602160045260246000fd5b149050801561225257600384018390554260048501556005840180546001600160a01b031916331790556001600160a01b0382161561224d57604051636ce5768960e11b81526001600160a01b038681166004830152306024830152604482018b905283169063d9caed1290606401600060405180830381600087803b15801561222257600080fd5b505af1158015612236573d6000803e3d6000fd5b5050506006850180546001600160a01b0319169055505b6123ac565b600089815260e26020908152604080832080546001600160a01b031990811690915560e19092528220805460ff191681556001810183905560028101839055600381018390556004810192909255600582018054821690556006909101805490911690556122c160df8a61381f565b506001600160a01b0382166123415760cf546040516323b872dd60e01b81523060048201526001600160a01b038a81166024830152604482018c9052909116906323b872dd90606401600060405180830381600087803b15801561232457600080fd5b505af1158015612338573d6000803e3d6000fd5b505050506123ac565b604051636ce5768960e11b81526001600160a01b0386811660048301528981166024830152604482018b905283169063d9caed1290606401600060405180830381600087803b15801561239357600080fd5b505af11580156123a7573d6000803e3d6000fd5b505050505b88856001600160a01b0316336001600160a01b03167f5e22e2eb4089b9fdb1a9fc6b284c2c42fae3b9d2c5182f4db03ef64d0f4891c3846040516123f4911515815260200190565b60405180910390a4505050505050505050565b60cf546040516331a9108f60e11b81526004810183905282916000916001600160a01b0390911690636352211e9060240160206040518083038186803b15801561245057600080fd5b505afa158015612464573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124889190613fcf565b6001600160a01b031614156124b357604051632d9e959b60e21b8152600481018290526024016107c4565b600082815260e16020526040808220815160e081019092528054829060ff1660028111156124f157634e487b7160e01b600052602160045260246000fd5b600281111561251057634e487b7160e01b600052602160045260246000fd5b815260018201546020808301919091526002830154604080840191909152600384015460608401526004840154608084015260058401546001600160a01b0390811660a0850152600690940154841660c090930192909252600087815260e29091522054919250163314612596576040516282b42960e81b815260040160405180910390fd5b60808101516125bb57604051631b1862a360e21b8152600481018490526024016107c4565b6002815160028111156125de57634e487b7160e01b600052602160045260246000fd5b146125ff57604051631b1862a360e21b8152600481018490526024016107c4565b60dd5460808201516126119190614725565b421061263357604051634d4efb5d60e01b8152600481018490526024016107c4565b606081015160dc546000906001600160801b03600160801b820481169161265b91168461475d565b612665919061473d565b600086815260e26020908152604080832080546001600160a01b031990811690915560e19092528220805460ff1916815560018101839055600281018390556003810183905560048101929092556005820180548216905560069091018054909116905590506126d660df8661381f565b50612700338460a0015183856126ec9190614725565b60c9546001600160a01b031692919061382b565b60cf54604051632142170760e11b8152306004820152336024820152604481018790526001600160a01b03909116906342842e0e90606401600060405180830381600087803b15801561275257600080fd5b505af1158015612766573d6000803e3d6000fd5b50506040518792503391507f7e429d711326cac95915db88feaa3038695e458f3a1819539c4bc0440c4114a190600090a35050505050565b60cf546040516331a9108f60e11b81526004810184905283916000916001600160a01b0390911690636352211e9060240160206040518083038186803b1580156127e757600080fd5b505afa1580156127fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061281f9190613fcf565b6001600160a01b0316141561284a57604051632d9e959b60e21b8152600481018290526024016107c4565b6001600160a01b0382166128715760405163d92e233d60e01b815260040160405180910390fd5b600083815260e16020526040808220815160e081019092528054829060ff1660028111156128af57634e487b7160e01b600052602160045260246000fd5b60028111156128ce57634e487b7160e01b600052602160045260246000fd5b815260018201546020808301919091526002830154604080840191909152600384015460608401526004840154608084015260058401546001600160a01b0390811660a0850152600690940154841660c090930192909252600088815260e29091522054919250168061295757604051631b1862a360e21b8152600481018690526024016107c4565b608082015161297c57604051631b1862a360e21b8152600481018690526024016107c4565b60dd546080830151429161298f91614725565b11156129b157604051630e66022360e41b8152600481018690526024016107c4565b60a08201516001600160a01b031633146129dd576040516282b42960e81b815260040160405180910390fd5b600085815260e26020908152604080832080546001600160a01b031990811690915560e19092528220805460ff19168155600181018390556002810183905560038101839055600481019290925560058201805482169055600690910180549091169055612a4c60df8661381f565b5060cf546040516323b872dd60e01b81523060048201526001600160a01b03868116602483015260448201889052909116906323b872dd90606401600060405180830381600087803b158015612aa157600080fd5b505af1158015612ab5573d6000803e3d6000fd5b50506040518792506001600160a01b03841691507fc562af1795c62a4a7f5c911a79cd1a4b2ccfe5f5d013dfc48f8a7add15b09d6d90600090a35050505050565b6060600061121783613863565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff16610ba657612b41816001600160a01b031660146138bf565b612b4c8360206138bf565b604051602001612b5d9291906143a8565b60408051601f198184030181529082905262461bcd60e51b82526107c491600401614599565b6000611217836001600160a01b038416613aae565b6000611217836001600160a01b038416613bcb565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff16610ba65760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612c0b3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6040516001600160a01b038316602482015260448101829052610cc690849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b031990931692909217909152613c1a565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff1615610ba65760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600054610100900460ff16612db55760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016107c4565b565b600054610100900460ff16612e225760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016107c4565b612db5613cff565b610ba68282612bad565b600082815260656020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b60208101516001600160801b03161580612eb2575080600001516001600160801b031681602001516001600160801b0316105b15612ed25780604051639259c66b60e01b81526004016107c491906145cc565b50565b8380612ef45760405163251f56a160e21b815260040160405180910390fd5b612efe60ea6136f2565b8410612f1d57604051632711b74d60e11b815260040160405180910390fd5b6000612f2a60ea86613d71565b60cf549091506001600160a01b0316600080836001600160a01b03166304baa00b6040518163ffffffff1660e01b815260040160206040518083038186803b158015612f7557600080fd5b505afa158015612f89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fad9190614255565b6001811115612fcc57634e487b7160e01b600052602160045260246000fd5b60405163b00425e160e01b8152336004820152911491506000906001600160a01b0385169063b00425e19060240160206040518083038186803b15801561301257600080fd5b505afa158015613026573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061304a9190613fcf565b905060005b858110156132055760008b8b8381811061307957634e487b7160e01b600052603260045260246000fd5b60209081029290920135600081815260e2909352604090922054919250506001600160a01b031633146130be576040516282b42960e81b815260040160405180910390fd5b600081815260e1602052604090206004810154156130f157604051624483ab60e91b8152600481018390526024016107c4565b60068101546001600160a01b03161561312057604051631b1862a360e21b8152600481018390526024016107c4565b8415613144576006810180546001600160a01b0319166001600160a01b0389161790555b6040516323b872dd60e01b81523060048201526001600160a01b038581166024830152604482018490528716906323b872dd90606401600060405180830381600087803b15801561319457600080fd5b505af11580156131a8573d6000803e3d6000fd5b50505050866001600160a01b0316827ffca1cdad9bd2f8cd7cc527480a93b98dc8dc0ea7d9b31a4c45cbea085504e960876040516131ea911515815260200190565b60405180910390a35050806131fe90614816565b905061304f565b506040516334b38b8f60e01b81526001600160a01b038516906334b38b8f9061323a9033908e908e908d908d90600401614429565b600060405180830381600087803b15801561325457600080fd5b505af1158015613268573d6000803e3d6000fd5b505050508161335a5760005b8581101561335857306001600160a01b038516636352211e8d8d858181106132ac57634e487b7160e01b600052603260045260246000fd5b905060200201356040518263ffffffff1660e01b81526004016132d191815260200190565b60206040518083038186803b1580156132e957600080fd5b505afa1580156132fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133219190613fcf565b6001600160a01b03161461334857604051632711b74d60e11b815260040160405180910390fd5b61335181614816565b9050613274565b505b50505050505050505050565b60008060d15442613377919061477c565b90508061338657600091505090565b60d054806133975760009250505090565b60d4546301e13380906001600160801b03600160801b8204811691166133bd848661475d565b6133c7919061475d565b6133d1919061473d565b6133db919061473d565b9250505090565b6000811561340457816133f5848661475d565b6133ff919061473d565b613407565b60005b949350505050565b808061342e5760405163251f56a160e21b815260040160405180910390fd5b60cf546001600160a01b031660005b8281101561103a57600085858381811061346757634e487b7160e01b600052603260045260246000fd5b60209081029290920135600081815260e2909352604090922054919250506001600160a01b031633146134ac576040516282b42960e81b815260040160405180910390fd5b600081815260e16020526040902060068101546001600160a01b0316801561361e57604051636ce5768960e11b8152336004820152306024820152604481018490526001600160a01b0382169063d9caed1290606401600060405180830381600087803b15801561351c57600080fd5b505af1158015613530573d6000803e3d6000fd5b50506040516331a9108f60e11b8152600481018690523092506001600160a01b0388169150636352211e9060240160206040518083038186803b15801561357657600080fd5b505afa15801561358a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135ae9190613fcf565b6001600160a01b0316146135d557604051632711b74d60e11b815260040160405180910390fd5b6006820180546001600160a01b03191690556040516001600160a01b0382169084907f39bb2cce248c9a900b42facd5d0b3ba203e1e8e997476bc41eeb28c11f30b84690600090a35b5050508061362b90614816565b905061343d565b60ca546040516329e463c960e01b81526001600160a01b0384811660048301526024820184905260009216906329e463c9906044015b60206040518083038186803b15801561368057600080fd5b505afa158015613694573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061121791906142fa565b60ca54604051632ebeaa8f60e11b81526001600160a01b038481166004830152602482018490526000921690635d7d551e90604401613668565b6000610781825490565b60008061372460d05460e160008681526020019081526020016000206002015460d3546133e2565b600084815260e160205260409020600101549091508181116112175781613407565b600081815260e26020526040902080546001600160a01b0319166001600160a01b03841617905561377860df82613d7d565b5060cf546040516323b872dd60e01b81526001600160a01b03848116600483015230602483015260448201849052909116906323b872dd90606401600060405180830381600087803b1580156137cd57600080fd5b505af11580156137e1573d6000803e3d6000fd5b50506040518392506001600160a01b03851691507f7033b91d43234ea7f0b72ec01052e5285ce842c91dcf6ab963fa44a54874172090600090a35050565b60006112178383613aae565b6040516001600160a01b03808516602483015283166044820152606481018290526114c79085906323b872dd60e01b90608401612c7b565b6060816000018054806020026020016040519081016040528092919081815260200182805480156138b357602002820191906000526020600020905b81548152602001906001019080831161389f575b50505050509050919050565b606060006138ce83600261475d565b6138d9906002614725565b67ffffffffffffffff8111156138ff57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015613929576020820181803683370190505b509050600360fc1b8160008151811061395257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061398f57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006139b384600261475d565b6139be906001614725565b90505b6001811115613a5f577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110613a0d57634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110613a3157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93613a58816147ff565b90506139c1565b5083156112175760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016107c4565b60008181526001830160205260408120548015613bc1576000613ad260018361477c565b8554909150600090613ae69060019061477c565b9050818114613b67576000866000018281548110613b1457634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080876000018481548110613b4557634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613b8657634e487b7160e01b600052603160045260246000fd5b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610781565b6000915050610781565b6000818152600183016020526040812054613c1257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610781565b506000610781565b6000613c6f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613d899092919063ffffffff16565b805190915015610cc65780806020019051810190613c8d919061415d565b610cc65760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016107c4565b600054610100900460ff16613d6a5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016107c4565b6001609755565b60006112178383613d98565b60006112178383613bcb565b60606134078484600085613dd0565b6000826000018281548110613dbd57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b606082471015613e485760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016107c4565b6001600160a01b0385163b613e9f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107c4565b600080866001600160a01b03168587604051613ebb919061438c565b60006040518083038185875af1925050503d8060008114613ef8576040519150601f19603f3d011682016040523d82523d6000602084013e613efd565b606091505b5091509150613f0d828286613f18565b979650505050505050565b60608315613f27575081611217565b825115613f375782518084602001fd5b8160405162461bcd60e51b81526004016107c49190614599565b60008083601f840112613f62578182fd5b50813567ffffffffffffffff811115613f79578182fd5b6020830191508360208260051b8501011115613f9457600080fd5b9250929050565b60006102808284031215613fad578081fd5b50919050565b600060208284031215613fc4578081fd5b8135611217816148f0565b600060208284031215613fe0578081fd5b8151611217816148f0565b60008060408385031215613ffd578081fd5b8235614008816148f0565b946020939093013593505050565b60008060208385031215614028578182fd5b823567ffffffffffffffff81111561403e578283fd5b61404a85828601613f51565b90969095509350505050565b60008060008060006060868803121561406d578081fd5b853567ffffffffffffffff80821115614084578283fd5b61409089838a01613f51565b90975095506020880135945060408801359150808211156140af578283fd5b818801915088601f8301126140c2578283fd5b8135818111156140d0578384fd5b8960208285010111156140e1578384fd5b9699959850939650602001949392505050565b60008060008060408587031215614109578384fd5b843567ffffffffffffffff80821115614120578586fd5b61412c88838901613f51565b90965094506020870135915080821115614144578384fd5b5061415187828801613f51565b95989497509550505050565b60006020828403121561416e578081fd5b815161121781614905565b60006020828403121561418a578081fd5b5035919050565b600080604083850312156141a3578182fd5b8235915060208301356141b5816148f0565b809150509250929050565b6000602082840312156141d1578081fd5b81356001600160e01b031981168114611217578182fd5b60008060408385031215613ffd578182fd5b6000806000806102e08587031215614210578182fd5b843561421b816148f0565b9350602085013561422b816148f0565b9250604085013561423b816148f0565b915061424a8660608701613f9b565b905092959194509250565b600060208284031215614266578081fd5b815160028110611217578182fd5b600060408284031215614285578081fd5b6040516040810181811067ffffffffffffffff821117156142b457634e487b7160e01b83526041600452602483fd5b60405282356142c281614913565b815260208301356142d281614913565b60208201529392505050565b600061028082840312156142f0578081fd5b6112178383613f9b565b60006020828403121561430b578081fd5b5051919050565b60008060408385031215614324578182fd5b50508035926020909101359150565b600080600060608486031215614347578081fd5b8335925060208401359150604084013561436081614905565b809150509250925092565b60006020828403121561437c578081fd5b813560ff81168114611217578182fd5b6000825161439e818460208701614793565b9190910192915050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516143e0816017850160208801614793565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161441d816028840160208801614793565b01602801949350505050565b6001600160a01b03861681526060602082015283606082015260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff851115614470578081fd5b8460051b808760808501378201828103608090810160408501528101849052838560a08301378160a0858301015260a0601f19601f8601168201019150509695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156144f95783516001600160a01b0316835292840192918401916001016144d4565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156144f957835183529284019291840191600101614521565b60e081016003891061455f57634e487b7160e01b600052602160045260246000fd5b97815260208101969096526040860194909452606085019290925260808401526001600160a01b0390811660a08401521660c09091015290565b60208152600082518060208401526145b8816040850160208701614793565b601f01601f19169190910160400192915050565b60408101610781828480516001600160801b03908116835260209182015116910152565b6102808101614615828e80516001600160801b03908116835260209182015116910152565b8b516001600160801b03908116604084015260209c8d0151811660608401528b51811660808401529a8c01518b1660a083015289518b1660c0830152988b01518a1660e082015287518a16610100820152968a0151891661012088015285518916610140880152948901518816610160870152835188166101808701529288015187166101a0860152815187166101c08601529087015186166101e0850152805186166102008501529095015190931661022082015261024081019390935261026090920152919050565b6000808335601e198436030181126146f6578283fd5b83018035915067ffffffffffffffff821115614710578283fd5b602001915036819003821315613f9457600080fd5b6000821982111561473857614738614831565b500190565b60008261475857634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561477757614777614831565b500290565b60008282101561478e5761478e614831565b500390565b60005b838110156147ae578181015183820152602001614796565b838111156114c75750506000910152565b81356147ca81614913565b6001600160801b03811690506001600160801b0319818184541617835560208401356147f581614913565b60801b1617905550565b60008161480e5761480e614831565b506000190190565b600060001982141561482a5761482a614831565b5060010190565b634e487b7160e01b600052601160045260246000fd5b61485182826147bf565b61486160408301600183016147bf565b61487160808301600283016147bf565b61488160c08301600383016147bf565b6148926101008301600483016147bf565b6148a36101408301600583016147bf565b6148b46101808301600683016147bf565b6148c56101c08301600783016147bf565b6148d66102008301600883016147bf565b6102408201356009820155610260820135600a8201555050565b6001600160a01b0381168114612ed257600080fd5b8015158114612ed257600080fd5b6001600160801b0381168114612ed257600080fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00a2646970667358221220f3538e41cb5460ea1eaba4a3af7823cb5a154cc828c5a54196c0e012ac872ee164736f6c63430008040033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
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.