Address Details
contract

0x81F24e822142216C1A0dEbca17cA952A6C0C1bEb

Contract Name
MicrocreditImplementation
Creator
0xa34737–43edab at 0x927946–32e85d
Balance
0 CELO ( )
Locked CELO Balance
0.00 CELO
Voting CELO Balance
0.00 CELO
Pending Unlocked Gold
0.00 CELO
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
18638644
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
MicrocreditImplementation




Optimization enabled
true
Compiler version
v0.8.4+commit.c7e474f2




Optimization runs
200
EVM Version
istanbul




Verified at
2023-05-22T14:21:29.177093Z

contracts/microcredit/MicrocreditImplementation.sol

//SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.4;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "./interfaces/MicrocreditStorageV1.sol";

contract MicrocreditImplementation is
    Initializable,
    OwnableUpgradeable,
    PausableUpgradeable,
    ReentrancyGuardUpgradeable,
    MicrocreditStorageV1
{
    using SafeERC20Upgradeable for IERC20;
    using EnumerableSet for EnumerableSet.AddressSet;

    event ManagerAdded(address indexed managerAddress);

    event ManagerRemoved(address indexed managerAddress);

    event LoanAdded(
        address indexed userAddress,
        uint256 loanId,
        uint256 amount,
        uint256 period,
        uint256 dailyInterest,
        uint256 claimDeadline
    );

    event LoanCanceled(address indexed userAddress, uint256 loanId);

    event UserAddressChanged(address indexed oldWalletAddress, address indexed newWalletAddress);

    event LoanClaimed(address indexed userAddress, uint256 loanId);

    event RepaymentAdded(
        address indexed userAddress,
        uint256 loanId,
        uint256 repaymentAmount,
        uint256 currentDebt
    );

    /**
    * @notice Triggered when a borrower's manager has been changed
    *
    * @param borrowerAddress   The address of the borrower
    * @param managerAddress    The address of the new manager
    */
    event ManagerChanged(
        address indexed borrowerAddress,
        address indexed managerAddress
    );

    modifier onlyManagers() {
        require(_managerList.contains(msg.sender), "Microcredit: caller is not a manager");
        _;
    }

    /**
     * @notice Used to initialize the Microcredit contract
     *
     * @param _cUSDAddress      The address of the cUSD token
     * @param _revenueAddress   The address that collects all the interest
     */
    function initialize(address _cUSDAddress, address _revenueAddress) public initializer {
        __Ownable_init();
        __Pausable_init();
        __ReentrancyGuard_init();

        cUSD = IERC20(_cUSDAddress);
        revenueAddress = _revenueAddress;
    }

    /**
     * @notice Returns the current implementation version
     */
    function getVersion() external pure override returns (uint256) {
        return 1;
    }

    /**
     * @notice Returns the information of a user
     *
     * @param _userAddress           address of the user
     * @return userId                the userId
     * @return movedTo               the number of the user's loans
     * @return loansLength           the number of the user's loans
     */
    function walletMetadata(address _userAddress)
        external
        view
        override
        returns (
            uint256 userId,
            address movedTo,
            uint256 loansLength
        )
    {
        WalletMetadata memory _metadata = _walletMetadata[_userAddress];

        userId = _metadata.userId;
        movedTo = _metadata.movedTo;
        loansLength = _users[_metadata.userId].loans.length;
    }

    /**
     * @notice Returns the length of the walletList
     */
    function walletListLength() external view override returns (uint256) {
        return _walletList.length();
    }

    /**
     * @notice Returns an address from the walletList
     *
     * @param _index index value
     * @return address of the user
     */
    function walletListAt(uint256 _index) external view override returns (address) {
        return _walletList.at(_index);
    }

    /**
     * @notice Returns an address from the managerList
     *
     * @param _index index value
     * @return address of the manager
     */
    function managerListAt(uint256 _index) external view override returns (address) {
        return _managerList.at(_index);
    }

    /**
     * @notice Returns the length of the managerList
     */
    function managerListLength() external view override returns (uint256) {
        return _managerList.length();
    }

    function userLoans(address _userAddress, uint256 _loanId)
        external
        view
        override
        returns (
            uint256 amountBorrowed,
            uint256 period,
            uint256 dailyInterest,
            uint256 claimDeadline,
            uint256 startDate,
            uint256 currentDebt,
            uint256 lastComputedDebt,
            uint256 amountRepayed,
            uint256 repaymentsLength,
            uint256 lastComputedDate
        )
    {
        _checkUserLoan(_userAddress, _loanId);

        WalletMetadata memory _metadata = _walletMetadata[_userAddress];
        User memory _user = _users[_metadata.userId];
        Loan memory _loan = _user.loans[_loanId];

        amountBorrowed = _loan.amountBorrowed;
        period = _loan.period;
        dailyInterest = _loan.dailyInterest;
        claimDeadline = _loan.claimDeadline;
        startDate = _loan.startDate;
        lastComputedDebt = _loan.lastComputedDebt;
        currentDebt = _calculateCurrentDebt(_loan);
        amountRepayed = _loan.amountRepayed;
        repaymentsLength = _loan.repayments.length;
        lastComputedDate = _loan.lastComputedDate;
    }

    function userLoanRepayments(
        address _userAddress,
        uint256 _loanId,
        uint256 _repaymentId
    ) external view override returns (uint256 date, uint256 amount) {
        _checkUserLoan(_userAddress, _loanId);

        WalletMetadata memory _metadata = _walletMetadata[_userAddress];
        User memory _user = _users[_metadata.userId];
        Loan memory _loan = _user.loans[_loanId];

        require(_loan.repayments.length > _repaymentId, "Microcredit: Repayment doesn't exist");

        date = _loan.repayments[_repaymentId].date;
        amount = _loan.repayments[_repaymentId].amount;
    }

    function updateRevenueAddress(address _newRevenueAddress) external override onlyOwner {
        revenueAddress = _newRevenueAddress;
    }

    /**
     * @notice Adds managers
     *
     * @param _managerAddresses      addresses of the managers
     */
    function addManagers(address[] calldata _managerAddresses) external override onlyOwner {
        uint256 _length = _managerAddresses.length;
        uint256 _index;

        for (_index = 0; _index < _length; _index++) {
            _managerList.add(_managerAddresses[_index]);
            emit ManagerAdded(_managerAddresses[_index]);
        }
    }

    /**
     * @notice Removes managers
     *
     * @param _managerAddresses     addresses of the managers
     */
    function removeManagers(address[] calldata _managerAddresses) external override onlyOwner {
        uint256 _length = _managerAddresses.length;
        uint256 _index;

        for (_index = 0; _index < _length; _index++) {
            _managerList.remove(_managerAddresses[_index]);
            emit ManagerRemoved(_managerAddresses[_index]);
        }
    }

    /**
     * @notice Adds a loan
     *
     * @param _userAddress           address of the user
     * @param _amount                amount of the loan
     * @param _period                period of the loan
     * @param _dailyInterest         daily interest of the loan
     * @param _claimDeadline         claim deadline of the loan
     */
    function addLoan(
        address _userAddress,
        uint256 _amount,
        uint256 _period,
        uint256 _dailyInterest,
        uint256 _claimDeadline
    ) external override onlyManagers {
        _addLoan(_userAddress, _amount, _period, _dailyInterest, _claimDeadline);
    }

    /**
     * @notice Adds multiples loans
     *
     * @param _userAddresses          addresses of the user
     * @param _amounts                amounts of the loan
     * @param _periods                periods of the loan
     * @param _dailyInterests         daily interests of the loan
     * @param _claimDeadlines         claim deadlines of the loan
     */
    function addLoans(
        address[] calldata _userAddresses,
        uint256[] calldata _amounts,
        uint256[] calldata _periods,
        uint256[] calldata _dailyInterests,
        uint256[] calldata _claimDeadlines
    ) external override onlyManagers {
        uint256 _loansNumber = _userAddresses.length;
        require(
            _loansNumber == _amounts.length,
            "Microcredit: calldata information arity mismatch"
        );
        require(
            _loansNumber == _periods.length,
            "Microcredit: calldata information arity mismatch"
        );
        require(
            _loansNumber == _dailyInterests.length,
            "Microcredit: calldata information arity mismatch"
        );
        require(
            _loansNumber == _claimDeadlines.length,
            "Microcredit: calldata information arity mismatch"
        );

        uint256 _index;

        for (_index = 0; _index < _loansNumber; _index++) {
            _addLoan(
                _userAddresses[_index],
                _amounts[_index],
                _periods[_index],
                _dailyInterests[_index],
                _claimDeadlines[_index]
            );
        }
    }

    /**
     * @notice Cancel a loan
     *
     * @param _userAddresses    User addresses
     * @param _loansIds Loan ids
     */
    function cancelLoans(address[] calldata _userAddresses, uint256[] calldata _loansIds)
        external
        override
        onlyManagers
    {
        require(
            _userAddresses.length == _loansIds.length,
            "Microcredit: calldata information arity mismatch"
        );

        uint256 _index;

        for (_index = 0; _index < _userAddresses.length; _index++) {
            _cancelLoan(_userAddresses[_index], _loansIds[_index]);
        }
    }

    /**
     * @notice Change user address
     *
     * @param _oldWalletAddress Old wallet address
     * @param _newWalletAddress New wallet address
     */
    function changeUserAddress(address _oldWalletAddress, address _newWalletAddress)
        external
        override
        onlyManagers
    {
        WalletMetadata storage _oldWalletMetadata = _walletMetadata[_oldWalletAddress];
        require(
            _oldWalletMetadata.userId > 0 && _oldWalletMetadata.movedTo == address(0),
            "Microcredit: This user cannot be moved"
        );

        WalletMetadata storage _newWalletMetadata = _walletMetadata[_newWalletAddress];
        require(_newWalletMetadata.userId == 0, "Microcredit: Target wallet address is invalid");

        _oldWalletMetadata.movedTo = _newWalletAddress;
        _newWalletMetadata.userId = _oldWalletMetadata.userId;

        _walletList.add(_newWalletAddress);

        emit UserAddressChanged(_oldWalletAddress, _newWalletAddress);
    }

    /**
     * @notice Claim a loan
     *
     * @param _loanId Loan ID
     */
    function claimLoan(uint256 _loanId) external override nonReentrant {
        _checkUserLoan(msg.sender, _loanId);

        WalletMetadata memory _metadata = _walletMetadata[msg.sender];
        User storage _user = _users[_metadata.userId];
        Loan storage _loan = _user.loans[_loanId];

        require(_loan.startDate == 0, "Microcredit: Loan already claimed");
        require(_loan.claimDeadline != 0, "Microcredit: Loan canceled");
        require(_loan.claimDeadline >= block.timestamp, "Microcredit: Loan expired");

        _loan.startDate = block.timestamp;

        _loan.lastComputedDebt = (_loan.amountBorrowed * (1e18 + _loan.dailyInterest / 100)) / 1e18;
        _loan.lastComputedDate = block.timestamp;

        cUSD.safeTransfer(msg.sender, _loan.amountBorrowed);

        emit LoanClaimed(msg.sender, _loanId);
    }

    /**
    * @notice Repay a loan
    *
    * @param _loanId Loan ID
    * @param _repaymentAmount Repayment amount
    */
    function repayLoan(uint256 _loanId, uint256 _repaymentAmount) external override nonReentrant {
        require(_repaymentAmount > 0, "Microcredit: Invalid amount");

        _checkUserLoan(msg.sender, _loanId);

        WalletMetadata memory _metadata = _walletMetadata[msg.sender];
        User storage _user = _users[_metadata.userId];
        Loan storage _loan = _user.loans[_loanId];

        require(_loan.startDate > 0, "Microcredit: Loan not claimed");
        require(_loan.lastComputedDebt > 0, "Microcredit: Loan has already been fully repayed");

        uint256 _currentDebt = _calculateCurrentDebt(_loan);

        if (_currentDebt < _repaymentAmount) {
            _repaymentAmount = _currentDebt;
        }

        uint256 _revenueAmount;
        uint256 _loanAmount;

        if (
            _loan.amountRepayed + _repaymentAmount <= _loan.amountBorrowed ||
            revenueAddress == address(0)
        ) {
            //all repaymentAmount should go to microcredit address
            cUSD.safeTransferFrom(msg.sender, address(this), _repaymentAmount);
        } else if (_loan.amountRepayed >= _loan.amountBorrowed) {
            //all repaymentAmount should go to revenue address
            cUSD.safeTransferFrom(msg.sender, revenueAddress, _repaymentAmount);
        } else {
            //a part of the repayment should go to microcredit address and the rest should go to the revenue address
            uint256 _loanDiff = _loan.amountBorrowed - _loan.amountRepayed;
            cUSD.safeTransferFrom(msg.sender, address(this), _loanDiff);
            cUSD.safeTransferFrom(msg.sender, revenueAddress, _repaymentAmount - _loanDiff);
        }

        Repayment storage _repayment = _loan.repayments.push();
        _repayment.date = block.timestamp;
        _repayment.amount = _repaymentAmount;

        _loan.lastComputedDebt = _currentDebt - _repaymentAmount;
        _loan.amountRepayed += _repaymentAmount;

        uint256 _days = (block.timestamp - _loan.lastComputedDate) / 86400; //86400 = 1 day in seconds

        _loan.lastComputedDate = _loan.lastComputedDate + _days * 86400;

        emit RepaymentAdded(msg.sender, _loanId, _repaymentAmount, _loan.lastComputedDebt);
    }

    /**
     * @notice Changes the borrowers manager address
     * @dev This method doesn't change anything on the contract state, it just emits events to be used by the off-chain system
     *
     * @param _borrowerAddresses address of the borrowers
     * @param _managerAddress address of the new manager
     */
    function changeManager(address[] memory _borrowerAddresses, address _managerAddress) external override onlyManagers {
        uint256 _index;
        require(_managerList.contains(_managerAddress), "Microcredit: invalid manager address");

        for(_index = 0; _index < _borrowerAddresses.length; _index++) {
            require(_walletList.contains(_borrowerAddresses[_index]), "Microcredit: invalid borrower address");
            emit ManagerChanged(_borrowerAddresses[_index], _managerAddress);
        }
    }

    /**
     * @notice Transfers an amount of an ERC20 from this contract to an address
     *
     * @param _token address of the ERC20 token
     * @param _to address of the receiver
     * @param _amount amount of the transaction
     */
    function transferERC20(
        IERC20 _token,
        address _to,
        uint256 _amount
    ) external override nonReentrant onlyOwner {
        _token.safeTransfer(_to, _amount);
    }

    function _checkUserLoan(address _userAddress, uint256 _loanId) internal view {
        WalletMetadata memory _metadata = _walletMetadata[_userAddress];

        require(
            _metadata.userId > 0 && _metadata.movedTo == address(0),
            "Microcredit: Invalid wallet address"
        );

        User memory _user = _users[_metadata.userId];

        require(_user.loans.length > _loanId, "Microcredit: Loan doesn't exist");
    }

    function _calculateCurrentDebt(Loan memory _loan) internal view returns (uint256) {
        if (_loan.lastComputedDebt == 0) {
            return 0;
        }

        uint256 _days = (block.timestamp - _loan.lastComputedDate) / 86400; //86400 = 1 day in seconds

        uint256 _currentDebt = _loan.lastComputedDebt;

        while (_days > 0) {
            _currentDebt = (_currentDebt * (1e18 + _loan.dailyInterest / 100)) / 1e18;
            _days--;
        }

        return _currentDebt;
    }

    function _addLoan(
        address _userAddress,
        uint256 _amount,
        uint256 _period,
        uint256 _dailyInterest,
        uint256 _claimDeadline
    ) internal {
        require(_claimDeadline > block.timestamp, "Microcredit: invalid claimDeadline");

        WalletMetadata storage _metadata = _walletMetadata[_userAddress];
        require(_metadata.movedTo == address(0), "Microcredit: The user has been moved");

        if (_metadata.userId == 0) {
            _usersLength++;
            _metadata.userId = _usersLength;
            _walletList.add(_userAddress);
        }

        User storage _user = _users[_metadata.userId];

        uint256 _loansLength = _user.loans.length;

        if (_loansLength > 0) {
            Loan memory _previousLoan = _user.loans[_loansLength - 1];
            require(
                (_previousLoan.startDate > 0 && _previousLoan.lastComputedDebt == 0) || // loan claimed and fully paid
                    (_previousLoan.startDate == 0 &&
                        _previousLoan.claimDeadline < block.timestamp) || //loan unclaimed and expired
                    (_previousLoan.claimDeadline == 0), //loan canceled
                "Microcredit: The user already has an active loan"
            );
        }

        Loan storage _loan = _user.loans.push();

        _loan.amountBorrowed = _amount;
        _loan.period = _period;
        _loan.dailyInterest = _dailyInterest;
        _loan.claimDeadline = _claimDeadline;

        emit LoanAdded(
            _userAddress,
            _user.loans.length - 1,
            _amount,
            _period,
            _dailyInterest,
            _claimDeadline
        );
    }

    function _cancelLoan(address _userAddress, uint256 _loanId) internal {
        _checkUserLoan(_userAddress, _loanId);

        WalletMetadata memory _metadata = _walletMetadata[_userAddress];
        User storage _user = _users[_metadata.userId];
        Loan storage _loan = _user.loans[_loanId];

        require(_loan.startDate == 0, "Microcredit: Loan already claimed");
        require(_loan.claimDeadline != 0, "Microcredit: Loan already canceled");

        _loan.claimDeadline = 0; //set claimDeadline to 0 to prevent claiming (cancel the loan)

        emit LoanCanceled(_userAddress, _loanId);
    }
}
        

