ETH Price: $2,469.74 (+0.57%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60806040174702752023-06-13 9:46:35509 days ago1686649595IN
 Create: DelegationController
0 ETH0.0797986115.47504776

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
DelegationController

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 26 : DelegationController.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    DelegationController.sol - SKALE Manager
    Copyright (C) 2018-Present SKALE Labs
    @author Dmytro Stebaiev
    @author Vadim Yavorsky

    SKALE Manager is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.17;

import "@openzeppelin/contracts/token/ERC777/IERC777.sol";

import "@skalenetwork/skale-manager-interfaces/delegation/IDelegationController.sol";
import "@skalenetwork/skale-manager-interfaces/delegation/IDelegationPeriodManager.sol";
import "@skalenetwork/skale-manager-interfaces/delegation/IPunisher.sol";
import "@skalenetwork/skale-manager-interfaces/delegation/ITokenState.sol";
import "@skalenetwork/skale-manager-interfaces/delegation/IValidatorService.sol";
import "@skalenetwork/skale-manager-interfaces/delegation/ILocker.sol";
import "@skalenetwork/skale-manager-interfaces/delegation/ITimeHelpers.sol";
import "@skalenetwork/skale-manager-interfaces/IBountyV2.sol";
import "@skalenetwork/skale-manager-interfaces/INodes.sol";
import "@skalenetwork/skale-manager-interfaces/IConstantsHolder.sol";

import "../Permissions.sol";
import "../utils/FractionUtils.sol";
import "../utils/MathUtils.sol";
import "./PartialDifferences.sol";

/**
 * @title Delegation Controller
 * @dev This contract performs all delegation functions including delegation
 * requests, and undelegation, etc.
 *
 * Delegators and validators may both perform delegations. Validators who perform
 * delegations to themselves are effectively self-delegating or self-bonding.
 *
 * IMPORTANT: Undelegation may be requested at any time, but undelegation is only
 * performed at the completion of the current delegation period.
 *
 * Delegated tokens may be in one of several states:
 *
 * - PROPOSED: token holder proposes tokens to delegate to a validator.
 * - ACCEPTED: token delegations are accepted by a validator and are locked-by-delegation.
 * - CANCELED: token holder cancels delegation proposal. Only allowed before the proposal is accepted by the validator.
 * - REJECTED: token proposal expires at the UTC start of the next month.
 * - DELEGATED: accepted delegations are delegated at the UTC start of the month.
 * - UNDELEGATION_REQUESTED: token holder requests delegations to undelegate from the validator.
 * - COMPLETED: undelegation request is completed at the end of the delegation period.
 */
contract DelegationController is Permissions, ILocker, IDelegationController {
    using MathUtils for uint;
    using PartialDifferences for PartialDifferences.Sequence;
    using PartialDifferences for PartialDifferences.Value;
    using FractionUtils for FractionUtils.Fraction;

    struct SlashingLogEvent {
        FractionUtils.Fraction reducingCoefficient;
        uint nextMonth;
    }

    struct SlashingLog {
        //      month => slashing event
        mapping (uint => SlashingLogEvent) slashes;
        uint firstMonth;
        uint lastMonth;
    }

    struct DelegationExtras {
        uint lastSlashingMonthBeforeDelegation;
    }

    struct SlashingEvent {
        FractionUtils.Fraction reducingCoefficient;
        uint validatorId;
        uint month;
    }

    struct SlashingSignal {
        address holder;
        uint penalty;
    }

    struct LockedInPending {
        uint amount;
        uint month;
    }

    struct FirstDelegationMonth {
        // month
        uint value;
        //validatorId => month
        mapping (uint => uint) byValidator;
    }

    struct ValidatorsStatistics {
        // number of validators
        uint number;
        //validatorId => amount of delegations
        mapping (uint => uint) delegated;
    }

    uint public constant UNDELEGATION_PROHIBITION_WINDOW_SECONDS = 3 * 24 * 60 * 60;

    /// @dev delegations will never be deleted to index in this array may be used like delegation id
    Delegation[] public delegations;

    // validatorId => delegationId[]
    mapping (uint => uint[]) public delegationsByValidator;

    //        holder => delegationId[]
    mapping (address => uint[]) public delegationsByHolder;

    // delegationId => extras
    mapping(uint => DelegationExtras) private _delegationExtras;

    // validatorId => sequence
    mapping (uint => PartialDifferences.Value) private _delegatedToValidator;
    // validatorId => sequence
    mapping (uint => PartialDifferences.Sequence) private _effectiveDelegatedToValidator;

    // validatorId => slashing log
    mapping (uint => SlashingLog) private _slashesOfValidator;

    //        holder => sequence
    mapping (address => PartialDifferences.Value) private _delegatedByHolder;
    //        holder =>   validatorId => sequence
    mapping (address => mapping (uint => PartialDifferences.Value)) private _delegatedByHolderToValidator;
    //        holder =>   validatorId => sequence
    mapping (address => mapping (uint => PartialDifferences.Sequence)) private _effectiveDelegatedByHolderToValidator;

    SlashingEvent[] private _slashes;
    //        holder => index in _slashes;
    mapping (address => uint) private _firstUnprocessedSlashByHolder;

    //        holder =>   validatorId => month
    mapping (address => FirstDelegationMonth) private _firstDelegationMonth;

    //        holder => locked in pending
    mapping (address => LockedInPending) private _lockedInPendingDelegations;

    mapping (address => ValidatorsStatistics) private _numberOfValidatorsPerDelegator;

    /**
     * @dev Modifier to make a function callable only if delegation exists.
     */
    modifier checkDelegationExists(uint delegationId) {
        require(delegationId < delegations.length, "Delegation does not exist");
        _;
    }

    /**
     * @dev Update and return a validator's delegations.
     */
    function getAndUpdateDelegatedToValidatorNow(uint validatorId) external override returns (uint) {
        return _getAndUpdateDelegatedToValidator(validatorId, _getCurrentMonth());
    }

    /**
     * @dev Update and return the amount delegated.
     */
    function getAndUpdateDelegatedAmount(address holder) external override returns (uint) {
        return _getAndUpdateDelegatedByHolder(holder);
    }

    /**
     * @dev Update and return the effective amount delegated (minus slash) for
     * the given month.
     */
    function getAndUpdateEffectiveDelegatedByHolderToValidator(address holder, uint validatorId, uint month)
        external
        override
        allow("Distributor")
        returns (uint effectiveDelegated)
    {
        SlashingSignal[] memory slashingSignals = _processAllSlashesWithoutSignals(holder);
        effectiveDelegated = _effectiveDelegatedByHolderToValidator[holder][validatorId]
            .getAndUpdateValueInSequence(month);
        _sendSlashingSignals(slashingSignals);
    }

    /**
     * @dev Allows a token holder to create a delegation proposal of an `amount`
     * and `delegationPeriod` to a `validatorId`. Delegation must be accepted
     * by the validator before the UTC start of the month, otherwise the
     * delegation will be rejected.
     *
     * The token holder may add additional information in each proposal.
     *
     * Emits a {DelegationProposed} event.
     *
     * Requirements:
     *
     * - Holder must have sufficient delegatable tokens.
     * - Delegation must be above the validator's minimum delegation amount.
     * - Delegation period must be allowed.
     * - Validator must be authorized if trusted list is enabled.
     * - Validator must be accepting new delegation requests.
     */
    function delegate(
        uint validatorId,
        uint amount,
        uint delegationPeriod,
        string calldata info
    )
        external
        override
    {
        require(
            _getDelegationPeriodManager().isDelegationPeriodAllowed(delegationPeriod),
            "This delegation period is not allowed");
        _getValidatorService().checkValidatorCanReceiveDelegation(validatorId, amount);
        _checkIfDelegationIsAllowed(msg.sender, validatorId);

        SlashingSignal[] memory slashingSignals = _processAllSlashesWithoutSignals(msg.sender);

        uint delegationId = _addDelegation(
            msg.sender,
            validatorId,
            amount,
            delegationPeriod,
            info);

        // check that there is enough money
        uint holderBalance = IERC777(contractManager.getSkaleToken()).balanceOf(msg.sender);
        uint forbiddenForDelegation = ILocker(contractManager.getTokenState())
            .getAndUpdateForbiddenForDelegationAmount(msg.sender);
        require(holderBalance >= forbiddenForDelegation, "Token holder does not have enough tokens to delegate");

        emit DelegationProposed(delegationId);

        _sendSlashingSignals(slashingSignals);
    }

    /**
     * @dev See {ILocker-getAndUpdateLockedAmount}.
     */
    function getAndUpdateLockedAmount(address wallet) external override returns (uint) {
        return _getAndUpdateLockedAmount(wallet);
    }

    /**
     * @dev See {ILocker-getAndUpdateForbiddenForDelegationAmount}.
     */
    function getAndUpdateForbiddenForDelegationAmount(address wallet) external override returns (uint) {
        return _getAndUpdateLockedAmount(wallet);
    }

    /**
     * @dev Allows token holder to cancel a delegation proposal.
     *
     * Emits a {DelegationRequestCanceledByUser} event.
     *
     * Requirements:
     *
     * - `msg.sender` must be the token holder of the delegation proposal.
     * - Delegation state must be PROPOSED.
     */
    function cancelPendingDelegation(uint delegationId) external override checkDelegationExists(delegationId) {
        require(msg.sender == delegations[delegationId].holder, "Only token holders can cancel delegation request");
        require(getState(delegationId) == State.PROPOSED, "Token holders are only able to cancel PROPOSED delegations");

        delegations[delegationId].finished = _getCurrentMonth();
        _subtractFromLockedInPendingDelegations(delegations[delegationId].holder, delegations[delegationId].amount);

        emit DelegationRequestCanceledByUser(delegationId);
    }

    /**
     * @dev Allows a validator to accept a proposed delegation.
     * Successful acceptance of delegations transition the tokens from a
     * PROPOSED state to ACCEPTED, and tokens are locked for the remainder of the
     * delegation period.
     *
     * Emits a {DelegationAccepted} event.
     *
     * Requirements:
     *
     * - Validator must be recipient of proposal.
     * - Delegation state must be PROPOSED.
     */
    function acceptPendingDelegation(uint delegationId) external override checkDelegationExists(delegationId) {
        require(
            _getValidatorService().checkValidatorAddressToId(msg.sender, delegations[delegationId].validatorId),
            "No permissions to accept request");
        _accept(delegationId);
    }

    /**
     * @dev Allows delegator to undelegate a specific delegation.
     *
     * Emits UndelegationRequested event.
     *
     * Requirements:
     *
     * - `msg.sender` must be the delegator or the validator.
     * - Delegation state must be DELEGATED.
     */
    function requestUndelegation(uint delegationId) external override checkDelegationExists(delegationId) {
        require(getState(delegationId) == State.DELEGATED, "Cannot request undelegation");
        IValidatorService validatorService = _getValidatorService();
        require(
            delegations[delegationId].holder == msg.sender ||
            (validatorService.validatorAddressExists(msg.sender) &&
            delegations[delegationId].validatorId == validatorService.getValidatorId(msg.sender)),
            "Permission denied to request undelegation");
        _removeValidatorFromValidatorsPerDelegators(
            delegations[delegationId].holder,
            delegations[delegationId].validatorId);
        processAllSlashes(msg.sender);
        delegations[delegationId].finished = _calculateDelegationEndMonth(delegationId);

        require(
            block.timestamp + UNDELEGATION_PROHIBITION_WINDOW_SECONDS
                < _getTimeHelpers().monthToTimestamp(delegations[delegationId].finished),
            "Undelegation requests must be sent 3 days before the end of delegation period"
        );

        _subtractFromAllStatistics(delegationId);

        emit UndelegationRequested(delegationId);
    }

    /**
     * @dev Allows Punisher contract to slash an `amount` of stake from
     * a validator. This slashes an amount of delegations of the validator,
     * which reduces the amount that the validator has staked. This consequence
     * may force the SKALE Manager to reduce the number of nodes a validator is
     * operating so the validator can meet the Minimum Staking Requirement.
     *
     * Emits a {SlashingEvent}.
     *
     * See {Punisher}.
     */
    function confiscate(uint validatorId, uint amount) external override allow("Punisher") {
        uint currentMonth = _getCurrentMonth();
        FractionUtils.Fraction memory coefficient =
            _delegatedToValidator[validatorId].reduceValue(amount, currentMonth);

        uint initialEffectiveDelegated =
            _effectiveDelegatedToValidator[validatorId].getAndUpdateValueInSequence(currentMonth);
        uint[] memory initialSubtractions = new uint[](0);
        if (currentMonth < _effectiveDelegatedToValidator[validatorId].lastChangedMonth) {
            initialSubtractions = new uint[](
                _effectiveDelegatedToValidator[validatorId].lastChangedMonth - currentMonth
            );
            for (uint i = 0; i < initialSubtractions.length; ++i) {
                initialSubtractions[i] = _effectiveDelegatedToValidator[validatorId]
                    .subtractDiff[currentMonth + i + 1];
            }
        }

        _effectiveDelegatedToValidator[validatorId].reduceSequence(coefficient, currentMonth);
        _putToSlashingLog(_slashesOfValidator[validatorId], coefficient, currentMonth);
        _slashes.push(SlashingEvent({reducingCoefficient: coefficient, validatorId: validatorId, month: currentMonth}));

        IBountyV2 bounty = _getBounty();
        bounty.handleDelegationRemoving(
            initialEffectiveDelegated -
                _effectiveDelegatedToValidator[validatorId].getAndUpdateValueInSequence(currentMonth),
            currentMonth
        );
        for (uint i = 0; i < initialSubtractions.length; ++i) {
            bounty.handleDelegationAdd(
                initialSubtractions[i] -
                    _effectiveDelegatedToValidator[validatorId].subtractDiff[currentMonth + i + 1],
                currentMonth + i + 1
            );
        }
        emit Confiscated(validatorId, amount);
    }

    /**
     * @dev Allows Distributor contract to return and update the effective
     * amount delegated (minus slash) to a validator for a given month.
     */
    function getAndUpdateEffectiveDelegatedToValidator(uint validatorId, uint month)
        external
        override
        allowTwo("Bounty", "Distributor")
        returns (uint)
    {
        return _effectiveDelegatedToValidator[validatorId].getAndUpdateValueInSequence(month);
    }

    /**
     * @dev Return and update the amount delegated to a validator for the
     * current month.
     */
    function getAndUpdateDelegatedByHolderToValidatorNow(address holder, uint validatorId)
        external
        override
        returns (uint)
    {
        return _getAndUpdateDelegatedByHolderToValidator(holder, validatorId, _getCurrentMonth());
    }

    function getEffectiveDelegatedValuesByValidator(uint validatorId) external view override returns (uint[] memory) {
        return _effectiveDelegatedToValidator[validatorId].getValuesInSequence();
    }

    function getEffectiveDelegatedToValidator(uint validatorId, uint month) external view override returns (uint) {
        return _effectiveDelegatedToValidator[validatorId].getValueInSequence(month);
    }

    function getDelegatedToValidator(uint validatorId, uint month) external view override returns (uint) {
        return _delegatedToValidator[validatorId].getValue(month);
    }

    /**
     * @dev Return Delegation struct.
     */
    function getDelegation(uint delegationId)
        external
        view
        override
        checkDelegationExists(delegationId)
        returns (Delegation memory)
    {
        return delegations[delegationId];
    }

    /**
     * @dev Returns the first delegation month.
     */
    function getFirstDelegationMonth(address holder, uint validatorId) external view override returns(uint) {
        return _firstDelegationMonth[holder].byValidator[validatorId];
    }

    /**
     * @dev Returns a validator's total number of delegations.
     */
    function getDelegationsByValidatorLength(uint validatorId) external view override returns (uint) {
        return delegationsByValidator[validatorId].length;
    }

    /**
     * @dev Returns a holder's total number of delegations.
     */
    function getDelegationsByHolderLength(address holder) external view override returns (uint) {
        return delegationsByHolder[holder].length;
    }

    function initialize(address contractsAddress) public override initializer {
        Permissions.initialize(contractsAddress);
    }

    /**
     * @dev Process slashes up to the given limit.
     */
    function processSlashes(address holder, uint limit) public override {
        _sendSlashingSignals(_processSlashesWithoutSignals(holder, limit));
        emit SlashesProcessed(holder, limit);
    }

    /**
     * @dev Process all slashes.
     */
    function processAllSlashes(address holder) public override {
        processSlashes(holder, 0);
    }

    /**
     * @dev Returns the token state of a given delegation.
     */
    function getState(uint delegationId)
        public
        view
        override
        checkDelegationExists(delegationId)
        returns (State state)
    {
        if (delegations[delegationId].started == 0) {
            if (delegations[delegationId].finished == 0) {
                if (_getCurrentMonth() == _getTimeHelpers().timestampToMonth(delegations[delegationId].created)) {
                    return State.PROPOSED;
                } else {
                    return State.REJECTED;
                }
            } else {
                return State.CANCELED;
            }
        } else {
            if (_getCurrentMonth() < delegations[delegationId].started) {
                return State.ACCEPTED;
            } else {
                if (delegations[delegationId].finished == 0) {
                    return State.DELEGATED;
                } else {
                    if (_getCurrentMonth() < delegations[delegationId].finished) {
                        return State.UNDELEGATION_REQUESTED;
                    } else {
                        return State.COMPLETED;
                    }
                }
            }
        }
    }

    /**
     * @dev Returns the amount of tokens in PENDING delegation state.
     */
    function getLockedInPendingDelegations(address holder) public view override returns (uint) {
        uint currentMonth = _getCurrentMonth();
        if (_lockedInPendingDelegations[holder].month < currentMonth) {
            return 0;
        } else {
            return _lockedInPendingDelegations[holder].amount;
        }
    }

    /**
     * @dev Checks whether there are any unprocessed slashes.
     */
    function hasUnprocessedSlashes(address holder) public view override returns (bool) {
        return _everDelegated(holder) && _firstUnprocessedSlashByHolder[holder] < _slashes.length;
    }

    // private

    /**
     * @dev Allows Nodes contract to get and update the amount delegated
     * to validator for a given month.
     */
    function _getAndUpdateDelegatedToValidator(uint validatorId, uint month)
        private returns (uint)
    {
        return _delegatedToValidator[validatorId].getAndUpdateValue(month);
    }

    /**
     * @dev Adds a new delegation proposal.
     */
    function _addDelegation(
        address holder,
        uint validatorId,
        uint amount,
        uint delegationPeriod,
        string memory info
    )
        private
        returns (uint delegationId)
    {
        delegationId = delegations.length;
        delegations.push(Delegation(
            holder,
            validatorId,
            amount,
            delegationPeriod,
            block.timestamp,
            0,
            0,
            info
        ));
        delegationsByValidator[validatorId].push(delegationId);
        delegationsByHolder[holder].push(delegationId);
        _addToLockedInPendingDelegations(delegations[delegationId].holder, delegations[delegationId].amount);
    }

    function _addToDelegatedToValidator(uint validatorId, uint amount, uint month) private {
        _delegatedToValidator[validatorId].addToValue(amount, month);
    }

    function _addToEffectiveDelegatedToValidator(uint validatorId, uint effectiveAmount, uint month) private {
        _effectiveDelegatedToValidator[validatorId].addToSequence(effectiveAmount, month);
    }

    function _addToDelegatedByHolder(address holder, uint amount, uint month) private {
        _delegatedByHolder[holder].addToValue(amount, month);
    }

    function _addToDelegatedByHolderToValidator(
        address holder, uint validatorId, uint amount, uint month) private
    {
        _delegatedByHolderToValidator[holder][validatorId].addToValue(amount, month);
    }

    function _addValidatorToValidatorsPerDelegators(address holder, uint validatorId) private {
        if (_numberOfValidatorsPerDelegator[holder].delegated[validatorId] == 0) {
            _numberOfValidatorsPerDelegator[holder].number += 1;
        }
        _numberOfValidatorsPerDelegator[holder].delegated[validatorId] += 1;
    }

    function _removeFromDelegatedByHolder(address holder, uint amount, uint month) private {
        _delegatedByHolder[holder].subtractFromValue(amount, month);
    }

    function _removeFromDelegatedByHolderToValidator(
        address holder, uint validatorId, uint amount, uint month) private
    {
        _delegatedByHolderToValidator[holder][validatorId].subtractFromValue(amount, month);
    }

    function _removeValidatorFromValidatorsPerDelegators(address holder, uint validatorId) private {
        if (_numberOfValidatorsPerDelegator[holder].delegated[validatorId] == 1) {
            _numberOfValidatorsPerDelegator[holder].number -= 1;
        }
        _numberOfValidatorsPerDelegator[holder].delegated[validatorId] -= 1;
    }

    function _addToEffectiveDelegatedByHolderToValidator(
        address holder,
        uint validatorId,
        uint effectiveAmount,
        uint month)
        private
    {
        _effectiveDelegatedByHolderToValidator[holder][validatorId].addToSequence(effectiveAmount, month);
    }

    function _removeFromEffectiveDelegatedByHolderToValidator(
        address holder,
        uint validatorId,
        uint effectiveAmount,
        uint month)
        private
    {
        _effectiveDelegatedByHolderToValidator[holder][validatorId].subtractFromSequence(effectiveAmount, month);
    }

    function _getAndUpdateDelegatedByHolder(address holder) private returns (uint) {
        uint currentMonth = _getCurrentMonth();
        processAllSlashes(holder);
        return _delegatedByHolder[holder].getAndUpdateValue(currentMonth);
    }

    function _getAndUpdateDelegatedByHolderToValidator(
        address holder,
        uint validatorId,
        uint month)
        private returns (uint)
    {
        return _delegatedByHolderToValidator[holder][validatorId].getAndUpdateValue(month);
    }

    function _addToLockedInPendingDelegations(address holder, uint amount) private {
        uint currentMonth = _getCurrentMonth();
        if (_lockedInPendingDelegations[holder].month < currentMonth) {
            _lockedInPendingDelegations[holder].amount = amount;
            _lockedInPendingDelegations[holder].month = currentMonth;
        } else {
            assert(_lockedInPendingDelegations[holder].month == currentMonth);
            _lockedInPendingDelegations[holder].amount = _lockedInPendingDelegations[holder].amount + amount;
        }
    }

    function _subtractFromLockedInPendingDelegations(address holder, uint amount) private {
        uint currentMonth = _getCurrentMonth();
        assert(_lockedInPendingDelegations[holder].month == currentMonth);
        _lockedInPendingDelegations[holder].amount = _lockedInPendingDelegations[holder].amount - amount;
    }

    /**
     * @dev See {ILocker-getAndUpdateLockedAmount}.
     */
    function _getAndUpdateLockedAmount(address wallet) private returns (uint) {
        return _getAndUpdateDelegatedByHolder(wallet) + getLockedInPendingDelegations(wallet);
    }

    function _updateFirstDelegationMonth(address holder, uint validatorId, uint month) private {
        if (_firstDelegationMonth[holder].value == 0) {
            _firstDelegationMonth[holder].value = month;
            _firstUnprocessedSlashByHolder[holder] = _slashes.length;
        }
        if (_firstDelegationMonth[holder].byValidator[validatorId] == 0) {
            _firstDelegationMonth[holder].byValidator[validatorId] = month;
        }
    }

    function _removeFromDelegatedToValidator(uint validatorId, uint amount, uint month) private {
        _delegatedToValidator[validatorId].subtractFromValue(amount, month);
    }

    function _removeFromEffectiveDelegatedToValidator(uint validatorId, uint effectiveAmount, uint month) private {
        _effectiveDelegatedToValidator[validatorId].subtractFromSequence(effectiveAmount, month);
    }

    function _putToSlashingLog(
        SlashingLog storage log,
        FractionUtils.Fraction memory coefficient,
        uint month)
        private
    {
        if (log.firstMonth == 0) {
            log.firstMonth = month;
            log.lastMonth = month;
            log.slashes[month].reducingCoefficient = coefficient;
            log.slashes[month].nextMonth = 0;
        } else {
            require(log.lastMonth <= month, "Cannot put slashing event in the past");
            if (log.lastMonth == month) {
                log.slashes[month].reducingCoefficient =
                    log.slashes[month].reducingCoefficient.multiplyFraction(coefficient);
            } else {
                log.slashes[month].reducingCoefficient = coefficient;
                log.slashes[month].nextMonth = 0;
                log.slashes[log.lastMonth].nextMonth = month;
                log.lastMonth = month;
            }
        }
    }

    function _processSlashesWithoutSignals(address holder, uint limit)
        private returns (SlashingSignal[] memory slashingSignals)
    {
        if (hasUnprocessedSlashes(holder)) {
            uint index = _firstUnprocessedSlashByHolder[holder];
            uint end = _slashes.length;
            if (limit > 0 && (index + limit) < end) {
                end = index + limit;
            }
            slashingSignals = new SlashingSignal[](end - index);
            uint begin = index;
            for (; index < end; ++index) {
                uint validatorId = _slashes[index].validatorId;
                uint month = _slashes[index].month;
                uint oldValue = _getAndUpdateDelegatedByHolderToValidator(holder, validatorId, month);
                if (oldValue.muchGreater(0)) {
                    _delegatedByHolderToValidator[holder][validatorId].reduceValueByCoefficientAndUpdateSum(
                        _delegatedByHolder[holder],
                        _slashes[index].reducingCoefficient,
                        month);
                    _effectiveDelegatedByHolderToValidator[holder][validatorId].reduceSequence(
                        _slashes[index].reducingCoefficient,
                        month);
                    slashingSignals[index - begin].holder = holder;
                    slashingSignals[index - begin].penalty
                        = oldValue.boundedSub(_getAndUpdateDelegatedByHolderToValidator(holder, validatorId, month));
                }
            }
            _firstUnprocessedSlashByHolder[holder] = end;
        }
    }

    function _processAllSlashesWithoutSignals(address holder)
        private returns (SlashingSignal[] memory slashingSignals)
    {
        return _processSlashesWithoutSignals(holder, 0);
    }

    function _sendSlashingSignals(SlashingSignal[] memory slashingSignals) private {
        IPunisher punisher = IPunisher(contractManager.getPunisher());
        address previousHolder = address(0);
        uint accumulatedPenalty = 0;
        for (uint i = 0; i < slashingSignals.length; ++i) {
            if (slashingSignals[i].holder != previousHolder) {
                if (accumulatedPenalty > 0) {
                    punisher.handleSlash(previousHolder, accumulatedPenalty);
                }
                previousHolder = slashingSignals[i].holder;
                accumulatedPenalty = slashingSignals[i].penalty;
            } else {
                accumulatedPenalty = accumulatedPenalty + slashingSignals[i].penalty;
            }
        }
        if (accumulatedPenalty > 0) {
            punisher.handleSlash(previousHolder, accumulatedPenalty);
        }
    }

    function _addToAllStatistics(uint delegationId) private {
        uint currentMonth = _getCurrentMonth();
        delegations[delegationId].started = currentMonth + 1;
        if (_slashesOfValidator[delegations[delegationId].validatorId].lastMonth > 0) {
            _delegationExtras[delegationId].lastSlashingMonthBeforeDelegation =
                _slashesOfValidator[delegations[delegationId].validatorId].lastMonth;
        }

        _addToDelegatedToValidator(
            delegations[delegationId].validatorId,
            delegations[delegationId].amount,
            currentMonth + 1);
        _addToDelegatedByHolder(
            delegations[delegationId].holder,
            delegations[delegationId].amount,
            currentMonth + 1);
        _addToDelegatedByHolderToValidator(
            delegations[delegationId].holder,
            delegations[delegationId].validatorId,
            delegations[delegationId].amount,
            currentMonth + 1);
        _updateFirstDelegationMonth(
            delegations[delegationId].holder,
            delegations[delegationId].validatorId,
            currentMonth + 1);
        uint effectiveAmount = delegations[delegationId].amount *
            _getDelegationPeriodManager().stakeMultipliers(delegations[delegationId].delegationPeriod);
        _addToEffectiveDelegatedToValidator(
            delegations[delegationId].validatorId,
            effectiveAmount,
            currentMonth + 1);
        _addToEffectiveDelegatedByHolderToValidator(
            delegations[delegationId].holder,
            delegations[delegationId].validatorId,
            effectiveAmount,
            currentMonth + 1);
        _addValidatorToValidatorsPerDelegators(
            delegations[delegationId].holder,
            delegations[delegationId].validatorId
        );
    }

    function _subtractFromAllStatistics(uint delegationId) private {
        uint amountAfterSlashing = _calculateDelegationAmountAfterSlashing(delegationId);
        _removeFromDelegatedToValidator(
            delegations[delegationId].validatorId,
            amountAfterSlashing,
            delegations[delegationId].finished);
        _removeFromDelegatedByHolder(
            delegations[delegationId].holder,
            amountAfterSlashing,
            delegations[delegationId].finished);
        _removeFromDelegatedByHolderToValidator(
            delegations[delegationId].holder,
            delegations[delegationId].validatorId,
            amountAfterSlashing,
            delegations[delegationId].finished);
        uint effectiveAmount = amountAfterSlashing *
                _getDelegationPeriodManager().stakeMultipliers(delegations[delegationId].delegationPeriod);
        _removeFromEffectiveDelegatedToValidator(
            delegations[delegationId].validatorId,
            effectiveAmount,
            delegations[delegationId].finished);
        _removeFromEffectiveDelegatedByHolderToValidator(
            delegations[delegationId].holder,
            delegations[delegationId].validatorId,
            effectiveAmount,
            delegations[delegationId].finished);
        _getBounty().handleDelegationRemoving(
            effectiveAmount,
            delegations[delegationId].finished);
    }

    function _accept(uint delegationId) private {
        _checkIfDelegationIsAllowed(delegations[delegationId].holder, delegations[delegationId].validatorId);

        State currentState = getState(delegationId);
        if (currentState != State.PROPOSED) {
            if (currentState == State.ACCEPTED ||
                currentState == State.DELEGATED ||
                currentState == State.UNDELEGATION_REQUESTED ||
                currentState == State.COMPLETED)
            {
                revert("The delegation has been already accepted");
            } else if (currentState == State.CANCELED) {
                revert("The delegation has been cancelled by token holder");
            } else if (currentState == State.REJECTED) {
                revert("The delegation request is outdated");
            }
        }
        require(currentState == State.PROPOSED, "Cannot set delegation state to accepted");

        SlashingSignal[] memory slashingSignals = _processAllSlashesWithoutSignals(delegations[delegationId].holder);

        _addToAllStatistics(delegationId);

        uint amount = delegations[delegationId].amount;

        uint effectiveAmount = amount *
            _getDelegationPeriodManager().stakeMultipliers(delegations[delegationId].delegationPeriod);
        _getBounty().handleDelegationAdd(
            effectiveAmount,
            delegations[delegationId].started
        );

        _sendSlashingSignals(slashingSignals);
        emit DelegationAccepted(delegationId);
    }

    function _getCurrentMonth() private view returns (uint) {
        return _getTimeHelpers().getCurrentMonth();
    }

    /**
     * @dev Checks whether the holder has performed a delegation.
     */
    function _everDelegated(address holder) private view returns (bool) {
        return _firstDelegationMonth[holder].value > 0;
    }

    /**
     * @dev Returns the month when a delegation ends.
     */
    function _calculateDelegationEndMonth(uint delegationId) private view returns (uint) {
        uint currentMonth = _getCurrentMonth();
        uint started = delegations[delegationId].started;

        if (currentMonth < started) {
            return started + delegations[delegationId].delegationPeriod;
        } else {
            uint completedPeriods = (currentMonth - started) / delegations[delegationId].delegationPeriod;
            return started + (completedPeriods + 1) * delegations[delegationId].delegationPeriod;
        }
    }

    /**
     * @dev Returns the delegated amount after a slashing event.
     */
    function _calculateDelegationAmountAfterSlashing(uint delegationId) private view returns (uint) {
        uint startMonth = _delegationExtras[delegationId].lastSlashingMonthBeforeDelegation;
        uint validatorId = delegations[delegationId].validatorId;
        uint amount = delegations[delegationId].amount;
        if (startMonth == 0) {
            startMonth = _slashesOfValidator[validatorId].firstMonth;
            if (startMonth == 0) {
                return amount;
            }
        }
        for (uint i = startMonth;
            i > 0 && i < delegations[delegationId].finished;
            i = _slashesOfValidator[validatorId].slashes[i].nextMonth) {
            if (i >= delegations[delegationId].started) {
                amount = amount
                    * _slashesOfValidator[validatorId].slashes[i].reducingCoefficient.numerator
                    / _slashesOfValidator[validatorId].slashes[i].reducingCoefficient.denominator;
            }
        }
        return amount;
    }

    /**
     * @dev Checks whether delegation to a validator is allowed.
     *
     * Requirements:
     *
     * - Delegator must not have reached the validator limit.
     * - Delegation must be made in or after the first delegation month.
     */
    function _checkIfDelegationIsAllowed(address holder, uint validatorId) private view {
        require(
            _numberOfValidatorsPerDelegator[holder].delegated[validatorId] > 0 ||
                _numberOfValidatorsPerDelegator[holder].number < _getConstantsHolder().limitValidatorsPerDelegator(),
            "Limit of validators is reached"
        );
    }

    function _getDelegationPeriodManager() private view returns (IDelegationPeriodManager) {
        return IDelegationPeriodManager(contractManager.getDelegationPeriodManager());
    }

    function _getBounty() private view returns (IBountyV2) {
        return IBountyV2(contractManager.getBounty());
    }

    function _getValidatorService() private view returns (IValidatorService) {
        return IValidatorService(contractManager.getValidatorService());
    }

    function _getTimeHelpers() private view returns (ITimeHelpers) {
        return ITimeHelpers(contractManager.getTimeHelpers());
    }

    function _getConstantsHolder() private view returns (IConstantsHolder) {
        return IConstantsHolder(contractManager.getConstantsHolder());
    }
}

File 2 of 26 : IERC777.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC777/IERC777.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC777Token standard as defined in the EIP.
 *
 * This contract uses the
 * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 registry standard] to let
 * token holders and recipients react to token movements by using setting implementers
 * for the associated interfaces in said registry. See {IERC1820Registry} and
 * {ERC1820Implementer}.
 */
