ETH Price: $3,274.59 (-1.70%)

Contract

0xdD8bd1a9927aB550Cf2fC0a9da14702F9c09ac88
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Reset Account214591172024-12-22 16:05:3524 hrs ago1734883535IN
0xdD8bd1a9...F9c09ac88
0 ETH0.000631298.86706912
Reset Account214492862024-12-21 7:07:112 days ago1734764831IN
0xdD8bd1a9...F9c09ac88
0 ETH0.000449619.52322122
Claim Yield214292042024-12-18 11:45:235 days ago1734522323IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0015477413.01
Delegate214254062024-12-17 23:01:115 days ago1734476471IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0018719813.01
Claim Yield214125472024-12-16 3:59:237 days ago1734321563IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0015710610.6176886
Claim Yield214002652024-12-14 10:49:479 days ago1734173387IN
0xdD8bd1a9...F9c09ac88
0 ETH0.000927098.15447308
Claim Yield213986002024-12-14 5:15:359 days ago1734153335IN
0xdD8bd1a9...F9c09ac88
0 ETH0.00119510.5109344
Claim Yield213985502024-12-14 5:05:359 days ago1734152735IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0010728111.10668315
Claim Yield213920452024-12-13 7:17:4710 days ago1734074267IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0013024210.83231676
Claim Yield213066172024-12-01 8:58:5922 days ago1733043539IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0010968810.48044404
Claim Yield213027982024-11-30 20:11:5922 days ago1732997519IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0017732412.97124809
Claim Yield212563242024-11-24 8:10:3529 days ago1732435835IN
0xdD8bd1a9...F9c09ac88
0 ETH0.001203679.07817596
Claim Yield212513682024-11-23 15:34:5930 days ago1732376099IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0024296521.37050331
Claim Yield212148172024-11-18 13:11:1135 days ago1731935471IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0017078415.02172153
Claim Yield212062562024-11-17 8:33:1136 days ago1731832391IN
0xdD8bd1a9...F9c09ac88
0 ETH0.001111839.06533936
Claim Yield212036152024-11-16 23:41:4736 days ago1731800507IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0010894110.09397028
Claim Yield211836102024-11-14 4:41:1139 days ago1731559271IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0025783725
Claim Yield211644412024-11-11 12:28:1142 days ago1731328091IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0028722322.52112302
Claim Yield211589012024-11-10 17:55:4742 days ago1731261347IN
0xdD8bd1a9...F9c09ac88
0 ETH0.003588633.2539529
Claim Yield211562742024-11-10 9:09:1143 days ago1731229751IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0014340212.61321832
Claim Yield211483822024-11-09 6:43:5944 days ago1731134639IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0015090711.59706618
Claim Yield211330982024-11-07 3:30:2346 days ago1730950223IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0016911714.87506382
Claim Yield211277992024-11-06 9:45:1147 days ago1730886311IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0021118815.6906446
Claim Yield210911732024-11-01 7:02:2352 days ago1730444543IN
0xdD8bd1a9...F9c09ac88
0 ETH0.000644755.25477338
Claim Yield210857392024-10-31 12:52:3553 days ago1730379155IN
0xdD8bd1a9...F9c09ac88
0 ETH0.0012190912.62107941
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ChromiaDelegation

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 2000 runs

Other Settings:
default evmVersion
File 1 of 15 : ChromiaDelegation.sol
// SPDX-License-Identifier: MIT

/*
    This contract makes use of a users stake in TwoWeeksNotice to delegate to a specific provider and gain rewards upon it. To use this contract,
    please stake your Chromia tokens in TwoWeeksNotice first.
    IMPORTANT: User MUST `undelegate(..)` AFTER reqesting a withdrawal, but BEFORE actually withdrawing their stake from TWN, otherwise their records
    in TWN will be gone and the contracts cannot be synced - this will lead to a loss of unclaimed rewards.
*/

pragma solidity ^0.8.17;

import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {ITwoWeeksNotice} from "contracts/interfaces/ITwoWeeksNotice.sol";

struct DelegationChange {
    address delegatedTo;
    uint72 balance;
    uint16 nextChange;
}

struct DelegationState {
    uint16 claimedEpoch;
    uint16 latestChangeEpoch;
    uint96 processed;
    uint64 processedDate;
    uint96 balanceAtProcessed;
    mapping(uint16 => DelegationChange) delegationTimeline; // each uint key is a week starting from "startTime"
}

struct RateTimeline {
    uint16 latestChangeEpoch;
    mapping(uint16 => uint16) timeline;
    mapping(uint16 => uint16) nextChange;
}

struct ProviderStateChange {
    bool lostWhitelist; // provider got removed from whitelist this epoch
    bool gainedWhitelist; // provider got added to whitelist this epoch
    uint96 delegationsIncrease;
    uint96 delegationsDecrease;
    uint16 nextChangeDelegations;
    uint16 nextChangeWhitelist;
}

struct AdditionalReward {
    uint16 additionalRewardPerYieldPeriodPerToken;
    uint16 epoch;
}

struct ProviderState {
    bool whitelisted;
    uint16 claimedEpochReward;
    uint16 latestDelegationsChange;
    uint16 latestWhitelistChange;
    uint128 latestTotalDelegation;
    uint16 latestTotalDelegationEpoch;
    AdditionalReward[] additionalRewards;
    mapping(uint16 => ProviderStateChange) providerStateTimeline;
}