/_openzeppelin/contracts/utils/structs/EnumerableSet.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 EnumerableSet {
    // 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;
    }
}
          

/_openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
    uint256[49] private __gap;
}
          

/_openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 a proxied contract can't have 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));
    }
}
          

/_openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Context_init_unchained();
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
    uint256[49] private __gap;
}
          

/_openzeppelin/contracts-upgradeable/security/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;
    }
    uint256[49] private __gap;
}
          

/_openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, 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 `sender` to `recipient` 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 sender,
        address recipient,
        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);
}
          

/_openzeppelin/contracts-upgradeable/token/ERC20/utils/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");
        }
    }
}
          

/_openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol

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

pragma solidity ^0.8.0;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 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);
            }
        }
    }
}
          

/_openzeppelin/contracts-upgradeable/utils/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 {
        __Context_init_unchained();
    }

    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;
    }
    uint256[50] private __gap;
}
          

/contracts/microcredit/interfaces/IMicrocredit.sol

//SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.4;

import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";

interface IMicrocredit {
    struct WalletMetadata {
        uint256 userId;
        address movedTo;
    }

    struct User {
        Loan[] loans;
    }

    struct Repayment {
        uint256 date;
        uint256 amount;
    }

    struct Loan {
        uint256 amountBorrowed;
        uint256 period;                   // the number of seconds after a loan should be fully repaid
        uint256 dailyInterest;
        uint256 claimDeadline;
        uint256 startDate;                // the timestamp the user claimed the amountBorrowed
        uint256 lastComputedDebt;
        uint256 amountRepayed;
        Repayment[] repayments;
        uint256 lastComputedDate;
    }