interface IERC777 {
    /**
     * @dev Emitted when `amount` tokens are created by `operator` and assigned to `to`.
     *
     * Note that some additional user `data` and `operatorData` can be logged in the event.
     */
    event Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData);

    /**
     * @dev Emitted when `operator` destroys `amount` tokens from `account`.
     *
     * Note that some additional user `data` and `operatorData` can be logged in the event.
     */
    event Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData);

    /**
     * @dev Emitted when `operator` is made operator for `tokenHolder`
     */
    event AuthorizedOperator(address indexed operator, address indexed tokenHolder);

    /**
     * @dev Emitted when `operator` is revoked its operator status for `tokenHolder`
     */
    event RevokedOperator(address indexed operator, address indexed tokenHolder);

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

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the smallest part of the token that is not divisible. This
     * means all token operations (creation, movement and destruction) must have
     * amounts that are a multiple of this number.
     *
     * For most token contracts, this value will equal 1.
     */
    function granularity() external view returns (uint256);

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

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

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * If send or receive hooks are registered for the caller and `recipient`,
     * the corresponding functions will be called with `data` and empty
     * `operatorData`. See {IERC777Sender} and {IERC777Recipient}.
     *
     * Emits a {Sent} event.
     *
     * Requirements
     *
     * - the caller must have at least `amount` tokens.
     * - `recipient` cannot be the zero address.
     * - if `recipient` is a contract, it must implement the {IERC777Recipient}
     * interface.
     */
    function send(
        address recipient,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev Destroys `amount` tokens from the caller's account, reducing the
     * total supply.
     *
     * If a send hook is registered for the caller, the corresponding function
     * will be called with `data` and empty `operatorData`. See {IERC777Sender}.
     *
     * Emits a {Burned} event.
     *
     * Requirements
     *
     * - the caller must have at least `amount` tokens.
     */
    function burn(uint256 amount, bytes calldata data) external;

    /**
     * @dev Returns true if an account is an operator of `tokenHolder`.
     * Operators can send and burn tokens on behalf of their owners. All
     * accounts are their own operator.
     *
     * See {operatorSend} and {operatorBurn}.
     */
    function isOperatorFor(address operator, address tokenHolder) external view returns (bool);

    /**
     * @dev Make an account an operator of the caller.
     *
     * See {isOperatorFor}.
     *
     * Emits an {AuthorizedOperator} event.
     *
     * Requirements
     *
     * - `operator` cannot be calling address.
     */
    function authorizeOperator(address operator) external;

    /**
     * @dev Revoke an account's operator status for the caller.
     *
     * See {isOperatorFor} and {defaultOperators}.
     *
     * Emits a {RevokedOperator} event.
     *
     * Requirements
     *
     * - `operator` cannot be calling address.
     */
    function revokeOperator(address operator) external;

    /**
     * @dev Returns the list of default operators. These accounts are operators
     * for all token holders, even if {authorizeOperator} was never called on
     * them.
     *
     * This list is immutable, but individual holders may revoke these via
     * {revokeOperator}, in which case {isOperatorFor} will return false.
     */
    function defaultOperators() external view returns (address[] memory);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient`. The caller must
     * be an operator of `sender`.
     *
     * If send or receive hooks are registered for `sender` and `recipient`,
     * the corresponding functions will be called with `data` and
     * `operatorData`. See {IERC777Sender} and {IERC777Recipient}.
     *
     * Emits a {Sent} event.
     *
     * Requirements
     *
     * - `sender` cannot be the zero address.
     * - `sender` must have at least `amount` tokens.
     * - the caller must be an operator for `sender`.
     * - `recipient` cannot be the zero address.
     * - if `recipient` is a contract, it must implement the {IERC777Recipient}
     * interface.
     */
    function operatorSend(
        address sender,
        address recipient,
        uint256 amount,
        bytes calldata data,
        bytes calldata operatorData
    ) external;

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the total supply.
     * The caller must be an operator of `account`.
     *
     * If a send hook is registered for `account`, the corresponding function
     * will be called with `data` and `operatorData`. See {IERC777Sender}.
     *
     * Emits a {Burned} event.
     *
     * Requirements
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     * - the caller must be an operator for `account`.
     */
    function operatorBurn(
        address account,
        uint256 amount,
        bytes calldata data,
        bytes calldata operatorData
    ) external;

    event Sent(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256 amount,
        bytes data,
        bytes operatorData
    );
}

File 3 of 26 : IDelegationController.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    IDelegationController.sol - SKALE Manager
    Copyright (C) 2018-Present SKALE Labs
    @author Artem Payvin

    SKALE Manager is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

interface IDelegationController {
    enum State {
        PROPOSED,
        ACCEPTED,
        CANCELED,
        REJECTED,
        DELEGATED,
        UNDELEGATION_REQUESTED,
        COMPLETED
    }

    struct Delegation {
        address holder; // address of token owner
        uint validatorId;
        uint amount;
        uint delegationPeriod;
        uint created; // time of delegation creation
        uint started; // month when a delegation becomes active
        uint finished; // first month after a delegation ends
        string info;
    }

    /**
     * @dev Emitted when validator was confiscated.
     */
    event Confiscated(
        uint indexed validatorId,
        uint amount
    );

    /**
     * @dev Emitted when validator was confiscated.
     */
    event SlashesProcessed(
        address indexed holder,
        uint limit
    );

    /**
     * @dev Emitted when a delegation is proposed to a validator.
     */
    event DelegationProposed(
        uint delegationId
    );

    /**
     * @dev Emitted when a delegation is accepted by a validator.
     */
    event DelegationAccepted(
        uint delegationId
    );

    /**
     * @dev Emitted when a delegation is cancelled by the delegator.
     */
    event DelegationRequestCanceledByUser(
        uint delegationId
    );

    /**
     * @dev Emitted when a delegation is requested to undelegate.
     */
    event UndelegationRequested(
        uint delegationId
    );
    
    function getAndUpdateDelegatedToValidatorNow(uint validatorId) external returns (uint);
    function getAndUpdateDelegatedAmount(address holder) external returns (uint);
    function getAndUpdateEffectiveDelegatedByHolderToValidator(address holder, uint validatorId, uint month)
        external
        returns (uint effectiveDelegated);
    function delegate(
        uint validatorId,
        uint amount,
        uint delegationPeriod,
        string calldata info
    )
        external;
    function cancelPendingDelegation(uint delegationId) external;
    function acceptPendingDelegation(uint delegationId) external;
    function requestUndelegation(uint delegationId) external;
    function confiscate(uint validatorId, uint amount) external;
    function getAndUpdateEffectiveDelegatedToValidator(uint validatorId, uint month) external returns (uint);
    function getAndUpdateDelegatedByHolderToValidatorNow(address holder, uint validatorId) external returns (uint);
    function processSlashes(address holder, uint limit) external;
    function processAllSlashes(address holder) external;
    function getEffectiveDelegatedValuesByValidator(uint validatorId) external view returns (uint[] memory);
    function getEffectiveDelegatedToValidator(uint validatorId, uint month) external view returns (uint);
    function getDelegatedToValidator(uint validatorId, uint month) external view returns (uint);
    function getDelegation(uint delegationId) external view returns (Delegation memory);
    function getFirstDelegationMonth(address holder, uint validatorId) external view returns(uint);
    function getDelegationsByValidatorLength(uint validatorId) external view returns (uint);
    function getDelegationsByHolderLength(address holder) external view returns (uint);
    function getState(uint delegationId) external view returns (State state);
    function getLockedInPendingDelegations(address holder) external view returns (uint);
    function hasUnprocessedSlashes(address holder) external view returns (bool);
}

File 4 of 26 : IDelegationPeriodManager.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    IDelegationPeriodManager.sol - SKALE Manager
    Copyright (C) 2018-Present SKALE Labs
    @author Artem Payvin

    SKALE Manager is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

interface IDelegationPeriodManager {
    /**
     * @dev Emitted when a new delegation period is specified.
     */
    event DelegationPeriodWasSet(
        uint length,
        uint stakeMultiplier
    );
    
    function setDelegationPeriod(uint monthsCount, uint stakeMultiplier) external;
    function stakeMultipliers(uint monthsCount) external view returns (uint);
    function isDelegationPeriodAllowed(uint monthsCount) external view returns (bool);
}

File 5 of 26 : IPunisher.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    IPunisher.sol - SKALE Manager
    Copyright (C) 2018-Present SKALE Labs
    @author Artem Payvin

    SKALE Manager is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

interface IPunisher {
    /**
     * @dev Emitted upon slashing condition.
     */
    event Slash(
        uint validatorId,
        uint amount
    );

    /**
     * @dev Emitted upon forgive condition.
     */
    event Forgive(
        address wallet,
        uint amount
    );
    
    function slash(uint validatorId, uint amount) external;
    function forgive(address holder, uint amount) external;
    function handleSlash(address holder, uint amount) external;
}

File 6 of 26 : ITokenState.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    ITokenState.sol - SKALE Manager
    Copyright (C) 2018-Present SKALE Labs
    @author Artem Payvin

    SKALE Manager is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

interface ITokenState {
    /**
     * @dev Emitted when a contract is added to the locker.
     */
    event LockerWasAdded(
        string locker
    );

    /**
     * @dev Emitted when a contract is removed from the locker.
     */
    event LockerWasRemoved(
        string locker
    );
    
    function removeLocker(string calldata locker) external;
    function addLocker(string memory locker) external;
}

File 7 of 26 : IValidatorService.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    IValidatorService.sol - SKALE Manager
    Copyright (C) 2018-Present SKALE Labs
    @author Artem Payvin

    SKALE Manager is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

interface IValidatorService {
    struct Validator {
        string name;
        address validatorAddress;
        address requestedAddress;
        string description;
        uint feeRate;
        uint registrationTime;
        uint minimumDelegationAmount;
        bool acceptNewRequests;
    }
    
    /**
     * @dev Emitted when a validator registers.
     */
    event ValidatorRegistered(
        uint validatorId
    );

    /**
     * @dev Emitted when a validator address changes.
     */
    event ValidatorAddressChanged(
        uint validatorId,
        address newAddress
    );

    /**
     * @dev Emitted when a validator is enabled.
     */
    event ValidatorWasEnabled(
        uint validatorId
    );

    /**
     * @dev Emitted when a validator is disabled.
     */
    event ValidatorWasDisabled(
        uint validatorId
    );

    /**
     * @dev Emitted when a node address is linked to a validator.
     */
    event NodeAddressWasAdded(
        uint validatorId,
        address nodeAddress
    );

    /**
     * @dev Emitted when a node address is unlinked from a validator.
     */
    event NodeAddressWasRemoved(
        uint validatorId,
        address nodeAddress
    );

    /**
     * @dev Emitted when whitelist disabled.
     */
    event WhitelistDisabled(bool status);

    /**
     * @dev Emitted when validator requested new address.
     */
    event RequestNewAddress(uint indexed validatorId, address previousAddress, address newAddress);

    /**
     * @dev Emitted when validator set new minimum delegation amount.
     */
    event SetMinimumDelegationAmount(uint indexed validatorId, uint previousMDA, uint newMDA);

    /**
     * @dev Emitted when validator set new name.
     */
    event SetValidatorName(uint indexed validatorId, string previousName, string newName);

    /**
     * @dev Emitted when validator set new description.
     */
    event SetValidatorDescription(uint indexed validatorId, string previousDescription, string newDescription);

    /**
     * @dev Emitted when validator start or stop accepting new delegation requests.
     */
    event AcceptingNewRequests(uint indexed validatorId, bool status);
    
    function registerValidator(
        string calldata name,
        string calldata description,
        uint feeRate,
        uint minimumDelegationAmount
    )
        external
        returns (uint validatorId);
    function enableValidator(uint validatorId) external;
    function disableValidator(uint validatorId) external;
    function disableWhitelist() external;
    function requestForNewAddress(address newValidatorAddress) external;
    function confirmNewAddress(uint validatorId) external;
    function linkNodeAddress(address nodeAddress, bytes calldata sig) external;
    function unlinkNodeAddress(address nodeAddress) external;
    function setValidatorMDA(uint minimumDelegationAmount) external;
    function setValidatorName(string calldata newName) external;
    function setValidatorDescription(string calldata newDescription) external;
    function startAcceptingNewRequests() external;
    function stopAcceptingNewRequests() external;
    function removeNodeAddress(uint validatorId, address nodeAddress) external;
    function getAndUpdateBondAmount(uint validatorId) external returns (uint);
    function getMyNodesAddresses() external view returns (address[] memory);
    function getTrustedValidators() external view returns (uint[] memory);
    function checkValidatorAddressToId(address validatorAddress, uint validatorId)
        external
        view
        returns (bool);
    function getValidatorIdByNodeAddress(address nodeAddress) external view returns (uint validatorId);
    function checkValidatorCanReceiveDelegation(uint validatorId, uint amount) external view;
    function getNodeAddresses(uint validatorId) external view returns (address[] memory);
    function validatorExists(uint validatorId) external view returns (bool);
    function validatorAddressExists(address validatorAddress) external view returns (bool);
    function checkIfValidatorAddressExists(address validatorAddress) external view;
    function getValidator(uint validatorId) external view returns (Validator memory);
    function getValidatorId(address validatorAddress) external view returns (uint);
    function isAcceptingNewRequests(uint validatorId) external view returns (bool);
    function isAuthorizedValidator(uint validatorId) external view returns (bool);
}

File 8 of 26 : ILocker.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    ILocker.sol - SKALE Manager
    Copyright (C) 2019-Present SKALE Labs
    @author Dmytro Stebaiev

    SKALE Manager is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

/**
 * @dev Interface of the Locker functions.
 */
interface ILocker {
    /**
     * @dev Returns and updates the total amount of locked tokens of a given 
     * `holder`.
     */
    function getAndUpdateLockedAmount(address wallet) external returns (uint);

    /**
     * @dev Returns and updates the total non-transferrable and un-delegatable
     * amount of a given `holder`.
     */
    function getAndUpdateForbiddenForDelegationAmount(address wallet) external returns (uint);
}

File 9 of 26 : ITimeHelpers.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    ITimeHelpers.sol - SKALE Manager
    Copyright (C) 2018-Present SKALE Labs
    @author Artem Payvin

    SKALE Manager is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

interface ITimeHelpers {
    function calculateProofOfUseLockEndTime(uint month, uint lockUpPeriodDays) external view returns (uint timestamp);
    function getCurrentMonth() external view returns (uint);
    function timestampToYear(uint timestamp) external view returns (uint);
    function timestampToMonth(uint timestamp) external view returns (uint);
    function monthToTimestamp(uint month) external view returns (uint timestamp);
    function addDays(uint fromTimestamp, uint n) external pure returns (uint);
    function addMonths(uint fromTimestamp, uint n) external pure returns (uint);
    function addYears(uint fromTimestamp, uint n) external pure returns (uint);
}

File 10 of 26 : IBountyV2.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    IBountyV2.sol - SKALE Manager Interfaces
    Copyright (C) 2021-Present SKALE Labs
    @author Artem Payvin

    SKALE Manager Interfaces is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager Interfaces.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

interface IBountyV2 {

    /**
     * @dev Emitted when bounty reduction is turned on or turned off.
     */
    event BountyReduction(bool status);
    /**
     * @dev Emitted when a node creation window was changed.
     */
    event NodeCreationWindowWasChanged(
        uint oldValue,
        uint newValue
    );

    function calculateBounty(uint nodeIndex) external returns (uint);
    function enableBountyReduction() external;
    function disableBountyReduction() external;
    function setNodeCreationWindowSeconds(uint window) external;
    function handleDelegationAdd(uint amount, uint month) external;
    function handleDelegationRemoving(uint amount, uint month) external;
    function estimateBounty(uint nodeIndex) external view returns (uint);
    function getNextRewardTimestamp(uint nodeIndex) external view returns (uint);
    function getEffectiveDelegatedSum() external view returns (uint[] memory);
}

File 11 of 26 : INodes.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    INodes.sol - SKALE Manager
    Copyright (C) 2018-Present SKALE Labs
    @author Artem Payvin

    SKALE Manager is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

import "./utils/IRandom.sol";

interface INodes {
    // All Nodes states
    enum NodeStatus {Active, Leaving, Left, In_Maintenance}

    struct Node {
        string name;
        bytes4 ip;
        bytes4 publicIP;
        uint16 port;
        bytes32[2] publicKey;
        uint startBlock;
        uint lastRewardDate;
        uint finishTime;
        NodeStatus status;
        uint validatorId;
    }

    // struct to note which Nodes and which number of Nodes owned by user
    struct CreatedNodes {
        mapping (uint => bool) isNodeExist;
        uint numberOfNodes;
    }

    struct SpaceManaging {
        uint8 freeSpace;
        uint indexInSpaceMap;
    }

    struct NodeCreationParams {
        string name;
        bytes4 ip;
        bytes4 publicIp;
        uint16 port;
        bytes32[2] publicKey;
        uint16 nonce;
        string domainName;
    }
    
    /**
     * @dev Emitted when a node is created.
     */
    event NodeCreated(
        uint nodeIndex,
        address owner,
        string name,
        bytes4 ip,
        bytes4 publicIP,
        uint16 port,
        uint16 nonce,
        string domainName
    );

    /**
     * @dev Emitted when a node completes a network exit.
     */
    event ExitCompleted(
        uint nodeIndex
    );

    /**
     * @dev Emitted when a node begins to exit from the network.
     */
    event ExitInitialized(
        uint nodeIndex,
        uint startLeavingPeriod
    );

    /**
     * @dev Emitted when a node set to in compliant or compliant.
     */
    event IncompliantNode(
        uint indexed nodeIndex,
        bool status
    );

    /**
     * @dev Emitted when a node set to in maintenance or from in maintenance.
     */
    event MaintenanceNode(
        uint indexed nodeIndex,
        bool status
    );

    /**
     * @dev Emitted when a node status changed.
     */
    event IPChanged(
        uint indexed nodeIndex,
        bytes4 previousIP,
        bytes4 newIP
    );
    
    function removeSpaceFromNode(uint nodeIndex, uint8 space) external returns (bool);
    function addSpaceToNode(uint nodeIndex, uint8 space) external;
    function changeNodeLastRewardDate(uint nodeIndex) external;
    function changeNodeFinishTime(uint nodeIndex, uint time) external;
    function createNode(address from, NodeCreationParams calldata params) external;
    function initExit(uint nodeIndex) external;
    function completeExit(uint nodeIndex) external returns (bool);
    function deleteNodeForValidator(uint validatorId, uint nodeIndex) external;
    function checkPossibilityCreatingNode(address nodeAddress) external;
    function checkPossibilityToMaintainNode(uint validatorId, uint nodeIndex) external returns (bool);
    function setNodeInMaintenance(uint nodeIndex) external;
    function removeNodeFromInMaintenance(uint nodeIndex) external;
    function setNodeIncompliant(uint nodeIndex) external;
    function setNodeCompliant(uint nodeIndex) external;
    function setDomainName(uint nodeIndex, string memory domainName) external;
    function makeNodeVisible(uint nodeIndex) external;
    function makeNodeInvisible(uint nodeIndex) external;
    function changeIP(uint nodeIndex, bytes4 newIP, bytes4 newPublicIP) external;
    function numberOfActiveNodes() external view returns (uint);
    function incompliant(uint nodeIndex) external view returns (bool);
    function getRandomNodeWithFreeSpace(
        uint8 freeSpace,
        IRandom.RandomGenerator memory randomGenerator
    )
        external
        view
        returns (uint);
    function isTimeForReward(uint nodeIndex) external view returns (bool);
    function getNodeIP(uint nodeIndex) external view returns (bytes4);
    function getNodeDomainName(uint nodeIndex) external view returns (string memory);
    function getNodePort(uint nodeIndex) external view returns (uint16);
    function getNodePublicKey(uint nodeIndex) external view returns (bytes32[2] memory);
    function getNodeAddress(uint nodeIndex) external view returns (address);
    function getNodeFinishTime(uint nodeIndex) external view returns (uint);
    function isNodeLeft(uint nodeIndex) external view returns (bool);
    function isNodeInMaintenance(uint nodeIndex) external view returns (bool);
    function getNodeLastRewardDate(uint nodeIndex) external view returns (uint);
    function getNodeNextRewardDate(uint nodeIndex) external view returns (uint);
    function getNumberOfNodes() external view returns (uint);
    function getNumberOnlineNodes() external view returns (uint);
    function getActiveNodeIds() external view returns (uint[] memory activeNodeIds);
    function getNodeStatus(uint nodeIndex) external view returns (NodeStatus);
    function getValidatorNodeIndexes(uint validatorId) external view returns (uint[] memory);
    function countNodesWithFreeSpace(uint8 freeSpace) external view returns (uint count);
    function getValidatorId(uint nodeIndex) external view returns (uint);
    function isNodeExist(address from, uint nodeIndex) external view returns (bool);
    function isNodeActive(uint nodeIndex) external view returns (bool);
    function isNodeLeaving(uint nodeIndex) external view returns (bool);
}

File 12 of 26 : IConstantsHolder.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    IConstantsHolder.sol - SKALE Manager Interfaces
    Copyright (C) 2021-Present SKALE Labs
    @author Artem Payvin

    SKALE Manager Interfaces is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager Interfaces.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

interface IConstantsHolder {

    /**
     * @dev Emitted when constants updated.
     */
    event ConstantUpdated(
        bytes32 indexed constantHash,
        uint previousValue,
        uint newValue
    );

    function setPeriods(uint32 newRewardPeriod, uint32 newDeltaPeriod) external;
    function setCheckTime(uint newCheckTime) external;
    function setLatency(uint32 newAllowableLatency) external;
    function setMSR(uint newMSR) external;
    function setLaunchTimestamp(uint timestamp) external;
    function setRotationDelay(uint newDelay) external;
    function setProofOfUseLockUpPeriod(uint periodDays) external;
    function setProofOfUseDelegationPercentage(uint percentage) external;
    function setLimitValidatorsPerDelegator(uint newLimit) external;
    function setSchainCreationTimeStamp(uint timestamp) external;
    function setMinimalSchainLifetime(uint lifetime) external;
    function setComplaintTimeLimit(uint timeLimit) external;
    function setMinNodeBalance(uint newMinNodeBalance) external;
    function reinitialize() external;
    function msr() external view returns (uint);
    function launchTimestamp() external view returns (uint);
    function rotationDelay() external view returns (uint);
    function limitValidatorsPerDelegator() external view returns (uint);
    function schainCreationTimeStamp() external view returns (uint);
    function minimalSchainLifetime() external view returns (uint);
    function complaintTimeLimit() external view returns (uint);
    function minNodeBalance() external view returns (uint);
}

File 13 of 26 : Permissions.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    Permissions.sol - SKALE Manager
    Copyright (C) 2018-Present SKALE Labs
    @author Artem Payvin

    SKALE Manager is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.17;

import "@skalenetwork/skale-manager-interfaces/IContractManager.sol";
import "@skalenetwork/skale-manager-interfaces/IPermissions.sol";

import "./thirdparty/openzeppelin/AccessControlUpgradeableLegacy.sol";


/**
 * @title Permissions
 * @dev Contract is connected module for Upgradeable approach, knows ContractManager
 */
contract Permissions is AccessControlUpgradeableLegacy, IPermissions {
    using AddressUpgradeable for address;

    IContractManager public contractManager;

    /**
     * @dev Modifier to make a function callable only when caller is the Owner.
     *
     * Requirements:
     *
     * - The caller must be the owner.
     */
    modifier onlyOwner() {
        require(_isOwner(), "Caller is not the owner");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when caller is an Admin.
     *
     * Requirements:
     *
     * - The caller must be an admin.
     */
    modifier onlyAdmin() {
        require(_isAdmin(msg.sender), "Caller is not an admin");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when caller is the Owner
     * or `contractName` contract.
     *
     * Requirements:
     *
     * - The caller must be the owner or `contractName`.
     */
    modifier allow(string memory contractName) {
        require(
            contractManager.getContract(contractName) == msg.sender || _isOwner(),
            "Message sender is invalid");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when caller is the Owner
     * or `contractName1` or `contractName2` contract.
     *
     * Requirements:
     *
     * - The caller must be the owner, `contractName1`, or `contractName2`.
     */
    modifier allowTwo(string memory contractName1, string memory contractName2) {
        require(
            contractManager.getContract(contractName1) == msg.sender ||
            contractManager.getContract(contractName2) == msg.sender ||
            _isOwner(),
            "Message sender is invalid");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when caller is the Owner
     * or `contractName1`, `contractName2`, or `contractName3` contract.
     *
     * Requirements:
     *
     * - The caller must be the owner, `contractName1`, `contractName2`, or
     * `contractName3`.
     */
    modifier allowThree(string memory contractName1, string memory contractName2, string memory contractName3) {
        require(
            contractManager.getContract(contractName1) == msg.sender ||
            contractManager.getContract(contractName2) == msg.sender ||
            contractManager.getContract(contractName3) == msg.sender ||
            _isOwner(),
            "Message sender is invalid");
        _;
    }

    function initialize(address contractManagerAddress) public virtual override initializer {
        AccessControlUpgradeableLegacy.__AccessControl_init();
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setContractManager(contractManagerAddress);
    }

    function _isOwner() internal view returns (bool) {
        return hasRole(DEFAULT_ADMIN_ROLE, msg.sender);
    }

    function _isAdmin(address account) internal view returns (bool) {
        address skaleManagerAddress = contractManager.contracts(keccak256(abi.encodePacked("SkaleManager")));
        if (skaleManagerAddress != address(0)) {
            AccessControlUpgradeableLegacy skaleManager = AccessControlUpgradeableLegacy(skaleManagerAddress);
            return skaleManager.hasRole(keccak256("ADMIN_ROLE"), account) || _isOwner();
        } else {
            return _isOwner();
        }
    }

    function _setContractManager(address contractManagerAddress) private {
        require(contractManagerAddress != address(0), "ContractManager address is not set");
        require(contractManagerAddress.isContract(), "Address is not contract");
        contractManager = IContractManager(contractManagerAddress);
    }
}

File 14 of 26 : FractionUtils.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    FractionUtils.sol - SKALE Manager
    Copyright (C) 2018-Present SKALE Labs
    @author Dmytro Stebaiev

    SKALE Manager is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.17;


library FractionUtils {

    struct Fraction {
        uint numerator;
        uint denominator;
    }

    function createFraction(uint numerator, uint denominator) internal pure returns (Fraction memory) {
        require(denominator > 0, "Division by zero");
        Fraction memory fraction = Fraction({numerator: numerator, denominator: denominator});
        reduceFraction(fraction);
        return fraction;
    }

    function createFraction(uint value) internal pure returns (Fraction memory) {
        return createFraction(value, 1);
    }

    function reduceFraction(Fraction memory fraction) internal pure {
        uint _gcd = gcd(fraction.numerator, fraction.denominator);
        fraction.numerator = fraction.numerator / _gcd;
        fraction.denominator = fraction.denominator / _gcd;
    }

    // numerator - is limited by 7*10^27, we could multiply it numerator * numerator - it would less than 2^256-1
    function multiplyFraction(Fraction memory a, Fraction memory b) internal pure returns (Fraction memory) {
        return createFraction(a.numerator * b.numerator, a.denominator * b.denominator);
    }

    function gcd(uint a, uint b) internal pure returns (uint) {
        uint _a = a;
        uint _b = b;
        if (_b > _a) {
            (_a, _b) = swap(_a, _b);
        }
        while (_b > 0) {
            _a = _a % _b;
            (_a, _b) = swap (_a, _b);
        }
        return _a;
    }

    function swap(uint a, uint b) internal pure returns (uint, uint) {
        return (b, a);
    }
}

File 15 of 26 : MathUtils.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    MathUtils.sol - SKALE Manager
    Copyright (C) 2018-Present SKALE Labs
    @author Dmytro Stebaiev

    SKALE Manager is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.17;


library MathUtils {

    uint constant private _EPS = 1e6;

    event UnderflowError(
        uint a,
        uint b
    );

    function boundedSub(uint256 a, uint256 b) internal returns (uint256) {
        if (a >= b) {
            return a - b;
        } else {
            emit UnderflowError(a, b);
            return 0;
        }
    }

    function boundedSubWithoutEvent(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a >= b) {
            return a - b;
        } else {
            return 0;
        }
    }

    function muchGreater(uint256 a, uint256 b) internal pure returns (bool) {
        assert(type(uint).max - _EPS > b);
        return a > b + _EPS;
    }

    function approximatelyEqual(uint256 a, uint256 b) internal pure returns (bool) {
        if (a > b) {
            return a - b < _EPS;
        } else {
            return b - a < _EPS;
        }
    }
}

File 16 of 26 : PartialDifferences.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    PartialDifferences.sol - SKALE Manager
    Copyright (C) 2018-Present SKALE Labs
    @author Dmytro Stebaiev

    SKALE Manager is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.17;

import "../utils/MathUtils.sol";
import "../utils/FractionUtils.sol";

/**
 * @title Partial Differences Library
 * @dev This library contains functions to manage Partial Differences data
 * structure. Partial Differences is an array of value differences over time.
 *
 * For example: assuming an array [3, 6, 3, 1, 2], partial differences can
 * represent this array as [_, 3, -3, -2, 1].
 *
 * This data structure allows adding values on an open interval with O(1)
 * complexity.
 *
 * For example: add +5 to [3, 6, 3, 1, 2] starting from the second element (3),
 * instead of performing [3, 6, 3+5, 1+5, 2+5] partial differences allows
 * performing [_, 3, -3+5, -2, 1]. The original array can be restored by
 * adding values from partial differences.
 */
library PartialDifferences {
    using MathUtils for uint;

    struct Sequence {
             // month => diff
        mapping (uint => uint) addDiff;
             // month => diff
        mapping (uint => uint) subtractDiff;
             // month => value
        mapping (uint => uint) value;

        uint firstUnprocessedMonth;
        uint lastChangedMonth;
    }

    struct Value {
             // month => diff
        mapping (uint => uint) addDiff;
             // month => diff
        mapping (uint => uint) subtractDiff;

        uint value;
        uint firstUnprocessedMonth;
        uint lastChangedMonth;
    }

    // functions for sequence

    function addToSequence(Sequence storage sequence, uint diff, uint month) internal {
        require(sequence.firstUnprocessedMonth <= month, "Cannot add to the past");
        if (sequence.firstUnprocessedMonth == 0) {
            sequence.firstUnprocessedMonth = month;
        }
        sequence.addDiff[month] = sequence.addDiff[month] + diff;
        if (sequence.lastChangedMonth != month) {
            sequence.lastChangedMonth = month;
        }
    }

    function subtractFromSequence(Sequence storage sequence, uint diff, uint month) internal {
        require(sequence.firstUnprocessedMonth <= month, "Cannot subtract from the past");
        if (sequence.firstUnprocessedMonth == 0) {
            sequence.firstUnprocessedMonth = month;
        }
        sequence.subtractDiff[month] = sequence.subtractDiff[month] + diff;
        if (sequence.lastChangedMonth != month) {
            sequence.lastChangedMonth = month;
        }
    }

    function getAndUpdateValueInSequence(Sequence storage sequence, uint month) internal returns (uint) {
        if (sequence.firstUnprocessedMonth == 0) {
            return 0;
        }

        if (sequence.firstUnprocessedMonth <= month) {
            for (uint i = sequence.firstUnprocessedMonth; i <= month; ++i) {
                uint nextValue = (sequence.value[i - 1] + sequence.addDiff[i]).boundedSub(sequence.subtractDiff[i]);
                if (sequence.value[i] != nextValue) {
                    sequence.value[i] = nextValue;
                }
                if (sequence.addDiff[i] > 0) {
                    delete sequence.addDiff[i];
                }
                if (sequence.subtractDiff[i] > 0) {
                    delete sequence.subtractDiff[i];
                }
            }
            sequence.firstUnprocessedMonth = month + 1;
        }

        return sequence.value[month];
    }

    function reduceSequence(
        Sequence storage sequence,
        FractionUtils.Fraction memory reducingCoefficient,
        uint month) internal
    {
        require(month + 1 >= sequence.firstUnprocessedMonth, "Cannot reduce value in the past");
        require(
            reducingCoefficient.numerator <= reducingCoefficient.denominator,
            "Increasing of values is not implemented");
        if (sequence.firstUnprocessedMonth == 0) {
            return;
        }
        uint value = getAndUpdateValueInSequence(sequence, month);
        if (value.approximatelyEqual(0)) {
            return;
        }

        sequence.value[month] = sequence.value[month]
            * reducingCoefficient.numerator
            / reducingCoefficient.denominator;

        for (uint i = month + 1; i <= sequence.lastChangedMonth; ++i) {
            sequence.subtractDiff[i] = sequence.subtractDiff[i]
                * reducingCoefficient.numerator
                / reducingCoefficient.denominator;
        }
    }

    // functions for value

    function addToValue(Value storage sequence, uint diff, uint month) internal {
        require(sequence.firstUnprocessedMonth <= month, "Cannot add to the past");
        if (sequence.firstUnprocessedMonth == 0) {
            sequence.firstUnprocessedMonth = month;
            sequence.lastChangedMonth = month;
        }
        if (month > sequence.lastChangedMonth) {
            sequence.lastChangedMonth = month;
        }

        if (month >= sequence.firstUnprocessedMonth) {
            sequence.addDiff[month] = sequence.addDiff[month] + diff;
        } else {
            sequence.value = sequence.value + diff;
        }
    }

    function subtractFromValue(Value storage sequence, uint diff, uint month) internal {
        require(sequence.firstUnprocessedMonth <= month + 1, "Cannot subtract from the past");
        if (sequence.firstUnprocessedMonth == 0) {
            sequence.firstUnprocessedMonth = month;
            sequence.lastChangedMonth = month;
        }
        if (month > sequence.lastChangedMonth) {
            sequence.lastChangedMonth = month;
        }

        if (month >= sequence.firstUnprocessedMonth) {
            sequence.subtractDiff[month] = sequence.subtractDiff[month] + diff;
        } else {
            sequence.value = sequence.value.boundedSub(diff);
        }
    }

    function getAndUpdateValue(Value storage sequence, uint month) internal returns (uint) {
        require(
            month + 1 >= sequence.firstUnprocessedMonth,
            "Cannot calculate value in the past");
        if (sequence.firstUnprocessedMonth == 0) {
            return 0;
        }

        if (sequence.firstUnprocessedMonth <= month) {
            uint value = sequence.value;
            for (uint i = sequence.firstUnprocessedMonth; i <= month; ++i) {
                value = (value + sequence.addDiff[i]).boundedSub(sequence.subtractDiff[i]);
                if (sequence.addDiff[i] > 0) {
                    delete sequence.addDiff[i];
                }
                if (sequence.subtractDiff[i] > 0) {
                    delete sequence.subtractDiff[i];
                }
            }
            if (sequence.value != value) {
                sequence.value = value;
            }
            sequence.firstUnprocessedMonth = month + 1;
        }

        return sequence.value;
    }

    function reduceValue(
        Value storage sequence,
        uint amount,
        uint month)
        internal returns (FractionUtils.Fraction memory)
    {
        require(month + 1 >= sequence.firstUnprocessedMonth, "Cannot reduce value in the past");
        if (sequence.firstUnprocessedMonth == 0) {
            return FractionUtils.createFraction(0);
        }
        uint value = getAndUpdateValue(sequence, month);
        if (value.approximatelyEqual(0)) {
            return FractionUtils.createFraction(0);
        }

        uint _amount = amount;
        if (value < amount) {
            _amount = value;
        }

        FractionUtils.Fraction memory reducingCoefficient =
            FractionUtils.createFraction(value.boundedSub(_amount), value);
        reduceValueByCoefficient(sequence, reducingCoefficient, month);
        return reducingCoefficient;
    }

    function reduceValueByCoefficient(
        Value storage sequence,
        FractionUtils.Fraction memory reducingCoefficient,
        uint month)
        internal
    {
        reduceValueByCoefficientAndUpdateSumIfNeeded(
            sequence,
            sequence,
            reducingCoefficient,
            month,
            false);
    }

    function reduceValueByCoefficientAndUpdateSum(
        Value storage sequence,
        Value storage sumSequence,
        FractionUtils.Fraction memory reducingCoefficient,
        uint month) internal
    {
        reduceValueByCoefficientAndUpdateSumIfNeeded(
            sequence,
            sumSequence,
            reducingCoefficient,
            month,
            true);
    }

    function reduceValueByCoefficientAndUpdateSumIfNeeded(
        Value storage sequence,
        Value storage sumSequence,
        FractionUtils.Fraction memory reducingCoefficient,
        uint month,
        bool hasSumSequence) internal
    {
        require(month + 1 >= sequence.firstUnprocessedMonth, "Cannot reduce value in the past");
        if (hasSumSequence) {
            require(month + 1 >= sumSequence.firstUnprocessedMonth, "Cannot reduce value in the past");
        }
        require(
            reducingCoefficient.numerator <= reducingCoefficient.denominator,
            "Increasing of values is not implemented");
        if (sequence.firstUnprocessedMonth == 0) {
            return;
        }
        uint value = getAndUpdateValue(sequence, month);
        if (value.approximatelyEqual(0)) {
            return;
        }

        uint newValue = sequence.value * reducingCoefficient.numerator / reducingCoefficient.denominator;
        if (hasSumSequence) {
            subtractFromValue(sumSequence, sequence.value.boundedSub(newValue), month);
        }
        sequence.value = newValue;

        for (uint i = month + 1; i <= sequence.lastChangedMonth; ++i) {
            uint newDiff = sequence.subtractDiff[i]
                * reducingCoefficient.numerator
                / reducingCoefficient.denominator;
            if (hasSumSequence) {
                sumSequence.subtractDiff[i] = sumSequence.subtractDiff[i]
                    .boundedSub(sequence.subtractDiff[i].boundedSub(newDiff));
            }
            sequence.subtractDiff[i] = newDiff;
        }
    }

    function getValueInSequence(Sequence storage sequence, uint month) internal view returns (uint) {
        if (sequence.firstUnprocessedMonth == 0) {
            return 0;
        }

        if (sequence.firstUnprocessedMonth <= month) {
            uint value = sequence.value[sequence.firstUnprocessedMonth - 1];
            for (uint i = sequence.firstUnprocessedMonth; i <= month; ++i) {
                value = value + sequence.addDiff[i] - sequence.subtractDiff[i];
            }
            return value;
        } else {
            return sequence.value[month];
        }
    }

    function getValuesInSequence(Sequence storage sequence) internal view returns (uint[] memory values) {
        if (sequence.firstUnprocessedMonth == 0) {
            return values;
        }
        uint begin = sequence.firstUnprocessedMonth - 1;
        uint end = sequence.lastChangedMonth + 1;
        if (end <= begin) {
            end = begin + 1;
        }
        values = new uint[](end - begin);
        values[0] = sequence.value[sequence.firstUnprocessedMonth - 1];
        for (uint i = 0; i + 1 < values.length; ++i) {
            uint month = sequence.firstUnprocessedMonth + i;
            values[i + 1] = values[i] + sequence.addDiff[month] - sequence.subtractDiff[month];
        }
    }

    function getValue(Value storage sequence, uint month) internal view returns (uint) {
        require(
            month + 1 >= sequence.firstUnprocessedMonth,
            "Cannot calculate value in the past");
        if (sequence.firstUnprocessedMonth == 0) {
            return 0;
        }

        if (sequence.firstUnprocessedMonth <= month) {
            uint value = sequence.value;
            for (uint i = sequence.firstUnprocessedMonth; i <= month; ++i) {
                value = value + sequence.addDiff[i] - sequence.subtractDiff[i];
            }
            return value;
        } else {
            return sequence.value;
        }
    }

    function getValues(Value storage sequence) internal view returns (uint[] memory values) {
        if (sequence.firstUnprocessedMonth == 0) {
            return values;
        }
        uint begin = sequence.firstUnprocessedMonth - 1;
        uint end = sequence.lastChangedMonth + 1;
        if (end <= begin) {
            end = begin + 1;
        }
        values = new uint[](end - begin);
        values[0] = sequence.value;
        for (uint i = 0; i + 1 < values.length; ++i) {
            uint month = sequence.firstUnprocessedMonth + i;
            values[i + 1] = values[i] + sequence.addDiff[month] - sequence.subtractDiff[month];
        }
    }
}

File 17 of 26 : IRandom.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    IRandom.sol - SKALE Manager Interfaces
    Copyright (C) 2022-Present SKALE Labs
    @author Dmytro Stebaiev

    SKALE Manager Interfaces is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager Interfaces.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;


interface IRandom {
    struct RandomGenerator {
        uint seed;
    }
}

File 18 of 26 : IContractManager.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    IContractManager.sol - SKALE Manager Interfaces
    Copyright (C) 2021-Present SKALE Labs
    @author Dmytro Stebaeiv

    SKALE Manager Interfaces is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager Interfaces.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

interface IContractManager {
    /**
     * @dev Emitted when contract is upgraded.
     */
    event ContractUpgraded(string contractsName, address contractsAddress);

    function initialize() external;
    function setContractsAddress(string calldata contractsName, address newContractsAddress) external;
    function contracts(bytes32 nameHash) external view returns (address);
    function getDelegationPeriodManager() external view returns (address);
    function getBounty() external view returns (address);
    function getValidatorService() external view returns (address);
    function getTimeHelpers() external view returns (address);
    function getConstantsHolder() external view returns (address);
    function getSkaleToken() external view returns (address);
    function getTokenState() external view returns (address);
    function getPunisher() external view returns (address);
    function getContract(string calldata name) external view returns (address);
}

File 19 of 26 : IPermissions.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    IPermissions.sol - SKALE Manager
    Copyright (C) 2018-Present SKALE Labs
    @author Artem Payvin

    SKALE Manager is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

interface IPermissions {
    function initialize(address contractManagerAddress) external;
}

File 20 of 26 : AccessControlUpgradeableLegacy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@skalenetwork/skale-manager-interfaces/thirdparty/openzeppelin/IAccessControlUpgradeableLegacy.sol";
import "./InitializableWithGap.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, _msgSender()));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 */
abstract contract AccessControlUpgradeableLegacy is InitializableWithGap, ContextUpgradeable, IAccessControlUpgradeableLegacy {
    function __AccessControl_init() internal initializer {
        __Context_init_unchained();
        __AccessControl_init_unchained();
    }

    function __AccessControl_init_unchained() internal initializer {


    }

    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;

    struct RoleData {
        EnumerableSetUpgradeable.AddressSet members;
        bytes32 adminRole;
    }

    mapping (bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view override returns (uint256) {
        return _roles[role].members.length();
    }

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view override returns (address) {
        return _roles[role].members.at(index);
    }

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

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) public virtual override {
        require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");

        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) public virtual override {
        require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");

        _revokeRole(role, account);
    }

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

        _revokeRole(role, account);
    }

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

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

    function _grantRole(bytes32 role, address account) private {
        if (_roles[role].members.add(account)) {
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (_roles[role].members.remove(account)) {
            emit RoleRevoked(role, account, _msgSender());
        }
    }

    uint256[49] private __gap;
}

File 21 of 26 : EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (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.
 *
 * [WARNING]
 * ====
 *  Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.
 *  See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 *  In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet.
 * ====
 */
library EnumerableSetUpgradeable {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

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

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

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

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

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

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

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

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

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

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

        /// @solidity memory-safe-assembly
        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;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

File 22 of 26 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

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

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

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

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

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

File 23 of 26 : IAccessControlUpgradeableLegacy.sol
// SPDX-License-Identifier: AGPL-3.0-only

/*
    IAccessControlUpgradeableLegacy.sol - SKALE Manager
    Copyright (C) 2018-Present SKALE Labs
    @author Artem Payvin

    SKALE Manager is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

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

    You should have received a copy of the GNU Affero General Public License
    along with SKALE Manager.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

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

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
    
    function grantRole(bytes32 role, address account) external;
    function revokeRole(bytes32 role, address account) external;
    function renounceRole(bytes32 role, address account) external;
    function hasRole(bytes32 role, address account) external view returns (bool);
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);
    function getRoleAdmin(bytes32 role) external view returns (bytes32);
}

File 24 of 26 : InitializableWithGap.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity ^0.8.7;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";


contract InitializableWithGap is Initializable {
    uint256[50] private ______gap;
}

File 25 of 26 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

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

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

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

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

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

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

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

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

File 26 of 26 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

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

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

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

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"validatorId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Confiscated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"delegationId","type":"uint256"}],"name":"DelegationAccepted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"delegationId","type":"uint256"}],"name":"DelegationProposed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"delegationId","type":"uint256"}],"name":"DelegationRequestCanceledByUser","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"holder","type":"address"},{"indexed":false,"internalType":"uint256","name":"limit","type":"uint256"}],"name":"SlashesProcessed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"delegationId","type":"uint256"}],"name":"UndelegationRequested","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNDELEGATION_PROHIBITION_WINDOW_SECONDS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"delegationId","type":"uint256"}],"name":"acceptPendingDelegation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"delegationId","type":"uint256"}],"name":"cancelPendingDelegation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"validatorId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"confiscate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contractManager","outputs":[{"internalType":"contract IContractManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"validatorId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"delegationPeriod","type":"uint256"},{"internalType":"string","name":"info","type":"string"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"delegations","outputs":[{"internalType":"address","name":"holder","type":"address"},{"internalType":"uint256","name":"validatorId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"delegationPeriod","type":"uint256"},{"internalType":"uint256","name":"created","type":"uint256"},{"internalType":"uint256","name":"started","type":"uint256"},{"internalType":"uint256","name":"finished","type":"uint256"},{"internalType":"string","name":"info","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"delegationsByHolder","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"delegationsByValidator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"}],"name":"getAndUpdateDelegatedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"},{"internalType":"uint256","name":"validatorId","type":"uint256"}],"name":"getAndUpdateDelegatedByHolderToValidatorNow","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"validatorId","type":"uint256"}],"name":"getAndUpdateDelegatedToValidatorNow","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"},{"internalType":"uint256","name":"validatorId","type":"uint256"},{"internalType":"uint256","name":"month","type":"uint256"}],"name":"getAndUpdateEffectiveDelegatedByHolderToValidator","outputs":[{"internalType":"uint256","name":"effectiveDelegated","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"validatorId","type":"uint256"},{"internalType":"uint256","name":"month","type":"uint256"}],"name":"getAndUpdateEffectiveDelegatedToValidator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"}],"name":"getAndUpdateForbiddenForDelegationAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"}],"name":"getAndUpdateLockedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"validatorId","type":"uint256"},{"internalType":"uint256","name":"month","type":"uint256"}],"name":"getDelegatedToValidator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"delegationId","type":"uint256"}],"name":"getDelegation","outputs":[{"components":[{"internalType":"address","name":"holder","type":"address"},{"internalType":"uint256","name":"validatorId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"delegationPeriod","type":"uint256"},{"internalType":"uint256","name":"created","type":"uint256"},{"internalType":"uint256","name":"started","type":"uint256"},{"internalType":"uint256","name":"finished","type":"uint256"},{"internalType":"string","name":"info","type":"string"}],"internalType":"struct IDelegationController.Delegation","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"}],"name":"getDelegationsByHolderLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"validatorId","type":"uint256"}],"name":"getDelegationsByValidatorLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"validatorId","type":"uint256"},{"internalType":"uint256","name":"month","type":"uint256"}],"name":"getEffectiveDelegatedToValidator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"validatorId","type":"uint256"}],"name":"getEffectiveDelegatedValuesByValidator","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"},{"internalType":"uint256","name":"validatorId","type":"uint256"}],"name":"getFirstDelegationMonth","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"}],"name":"getLockedInPendingDelegations","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"delegationId","type":"uint256"}],"name":"getState","outputs":[{"internalType":"enum IDelegationController.State","name":"state","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"}],"name":"hasUnprocessedSlashes","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"contractsAddress","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"}],"name":"processAllSlashes","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"},{"internalType":"uint256","name":"limit","type":"uint256"}],"name":"processSlashes","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"delegationId","type":"uint256"}],"name":"requestUndelegation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50615c4f80620000216000396000f3fe608060405234801561001057600080fd5b50600436106102325760003560e01c80635fd5529311610130578063a217fddf116100b8578063ca15c8731161007c578063ca15c87314610552578063d547741f14610565578063dda641ae14610578578063fa8dacba14610237578063ff1f7799146105a157600080fd5b8063a217fddf146104ea578063b39e12cf146104f2578063b863158514610505578063c4336c1c14610518578063c4d66de81461053f57600080fd5b806391d14854116100ff57806391d14854146104605780639654ff1614610473578063986b5d75146104ad5780639ac1c4ad146104b7578063a0fb4722146104ca57600080fd5b80635fd55293146103fc5780637ce845d01461040f5780638fa6b518146104225780639010d07c1461043557600080fd5b806327040f68116101be5780633d42b1ce116101825780633d42b1ce14610383578063416880b0146103a357806344c9af28146103b657806356574b8c146103d65780635bb12446146103e957600080fd5b806327040f681461031457806327e5455a146103275780632f2ff15d1461033a5780632f7263cd1461034d57806336568abe1461037057600080fd5b80631d703812116102055780631d703812146102a55780631d9c7f0a146102b85780631da42e5e146102cb57806321eb5859146102de578063248a9ca3146102f157600080fd5b80630b975991146102375780630dd357011461025d5780630e01bff81461027d5780631c8a253e14610290575b600080fd5b61024a6102453660046154ee565b6105b4565b6040519081526020015b60405180910390f35b61027061026b36600461550b565b6105c5565b604051610254919061556a565b61024a61028b3660046155d7565b610775565b6102a361029e36600461560c565b61088e565b005b61024a6102b336600461550b565b6108e7565b61024a6102c6366004615638565b6108fa565b6102a36102d9366004615638565b61092b565b6102a36102ec36600461565a565b610dfe565b61024a6102ff36600461550b565b60009081526065602052604090206002015490565b61024a6103223660046154ee565b611215565b6102a361033536600461550b565b611220565b6102a36103483660046156e7565b61165a565b61036061035b3660046154ee565b6116e8565b6040519015158152602001610254565b6102a361037e3660046156e7565b61172d565b61024a61039136600461550b565b60009081526099602052604090205490565b61024a6103b1366004615638565b6117a7565b6103c96103c436600461550b565b611934565b604051610254919061572d565b61024a6103e436600461560c565b611b2a565b61024a6103f7366004615638565b611b46565b6102a361040a3660046154ee565b611b65565b61024a61041d3660046154ee565b611b73565b61024a610430366004615638565b611bca565b610448610443366004615638565b611be2565b6040516001600160a01b039091168152602001610254565b61036061046e3660046156e7565b611bfa565b61024a61048136600461560c565b6001600160a01b0391909116600090815260a46020908152604080832093835260019093019052205490565b61024a6203f48081565b6102a36104c536600461550b565b611c12565b6104dd6104d836600461550b565b611e1e565b6040516102549190615755565b61024a600081565b609754610448906001600160a01b031681565b6102a361051336600461550b565b611e38565b61052b61052636600461550b565b611f5b565b604051610254989796959493929190615799565b6102a361054d3660046154ee565b612047565b61024a61056036600461550b565b61210b565b6102a36105733660046156e7565b612122565b61024a6105863660046154ee565b6001600160a01b03166000908152609a602052604090205490565b61024a6105af36600461560c565b6121a3565b60006105bf826121b7565b92915050565b61061660405180610100016040528060006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001606081525090565b609854829081106106425760405162461bcd60e51b8152600401610639906157ee565b60405180910390fd5b6098838154811061065557610655615825565b9060005260206000209060080201604051806101000160405290816000820160009054906101000a90046001600160a01b03166001600160a01b03166001600160a01b031681526020016001820154815260200160028201548152602001600382015481526020016004820154815260200160058201548152602001600682015481526020016007820180546106ea9061583b565b80601f01602080910402602001604051908101604052809291908181526020018280546107169061583b565b80156107635780601f1061073857610100808354040283529160200191610763565b820191906000526020600020905b81548152906001019060200180831161074657829003601f168201915b50505050508152505091505b50919050565b604080518082018252600b81526a2234b9ba3934b13aba37b960a91b60208201526097549151633581777360e01b815260009233916001600160a01b03909116906335817773906107ca90859060040161586f565b602060405180830381865afa1580156107e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061080b9190615882565b6001600160a01b0316148061082357506108236121d5565b61083f5760405162461bcd60e51b81526004016106399061589f565b600061084a866121e6565b6001600160a01b038716600090815260a160209081526040808320898452909152902090915061087a90856121f3565b925061088581612325565b50509392505050565b6108a061089b8383612534565b612325565b816001600160a01b03167f6a381e190498f9237c995d8cc01bcb4717cc168be3ad2eb12e2a426c664eba85826040516108db91815260200190565b60405180910390a25050565b60006105bf826108f56127f5565b612860565b6099602052816000526040600020818154811061091657600080fd5b90600052602060002001600091509150505481565b6040805180820182526008815267283ab734b9b432b960c11b60208201526097549151633581777360e01b8152909133916001600160a01b039091169063358177739061097c90859060040161586f565b602060405180830381865afa158015610999573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109bd9190615882565b6001600160a01b031614806109d557506109d56121d5565b6109f15760405162461bcd60e51b81526004016106399061589f565b60006109fb6127f5565b6000858152609c6020526040812091925090610a18908584612878565b6000868152609d6020526040812091925090610a3490846121f3565b604080516000808252602080830184528a8252609d9052919091206004015491925090841015610b30576000878152609d6020526040902060040154610a7b908590615902565b67ffffffffffffffff811115610a9357610a936158d6565b604051908082528060200260200182016040528015610abc578160200160208202803683370190505b50905060005b8151811015610b2e576000888152609d6020526040812060010190610ae78388615915565b610af2906001615915565b815260200190815260200160002054828281518110610b1357610b13615825565b6020908102919091010152610b2781615928565b9050610ac2565b505b6000878152609d60205260409020610b4990848661293f565b6000878152609e60205260409020610b62908486612a7a565b6040805160608101825284815260208082018a815292820187815260a280546001810182556000918252935180517faaf4f58de99300cfadc4585755f376d5fa747d5bc561d5bd9d710de1f91bf42d600490960295860155909201517faaf4f58de99300cfadc4585755f376d5fa747d5bc561d5bd9d710de1f91bf42e84015592517faaf4f58de99300cfadc4585755f376d5fa747d5bc561d5bd9d710de1f91bf42f83015591517faaf4f58de99300cfadc4585755f376d5fa747d5bc561d5bd9d710de1f91bf43090910155610c37612bac565b6000898152609d602052604090209091506001600160a01b03821690635a4adb6890610c6390886121f3565b610c6d9086615902565b876040518363ffffffff1660e01b8152600401610c94929190918252602082015260400190565b600060405180830381600087803b158015610cae57600080fd5b505af1158015610cc2573d6000803e3d6000fd5b5050505060005b8251811015610db9576000898152609d602052604081206001600160a01b03841691636ad5a9cf9160010190610cff858b615915565b610d0a906001615915565b815260200190815260200160002054858481518110610d2b57610d2b615825565b6020026020010151610d3d9190615902565b610d47848a615915565b610d52906001615915565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b158015610d9057600080fd5b505af1158015610da4573d6000803e3d6000fd5b5050505080610db290615928565b9050610cc9565b50877fcb143db1425277cb2275934e67a84211c71fe3344bee67d9469ed42067cd137d88604051610dec91815260200190565b60405180910390a25050505050505050565b610e06612c1a565b6001600160a01b031663a795d293846040518263ffffffff1660e01b8152600401610e3391815260200190565b602060405180830381865afa158015610e50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e749190615941565b610ece5760405162461bcd60e51b815260206004820152602560248201527f546869732064656c65676174696f6e20706572696f64206973206e6f7420616c6044820152641b1bddd95960da1b6064820152608401610639565b610ed6612c64565b6040516348b432a760e01b815260048101879052602481018690526001600160a01b0391909116906348b432a79060440160006040518083038186803b158015610f1f57600080fd5b505afa158015610f33573d6000803e3d6000fd5b50505050610f413386612cae565b6000610f4c336121e6565b90506000610f933388888888888080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612dad92505050565b90506000609760009054906101000a90046001600160a01b03166001600160a01b0316639b391a466040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061100e9190615882565b6040516370a0823160e01b81523360048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015611054573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110789190615963565b90506000609760009054906101000a90046001600160a01b03166001600160a01b031663ebd2665f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f39190615882565b604051630b97599160e01b81523360048201526001600160a01b039190911690630b975991906024016020604051808303816000875af115801561113b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115f9190615963565b9050808210156111ce5760405162461bcd60e51b815260206004820152603460248201527f546f6b656e20686f6c64657220646f6573206e6f74206861766520656e6f75676044820152736820746f6b656e7320746f2064656c656761746560601b6064820152608401610639565b6040518381527f839237f8da6208af7e49773f22501b3082aaae94d5b6ce8ee96f117835fe2f679060200160405180910390a161120a84612325565b505050505050505050565b60006105bf82613007565b609854819081106112435760405162461bcd60e51b8152600401610639906157ee565b600461124e83611934565b600681111561125f5761125f615717565b146112ac5760405162461bcd60e51b815260206004820152601b60248201527f43616e6e6f74207265717565737420756e64656c65676174696f6e00000000006044820152606401610639565b60006112b6612c64565b9050336001600160a01b0316609884815481106112d5576112d5615825565b60009182526020909120600890910201546001600160a01b031614806113f357506040516224441f60e71b81523360048201526001600160a01b038216906312220f8090602401602060405180830381865afa158015611339573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061135d9190615941565b80156113f35750604051630ba7341960e11b81523360048201526001600160a01b0382169063174e683290602401602060405180830381865afa1580156113a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113cc9190615963565b609884815481106113df576113df615825565b906000526020600020906008020160010154145b6114515760405162461bcd60e51b815260206004820152602960248201527f5065726d697373696f6e2064656e69656420746f207265717565737420756e6460448201526832b632b3b0ba34b7b760b91b6064820152608401610639565b6114af6098848154811061146757611467615825565b6000918252602090912060089091020154609880546001600160a01b03909216918690811061149857611498615825565b90600052602060002090600802016001015461303f565b6114b833611b65565b6114c1836130e0565b609884815481106114d4576114d4615825565b9060005260206000209060080201600601819055506114f16131db565b6001600160a01b031663568b55b26098858154811061151257611512615825565b9060005260206000209060080201600601546040518263ffffffff1660e01b815260040161154291815260200190565b602060405180830381865afa15801561155f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115839190615963565b6115906203f48042615915565b106116195760405162461bcd60e51b815260206004820152604d60248201527f556e64656c65676174696f6e207265717565737473206d75737420626520736560448201527f6e7420332064617973206265666f72652074686520656e64206f662064656c6560648201526c19d85d1a5bdb881c195c9a5bd9609a1b608482015260a401610639565b61162283613225565b6040518381527fb0142de902382ce87e0ae1e5ec0699b26d25bec2eeb06bca82e1253099b3119c9060200160405180910390a1505050565b6000828152606560205260409020600201546116769033611bfa565b6116da5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60448201526e0818591b5a5b881d1bc819dc985b9d608a1b6064820152608401610639565b6116e48282613587565b5050565b6001600160a01b038116600090815260a46020526040812054151580156105bf575060a2546001600160a01b038316600090815260a360205260409020541092915050565b6001600160a01b038116331461179d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610639565b6116e482826135e0565b6040805180820182526006815265426f756e747960d01b60208083019190915282518084018452600b81526a2234b9ba3934b13aba37b960a91b918101919091526097549251633581777360e01b815260009333916001600160a01b039091169063358177739061181c90869060040161586f565b602060405180830381865afa158015611839573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061185d9190615882565b6001600160a01b031614806118e95750609754604051633581777360e01b815233916001600160a01b03169063358177739061189d90859060040161586f565b602060405180830381865afa1580156118ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118de9190615882565b6001600160a01b0316145b806118f757506118f76121d5565b6119135760405162461bcd60e51b81526004016106399061589f565b6000858152609d6020526040902061192b90856121f3565b95945050505050565b6098546000908290811061195a5760405162461bcd60e51b8152600401610639906157ee565b6098838154811061196d5761196d615825565b906000526020600020906008020160050154600003611a74576098838154811061199957611999615825565b906000526020600020906008020160060154600003611a6b576119ba6131db565b6001600160a01b031663bf64d849609885815481106119db576119db615825565b9060005260206000209060080201600401546040518263ffffffff1660e01b8152600401611a0b91815260200190565b602060405180830381865afa158015611a28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a4c9190615963565b611a546127f5565b03611a62576000915061076f565b6003915061076f565b6002915061076f565b60988381548110611a8757611a87615825565b906000526020600020906008020160050154611aa16127f5565b1015611ab0576001915061076f565b60988381548110611ac357611ac3615825565b906000526020600020906008020160060154600003611ae5576004915061076f565b60988381548110611af857611af8615825565b906000526020600020906008020160060154611b126127f5565b1015611b21576005915061076f565b6006915061076f565b609a602052816000526040600020818154811061091657600080fd5b6000828152609c60205260408120611b5e9083613639565b9392505050565b611b7081600061088e565b50565b600080611b7e6127f5565b6001600160a01b038416600090815260a56020526040902060010154909150811115611bad5750600092915050565b50506001600160a01b0316600090815260a5602052604090205490565b6000828152609d60205260408120611b5e90836136f0565b6000828152606560205260408120611b5e90836137a5565b6000828152606560205260408120611b5e90836137b1565b60985481908110611c355760405162461bcd60e51b8152600401610639906157ee565b60988281548110611c4857611c48615825565b60009182526020909120600890910201546001600160a01b03163314611cc95760405162461bcd60e51b815260206004820152603060248201527f4f6e6c7920746f6b656e20686f6c646572732063616e2063616e63656c20646560448201526f1b1959d85d1a5bdb881c995c5d595cdd60821b6064820152608401610639565b6000611cd483611934565b6006811115611ce557611ce5615717565b14611d585760405162461bcd60e51b815260206004820152603a60248201527f546f6b656e20686f6c6465727320617265206f6e6c792061626c6520746f206360448201527f616e63656c2050524f504f5345442064656c65676174696f6e730000000000006064820152608401610639565b611d606127f5565b60988381548110611d7357611d73615825565b906000526020600020906008020160060181905550611de660988381548110611d9e57611d9e615825565b6000918252602090912060089091020154609880546001600160a01b039092169185908110611dcf57611dcf615825565b9060005260206000209060080201600201546137d3565b6040518281527fc42cff898171c085fa87ecad4869a5fb22753dddf61048199b8c740c2109fb11906020015b60405180910390a15050565b6000818152609d602052604090206060906105bf9061384f565b60985481908110611e5b5760405162461bcd60e51b8152600401610639906157ee565b611e63612c64565b6001600160a01b031663bed5012e3360988581548110611e8557611e85615825565b60009182526020909120600160089092020101546040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381865afa158015611ee2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f069190615941565b611f525760405162461bcd60e51b815260206004820181905260248201527f4e6f207065726d697373696f6e7320746f2061636365707420726571756573746044820152606401610639565b6116e4826139ed565b60988181548110611f6b57600080fd5b6000918252602090912060089091020180546001820154600283015460038401546004850154600586015460068701546007880180546001600160a01b03909816995095979496939592949193909290611fc49061583b565b80601f0160208091040260200160405190810160405280929190818152602001828054611ff09061583b565b801561203d5780601f106120125761010080835404028352916020019161203d565b820191906000526020600020905b81548152906001019060200180831161202057829003601f168201915b5050505050905088565b600054610100900460ff16158080156120675750600054600160ff909116105b806120815750303b158015612081575060005460ff166001145b61209d5760405162461bcd60e51b81526004016106399061597c565b6000805460ff1916600117905580156120c0576000805461ff0019166101001790555b6120c982613e7a565b80156116e4576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001611e12565b60008181526065602052604081206105bf90613f0f565b60008281526065602052604090206002015461213e9033611bfa565b61179d5760405162461bcd60e51b815260206004820152603060248201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60448201526f2061646d696e20746f207265766f6b6560801b6064820152608401610639565b6000611b5e83836121b26127f5565b613f19565b60006121c282611b73565b6121cb83613007565b6105bf9190615915565b60006121e18133611bfa565b905090565b60606105bf826000612534565b60008260030154600003612209575060006105bf565b8183600301541161230e5760038301545b8281116122fc576000818152600180860160209081526040808420549188905283205461227192600289019085906122529088615902565b81526020019081526020016000205461226b9190615915565b90613f46565b6000838152600287016020526040902054909150811461229f57600082815260028601602052604090208190555b600082815260208690526040902054156122c3576000828152602086905260408120555b6000828152600186016020526040902054156122eb5760008281526001860160205260408120555b506122f581615928565b905061221a565b50612308826001615915565b60038401555b506000908152600291909101602052604090205490565b60975460408051636f72c4ab60e01b815290516000926001600160a01b031691636f72c4ab9160048083019260209291908290030181865afa15801561236f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123939190615882565b905060008060005b84518110156124c457826001600160a01b03168582815181106123c0576123c0615825565b6020026020010151600001516001600160a01b03161461248857811561244357604051634458328b60e01b81526001600160a01b03848116600483015260248201849052851690634458328b90604401600060405180830381600087803b15801561242a57600080fd5b505af115801561243e573d6000803e3d6000fd5b505050505b84818151811061245557612455615825565b602002602001015160000151925084818151811061247557612475615825565b60200260200101516020015191506124b4565b84818151811061249a5761249a615825565b602002602001015160200151826124b19190615915565b91505b6124bd81615928565b905061239b565b50801561252e57604051634458328b60e01b81526001600160a01b03838116600483015260248201839052841690634458328b90604401600060405180830381600087803b15801561251557600080fd5b505af1158015612529573d6000803e3d6000fd5b505050505b50505050565b606061253f836116e8565b156105bf576001600160a01b038316600090815260a3602052604090205460a25483158015906125775750806125758584615915565b105b15612589576125868483615915565b90505b6125938282615902565b67ffffffffffffffff8111156125ab576125ab6158d6565b6040519080825280602002602001820160405280156125f057816020015b60408051808201909152600080825260208201528152602001906001900390816125c95790505b509250815b818310156127d457600060a2848154811061261257612612615825565b9060005260206000209060040201600201549050600060a2858154811061263b5761263b615825565b9060005260206000209060040201600301549050600061265c898484613f19565b9050612669816000613fa1565b156127c0576001600160a01b0389166000908152609f6020526040902060a280546126eb929190899081106126a0576126a0615825565b6000918252602080832060408051808201825260049094029091018054845260010154838301526001600160a01b038f16845260a08252808420898552909152909120919085613fd6565b61274b60a2878154811061270157612701615825565b6000918252602080832060408051808201825260049094029091018054845260010154838301526001600160a01b038e16845260a18252808420888552909152909120908461293f565b88876127578689615902565b8151811061276757612767615825565b60209081029190910101516001600160a01b03909116905261279461278d8a8585613f19565b8290613f46565b8761279f8689615902565b815181106127af576127af615825565b602002602001015160200181815250505b505050826127cd90615928565b92506125f5565b506001600160a01b038516600090815260a360205260409020555092915050565b60006127ff6131db565b6001600160a01b031663ddd1b67e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561283c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121e19190615963565b6000828152609c60205260408120611b5e9083613fe4565b6040805180820190915260008082526020820152600384015461289c836001615915565b10156128ba5760405162461bcd60e51b8152600401610639906159ca565b83600301546000036128d7576128d060006140ff565b9050611b5e565b60006128e38584613fe4565b90506128f081600061411e565b15612907576128ff60006140ff565b915050611b5e565b83808210156129135750805b60006129286129228484613f46565b8461414c565b90506129358782876141c0565b9695505050505050565b600383015461294f826001615915565b101561296d5760405162461bcd60e51b8152600401610639906159ca565b6020820151825111156129925760405162461bcd60e51b815260040161063990615a01565b82600301546000036129a357505050565b60006129af84836121f3565b90506129bc81600061411e565b156129c75750505050565b602080840151845160008581526002880190935260409092205490916129ec91615a48565b6129f69190615a75565b6000838152600286016020526040812091909155612a15836001615915565b90505b84600401548111612a735760208085015185516000848152600189019093526040909220549091612a4891615a48565b612a529190615a75565b6000828152600187016020526040902055612a6c81615928565b9050612a18565b5050505050565b8260010154600003612ab65760018381018290556002808501839055600092835260209485526040832084518155939094015190830155910155565b8083600201541115612b185760405162461bcd60e51b815260206004820152602560248201527f43616e6e6f742070757420736c617368696e67206576656e7420696e20746865604482015264081c185cdd60da1b6064820152608401610639565b80836002015403612b7257600081815260208481526040918290208251808401909352805483526001015490820152612b5190836141ce565b60008281526020858152604090912082518155910151600190910155505050565b600081815260208481526040808320855181559185015160018301556002918201839055818601805484529220018290558190555b505050565b6097546040805163f49bff7b60e01b815290516000926001600160a01b03169163f49bff7b9160048083019260209291908290030181865afa158015612bf6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121e19190615882565b609754604080516323f9e0d960e11b815290516000926001600160a01b0316916347f3c1b29160048083019260209291908290030181865afa158015612bf6573d6000803e3d6000fd5b60975460408051639cb83f5760e01b815290516000926001600160a01b031691639cb83f579160048083019260209291908290030181865afa158015612bf6573d6000803e3d6000fd5b6001600160a01b038216600090815260a660209081526040808320848452600101909152902054151580612d615750612ce561420c565b6001600160a01b031663049e41776040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d469190615963565b6001600160a01b038316600090815260a66020526040902054105b6116e45760405162461bcd60e51b815260206004820152601e60248201527f4c696d6974206f662076616c696461746f7273206973207265616368656400006044820152606401610639565b6098805460408051610100810182526001600160a01b03898116825260208201898152928201888152606083018881524260808501908152600060a0860181815260c0870182815260e088018c815260018b018c559a90925286517f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d81460088b0290810180546001600160a01b0319169290981691909117875597517f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d81589015593517f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d81688015591517f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d817870155517f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d81886015590517f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d819850155517f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d81a84015593519293909290917f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d81b0190612f5d9082615ad7565b5050506000858152609960209081526040808320805460018181018355918552838520018590556001600160a01b038a168452609a83529083208054918201815583529120018190556098805461192b919083908110612fbf57612fbf615825565b6000918252602090912060089091020154609880546001600160a01b039092169184908110612ff057612ff0615825565b906000526020600020906008020160020154614256565b6000806130126127f5565b905061301d83611b65565b6001600160a01b0383166000908152609f60205260409020611b5e9082613fe4565b6001600160a01b038216600090815260a660209081526040808320848452600190810190925290912054900361309e576001600160a01b038216600090815260a660205260408120805460019290613098908490615902565b90915550505b6001600160a01b038216600090815260a660209081526040808320848452600190810190925282208054919290916130d7908490615902565b90915550505050565b6000806130eb6127f5565b905060006098848154811061310257613102615825565b906000526020600020906008020160050154905080821015613156576098848154811061313157613131615825565b9060005260206000209060080201600301548161314e9190615915565b949350505050565b60006098858154811061316b5761316b615825565b90600052602060002090600802016003015482846131899190615902565b6131939190615a75565b9050609885815481106131a8576131a8615825565b9060005260206000209060080201600301548160016131c79190615915565b6131d19190615a48565b61192b9083615915565b6097546040805163954b385d60e01b815290516000926001600160a01b03169163954b385d9160048083019260209291908290030181865afa158015612bf6573d6000803e3d6000fd5b6000613230826142f7565b90506132856098838154811061324857613248615825565b906000526020600020906008020160010154826098858154811061326e5761326e615825565b90600052602060002090600802016006015461444b565b6132eb6098838154811061329b5761329b615825565b906000526020600020906008020160000160009054906101000a90046001600160a01b031682609885815481106132d4576132d4615825565b906000526020600020906008020160060154614464565b61336f6098838154811061330157613301615825565b6000918252602090912060089091020154609880546001600160a01b03909216918590811061333257613332615825565b906000526020600020906008020160010154836098868154811061335857613358615825565b906000526020600020906008020160060154614487565b6000613379612c1a565b6001600160a01b031663f5b98f416098858154811061339a5761339a615825565b9060005260206000209060080201600301546040518263ffffffff1660e01b81526004016133ca91815260200190565b602060405180830381865afa1580156133e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061340b9190615963565b6134159083615a48565b905061346a6098848154811061342d5761342d615825565b906000526020600020906008020160010154826098868154811061345357613453615825565b9060005260206000209060080201600601546144b5565b6134ee6098848154811061348057613480615825565b6000918252602090912060089091020154609880546001600160a01b0390921691869081106134b1576134b1615825565b90600052602060002090600802016001015483609887815481106134d7576134d7615825565b9060005260206000209060080201600601546144ce565b6134f6612bac565b6001600160a01b0316635a4adb68826098868154811061351857613518615825565b9060005260206000209060080201600601546040518363ffffffff1660e01b8152600401613550929190918252602082015260400190565b600060405180830381600087803b15801561356a57600080fd5b505af115801561357e573d6000803e3d6000fd5b50505050505050565b600082815260656020526040902061359f90826144fc565b156116e45760405133906001600160a01b0383169084907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d90600090a45050565b60008281526065602052604090206135f89082614511565b156116e45760405133906001600160a01b0383169084907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b90600090a45050565b600382015460009061364c836001615915565b101561366a5760405162461bcd60e51b815260040161063990615b97565b826003015460000361367e575060006105bf565b818360030154116136e557600283015460038401545b8381116136dd57600081815260018601602090815260408083205491889052909120546136c19084615915565b6136cb9190615902565b91506136d681615928565b9050613694565b5090506105bf565b5060028201546105bf565b60008260030154600003613706575060006105bf565b8183600301541161378e5760008360020160006001866003015461372a9190615902565b81526020019081526020016000205490506000846003015490505b8381116136dd57600081815260018601602090815260408083205491889052909120546137729084615915565b61377c9190615902565b915061378781615928565b9050613745565b5060008181526002830160205260409020546105bf565b6000611b5e8383614526565b6001600160a01b03811660009081526001830160205260408120541515611b5e565b60006137dd6127f5565b6001600160a01b038416600090815260a56020526040902060010154909150811461380a5761380a615bd9565b6001600160a01b038316600090815260a5602052604090205461382e908390615902565b6001600160a01b03909316600090815260a560205260409020929092555050565b6060816003015460000361386257919050565b6000600183600301546138759190615902565b905060008360040154600161388a9190615915565b90508181116138a15761389e826001615915565b90505b6138ab8282615902565b67ffffffffffffffff8111156138c3576138c36158d6565b6040519080825280602002602001820160405280156138ec578160200160208202803683370190505b509250836002016000600186600301546139069190615902565b8152602001908152602001600020548360008151811061392857613928615825565b60200260200101818152505060005b8351613944826001615915565b10156139e557600081866003015461395c9190615915565b6000818152600188016020908152604080832054918a9052909120548751929350909187908590811061399157613991615825565b60200260200101516139a39190615915565b6139ad9190615902565b856139b9846001615915565b815181106139c9576139c9615825565b6020908102919091010152506139de81615928565b9050613937565b505050919050565b613a4b60988281548110613a0357613a03615825565b6000918252602090912060089091020154609880546001600160a01b039092169184908110613a3457613a34615825565b906000526020600020906008020160010154612cae565b6000613a5682611934565b90506000816006811115613a6c57613a6c615717565b14613c1f576001816006811115613a8557613a85615717565b1480613aa257506004816006811115613aa057613aa0615717565b145b80613abe57506005816006811115613abc57613abc615717565b145b80613ada57506006816006811115613ad857613ad8615717565b145b15613b385760405162461bcd60e51b815260206004820152602860248201527f5468652064656c65676174696f6e20686173206265656e20616c7265616479206044820152671858d8d95c1d195960c21b6064820152608401610639565b6002816006811115613b4c57613b4c615717565b03613bb35760405162461bcd60e51b815260206004820152603160248201527f5468652064656c65676174696f6e20686173206265656e2063616e63656c6c656044820152703210313c903a37b5b2b7103437b63232b960791b6064820152608401610639565b6003816006811115613bc757613bc7615717565b03613c1f5760405162461bcd60e51b815260206004820152602260248201527f5468652064656c65676174696f6e2072657175657374206973206f7574646174604482015261195960f21b6064820152608401610639565b6000816006811115613c3357613c33615717565b14613c905760405162461bcd60e51b815260206004820152602760248201527f43616e6e6f74207365742064656c65676174696f6e20737461746520746f206160448201526618d8d95c1d195960ca1b6064820152608401610639565b6000613cc760988481548110613ca857613ca8615825565b60009182526020909120600890910201546001600160a01b03166121e6565b9050613cd283614550565b600060988481548110613ce757613ce7615825565b90600052602060002090600802016002015490506000613d05612c1a565b6001600160a01b031663f5b98f4160988781548110613d2657613d26615825565b9060005260206000209060080201600301546040518263ffffffff1660e01b8152600401613d5691815260200190565b602060405180830381865afa158015613d73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d979190615963565b613da19083615a48565b9050613dab612bac565b6001600160a01b0316636ad5a9cf8260988881548110613dcd57613dcd615825565b9060005260206000209060080201600501546040518363ffffffff1660e01b8152600401613e05929190918252602082015260400190565b600060405180830381600087803b158015613e1f57600080fd5b505af1158015613e33573d6000803e3d6000fd5b50505050613e4083612325565b6040518581527fdb0c41de0e1a6e61f3ea29d9618edd8bfe8cb4e041a267c54eec70418341272d9060200160405180910390a15050505050565b600054610100900460ff1615808015613e9a5750600054600160ff909116105b80613eb45750303b158015613eb4575060005460ff166001145b613ed05760405162461bcd60e51b81526004016106399061597c565b6000805460ff191660011790558015613ef3576000805461ff0019166101001790555b613efb6149b6565b613f066000336116da565b6120c982614a88565b60006105bf825490565b6001600160a01b038316600090815260a060209081526040808320858452909152812061314e9083613fe4565b6000818310613f6057613f598284615902565b90506105bf565b60408051848152602081018490527f5b70a077a991facb623c7b2ee44cc539dc6ba345b6636552b8ea97fbbd4d5419910160405180910390a15060006105bf565b600081613fb3620f4240600019615902565b11613fc057613fc0615bd9565b613fcd620f424083615915565b90921192915050565b61252e848484846001614b62565b6003820154600090613ff7836001615915565b10156140155760405162461bcd60e51b815260040161063990615b97565b8260030154600003614029575060006105bf565b818360030154116140f657600283015460038401545b8381116140d05760008181526001860160209081526040808320549188905290912054614071919061226b9085615915565b60008281526020879052604090205490925015614098576000818152602086905260408120555b6000818152600186016020526040902054156140c05760008181526001860160205260408120555b6140c981615928565b905061403f565b50808460020154146140e457600284018190555b6140ef836001615915565b6003850155505b50506002015490565b60408051808201909152600080825260208201526105bf82600161414c565b60008183111561413e57620f42406141368385615902565b1090506105bf565b620f42406141368484615902565b6040805180820190915260008082526020820152600082116141a35760405162461bcd60e51b815260206004820152601060248201526f4469766973696f6e206279207a65726f60801b6044820152606401610639565b6040805180820190915283815260208101839052611b5e81614d23565b612ba7838484846000614b62565b604080518082019091526000808252602082015281518351611b5e916141f391615a48565b836020015185602001516142079190615a48565b61414c565b60975460408051633f2a95e960e21b815290516000926001600160a01b03169163fcaa57a49160048083019260209291908290030181865afa158015612bf6573d6000803e3d6000fd5b60006142606127f5565b6001600160a01b038416600090815260a560205260409020600101549091508111156142a9576001600160a01b0392909216600090815260a56020526040902090815560010155565b6001600160a01b038316600090815260a5602052604090206001015481146142d3576142d3615bd9565b6001600160a01b038316600090815260a5602052604090205461382e908390615915565b6000818152609b6020526040812054609880548391908590811061431d5761431d615825565b906000526020600020906008020160010154905060006098858154811061434657614346615825565b906000526020600020906008020160020154905082600003614385576000828152609e6020526040812060010154935083900361438557949350505050565b825b6000811180156143ba5750609886815481106143a5576143a5615825565b90600052602060002090600802016006015481105b1561444257609886815481106143d2576143d2615825565b9060005260206000209060080201600501548110614421576000838152609e602090815260408083208484529091529020600181015490546144149084615a48565b61441e9190615a75565b91505b6000838152609e602090815260408083209383529290522060020154614387565b50949350505050565b6000838152609c60205260409020612ba7908383614d65565b6001600160a01b0383166000908152609f60205260409020612ba7908383614d65565b6001600160a01b038416600090815260a060209081526040808320868452909152902061252e908383614d65565b6000838152609d60205260409020612ba7908383614e48565b6001600160a01b038416600090815260a160209081526040808320868452909152902061252e908383614e48565b6000611b5e836001600160a01b038416614ef4565b6000611b5e836001600160a01b038416614f43565b600082600001828154811061453d5761453d615825565b9060005260206000200154905092915050565b600061455a6127f5565b9050614567816001615915565b6098838154811061457a5761457a615825565b9060005260206000209060080201600501819055506000609e6000609885815481106145a8576145a8615825565b906000526020600020906008020160010154815260200190815260200160002060020154111561461f57609e6000609884815481106145e9576145e9615825565b60009182526020808320600160089093020191909101548352828101939093526040918201812060020154858252609b90935220555b61467e6098838154811061463557614635615825565b9060005260206000209060080201600101546098848154811061465a5761465a615825565b9060005260206000209060080201600201548360016146799190615915565b615036565b6146e96098838154811061469457614694615825565b6000918252602090912060089091020154609880546001600160a01b0390921691859081106146c5576146c5615825565b9060005260206000209060080201600201548360016146e49190615915565b61504f565b614779609883815481106146ff576146ff615825565b6000918252602090912060089091020154609880546001600160a01b03909216918590811061473057614730615825565b9060005260206000209060080201600101546098858154811061475557614755615825565b9060005260206000209060080201600201548460016147749190615915565b615072565b6147e46098838154811061478f5761478f615825565b6000918252602090912060089091020154609880546001600160a01b0390921691859081106147c0576147c0615825565b9060005260206000209060080201600101548360016147df9190615915565b6150a0565b60006147ee612c1a565b6001600160a01b031663f5b98f416098858154811061480f5761480f615825565b9060005260206000209060080201600301546040518263ffffffff1660e01b815260040161483f91815260200190565b602060405180830381865afa15801561485c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148809190615963565b6098848154811061489357614893615825565b9060005260206000209060080201600201546148af9190615a48565b90506148ec609884815481106148c7576148c7615825565b906000526020600020906008020160010154828460016148e79190615915565b615142565b6149586098848154811061490257614902615825565b6000918252602090912060089091020154609880546001600160a01b03909216918690811061493357614933615825565b906000526020600020906008020160010154838560016149539190615915565b61515b565b612ba76098848154811061496e5761496e615825565b6000918252602090912060089091020154609880546001600160a01b03909216918690811061499f5761499f615825565b906000526020600020906008020160010154615189565b600054610100900460ff16158080156149d65750600054600160ff909116105b806149f05750303b1580156149f0575060005460ff166001145b614a0c5760405162461bcd60e51b81526004016106399061597c565b6000805460ff191660011790558015614a2f576000805461ff0019166101001790555b614a3761521e565b614a3f61528b565b8015611b70576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a150565b6001600160a01b038116614ae95760405162461bcd60e51b815260206004820152602260248201527f436f6e74726163744d616e616765722061646472657373206973206e6f742073604482015261195d60f21b6064820152608401610639565b6001600160a01b0381163b614b405760405162461bcd60e51b815260206004820152601760248201527f41646472657373206973206e6f7420636f6e74726163740000000000000000006044820152606401610639565b609780546001600160a01b0319166001600160a01b0392909216919091179055565b6003850154614b72836001615915565b1015614b905760405162461bcd60e51b8152600401610639906159ca565b8015614bc4576003840154614ba6836001615915565b1015614bc45760405162461bcd60e51b8152600401610639906159ca565b602083015183511115614be95760405162461bcd60e51b815260040161063990615a01565b600385015415612a73576000614bff8684613fe4565b9050614c0c81600061411e565b15614c175750612a73565b60208401518451600288015460009291614c3091615a48565b614c3a9190615a75565b90508215614c6357614c6386614c5d838a60020154613f4690919063ffffffff16565b86614d65565b600287018190556000614c77856001615915565b90505b87600401548111612529576020808701518751600084815260018c019093526040832054614ca89190615a48565b614cb29190615a75565b90508415614d0257600082815260018a016020526040902054614cf090614cd99083613f46565b600084815260018b01602052604090205490613f46565b600083815260018a0160205260409020555b600082815260018a016020526040902055614d1c81615928565b9050614c7a565b6000614d3782600001518360200151615345565b8251909150614d47908290615a75565b82526020820151614d59908290615a75565b60209092019190915250565b614d70816001615915565b83600301541115614dc35760405162461bcd60e51b815260206004820152601d60248201527f43616e6e6f742073756274726163742066726f6d2074686520706173740000006044820152606401610639565b8260030154600003614dde5760038301819055600483018190555b8260040154811115614df257600483018190555b82600301548110614e2f576000818152600184016020526040902054614e19908390615915565b6000828152600185016020526040902055505050565b6002830154614e3e9083613f46565b6002840155505050565b8083600301541115614e9c5760405162461bcd60e51b815260206004820152601d60248201527f43616e6e6f742073756274726163742066726f6d2074686520706173740000006044820152606401610639565b8260030154600003614eb057600383018190555b6000818152600184016020526040902054614ecc908390615915565b600082815260018501602052604090205560048301548114612ba75760048301819055505050565b6000818152600183016020526040812054614f3b575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556105bf565b5060006105bf565b6000818152600183016020526040812054801561502c576000614f67600183615902565b8554909150600090614f7b90600190615902565b9050818114614fe0576000866000018281548110614f9b57614f9b615825565b9060005260206000200154905080876000018481548110614fbe57614fbe615825565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080614ff157614ff1615bef565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506105bf565b60009150506105bf565b6000838152609c60205260409020612ba7908383615373565b6001600160a01b0383166000908152609f60205260409020612ba7908383615373565b6001600160a01b038416600090815260a060209081526040808320868452909152902061252e908383615373565b6001600160a01b038316600090815260a4602052604081205490036150ea576001600160a01b038316600090815260a46020908152604080832084905560a25460a3909252909120555b6001600160a01b038316600090815260a4602090815260408083208584526001019091528120549003612ba7576001600160a01b0392909216600090815260a460209081526040808320938352600190930190522055565b6000838152609d60205260409020612ba7908383615438565b6001600160a01b038416600090815260a160209081526040808320868452909152902061252e908383615438565b6001600160a01b038216600090815260a66020908152604080832084845260010190915281205490036151e5576001600160a01b038216600090815260a6602052604081208054600192906151df908490615915565b90915550505b6001600160a01b038216600090815260a660209081526040808320848452600190810190925282208054919290916130d7908490615915565b600054610100900460ff166152895760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610639565b565b600054610100900460ff16158080156152ab5750600054600160ff909116105b806152c55750303b1580156152c5575060005460ff166001145b6152e15760405162461bcd60e51b81526004016106399061597c565b6000805460ff191660011790558015614a3f576000805461ff0019166101001790558015611b70576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001614a7d565b600082828181111561535357905b801561536b576153638183615c05565b909150615353565b509392505050565b80836003015411156153c05760405162461bcd60e51b815260206004820152601660248201527510d85b9b9bdd08185919081d1bc81d1a19481c185cdd60521b6044820152606401610639565b82600301546000036153db5760038301819055600483018190555b82600401548111156153ef57600483018190555b8260030154811061542857600081815260208490526040902054615414908390615915565b600082815260208590526040902055505050565b818360020154614e3e9190615915565b80836003015411156154855760405162461bcd60e51b815260206004820152601660248201527510d85b9b9bdd08185919081d1bc81d1a19481c185cdd60521b6044820152606401610639565b826003015460000361549957600383018190555b6000818152602084905260409020546154b3908390615915565b60008281526020859052604090205560048301548114612ba75760048301819055505050565b6001600160a01b0381168114611b7057600080fd5b60006020828403121561550057600080fd5b8135611b5e816154d9565b60006020828403121561551d57600080fd5b5035919050565b6000815180845260005b8181101561554a5760208185018101518683018201520161552e565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260018060a01b038251166020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015260a082015160c082015260c082015160e0820152600060e083015161010080818501525061314e610120840182615524565b6000806000606084860312156155ec57600080fd5b83356155f7816154d9565b95602085013595506040909401359392505050565b6000806040838503121561561f57600080fd5b823561562a816154d9565b946020939093013593505050565b6000806040838503121561564b57600080fd5b50508035926020909101359150565b60008060008060006080868803121561567257600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff8082111561569f57600080fd5b818801915088601f8301126156b357600080fd5b8135818111156156c257600080fd5b8960208285010111156156d457600080fd5b9699959850939650602001949392505050565b600080604083850312156156fa57600080fd5b82359150602083013561570c816154d9565b809150509250929050565b634e487b7160e01b600052602160045260246000fd5b602081016007831061574f57634e487b7160e01b600052602160045260246000fd5b91905290565b6020808252825182820181905260009190848201906040850190845b8181101561578d57835183529284019291840191600101615771565b50909695505050505050565b600061010060018060a01b038b1683528960208401528860408401528760608401528660808401528560a08401528460c08401528060e08401526157df81840185615524565b9b9a5050505050505050505050565b60208082526019908201527f44656c65676174696f6e20646f6573206e6f7420657869737400000000000000604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600181811c9082168061584f57607f821691505b60208210810361076f57634e487b7160e01b600052602260045260246000fd5b602081526000611b5e6020830184615524565b60006020828403121561589457600080fd5b8151611b5e816154d9565b60208082526019908201527f4d6573736167652073656e64657220697320696e76616c696400000000000000604082015260600190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b818103818111156105bf576105bf6158ec565b808201808211156105bf576105bf6158ec565b60006001820161593a5761593a6158ec565b5060010190565b60006020828403121561595357600080fd5b81518015158114611b5e57600080fd5b60006020828403121561597557600080fd5b5051919050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252601f908201527f43616e6e6f74207265647563652076616c756520696e20746865207061737400604082015260600190565b60208082526027908201527f496e6372656173696e67206f662076616c756573206973206e6f7420696d706c604082015266195b595b9d195960ca1b606082015260800190565b80820281158282048414176105bf576105bf6158ec565b634e487b7160e01b600052601260045260246000fd5b600082615a8457615a84615a5f565b500490565b601f821115612ba757600081815260208120601f850160051c81016020861015615ab05750805b601f850160051c820191505b81811015615acf57828155600101615abc565b505050505050565b815167ffffffffffffffff811115615af157615af16158d6565b615b0581615aff845461583b565b84615a89565b602080601f831160018114615b3a5760008415615b225750858301515b600019600386901b1c1916600185901b178555615acf565b600085815260208120601f198616915b82811015615b6957888601518255948401946001909101908401615b4a565b5085821015615b875787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60208082526022908201527f43616e6e6f742063616c63756c6174652076616c756520696e207468652070616040820152611cdd60f21b606082015260800190565b634e487b7160e01b600052600160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b600082615c1457615c14615a5f565b50069056fea2646970667358221220b5203e3d13d9b370c9cff0102989782b28d069331c2307b0c8ca6d6595de1de764736f6c63430008110033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102325760003560e01c80635fd5529311610130578063a217fddf116100b8578063ca15c8731161007c578063ca15c87314610552578063d547741f14610565578063dda641ae14610578578063fa8dacba14610237578063ff1f7799146105a157600080fd5b8063a217fddf146104ea578063b39e12cf146104f2578063b863158514610505578063c4336c1c14610518578063c4d66de81461053f57600080fd5b806391d14854116100ff57806391d14854146104605780639654ff1614610473578063986b5d75146104ad5780639ac1c4ad146104b7578063a0fb4722146104ca57600080fd5b80635fd55293146103fc5780637ce845d01461040f5780638fa6b518146104225780639010d07c1461043557600080fd5b806327040f68116101be5780633d42b1ce116101825780633d42b1ce14610383578063416880b0146103a357806344c9af28146103b657806356574b8c146103d65780635bb12446146103e957600080fd5b806327040f681461031457806327e5455a146103275780632f2ff15d1461033a5780632f7263cd1461034d57806336568abe1461037057600080fd5b80631d703812116102055780631d703812146102a55780631d9c7f0a146102b85780631da42e5e146102cb57806321eb5859146102de578063248a9ca3146102f157600080fd5b80630b975991146102375780630dd357011461025d5780630e01bff81461027d5780631c8a253e14610290575b600080fd5b61024a6102453660046154ee565b6105b4565b6040519081526020015b60405180910390f35b61027061026b36600461550b565b6105c5565b604051610254919061556a565b61024a61028b3660046155d7565b610775565b6102a361029e36600461560c565b61088e565b005b61024a6102b336600461550b565b6108e7565b61024a6102c6366004615638565b6108fa565b6102a36102d9366004615638565b61092b565b6102a36102ec36600461565a565b610dfe565b61024a6102ff36600461550b565b60009081526065602052604090206002015490565b61024a6103223660046154ee565b611215565b6102a361033536600461550b565b611220565b6102a36103483660046156e7565b61165a565b61036061035b3660046154ee565b6116e8565b6040519015158152602001610254565b6102a361037e3660046156e7565b61172d565b61024a61039136600461550b565b60009081526099602052604090205490565b61024a6103b1366004615638565b6117a7565b6103c96103c436600461550b565b611934565b604051610254919061572d565b61024a6103e436600461560c565b611b2a565b61024a6103f7366004615638565b611b46565b6102a361040a3660046154ee565b611b65565b61024a61041d3660046154ee565b611b73565b61024a610430366004615638565b611bca565b610448610443366004615638565b611be2565b6040516001600160a01b039091168152602001610254565b61036061046e3660046156e7565b611bfa565b61024a61048136600461560c565b6001600160a01b0391909116600090815260a46020908152604080832093835260019093019052205490565b61024a6203f48081565b6102a36104c536600461550b565b611c12565b6104dd6104d836600461550b565b611e1e565b6040516102549190615755565b61024a600081565b609754610448906001600160a01b031681565b6102a361051336600461550b565b611e38565b61052b61052636600461550b565b611f5b565b604051610254989796959493929190615799565b6102a361054d3660046154ee565b612047565b61024a61056036600461550b565b61210b565b6102a36105733660046156e7565b612122565b61024a6105863660046154ee565b6001600160a01b03166000908152609a602052604090205490565b61024a6105af36600461560c565b6121a3565b60006105bf826121b7565b92915050565b61061660405180610100016040528060006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001606081525090565b609854829081106106425760405162461bcd60e51b8152600401610639906157ee565b60405180910390fd5b6098838154811061065557610655615825565b9060005260206000209060080201604051806101000160405290816000820160009054906101000a90046001600160a01b03166001600160a01b03166001600160a01b031681526020016001820154815260200160028201548152602001600382015481526020016004820154815260200160058201548152602001600682015481526020016007820180546106ea9061583b565b80601f01602080910402602001604051908101604052809291908181526020018280546107169061583b565b80156107635780601f1061073857610100808354040283529160200191610763565b820191906000526020600020905b81548152906001019060200180831161074657829003601f168201915b50505050508152505091505b50919050565b604080518082018252600b81526a2234b9ba3934b13aba37b960a91b60208201526097549151633581777360e01b815260009233916001600160a01b03909116906335817773906107ca90859060040161586f565b602060405180830381865afa1580156107e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061080b9190615882565b6001600160a01b0316148061082357506108236121d5565b61083f5760405162461bcd60e51b81526004016106399061589f565b600061084a866121e6565b6001600160a01b038716600090815260a160209081526040808320898452909152902090915061087a90856121f3565b925061088581612325565b50509392505050565b6108a061089b8383612534565b612325565b816001600160a01b03167f6a381e190498f9237c995d8cc01bcb4717cc168be3ad2eb12e2a426c664eba85826040516108db91815260200190565b60405180910390a25050565b60006105bf826108f56127f5565b612860565b6099602052816000526040600020818154811061091657600080fd5b90600052602060002001600091509150505481565b6040805180820182526008815267283ab734b9b432b960c11b60208201526097549151633581777360e01b8152909133916001600160a01b039091169063358177739061097c90859060040161586f565b602060405180830381865afa158015610999573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109bd9190615882565b6001600160a01b031614806109d557506109d56121d5565b6109f15760405162461bcd60e51b81526004016106399061589f565b60006109fb6127f5565b6000858152609c6020526040812091925090610a18908584612878565b6000868152609d6020526040812091925090610a3490846121f3565b604080516000808252602080830184528a8252609d9052919091206004015491925090841015610b30576000878152609d6020526040902060040154610a7b908590615902565b67ffffffffffffffff811115610a9357610a936158d6565b604051908082528060200260200182016040528015610abc578160200160208202803683370190505b50905060005b8151811015610b2e576000888152609d6020526040812060010190610ae78388615915565b610af2906001615915565b815260200190815260200160002054828281518110610b1357610b13615825565b6020908102919091010152610b2781615928565b9050610ac2565b505b6000878152609d60205260409020610b4990848661293f565b6000878152609e60205260409020610b62908486612a7a565b6040805160608101825284815260208082018a815292820187815260a280546001810182556000918252935180517faaf4f58de99300cfadc4585755f376d5fa747d5bc561d5bd9d710de1f91bf42d600490960295860155909201517faaf4f58de99300cfadc4585755f376d5fa747d5bc561d5bd9d710de1f91bf42e84015592517faaf4f58de99300cfadc4585755f376d5fa747d5bc561d5bd9d710de1f91bf42f83015591517faaf4f58de99300cfadc4585755f376d5fa747d5bc561d5bd9d710de1f91bf43090910155610c37612bac565b6000898152609d602052604090209091506001600160a01b03821690635a4adb6890610c6390886121f3565b610c6d9086615902565b876040518363ffffffff1660e01b8152600401610c94929190918252602082015260400190565b600060405180830381600087803b158015610cae57600080fd5b505af1158015610cc2573d6000803e3d6000fd5b5050505060005b8251811015610db9576000898152609d602052604081206001600160a01b03841691636ad5a9cf9160010190610cff858b615915565b610d0a906001615915565b815260200190815260200160002054858481518110610d2b57610d2b615825565b6020026020010151610d3d9190615902565b610d47848a615915565b610d52906001615915565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b158015610d9057600080fd5b505af1158015610da4573d6000803e3d6000fd5b5050505080610db290615928565b9050610cc9565b50877fcb143db1425277cb2275934e67a84211c71fe3344bee67d9469ed42067cd137d88604051610dec91815260200190565b60405180910390a25050505050505050565b610e06612c1a565b6001600160a01b031663a795d293846040518263ffffffff1660e01b8152600401610e3391815260200190565b602060405180830381865afa158015610e50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e749190615941565b610ece5760405162461bcd60e51b815260206004820152602560248201527f546869732064656c65676174696f6e20706572696f64206973206e6f7420616c6044820152641b1bddd95960da1b6064820152608401610639565b610ed6612c64565b6040516348b432a760e01b815260048101879052602481018690526001600160a01b0391909116906348b432a79060440160006040518083038186803b158015610f1f57600080fd5b505afa158015610f33573d6000803e3d6000fd5b50505050610f413386612cae565b6000610f4c336121e6565b90506000610f933388888888888080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612dad92505050565b90506000609760009054906101000a90046001600160a01b03166001600160a01b0316639b391a466040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061100e9190615882565b6040516370a0823160e01b81523360048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015611054573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110789190615963565b90506000609760009054906101000a90046001600160a01b03166001600160a01b031663ebd2665f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f39190615882565b604051630b97599160e01b81523360048201526001600160a01b039190911690630b975991906024016020604051808303816000875af115801561113b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115f9190615963565b9050808210156111ce5760405162461bcd60e51b815260206004820152603460248201527f546f6b656e20686f6c64657220646f6573206e6f74206861766520656e6f75676044820152736820746f6b656e7320746f2064656c656761746560601b6064820152608401610639565b6040518381527f839237f8da6208af7e49773f22501b3082aaae94d5b6ce8ee96f117835fe2f679060200160405180910390a161120a84612325565b505050505050505050565b60006105bf82613007565b609854819081106112435760405162461bcd60e51b8152600401610639906157ee565b600461124e83611934565b600681111561125f5761125f615717565b146112ac5760405162461bcd60e51b815260206004820152601b60248201527f43616e6e6f74207265717565737420756e64656c65676174696f6e00000000006044820152606401610639565b60006112b6612c64565b9050336001600160a01b0316609884815481106112d5576112d5615825565b60009182526020909120600890910201546001600160a01b031614806113f357506040516224441f60e71b81523360048201526001600160a01b038216906312220f8090602401602060405180830381865afa158015611339573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061135d9190615941565b80156113f35750604051630ba7341960e11b81523360048201526001600160a01b0382169063174e683290602401602060405180830381865afa1580156113a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113cc9190615963565b609884815481106113df576113df615825565b906000526020600020906008020160010154145b6114515760405162461bcd60e51b815260206004820152602960248201527f5065726d697373696f6e2064656e69656420746f207265717565737420756e6460448201526832b632b3b0ba34b7b760b91b6064820152608401610639565b6114af6098848154811061146757611467615825565b6000918252602090912060089091020154609880546001600160a01b03909216918690811061149857611498615825565b90600052602060002090600802016001015461303f565b6114b833611b65565b6114c1836130e0565b609884815481106114d4576114d4615825565b9060005260206000209060080201600601819055506114f16131db565b6001600160a01b031663568b55b26098858154811061151257611512615825565b9060005260206000209060080201600601546040518263ffffffff1660e01b815260040161154291815260200190565b602060405180830381865afa15801561155f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115839190615963565b6115906203f48042615915565b106116195760405162461bcd60e51b815260206004820152604d60248201527f556e64656c65676174696f6e207265717565737473206d75737420626520736560448201527f6e7420332064617973206265666f72652074686520656e64206f662064656c6560648201526c19d85d1a5bdb881c195c9a5bd9609a1b608482015260a401610639565b61162283613225565b6040518381527fb0142de902382ce87e0ae1e5ec0699b26d25bec2eeb06bca82e1253099b3119c9060200160405180910390a1505050565b6000828152606560205260409020600201546116769033611bfa565b6116da5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60448201526e0818591b5a5b881d1bc819dc985b9d608a1b6064820152608401610639565b6116e48282613587565b5050565b6001600160a01b038116600090815260a46020526040812054151580156105bf575060a2546001600160a01b038316600090815260a360205260409020541092915050565b6001600160a01b038116331461179d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610639565b6116e482826135e0565b6040805180820182526006815265426f756e747960d01b60208083019190915282518084018452600b81526a2234b9ba3934b13aba37b960a91b918101919091526097549251633581777360e01b815260009333916001600160a01b039091169063358177739061181c90869060040161586f565b602060405180830381865afa158015611839573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061185d9190615882565b6001600160a01b031614806118e95750609754604051633581777360e01b815233916001600160a01b03169063358177739061189d90859060040161586f565b602060405180830381865afa1580156118ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118de9190615882565b6001600160a01b0316145b806118f757506118f76121d5565b6119135760405162461bcd60e51b81526004016106399061589f565b6000858152609d6020526040902061192b90856121f3565b95945050505050565b6098546000908290811061195a5760405162461bcd60e51b8152600401610639906157ee565b6098838154811061196d5761196d615825565b906000526020600020906008020160050154600003611a74576098838154811061199957611999615825565b906000526020600020906008020160060154600003611a6b576119ba6131db565b6001600160a01b031663bf64d849609885815481106119db576119db615825565b9060005260206000209060080201600401546040518263ffffffff1660e01b8152600401611a0b91815260200190565b602060405180830381865afa158015611a28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a4c9190615963565b611a546127f5565b03611a62576000915061076f565b6003915061076f565b6002915061076f565b60988381548110611a8757611a87615825565b906000526020600020906008020160050154611aa16127f5565b1015611ab0576001915061076f565b60988381548110611ac357611ac3615825565b906000526020600020906008020160060154600003611ae5576004915061076f565b60988381548110611af857611af8615825565b906000526020600020906008020160060154611b126127f5565b1015611b21576005915061076f565b6006915061076f565b609a602052816000526040600020818154811061091657600080fd5b6000828152609c60205260408120611b5e9083613639565b9392505050565b611b7081600061088e565b50565b600080611b7e6127f5565b6001600160a01b038416600090815260a56020526040902060010154909150811115611bad5750600092915050565b50506001600160a01b0316600090815260a5602052604090205490565b6000828152609d60205260408120611b5e90836136f0565b6000828152606560205260408120611b5e90836137a5565b6000828152606560205260408120611b5e90836137b1565b60985481908110611c355760405162461bcd60e51b8152600401610639906157ee565b60988281548110611c4857611c48615825565b60009182526020909120600890910201546001600160a01b03163314611cc95760405162461bcd60e51b815260206004820152603060248201527f4f6e6c7920746f6b656e20686f6c646572732063616e2063616e63656c20646560448201526f1b1959d85d1a5bdb881c995c5d595cdd60821b6064820152608401610639565b6000611cd483611934565b6006811115611ce557611ce5615717565b14611d585760405162461bcd60e51b815260206004820152603a60248201527f546f6b656e20686f6c6465727320617265206f6e6c792061626c6520746f206360448201527f616e63656c2050524f504f5345442064656c65676174696f6e730000000000006064820152608401610639565b611d606127f5565b60988381548110611d7357611d73615825565b906000526020600020906008020160060181905550611de660988381548110611d9e57611d9e615825565b6000918252602090912060089091020154609880546001600160a01b039092169185908110611dcf57611dcf615825565b9060005260206000209060080201600201546137d3565b6040518281527fc42cff898171c085fa87ecad4869a5fb22753dddf61048199b8c740c2109fb11906020015b60405180910390a15050565b6000818152609d602052604090206060906105bf9061384f565b60985481908110611e5b5760405162461bcd60e51b8152600401610639906157ee565b611e63612c64565b6001600160a01b031663bed5012e3360988581548110611e8557611e85615825565b60009182526020909120600160089092020101546040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381865afa158015611ee2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f069190615941565b611f525760405162461bcd60e51b815260206004820181905260248201527f4e6f207065726d697373696f6e7320746f2061636365707420726571756573746044820152606401610639565b6116e4826139ed565b60988181548110611f6b57600080fd5b6000918252602090912060089091020180546001820154600283015460038401546004850154600586015460068701546007880180546001600160a01b03909816995095979496939592949193909290611fc49061583b565b80601f0160208091040260200160405190810160405280929190818152602001828054611ff09061583b565b801561203d5780601f106120125761010080835404028352916020019161203d565b820191906000526020600020905b81548152906001019060200180831161202057829003601f168201915b5050505050905088565b600054610100900460ff16158080156120675750600054600160ff909116105b806120815750303b158015612081575060005460ff166001145b61209d5760405162461bcd60e51b81526004016106399061597c565b6000805460ff1916600117905580156120c0576000805461ff0019166101001790555b6120c982613e7a565b80156116e4576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001611e12565b60008181526065602052604081206105bf90613f0f565b60008281526065602052604090206002015461213e9033611bfa565b61179d5760405162461bcd60e51b815260206004820152603060248201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60448201526f2061646d696e20746f207265766f6b6560801b6064820152608401610639565b6000611b5e83836121b26127f5565b613f19565b60006121c282611b73565b6121cb83613007565b6105bf9190615915565b60006121e18133611bfa565b905090565b60606105bf826000612534565b60008260030154600003612209575060006105bf565b8183600301541161230e5760038301545b8281116122fc576000818152600180860160209081526040808420549188905283205461227192600289019085906122529088615902565b81526020019081526020016000205461226b9190615915565b90613f46565b6000838152600287016020526040902054909150811461229f57600082815260028601602052604090208190555b600082815260208690526040902054156122c3576000828152602086905260408120555b6000828152600186016020526040902054156122eb5760008281526001860160205260408120555b506122f581615928565b905061221a565b50612308826001615915565b60038401555b506000908152600291909101602052604090205490565b60975460408051636f72c4ab60e01b815290516000926001600160a01b031691636f72c4ab9160048083019260209291908290030181865afa15801561236f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123939190615882565b905060008060005b84518110156124c457826001600160a01b03168582815181106123c0576123c0615825565b6020026020010151600001516001600160a01b03161461248857811561244357604051634458328b60e01b81526001600160a01b03848116600483015260248201849052851690634458328b90604401600060405180830381600087803b15801561242a57600080fd5b505af115801561243e573d6000803e3d6000fd5b505050505b84818151811061245557612455615825565b602002602001015160000151925084818151811061247557612475615825565b60200260200101516020015191506124b4565b84818151811061249a5761249a615825565b602002602001015160200151826124b19190615915565b91505b6124bd81615928565b905061239b565b50801561252e57604051634458328b60e01b81526001600160a01b03838116600483015260248201839052841690634458328b90604401600060405180830381600087803b15801561251557600080fd5b505af1158015612529573d6000803e3d6000fd5b505050505b50505050565b606061253f836116e8565b156105bf576001600160a01b038316600090815260a3602052604090205460a25483158015906125775750806125758584615915565b105b15612589576125868483615915565b90505b6125938282615902565b67ffffffffffffffff8111156125ab576125ab6158d6565b6040519080825280602002602001820160405280156125f057816020015b60408051808201909152600080825260208201528152602001906001900390816125c95790505b509250815b818310156127d457600060a2848154811061261257612612615825565b9060005260206000209060040201600201549050600060a2858154811061263b5761263b615825565b9060005260206000209060040201600301549050600061265c898484613f19565b9050612669816000613fa1565b156127c0576001600160a01b0389166000908152609f6020526040902060a280546126eb929190899081106126a0576126a0615825565b6000918252602080832060408051808201825260049094029091018054845260010154838301526001600160a01b038f16845260a08252808420898552909152909120919085613fd6565b61274b60a2878154811061270157612701615825565b6000918252602080832060408051808201825260049094029091018054845260010154838301526001600160a01b038e16845260a18252808420888552909152909120908461293f565b88876127578689615902565b8151811061276757612767615825565b60209081029190910101516001600160a01b03909116905261279461278d8a8585613f19565b8290613f46565b8761279f8689615902565b815181106127af576127af615825565b602002602001015160200181815250505b505050826127cd90615928565b92506125f5565b506001600160a01b038516600090815260a360205260409020555092915050565b60006127ff6131db565b6001600160a01b031663ddd1b67e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561283c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121e19190615963565b6000828152609c60205260408120611b5e9083613fe4565b6040805180820190915260008082526020820152600384015461289c836001615915565b10156128ba5760405162461bcd60e51b8152600401610639906159ca565b83600301546000036128d7576128d060006140ff565b9050611b5e565b60006128e38584613fe4565b90506128f081600061411e565b15612907576128ff60006140ff565b915050611b5e565b83808210156129135750805b60006129286129228484613f46565b8461414c565b90506129358782876141c0565b9695505050505050565b600383015461294f826001615915565b101561296d5760405162461bcd60e51b8152600401610639906159ca565b6020820151825111156129925760405162461bcd60e51b815260040161063990615a01565b82600301546000036129a357505050565b60006129af84836121f3565b90506129bc81600061411e565b156129c75750505050565b602080840151845160008581526002880190935260409092205490916129ec91615a48565b6129f69190615a75565b6000838152600286016020526040812091909155612a15836001615915565b90505b84600401548111612a735760208085015185516000848152600189019093526040909220549091612a4891615a48565b612a529190615a75565b6000828152600187016020526040902055612a6c81615928565b9050612a18565b5050505050565b8260010154600003612ab65760018381018290556002808501839055600092835260209485526040832084518155939094015190830155910155565b8083600201541115612b185760405162461bcd60e51b815260206004820152602560248201527f43616e6e6f742070757420736c617368696e67206576656e7420696e20746865604482015264081c185cdd60da1b6064820152608401610639565b80836002015403612b7257600081815260208481526040918290208251808401909352805483526001015490820152612b5190836141ce565b60008281526020858152604090912082518155910151600190910155505050565b600081815260208481526040808320855181559185015160018301556002918201839055818601805484529220018290558190555b505050565b6097546040805163f49bff7b60e01b815290516000926001600160a01b03169163f49bff7b9160048083019260209291908290030181865afa158015612bf6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121e19190615882565b609754604080516323f9e0d960e11b815290516000926001600160a01b0316916347f3c1b29160048083019260209291908290030181865afa158015612bf6573d6000803e3d6000fd5b60975460408051639cb83f5760e01b815290516000926001600160a01b031691639cb83f579160048083019260209291908290030181865afa158015612bf6573d6000803e3d6000fd5b6001600160a01b038216600090815260a660209081526040808320848452600101909152902054151580612d615750612ce561420c565b6001600160a01b031663049e41776040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d469190615963565b6001600160a01b038316600090815260a66020526040902054105b6116e45760405162461bcd60e51b815260206004820152601e60248201527f4c696d6974206f662076616c696461746f7273206973207265616368656400006044820152606401610639565b6098805460408051610100810182526001600160a01b03898116825260208201898152928201888152606083018881524260808501908152600060a0860181815260c0870182815260e088018c815260018b018c559a90925286517f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d81460088b0290810180546001600160a01b0319169290981691909117875597517f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d81589015593517f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d81688015591517f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d817870155517f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d81886015590517f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d819850155517f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d81a84015593519293909290917f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d81b0190612f5d9082615ad7565b5050506000858152609960209081526040808320805460018181018355918552838520018590556001600160a01b038a168452609a83529083208054918201815583529120018190556098805461192b919083908110612fbf57612fbf615825565b6000918252602090912060089091020154609880546001600160a01b039092169184908110612ff057612ff0615825565b906000526020600020906008020160020154614256565b6000806130126127f5565b905061301d83611b65565b6001600160a01b0383166000908152609f60205260409020611b5e9082613fe4565b6001600160a01b038216600090815260a660209081526040808320848452600190810190925290912054900361309e576001600160a01b038216600090815260a660205260408120805460019290613098908490615902565b90915550505b6001600160a01b038216600090815260a660209081526040808320848452600190810190925282208054919290916130d7908490615902565b90915550505050565b6000806130eb6127f5565b905060006098848154811061310257613102615825565b906000526020600020906008020160050154905080821015613156576098848154811061313157613131615825565b9060005260206000209060080201600301548161314e9190615915565b949350505050565b60006098858154811061316b5761316b615825565b90600052602060002090600802016003015482846131899190615902565b6131939190615a75565b9050609885815481106131a8576131a8615825565b9060005260206000209060080201600301548160016131c79190615915565b6131d19190615a48565b61192b9083615915565b6097546040805163954b385d60e01b815290516000926001600160a01b03169163954b385d9160048083019260209291908290030181865afa158015612bf6573d6000803e3d6000fd5b6000613230826142f7565b90506132856098838154811061324857613248615825565b906000526020600020906008020160010154826098858154811061326e5761326e615825565b90600052602060002090600802016006015461444b565b6132eb6098838154811061329b5761329b615825565b906000526020600020906008020160000160009054906101000a90046001600160a01b031682609885815481106132d4576132d4615825565b906000526020600020906008020160060154614464565b61336f6098838154811061330157613301615825565b6000918252602090912060089091020154609880546001600160a01b03909216918590811061333257613332615825565b906000526020600020906008020160010154836098868154811061335857613358615825565b906000526020600020906008020160060154614487565b6000613379612c1a565b6001600160a01b031663f5b98f416098858154811061339a5761339a615825565b9060005260206000209060080201600301546040518263ffffffff1660e01b81526004016133ca91815260200190565b602060405180830381865afa1580156133e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061340b9190615963565b6134159083615a48565b905061346a6098848154811061342d5761342d615825565b906000526020600020906008020160010154826098868154811061345357613453615825565b9060005260206000209060080201600601546144b5565b6134ee6098848154811061348057613480615825565b6000918252602090912060089091020154609880546001600160a01b0390921691869081106134b1576134b1615825565b90600052602060002090600802016001015483609887815481106134d7576134d7615825565b9060005260206000209060080201600601546144ce565b6134f6612bac565b6001600160a01b0316635a4adb68826098868154811061351857613518615825565b9060005260206000209060080201600601546040518363ffffffff1660e01b8152600401613550929190918252602082015260400190565b600060405180830381600087803b15801561356a57600080fd5b505af115801561357e573d6000803e3d6000fd5b50505050505050565b600082815260656020526040902061359f90826144fc565b156116e45760405133906001600160a01b0383169084907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d90600090a45050565b60008281526065602052604090206135f89082614511565b156116e45760405133906001600160a01b0383169084907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b90600090a45050565b600382015460009061364c836001615915565b101561366a5760405162461bcd60e51b815260040161063990615b97565b826003015460000361367e575060006105bf565b818360030154116136e557600283015460038401545b8381116136dd57600081815260018601602090815260408083205491889052909120546136c19084615915565b6136cb9190615902565b91506136d681615928565b9050613694565b5090506105bf565b5060028201546105bf565b60008260030154600003613706575060006105bf565b8183600301541161378e5760008360020160006001866003015461372a9190615902565b81526020019081526020016000205490506000846003015490505b8381116136dd57600081815260018601602090815260408083205491889052909120546137729084615915565b61377c9190615902565b915061378781615928565b9050613745565b5060008181526002830160205260409020546105bf565b6000611b5e8383614526565b6001600160a01b03811660009081526001830160205260408120541515611b5e565b60006137dd6127f5565b6001600160a01b038416600090815260a56020526040902060010154909150811461380a5761380a615bd9565b6001600160a01b038316600090815260a5602052604090205461382e908390615902565b6001600160a01b03909316600090815260a560205260409020929092555050565b6060816003015460000361386257919050565b6000600183600301546138759190615902565b905060008360040154600161388a9190615915565b90508181116138a15761389e826001615915565b90505b6138ab8282615902565b67ffffffffffffffff8111156138c3576138c36158d6565b6040519080825280602002602001820160405280156138ec578160200160208202803683370190505b509250836002016000600186600301546139069190615902565b8152602001908152602001600020548360008151811061392857613928615825565b60200260200101818152505060005b8351613944826001615915565b10156139e557600081866003015461395c9190615915565b6000818152600188016020908152604080832054918a9052909120548751929350909187908590811061399157613991615825565b60200260200101516139a39190615915565b6139ad9190615902565b856139b9846001615915565b815181106139c9576139c9615825565b6020908102919091010152506139de81615928565b9050613937565b505050919050565b613a4b60988281548110613a0357613a03615825565b6000918252602090912060089091020154609880546001600160a01b039092169184908110613a3457613a34615825565b906000526020600020906008020160010154612cae565b6000613a5682611934565b90506000816006811115613a6c57613a6c615717565b14613c1f576001816006811115613a8557613a85615717565b1480613aa257506004816006811115613aa057613aa0615717565b145b80613abe57506005816006811115613abc57613abc615717565b145b80613ada57506006816006811115613ad857613ad8615717565b145b15613b385760405162461bcd60e51b815260206004820152602860248201527f5468652064656c65676174696f6e20686173206265656e20616c7265616479206044820152671858d8d95c1d195960c21b6064820152608401610639565b6002816006811115613b4c57613b4c615717565b03613bb35760405162461bcd60e51b815260206004820152603160248201527f5468652064656c65676174696f6e20686173206265656e2063616e63656c6c656044820152703210313c903a37b5b2b7103437b63232b960791b6064820152608401610639565b6003816006811115613bc757613bc7615717565b03613c1f5760405162461bcd60e51b815260206004820152602260248201527f5468652064656c65676174696f6e2072657175657374206973206f7574646174604482015261195960f21b6064820152608401610639565b6000816006811115613c3357613c33615717565b14613c905760405162461bcd60e51b815260206004820152602760248201527f43616e6e6f74207365742064656c65676174696f6e20737461746520746f206160448201526618d8d95c1d195960ca1b6064820152608401610639565b6000613cc760988481548110613ca857613ca8615825565b60009182526020909120600890910201546001600160a01b03166121e6565b9050613cd283614550565b600060988481548110613ce757613ce7615825565b90600052602060002090600802016002015490506000613d05612c1a565b6001600160a01b031663f5b98f4160988781548110613d2657613d26615825565b9060005260206000209060080201600301546040518263ffffffff1660e01b8152600401613d5691815260200190565b602060405180830381865afa158015613d73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d979190615963565b613da19083615a48565b9050613dab612bac565b6001600160a01b0316636ad5a9cf8260988881548110613dcd57613dcd615825565b9060005260206000209060080201600501546040518363ffffffff1660e01b8152600401613e05929190918252602082015260400190565b600060405180830381600087803b158015613e1f57600080fd5b505af1158015613e33573d6000803e3d6000fd5b50505050613e4083612325565b6040518581527fdb0c41de0e1a6e61f3ea29d9618edd8bfe8cb4e041a267c54eec70418341272d9060200160405180910390a15050505050565b600054610100900460ff1615808015613e9a5750600054600160ff909116105b80613eb45750303b158015613eb4575060005460ff166001145b613ed05760405162461bcd60e51b81526004016106399061597c565b6000805460ff191660011790558015613ef3576000805461ff0019166101001790555b613efb6149b6565b613f066000336116da565b6120c982614a88565b60006105bf825490565b6001600160a01b038316600090815260a060209081526040808320858452909152812061314e9083613fe4565b6000818310613f6057613f598284615902565b90506105bf565b60408051848152602081018490527f5b70a077a991facb623c7b2ee44cc539dc6ba345b6636552b8ea97fbbd4d5419910160405180910390a15060006105bf565b600081613fb3620f4240600019615902565b11613fc057613fc0615bd9565b613fcd620f424083615915565b90921192915050565b61252e848484846001614b62565b6003820154600090613ff7836001615915565b10156140155760405162461bcd60e51b815260040161063990615b97565b8260030154600003614029575060006105bf565b818360030154116140f657600283015460038401545b8381116140d05760008181526001860160209081526040808320549188905290912054614071919061226b9085615915565b60008281526020879052604090205490925015614098576000818152602086905260408120555b6000818152600186016020526040902054156140c05760008181526001860160205260408120555b6140c981615928565b905061403f565b50808460020154146140e457600284018190555b6140ef836001615915565b6003850155505b50506002015490565b60408051808201909152600080825260208201526105bf82600161414c565b60008183111561413e57620f42406141368385615902565b1090506105bf565b620f42406141368484615902565b6040805180820190915260008082526020820152600082116141a35760405162461bcd60e51b815260206004820152601060248201526f4469766973696f6e206279207a65726f60801b6044820152606401610639565b6040805180820190915283815260208101839052611b5e81614d23565b612ba7838484846000614b62565b604080518082019091526000808252602082015281518351611b5e916141f391615a48565b836020015185602001516142079190615a48565b61414c565b60975460408051633f2a95e960e21b815290516000926001600160a01b03169163fcaa57a49160048083019260209291908290030181865afa158015612bf6573d6000803e3d6000fd5b60006142606127f5565b6001600160a01b038416600090815260a560205260409020600101549091508111156142a9576001600160a01b0392909216600090815260a56020526040902090815560010155565b6001600160a01b038316600090815260a5602052604090206001015481146142d3576142d3615bd9565b6001600160a01b038316600090815260a5602052604090205461382e908390615915565b6000818152609b6020526040812054609880548391908590811061431d5761431d615825565b906000526020600020906008020160010154905060006098858154811061434657614346615825565b906000526020600020906008020160020154905082600003614385576000828152609e6020526040812060010154935083900361438557949350505050565b825b6000811180156143ba5750609886815481106143a5576143a5615825565b90600052602060002090600802016006015481105b1561444257609886815481106143d2576143d2615825565b9060005260206000209060080201600501548110614421576000838152609e602090815260408083208484529091529020600181015490546144149084615a48565b61441e9190615a75565b91505b6000838152609e602090815260408083209383529290522060020154614387565b50949350505050565b6000838152609c60205260409020612ba7908383614d65565b6001600160a01b0383166000908152609f60205260409020612ba7908383614d65565b6001600160a01b038416600090815260a060209081526040808320868452909152902061252e908383614d65565b6000838152609d60205260409020612ba7908383614e48565b6001600160a01b038416600090815260a160209081526040808320868452909152902061252e908383614e48565b6000611b5e836001600160a01b038416614ef4565b6000611b5e836001600160a01b038416614f43565b600082600001828154811061453d5761453d615825565b9060005260206000200154905092915050565b600061455a6127f5565b9050614567816001615915565b6098838154811061457a5761457a615825565b9060005260206000209060080201600501819055506000609e6000609885815481106145a8576145a8615825565b906000526020600020906008020160010154815260200190815260200160002060020154111561461f57609e6000609884815481106145e9576145e9615825565b60009182526020808320600160089093020191909101548352828101939093526040918201812060020154858252609b90935220555b61467e6098838154811061463557614635615825565b9060005260206000209060080201600101546098848154811061465a5761465a615825565b9060005260206000209060080201600201548360016146799190615915565b615036565b6146e96098838154811061469457614694615825565b6000918252602090912060089091020154609880546001600160a01b0390921691859081106146c5576146c5615825565b9060005260206000209060080201600201548360016146e49190615915565b61504f565b614779609883815481106146ff576146ff615825565b6000918252602090912060089091020154609880546001600160a01b03909216918590811061473057614730615825565b9060005260206000209060080201600101546098858154811061475557614755615825565b9060005260206000209060080201600201548460016147749190615915565b615072565b6147e46098838154811061478f5761478f615825565b6000918252602090912060089091020154609880546001600160a01b0390921691859081106147c0576147c0615825565b9060005260206000209060080201600101548360016147df9190615915565b6150a0565b60006147ee612c1a565b6001600160a01b031663f5b98f416098858154811061480f5761480f615825565b9060005260206000209060080201600301546040518263ffffffff1660e01b815260040161483f91815260200190565b602060405180830381865afa15801561485c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148809190615963565b6098848154811061489357614893615825565b9060005260206000209060080201600201546148af9190615a48565b90506148ec609884815481106148c7576148c7615825565b906000526020600020906008020160010154828460016148e79190615915565b615142565b6149586098848154811061490257614902615825565b6000918252602090912060089091020154609880546001600160a01b03909216918690811061493357614933615825565b906000526020600020906008020160010154838560016149539190615915565b61515b565b612ba76098848154811061496e5761496e615825565b6000918252602090912060089091020154609880546001600160a01b03909216918690811061499f5761499f615825565b906000526020600020906008020160010154615189565b600054610100900460ff16158080156149d65750600054600160ff909116105b806149f05750303b1580156149f0575060005460ff166001145b614a0c5760405162461bcd60e51b81526004016106399061597c565b6000805460ff191660011790558015614a2f576000805461ff0019166101001790555b614a3761521e565b614a3f61528b565b8015611b70576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a150565b6001600160a01b038116614ae95760405162461bcd60e51b815260206004820152602260248201527f436f6e74726163744d616e616765722061646472657373206973206e6f742073604482015261195d60f21b6064820152608401610639565b6001600160a01b0381163b614b405760405162461bcd60e51b815260206004820152601760248201527f41646472657373206973206e6f7420636f6e74726163740000000000000000006044820152606401610639565b609780546001600160a01b0319166001600160a01b0392909216919091179055565b6003850154614b72836001615915565b1015614b905760405162461bcd60e51b8152600401610639906159ca565b8015614bc4576003840154614ba6836001615915565b1015614bc45760405162461bcd60e51b8152600401610639906159ca565b602083015183511115614be95760405162461bcd60e51b815260040161063990615a01565b600385015415612a73576000614bff8684613fe4565b9050614c0c81600061411e565b15614c175750612a73565b60208401518451600288015460009291614c3091615a48565b614c3a9190615a75565b90508215614c6357614c6386614c5d838a60020154613f4690919063ffffffff16565b86614d65565b600287018190556000614c77856001615915565b90505b87600401548111612529576020808701518751600084815260018c019093526040832054614ca89190615a48565b614cb29190615a75565b90508415614d0257600082815260018a016020526040902054614cf090614cd99083613f46565b600084815260018b01602052604090205490613f46565b600083815260018a0160205260409020555b600082815260018a016020526040902055614d1c81615928565b9050614c7a565b6000614d3782600001518360200151615345565b8251909150614d47908290615a75565b82526020820151614d59908290615a75565b60209092019190915250565b614d70816001615915565b83600301541115614dc35760405162461bcd60e51b815260206004820152601d60248201527f43616e6e6f742073756274726163742066726f6d2074686520706173740000006044820152606401610639565b8260030154600003614dde5760038301819055600483018190555b8260040154811115614df257600483018190555b82600301548110614e2f576000818152600184016020526040902054614e19908390615915565b6000828152600185016020526040902055505050565b6002830154614e3e9083613f46565b6002840155505050565b8083600301541115614e9c5760405162461bcd60e51b815260206004820152601d60248201527f43616e6e6f742073756274726163742066726f6d2074686520706173740000006044820152606401610639565b8260030154600003614eb057600383018190555b6000818152600184016020526040902054614ecc908390615915565b600082815260018501602052604090205560048301548114612ba75760048301819055505050565b6000818152600183016020526040812054614f3b575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556105bf565b5060006105bf565b6000818152600183016020526040812054801561502c576000614f67600183615902565b8554909150600090614f7b90600190615902565b9050818114614fe0576000866000018281548110614f9b57614f9b615825565b9060005260206000200154905080876000018481548110614fbe57614fbe615825565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080614ff157614ff1615bef565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506105bf565b60009150506105bf565b6000838152609c60205260409020612ba7908383615373565b6001600160a01b0383166000908152609f60205260409020612ba7908383615373565b6001600160a01b038416600090815260a060209081526040808320868452909152902061252e908383615373565b6001600160a01b038316600090815260a4602052604081205490036150ea576001600160a01b038316600090815260a46020908152604080832084905560a25460a3909252909120555b6001600160a01b038316600090815260a4602090815260408083208584526001019091528120549003612ba7576001600160a01b0392909216600090815260a460209081526040808320938352600190930190522055565b6000838152609d60205260409020612ba7908383615438565b6001600160a01b038416600090815260a160209081526040808320868452909152902061252e908383615438565b6001600160a01b038216600090815260a66020908152604080832084845260010190915281205490036151e5576001600160a01b038216600090815260a6602052604081208054600192906151df908490615915565b90915550505b6001600160a01b038216600090815260a660209081526040808320848452600190810190925282208054919290916130d7908490615915565b600054610100900460ff166152895760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610639565b565b600054610100900460ff16158080156152ab5750600054600160ff909116105b806152c55750303b1580156152c5575060005460ff166001145b6152e15760405162461bcd60e51b81526004016106399061597c565b6000805460ff191660011790558015614a3f576000805461ff0019166101001790558015611b70576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001614a7d565b600082828181111561535357905b801561536b576153638183615c05565b909150615353565b509392505050565b80836003015411156153c05760405162461bcd60e51b815260206004820152601660248201527510d85b9b9bdd08185919081d1bc81d1a19481c185cdd60521b6044820152606401610639565b82600301546000036153db5760038301819055600483018190555b82600401548111156153ef57600483018190555b8260030154811061542857600081815260208490526040902054615414908390615915565b600082815260208590526040902055505050565b818360020154614e3e9190615915565b80836003015411156154855760405162461bcd60e51b815260206004820152601660248201527510d85b9b9bdd08185919081d1bc81d1a19481c185cdd60521b6044820152606401610639565b826003015460000361549957600383018190555b6000818152602084905260409020546154b3908390615915565b60008281526020859052604090205560048301548114612ba75760048301819055505050565b6001600160a01b0381168114611b7057600080fd5b60006020828403121561550057600080fd5b8135611b5e816154d9565b60006020828403121561551d57600080fd5b5035919050565b6000815180845260005b8181101561554a5760208185018101518683018201520161552e565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260018060a01b038251166020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015260a082015160c082015260c082015160e0820152600060e083015161010080818501525061314e610120840182615524565b6000806000606084860312156155ec57600080fd5b83356155f7816154d9565b95602085013595506040909401359392505050565b6000806040838503121561561f57600080fd5b823561562a816154d9565b946020939093013593505050565b6000806040838503121561564b57600080fd5b50508035926020909101359150565b60008060008060006080868803121561567257600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff8082111561569f57600080fd5b818801915088601f8301126156b357600080fd5b8135818111156156c257600080fd5b8960208285010111156156d457600080fd5b9699959850939650602001949392505050565b600080604083850312156156fa57600080fd5b82359150602083013561570c816154d9565b809150509250929050565b634e487b7160e01b600052602160045260246000fd5b602081016007831061574f57634e487b7160e01b600052602160045260246000fd5b91905290565b6020808252825182820181905260009190848201906040850190845b8181101561578d57835183529284019291840191600101615771565b50909695505050505050565b600061010060018060a01b038b1683528960208401528860408401528760608401528660808401528560a08401528460c08401528060e08401526157df81840185615524565b9b9a5050505050505050505050565b60208082526019908201527f44656c65676174696f6e20646f6573206e6f7420657869737400000000000000604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600181811c9082168061584f57607f821691505b60208210810361076f57634e487b7160e01b600052602260045260246000fd5b602081526000611b5e6020830184615524565b60006020828403121561589457600080fd5b8151611b5e816154d9565b60208082526019908201527f4d6573736167652073656e64657220697320696e76616c696400000000000000604082015260600190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b818103818111156105bf576105bf6158ec565b808201808211156105bf576105bf6158ec565b60006001820161593a5761593a6158ec565b5060010190565b60006020828403121561595357600080fd5b81518015158114611b5e57600080fd5b60006020828403121561597557600080fd5b5051919050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252601f908201527f43616e6e6f74207265647563652076616c756520696e20746865207061737400604082015260600190565b60208082526027908201527f496e6372656173696e67206f662076616c756573206973206e6f7420696d706c604082015266195b595b9d195960ca1b606082015260800190565b80820281158282048414176105bf576105bf6158ec565b634e487b7160e01b600052601260045260246000fd5b600082615a8457615a84615a5f565b500490565b601f821115612ba757600081815260208120601f850160051c81016020861015615ab05750805b601f850160051c820191505b81811015615acf57828155600101615abc565b505050505050565b815167ffffffffffffffff811115615af157615af16158d6565b615b0581615aff845461583b565b84615a89565b602080601f831160018114615b3a5760008415615b225750858301515b600019600386901b1c1916600185901b178555615acf565b600085815260208120601f198616915b82811015615b6957888601518255948401946001909101908401615b4a565b5085821015615b875787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60208082526022908201527f43616e6e6f742063616c63756c6174652076616c756520696e207468652070616040820152611cdd60f21b606082015260800190565b634e487b7160e01b600052600160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b600082615c1457615c14615a5f565b50069056fea2646970667358221220b5203e3d13d9b370c9cff0102989782b28d069331c2307b0c8ca6d6595de1de764736f6c63430008110033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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