/// @title ChromiaProvider Delegation
/// @author Mustafa Koray Kaya
/// @notice TwoWeekNoticeProvider extension that allows delegation rewards for an existing TwoWeekNotice contract.
/// @dev Syncronizes state with the TWN contract when delegation is altered.
/// @dev Syncronization must also be performed before a TWN withdrawal
contract ChromiaDelegation is AccessControl, ReentrancyGuard {
    using SafeERC20 for IERC20Metadata;

    bytes32 public constant WHITELIST_ADMIN = keccak256("WHITELIST_ADMIN");
    bytes32 public constant RATE_ADMIN = keccak256("RATE_ADMIN");
    bytes32 public constant ADDITIONAL_REWARD_ADMIN = keccak256("ADDITIONAL_REWARD_ADMIN");

    uint32 public immutable yieldPeriod;
    uint32 public immutable epochLength;
    uint32 public immutable startTime;

    ITwoWeeksNotice public immutable twn;
    IERC20Metadata public immutable token;
    address public bank;

    uint128 private immutable minorTokenUnitsInMajor;

    mapping(address => DelegationState) public delegatorStates;
    mapping(address => ProviderState) public providerStates;

    RateTimeline private delegatorYieldTimeline; // The yield delegators get for delegating
    RateTimeline private providerRewardRateTimeline; // The reward the provider gets from the delegations that are delegated to them

    event Delegated(address indexed delegator, address indexed provider, uint128 amount);
    event Undelegated(address indexed delegator, address indexed provider, uint128 amount);
    event DelegatorYieldRateChanged(uint16 newRate);
    event ProviderTotalDelegationRateChanged(uint16 newRate);
    event AddedWhitelist(address provider);
    event RemovedWhitelist(address provider);
    event RevisedDelegation(address delegator);
    event ResetAccount(address delegator);
    event GrantedAdditionalReward(address provider, uint16 rate);
    event ClaimedYield(address delegator, uint128 amount);
    event ProviderClaimedTotalDelegationYield(address provider, uint128 amount);

    string private constant INVALID_WITHDRAW_ERROR = "Withdrawn without undelegating";
    string private constant TIMELINE_MISMATCH_ERROR = "Timeline does not match with TWN.";
    string private constant UNAUTHORISED_ERROR = "Unauthorized";
    string private constant CANNOT_CHANGE_WITHDRAWAL_ERROR = "Cannot change delegation while withdrawing";
    string private constant WITHDRAWAL_NOT_REQUESTED_ERROR = "Withdraw has not been requested";
    string private constant MUST_HAVE_STAKE_ERROR = "Must have a stake to delegate";
    string private constant MUST_WHITELISTED_ERROR = "Provider must be whitelisted";
    string private constant MUST_AFTER_START_ERROR = "Time must be after start time";
    string private constant CHANGE_TOO_RECENT_ERROR = "Change is too recent";
    string private constant ZERO_REWARD_ERROR = "Reward is 0";
    string private constant FIRST_DELEGATION_NEEDED_ERROR = "Address must make a first delegation.";
    string private constant ALREADY_SYNCRONISED_ERROR = "Stake is synced";

    constructor(
        IERC20Metadata _token,
        ITwoWeeksNotice _twn,
        address _owner,
        uint16 _delegatorYield, // Yield delegators get for delegating
        uint16 _totalDelegationYield, // Yield providers get on the total amount delegated to them
        address _bank,
        uint32 _yieldPeriodInSecs,
        uint32 _epochLengthInYieldPeriods
    ) {
        yieldPeriod = _yieldPeriodInSecs;
        epochLength = _epochLengthInYieldPeriods * yieldPeriod;
        startTime = uint32(block.timestamp) - epochLength;

        _setupRole(DEFAULT_ADMIN_ROLE, _owner);
        _setupRole(WHITELIST_ADMIN, _owner);
        _setupRole(RATE_ADMIN, _owner);
        _setupRole(ADDITIONAL_REWARD_ADMIN, _owner);

        twn = _twn;
        token = _token;
        bank = _bank;

        minorTokenUnitsInMajor = uint128(10 ** token.decimals());

        delegatorYieldTimeline.timeline[1] = _delegatorYield;
        delegatorYieldTimeline.nextChange[0] = 1;
        delegatorYieldTimeline.latestChangeEpoch = 1;

        providerRewardRateTimeline.timeline[1] = _totalDelegationYield;
        providerRewardRateTimeline.nextChange[0] = 1;
        providerRewardRateTimeline.latestChangeEpoch = 1;
    }

    /// @dev Has the delegator's stake on the TWN contract not been released or modified.
    function isStakeValid(address account) public view returns (bool) {
        (, uint128 remoteAccumulated) = twn.getAccumulated(account);
        return remoteAccumulated == delegatorStates[account].processed;
    }

    /**
     *
     * SETTERS AND GETTERS
     *
     */

    /// @notice Set the reward rate to `rewardRate` for the *next* epoch
    function setRewardRate(uint16 newRate) external {
        setNewRate(newRate, delegatorYieldTimeline);
        emit DelegatorYieldRateChanged(newRate);
    }

    /// @notice Set the provider reward rate to `newRate` at the new epoch
    function setProviderRewardRate(uint16 newRate) external {
        setNewRate(newRate, providerRewardRateTimeline);
        emit ProviderTotalDelegationRateChanged(newRate);
    }

    function setNewRate(uint16 newRate, RateTimeline storage rateTimeline) private {
        require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(RATE_ADMIN, msg.sender), UNAUTHORISED_ERROR);
        uint16 nextEpoch = getCurrentEpoch() + 1;
        rateTimeline.timeline[nextEpoch] = newRate;
        if (rateTimeline.latestChangeEpoch != nextEpoch) {
            rateTimeline.nextChange[rateTimeline.latestChangeEpoch] = nextEpoch;
            rateTimeline.latestChangeEpoch = nextEpoch;
        }
    }

    function journalProviderWhitelistChange(ProviderState storage providerState) private returns (uint16 newLatestChange) {
        ProviderStateChange storage nextChangeMapping = providerState.providerStateTimeline[providerState.latestWhitelistChange];
        if (providerState.latestWhitelistChange != getCurrentEpoch()) {
            nextChangeMapping.nextChangeWhitelist = getCurrentEpoch();
            return getCurrentEpoch();
        }
        return providerState.latestWhitelistChange;
    }

    function journalProviderDelegationChange(ProviderState storage ps) private returns (uint16 newLatestChange) {
        uint16 changeEpoch = getCurrentEpoch() + 1;
        ProviderStateChange storage nextChangeMapping = ps.providerStateTimeline[ps.latestDelegationsChange];
        if (ps.latestDelegationsChange != changeEpoch) {
            nextChangeMapping.nextChangeDelegations = changeEpoch;
            return changeEpoch;
        }
        return ps.latestDelegationsChange;
    }

    function journalDelegationChange(uint16 epoch, DelegationState storage userState) private returns (uint16 newLatestChange) {
        DelegationChange storage nextChangeMapping = userState.delegationTimeline[userState.latestChangeEpoch];

        if (userState.latestChangeEpoch != epoch) {
            nextChangeMapping.nextChange = epoch;
            return epoch;
        }
        return userState.latestChangeEpoch;
    }

    /// @notice Gets the current active reward rate in the present epoch
    function getActiveProviderRewardRate(uint16 epoch) public view returns (uint128 activeRate, uint16 latestEpoch) {
        return getActiveRate(epoch, providerRewardRateTimeline);
    }

    /// @notice Get the reward rate active at epoch `epoch`
    function getActiveYieldRate(uint16 epoch) public view returns (uint128 activeRate, uint16 latestEpoch) {
        return getActiveRate(epoch, delegatorYieldTimeline);
    }

    function getActiveRate(uint16 epoch, RateTimeline storage rateTimeline) private view returns (uint128 activeRate, uint16 latestEpoch) {
        if (epoch >= rateTimeline.latestChangeEpoch) {
            return (rateTimeline.timeline[rateTimeline.latestChangeEpoch], rateTimeline.latestChangeEpoch);
        }

        uint16 nextChange = 0;
        while (true) {
            if (rateTimeline.nextChange[nextChange] > epoch) {
                return (rateTimeline.timeline[nextChange], nextChange);
            }
            nextChange = rateTimeline.nextChange[nextChange];
        }
    }

    /// @notice Get the active delegates state for `account` at epoch `epoch`
    function getActiveDelegation(address account, uint16 epoch) public view returns (DelegationChange memory activeDelegation, uint16 latestEpoch) {
        DelegationState storage userState = delegatorStates[account];
        if (userState.latestChangeEpoch == 0) {
            return (activeDelegation, 0);
        }
        if (epoch >= userState.latestChangeEpoch) {
            return (userState.delegationTimeline[userState.latestChangeEpoch], userState.latestChangeEpoch);
        }

        uint16 nextChange = 0;
        while (true) {
            if (userState.delegationTimeline[nextChange].nextChange > epoch) {
                return (userState.delegationTimeline[nextChange], nextChange);
            }
            nextChange = userState.delegationTimeline[nextChange].nextChange;
        }
    }

    /// @notice Get if the account has whitelist at certain epoch
    function getWhitelisted(address account, uint16 epoch) public view returns (bool whitelisted, uint16 latestEpoch) {
        ProviderState storage providerState = providerStates[account];

        if (providerState.latestWhitelistChange == 0) {
            return (false, 0);
        }

        ProviderStateChange storage psc;
        if (epoch >= providerState.latestWhitelistChange) {
            psc = providerState.providerStateTimeline[providerState.latestWhitelistChange];
            if (psc.lostWhitelist) {
                return (false, providerState.latestWhitelistChange);
            } else if (psc.gainedWhitelist) {
                return (true, providerState.latestWhitelistChange);
            }
        }

        uint16 nextChange = 0;
        while (true) {
            if (providerState.providerStateTimeline[nextChange].nextChangeWhitelist > epoch) {
                psc = providerState.providerStateTimeline[nextChange];
                if (psc.lostWhitelist) {
                    return (false, nextChange);
                } else if (psc.gainedWhitelist) {
                    return (true, nextChange);
                }
            }
            nextChange = providerState.providerStateTimeline[nextChange].nextChangeWhitelist;
        }
    }

    function getTotalDelegations(address provider) external view returns (uint128 totalDelegations) {
        ProviderState storage providerState = providerStates[provider];
        totalDelegations = providerState.latestTotalDelegation;
        uint16 next = providerState.providerStateTimeline[providerState.latestTotalDelegationEpoch].nextChangeDelegations;

        ProviderStateChange storage psc;
        while (true) {
            if (next == 0 || next > getCurrentEpoch() - 1) {
                break;
            }
            psc = providerState.providerStateTimeline[next];
            if (psc.delegationsIncrease != 0) {
                totalDelegations += psc.delegationsIncrease;
            }

            if (psc.delegationsDecrease != 0) {
                if (totalDelegations > psc.delegationsDecrease) {
                    totalDelegations -= psc.delegationsDecrease;
                } else totalDelegations = 0;
            }
            next = providerState.providerStateTimeline[next].nextChangeDelegations;
        }
    }

    /**
     *
     * DELEGATION MANAGEMENT
     *
     */

    function removeCurrentDelegationFromProvider(DelegationChange memory currentDelegation, uint16 currDelEpoch) private {
        uint16 nextEpoch = getCurrentEpoch() + 1;
        ProviderState storage ps = providerStates[currentDelegation.delegatedTo];
        // If provider has lost whitelist since delegation, dont bother to decreae since their total is already set to 0 on
        // removeWhitelist()
        if (currDelEpoch >= ps.latestWhitelistChange) {
            // Remove previous delegation from providers pool
            ps.providerStateTimeline[nextEpoch].delegationsDecrease += currentDelegation.balance;
            ps.latestDelegationsChange = journalProviderDelegationChange(ps);
        }
    }

    function addDelegation(DelegationState storage userState, uint16 epoch, address to, uint128 acc, uint64 since, uint64 delegateAmount) private {
        userState.delegationTimeline[epoch] = DelegationChange(to, delegateAmount, 0);
        userState.latestChangeEpoch = journalDelegationChange(epoch, userState);
        userState.balanceAtProcessed = delegateAmount;
        userState.processed = uint96(acc);
        userState.processedDate = since;
    }

    /// @notice Removes delegation after a withdrawal is requested. Failure to do so prior to withdrawal may result in lost.
    function undelegate(address account) external nonReentrant {
        (, , uint64 lockedUntil, uint64 since) = twn.getStakeState(account);
        require(lockedUntil > 0, WITHDRAWAL_NOT_REQUESTED_ERROR);
        DelegationState storage userState = delegatorStates[account];
        (, uint128 acc) = twn.getAccumulated(msg.sender);

        ensureSyncronisedDelegationState(userState, acc, since);

        uint16 nextEpoch = getCurrentEpoch() + 1;
        // Remove previous delegation from providers pool
        (DelegationChange memory currentDelegation, uint16 currDelEpoch) = getActiveDelegation(msg.sender, nextEpoch);
        removeCurrentDelegationFromProvider(currentDelegation, currDelEpoch);

        uint16 requestWithdrawEpoch = getEpoch(since);
        if (currDelEpoch > requestWithdrawEpoch) {
            // if there is a change queued up, delete it and reset the pointers
            (, uint16 prevDelEpoch) = getActiveDelegation(msg.sender, currDelEpoch - 1);
            delete userState.delegationTimeline[currDelEpoch];
            userState.delegationTimeline[prevDelEpoch].nextChange = 0;
            userState.latestChangeEpoch = prevDelEpoch;
        }

        addDelegation(userState, requestWithdrawEpoch, address(0), acc, since, 0);

        emit Undelegated(account, currentDelegation.delegatedTo, currentDelegation.balance);
    }

    /// @notice Set the delegation of the caller for the *next* epoch
    function delegate(address to) external nonReentrant {
        DelegationState storage userState = delegatorStates[msg.sender];
        ProviderState storage ps = providerStates[to];

        (, uint128 acc) = twn.getAccumulated(msg.sender);
        (uint64 delegateAmount, , uint64 lockedUntil, uint64 since) = twn.getStakeState(msg.sender);

        require(delegateAmount > 0, MUST_HAVE_STAKE_ERROR);
        require(lockedUntil == 0, CANNOT_CHANGE_WITHDRAWAL_ERROR);
        require(ps.whitelisted, MUST_WHITELISTED_ERROR);

        uint16 nextEpoch = getCurrentEpoch() + 1;

        // Remove previous delegation from providers pool so that they cannot claim rewards from it if we have a new provider
        (DelegationChange memory currentDelegation, uint16 currDelEpoch) = getActiveDelegation(msg.sender, nextEpoch);
        if (currentDelegation.delegatedTo != address(0) && (currentDelegation.delegatedTo != to || currDelEpoch < ps.latestWhitelistChange)) {
            removeCurrentDelegationFromProvider(currentDelegation, currDelEpoch); // 40k gas
        }

        if (userState.latestChangeEpoch == 0) {
            userState.claimedEpoch = nextEpoch - 1; // If user has never delegated before, set claimedEpoch to current epoch
        } else {
            ensureSyncronisedDelegationState(userState, acc, since); // Make sure that the user hasnt decreased stake since last delegation
        }
        addDelegation(userState, nextEpoch, to, acc, since, delegateAmount); // 80k gas. Add delegation to users state

        // Add to new providers "totalDelegations" pool so they can claim rewards
        // 40k gas
        if (currentDelegation.delegatedTo != to || currDelEpoch < ps.latestWhitelistChange) {
            ps.providerStateTimeline[nextEpoch].delegationsIncrease += delegateAmount;
        } else {
            ps.providerStateTimeline[nextEpoch].delegationsIncrease += delegateAmount - currentDelegation.balance;
        }
        ps.latestDelegationsChange = journalProviderDelegationChange(ps);
        emit Delegated(msg.sender, to, delegateAmount);
    }

    /// @notice Remove the calling account's delegation status. Call only if state is "broken".
    function resetAccount() external {
        DelegationState storage userState = delegatorStates[msg.sender];
        require(userState.latestChangeEpoch > 0, FIRST_DELEGATION_NEEDED_ERROR);

        (DelegationChange memory currentDelegation, uint16 currDelEpoch) = getActiveDelegation(msg.sender, getCurrentEpoch() + 1);
        removeCurrentDelegationFromProvider(currentDelegation, currDelEpoch);

        uint16 currChange = 0;
        uint16 nextChange;
        while (true) {
            nextChange = userState.delegationTimeline[currChange].nextChange;
            delete userState.delegationTimeline[currChange];
            if (nextChange == 0) break;
            currChange = nextChange;
        }

        delete delegatorStates[msg.sender];

        emit ResetAccount(msg.sender);
    }

    /// @notice Matches `account`'s delegation to the underlying stake. `isStakeValid(account)` must be false before call.
    function reviseDelegation(address account) external nonReentrant onlyRole(WHITELIST_ADMIN) {
        require(!isStakeValid(account), ALREADY_SYNCRONISED_ERROR);

        (, , , uint64 since) = twn.getStakeState(account);
        require(block.timestamp - since > epochLength, CHANGE_TOO_RECENT_ERROR);
        DelegationState storage userState = delegatorStates[account];
        require(userState.latestChangeEpoch > 0, FIRST_DELEGATION_NEEDED_ERROR);

        uint16 currentEpoch = getCurrentEpoch();

        (DelegationChange memory currentDelegation, uint16 currDelEpoch) = getActiveDelegation(account, currentEpoch + 1);
        removeCurrentDelegationFromProvider(currentDelegation, currDelEpoch);

        userState.delegationTimeline[currentEpoch] = DelegationChange(address(0), 0, 0);
        userState.latestChangeEpoch = journalDelegationChange(currentEpoch, userState);
        emit RevisedDelegation(account);
    }

    /**
     *
     * REWARD FUNCTIONS
     *
     */

    /// @notice Estimates the additional reward providers get for the total amount delegated to them per epoch
    function updateProviderDelegationRewardEstimate(address account) external nonReentrant returns (uint128 reward) {
        return _updateProviderDelegationRewardEstimate(account);
    }

    function _updateProviderDelegationRewardEstimate(address account) internal returns (uint128 reward) {
        ProviderState storage providerState = providerStates[account];
        uint16 currentEpoch = getCurrentEpoch();

        if (currentEpoch - 1 <= providerState.claimedEpochReward) {
            return 0;
        }

        uint128 totalDelegations = providerState.latestTotalDelegation;
        uint16 nextDC = providerState.latestTotalDelegationEpoch;
        (uint128 activeRate, uint16 nextAR) = getActiveProviderRewardRate(providerState.claimedEpochReward + 1);

        uint16 latestTotalDelegationEpoch = nextDC;

        nextAR = providerRewardRateTimeline.nextChange[nextAR];
        nextDC = providerState.providerStateTimeline[nextDC].nextChangeDelegations;

        uint16 prev = providerState.claimedEpochReward + 1;
        uint16 next = findSmallestNonZero(nextAR, nextDC);
        if (next == 0 || next >= currentEpoch) {
            next = currentEpoch;
        }
        ProviderStateChange storage psc;
        while (true) {
            reward += uint128((activeRate) * totalDelegations * epochLength) * (next - prev);

            if (next == currentEpoch) break;

            if (next == nextAR) {
                activeRate = providerRewardRateTimeline.timeline[next];
                nextAR = providerRewardRateTimeline.nextChange[next];
            }
            if (next == nextDC) {
                psc = providerStates[account].providerStateTimeline[next];
                if (psc.delegationsIncrease != 0) {
                    totalDelegations += psc.delegationsIncrease;
                }
                if (psc.delegationsDecrease != 0) {
                    if (totalDelegations > psc.delegationsDecrease) {
                        totalDelegations -= psc.delegationsDecrease;
                    } else totalDelegations = 0;
                }

                latestTotalDelegationEpoch = nextDC;
                nextDC = providerState.providerStateTimeline[next].nextChangeDelegations;
            }
            prev = next;
            next = findSmallestNonZero(nextAR, nextDC);
            if (next == 0 || next >= currentEpoch) {
                next = currentEpoch;
            }
        }

        reward /= minorTokenUnitsInMajor * yieldPeriod;

        providerState.latestTotalDelegation = totalDelegations;
        providerState.latestTotalDelegationEpoch = latestTotalDelegationEpoch;
    }

    /// @notice Calculate the total accumulated reward available to `account`
    function estimateYield(address account) public view returns (uint128 reward) {
        DelegationState storage userState = delegatorStates[account];
        uint16 processedEpoch = userState.claimedEpoch;
        uint16 currentEpoch = getCurrentEpoch();

        if (currentEpoch - 1 <= processedEpoch) {
            return 0;
        }

        (uint128 activeRate, uint16 nextAR) = getActiveYieldRate(processedEpoch + 1);
        (DelegationChange memory activeDelegation, uint16 nextAD) = getActiveDelegation(account, processedEpoch + 1);
        (bool whitelisted, uint16 nextWL) = getWhitelisted(activeDelegation.delegatedTo, processedEpoch + 1);

        ProviderState storage providerState = providerStates[activeDelegation.delegatedTo];

        nextAR = delegatorYieldTimeline.nextChange[nextAR];
        nextAD = userState.delegationTimeline[nextAD].nextChange;
        nextWL = providerState.providerStateTimeline[nextWL].nextChangeWhitelist;

        uint16 prev = processedEpoch + 1;
        uint16 next = findSmallestNonZero(nextAR, nextAD, nextWL);
        if (next == 0 || next >= currentEpoch) {
            next = currentEpoch;
        }

        while (true) {
            if (whitelisted) {
                reward += uint128((activeRate) * activeDelegation.balance * epochLength) * (next - prev);

                if (providerState.additionalRewards.length > 0) {
                    for (uint i = providerState.additionalRewards.length - 1; i >= 0; i--) {
                        if (providerState.additionalRewards[i].epoch < prev) break;
                        if (
                            providerState.additionalRewards[i].epoch < next &&
                            providerState.additionalRewards[i].additionalRewardPerYieldPeriodPerToken > 0
                        ) {
                            reward += uint128(
                                (providerState.additionalRewards[i].additionalRewardPerYieldPeriodPerToken) * activeDelegation.balance * epochLength
                            );
                        }

                        if (i == 0) break;
                    }
                }
            }

            if (next == currentEpoch) break;

            if (next == nextAR) {
                activeRate = delegatorYieldTimeline.timeline[next];
                nextAR = delegatorYieldTimeline.nextChange[next];
            }
            if (next == nextAD) {
                DelegationChange memory oldDelegation = activeDelegation;
                activeDelegation = userState.delegationTimeline[next];
                if (oldDelegation.delegatedTo != activeDelegation.delegatedTo) {
                    providerState = providerStates[activeDelegation.delegatedTo];

                    (whitelisted, nextWL) = getWhitelisted(activeDelegation.delegatedTo, next);

                    nextWL = providerState.providerStateTimeline[nextWL].nextChangeWhitelist;
                }
                nextAD = userState.delegationTimeline[next].nextChange;
            }
            if (next == nextWL) {
                ProviderStateChange storage psc = providerState.providerStateTimeline[next];
                if (psc.lostWhitelist) {
                    whitelisted = false;
                } else if (psc.gainedWhitelist) {
                    whitelisted = true;
                }
                nextWL = providerState.providerStateTimeline[next].nextChangeWhitelist;
            }

            prev = next;
            next = findSmallestNonZero(nextAR, nextAD, nextWL);
            if (next == 0 || next >= currentEpoch) {
                next = currentEpoch;
            }
        }

        reward /= (minorTokenUnitsInMajor * yieldPeriod);
    }

    /// @notice Claims the rewards (which should be per `estimateYield(account)`) for `account`
    function claimYield(address account) external nonReentrant {
        require(delegatorStates[account].latestChangeEpoch > 0, FIRST_DELEGATION_NEEDED_ERROR);
        require(isStakeValid(account), TIMELINE_MISMATCH_ERROR);
        uint128 reward = estimateYield(account);
        require(reward > 0, ZERO_REWARD_ERROR);
        delegatorStates[account].claimedEpoch = getCurrentEpoch() - 1;
        token.safeTransferFrom(bank, account, reward);
        emit ClaimedYield(account, reward);
    }

    /// @notice Claims additional token rewards for the calling provider
    function claimProviderDelegationReward(address account) external nonReentrant {
        _claimProviderDelegationReward(account);
    }

    function _claimProviderDelegationReward(address account) internal {
        uint128 reward = _updateProviderDelegationRewardEstimate(account);
        providerStates[account].claimedEpochReward = getCurrentEpoch() - 1;
        token.safeTransferFrom(bank, account, reward);

        emit ProviderClaimedTotalDelegationYield(account, reward);
    }

    /**
     *
     * HELPERS
     *
     */

    function getCurrentEpoch() public view returns (uint16) {
        return getEpoch(block.timestamp);
    }

    function getEpoch(uint time) public view returns (uint16) {
        require(time > startTime, MUST_AFTER_START_ERROR);
        return uint16((time - startTime) / epochLength);
    }

    function ensureSyncronisedDelegationState(DelegationState storage userState, uint128 acc, uint64 since) private view {
        /// @dev This must match the calculation of acc at TWN exactly. Even the rounding errors MUST be matched.
        require(
            (userState.balanceAtProcessed * (since - userState.processedDate)) / yieldPeriod + userState.processed <= acc,
            INVALID_WITHDRAW_ERROR
        );
    }

    function findSmallestNonZero(uint16 a, uint16 b, uint16 c) private pure returns (uint16 smallestNonZero) {
        if (a == 0 && b == 0 && c == 0) {
            return 0;
        }

        smallestNonZero = type(uint16).max;

        if (a != 0 && a < smallestNonZero) {
            smallestNonZero = a;
        }
        if (b != 0 && b < smallestNonZero) {
            smallestNonZero = b;
        }
        if (c != 0 && c < smallestNonZero) {
            smallestNonZero = c;
        }
    }

    function findSmallestNonZero(uint16 a, uint16 b) private pure returns (uint16 smallestNonZero) {
        if (a == 0 && b == 0) {
            return 0;
        }

        smallestNonZero = type(uint16).max;

        if (a != 0 && a < smallestNonZero) {
            smallestNonZero = a;
        }
        if (b != 0 && b < smallestNonZero) {
            smallestNonZero = b;
        }
    }

    /**
     *
     * ADMIN
     *
     */

    /// @notice Adds `account` as a valid provider on the whitelist
    function addToWhitelist(address account) external {
        require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(WHITELIST_ADMIN, msg.sender), UNAUTHORISED_ERROR);
        uint16 currentEpoch = getCurrentEpoch();

        ProviderState storage providerState = providerStates[account];
        providerState.whitelisted = true;
        providerState.providerStateTimeline[currentEpoch].gainedWhitelist = true;
        providerState.latestWhitelistChange = journalProviderWhitelistChange(providerState);

        emit AddedWhitelist(account);
    }

    /// @notice Removes `account` from the provider whitelist, and process an immediate withdrawal if successful
    function removeFromWhitelist(address account) external nonReentrant {
        require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(WHITELIST_ADMIN, msg.sender), UNAUTHORISED_ERROR);
        ProviderState storage providerState = providerStates[account];
        uint16 currentEpoch = getCurrentEpoch();

        _claimProviderDelegationReward(account);

        providerState.latestTotalDelegation = 0;
        // remove from whitelist
        providerState.whitelisted = false;
        providerState.providerStateTimeline[currentEpoch].lostWhitelist = true;
        // Record change
        providerState.latestWhitelistChange = journalProviderWhitelistChange(providerState);
        emit RemovedWhitelist(account);
    }

    /// @notice Grants a lump `amount` award to a provider `account` at epoch `epoch`. Admin only.
    function grantAdditionalReward(address account, uint16 epoch, uint16 amount) external onlyRole(ADDITIONAL_REWARD_ADMIN) {
        require(epoch >= getCurrentEpoch(), "Cannot grant additional rewards retroactively");
        providerStates[account].additionalRewards.push(AdditionalReward(amount, epoch));

        emit GrantedAdditionalReward(account, amount);
    }

    /// @notice Changes the bank address from which rewards are drawn to `newBank`. Admin only.
    function changeBank(address newBank) external onlyRole(DEFAULT_ADMIN_ROLE) {
        bank = newBank;
    }

    /// @notice Sends all CHR tokens to the contract owner. Only admin can call.
    function drain() external onlyRole(DEFAULT_ADMIN_ROLE) {
        token.safeTransfer(msg.sender, token.balanceOf(address(this)));
    }
}

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

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

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

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

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

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

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

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

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    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.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

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

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

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