    function getVersion() external pure returns(uint256);
    function cUSD() external view returns(IERC20);
    function revenueAddress() external view returns(address);
    function walletMetadata(address userAddress)
        external view returns(uint256 userId, address movedTo, uint256 loansLength);
    function userLoans(address userAddress, uint256 loanId) external view returns(
        uint256 amountBorrowed,
        uint256 period,
        uint256 dailyInterest,
        uint256 claimDeadline,
        uint256 startDate,
        uint256 lastComputedDebt,
        uint256 currentDebt,
        uint256 amountRepayed,
        uint256 repaymentsLength,
        uint256 lastComputedDate
    );
    function userLoanRepayments(address userAddress, uint256 loanId, uint256 repaymentId)
        external view returns( uint256 date, uint256 amount);
    function walletListAt(uint256 index) external view returns (address);
    function walletListLength() external view returns (uint256);
    function managerListAt(uint256 index) external view returns (address);
    function managerListLength() external view returns (uint256);
    function updateRevenueAddress(address newRevenueAddress) external;
    function addManagers(address[] calldata managerAddresses) external;
    function removeManagers(address[] calldata managerAddresses) external;
    function addLoan(
        address userAddress,
        uint256 amount,
        uint256 period,
        uint256 dailyInterest,
        uint256 claimDeadline
    ) external;
    function addLoans(
        address[] calldata userAddresses,
        uint256[] calldata amounts,
        uint256[] calldata periods,
        uint256[] calldata dailyInterests,
        uint256[] calldata claimDeadlines
    ) external;
    function cancelLoans(
        address[] calldata userAddresses,
        uint256[] calldata loansIds
    ) external;
    function changeUserAddress(address oldWalletAddress, address newWalletAddress) external;
    function claimLoan(uint256 loanId) external;
    function repayLoan(uint256 loanId, uint256 repaymentAmount) external;
    function changeManager(address[] memory borrowerAddresses, address managerAddress) external;
    function transferERC20(IERC20 _token, address _to, uint256 _amount) external;
}
          

/contracts/microcredit/interfaces/MicrocreditStorageV1.sol

// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.4;

import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "./IMicrocredit.sol";

/**
 * @title Storage for Microcredit
 * @notice For future upgrades, do not change MicrocreditStorageV1. Create a new
 * contract which implements MicrocreditStorageV1 and following the naming convention
 * MicrocreditStorageVx.
 */
abstract contract MicrocreditStorageV1 is IMicrocredit {
    IERC20 public override cUSD;

    uint256 internal  _usersLength;
    mapping(uint256 => User) internal _users;

    mapping(address => WalletMetadata) internal _walletMetadata;
    EnumerableSet.AddressSet internal _walletList;

    EnumerableSet.AddressSet internal _managerList;
    address public override revenueAddress;
}
          

Contract ABI

[{"type":"event","name":"LoanAdded","inputs":[{"type":"address","name":"userAddress","internalType":"address","indexed":true},{"type":"uint256","name":"loanId","internalType":"uint256","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"period","internalType":"uint256","indexed":false},{"type":"uint256","name":"dailyInterest","internalType":"uint256","indexed":false},{"type":"uint256","name":"claimDeadline","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"LoanCanceled","inputs":[{"type":"address","name":"userAddress","internalType":"address","indexed":true},{"type":"uint256","name":"loanId","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"LoanClaimed","inputs":[{"type":"address","name":"userAddress","internalType":"address","indexed":true},{"type":"uint256","name":"loanId","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ManagerAdded","inputs":[{"type":"address","name":"managerAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"ManagerChanged","inputs":[{"type":"address","name":"borrowerAddress","internalType":"address","indexed":true},{"type":"address","name":"managerAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"ManagerRemoved","inputs":[{"type":"address","name":"managerAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"RepaymentAdded","inputs":[{"type":"address","name":"userAddress","internalType":"address","indexed":true},{"type":"uint256","name":"loanId","internalType":"uint256","indexed":false},{"type":"uint256","name":"repaymentAmount","internalType":"uint256","indexed":false},{"type":"uint256","name":"currentDebt","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"UserAddressChanged","inputs":[{"type":"address","name":"oldWalletAddress","internalType":"address","indexed":true},{"type":"address","name":"newWalletAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addLoan","inputs":[{"type":"address","name":"_userAddress","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"uint256","name":"_period","internalType":"uint256"},{"type":"uint256","name":"_dailyInterest","internalType":"uint256"},{"type":"uint256","name":"_claimDeadline","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addLoans","inputs":[{"type":"address[]","name":"_userAddresses","internalType":"address[]"},{"type":"uint256[]","name":"_amounts","internalType":"uint256[]"},{"type":"uint256[]","name":"_periods","internalType":"uint256[]"},{"type":"uint256[]","name":"_dailyInterests","internalType":"uint256[]"},{"type":"uint256[]","name":"_claimDeadlines","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addManagers","inputs":[{"type":"address[]","name":"_managerAddresses","internalType":"address[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20Upgradeable"}],"name":"cUSD","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"cancelLoans","inputs":[{"type":"address[]","name":"_userAddresses","internalType":"address[]"},{"type":"uint256[]","name":"_loansIds","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"changeManager","inputs":[{"type":"address[]","name":"_borrowerAddresses","internalType":"address[]"},{"type":"address","name":"_managerAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"changeUserAddress","inputs":[{"type":"address","name":"_oldWalletAddress","internalType":"address"},{"type":"address","name":"_newWalletAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimLoan","inputs":[{"type":"uint256","name":"_loanId","internalType":"uint256"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getVersion","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_cUSDAddress","internalType":"address"},{"type":"address","name":"_revenueAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"managerListAt","inputs":[{"type":"uint256","name":"_index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"managerListLength","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeManagers","inputs":[{"type":"address[]","name":"_managerAddresses","internalType":"address[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"repayLoan","inputs":[{"type":"uint256","name":"_loanId","internalType":"uint256"},{"type":"uint256","name":"_repaymentAmount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"revenueAddress","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferERC20","inputs":[{"type":"address","name":"_token","internalType":"contract IERC20Upgradeable"},{"type":"address","name":"_to","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateRevenueAddress","inputs":[{"type":"address","name":"_newRevenueAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"date","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"}],"name":"userLoanRepayments","inputs":[{"type":"address","name":"_userAddress","internalType":"address"},{"type":"uint256","name":"_loanId","internalType":"uint256"},{"type":"uint256","name":"_repaymentId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"amountBorrowed","internalType":"uint256"},{"type":"uint256","name":"period","internalType":"uint256"},{"type":"uint256","name":"dailyInterest","internalType":"uint256"},{"type":"uint256","name":"claimDeadline","internalType":"uint256"},{"type":"uint256","name":"startDate","internalType":"uint256"},{"type":"uint256","name":"currentDebt","internalType":"uint256"},{"type":"uint256","name":"lastComputedDebt","internalType":"uint256"},{"type":"uint256","name":"amountRepayed","internalType":"uint256"},{"type":"uint256","name":"repaymentsLength","internalType":"uint256"},{"type":"uint256","name":"lastComputedDate","internalType":"uint256"}],"name":"userLoans","inputs":[{"type":"address","name":"_userAddress","internalType":"address"},{"type":"uint256","name":"_loanId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"walletListAt","inputs":[{"type":"uint256","name":"_index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"walletListLength","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"userId","internalType":"uint256"},{"type":"address","name":"movedTo","internalType":"address"},{"type":"uint256","name":"loansLength","internalType":"uint256"}],"name":"walletMetadata","inputs":[{"type":"address","name":"_userAddress","internalType":"address"}]}]
              

Contract Creation Code

0x608060405234801561001057600080fd5b50612f72806100206000396000f3fe608060405234801561001057600080fd5b506004361061018e5760003560e01c806378d5bcc1116100de5780639db5dbe411610097578063d8bad5bd11610071578063d8bad5bd146103ac578063eef1b51514610409578063f2fde38b1461041c578063fdd288591461042f57600080fd5b80639db5dbe414610373578063adb9712614610386578063b410908d1461039957600080fd5b806378d5bcc1146102ee57806380407735146103165780638a700b53146103295780638c5f9e741461033c5780638da5cb5b1461034f5780639a9cb9711461036057600080fd5b806353a469b31161014b57806360c4477a1161012557806360c4477a146102535780636323f5e91461025b57806368fcaf84146102d3578063715018a6146102e657600080fd5b806353a469b3146102175780635c975abb1461022a5780635d916afd1461024057600080fd5b80630d8e6e2c1461019357806310f3ee29146101a95780631fccf672146101be578063387d0263146101e95780633a17596b146101f1578063485cc95514610204575b600080fd5b60015b6040519081526020015b60405180910390f35b6101bc6101b736600461294e565b610442565b005b60c9546101d1906001600160a01b031681565b6040516001600160a01b0390911681526020016101a0565b610196610544565b6101bc6101ff36600461290b565b610555565b6101bc610212366004612874565b610590565b6101bc610225366004612c1b565b610693565b60655460ff1660405190151581526020016101a0565b6101bc61024e3660046129f7565b6108af565b610196610a57565b6102b0610269366004612858565b6001600160a01b03908116600090815260cc6020908152604080832081518083018352815480825260019092015490951694830185905280845260cb909252909120549092565b604080519384526001600160a01b039092166020840152908201526060016101a0565b6101d16102e1366004612c1b565b610a63565b6101bc610a76565b6103016102fc3660046128d7565b610aac565b604080519283526020830191909152016101a0565b6101bc61032436600461298e565b610d16565b6101bc610337366004612c33565b610ddd565b6101bc61034a36600461294e565b611241565b6033546001600160a01b03166101d1565b6101bc61036e366004612ae2565b611334565b6101bc610381366004612bdb565b6114db565b6101d1610394366004612c1b565b61154b565b60d1546101d1906001600160a01b031681565b6103bf6103ba3660046128ac565b611558565b604080519a8b5260208b0199909952978901969096526060880194909452608087019290925260a086015260c085015260e0840152610100830152610120820152610140016101a0565b6101bc610417366004612874565b61175d565b6101bc61042a366004612858565b611902565b6101bc61043d366004612858565b61199d565b6033546001600160a01b031633146104755760405162461bcd60e51b815260040161046c90612d78565b60405180910390fd5b8060005b8181101561053e576104c18484838181106104a457634e487b7160e01b600052603260045260246000fd5b90506020020160208101906104b99190612858565b60cf906119e9565b508383828181106104e257634e487b7160e01b600052603260045260246000fd5b90506020020160208101906104f79190612858565b6001600160a01b03167fef69f7d97228658c92417be1b16b19058315de71fecb435d07b7d23728b6bd3160405160405180910390a28061053681612ee0565b915050610479565b50505050565b600061055060cf611a05565b905090565b61056060cf33611a0f565b61057c5760405162461bcd60e51b815260040161046c90612ca3565b6105898585858585611a31565b5050505050565b600054610100900460ff166105ab5760005460ff16156105af565b303b155b6106125760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161046c565b600054610100900460ff16158015610634576000805461ffff19166101011790555b61063c611d9c565b610644611dd3565b61064c611e0a565b60c980546001600160a01b038086166001600160a01b03199283161790925560d1805492851692909116919091179055801561068e576000805461ff00191690555b505050565b600260975414156106b65760405162461bcd60e51b815260040161046c90612df8565b60026097556106c53382611e39565b33600090815260cc602090815260408083208151808301835281548082526001909201546001600160a01b03168185015290845260cb909252822080549192909182908590811061072657634e487b7160e01b600052603260045260246000fd5b90600052602060002090600902019050806004015460001461075a5760405162461bcd60e51b815260040161046c90612d37565b60038101546107ab5760405162461bcd60e51b815260206004820152601a60248201527f4d6963726f6372656469743a204c6f616e2063616e63656c6564000000000000604482015260640161046c565b42816003015410156107ff5760405162461bcd60e51b815260206004820152601960248201527f4d6963726f6372656469743a204c6f616e206578706972656400000000000000604482015260640161046c565b4260048201556002810154670de0b6b3a76400009061082090606490612e47565b61083290670de0b6b3a7640000612e2f565b825461083e9190612e67565b6108489190612e47565b6005820155426008820155805460c95461086f916001600160a01b03909116903390612066565b60405184815233907fba0cbe8ef8ef3c6984adc684d0c9b9a4d2d4c79b4678b63c38651fa48d21c62c9060200160405180910390a2505060016097555050565b6108ba60cf33611a0f565b6108d65760405162461bcd60e51b815260040161046c90612ca3565b888781146108f65760405162461bcd60e51b815260040161046c90612ce7565b8086146109155760405162461bcd60e51b815260040161046c90612ce7565b8084146109345760405162461bcd60e51b815260040161046c90612ce7565b8082146109535760405162461bcd60e51b815260040161046c90612ce7565b60005b81811015610a4957610a378c8c8381811061098157634e487b7160e01b600052603260045260246000fd5b90506020020160208101906109969190612858565b8b8b848181106109b657634e487b7160e01b600052603260045260246000fd5b905060200201358a8a858181106109dd57634e487b7160e01b600052603260045260246000fd5b90506020020135898986818110610a0457634e487b7160e01b600052603260045260246000fd5b90506020020135888887818110610a2b57634e487b7160e01b600052603260045260246000fd5b90506020020135611a31565b80610a4181612ee0565b915050610956565b505050505050505050505050565b600061055060cd611a05565b6000610a7060cf836120c9565b92915050565b6033546001600160a01b03163314610aa05760405162461bcd60e51b815260040161046c90612d78565b610aaa60006120d5565b565b600080610ab98585611e39565b6001600160a01b03808616600090815260cc6020908152604080832081518083018352815480825260019092015490951685840152835260cb8252808320815181548085028201840184529381018481529093919284928491879085015b82821015610c0d5783829060005260206000209060090201604051806101200160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201548152602001600582015481526020016006820154815260200160078201805480602002602001604051908101604052809291908181526020016000905b82821015610bec57838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190610ba6565b50505050815260200160088201548152505081526020019060010190610b17565b50505050815250509050600081600001518781518110610c3d57634e487b7160e01b600052603260045260246000fd5b60200260200101519050858160e001515111610ca75760405162461bcd60e51b8152602060048201526024808201527f4d6963726f6372656469743a2052657061796d656e7420646f65736e277420656044820152631e1a5cdd60e21b606482015260840161046c565b8060e001518681518110610ccb57634e487b7160e01b600052603260045260246000fd5b60200260200101516000015194508060e001518681518110610cfd57634e487b7160e01b600052603260045260246000fd5b6020026020010151602001519350505050935093915050565b610d2160cf33611a0f565b610d3d5760405162461bcd60e51b815260040161046c90612ca3565b828114610d5c5760405162461bcd60e51b815260040161046c90612ce7565b60005b8381101561058957610dcb858583818110610d8a57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610d9f9190612858565b848484818110610dbf57634e487b7160e01b600052603260045260246000fd5b90506020020135612127565b80610dd581612ee0565b915050610d5f565b60026097541415610e005760405162461bcd60e51b815260040161046c90612df8565b600260975580610e525760405162461bcd60e51b815260206004820152601b60248201527f4d6963726f6372656469743a20496e76616c696420616d6f756e740000000000604482015260640161046c565b610e5c3383611e39565b33600090815260cc602090815260408083208151808301835281548082526001909201546001600160a01b03168185015290845260cb9092528220805491929091829086908110610ebd57634e487b7160e01b600052603260045260246000fd5b906000526020600020906009020190506000816004015411610f215760405162461bcd60e51b815260206004820152601d60248201527f4d6963726f6372656469743a204c6f616e206e6f7420636c61696d6564000000604482015260640161046c565b6000816005015411610f8e5760405162461bcd60e51b815260206004820152603060248201527f4d6963726f6372656469743a204c6f616e2068617320616c726561647920626560448201526f195b88199d5b1b1e481c995c185e595960821b606482015260840161046c565b600061106882604051806101200160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201548152602001600582015481526020016006820154815260200160078201805480602002602001604051908101604052809291908181526020016000905b828210156110515783829060005260206000209060020201604051806040016040529081600082015481526020016001820154815250508152602001906001019061100b565b505050508152602001600882015481525050612270565b905084811015611076578094505b600080836000015487856006015461108e9190612e2f565b1115806110a4575060d1546001600160a01b0316155b156110c65760c9546110c1906001600160a01b031633308a61230b565b611151565b83546006850154106110f15760d15460c9546110c1916001600160a01b03918216913391168a61230b565b6006840154845460009161110491612e86565b60c95490915061111f906001600160a01b031633308461230b565b60d15461114f9033906001600160a01b031661113b848c612e86565b60c9546001600160a01b031692919061230b565b505b6007840180546001818101835560009283526020909220426002909202019081559081018890556111828885612e86565b85600501819055508785600601600082825461119e9190612e2f565b9091555050600885015460009062015180906111ba9042612e86565b6111c49190612e47565b90506111d38162015180612e67565b86600801546111e29190612e2f565b60088701556005860154604080518c8152602081018c90529081019190915233907f36bd188317b9b3af98bbc5bfd88a0bccb96582fa2c955815ea9916dfeeb02d9e9060600160405180910390a2505060016097555050505050505050565b6033546001600160a01b0316331461126b5760405162461bcd60e51b815260040161046c90612d78565b8060005b8181101561053e576112b784848381811061129a57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906112af9190612858565b60cf90612343565b508383828181106112d857634e487b7160e01b600052603260045260246000fd5b90506020020160208101906112ed9190612858565b6001600160a01b03167f3b4a40cccf2058c593542587329dd385be4f0b588db5471fbd9598e56dd7093a60405160405180910390a28061132c81612ee0565b91505061126f565b61133f60cf33611a0f565b61135b5760405162461bcd60e51b815260040161046c90612ca3565b600061136860cf83611a0f565b6113c05760405162461bcd60e51b8152602060048201526024808201527f4d6963726f6372656469743a20696e76616c6964206d616e61676572206164646044820152637265737360e01b606482015260840161046c565b5060005b825181101561068e576114088382815181106113f057634e487b7160e01b600052603260045260246000fd5b602002602001015160cd611a0f90919063ffffffff16565b6114625760405162461bcd60e51b815260206004820152602560248201527f4d6963726f6372656469743a20696e76616c696420626f72726f776572206164604482015264647265737360d81b606482015260840161046c565b816001600160a01b031683828151811061148c57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03167f605c2dbf762e5f7d60a546d42e7205dcb1b011ebc62a61736a57c9089d3a435060405160405180910390a3806114d381612ee0565b9150506113c4565b600260975414156114fe5760405162461bcd60e51b815260040161046c90612df8565b60026097556033546001600160a01b0316331461152d5760405162461bcd60e51b815260040161046c90612d78565b6115416001600160a01b0384168383612066565b5050600160975550565b6000610a7060cd836120c9565b6000806000806000806000806000806115718c8c611e39565b6001600160a01b03808d16600090815260cc6020908152604080832081518083018352815480825260019092015490951685840152835260cb8252808320815181548085028201840184529381018481529093919284928491879085015b828210156116c55783829060005260206000209060090201604051806101200160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201548152602001600582015481526020016006820154815260200160078201805480602002602001604051908101604052809291908181526020016000905b828210156116a45783829060005260206000209060020201604051806040016040529081600082015481526020016001820154815250508152602001906001019061165e565b505050508152602001600882015481525050815260200190600101906115cf565b50505050815250509050600081600001518e815181106116f557634e487b7160e01b600052603260045260246000fd5b6020026020010151905080600001519c5080602001519b5080604001519a5080606001519950806080015198508060a00151965061173281612270565b97508060c0015195508060e0015151945080610100015193505050509295989b9194979a5092959850565b61176860cf33611a0f565b6117845760405162461bcd60e51b815260040161046c90612ca3565b6001600160a01b038216600090815260cc602052604090208054158015906117b7575060018101546001600160a01b0316155b6118125760405162461bcd60e51b815260206004820152602660248201527f4d6963726f6372656469743a205468697320757365722063616e6e6f74206265604482015265081b5bdd995960d21b606482015260840161046c565b6001600160a01b038216600090815260cc6020526040902080541561188f5760405162461bcd60e51b815260206004820152602d60248201527f4d6963726f6372656469743a205461726765742077616c6c657420616464726560448201526c1cdcc81a5cc81a5b9d985b1a59609a1b606482015260840161046c565b6001820180546001600160a01b0319166001600160a01b038516179055815481556118bb60cd84612343565b50826001600160a01b0316846001600160a01b03167ffe697da51e9b8089b3ac92361b06886b93f48f935848aa4da1148c15b262840a60405160405180910390a350505050565b6033546001600160a01b0316331461192c5760405162461bcd60e51b815260040161046c90612d78565b6001600160a01b0381166119915760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161046c565b61199a816120d5565b50565b6033546001600160a01b031633146119c75760405162461bcd60e51b815260040161046c90612d78565b60d180546001600160a01b0319166001600160a01b0392909216919091179055565b60006119fe836001600160a01b038416612358565b9392505050565b6000610a70825490565b6001600160a01b038116600090815260018301602052604081205415156119fe565b428111611a8b5760405162461bcd60e51b815260206004820152602260248201527f4d6963726f6372656469743a20696e76616c696420636c61696d446561646c696044820152616e6560f01b606482015260840161046c565b6001600160a01b03808616600090815260cc60205260409020600181015490911615611b055760405162461bcd60e51b8152602060048201526024808201527f4d6963726f6372656469743a20546865207573657220686173206265656e206d6044820152631bdd995960e21b606482015260840161046c565b8054611b325760ca8054906000611b1b83612ee0565b909155505060ca548155611b3060cd87612343565b505b8054600090815260cb6020526040902080548015611cfa57600082611b58600184612e86565b81548110611b7657634e487b7160e01b600052603260045260246000fd5b9060005260206000209060090201604051806101200160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201548152602001600582015481526020016006820154815260200160078201805480602002602001604051908101604052809291908181526020016000905b82821015611c4157838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190611bfb565b505050508152602001600882015481525050905060008160800151118015611c6b575060a0810151155b80611c8657506080810151158015611c865750428160600151105b80611c9357506060810151155b611cf85760405162461bcd60e51b815260206004820152603060248201527f4d6963726f6372656469743a20546865207573657220616c726561647920686160448201526f399030b71030b1ba34bb32903637b0b760811b606482015260840161046c565b505b81546001818101845560008481526020902060099092029091018881558082018890556002810187905560038101869055835490916001600160a01b038b16917fdf5f35c1edc69bc65031bb54e429851779e0db0a2d5f763a0eabdd9bec9429f291611d6591612e86565b60408051918252602082018c905281018a9052606081018990526080810188905260a00160405180910390a2505050505050505050565b600054610100900460ff16611dc35760405162461bcd60e51b815260040161046c90612dad565b611dcb612475565b610aaa61249c565b600054610100900460ff16611dfa5760405162461bcd60e51b815260040161046c90612dad565b611e02612475565b610aaa6124cc565b600054610100900460ff16611e315760405162461bcd60e51b815260040161046c90612dad565b610aaa6124ff565b6001600160a01b03808316600090815260cc602090815260409182902082518084019093528054808452600190910154909316908201529015801590611e8a575060208101516001600160a01b0316155b611ee25760405162461bcd60e51b815260206004820152602360248201527f4d6963726f6372656469743a20496e76616c69642077616c6c6574206164647260448201526265737360e81b606482015260840161046c565b8051600090815260cb60209081526040808320815181548085028201840184529381018481529093919284928491879085015b8282101561200b5783829060005260206000209060090201604051806101200160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201548152602001600582015481526020016006820154815260200160078201805480602002602001604051908101604052809291908181526020016000905b82821015611fea57838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190611fa4565b50505050815260200160088201548152505081526020019060010190611f15565b50505091525050805151909150831061053e5760405162461bcd60e51b815260206004820152601f60248201527f4d6963726f6372656469743a204c6f616e20646f65736e277420657869737400604482015260640161046c565b6040516001600160a01b03831660248201526044810182905261068e90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261252d565b60006119fe83836125ff565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6121318282611e39565b6001600160a01b03808316600090815260cc6020908152604080832081518083018352815480825260019092015490951685840152835260cb9091528120805490919082908590811061219457634e487b7160e01b600052603260045260246000fd5b9060005260206000209060090201905080600401546000146121c85760405162461bcd60e51b815260040161046c90612d37565b60038101546122245760405162461bcd60e51b815260206004820152602260248201527f4d6963726f6372656469743a204c6f616e20616c72656164792063616e63656c604482015261195960f21b606482015260840161046c565b600060038201556040518481526001600160a01b038616907f2f0f5933c0b9b1d9fee69327e7789ce07ef1be486122748fc2a079742067a8089060200160405180910390a25050505050565b60008160a001516000141561228757506000919050565b6000620151808361010001514261229e9190612e86565b6122a89190612e47565b60a08401519091505b81156119fe57670de0b6b3a7640000606485604001516122d19190612e47565b6122e390670de0b6b3a7640000612e2f565b6122ed9083612e67565b6122f79190612e47565b90508161230381612ec9565b9250506122b1565b6040516001600160a01b038085166024830152831660448201526064810182905261053e9085906323b872dd60e01b90608401612092565b60006119fe836001600160a01b038416612637565b6000818152600183016020526040812054801561246b57600061237c600183612e86565b855490915060009061239090600190612e86565b90508181146124115760008660000182815481106123be57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050808760000184815481106123ef57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b855486908061243057634e487b7160e01b600052603160045260246000fd5b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610a70565b6000915050610a70565b600054610100900460ff16610aaa5760405162461bcd60e51b815260040161046c90612dad565b600054610100900460ff166124c35760405162461bcd60e51b815260040161046c90612dad565b610aaa336120d5565b600054610100900460ff166124f35760405162461bcd60e51b815260040161046c90612dad565b6065805460ff19169055565b600054610100900460ff166125265760405162461bcd60e51b815260040161046c90612dad565b6001609755565b6000612582826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166126869092919063ffffffff16565b80519091501561068e57808060200190518101906125a09190612bbb565b61068e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161046c565b600082600001828154811061262457634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b600081815260018301602052604081205461267e57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a70565b506000610a70565b6060612695848460008561269d565b949350505050565b6060824710156126fe5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161046c565b843b61274c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161046c565b600080866001600160a01b031685876040516127689190612c54565b60006040518083038185875af1925050503d80600081146127a5576040519150601f19603f3d011682016040523d82523d6000602084013e6127aa565b606091505b50915091506127ba8282866127c5565b979650505050505050565b606083156127d45750816119fe565b8251156127e45782518084602001fd5b8160405162461bcd60e51b815260040161046c9190612c70565b803561280981612f27565b919050565b60008083601f84011261281f578081fd5b50813567ffffffffffffffff811115612836578182fd5b6020830191508360208260051b850101111561285157600080fd5b9250929050565b600060208284031215612869578081fd5b81356119fe81612f27565b60008060408385031215612886578081fd5b823561289181612f27565b915060208301356128a181612f27565b809150509250929050565b600080604083850312156128be578182fd5b82356128c981612f27565b946020939093013593505050565b6000806000606084860312156128eb578081fd5b83356128f681612f27565b95602085013595506040909401359392505050565b600080600080600060a08688031215612922578081fd5b853561292d81612f27565b97602087013597506040870135966060810135965060800135945092505050565b60008060208385031215612960578182fd5b823567ffffffffffffffff811115612976578283fd5b6129828582860161280e565b90969095509350505050565b600080600080604085870312156129a3578384fd5b843567ffffffffffffffff808211156129ba578586fd5b6129c68883890161280e565b909650945060208701359150808211156129de578384fd5b506129eb8782880161280e565b95989497509550505050565b60008060008060008060008060008060a08b8d031215612a15578485fd5b8a3567ffffffffffffffff80821115612a2c578687fd5b612a388e838f0161280e565b909c509a5060208d0135915080821115612a50578687fd5b612a5c8e838f0161280e565b909a50985060408d0135915080821115612a74578687fd5b612a808e838f0161280e565b909850965060608d0135915080821115612a98578586fd5b612aa48e838f0161280e565b909650945060808d0135915080821115612abc578384fd5b50612ac98d828e0161280e565b915080935050809150509295989b9194979a5092959850565b60008060408385031215612af4578182fd5b823567ffffffffffffffff80821115612b0b578384fd5b818501915085601f830112612b1e578384fd5b8135602082821115612b3257612b32612f11565b8160051b604051601f19603f83011681018181108682111715612b5757612b57612f11565b604052838152828101945085830182870184018b1015612b75578889fd5b8896505b84871015612b9e57612b8a816127fe565b865260019690960195948301948301612b79565b509650612bae90508782016127fe565b9450505050509250929050565b600060208284031215612bcc578081fd5b815180151581146119fe578182fd5b600080600060608486031215612bef578283fd5b8335612bfa81612f27565b92506020840135612c0a81612f27565b929592945050506040919091013590565b600060208284031215612c2c578081fd5b5035919050565b60008060408385031215612c45578182fd5b50508035926020909101359150565b60008251612c66818460208701612e9d565b9190910192915050565b6020815260008251806020840152612c8f816040850160208701612e9d565b601f01601f19169190910160400192915050565b60208082526024908201527f4d6963726f6372656469743a2063616c6c6572206973206e6f742061206d616e60408201526330b3b2b960e11b606082015260800190565b60208082526030908201527f4d6963726f6372656469743a2063616c6c6461746120696e666f726d6174696f60408201526f0dc40c2e4d2e8f240dad2e6dac2e8c6d60831b606082015260800190565b60208082526021908201527f4d6963726f6372656469743a204c6f616e20616c726561647920636c61696d656040820152601960fa1b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115612e4257612e42612efb565b500190565b600082612e6257634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615612e8157612e81612efb565b500290565b600082821015612e9857612e98612efb565b500390565b60005b83811015612eb8578181015183820152602001612ea0565b8381111561053e5750506000910152565b600081612ed857612ed8612efb565b506000190190565b6000600019821415612ef457612ef4612efb565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461199a57600080fdfea26469706673582212209acbae80b61d32352f0cf583f598d5f02f8166009cdd6bac133bd46d7afa537564736f6c63430008040033

Deployed ByteCode

0x608060405234801561001057600080fd5b506004361061018e5760003560e01c806378d5bcc1116100de5780639db5dbe411610097578063d8bad5bd11610071578063d8bad5bd146103ac578063eef1b51514610409578063f2fde38b1461041c578063fdd288591461042f57600080fd5b80639db5dbe414610373578063adb9712614610386578063b410908d1461039957600080fd5b806378d5bcc1146102ee57806380407735146103165780638a700b53146103295780638c5f9e741461033c5780638da5cb5b1461034f5780639a9cb9711461036057600080fd5b806353a469b31161014b57806360c4477a1161012557806360c4477a146102535780636323f5e91461025b57806368fcaf84146102d3578063715018a6146102e657600080fd5b806353a469b3146102175780635c975abb1461022a5780635d916afd1461024057600080fd5b80630d8e6e2c1461019357806310f3ee29146101a95780631fccf672146101be578063387d0263146101e95780633a17596b146101f1578063485cc95514610204575b600080fd5b60015b6040519081526020015b60405180910390f35b6101bc6101b736600461294e565b610442565b005b60c9546101d1906001600160a01b031681565b6040516001600160a01b0390911681526020016101a0565b610196610544565b6101bc6101ff36600461290b565b610555565b6101bc610212366004612874565b610590565b6101bc610225366004612c1b565b610693565b60655460ff1660405190151581526020016101a0565b6101bc61024e3660046129f7565b6108af565b610196610a57565b6102b0610269366004612858565b6001600160a01b03908116600090815260cc6020908152604080832081518083018352815480825260019092015490951694830185905280845260cb909252909120549092565b604080519384526001600160a01b039092166020840152908201526060016101a0565b6101d16102e1366004612c1b565b610a63565b6101bc610a76565b6103016102fc3660046128d7565b610aac565b604080519283526020830191909152016101a0565b6101bc61032436600461298e565b610d16565b6101bc610337366004612c33565b610ddd565b6101bc61034a36600461294e565b611241565b6033546001600160a01b03166101d1565b6101bc61036e366004612ae2565b611334565b6101bc610381366004612bdb565b6114db565b6101d1610394366004612c1b565b61154b565b60d1546101d1906001600160a01b031681565b6103bf6103ba3660046128ac565b611558565b604080519a8b5260208b0199909952978901969096526060880194909452608087019290925260a086015260c085015260e0840152610100830152610120820152610140016101a0565b6101bc610417366004612874565b61175d565b6101bc61042a366004612858565b611902565b6101bc61043d366004612858565b61199d565b6033546001600160a01b031633146104755760405162461bcd60e51b815260040161046c90612d78565b60405180910390fd5b8060005b8181101561053e576104c18484838181106104a457634e487b7160e01b600052603260045260246000fd5b90506020020160208101906104b99190612858565b60cf906119e9565b508383828181106104e257634e487b7160e01b600052603260045260246000fd5b90506020020160208101906104f79190612858565b6001600160a01b03167fef69f7d97228658c92417be1b16b19058315de71fecb435d07b7d23728b6bd3160405160405180910390a28061053681612ee0565b915050610479565b50505050565b600061055060cf611a05565b905090565b61056060cf33611a0f565b61057c5760405162461bcd60e51b815260040161046c90612ca3565b6105898585858585611a31565b5050505050565b600054610100900460ff166105ab5760005460ff16156105af565b303b155b6106125760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161046c565b600054610100900460ff16158015610634576000805461ffff19166101011790555b61063c611d9c565b610644611dd3565b61064c611e0a565b60c980546001600160a01b038086166001600160a01b03199283161790925560d1805492851692909116919091179055801561068e576000805461ff00191690555b505050565b600260975414156106b65760405162461bcd60e51b815260040161046c90612df8565b60026097556106c53382611e39565b33600090815260cc602090815260408083208151808301835281548082526001909201546001600160a01b03168185015290845260cb909252822080549192909182908590811061072657634e487b7160e01b600052603260045260246000fd5b90600052602060002090600902019050806004015460001461075a5760405162461bcd60e51b815260040161046c90612d37565b60038101546107ab5760405162461bcd60e51b815260206004820152601a60248201527f4d6963726f6372656469743a204c6f616e2063616e63656c6564000000000000604482015260640161046c565b42816003015410156107ff5760405162461bcd60e51b815260206004820152601960248201527f4d6963726f6372656469743a204c6f616e206578706972656400000000000000604482015260640161046c565b4260048201556002810154670de0b6b3a76400009061082090606490612e47565b61083290670de0b6b3a7640000612e2f565b825461083e9190612e67565b6108489190612e47565b6005820155426008820155805460c95461086f916001600160a01b03909116903390612066565b60405184815233907fba0cbe8ef8ef3c6984adc684d0c9b9a4d2d4c79b4678b63c38651fa48d21c62c9060200160405180910390a2505060016097555050565b6108ba60cf33611a0f565b6108d65760405162461bcd60e51b815260040161046c90612ca3565b888781146108f65760405162461bcd60e51b815260040161046c90612ce7565b8086146109155760405162461bcd60e51b815260040161046c90612ce7565b8084146109345760405162461bcd60e51b815260040161046c90612ce7565b8082146109535760405162461bcd60e51b815260040161046c90612ce7565b60005b81811015610a4957610a378c8c8381811061098157634e487b7160e01b600052603260045260246000fd5b90506020020160208101906109969190612858565b8b8b848181106109b657634e487b7160e01b600052603260045260246000fd5b905060200201358a8a858181106109dd57634e487b7160e01b600052603260045260246000fd5b90506020020135898986818110610a0457634e487b7160e01b600052603260045260246000fd5b90506020020135888887818110610a2b57634e487b7160e01b600052603260045260246000fd5b90506020020135611a31565b80610a4181612ee0565b915050610956565b505050505050505050505050565b600061055060cd611a05565b6000610a7060cf836120c9565b92915050565b6033546001600160a01b03163314610aa05760405162461bcd60e51b815260040161046c90612d78565b610aaa60006120d5565b565b600080610ab98585611e39565b6001600160a01b03808616600090815260cc6020908152604080832081518083018352815480825260019092015490951685840152835260cb8252808320815181548085028201840184529381018481529093919284928491879085015b82821015610c0d5783829060005260206000209060090201604051806101200160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201548152602001600582015481526020016006820154815260200160078201805480602002602001604051908101604052809291908181526020016000905b82821015610bec57838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190610ba6565b50505050815260200160088201548152505081526020019060010190610b17565b50505050815250509050600081600001518781518110610c3d57634e487b7160e01b600052603260045260246000fd5b60200260200101519050858160e001515111610ca75760405162461bcd60e51b8152602060048201526024808201527f4d6963726f6372656469743a2052657061796d656e7420646f65736e277420656044820152631e1a5cdd60e21b606482015260840161046c565b8060e001518681518110610ccb57634e487b7160e01b600052603260045260246000fd5b60200260200101516000015194508060e001518681518110610cfd57634e487b7160e01b600052603260045260246000fd5b6020026020010151602001519350505050935093915050565b610d2160cf33611a0f565b610d3d5760405162461bcd60e51b815260040161046c90612ca3565b828114610d5c5760405162461bcd60e51b815260040161046c90612ce7565b60005b8381101561058957610dcb858583818110610d8a57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610d9f9190612858565b848484818110610dbf57634e487b7160e01b600052603260045260246000fd5b90506020020135612127565b80610dd581612ee0565b915050610d5f565b60026097541415610e005760405162461bcd60e51b815260040161046c90612df8565b600260975580610e525760405162461bcd60e51b815260206004820152601b60248201527f4d6963726f6372656469743a20496e76616c696420616d6f756e740000000000604482015260640161046c565b610e5c3383611e39565b33600090815260cc602090815260408083208151808301835281548082526001909201546001600160a01b03168185015290845260cb9092528220805491929091829086908110610ebd57634e487b7160e01b600052603260045260246000fd5b906000526020600020906009020190506000816004015411610f215760405162461bcd60e51b815260206004820152601d60248201527f4d6963726f6372656469743a204c6f616e206e6f7420636c61696d6564000000604482015260640161046c565b6000816005015411610f8e5760405162461bcd60e51b815260206004820152603060248201527f4d6963726f6372656469743a204c6f616e2068617320616c726561647920626560448201526f195b88199d5b1b1e481c995c185e595960821b606482015260840161046c565b600061106882604051806101200160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201548152602001600582015481526020016006820154815260200160078201805480602002602001604051908101604052809291908181526020016000905b828210156110515783829060005260206000209060020201604051806040016040529081600082015481526020016001820154815250508152602001906001019061100b565b505050508152602001600882015481525050612270565b905084811015611076578094505b600080836000015487856006015461108e9190612e2f565b1115806110a4575060d1546001600160a01b0316155b156110c65760c9546110c1906001600160a01b031633308a61230b565b611151565b83546006850154106110f15760d15460c9546110c1916001600160a01b03918216913391168a61230b565b6006840154845460009161110491612e86565b60c95490915061111f906001600160a01b031633308461230b565b60d15461114f9033906001600160a01b031661113b848c612e86565b60c9546001600160a01b031692919061230b565b505b6007840180546001818101835560009283526020909220426002909202019081559081018890556111828885612e86565b85600501819055508785600601600082825461119e9190612e2f565b9091555050600885015460009062015180906111ba9042612e86565b6111c49190612e47565b90506111d38162015180612e67565b86600801546111e29190612e2f565b60088701556005860154604080518c8152602081018c90529081019190915233907f36bd188317b9b3af98bbc5bfd88a0bccb96582fa2c955815ea9916dfeeb02d9e9060600160405180910390a2505060016097555050505050505050565b6033546001600160a01b0316331461126b5760405162461bcd60e51b815260040161046c90612d78565b8060005b8181101561053e576112b784848381811061129a57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906112af9190612858565b60cf90612343565b508383828181106112d857634e487b7160e01b600052603260045260246000fd5b90506020020160208101906112ed9190612858565b6001600160a01b03167f3b4a40cccf2058c593542587329dd385be4f0b588db5471fbd9598e56dd7093a60405160405180910390a28061132c81612ee0565b91505061126f565b61133f60cf33611a0f565b61135b5760405162461bcd60e51b815260040161046c90612ca3565b600061136860cf83611a0f565b6113c05760405162461bcd60e51b8152602060048201526024808201527f4d6963726f6372656469743a20696e76616c6964206d616e61676572206164646044820152637265737360e01b606482015260840161046c565b5060005b825181101561068e576114088382815181106113f057634e487b7160e01b600052603260045260246000fd5b602002602001015160cd611a0f90919063ffffffff16565b6114625760405162461bcd60e51b815260206004820152602560248201527f4d6963726f6372656469743a20696e76616c696420626f72726f776572206164604482015264647265737360d81b606482015260840161046c565b816001600160a01b031683828151811061148c57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03167f605c2dbf762e5f7d60a546d42e7205dcb1b011ebc62a61736a57c9089d3a435060405160405180910390a3806114d381612ee0565b9150506113c4565b600260975414156114fe5760405162461bcd60e51b815260040161046c90612df8565b60026097556033546001600160a01b0316331461152d5760405162461bcd60e51b815260040161046c90612d78565b6115416001600160a01b0384168383612066565b5050600160975550565b6000610a7060cd836120c9565b6000806000806000806000806000806115718c8c611e39565b6001600160a01b03808d16600090815260cc6020908152604080832081518083018352815480825260019092015490951685840152835260cb8252808320815181548085028201840184529381018481529093919284928491879085015b828210156116c55783829060005260206000209060090201604051806101200160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201548152602001600582015481526020016006820154815260200160078201805480602002602001604051908101604052809291908181526020016000905b828210156116a45783829060005260206000209060020201604051806040016040529081600082015481526020016001820154815250508152602001906001019061165e565b505050508152602001600882015481525050815260200190600101906115cf565b50505050815250509050600081600001518e815181106116f557634e487b7160e01b600052603260045260246000fd5b6020026020010151905080600001519c5080602001519b5080604001519a5080606001519950806080015198508060a00151965061173281612270565b97508060c0015195508060e0015151945080610100015193505050509295989b9194979a5092959850565b61176860cf33611a0f565b6117845760405162461bcd60e51b815260040161046c90612ca3565b6001600160a01b038216600090815260cc602052604090208054158015906117b7575060018101546001600160a01b0316155b6118125760405162461bcd60e51b815260206004820152602660248201527f4d6963726f6372656469743a205468697320757365722063616e6e6f74206265604482015265081b5bdd995960d21b606482015260840161046c565b6001600160a01b038216600090815260cc6020526040902080541561188f5760405162461bcd60e51b815260206004820152602d60248201527f4d6963726f6372656469743a205461726765742077616c6c657420616464726560448201526c1cdcc81a5cc81a5b9d985b1a59609a1b606482015260840161046c565b6001820180546001600160a01b0319166001600160a01b038516179055815481556118bb60cd84612343565b50826001600160a01b0316846001600160a01b03167ffe697da51e9b8089b3ac92361b06886b93f48f935848aa4da1148c15b262840a60405160405180910390a350505050565b6033546001600160a01b0316331461192c5760405162461bcd60e51b815260040161046c90612d78565b6001600160a01b0381166119915760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161046c565b61199a816120d5565b50565b6033546001600160a01b031633146119c75760405162461bcd60e51b815260040161046c90612d78565b60d180546001600160a01b0319166001600160a01b0392909216919091179055565b60006119fe836001600160a01b038416612358565b9392505050565b6000610a70825490565b6001600160a01b038116600090815260018301602052604081205415156119fe565b428111611a8b5760405162461bcd60e51b815260206004820152602260248201527f4d6963726f6372656469743a20696e76616c696420636c61696d446561646c696044820152616e6560f01b606482015260840161046c565b6001600160a01b03808616600090815260cc60205260409020600181015490911615611b055760405162461bcd60e51b8152602060048201526024808201527f4d6963726f6372656469743a20546865207573657220686173206265656e206d6044820152631bdd995960e21b606482015260840161046c565b8054611b325760ca8054906000611b1b83612ee0565b909155505060ca548155611b3060cd87612343565b505b8054600090815260cb6020526040902080548015611cfa57600082611b58600184612e86565b81548110611b7657634e487b7160e01b600052603260045260246000fd5b9060005260206000209060090201604051806101200160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201548152602001600582015481526020016006820154815260200160078201805480602002602001604051908101604052809291908181526020016000905b82821015611c4157838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190611bfb565b505050508152602001600882015481525050905060008160800151118015611c6b575060a0810151155b80611c8657506080810151158015611c865750428160600151105b80611c9357506060810151155b611cf85760405162461bcd60e51b815260206004820152603060248201527f4d6963726f6372656469743a20546865207573657220616c726561647920686160448201526f399030b71030b1ba34bb32903637b0b760811b606482015260840161046c565b505b81546001818101845560008481526020902060099092029091018881558082018890556002810187905560038101869055835490916001600160a01b038b16917fdf5f35c1edc69bc65031bb54e429851779e0db0a2d5f763a0eabdd9bec9429f291611d6591612e86565b60408051918252602082018c905281018a9052606081018990526080810188905260a00160405180910390a2505050505050505050565b600054610100900460ff16611dc35760405162461bcd60e51b815260040161046c90612dad565b611dcb612475565b610aaa61249c565b600054610100900460ff16611dfa5760405162461bcd60e51b815260040161046c90612dad565b611e02612475565b610aaa6124cc565b600054610100900460ff16611e315760405162461bcd60e51b815260040161046c90612dad565b610aaa6124ff565b6001600160a01b03808316600090815260cc602090815260409182902082518084019093528054808452600190910154909316908201529015801590611e8a575060208101516001600160a01b0316155b611ee25760405162461bcd60e51b815260206004820152602360248201527f4d6963726f6372656469743a20496e76616c69642077616c6c6574206164647260448201526265737360e81b606482015260840161046c565b8051600090815260cb60209081526040808320815181548085028201840184529381018481529093919284928491879085015b8282101561200b5783829060005260206000209060090201604051806101200160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201548152602001600582015481526020016006820154815260200160078201805480602002602001604051908101604052809291908181526020016000905b82821015611fea57838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190611fa4565b50505050815260200160088201548152505081526020019060010190611f15565b50505091525050805151909150831061053e5760405162461bcd60e51b815260206004820152601f60248201527f4d6963726f6372656469743a204c6f616e20646f65736e277420657869737400604482015260640161046c565b6040516001600160a01b03831660248201526044810182905261068e90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261252d565b60006119fe83836125ff565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6121318282611e39565b6001600160a01b03808316600090815260cc6020908152604080832081518083018352815480825260019092015490951685840152835260cb9091528120805490919082908590811061219457634e487b7160e01b600052603260045260246000fd5b9060005260206000209060090201905080600401546000146121c85760405162461bcd60e51b815260040161046c90612d37565b60038101546122245760405162461bcd60e51b815260206004820152602260248201527f4d6963726f6372656469743a204c6f616e20616c72656164792063616e63656c604482015261195960f21b606482015260840161046c565b600060038201556040518481526001600160a01b038616907f2f0f5933c0b9b1d9fee69327e7789ce07ef1be486122748fc2a079742067a8089060200160405180910390a25050505050565b60008160a001516000141561228757506000919050565b6000620151808361010001514261229e9190612e86565b6122a89190612e47565b60a08401519091505b81156119fe57670de0b6b3a7640000606485604001516122d19190612e47565b6122e390670de0b6b3a7640000612e2f565b6122ed9083612e67565b6122f79190612e47565b90508161230381612ec9565b9250506122b1565b6040516001600160a01b038085166024830152831660448201526064810182905261053e9085906323b872dd60e01b90608401612092565b60006119fe836001600160a01b038416612637565b6000818152600183016020526040812054801561246b57600061237c600183612e86565b855490915060009061239090600190612e86565b90508181146124115760008660000182815481106123be57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050808760000184815481106123ef57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b855486908061243057634e487b7160e01b600052603160045260246000fd5b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610a70565b6000915050610a70565b600054610100900460ff16610aaa5760405162461bcd60e51b815260040161046c90612dad565b600054610100900460ff166124c35760405162461bcd60e51b815260040161046c90612dad565b610aaa336120d5565b600054610100900460ff166124f35760405162461bcd60e51b815260040161046c90612dad565b6065805460ff19169055565b600054610100900460ff166125265760405162461bcd60e51b815260040161046c90612dad565b6001609755565b6000612582826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166126869092919063ffffffff16565b80519091501561068e57808060200190518101906125a09190612bbb565b61068e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161046c565b600082600001828154811061262457634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b600081815260018301602052604081205461267e57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a70565b506000610a70565b6060612695848460008561269d565b949350505050565b6060824710156126fe5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161046c565b843b61274c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161046c565b600080866001600160a01b031685876040516127689190612c54565b60006040518083038185875af1925050503d80600081146127a5576040519150601f19603f3d011682016040523d82523d6000602084013e6127aa565b606091505b50915091506127ba8282866127c5565b979650505050505050565b606083156127d45750816119fe565b8251156127e45782518084602001fd5b8160405162461bcd60e51b815260040161046c9190612c70565b803561280981612f27565b919050565b60008083601f84011261281f578081fd5b50813567ffffffffffffffff811115612836578182fd5b6020830191508360208260051b850101111561285157600080fd5b9250929050565b600060208284031215612869578081fd5b81356119fe81612f27565b60008060408385031215612886578081fd5b823561289181612f27565b915060208301356128a181612f27565b809150509250929050565b600080604083850312156128be578182fd5b82356128c981612f27565b946020939093013593505050565b6000806000606084860312156128eb578081fd5b83356128f681612f27565b95602085013595506040909401359392505050565b600080600080600060a08688031215612922578081fd5b853561292d81612f27565b97602087013597506040870135966060810135965060800135945092505050565b60008060208385031215612960578182fd5b823567ffffffffffffffff811115612976578283fd5b6129828582860161280e565b90969095509350505050565b600080600080604085870312156129a3578384fd5b843567ffffffffffffffff808211156129ba578586fd5b6129c68883890161280e565b909650945060208701359150808211156129de578384fd5b506129eb8782880161280e565b95989497509550505050565b60008060008060008060008060008060a08b8d031215612a15578485fd5b8a3567ffffffffffffffff80821115612a2c578687fd5b612a388e838f0161280e565b909c509a5060208d0135915080821115612a50578687fd5b612a5c8e838f0161280e565b909a50985060408d0135915080821115612a74578687fd5b612a808e838f0161280e565b909850965060608d0135915080821115612a98578586fd5b612aa48e838f0161280e565b909650945060808d0135915080821115612abc578384fd5b50612ac98d828e0161280e565b915080935050809150509295989b9194979a5092959850565b60008060408385031215612af4578182fd5b823567ffffffffffffffff80821115612b0b578384fd5b818501915085601f830112612b1e578384fd5b8135602082821115612b3257612b32612f11565b8160051b604051601f19603f83011681018181108682111715612b5757612b57612f11565b604052838152828101945085830182870184018b1015612b75578889fd5b8896505b84871015612b9e57612b8a816127fe565b865260019690960195948301948301612b79565b509650612bae90508782016127fe565b9450505050509250929050565b600060208284031215612bcc578081fd5b815180151581146119fe578182fd5b600080600060608486031215612bef578283fd5b8335612bfa81612f27565b92506020840135612c0a81612f27565b929592945050506040919091013590565b600060208284031215612c2c578081fd5b5035919050565b60008060408385031215612c45578182fd5b50508035926020909101359150565b60008251612c66818460208701612e9d565b9190910192915050565b6020815260008251806020840152612c8f816040850160208701612e9d565b601f01601f19169190910160400192915050565b60208082526024908201527f4d6963726f6372656469743a2063616c6c6572206973206e6f742061206d616e60408201526330b3b2b960e11b606082015260800190565b60208082526030908201527f4d6963726f6372656469743a2063616c6c6461746120696e666f726d6174696f60408201526f0dc40c2e4d2e8f240dad2e6dac2e8c6d60831b606082015260800190565b60208082526021908201527f4d6963726f6372656469743a204c6f616e20616c726561647920636c61696d656040820152601960fa1b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115612e4257612e42612efb565b500190565b600082612e6257634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615612e8157612e81612efb565b500290565b600082821015612e9857612e98612efb565b500390565b60005b83811015612eb8578181015183820152602001612ea0565b8381111561053e5750506000910152565b600081612ed857612ed8612efb565b506000190190565b6000600019821415612ef457612ef4612efb565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461199a57600080fdfea26469706673582212209acbae80b61d32352f0cf583f598d5f02f8166009cdd6bac133bd46d7afa537564736f6c63430008040033