File 3 of 15 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 4 of 15 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

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

File 5 of 15 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

import "../IERC20.sol";

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

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

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

File 7 of 15 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 8 of 15 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

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

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

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

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

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

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

File 9 of 15 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [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 functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

/**
 * @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 Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

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

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

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

pragma solidity ^0.8.0;

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

File 13 of 15 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 14 of 15 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

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

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

File 15 of 15 : ITwoWeeksNotice.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

interface ITwoWeeksNotice {
    function getStakeState(address account) external view returns (uint64, uint64, uint64, uint64);

    function getAccumulated(address account) external view returns (uint128, uint128);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract IERC20Metadata","name":"_token","type":"address"},{"internalType":"contract ITwoWeeksNotice","name":"_twn","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint16","name":"_delegatorYield","type":"uint16"},{"internalType":"uint16","name":"_totalDelegationYield","type":"uint16"},{"internalType":"address","name":"_bank","type":"address"},{"internalType":"uint32","name":"_yieldPeriodInSecs","type":"uint32"},{"internalType":"uint32","name":"_epochLengthInYieldPeriods","type":"uint32"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"provider","type":"address"}],"name":"AddedWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"delegator","type":"address"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"}],"name":"ClaimedYield","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"}],"name":"Delegated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"newRate","type":"uint16"}],"name":"DelegatorYieldRateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint16","name":"rate","type":"uint16"}],"name":"GrantedAdditionalReward","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"}],"name":"ProviderClaimedTotalDelegationYield","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"newRate","type":"uint16"}],"name":"ProviderTotalDelegationRateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"provider","type":"address"}],"name":"RemovedWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"delegator","type":"address"}],"name":"ResetAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"delegator","type":"address"}],"name":"RevisedDelegation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"}],"name":"Undelegated","type":"event"},{"inputs":[],"name":"ADDITIONAL_REWARD_ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RATE_ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WHITELIST_ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addToWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"bank","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newBank","type":"address"}],"name":"changeBank","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"claimProviderDelegationReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"claimYield","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"delegatorStates","outputs":[{"internalType":"uint16","name":"claimedEpoch","type":"uint16"},{"internalType":"uint16","name":"latestChangeEpoch","type":"uint16"},{"internalType":"uint96","name":"processed","type":"uint96"},{"internalType":"uint64","name":"processedDate","type":"uint64"},{"internalType":"uint96","name":"balanceAtProcessed","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"drain","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"epochLength","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"estimateYield","outputs":[{"internalType":"uint128","name":"reward","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint16","name":"epoch","type":"uint16"}],"name":"getActiveDelegation","outputs":[{"components":[{"internalType":"address","name":"delegatedTo","type":"address"},{"internalType":"uint72","name":"balance","type":"uint72"},{"internalType":"uint16","name":"nextChange","type":"uint16"}],"internalType":"struct DelegationChange","name":"activeDelegation","type":"tuple"},{"internalType":"uint16","name":"latestEpoch","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"epoch","type":"uint16"}],"name":"getActiveProviderRewardRate","outputs":[{"internalType":"uint128","name":"activeRate","type":"uint128"},{"internalType":"uint16","name":"latestEpoch","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"epoch","type":"uint16"}],"name":"getActiveYieldRate","outputs":[{"internalType":"uint128","name":"activeRate","type":"uint128"},{"internalType":"uint16","name":"latestEpoch","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentEpoch","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"time","type":"uint256"}],"name":"getEpoch","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"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":"address","name":"provider","type":"address"}],"name":"getTotalDelegations","outputs":[{"internalType":"uint128","name":"totalDelegations","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint16","name":"epoch","type":"uint16"}],"name":"getWhitelisted","outputs":[{"internalType":"bool","name":"whitelisted","type":"bool"},{"internalType":"uint16","name":"latestEpoch","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint16","name":"epoch","type":"uint16"},{"internalType":"uint16","name":"amount","type":"uint16"}],"name":"grantAdditionalReward","outputs":[],"stateMutability":"nonpayable","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":"account","type":"address"}],"name":"isStakeValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"providerStates","outputs":[{"internalType":"bool","name":"whitelisted","type":"bool"},{"internalType":"uint16","name":"claimedEpochReward","type":"uint16"},{"internalType":"uint16","name":"latestDelegationsChange","type":"uint16"},{"internalType":"uint16","name":"latestWhitelistChange","type":"uint16"},{"internalType":"uint128","name":"latestTotalDelegation","type":"uint128"},{"internalType":"uint16","name":"latestTotalDelegationEpoch","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"removeFromWhitelist","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":[],"name":"resetAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"reviseDelegation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newRate","type":"uint16"}],"name":"setProviderRewardRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newRate","type":"uint16"}],"name":"setRewardRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startTime","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IERC20Metadata","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"twn","outputs":[{"internalType":"contract ITwoWeeksNotice","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"undelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"updateProviderDelegationRewardEstimate","outputs":[{"internalType":"uint128","name":"reward","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"yieldPeriod","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"}]

6101406040523480156200001257600080fd5b5060405162004c0938038062004c0983398101604081905262000035916200039a565b6001805563ffffffff8216608081905262000051908262000462565b63ffffffff1660a08190526200006890426200048d565b63ffffffff1660c0526200007e60008762000291565b620000aa7f9cc798953f1657230a000cfd0cfb877f321fc37733bbdaba923c800c0f6f63b68762000291565b620000d67fb54bb84ee3be50e6950d3bc7b4df6132e81f11695d45d3abf42ff629408f25398762000291565b620001027fc4fb326a0f29357e7e664c75ea916c5b15852bf43b3ef049935b453971100f0a8762000291565b6001600160a01b0387811660e052888116610100819052600280546001600160a01b031916928616929092179091556040805163313ce56760e01b8152905163313ce567916004808201926020929091908290030181865afa1580156200016d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001939190620004b4565b620001a090600a620005dd565b6001600160801b03166101205250507f3e5fec24aa4dc4e5aee2e025e51e1392c72a2500577559fae9665c6d52bd6a31805461ffff1990811661ffff958616179091557f6d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6df805482166001908117909155600580548316821790557f92e85d02570a8092d09a6e3a57665bc3815a2699a4074001bf1ccabf660f5a368054831694909516939093179093555060008052600a6020527f13da86008ba1c6922daee3e07db95305ef49ebced9f5467a0b8613fcc6b343e380548316821790556008805490921617905550620005ee915050565b6200029d8282620002a1565b5050565b620002ad828262000329565b6200029d576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620002e53390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff165b92915050565b6001600160a01b03811681146200036a57600080fd5b50565b805161ffff811681146200038057600080fd5b919050565b805163ffffffff811681146200038057600080fd5b600080600080600080600080610100898b031215620003b857600080fd5b8851620003c58162000354565b60208a0151909850620003d88162000354565b60408a0151909750620003eb8162000354565b9550620003fb60608a016200036d565b94506200040b60808a016200036d565b935060a08901516200041d8162000354565b92506200042d60c08a0162000385565b91506200043d60e08a0162000385565b90509295985092959890939650565b634e487b7160e01b600052601160045260246000fd5b63ffffffff8181168382160280821691908281146200048557620004856200044c565b505092915050565b63ffffffff828116828216039080821115620004ad57620004ad6200044c565b5092915050565b600060208284031215620004c757600080fd5b815160ff81168114620004d957600080fd5b9392505050565b600181815b80851115620005215781600019048211156200050557620005056200044c565b808516156200051357918102915b93841c9390800290620004e5565b509250929050565b6000826200053a575060016200034e565b8162000549575060006200034e565b81600181146200056257600281146200056d576200058d565b60019150506200034e565b60ff8411156200058157620005816200044c565b50506001821b6200034e565b5060208310610133831016604e8410600b8410161715620005b2575081810a6200034e565b620005be8383620004e0565b8060001904821115620005d557620005d56200044c565b029392505050565b6000620004d960ff84168362000529565b60805160a05160c05160e0516101005161012051614538620006d160003960008181611023015261327e01526000818161088401528181611b4301528181611bb801528181611d420152612cc601526000818161051601528181611341015281816113d501528181611ded015281816120410152818161214501526123b80152600081816105c001528181611f030152611fa80152600081816104c701528181610c6d01528181610d8a01528181611f810152818161242c01526130970152600081816107e3015281816110010152818161325c01526133d001526145386000f3fe608060405234801561001057600080fd5b50600436106102d35760003560e01c80638ab1d68111610186578063bc0bc6ba116100e3578063e06fffa411610097578063f58af7db11610071578063f58af7db14610858578063fc0c546a1461087f578063ffc19224146108a657600080fd5b8063e06fffa414610805578063e43252d714610818578063e4a10abd1461082b57600080fd5b8063d547741f116100c8578063d547741f146107b8578063da8be864146107cb578063dedfbbfa146107de57600080fd5b8063bc0bc6ba14610792578063c2c39b08146107a557600080fd5b80639f25d7221161013a578063a5a9f84a1161011f578063a5a9f84a1461072f578063b8addc9614610742578063b97dd9e21461077757600080fd5b80639f25d72214610681578063a217fddf1461072757600080fd5b80639890220b1161016b5780639890220b14610653578063999927df1461065b5780639a61fd6f1461066e57600080fd5b80638ab1d6811461060957806391d148541461061c57600080fd5b8063361d004f116102345780636027bfb0116101e857806376cdb03b116101cd57806376cdb03b146105a857806378e97925146105bb5780638846da69146105e257600080fd5b80636027bfb01461051157806363052bb21461055057600080fd5b8063559301751161021957806355930175146104af57806357d775f8146104c25780635c19a95c146104fe57600080fd5b8063361d004f1461048957806336568abe1461049c57600080fd5b80631dd624671161028b5780632ec027bf116102705780632ec027bf1461043c5780632f2ff15d146104635780633587ec701461047657600080fd5b80631dd62467146103e0578063248a9ca31461040b57600080fd5b806309995d7f116102bc57806309995d7f146103155780631c12c613146103285780631d0c2652146103d857600080fd5b806301ffc9a7146102d857806306a89ca114610300575b600080fd5b6102eb6102e6366004613ef2565b6108b9565b60405190151581526020015b60405180910390f35b61031361030e366004613f46565b610952565b005b610313610323366004613f78565b610998565b610394610336366004613f78565b6003602052600090815260409020805460019091015461ffff80831692620100008104909116916001600160601b03640100000000830481169267ffffffffffffffff70010000000000000000000000000000000090910416911685565b6040805161ffff96871681529590941660208601526001600160601b039283169385019390935267ffffffffffffffff16606084015216608082015260a0016102f7565b6103136109b5565b6103f36103ee366004613f78565b610b21565b6040516001600160801b0390911681526020016102f7565b61042e610419366004613f93565b60009081526020819052604090206001015490565b6040519081526020016102f7565b61042e7fb54bb84ee3be50e6950d3bc7b4df6132e81f11695d45d3abf42ff629408f253981565b610313610471366004613fac565b611063565b6103f3610484366004613f78565b61108d565b610313610497366004613f78565b6110b0565b6103136104aa366004613fac565b6110f6565b6103136104bd366004613fd8565b611182565b6104e97f000000000000000000000000000000000000000000000000000000000000000081565b60405163ffffffff90911681526020016102f7565b61031361050c366004613f78565b6112f8565b6105387f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016102f7565b61056361055e36600461401b565b6117bf565b6040805183516001600160a01b0316815260208085015168ffffffffffffffffff16908201529281015161ffff908116918401919091521660608201526080016102f7565b600254610538906001600160a01b031681565b6104e97f000000000000000000000000000000000000000000000000000000000000000081565b61042e7fc4fb326a0f29357e7e664c75ea916c5b15852bf43b3ef049935b453971100f0a81565b610313610617366004613f78565b611952565b6102eb61062a366004613fac565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b610313611afc565b610313610669366004613f78565b611bdf565b6102eb61067c366004613f78565b611dc9565b6106e561068f366004613f78565b60046020526000908152604090205460ff81169061ffff6101008204811691630100000081048216916501000000000082048116916001600160801b0367010000000000000082041691600160b81b9091041686565b60408051961515875261ffff95861660208801529385169386019390935290831660608501526001600160801b031660808401521660a082015260c0016102f7565b61042e600081565b61031361073d366004613f46565b611e99565b610755610750366004613f46565b611ed8565b604080516001600160801b03909316835261ffff9091166020830152016102f7565b61077f611eef565b60405161ffff90911681526020016102f7565b61077f6107a0366004613f93565b611eff565b6107556107b3366004613f46565b611fe2565b6103136107c6366004613fac565b611ff0565b6103136107d9366004613f78565b612015565b6104e97f000000000000000000000000000000000000000000000000000000000000000081565b610313610813366004613f78565b612305565b610313610826366004613f78565b612659565b61083e61083936600461401b565b6127f1565b60408051921515835261ffff9091166020830152016102f7565b61042e7f9cc798953f1657230a000cfd0cfb877f321fc37733bbdaba923c800c0f6f63b681565b6105387f000000000000000000000000000000000000000000000000000000000000000081565b6103f36108b4366004613f78565b612956565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061094c57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b61095d816005612abb565b60405161ffff821681527fb7c5fd9f6249df36ef72e1a3e3d9820beb9a9a7b38efef6f5ce6c9d6af181d70906020015b60405180910390a150565b6109a0612bf2565b6109a981612c4b565b6109b260018055565b50565b336000908152600360209081526040918290208054835160608101909452602580855291936201000090910461ffff161515929091906144939083013990610a195760405162461bcd60e51b8152600401610a109190614069565b60405180910390fd5b50600080610a3433610a29611eef565b61055e9060016140b2565b91509150610a428282612d47565b6000805b5061ffff8082166000908152600286016020526040902080547fff000000000000000000000000000000000000000000000000000000000000008116909155600160e81b9004168015610a9b57809150610a46565b3360008181526003602090815260409182902080547fffffffffffffffff00000000000000000000000000000000000000000000000016815560010180546bffffffffffffffffffffffff1916905590519182527ff342139ca4d413a491f1cef1c72371556e3c982936b4e7184b58674e241c492c910160405180910390a15050505050565b6001600160a01b0381166000908152600360205260408120805461ffff1682610b48611eef565b905061ffff8216610b5a6001836140d4565b61ffff1611610b6e57506000949350505050565b600080610b7f6107508560016140b2565b9092509050600080610b968961055e8860016140b2565b91509150600080610bb2846000015189600161083991906140b2565b85516001600160a01b0316600090815260046020908152604080832061ffff9a8b1684526007835281842054988b16845260028f8101845282852054958c168552810190925282205496891698600160e81b909304831696939550600160e01b9093049091169250610c258a60016140b2565b90506000610c34888786612e2c565b905061ffff81161580610c4f57508961ffff168161ffff1610155b15610c575750885b8415610e1f57610c6782826140d4565b61ffff167f000000000000000000000000000000000000000000000000000000000000000063ffffffff16886020015168ffffffffffffffffff168b610cad91906140ef565b610cb791906140ef565b610cc191906140ef565b610ccb908e61411a565b6001840154909d5015610e1f57600183810154600091610cea9161413a565b90505b8261ffff16846001018281548110610d0757610d0761414d565b60009182526020909120015462010000900461ffff1610610e1d578161ffff16846001018281548110610d3c57610d3c61414d565b60009182526020909120015462010000900461ffff16108015610d8357506000846001018281548110610d7157610d7161414d565b60009182526020909120015461ffff16115b15610e05577f000000000000000000000000000000000000000000000000000000000000000063ffffffff168860200151856001018381548110610dc957610dc961414d565b600091825260209091200154610de3919061ffff16614163565b610ded9190614163565b610e029068ffffffffffffffffff168f61411a565b9d505b8015610e1d5780610e1581614188565b915050610ced565b505b8961ffff168161ffff160315610ff7578761ffff168161ffff1603610e685761ffff8082166000908152600660209081526040808320546007909252909120549082169a501697505b8561ffff168161ffff1603610f535761ffff808216600090815260028e016020908152604091829020825160608101845290546001600160a01b0380821680845268ffffffffffffffffff600160a01b84041694840194909452600160e81b9091049094169281019290925289519199929190911614610f305787516001600160a01b031660009081526004602052604090208851909450610f0a90836127f1565b61ffff9081166000908152600287016020526040902054919750600160e01b9091041694505b5061ffff808216600090815260028e016020526040902054600160e81b90041695505b8361ffff168161ffff1603610fc15761ffff811660009081526002840160205260409020805460ff1615610f8a5760009550610f9e565b8054610100900460ff1615610f9e57600195505b5061ffff8082166000908152600285016020526040902054600160e01b90041693505b809150610fcf888786612e2c565b905061ffff81161580610fea57508961ffff168161ffff1610155b15610ff25750885b610c57565b61104763ffffffff7f0000000000000000000000000000000000000000000000000000000000000000167f00000000000000000000000000000000000000000000000000000000000000006140ef565b611051908e6141d3565b9e9d5050505050505050505050505050565b60008281526020819052604090206001015461107e81612ecc565b6110888383612ed6565b505050565b6000611097612bf2565b6110a082612f74565b90506110ab60018055565b919050565b60006110bb81612ecc565b50600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6001600160a01b03811633146111745760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610a10565b61117e8282613330565b5050565b7fc4fb326a0f29357e7e664c75ea916c5b15852bf43b3ef049935b453971100f0a6111ac81612ecc565b6111b4611eef565b61ffff168361ffff1610156112315760405162461bcd60e51b815260206004820152602d60248201527f43616e6e6f74206772616e74206164646974696f6e616c20726577617264732060448201527f726574726f6163746976656c79000000000000000000000000000000000000006064820152608401610a10565b6001600160a01b03841660008181526004602090815260408083208151808301835261ffff8881168083528a821683870190815260019485018054958601815588529686902092519290930180549651821662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000009097169290911691909117949094179093558051938452908301919091527fc96041c5d70aebb7bb795817bab7964a05e1f39a37ee304c6aee0e19a3538f12910160405180910390a150505050565b611300612bf2565b3360008181526003602090815260408083206001600160a01b038681168552600493849052828520925163112acded60e21b815293840195909552939092917f0000000000000000000000000000000000000000000000000000000000000000909116906344ab37b4906024016040805180830381865afa158015611389573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ad9190614210565b604051630fd4003760e41b815233600482015290925060009150819081906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063fd40037090602401608060405180830381865afa15801561141c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114409190614252565b9350935050925060008367ffffffffffffffff16116040518060400160405280601d81526020017f4d75737420686176652061207374616b6520746f2064656c6567617465000000815250906114a95760405162461bcd60e51b8152600401610a109190614069565b508167ffffffffffffffff166000146040518060600160405280602a81526020016144d9602a9139906114ef5760405162461bcd60e51b8152600401610a109190614069565b50845460408051808201909152601c81527f50726f7669646572206d7573742062652077686974656c69737465640000000060208201529060ff166115475760405162461bcd60e51b8152600401610a109190614069565b506000611552611eef565b61155d9060016140b2565b905060008061156c33846117bf565b815191935091506001600160a01b0316158015906115bb5750896001600160a01b031682600001516001600160a01b03161415806115bb5750875461ffff650100000000009091048116908216105b156115ca576115ca8282612d47565b885462010000900461ffff166000036115fe576115e86001846140d4565b895461ffff191661ffff91909116178955611609565b6116098988866133af565b61161789848c8a888b6134b3565b896001600160a01b031682600001516001600160a01b031614158061164d5750875461ffff650100000000009091048116908216105b156116bb5761ffff8316600090815260028981016020526040909120805467ffffffffffffffff891692906116929084906201000090046001600160601b03166142a6565b92506101000a8154816001600160601b0302191690836001600160601b0316021790555061173e565b60208201516116d49067ffffffffffffffff88166142c6565b61ffff8416600090815260028a81016020526040909120805468ffffffffffffffffff93909316929091906117199084906201000090046001600160601b03166142a6565b92506101000a8154816001600160601b0302191690836001600160601b031602179055505b61174788613637565b885461ffff9190911663010000000264ffff0000001990911617885560405167ffffffffffffffff871681526001600160a01b038b169033907f24c73a8cd5729a711d07964c8034bffe7222a8297237b39a5424d499aa97b6f39060200160405180910390a35050505050505050506109b260018055565b60408051606081018252600080825260208201819052918101919091526001600160a01b0383166000908152600360205260408120805462010000900461ffff16820361181057506000905061194b565b805461ffff6201000090910481169085161061189357805461ffff620100009091048116600081815260029093016020908152604093849020845160608101865290546001600160a01b038116825268ffffffffffffffffff600160a01b82041692820192909252600160e81b909104909216928201929092529250905061194b565b60005b61ffff8181166000908152600284016020526040902054818716600160e81b90910490911611156119275761ffff808216600090815260029093016020908152604093849020845160608101865290546001600160a01b038116825268ffffffffffffffffff600160a01b82041692820192909252600160e81b90910490911692810192909252909250905061194b565b61ffff9081166000908152600283016020526040902054600160e81b900416611896565b9250929050565b61195a612bf2565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff16806119c557503360009081527f2fad6f534c831d814d61bd3f1935c89916c064d457ab36ff588d93f1b344468c602052604090205460ff165b6040518060400160405280600c81526020017f556e617574686f72697a6564000000000000000000000000000000000000000081525090611a195760405162461bcd60e51b8152600401610a109190614069565b506001600160a01b038116600090815260046020526040812090611a3b611eef565b9050611a4683612c4b565b81547fffffffffffffffffff00000000000000000000000000000000ffffffffffff0016825561ffff811660009081526002830160205260409020805460ff19166001179055611a95826136c3565b825461ffff91909116650100000000000266ffff0000000000199091161782556040516001600160a01b03841681527f441e43beaf2db8af6e1f9f7a6b9f0dcc36fcf83a2904264c9ab624068242efff9060200160405180910390a150506109b260018055565b6000611b0781612ecc565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526109b29033906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa158015611b8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bae91906142e8565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016919061375b565b611be7612bf2565b6001600160a01b0381166000908152600360209081526040918290205482516060810190935260258084526201000090910461ffff16151592916144939083013990611c465760405162461bcd60e51b8152600401610a109190614069565b50611c5081611dc9565b6040518060600160405280602181526020016144b86021913990611c875760405162461bcd60e51b8152600401610a109190614069565b506000611c9382610b21565b90506000816001600160801b0316116040518060400160405280600b81526020017f526577617264206973203000000000000000000000000000000000000000000081525090611cf65760405162461bcd60e51b8152600401610a109190614069565b506001611d01611eef565b611d0b91906140d4565b6001600160a01b038381166000908152600360205260409020805461ffff191661ffff9390931692909217909155600254611d75917f000000000000000000000000000000000000000000000000000000000000000081169116846001600160801b038516613804565b604080516001600160a01b03841681526001600160801b03831660208201527fef43505223391b62c1822fa8cb516c89c1ebe8d6d132bb1d4bb16aa024cf22da910160405180910390a1506109b260018055565b60405163112acded60e21b81526001600160a01b03828116600483015260009182917f000000000000000000000000000000000000000000000000000000000000000016906344ab37b4906024016040805180830381865afa158015611e33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e579190614210565b6001600160a01b039490941660009081526003602052604090205464010000000090046001600160601b03166001600160801b03909416939093149392505050565b611ea4816008612abb565b60405161ffff821681527f4cbb06fa60b98b90df166f921bd5cddfdde3e01f61701e13e7ba250188106f3a9060200161098d565b600080611ee6836005613855565b91509150915091565b6000611efa42611eff565b905090565b60007f000000000000000000000000000000000000000000000000000000000000000063ffffffff1682116040518060400160405280601d81526020017f54696d65206d7573742062652061667465722073746172742074696d6500000081525090611f7e5760405162461bcd60e51b8152600401610a109190614069565b507f000000000000000000000000000000000000000000000000000000000000000063ffffffff167f000000000000000000000000000000000000000000000000000000000000000063ffffffff1683611fd8919061413a565b61094c9190614301565b600080611ee6836008613855565b60008281526020819052604090206001015461200b81612ecc565b6110888383613330565b61201d612bf2565b604051630fd4003760e41b81526001600160a01b03828116600483015260009182917f0000000000000000000000000000000000000000000000000000000000000000169063fd40037090602401608060405180830381865afa158015612088573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120ac9190614252565b93509350505060008267ffffffffffffffff16116040518060400160405280601f81526020017f576974686472617720686173206e6f74206265656e2072657175657374656400815250906121145760405162461bcd60e51b8152600401610a109190614069565b506001600160a01b03838116600090815260036020526040808220905163112acded60e21b815233600482015290927f000000000000000000000000000000000000000000000000000000000000000016906344ab37b4906024016040805180830381865afa15801561218b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121af9190614210565b9150506121bd8282856133af565b60006121c7611eef565b6121d29060016140b2565b90506000806121e133846117bf565b915091506121ef8282612d47565b60006122048767ffffffffffffffff16611eff565b90508061ffff168261ffff1611156122905760006122273361055e6001866140d4565b61ffff858116600090815260028b01602052604080822080547fff0000000000000000000000000000000000000000000000000000000000000016905592909116808252919020805461ffff60e81b19169055885463ffff000019166201000090910217885550505b6122a086826000888b60006134b3565b825160208085015160405168ffffffffffffffffff90911681526001600160a01b03928316928c16917fc909aa6ad3220db7f68d6c9419dc76f84c8003fb90e6c6709fe7f01344875462910160405180910390a350505050505050506109b260018055565b61230d612bf2565b7f9cc798953f1657230a000cfd0cfb877f321fc37733bbdaba923c800c0f6f63b661233781612ecc565b61234082611dc9565b156040518060400160405280600f81526020017f5374616b652069732073796e6365640000000000000000000000000000000000815250906123955760405162461bcd60e51b8152600401610a109190614069565b50604051630fd4003760e41b81526001600160a01b0383811660048301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063fd40037090602401608060405180830381865afa158015612401573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124259190614252565b93505050507f000000000000000000000000000000000000000000000000000000000000000063ffffffff168167ffffffffffffffff1642612467919061413a565b116040518060400160405280601481526020017f4368616e676520697320746f6f20726563656e74000000000000000000000000815250906124bc5760405162461bcd60e51b8152600401610a109190614069565b506001600160a01b0383166000908152600360209081526040918290208054835160608101909452602580855291936201000090910461ffff1615159290919061449390830139906125215760405162461bcd60e51b8152600401610a109190614069565b50600061252c611eef565b90506000806125408761055e8560016140b2565b9150915061254e8282612d47565b604080516060810182526000808252602080830182815283850183815261ffff898116855260028b01909352949092209251835492519451909116600160e81b0261ffff60e81b1968ffffffffffffffffff909516600160a01b027fffffff00000000000000000000000000000000000000000000000000000000009093166001600160a01b039092169190911791909117929092169190911790556125f483856138f1565b845461ffff91909116620100000263ffff0000199091161784556040516001600160a01b03881681527ff4121035e07e1bf50eab89f52c0a5f0ef9f4a57fc875681e8de25a231f9567759060200160405180910390a15050505050506109b260018055565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff16806126c457503360009081527f2fad6f534c831d814d61bd3f1935c89916c064d457ab36ff588d93f1b344468c602052604090205460ff165b6040518060400160405280600c81526020017f556e617574686f72697a65640000000000000000000000000000000000000000815250906127185760405162461bcd60e51b8152600401610a109190614069565b506000612723611eef565b6001600160a01b0383166000908152600460209081526040808320805460ff1916600117815561ffff851684526002810190925290912080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16610100179055909150612790816136c3565b815461ffff91909116650100000000000266ffff0000000000199091161781556040516001600160a01b03841681527f2373c347d35d91064d64b63157cb8aee2bd652a41983ca2e8a3e7348bfeff92f9060200160405180910390a1505050565b6001600160a01b0382166000908152600460205260408120805482919065010000000000900461ffff16820361282e57600080925092505061194b565b805460009061ffff650100000000009091048116908616106128b75750805465010000000000900461ffff1660009081526002820160205260409020805460ff161561288e5750546000925065010000000000900461ffff16905061194b565b8054610100900460ff16156128b75750546001925065010000000000900461ffff16905061194b565b60005b61ffff8181166000908152600285016020526040902054818816600160e01b90910490911611156129325761ffff811660009081526002840160205260409020805490925060ff16156129155760009450925061194b915050565b8154610100900460ff16156129325760019450925061194b915050565b61ffff9081166000908152600284016020526040902054600160e01b9004166128ba565b6001600160a01b03811660009081526004602090815260408083208054600160b81b810461ffff908116865260028301909452918420546701000000000000009092046001600160801b0316939092600160d01b909204909116905b61ffff821615806129dd575060016129c8611eef565b6129d291906140d4565b61ffff168261ffff16115b612ab3575061ffff81166000908152600283016020526040902080546201000090046001600160601b031615612a2b578054612a28906201000090046001600160601b03168561411a565b93505b8054600160701b90046001600160601b031615612a8c578054600160701b90046001600160601b03166001600160801b0385161115612a87578054612a8090600160701b90046001600160601b031685614315565b9350612a8c565b600093505b61ffff9182166000908152600284016020526040902054600160d01b9004909116906129b2565b505050919050565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff1680612b2657503360009081527fc342493bf0f29bc7b419c89b92007cc16992810c027f6983a264f9a7ce1c9b99602052604090205460ff165b6040518060400160405280600c81526020017f556e617574686f72697a6564000000000000000000000000000000000000000081525090612b7a5760405162461bcd60e51b8152600401610a109190614069565b506000612b85611eef565b612b909060016140b2565b61ffff81811660008181526001860160205260409020805461ffff1916878416179055845492935091161461108857815461ffff90811660009081526002840160205260409020805461ffff1990811693909216928317905582541617905550565b600260015403612c445760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a10565b6002600155565b6000612c5682612f74565b90506001612c62611eef565b612c6c91906140d4565b6001600160a01b038084166000908152600460205260409020805461ffff93909316610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ff90931692909217909155600254612cf9917f000000000000000000000000000000000000000000000000000000000000000081169116846001600160801b038516613804565b604080516001600160a01b03841681526001600160801b03831660208201527f1a37fda35171b6151f4e7ae8aa53df21f025cf0cb96e363cfa48f504ba9456de910160405180910390a15050565b6000612d51611eef565b612d5c9060016140b2565b83516001600160a01b0316600090815260046020526040902080549192509061ffff65010000000000909104811690841610612e265760208481015161ffff84166000908152600284019092526040909120805468ffffffffffffffffff90921691600e90612ddc908490600160701b90046001600160601b03166142a6565b92506101000a8154816001600160601b0302191690836001600160601b03160217905550612e0981613637565b815461ffff9190911663010000000264ffff000000199091161781555b50505050565b600061ffff8416158015612e42575061ffff8316155b8015612e50575061ffff8216155b15612e5d57506000612ec5565b5061ffff83811615801590612e7957508061ffff168461ffff16105b15612e815750825b61ffff831615801590612e9b57508061ffff168361ffff16105b15612ea35750815b61ffff821615801590612ebd57508061ffff168261ffff16105b15612ec55750805b9392505050565b6109b2813361394c565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1661117e576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055612f303390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6001600160a01b038116600090815260046020526040812081612f95611eef565b8254909150610100900461ffff16612fae6001836140d4565b61ffff1611612fc1575060009392505050565b81546001600160801b036701000000000000008204169061ffff600160b81b82048116916000918291612fff916107b39161010090041660016140b2565b61ffff9081166000908152600a6020908152604080832054848916845260028c019092528220548a54600160d01b9091048416979496509083169450909161304e9161010090041660016140b2565b9050600061305c84876139bf565b905061ffff8116158061307757508761ffff168161ffff1610155b1561307f5750865b60005b61308c83836140d4565b61ffff1663ffffffff7f0000000000000000000000000000000000000000000000000000000000000000166130c18a896140ef565b6130cb91906140ef565b6130d591906140ef565b6130df908c61411a565b9a508861ffff168261ffff160315613252578461ffff168261ffff160361312a5761ffff808316600090815260096020908152604080832054600a9092529091205490821697501694505b8661ffff168261ffff160361321c57506001600160a01b038b16600090815260046020908152604080832061ffff85168452600201909152902080546201000090046001600160601b031615613198578054613195906201000090046001600160601b03168961411a565b97505b8054600160701b90046001600160601b0316156131f9578054600160701b90046001600160601b03166001600160801b03891611156131f45780546131ed90600160701b90046001600160601b031689614315565b97506131f9565b600097505b61ffff808316600090815260028c016020526040902054600160d01b9004169693505b81925061322985886139bf565b915061ffff8216158061324457508861ffff168261ffff1610155b1561324d578891505b613082565b6132a263ffffffff7f0000000000000000000000000000000000000000000000000000000000000000167f00000000000000000000000000000000000000000000000000000000000000006140ef565b6132ac908c6141d3565b8a5461ffff909516600160b81b027fffffffffffffff0000ffffffffffffffffffffffffffffffffffffffffffffff6001600160801b03909a1667010000000000000002999099167fffffffffffffff000000000000000000000000000000000000ffffffffffffff90951694909417979097179098555098975050505050505050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff161561117e576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b82546001600160801b0383169064010000000081046001600160601b0316907f000000000000000000000000000000000000000000000000000000000000000063ffffffff169061341e90700100000000000000000000000000000000900467ffffffffffffffff1685614335565b60018701546134409167ffffffffffffffff16906001600160601b0316614356565b61344a9190614379565b61345491906142a6565b6001600160601b031611156040518060400160405280601e81526020017f57697468647261776e20776974686f757420756e64656c65676174696e67000081525090612e265760405162461bcd60e51b8152600401610a109190614069565b604080516060810182526001600160a01b03808716825267ffffffffffffffff84166020808401918252600084860181815261ffff8c8116835260028e019093529590209351845492519551909116600160e81b0261ffff60e81b1968ffffffffffffffffff96909616600160a01b027fffffff00000000000000000000000000000000000000000000000000000000009093169190931617179290921691909117905561356185876138f1565b865460018801805467ffffffffffffffff9485166bffffffffffffffffffffffff199091161790557fffffffffffffffffffffffffffffffff0000000000000000000000000000ffff166201000061ffff909216919091027fffffffffffffffffffffffffffffffff000000000000000000000000ffffffff16176401000000006001600160601b039490941693909302929092177fffffffffffffffff0000000000000000ffffffffffffffffffffffffffffffff167001000000000000000000000000000000009190921602179092555050565b600080613642611eef565b61364d9060016140b2565b835461ffff6301000000909104811660008181526002870160205260409020929350908316146136af5780547fffffffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffff16600160d01b61ffff84160217905592915050565b505090546301000000900461ffff16919050565b805465010000000000900461ffff16600090815260028201602052604081206136ea611eef565b835465010000000000900461ffff9081169116146137485761370a611eef565b815461ffff91909116600160e01b027fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff909116178155612ec5611eef565b50505465010000000000900461ffff1690565b6040516001600160a01b0383166024820152604481018290526110889084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613a2b565b6040516001600160a01b0380851660248301528316604482015260648101829052612e269085907f23b872dd00000000000000000000000000000000000000000000000000000000906084016137a0565b8054600090819061ffff9081169085161061388e575050805461ffff90811660008181526001840160205260409020549091169061194b565b60005b61ffff8181166000908152600286016020526040902054818716911611156138d45761ffff8082166000908152600186016020526040902054169250905061194b565b61ffff908116600090815260028501602052604090205416613891565b805461ffff62010000909104811660008181526002840160205260408120909290919085161461393a57805461ffff60e81b1916600160e81b61ffff861602179055508161094c565b50505462010000900461ffff16919050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1661117e5761397d81613b10565b613988836020613b22565b604051602001613999929190614393565b60408051601f198184030181529082905262461bcd60e51b8252610a1091600401614069565b600061ffff83161580156139d5575061ffff8216155b156139e25750600061094c565b5061ffff828116158015906139fe57508061ffff168361ffff16105b15613a065750815b61ffff821615801590613a2057508061ffff168261ffff16105b1561094c5750919050565b6000613a80826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613d4b9092919063ffffffff16565b8051909150156110885780806020019051810190613a9e9190614414565b6110885760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610a10565b606061094c6001600160a01b03831660145b60606000613b31836002614436565b613b3c90600261444d565b67ffffffffffffffff811115613b5457613b54614460565b6040519080825280601f01601f191660200182016040528015613b7e576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110613bb557613bb561414d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110613c1857613c1861414d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000613c54846002614436565b613c5f90600161444d565b90505b6001811115613cfc577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110613ca057613ca061414d565b1a60f81b828281518110613cb657613cb661414d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93613cf581614188565b9050613c62565b508315612ec55760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a10565b6060613d5a8484600085613d62565b949350505050565b606082471015613dda5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610a10565b600080866001600160a01b03168587604051613df69190614476565b60006040518083038185875af1925050503d8060008114613e33576040519150601f19603f3d011682016040523d82523d6000602084013e613e38565b606091505b5091509150613e4987838387613e54565b979650505050505050565b60608315613ec3578251600003613ebc576001600160a01b0385163b613ebc5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a10565b5081613d5a565b613d5a8383815115613ed85781518083602001fd5b8060405162461bcd60e51b8152600401610a109190614069565b600060208284031215613f0457600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114612ec557600080fd5b803561ffff811681146110ab57600080fd5b600060208284031215613f5857600080fd5b612ec582613f34565b80356001600160a01b03811681146110ab57600080fd5b600060208284031215613f8a57600080fd5b612ec582613f61565b600060208284031215613fa557600080fd5b5035919050565b60008060408385031215613fbf57600080fd5b82359150613fcf60208401613f61565b90509250929050565b600080600060608486031215613fed57600080fd5b613ff684613f61565b925061400460208501613f34565b915061401260408501613f34565b90509250925092565b6000806040838503121561402e57600080fd5b61403783613f61565b9150613fcf60208401613f34565b60005b83811015614060578181015183820152602001614048565b50506000910152565b6020815260008251806020840152614088816040850160208701614045565b601f01601f19169190910160400192915050565b634e487b7160e01b600052601160045260246000fd5b61ffff8181168382160190808211156140cd576140cd61409c565b5092915050565b61ffff8281168282160390808211156140cd576140cd61409c565b6001600160801b038181168382160280821691908281146141125761411261409c565b505092915050565b6001600160801b038181168382160190808211156140cd576140cd61409c565b8181038181111561094c5761094c61409c565b634e487b7160e01b600052603260045260246000fd5b68ffffffffffffffffff8181168382160280821691908281146141125761411261409c565b6000816141975761419761409c565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b634e487b7160e01b600052601260045260246000fd5b60006001600160801b03808416806141ed576141ed6141bd565b92169190910492915050565b80516001600160801b03811681146110ab57600080fd5b6000806040838503121561422357600080fd5b61422c836141f9565b9150613fcf602084016141f9565b805167ffffffffffffffff811681146110ab57600080fd5b6000806000806080858703121561426857600080fd5b6142718561423a565b935061427f6020860161423a565b925061428d6040860161423a565b915061429b6060860161423a565b905092959194509250565b6001600160601b038181168382160190808211156140cd576140cd61409c565b68ffffffffffffffffff8281168282160390808211156140cd576140cd61409c565b6000602082840312156142fa57600080fd5b5051919050565b600082614310576143106141bd565b500490565b6001600160801b038281168282160390808211156140cd576140cd61409c565b67ffffffffffffffff8281168282160390808211156140cd576140cd61409c565b6001600160601b038181168382160280821691908281146141125761411261409c565b60006001600160601b03808416806141ed576141ed6141bd565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516143cb816017850160208801614045565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351614408816028840160208801614045565b01602801949350505050565b60006020828403121561442657600080fd5b81518015158114612ec557600080fd5b808202811582820484141761094c5761094c61409c565b8082018082111561094c5761094c61409c565b634e487b7160e01b600052604160045260246000fd5b60008251614488818460208701614045565b919091019291505056fe41646472657373206d757374206d616b6520612066697273742064656c65676174696f6e2e54696d656c696e6520646f6573206e6f74206d6174636820776974682054574e2e43616e6e6f74206368616e67652064656c65676174696f6e207768696c65207769746864726177696e67a264697066735822122047890c57d563d9357a191fcfa66f231b22646f8adf0dd630d0038c6afedfdb9c64736f6c634300081100330000000000000000000000008a2279d4a90b6fe1c4b30fa660cc9f926797baa2000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b00000000000000000000000095a260218497ea7420168a15f4d062651ec784c700000000000000000000000000000000000000000000000000000000000002240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fbea240239932dfa7ec1c50024992b0e366315e500000000000000000000000000000000000000000000000000000000000151800000000000000000000000000000000000000000000000000000000000000007

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102d35760003560e01c80638ab1d68111610186578063bc0bc6ba116100e3578063e06fffa411610097578063f58af7db11610071578063f58af7db14610858578063fc0c546a1461087f578063ffc19224146108a657600080fd5b8063e06fffa414610805578063e43252d714610818578063e4a10abd1461082b57600080fd5b8063d547741f116100c8578063d547741f146107b8578063da8be864146107cb578063dedfbbfa146107de57600080fd5b8063bc0bc6ba14610792578063c2c39b08146107a557600080fd5b80639f25d7221161013a578063a5a9f84a1161011f578063a5a9f84a1461072f578063b8addc9614610742578063b97dd9e21461077757600080fd5b80639f25d72214610681578063a217fddf1461072757600080fd5b80639890220b1161016b5780639890220b14610653578063999927df1461065b5780639a61fd6f1461066e57600080fd5b80638ab1d6811461060957806391d148541461061c57600080fd5b8063361d004f116102345780636027bfb0116101e857806376cdb03b116101cd57806376cdb03b146105a857806378e97925146105bb5780638846da69146105e257600080fd5b80636027bfb01461051157806363052bb21461055057600080fd5b8063559301751161021957806355930175146104af57806357d775f8146104c25780635c19a95c146104fe57600080fd5b8063361d004f1461048957806336568abe1461049c57600080fd5b80631dd624671161028b5780632ec027bf116102705780632ec027bf1461043c5780632f2ff15d146104635780633587ec701461047657600080fd5b80631dd62467146103e0578063248a9ca31461040b57600080fd5b806309995d7f116102bc57806309995d7f146103155780631c12c613146103285780631d0c2652146103d857600080fd5b806301ffc9a7146102d857806306a89ca114610300575b600080fd5b6102eb6102e6366004613ef2565b6108b9565b60405190151581526020015b60405180910390f35b61031361030e366004613f46565b610952565b005b610313610323366004613f78565b610998565b610394610336366004613f78565b6003602052600090815260409020805460019091015461ffff80831692620100008104909116916001600160601b03640100000000830481169267ffffffffffffffff70010000000000000000000000000000000090910416911685565b6040805161ffff96871681529590941660208601526001600160601b039283169385019390935267ffffffffffffffff16606084015216608082015260a0016102f7565b6103136109b5565b6103f36103ee366004613f78565b610b21565b6040516001600160801b0390911681526020016102f7565b61042e610419366004613f93565b60009081526020819052604090206001015490565b6040519081526020016102f7565b61042e7fb54bb84ee3be50e6950d3bc7b4df6132e81f11695d45d3abf42ff629408f253981565b610313610471366004613fac565b611063565b6103f3610484366004613f78565b61108d565b610313610497366004613f78565b6110b0565b6103136104aa366004613fac565b6110f6565b6103136104bd366004613fd8565b611182565b6104e97f0000000000000000000000000000000000000000000000000000000000093a8081565b60405163ffffffff90911681526020016102f7565b61031361050c366004613f78565b6112f8565b6105387f000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b81565b6040516001600160a01b0390911681526020016102f7565b61056361055e36600461401b565b6117bf565b6040805183516001600160a01b0316815260208085015168ffffffffffffffffff16908201529281015161ffff908116918401919091521660608201526080016102f7565b600254610538906001600160a01b031681565b6104e97f0000000000000000000000000000000000000000000000000000000064849bef81565b61042e7fc4fb326a0f29357e7e664c75ea916c5b15852bf43b3ef049935b453971100f0a81565b610313610617366004613f78565b611952565b6102eb61062a366004613fac565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b610313611afc565b610313610669366004613f78565b611bdf565b6102eb61067c366004613f78565b611dc9565b6106e561068f366004613f78565b60046020526000908152604090205460ff81169061ffff6101008204811691630100000081048216916501000000000082048116916001600160801b0367010000000000000082041691600160b81b9091041686565b60408051961515875261ffff95861660208801529385169386019390935290831660608501526001600160801b031660808401521660a082015260c0016102f7565b61042e600081565b61031361073d366004613f46565b611e99565b610755610750366004613f46565b611ed8565b604080516001600160801b03909316835261ffff9091166020830152016102f7565b61077f611eef565b60405161ffff90911681526020016102f7565b61077f6107a0366004613f93565b611eff565b6107556107b3366004613f46565b611fe2565b6103136107c6366004613fac565b611ff0565b6103136107d9366004613f78565b612015565b6104e97f000000000000000000000000000000000000000000000000000000000001518081565b610313610813366004613f78565b612305565b610313610826366004613f78565b612659565b61083e61083936600461401b565b6127f1565b60408051921515835261ffff9091166020830152016102f7565b61042e7f9cc798953f1657230a000cfd0cfb877f321fc37733bbdaba923c800c0f6f63b681565b6105387f0000000000000000000000008a2279d4a90b6fe1c4b30fa660cc9f926797baa281565b6103f36108b4366004613f78565b612956565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061094c57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b61095d816005612abb565b60405161ffff821681527fb7c5fd9f6249df36ef72e1a3e3d9820beb9a9a7b38efef6f5ce6c9d6af181d70906020015b60405180910390a150565b6109a0612bf2565b6109a981612c4b565b6109b260018055565b50565b336000908152600360209081526040918290208054835160608101909452602580855291936201000090910461ffff161515929091906144939083013990610a195760405162461bcd60e51b8152600401610a109190614069565b60405180910390fd5b50600080610a3433610a29611eef565b61055e9060016140b2565b91509150610a428282612d47565b6000805b5061ffff8082166000908152600286016020526040902080547fff000000000000000000000000000000000000000000000000000000000000008116909155600160e81b9004168015610a9b57809150610a46565b3360008181526003602090815260409182902080547fffffffffffffffff00000000000000000000000000000000000000000000000016815560010180546bffffffffffffffffffffffff1916905590519182527ff342139ca4d413a491f1cef1c72371556e3c982936b4e7184b58674e241c492c910160405180910390a15050505050565b6001600160a01b0381166000908152600360205260408120805461ffff1682610b48611eef565b905061ffff8216610b5a6001836140d4565b61ffff1611610b6e57506000949350505050565b600080610b7f6107508560016140b2565b9092509050600080610b968961055e8860016140b2565b91509150600080610bb2846000015189600161083991906140b2565b85516001600160a01b0316600090815260046020908152604080832061ffff9a8b1684526007835281842054988b16845260028f8101845282852054958c168552810190925282205496891698600160e81b909304831696939550600160e01b9093049091169250610c258a60016140b2565b90506000610c34888786612e2c565b905061ffff81161580610c4f57508961ffff168161ffff1610155b15610c575750885b8415610e1f57610c6782826140d4565b61ffff167f0000000000000000000000000000000000000000000000000000000000093a8063ffffffff16886020015168ffffffffffffffffff168b610cad91906140ef565b610cb791906140ef565b610cc191906140ef565b610ccb908e61411a565b6001840154909d5015610e1f57600183810154600091610cea9161413a565b90505b8261ffff16846001018281548110610d0757610d0761414d565b60009182526020909120015462010000900461ffff1610610e1d578161ffff16846001018281548110610d3c57610d3c61414d565b60009182526020909120015462010000900461ffff16108015610d8357506000846001018281548110610d7157610d7161414d565b60009182526020909120015461ffff16115b15610e05577f0000000000000000000000000000000000000000000000000000000000093a8063ffffffff168860200151856001018381548110610dc957610dc961414d565b600091825260209091200154610de3919061ffff16614163565b610ded9190614163565b610e029068ffffffffffffffffff168f61411a565b9d505b8015610e1d5780610e1581614188565b915050610ced565b505b8961ffff168161ffff160315610ff7578761ffff168161ffff1603610e685761ffff8082166000908152600660209081526040808320546007909252909120549082169a501697505b8561ffff168161ffff1603610f535761ffff808216600090815260028e016020908152604091829020825160608101845290546001600160a01b0380821680845268ffffffffffffffffff600160a01b84041694840194909452600160e81b9091049094169281019290925289519199929190911614610f305787516001600160a01b031660009081526004602052604090208851909450610f0a90836127f1565b61ffff9081166000908152600287016020526040902054919750600160e01b9091041694505b5061ffff808216600090815260028e016020526040902054600160e81b90041695505b8361ffff168161ffff1603610fc15761ffff811660009081526002840160205260409020805460ff1615610f8a5760009550610f9e565b8054610100900460ff1615610f9e57600195505b5061ffff8082166000908152600285016020526040902054600160e01b90041693505b809150610fcf888786612e2c565b905061ffff81161580610fea57508961ffff168161ffff1610155b15610ff25750885b610c57565b61104763ffffffff7f0000000000000000000000000000000000000000000000000000000000015180167f00000000000000000000000000000000000000000000000000000000000f42406140ef565b611051908e6141d3565b9e9d5050505050505050505050505050565b60008281526020819052604090206001015461107e81612ecc565b6110888383612ed6565b505050565b6000611097612bf2565b6110a082612f74565b90506110ab60018055565b919050565b60006110bb81612ecc565b50600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6001600160a01b03811633146111745760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610a10565b61117e8282613330565b5050565b7fc4fb326a0f29357e7e664c75ea916c5b15852bf43b3ef049935b453971100f0a6111ac81612ecc565b6111b4611eef565b61ffff168361ffff1610156112315760405162461bcd60e51b815260206004820152602d60248201527f43616e6e6f74206772616e74206164646974696f6e616c20726577617264732060448201527f726574726f6163746976656c79000000000000000000000000000000000000006064820152608401610a10565b6001600160a01b03841660008181526004602090815260408083208151808301835261ffff8881168083528a821683870190815260019485018054958601815588529686902092519290930180549651821662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000009097169290911691909117949094179093558051938452908301919091527fc96041c5d70aebb7bb795817bab7964a05e1f39a37ee304c6aee0e19a3538f12910160405180910390a150505050565b611300612bf2565b3360008181526003602090815260408083206001600160a01b038681168552600493849052828520925163112acded60e21b815293840195909552939092917f000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b909116906344ab37b4906024016040805180830381865afa158015611389573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ad9190614210565b604051630fd4003760e41b815233600482015290925060009150819081906001600160a01b037f000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b169063fd40037090602401608060405180830381865afa15801561141c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114409190614252565b9350935050925060008367ffffffffffffffff16116040518060400160405280601d81526020017f4d75737420686176652061207374616b6520746f2064656c6567617465000000815250906114a95760405162461bcd60e51b8152600401610a109190614069565b508167ffffffffffffffff166000146040518060600160405280602a81526020016144d9602a9139906114ef5760405162461bcd60e51b8152600401610a109190614069565b50845460408051808201909152601c81527f50726f7669646572206d7573742062652077686974656c69737465640000000060208201529060ff166115475760405162461bcd60e51b8152600401610a109190614069565b506000611552611eef565b61155d9060016140b2565b905060008061156c33846117bf565b815191935091506001600160a01b0316158015906115bb5750896001600160a01b031682600001516001600160a01b03161415806115bb5750875461ffff650100000000009091048116908216105b156115ca576115ca8282612d47565b885462010000900461ffff166000036115fe576115e86001846140d4565b895461ffff191661ffff91909116178955611609565b6116098988866133af565b61161789848c8a888b6134b3565b896001600160a01b031682600001516001600160a01b031614158061164d5750875461ffff650100000000009091048116908216105b156116bb5761ffff8316600090815260028981016020526040909120805467ffffffffffffffff891692906116929084906201000090046001600160601b03166142a6565b92506101000a8154816001600160601b0302191690836001600160601b0316021790555061173e565b60208201516116d49067ffffffffffffffff88166142c6565b61ffff8416600090815260028a81016020526040909120805468ffffffffffffffffff93909316929091906117199084906201000090046001600160601b03166142a6565b92506101000a8154816001600160601b0302191690836001600160601b031602179055505b61174788613637565b885461ffff9190911663010000000264ffff0000001990911617885560405167ffffffffffffffff871681526001600160a01b038b169033907f24c73a8cd5729a711d07964c8034bffe7222a8297237b39a5424d499aa97b6f39060200160405180910390a35050505050505050506109b260018055565b60408051606081018252600080825260208201819052918101919091526001600160a01b0383166000908152600360205260408120805462010000900461ffff16820361181057506000905061194b565b805461ffff6201000090910481169085161061189357805461ffff620100009091048116600081815260029093016020908152604093849020845160608101865290546001600160a01b038116825268ffffffffffffffffff600160a01b82041692820192909252600160e81b909104909216928201929092529250905061194b565b60005b61ffff8181166000908152600284016020526040902054818716600160e81b90910490911611156119275761ffff808216600090815260029093016020908152604093849020845160608101865290546001600160a01b038116825268ffffffffffffffffff600160a01b82041692820192909252600160e81b90910490911692810192909252909250905061194b565b61ffff9081166000908152600283016020526040902054600160e81b900416611896565b9250929050565b61195a612bf2565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff16806119c557503360009081527f2fad6f534c831d814d61bd3f1935c89916c064d457ab36ff588d93f1b344468c602052604090205460ff165b6040518060400160405280600c81526020017f556e617574686f72697a6564000000000000000000000000000000000000000081525090611a195760405162461bcd60e51b8152600401610a109190614069565b506001600160a01b038116600090815260046020526040812090611a3b611eef565b9050611a4683612c4b565b81547fffffffffffffffffff00000000000000000000000000000000ffffffffffff0016825561ffff811660009081526002830160205260409020805460ff19166001179055611a95826136c3565b825461ffff91909116650100000000000266ffff0000000000199091161782556040516001600160a01b03841681527f441e43beaf2db8af6e1f9f7a6b9f0dcc36fcf83a2904264c9ab624068242efff9060200160405180910390a150506109b260018055565b6000611b0781612ecc565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526109b29033906001600160a01b037f0000000000000000000000008a2279d4a90b6fe1c4b30fa660cc9f926797baa216906370a0823190602401602060405180830381865afa158015611b8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bae91906142e8565b6001600160a01b037f0000000000000000000000008a2279d4a90b6fe1c4b30fa660cc9f926797baa216919061375b565b611be7612bf2565b6001600160a01b0381166000908152600360209081526040918290205482516060810190935260258084526201000090910461ffff16151592916144939083013990611c465760405162461bcd60e51b8152600401610a109190614069565b50611c5081611dc9565b6040518060600160405280602181526020016144b86021913990611c875760405162461bcd60e51b8152600401610a109190614069565b506000611c9382610b21565b90506000816001600160801b0316116040518060400160405280600b81526020017f526577617264206973203000000000000000000000000000000000000000000081525090611cf65760405162461bcd60e51b8152600401610a109190614069565b506001611d01611eef565b611d0b91906140d4565b6001600160a01b038381166000908152600360205260409020805461ffff191661ffff9390931692909217909155600254611d75917f0000000000000000000000008a2279d4a90b6fe1c4b30fa660cc9f926797baa281169116846001600160801b038516613804565b604080516001600160a01b03841681526001600160801b03831660208201527fef43505223391b62c1822fa8cb516c89c1ebe8d6d132bb1d4bb16aa024cf22da910160405180910390a1506109b260018055565b60405163112acded60e21b81526001600160a01b03828116600483015260009182917f000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b16906344ab37b4906024016040805180830381865afa158015611e33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e579190614210565b6001600160a01b039490941660009081526003602052604090205464010000000090046001600160601b03166001600160801b03909416939093149392505050565b611ea4816008612abb565b60405161ffff821681527f4cbb06fa60b98b90df166f921bd5cddfdde3e01f61701e13e7ba250188106f3a9060200161098d565b600080611ee6836005613855565b91509150915091565b6000611efa42611eff565b905090565b60007f0000000000000000000000000000000000000000000000000000000064849bef63ffffffff1682116040518060400160405280601d81526020017f54696d65206d7573742062652061667465722073746172742074696d6500000081525090611f7e5760405162461bcd60e51b8152600401610a109190614069565b507f0000000000000000000000000000000000000000000000000000000000093a8063ffffffff167f0000000000000000000000000000000000000000000000000000000064849bef63ffffffff1683611fd8919061413a565b61094c9190614301565b600080611ee6836008613855565b60008281526020819052604090206001015461200b81612ecc565b6110888383613330565b61201d612bf2565b604051630fd4003760e41b81526001600160a01b03828116600483015260009182917f000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b169063fd40037090602401608060405180830381865afa158015612088573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120ac9190614252565b93509350505060008267ffffffffffffffff16116040518060400160405280601f81526020017f576974686472617720686173206e6f74206265656e2072657175657374656400815250906121145760405162461bcd60e51b8152600401610a109190614069565b506001600160a01b03838116600090815260036020526040808220905163112acded60e21b815233600482015290927f000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b16906344ab37b4906024016040805180830381865afa15801561218b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121af9190614210565b9150506121bd8282856133af565b60006121c7611eef565b6121d29060016140b2565b90506000806121e133846117bf565b915091506121ef8282612d47565b60006122048767ffffffffffffffff16611eff565b90508061ffff168261ffff1611156122905760006122273361055e6001866140d4565b61ffff858116600090815260028b01602052604080822080547fff0000000000000000000000000000000000000000000000000000000000000016905592909116808252919020805461ffff60e81b19169055885463ffff000019166201000090910217885550505b6122a086826000888b60006134b3565b825160208085015160405168ffffffffffffffffff90911681526001600160a01b03928316928c16917fc909aa6ad3220db7f68d6c9419dc76f84c8003fb90e6c6709fe7f01344875462910160405180910390a350505050505050506109b260018055565b61230d612bf2565b7f9cc798953f1657230a000cfd0cfb877f321fc37733bbdaba923c800c0f6f63b661233781612ecc565b61234082611dc9565b156040518060400160405280600f81526020017f5374616b652069732073796e6365640000000000000000000000000000000000815250906123955760405162461bcd60e51b8152600401610a109190614069565b50604051630fd4003760e41b81526001600160a01b0383811660048301526000917f000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b9091169063fd40037090602401608060405180830381865afa158015612401573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124259190614252565b93505050507f0000000000000000000000000000000000000000000000000000000000093a8063ffffffff168167ffffffffffffffff1642612467919061413a565b116040518060400160405280601481526020017f4368616e676520697320746f6f20726563656e74000000000000000000000000815250906124bc5760405162461bcd60e51b8152600401610a109190614069565b506001600160a01b0383166000908152600360209081526040918290208054835160608101909452602580855291936201000090910461ffff1615159290919061449390830139906125215760405162461bcd60e51b8152600401610a109190614069565b50600061252c611eef565b90506000806125408761055e8560016140b2565b9150915061254e8282612d47565b604080516060810182526000808252602080830182815283850183815261ffff898116855260028b01909352949092209251835492519451909116600160e81b0261ffff60e81b1968ffffffffffffffffff909516600160a01b027fffffff00000000000000000000000000000000000000000000000000000000009093166001600160a01b039092169190911791909117929092169190911790556125f483856138f1565b845461ffff91909116620100000263ffff0000199091161784556040516001600160a01b03881681527ff4121035e07e1bf50eab89f52c0a5f0ef9f4a57fc875681e8de25a231f9567759060200160405180910390a15050505050506109b260018055565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff16806126c457503360009081527f2fad6f534c831d814d61bd3f1935c89916c064d457ab36ff588d93f1b344468c602052604090205460ff165b6040518060400160405280600c81526020017f556e617574686f72697a65640000000000000000000000000000000000000000815250906127185760405162461bcd60e51b8152600401610a109190614069565b506000612723611eef565b6001600160a01b0383166000908152600460209081526040808320805460ff1916600117815561ffff851684526002810190925290912080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16610100179055909150612790816136c3565b815461ffff91909116650100000000000266ffff0000000000199091161781556040516001600160a01b03841681527f2373c347d35d91064d64b63157cb8aee2bd652a41983ca2e8a3e7348bfeff92f9060200160405180910390a1505050565b6001600160a01b0382166000908152600460205260408120805482919065010000000000900461ffff16820361282e57600080925092505061194b565b805460009061ffff650100000000009091048116908616106128b75750805465010000000000900461ffff1660009081526002820160205260409020805460ff161561288e5750546000925065010000000000900461ffff16905061194b565b8054610100900460ff16156128b75750546001925065010000000000900461ffff16905061194b565b60005b61ffff8181166000908152600285016020526040902054818816600160e01b90910490911611156129325761ffff811660009081526002840160205260409020805490925060ff16156129155760009450925061194b915050565b8154610100900460ff16156129325760019450925061194b915050565b61ffff9081166000908152600284016020526040902054600160e01b9004166128ba565b6001600160a01b03811660009081526004602090815260408083208054600160b81b810461ffff908116865260028301909452918420546701000000000000009092046001600160801b0316939092600160d01b909204909116905b61ffff821615806129dd575060016129c8611eef565b6129d291906140d4565b61ffff168261ffff16115b612ab3575061ffff81166000908152600283016020526040902080546201000090046001600160601b031615612a2b578054612a28906201000090046001600160601b03168561411a565b93505b8054600160701b90046001600160601b031615612a8c578054600160701b90046001600160601b03166001600160801b0385161115612a87578054612a8090600160701b90046001600160601b031685614315565b9350612a8c565b600093505b61ffff9182166000908152600284016020526040902054600160d01b9004909116906129b2565b505050919050565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff1680612b2657503360009081527fc342493bf0f29bc7b419c89b92007cc16992810c027f6983a264f9a7ce1c9b99602052604090205460ff165b6040518060400160405280600c81526020017f556e617574686f72697a6564000000000000000000000000000000000000000081525090612b7a5760405162461bcd60e51b8152600401610a109190614069565b506000612b85611eef565b612b909060016140b2565b61ffff81811660008181526001860160205260409020805461ffff1916878416179055845492935091161461108857815461ffff90811660009081526002840160205260409020805461ffff1990811693909216928317905582541617905550565b600260015403612c445760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a10565b6002600155565b6000612c5682612f74565b90506001612c62611eef565b612c6c91906140d4565b6001600160a01b038084166000908152600460205260409020805461ffff93909316610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ff90931692909217909155600254612cf9917f0000000000000000000000008a2279d4a90b6fe1c4b30fa660cc9f926797baa281169116846001600160801b038516613804565b604080516001600160a01b03841681526001600160801b03831660208201527f1a37fda35171b6151f4e7ae8aa53df21f025cf0cb96e363cfa48f504ba9456de910160405180910390a15050565b6000612d51611eef565b612d5c9060016140b2565b83516001600160a01b0316600090815260046020526040902080549192509061ffff65010000000000909104811690841610612e265760208481015161ffff84166000908152600284019092526040909120805468ffffffffffffffffff90921691600e90612ddc908490600160701b90046001600160601b03166142a6565b92506101000a8154816001600160601b0302191690836001600160601b03160217905550612e0981613637565b815461ffff9190911663010000000264ffff000000199091161781555b50505050565b600061ffff8416158015612e42575061ffff8316155b8015612e50575061ffff8216155b15612e5d57506000612ec5565b5061ffff83811615801590612e7957508061ffff168461ffff16105b15612e815750825b61ffff831615801590612e9b57508061ffff168361ffff16105b15612ea35750815b61ffff821615801590612ebd57508061ffff168261ffff16105b15612ec55750805b9392505050565b6109b2813361394c565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1661117e576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055612f303390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6001600160a01b038116600090815260046020526040812081612f95611eef565b8254909150610100900461ffff16612fae6001836140d4565b61ffff1611612fc1575060009392505050565b81546001600160801b036701000000000000008204169061ffff600160b81b82048116916000918291612fff916107b39161010090041660016140b2565b61ffff9081166000908152600a6020908152604080832054848916845260028c019092528220548a54600160d01b9091048416979496509083169450909161304e9161010090041660016140b2565b9050600061305c84876139bf565b905061ffff8116158061307757508761ffff168161ffff1610155b1561307f5750865b60005b61308c83836140d4565b61ffff1663ffffffff7f0000000000000000000000000000000000000000000000000000000000093a80166130c18a896140ef565b6130cb91906140ef565b6130d591906140ef565b6130df908c61411a565b9a508861ffff168261ffff160315613252578461ffff168261ffff160361312a5761ffff808316600090815260096020908152604080832054600a9092529091205490821697501694505b8661ffff168261ffff160361321c57506001600160a01b038b16600090815260046020908152604080832061ffff85168452600201909152902080546201000090046001600160601b031615613198578054613195906201000090046001600160601b03168961411a565b97505b8054600160701b90046001600160601b0316156131f9578054600160701b90046001600160601b03166001600160801b03891611156131f45780546131ed90600160701b90046001600160601b031689614315565b97506131f9565b600097505b61ffff808316600090815260028c016020526040902054600160d01b9004169693505b81925061322985886139bf565b915061ffff8216158061324457508861ffff168261ffff1610155b1561324d578891505b613082565b6132a263ffffffff7f0000000000000000000000000000000000000000000000000000000000015180167f00000000000000000000000000000000000000000000000000000000000f42406140ef565b6132ac908c6141d3565b8a5461ffff909516600160b81b027fffffffffffffff0000ffffffffffffffffffffffffffffffffffffffffffffff6001600160801b03909a1667010000000000000002999099167fffffffffffffff000000000000000000000000000000000000ffffffffffffff90951694909417979097179098555098975050505050505050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff161561117e576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b82546001600160801b0383169064010000000081046001600160601b0316907f000000000000000000000000000000000000000000000000000000000001518063ffffffff169061341e90700100000000000000000000000000000000900467ffffffffffffffff1685614335565b60018701546134409167ffffffffffffffff16906001600160601b0316614356565b61344a9190614379565b61345491906142a6565b6001600160601b031611156040518060400160405280601e81526020017f57697468647261776e20776974686f757420756e64656c65676174696e67000081525090612e265760405162461bcd60e51b8152600401610a109190614069565b604080516060810182526001600160a01b03808716825267ffffffffffffffff84166020808401918252600084860181815261ffff8c8116835260028e019093529590209351845492519551909116600160e81b0261ffff60e81b1968ffffffffffffffffff96909616600160a01b027fffffff00000000000000000000000000000000000000000000000000000000009093169190931617179290921691909117905561356185876138f1565b865460018801805467ffffffffffffffff9485166bffffffffffffffffffffffff199091161790557fffffffffffffffffffffffffffffffff0000000000000000000000000000ffff166201000061ffff909216919091027fffffffffffffffffffffffffffffffff000000000000000000000000ffffffff16176401000000006001600160601b039490941693909302929092177fffffffffffffffff0000000000000000ffffffffffffffffffffffffffffffff167001000000000000000000000000000000009190921602179092555050565b600080613642611eef565b61364d9060016140b2565b835461ffff6301000000909104811660008181526002870160205260409020929350908316146136af5780547fffffffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffff16600160d01b61ffff84160217905592915050565b505090546301000000900461ffff16919050565b805465010000000000900461ffff16600090815260028201602052604081206136ea611eef565b835465010000000000900461ffff9081169116146137485761370a611eef565b815461ffff91909116600160e01b027fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff909116178155612ec5611eef565b50505465010000000000900461ffff1690565b6040516001600160a01b0383166024820152604481018290526110889084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613a2b565b6040516001600160a01b0380851660248301528316604482015260648101829052612e269085907f23b872dd00000000000000000000000000000000000000000000000000000000906084016137a0565b8054600090819061ffff9081169085161061388e575050805461ffff90811660008181526001840160205260409020549091169061194b565b60005b61ffff8181166000908152600286016020526040902054818716911611156138d45761ffff8082166000908152600186016020526040902054169250905061194b565b61ffff908116600090815260028501602052604090205416613891565b805461ffff62010000909104811660008181526002840160205260408120909290919085161461393a57805461ffff60e81b1916600160e81b61ffff861602179055508161094c565b50505462010000900461ffff16919050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1661117e5761397d81613b10565b613988836020613b22565b604051602001613999929190614393565b60408051601f198184030181529082905262461bcd60e51b8252610a1091600401614069565b600061ffff83161580156139d5575061ffff8216155b156139e25750600061094c565b5061ffff828116158015906139fe57508061ffff168361ffff16105b15613a065750815b61ffff821615801590613a2057508061ffff168261ffff16105b1561094c5750919050565b6000613a80826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613d4b9092919063ffffffff16565b8051909150156110885780806020019051810190613a9e9190614414565b6110885760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610a10565b606061094c6001600160a01b03831660145b60606000613b31836002614436565b613b3c90600261444d565b67ffffffffffffffff811115613b5457613b54614460565b6040519080825280601f01601f191660200182016040528015613b7e576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110613bb557613bb561414d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110613c1857613c1861414d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000613c54846002614436565b613c5f90600161444d565b90505b6001811115613cfc577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110613ca057613ca061414d565b1a60f81b828281518110613cb657613cb661414d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93613cf581614188565b9050613c62565b508315612ec55760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a10565b6060613d5a8484600085613d62565b949350505050565b606082471015613dda5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610a10565b600080866001600160a01b03168587604051613df69190614476565b60006040518083038185875af1925050503d8060008114613e33576040519150601f19603f3d011682016040523d82523d6000602084013e613e38565b606091505b5091509150613e4987838387613e54565b979650505050505050565b60608315613ec3578251600003613ebc576001600160a01b0385163b613ebc5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a10565b5081613d5a565b613d5a8383815115613ed85781518083602001fd5b8060405162461bcd60e51b8152600401610a109190614069565b600060208284031215613f0457600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114612ec557600080fd5b803561ffff811681146110ab57600080fd5b600060208284031215613f5857600080fd5b612ec582613f34565b80356001600160a01b03811681146110ab57600080fd5b600060208284031215613f8a57600080fd5b612ec582613f61565b600060208284031215613fa557600080fd5b5035919050565b60008060408385031215613fbf57600080fd5b82359150613fcf60208401613f61565b90509250929050565b600080600060608486031215613fed57600080fd5b613ff684613f61565b925061400460208501613f34565b915061401260408501613f34565b90509250925092565b6000806040838503121561402e57600080fd5b61403783613f61565b9150613fcf60208401613f34565b60005b83811015614060578181015183820152602001614048565b50506000910152565b6020815260008251806020840152614088816040850160208701614045565b601f01601f19169190910160400192915050565b634e487b7160e01b600052601160045260246000fd5b61ffff8181168382160190808211156140cd576140cd61409c565b5092915050565b61ffff8281168282160390808211156140cd576140cd61409c565b6001600160801b038181168382160280821691908281146141125761411261409c565b505092915050565b6001600160801b038181168382160190808211156140cd576140cd61409c565b8181038181111561094c5761094c61409c565b634e487b7160e01b600052603260045260246000fd5b68ffffffffffffffffff8181168382160280821691908281146141125761411261409c565b6000816141975761419761409c565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b634e487b7160e01b600052601260045260246000fd5b60006001600160801b03808416806141ed576141ed6141bd565b92169190910492915050565b80516001600160801b03811681146110ab57600080fd5b6000806040838503121561422357600080fd5b61422c836141f9565b9150613fcf602084016141f9565b805167ffffffffffffffff811681146110ab57600080fd5b6000806000806080858703121561426857600080fd5b6142718561423a565b935061427f6020860161423a565b925061428d6040860161423a565b915061429b6060860161423a565b905092959194509250565b6001600160601b038181168382160190808211156140cd576140cd61409c565b68ffffffffffffffffff8281168282160390808211156140cd576140cd61409c565b6000602082840312156142fa57600080fd5b5051919050565b600082614310576143106141bd565b500490565b6001600160801b038281168282160390808211156140cd576140cd61409c565b67ffffffffffffffff8281168282160390808211156140cd576140cd61409c565b6001600160601b038181168382160280821691908281146141125761411261409c565b60006001600160601b03808416806141ed576141ed6141bd565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516143cb816017850160208801614045565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351614408816028840160208801614045565b01602801949350505050565b60006020828403121561442657600080fd5b81518015158114612ec557600080fd5b808202811582820484141761094c5761094c61409c565b8082018082111561094c5761094c61409c565b634e487b7160e01b600052604160045260246000fd5b60008251614488818460208701614045565b919091019291505056fe41646472657373206d757374206d616b6520612066697273742064656c65676174696f6e2e54696d656c696e6520646f6573206e6f74206d6174636820776974682054574e2e43616e6e6f74206368616e67652064656c65676174696f6e207768696c65207769746864726177696e67a264697066735822122047890c57d563d9357a191fcfa66f231b22646f8adf0dd630d0038c6afedfdb9c64736f6c63430008110033

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

0000000000000000000000008a2279d4a90b6fe1c4b30fa660cc9f926797baa2000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b00000000000000000000000095a260218497ea7420168a15f4d062651ec784c700000000000000000000000000000000000000000000000000000000000002240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fbea240239932dfa7ec1c50024992b0e366315e500000000000000000000000000000000000000000000000000000000000151800000000000000000000000000000000000000000000000000000000000000007

-----Decoded View---------------
Arg [0] : _token (address): 0x8A2279d4A90B6fe1C4B30fa660cC9f926797bAA2
Arg [1] : _twn (address): 0xC7b0F970c1EFBB181194Fc15ccD5C4a2c2Ab863B
Arg [2] : _owner (address): 0x95a260218497ea7420168A15f4D062651Ec784C7
Arg [3] : _delegatorYield (uint16): 548
Arg [4] : _totalDelegationYield (uint16): 0
Arg [5] : _bank (address): 0xfbea240239932dFa7Ec1c50024992b0E366315e5
Arg [6] : _yieldPeriodInSecs (uint32): 86400
Arg [7] : _epochLengthInYieldPeriods (uint32): 7

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 0000000000000000000000008a2279d4a90b6fe1c4b30fa660cc9f926797baa2
Arg [1] : 000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b
Arg [2] : 00000000000000000000000095a260218497ea7420168a15f4d062651ec784c7
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000224
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [5] : 000000000000000000000000fbea240239932dfa7ec1c50024992b0e366315e5
Arg [6] : 0000000000000000000000000000000000000000000000000000000000015180
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000007


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.