Address Details
contract

0xBB04D738e013D5336B64352BFb428306b333530b

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




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




Optimization runs
200
EVM Version
istanbul




Verified at
2022-08-26T12:23:04.497397Z

contracts/donationMiner/DonationMinerImplementation.sol

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

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "./interfaces/DonationMinerStorageV4.sol";

contract DonationMinerImplementation is
    Initializable,
    OwnableUpgradeable,
    PausableUpgradeable,
    ReentrancyGuardUpgradeable,
    DonationMinerStorageV4
{
    using SafeERC20 for IERC20;

    /**
     * @notice Triggered when a donation has been added
     *
     * @param donationId        Id of the donation
     * @param delegateAddress   Address of the delegate
     * @param amount            Value of the donation
     * @param token             Address of the token after conversion
     * @param amount            Number of token donated
     * @param target            Address of the receiver (community or treasury)
     *                          or address of the DonationMiner contract otherwise
     */
    event DonationAdded(
        uint256 indexed donationId,
        address indexed delegateAddress,
        uint256 amount,
        address token,
        uint256 initialAmount,
        address indexed target
    );

    /**
     * @notice Triggered when a donor has claimed his reward
     *
     * @param donor             Address of the donner
     * @param amount            Value of the reward
     */
    event RewardClaimed(address indexed donor, uint256 amount);

    /**
     * @notice Triggered when a donor has claimed his reward
     *
     * @param donor             Address of the donner
     * @param amount            Value of the reward
     * @param lastRewardPeriod  Number of the last reward period for witch the claim was made
     */
    event RewardClaimedPartial(address indexed donor, uint256 amount, uint256 lastRewardPeriod);

    /**
     * @notice Triggered when a donor has staked his reward
     *
     * @param donor             Address of the donner
     * @param amount            Value of the reward
     */
    event RewardStaked(address indexed donor, uint256 amount);

    /**
     * @notice Triggered when a donor has staked his reward
     *
     * @param donor             Address of the donner
     * @param amount            Value of the reward
     * @param lastRewardPeriod  Number of the last reward period for witch tha stake was made
     */
    event RewardStakedPartial(address indexed donor, uint256 amount, uint256 lastRewardPeriod);

    /**
     * @notice Triggered when an amount of an ERC20 has been transferred from this contract to an address
     *
     * @param token               ERC20 token address
     * @param to                  Address of the receiver
     * @param amount              Amount of the transaction
     */
    event TransferERC20(address indexed token, address indexed to, uint256 amount);

    /**
     * @notice Triggered when reward period params have been updated
     *
     * @param oldRewardPeriodSize   Old rewardPeriodSize value
     * @param oldDecayNumerator     Old decayNumerator value
     * @param oldDecayDenominator   Old decayDenominator value
     * @param newRewardPeriodSize   New rewardPeriodSize value
     * @param newDecayNumerator     New decayNumerator value
     * @param newDecayDenominator   New decayDenominator value
     *
     * For further information regarding each parameter, see
     * *DonationMiner* smart contract initialize method.
     */
    event RewardPeriodParamsUpdated(
        uint256 oldRewardPeriodSize,
        uint256 oldDecayNumerator,
        uint256 oldDecayDenominator,
        uint256 newRewardPeriodSize,
        uint256 newDecayNumerator,
        uint256 newDecayDenominator
    );

    /**
     * @notice Triggered when the claimDelay value has been updated
     *
     * @param oldClaimDelay            Old claimDelay value
     * @param newClaimDelay            New claimDelay value
     */
    event ClaimDelayUpdated(uint256 oldClaimDelay, uint256 newClaimDelay);

    /**
     * @notice Triggered when the stakingDonationRatio value has been updated
     *
     * @param oldStakingDonationRatio            Old stakingDonationRatio value
     * @param newStakingDonationRatio            New stakingDonationRatio value
     */
    event StakingDonationRatioUpdated(
        uint256 oldStakingDonationRatio,
        uint256 newStakingDonationRatio
    );

    /**
     * @notice Triggered when the communityDonationRatio value has been updated
     *
     * @param oldCommunityDonationRatio            Old communityDonationRatio value
     * @param newCommunityDonationRatio            New communityDonationRatio value
     */
    event CommunityDonationRatioUpdated(
        uint256 oldCommunityDonationRatio,
        uint256 newCommunityDonationRatio
    );

    /**
     * @notice Triggered when the againstPeriods value has been updated
     *
     * @param oldAgainstPeriods            Old againstPeriods value
     * @param newAgainstPeriods            New againstPeriods value
     */
    event AgainstPeriodsUpdated(uint256 oldAgainstPeriods, uint256 newAgainstPeriods);

    /**
     * @notice Triggered when the treasury address has been updated
     *
     * @param oldTreasury             Old treasury address
     * @param newTreasury             New treasury address
     */
    event TreasuryUpdated(address indexed oldTreasury, address indexed newTreasury);

    /**
     * @notice Triggered when the staking address has been updated
     *
     * @param oldStaking             Old staking address
     * @param newStaking             New staking address
     */
    event StakingUpdated(address indexed oldStaking, address indexed newStaking);

    /**
     * @notice Enforces beginning rewardPeriod has started
     */
    modifier whenStarted() {
        require(block.number >= rewardPeriods[1].startBlock, "DonationMiner: ERR_NOT_STARTED");
        _;
    }

    /**
     * @notice Enforces sender to be Staking contract
     */
    modifier onlyStaking() {
        require(msg.sender == address(staking), "DonationMiner: NOT_STAKING");
        _;
    }

    /**
     * @notice Used to initialize a new DonationMiner contract
     *
     * @param _cUSD                 Address of the cUSD token
     * @param _PACT                 Address of the PACT Token
     * @param _treasury             Address of the Treasury
     * @param _firstRewardPerBlock  Number of PACTs given for each block
     *                              from the first reward period
     * @param _rewardPeriodSize     Number of blocks of the reward period
     * @param _startingBlock        First block of the first reward period
     * @param _decayNumerator       Decay numerator used for calculating
                                    the new reward per block based on
                                    the previous reward per block
     * @param _decayDenominator     Decay denominator used for calculating
                                    the new reward per block based on
                                    the previous reward per block
     */
    function initialize(
        IERC20 _cUSD,
        IERC20 _PACT,
        ITreasury _treasury,
        uint256 _firstRewardPerBlock,
        uint256 _rewardPeriodSize,
        uint256 _startingBlock,
        uint256 _decayNumerator,
        uint256 _decayDenominator
    ) public initializer {
        require(address(_cUSD) != address(0), "DonationMiner::initialize: cUSD address not set");
        require(address(_PACT) != address(0), "DonationMiner::initialize: PACT address not set");
        require(address(_treasury) != address(0), "DonationMiner::initialize: treasury_ not set");
        require(
            _firstRewardPerBlock != 0,
            "DonationMiner::initialize: firstRewardPerBlock not set!"
        );
        require(_startingBlock != 0, "DonationMiner::initialize: startingRewardPeriod not set!");
        require(_rewardPeriodSize != 0, "DonationMiner::initialize: rewardPeriodSize is invalid!");

        __Ownable_init();
        __Pausable_init();
        __ReentrancyGuard_init();

        cUSD = _cUSD;
        PACT = _PACT;
        treasury = _treasury;
        rewardPeriodSize = _rewardPeriodSize;
        decayNumerator = _decayNumerator;
        decayDenominator = _decayDenominator;

        rewardPeriodCount = 1;
        initFirstPeriod(_startingBlock, _firstRewardPerBlock);
    }

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

    /**
     * @notice Returns the amount of cUSD donated by a user in a reward period
     *
     * @param _period number of the reward period
     * @param _donor address of the donor
     * @return uint256 amount of cUSD donated by the user in this reward period
     */
    function rewardPeriodDonorAmount(uint256 _period, address _donor)
        external
        view
        override
        returns (uint256)
    {
        return rewardPeriods[_period].donorAmounts[_donor];
    }

    /**
     * @notice Returns the amount of PACT staked by a user at the and of the reward period
     *
     * @param _period reward period number
     * @param _donor address of the donor
     * @return uint256 amount of PACT staked by a user at the and of the reward period
     */
    function rewardPeriodDonorStakeAmounts(uint256 _period, address _donor)
        external
        view
        override
        returns (uint256)
    {
        return rewardPeriods[_period].donorStakeAmounts[_donor];
    }

    /**
     * @notice Returns a reward period number from a donor reward period list
     *
     * @param _donor address of the donor
     * @param _rewardPeriodIndex index of the reward period
     * @return uint256 number of the reward period
     */
    function donorRewardPeriod(address _donor, uint256 _rewardPeriodIndex)
        external
        view
        override
        returns (uint256)
    {
        return donors[_donor].rewardPeriods[_rewardPeriodIndex];
    }

    /**
     * @notice Updates reward period default params
     *
     * @param _newRewardPeriodSize value of new rewardPeriodSize
     * @param _newDecayNumerator value of new decayNumerator
     * @param _newDecayDenominator value of new decayDenominator
     */
    function updateRewardPeriodParams(
        uint256 _newRewardPeriodSize,
        uint256 _newDecayNumerator,
        uint256 _newDecayDenominator
    ) external override onlyOwner {
        require(
            _newRewardPeriodSize != 0,
            "DonationMiner::initialize: rewardPeriodSize is invalid!"
        );

        initializeRewardPeriods();

        emit RewardPeriodParamsUpdated(
            rewardPeriodSize,
            decayNumerator,
            decayDenominator,
            _newRewardPeriodSize,
            _newDecayNumerator,
            _newDecayDenominator
        );

        rewardPeriodSize = _newRewardPeriodSize;
        decayNumerator = _newDecayNumerator;
        decayDenominator = _newDecayDenominator;
    }

    /**
     * @notice Updates claimDelay value
     *
     * @param _newClaimDelay      Number of reward periods a donor has to wait after
     *                            a donation until he will be able to claim his reward
     */
    function updateClaimDelay(uint256 _newClaimDelay) external override onlyOwner {
        emit ClaimDelayUpdated(claimDelay, _newClaimDelay);

        claimDelay = _newClaimDelay;
    }

    /**
     * @notice Updates stakingDonationRatio value
     *
     * @param _newStakingDonationRatio    Number of tokens that need to be staked to be counted as 1 PACT donated
     */
    function updateStakingDonationRatio(uint256 _newStakingDonationRatio)
        external
        override
        onlyOwner
    {
        initializeRewardPeriods();

        emit StakingDonationRatioUpdated(stakingDonationRatio, _newStakingDonationRatio);

        stakingDonationRatio = _newStakingDonationRatio;
    }

    /**
     * @notice Updates communityDonationRatio value
     *
     * @param _newCommunityDonationRatio    Ratio between 1USD donated into the treasury vs 1USD donated to a community
     */
    function updateCommunityDonationRatio(uint256 _newCommunityDonationRatio)
        external
        override
        onlyOwner
    {
        emit CommunityDonationRatioUpdated(communityDonationRatio, _newCommunityDonationRatio);
        communityDonationRatio = _newCommunityDonationRatio;
    }

    /**
     * @notice Updates againstPeriods value
     *
     * @param _newAgainstPeriods      Number of reward periods for the backward computation
     */
    function updateAgainstPeriods(uint256 _newAgainstPeriods) external override onlyOwner {
        initializeRewardPeriods();

        emit AgainstPeriodsUpdated(againstPeriods, _newAgainstPeriods);
        againstPeriods = _newAgainstPeriods;
    }

    /**
     * @notice Updates Treasury address
     *
     * @param _newTreasury address of new treasury_ contract
     */
    function updateTreasury(ITreasury _newTreasury) external override onlyOwner {
        emit TreasuryUpdated(address(treasury), address(_newTreasury));
        treasury = _newTreasury;
    }

    /**
     * @notice Updates Staking address
     *
     * @param _newStaking address of new Staking contract
     */
    function updateStaking(IStaking _newStaking) external override onlyOwner {
        emit StakingUpdated(address(staking), address(_newStaking));
        staking = _newStaking;
    }

    /**
     * @notice Transfers cUSD tokens to the treasury contract
     *
     * @param _token address of the token
     * @param _amount Amount of cUSD tokens to deposit.
     * @param _delegateAddress the address that will claim the reward for the donation
     */
    function donate(
        IERC20 _token,
        uint256 _amount,
        address _delegateAddress
    ) external override whenNotPaused whenStarted nonReentrant {
        require(
            _token == cUSD || treasury.isToken(address(_token)),
            "DonationMiner::donate: Invalid token"
        );

        _token.safeTransferFrom(msg.sender, address(treasury), _amount);

        _addDonation(_delegateAddress, _token, _amount, address(treasury));
    }

    /**
     * @dev Transfers tokens to the community contract
     *
     * @param _community address of the community
     * @param _token address of the token
     * @param _amount amount of cUSD tokens to deposit
     * @param _delegateAddress the address that will claim the reward for the donation
     */
    function donateToCommunity(
        ICommunity _community,
        IERC20 _token,
        uint256 _amount,
        address _delegateAddress
    ) external override whenNotPaused whenStarted nonReentrant {
        ICommunityAdmin _communityAdmin = treasury.communityAdmin();
        require(
            _communityAdmin.communities(address(_community)) ==
                ICommunityAdmin.CommunityState.Valid,
            "DonationMiner::donateToCommunity: This is not a valid community address"
        );

        require(
            address(_token) == address(_community.cUSD()),
            "DonationMiner::donateToCommunity: Invalid token"
        );

        _community.donate(msg.sender, _amount);
        _addDonation(_delegateAddress, _token, _amount, address(_community));
    }

    /**
     * @notice Transfers to the sender the rewards
     */
    function claimRewards() external override whenNotPaused whenStarted nonReentrant {
        uint256 _claimAmount = _computeRewardsByPeriodNumber(msg.sender, _getLastClaimablePeriod());

        PACT.safeTransfer(msg.sender, _claimAmount);
        emit RewardClaimed(msg.sender, _claimAmount);
    }

    /**
     * @notice Transfers to the sender the rewards
     */
    function claimRewardsPartial(uint256 _lastPeriodNumber)
        external
        override
        whenNotPaused
        whenStarted
        nonReentrant
    {
        require(
            _lastPeriodNumber <= _getLastClaimablePeriod(),
            "DonationMiner::claimRewardsPartial: This reward period isn't claimable yet"
        );

        uint256 _claimAmount = _computeRewardsByPeriodNumber(msg.sender, _lastPeriodNumber);

        PACT.safeTransfer(msg.sender, _claimAmount);

        emit RewardClaimedPartial(msg.sender, _claimAmount, _lastPeriodNumber);
    }

    /**
     * @notice Stakes the reward
     */
    function stakeRewards() external override whenNotPaused whenStarted nonReentrant {
        initializeRewardPeriods();

        uint256 _stakeAmount = _computeRewardsByPeriodNumber(msg.sender, rewardPeriodCount - 1);

        PACT.approve(address(staking), _stakeAmount);
        staking.stake(msg.sender, _stakeAmount);

        emit RewardStaked(msg.sender, _stakeAmount);
    }

    /**
     * @notice Stakes the reward
     */
    function stakeRewardsPartial(uint256 _lastPeriodNumber)
        external
        override
        whenNotPaused
        whenStarted
        nonReentrant
    {
        initializeRewardPeriods();

        require(
            _lastPeriodNumber < rewardPeriodCount,
            "DonationMiner::stakeRewardsPartial: This reward period isn't claimable yet"
        );

        uint256 _stakeAmount = _computeRewardsByPeriodNumber(msg.sender, _lastPeriodNumber);

        PACT.approve(address(staking), _stakeAmount);
        staking.stake(msg.sender, _stakeAmount);

        emit RewardStaked(msg.sender, _stakeAmount);
    }

    /**
     * @notice Calculates the rewards from ended reward periods of a donor
     *
     * @param _donorAddress address of the donor
     * @param _lastPeriodNumber last reward period number to be computed
     * @return uint256 sum of all donor's rewards that has not been claimed until _lastPeriodNumber
     */
    function calculateClaimableRewardsByPeriodNumber(
        address _donorAddress,
        uint256 _lastPeriodNumber
    ) external view override returns (uint256) {
        uint256 _maxRewardPeriod;

        if (rewardPeriods[rewardPeriodCount].endBlock < block.number) {
            _maxRewardPeriod =
                (block.number - rewardPeriods[rewardPeriodCount].endBlock) /
                rewardPeriodSize;
            _maxRewardPeriod += rewardPeriodCount;
        } else {
            _maxRewardPeriod = rewardPeriodCount - 1;
        }

        require(
            _lastPeriodNumber <= _maxRewardPeriod,
            "DonationMiner::calculateClaimableRewardsByPeriodNumber: This reward period isn't available yet"
        );

        (uint256 _claimAmount, ) = _calculateRewardByPeriodNumber(_donorAddress, _lastPeriodNumber);
        return _claimAmount;
    }

    /**
     * @notice Calculates the rewards from ended reward periods of a donor
     *
     * @param _donorAddress address of the donor
     * @return claimAmount uint256 sum of all donor's rewards that has not been claimed until _lastPeriodNumber
     */
    function calculateClaimableRewards(address _donorAddress)
        external
        view
        override
        returns (uint256)
    {
        (uint256 _claimAmount, ) = _calculateRewardByPeriodNumber(
            _donorAddress,
            currentRewardPeriodNumber() - 1
        );
        return _claimAmount;
    }

    /**
     * @notice Calculates the estimate reward of a donor for current reward period
     *
     * @param _donorAddress             address of the donor
     *
     * @return uint256 reward that donor will receive in current reward period if there isn't another donation
     */
    function estimateClaimableReward(address _donorAddress)
        external
        view
        override
        whenStarted
        whenNotPaused
        returns (uint256)
    {
        return _estimateClaimableReward(_donorAddress, 0);
    }

    /**
     * @notice Calculates the estimate reward of a donor for the next x reward periods
     *
     * @param _donorAddress             address of the donor
     *
     * @return uint256 reward that donor will receive in current reward period if there isn't another donation
     */
    function estimateClaimableRewardAdvance(address _donorAddress)
        external
        view
        override
        whenStarted
        whenNotPaused
        returns (uint256)
    {
        return _estimateClaimableReward(_donorAddress, againstPeriods);
    }

    /**
     * @notice Calculates the estimate reward of a donor for current reward period based on his staking
     *
     * @return uint256 estimated reward by donor stakes
     */
    function estimateClaimableRewardByStaking(address _donorAddress)
        external
        view
        override
        whenStarted
        whenNotPaused
        returns (uint256)
    {
        uint256 _donorAmount;
        uint256 _totalAmount;

        (, _totalAmount) = lastPeriodsDonations(address(0));

        uint256 _currentPeriodReward = _calculateCurrentPeriodReward();

        return
            (_currentPeriodReward * staking.stakeholderAmount(_donorAddress)) /
            (_totalAmount * stakingDonationRatio + staking.currentTotalAmount());
    }

    /**
     * @notice Calculates the APR of a user based on his staking
     *
     * @param _stakeholderAddress      address of the stakeHolder
     *
     * @return uint256 APR of the user
     */
    function apr(address _stakeholderAddress)
        external
        view
        override
        whenStarted
        whenNotPaused
        returns (uint256)
    {
        uint256 _stakeholderAmount = staking.stakeholderAmount(_stakeholderAddress);
        if (_stakeholderAmount == 0) {
            return 0;
        }

        return
            (1e18 * 365100 * _estimateClaimableReward(_stakeholderAddress, 0)) / _stakeholderAmount;
    }

    /**
     * @notice Calculates the APR
     *
     * @return uint256 APR
     */
    function generalApr() public view override whenStarted whenNotPaused returns (uint256) {
        uint256 _donorAmount;
        uint256 _totalAmount;

        (, _totalAmount) = lastPeriodsDonations(address(0));

        uint256 _currentPeriodReward = _calculateCurrentPeriodReward();
        uint256 _totalReward = _currentPeriodReward;
        uint256 _index;
        while (_index < 364) {
            _currentPeriodReward = (_currentPeriodReward * decayNumerator) / decayDenominator;
            _totalReward += _currentPeriodReward;
            _index++;
        }

        return
            (1e18 * 100 * _totalReward) /
            (_totalAmount * stakingDonationRatio + staking.currentTotalAmount());
    }

    /**
     * @dev Calculate the score of a user based as
     * this ratio (his donation and staking) / (all donation and staking)
     * E.G. score = 0.01 * 1e18 => the donor have have 1% score
     *      so he will get 1% of the reward
     *
     * @param _donorAddress  address of the donor
     *
     * @return uint256    donor's score
     */
    function donorScore(address _donorAddress) public view returns (uint256) {
        return _calculateDonorShare(_donorAddress, 1e18);
    }

    /**
     * @dev Calculate all donations on the last X epochs as well as everyone
     * else in the same period.
     *
     * @param _donorAddress  address of the donor
     *
     * @return donorAmount uint256    sum of donor's donations
     * @return totalAmount uint256    sum of all donations
     */
    function lastPeriodsDonations(address _donorAddress)
        public
        view
        override
        returns (uint256 donorAmount, uint256 totalAmount)
    {
        uint256 _currentRewardPeriodNumber = currentRewardPeriodNumber();

        uint256 _startPeriod = _currentRewardPeriodNumber > againstPeriods
            ? _currentRewardPeriodNumber - againstPeriods
            : 1;

        if (rewardPeriodCount >= _startPeriod) {
            (donorAmount, totalAmount) = _calculateDonorIntervalAmounts(
                _donorAddress,
                _startPeriod,
                rewardPeriodCount
            );
        }
    }

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

        emit TransferERC20(address(_token), _to, _amount);
    }

    function setStakingAmounts(
        address _holderAddress,
        uint256 _holderAmount,
        uint256 _totalAmount
    ) external override whenNotPaused whenStarted onlyStaking {
        initializeRewardPeriods();

        RewardPeriod storage _rewardPeriod = rewardPeriods[rewardPeriodCount];
        _rewardPeriod.hasSetStakeAmount[_holderAddress] = true;
        _rewardPeriod.donorStakeAmounts[_holderAddress] = _holderAmount;
        _rewardPeriod.stakesAmount = _totalAmount;

        Donor storage _donor = donors[_holderAddress];
        //if user hasn't made any donation/staking
        //set _donor.lastClaimPeriod to be previous reward period
        //to not calculate reward for epochs 1 to rewardPeriodsCount -1
        if (_donor.lastClaimPeriod == 0 && _donor.rewardPeriodsCount == 0) {
            _donor.lastClaimPeriod = rewardPeriodCount - 1;
        }
    }

    function currentRewardPeriodNumber() public view override returns (uint256) {
        uint256 lastRewardPeriodEndBlock = rewardPeriods[rewardPeriodCount].endBlock;

        return
            lastRewardPeriodEndBlock > block.number
                ? rewardPeriodCount
                : rewardPeriodCount +
                    (block.number - lastRewardPeriodEndBlock) /
                    rewardPeriodSize +
                    1;
    }

    /**
     * @notice Initializes all reward periods that haven't been initialized yet until the current one.
     *         The first donor in a reward period will pay for that operation.
     */
    function initializeRewardPeriods() internal {
        RewardPeriod storage _lastPeriod = rewardPeriods[rewardPeriodCount];

        while (_lastPeriod.endBlock < block.number) {
            rewardPeriodCount++;
            RewardPeriod storage _newPeriod = rewardPeriods[rewardPeriodCount];
            _newPeriod.againstPeriods = againstPeriods;
            _newPeriod.startBlock = _lastPeriod.endBlock + 1;
            _newPeriod.endBlock = _newPeriod.startBlock + rewardPeriodSize - 1;
            _newPeriod.rewardPerBlock =
                (_lastPeriod.rewardPerBlock * decayNumerator) /
                decayDenominator;
            _newPeriod.stakesAmount = _lastPeriod.stakesAmount;
            _newPeriod.stakingDonationRatio = stakingDonationRatio;
            uint256 _rewardAmount = rewardPeriodSize * _newPeriod.rewardPerBlock;

            uint256 _startPeriod = (rewardPeriodCount - 1 > _lastPeriod.againstPeriods)
                ? rewardPeriodCount - 1 - _lastPeriod.againstPeriods
                : 1;

            if (!hasDonationOrStake(_startPeriod, rewardPeriodCount - 1)) {
                _rewardAmount += _lastPeriod.rewardAmount;
            }
            _newPeriod.rewardAmount = _rewardAmount;
            _lastPeriod = _newPeriod;
        }
    }

    /**
     * @notice Adds a new donation in donations list
     *
     * @param _delegateAddress address of the wallet that will claim the reward
     * @param _initialAmount amount of the donation
     * @param _target address of the receiver (community or treasury)
     */
    function _addDonation(
        address _delegateAddress,
        IERC20 _token,
        uint256 _initialAmount,
        address _target
    ) internal {
        initializeRewardPeriods();

        donationCount++;
        Donation storage _donation = donations[donationCount];
        _donation.donor = _delegateAddress;
        _donation.target = _target;
        _donation.blockNumber = block.number;
        _donation.rewardPeriod = rewardPeriodCount;
        _donation.token = _token;
        _donation.initialAmount = _initialAmount;

        if (_target == address(treasury)) {
            _donation.amount = (_token == cUSD)
                ? _initialAmount
                : treasury.getConvertedAmount(address(_token), _initialAmount);
        } else {
            _donation.amount = _initialAmount / communityDonationRatio;
        }

        updateRewardPeriodAmounts(rewardPeriodCount, _delegateAddress, _donation.amount);
        addCurrentRewardPeriodToDonor(_delegateAddress);

        emit DonationAdded(
            donationCount,
            _delegateAddress,
            _donation.amount,
            address(_token),
            _initialAmount,
            _target
        );
    }

    /**
     * @notice Adds the current reward period number to a donor's list only if it hasn't been added yet
     *
     * @param _donorAddress address of the donor
     */
    function addCurrentRewardPeriodToDonor(address _donorAddress) internal {
        Donor storage _donor = donors[_donorAddress];
        uint256 _lastDonorRewardPeriod = _donor.rewardPeriods[_donor.rewardPeriodsCount];

        //ensures that the current reward period number hasn't been added in the donor's list
        if (_lastDonorRewardPeriod != rewardPeriodCount) {
            _donor.rewardPeriodsCount++;
            _donor.rewardPeriods[_donor.rewardPeriodsCount] = rewardPeriodCount;
        }

        //if user hasn't made any donation/staking
        //set _donor.lastClaimPeriod to be previous reward period
        //to not calculate reward for epochs 1 to rewardPeriodsCount -1
        if (_donor.lastClaimPeriod == 0 && _donor.rewardPeriodsCount == 0) {
            _donor.lastClaimPeriod = rewardPeriodCount - 1;
        }
    }

    /**
     * @notice Updates the amounts of a reward period
     *
     * @param _rewardPeriodNumber number of the reward period
     * @param _donorAddress address of the donor
     * @param _amount amount to be added
     */
    function updateRewardPeriodAmounts(
        uint256 _rewardPeriodNumber,
        address _donorAddress,
        uint256 _amount
    ) internal {
        RewardPeriod storage _currentPeriod = rewardPeriods[_rewardPeriodNumber];
        _currentPeriod.donationsAmount += _amount;
        _currentPeriod.donorAmounts[_donorAddress] += _amount;
    }

    /**
     * @notice Checks if current reward period has been initialized
     *
     * @return bool true if current reward period has been initialized
     */
    function isCurrentRewardPeriodInitialized() internal view returns (bool) {
        return rewardPeriods[rewardPeriodCount].endBlock >= block.number;
    }

    function _calculateDonorIntervalAmounts(
        address _donorAddress,
        uint256 _startPeriod,
        uint256 _endPeriod
    ) internal view returns (uint256, uint256) {
        uint256 _donorAmount;
        uint256 _totalAmount;
        uint256 _index = _startPeriod;
        for (; _index <= _endPeriod; _index++) {
            RewardPeriod storage _rewardPeriod = rewardPeriods[_index];
            _donorAmount += _rewardPeriod.donorAmounts[_donorAddress];
            _totalAmount += _rewardPeriod.donationsAmount;
        }
        return (_donorAmount, _totalAmount);
    }

    function _getLastClaimablePeriod() internal returns (uint256) {
        initializeRewardPeriods();

        return rewardPeriodCount > claimDelay + 1 ? rewardPeriodCount - 1 - claimDelay : 0;
    }

    /**
     * @notice Computes the rewards
     */
    function _computeRewardsByPeriodNumber(address _donorAddress, uint256 _lastPeriodNumber)
        internal
        returns (uint256)
    {
        Donor storage _donor = donors[_donorAddress];
        uint256 _claimAmount;
        uint256 _lastDonorStakeAmount;

        (_claimAmount, _lastDonorStakeAmount) = _calculateRewardByPeriodNumber(
            _donorAddress,
            _lastPeriodNumber
        );

        if (_donor.lastClaimPeriod < _lastPeriodNumber) {
            _donor.lastClaimPeriod = _lastPeriodNumber;
        }

        rewardPeriods[_lastPeriodNumber].donorStakeAmounts[_donorAddress] = _lastDonorStakeAmount;

        if (_claimAmount == 0) {
            return _claimAmount;
        }

        if (_claimAmount > PACT.balanceOf(address(this))) {
            _claimAmount = PACT.balanceOf(address(this));
        }

        return _claimAmount;
    }

    /**
     * @notice Calculates the reward for a donor starting with his last reward period claimed
     *
     * @param _donorAddress address of the donor
     * @param _lastPeriodNumber last reward period number to be computed
     * @return _claimAmount uint256 sum of all donor's rewards that has not been claimed until _lastPeriodNumber
     * @return _lastDonorStakeAmount uint256 number of PACTs that are staked by the donor at the end of _lastPeriodNumber
     */
    function _calculateRewardByPeriodNumber(address _donorAddress, uint256 _lastPeriodNumber)
        internal
        view
        returns (uint256 _claimAmount, uint256 _lastDonorStakeAmount)
    {
        Donor storage _donor = donors[_donorAddress];

        // _index is the last reward period number for which the donor claimed his reward
        uint256 _index = _donor.lastClaimPeriod + 1;

        // this is only used for the transition from V2 to V3
        // we have to be sure a user is not able to claim for a epoch that he's claimed
        //      so, if the _donor.lastClaimPeriod hasn't been set yet,
        //      we will start from _donor.rewardPeriods[_donor.lastClaim]
        if (_index == 1) {
            _index = _donor.rewardPeriods[_donor.lastClaim] + 1;
        }

        uint256 _donorAmount;
        uint256 _totalAmount;
        uint256 _rewardAmount;
        uint256 _stakesAmount;
        uint256 _stakingDonationRatio;

        //first time _previousRewardPeriod must be rewardPeriods[0] in order to have:
        //_currentRewardPeriod.againstPeriods = _currentRewardPeriod.againstPeriods - _previousRewardPeriod.againstPeriods
        RewardPeriod storage _previousRewardPeriod = rewardPeriods[0];
        RewardPeriod storage _currentRewardPeriod = rewardPeriods[_index];
        RewardPeriod storage _expiredRewardPeriod = rewardPeriods[0];

        //we save the stake amount of a donor at the end of each claim,
        //so rewardPeriods[_index - 1].donorStakeAmounts[_donorAddress] is the amount staked by the donor at his last claim
        _lastDonorStakeAmount = rewardPeriods[_index - 1].donorStakeAmounts[_donorAddress];

        while (_index <= _lastPeriodNumber) {
            if (_currentRewardPeriod.startBlock > 0) {
                // this case is used to calculate the reward for periods that have been initialized

                if (_currentRewardPeriod.againstPeriods == 0) {
                    _donorAmount = _currentRewardPeriod.donorAmounts[_donorAddress];
                    _totalAmount = _currentRewardPeriod.donationsAmount;
                } else if (
                    _previousRewardPeriod.againstPeriods == _currentRewardPeriod.againstPeriods
                ) {
                    if (_index > _currentRewardPeriod.againstPeriods + 1) {
                        _expiredRewardPeriod = rewardPeriods[
                            _index - 1 - _currentRewardPeriod.againstPeriods
                        ];
                        _donorAmount -= _expiredRewardPeriod.donorAmounts[_donorAddress];
                        _totalAmount -= _expiredRewardPeriod.donationsAmount;
                    }

                    _donorAmount += _currentRewardPeriod.donorAmounts[_donorAddress];
                    _totalAmount += _currentRewardPeriod.donationsAmount;
                } else {
                    if (_index > _currentRewardPeriod.againstPeriods) {
                        (_donorAmount, _totalAmount) = _calculateDonorIntervalAmounts(
                            _donorAddress,
                            _index - _currentRewardPeriod.againstPeriods,
                            _index
                        );
                    } else {
                        (_donorAmount, _totalAmount) = _calculateDonorIntervalAmounts(
                            _donorAddress,
                            0,
                            _index
                        );
                    }
                }

                _rewardAmount = _currentRewardPeriod.rewardAmount;
                _stakesAmount = _currentRewardPeriod.stakesAmount;
                _stakingDonationRatio = _currentRewardPeriod.stakingDonationRatio > 0
                    ? _currentRewardPeriod.stakingDonationRatio
                    : 1;
            } else {
                // this case is used to calculate the reward for periods that have not been initialized yet
                // E.g. calculateClaimableRewardsByPeriodNumber & calculateClaimableRewards
                // this step can be reached only after calculating the reward for periods that have been initialized

                if (_index > againstPeriods + 1) {
                    _expiredRewardPeriod = rewardPeriods[_index - 1 - againstPeriods];

                    //we already know that _donorAmount >= _expiredRewardPeriod.donorAmounts[_donorAddress]
                    //because _donorAmount is a sum of some donorAmounts, including _expiredRewardPeriod.donorAmounts[_donorAddress]
                    _donorAmount -= _expiredRewardPeriod.donorAmounts[_donorAddress];
                    //we already know that _totalAmount >= _expiredRewardPeriod.donationsAmount
                    //because _totalAmount is a sum of some donationsAmounts, including _expiredRewardPeriod.donationsAmount
                    _totalAmount -= _expiredRewardPeriod.donationsAmount;
                }

                _donorAmount += _currentRewardPeriod.donorAmounts[_donorAddress];
                _totalAmount += _currentRewardPeriod.donationsAmount;
                _rewardAmount = (_rewardAmount * decayNumerator) / decayDenominator;
            }

            if (_currentRewardPeriod.hasSetStakeAmount[_donorAddress]) {
                _lastDonorStakeAmount = _currentRewardPeriod.donorStakeAmounts[_donorAddress];
            }

            if (_donorAmount + _lastDonorStakeAmount > 0) {
                _claimAmount +=
                    (_rewardAmount *
                        (_donorAmount * _stakingDonationRatio + _lastDonorStakeAmount)) /
                    (_totalAmount * _stakingDonationRatio + _stakesAmount);
            }

            _index++;

            _previousRewardPeriod = _currentRewardPeriod;
            _currentRewardPeriod = rewardPeriods[_index];
        }

        return (_claimAmount, _lastDonorStakeAmount);
    }

    /**
     * @notice Initializes the first reward period
     *
     * @param _startingBlock first block
     * @param _firstRewardPerBlock initial reward per block
     */
    function initFirstPeriod(uint256 _startingBlock, uint256 _firstRewardPerBlock) internal {
        RewardPeriod storage _firstPeriod = rewardPeriods[1];
        _firstPeriod.startBlock = _startingBlock;
        _firstPeriod.endBlock = _startingBlock + rewardPeriodSize - 1;
        _firstPeriod.rewardPerBlock = _firstRewardPerBlock;
        _firstPeriod.rewardAmount = _firstRewardPerBlock * rewardPeriodSize;
    }

    /**
     * @notice Checks if there is any donation or stake between _startPeriod and _endPeriod
     *
     * @return bool true if there is any donation or stake
     */
    function hasDonationOrStake(uint256 _startPeriod, uint256 _endPeriod)
        internal
        view
        returns (bool)
    {
        while (_startPeriod <= _endPeriod) {
            if (
                rewardPeriods[_startPeriod].donationsAmount +
                    rewardPeriods[_startPeriod].stakesAmount >
                0
            ) {
                return true;
            }
            _startPeriod++;
        }
        return false;
    }

    /**
     * @notice Calculates the estimate reward of a donor
     *
     * @param _donorAddress             address of the donor
     * @param _inAdvanceRewardPeriods   number of reward periods in front
     *                                   if _inAdvanceRewardPeriods is 0 the method returns
     *                                        the estimated reward for current reward period
     * @return uint256 reward that donor will receive in current reward period if there isn't another donation
     */
    function _estimateClaimableReward(address _donorAddress, uint256 _inAdvanceRewardPeriods)
        internal
        view
        returns (uint256)
    {
        uint256 _currentPeriodReward = _calculateCurrentPeriodReward();
        uint256 _totalReward = _currentPeriodReward;

        while (_inAdvanceRewardPeriods > 0) {
            _currentPeriodReward = (_currentPeriodReward * decayNumerator) / decayDenominator;
            _totalReward += _currentPeriodReward;
            _inAdvanceRewardPeriods--;
        }
        return _calculateDonorShare(_donorAddress, _totalReward);
    }

    /**
     * @notice Calculates a donor share based on the donations and stakes from the last x rewardPeriods
     *
     *
     * @return uint256  the share from the _total
     */
    function _calculateDonorShare(address _donorAddress, uint256 _total)
        internal
        view
        returns (uint256)
    {
        uint256 _donorAmount;
        uint256 _totalAmount;

        (_donorAmount, _totalAmount) = lastPeriodsDonations(_donorAddress);

        uint256 totalStakeAmount = staking.SPACT().totalSupply();
        if (totalStakeAmount == 0 && _totalAmount == 0) {
            return 0;
        }

        uint256 _stakingDonationRatio = stakingDonationRatio > 0 ? stakingDonationRatio : 1;

        return
            (_total *
                (_donorAmount * _stakingDonationRatio + staking.stakeholderAmount(_donorAddress))) /
            (_totalAmount * _stakingDonationRatio + staking.currentTotalAmount());
    }

    function _calculateCurrentPeriodReward() internal view returns (uint256) {
        uint256 _currentRewardPeriodNumber = currentRewardPeriodNumber();

        uint256 _rewardPerBlock = (rewardPeriods[rewardPeriodCount].rewardPerBlock *
            decayNumerator**(_currentRewardPeriodNumber - rewardPeriodCount)) /
            decayDenominator**(_currentRewardPeriodNumber - rewardPeriodCount);

        return _rewardPerBlock * rewardPeriodSize;
    }
}
        

/_openzeppelin/contracts/access/Ownable.sol

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

pragma solidity ^0.8.0;

import "../utils/Context.sol";

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

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

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

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

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

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

/_openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)

pragma solidity ^0.8.0;

import "../Proxy.sol";
import "./ERC1967Upgrade.sol";

/**
 * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
 * implementation address that can be changed. This address is stored in storage in the location specified by
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
 * implementation behind the proxy.
 */
contract ERC1967Proxy is Proxy, ERC1967Upgrade {
    /**
     * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
     *
     * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
     * function call, and allows initializating the storage of the proxy like a Solidity constructor.
     */
    constructor(address _logic, bytes memory _data) payable {
        assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
        _upgradeToAndCall(_logic, _data, false);
    }

    /**
     * @dev Returns the current implementation address.
     */
    function _implementation() internal view virtual override returns (address impl) {
        return ERC1967Upgrade._getImplementation();
    }
}
          

/_openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeacon.sol";
import "../../utils/Address.sol";
import "../../utils/StorageSlot.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967Upgrade {
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            Address.functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallSecure(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        address oldImplementation = _getImplementation();

        // Initial upgrade and setup call
        _setImplementation(newImplementation);
        if (data.length > 0 || forceCall) {
            Address.functionDelegateCall(newImplementation, data);
        }

        // Perform rollback test if not already in progress
        StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT);
        if (!rollbackTesting.value) {
            // Trigger rollback using upgradeTo from the new implementation
            rollbackTesting.value = true;
            Address.functionDelegateCall(
                newImplementation,
                abi.encodeWithSignature("upgradeTo(address)", oldImplementation)
            );
            rollbackTesting.value = false;
            // Check rollback was effective
            require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
            // Finally reset to the new implementation and log the upgrade
            _upgradeTo(newImplementation);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            Address.isContract(IBeacon(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
        }
    }
}
          

/_openzeppelin/contracts/proxy/Proxy.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/Proxy.sol)

pragma solidity ^0.8.0;

/**
 * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
 * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
 * be specified by overriding the virtual {_implementation} function.
 *
 * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
 * different contract through the {_delegate} function.
 *
 * The success and return data of the delegated call will be returned back to the caller of the proxy.
 */
abstract contract Proxy {
    /**
     * @dev Delegates the current call to `implementation`.
     *
     * This function does not return to its internall call site, it will return directly to the external caller.
     */
    function _delegate(address implementation) internal virtual {
        assembly {
            // Copy msg.data. We take full control of memory in this inline assembly
            // block because it will not return to Solidity code. We overwrite the
            // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize())

            // Call the implementation.
            // out and outsize are 0 because we don't know the size yet.
            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)

            // Copy the returned data.
            returndatacopy(0, 0, returndatasize())

            switch result
            // delegatecall returns 0 on error.
            case 0 {
                revert(0, returndatasize())
            }
            default {
                return(0, returndatasize())
            }
        }
    }

    /**
     * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
     * and {_fallback} should delegate.
     */
    function _implementation() internal view virtual returns (address);

    /**
     * @dev Delegates the current call to the address returned by `_implementation()`.
     *
     * This function does not return to its internall call site, it will return directly to the external caller.
     */
    function _fallback() internal virtual {
        _beforeFallback();
        _delegate(_implementation());
    }

    /**
     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
     * function in the contract matches the call data.
     */
    fallback() external payable virtual {
        _fallback();
    }

    /**
     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
     * is empty.
     */
    receive() external payable virtual {
        _fallback();
    }

    /**
     * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
     * call, or as part of the Solidity `fallback` or `receive` functions.
     *
     * If overriden should call `super._beforeFallback()`.
     */
    function _beforeFallback() internal virtual {}
}
          

/_openzeppelin/contracts/proxy/beacon/IBeacon.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeacon {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}
          

/_openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)

pragma solidity ^0.8.0;

import "./TransparentUpgradeableProxy.sol";
import "../../access/Ownable.sol";

/**
 * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
 * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
 */
contract ProxyAdmin is Ownable {
    /**
     * @dev Returns the current implementation of `proxy`.
     *
     * Requirements:
     *
     * - This contract must be the admin of `proxy`.
     */
    function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
        // We need to manually run the static call since the getter cannot be flagged as view
        // bytes4(keccak256("implementation()")) == 0x5c60da1b
        (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
        require(success);
        return abi.decode(returndata, (address));
    }

    /**
     * @dev Returns the current admin of `proxy`.
     *
     * Requirements:
     *
     * - This contract must be the admin of `proxy`.
     */
    function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
        // We need to manually run the static call since the getter cannot be flagged as view
        // bytes4(keccak256("admin()")) == 0xf851a440
        (bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
        require(success);
        return abi.decode(returndata, (address));
    }

    /**
     * @dev Changes the admin of `proxy` to `newAdmin`.
     *
     * Requirements:
     *
     * - This contract must be the current admin of `proxy`.
     */
    function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {
        proxy.changeAdmin(newAdmin);
    }

    /**
     * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.
     *
     * Requirements:
     *
     * - This contract must be the admin of `proxy`.
     */
    function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {
        proxy.upgradeTo(implementation);
    }

    /**
     * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See
     * {TransparentUpgradeableProxy-upgradeToAndCall}.
     *
     * Requirements:
     *
     * - This contract must be the admin of `proxy`.
     */
    function upgradeAndCall(
        TransparentUpgradeableProxy proxy,
        address implementation,
        bytes memory data
    ) public payable virtual onlyOwner {
        proxy.upgradeToAndCall{value: msg.value}(implementation, data);
    }
}
          

/_openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)

pragma solidity ^0.8.0;

import "../ERC1967/ERC1967Proxy.sol";

/**
 * @dev This contract implements a proxy that is upgradeable by an admin.
 *
 * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
 * clashing], which can potentially be used in an attack, this contract uses the
 * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
 * things that go hand in hand:
 *
 * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
 * that call matches one of the admin functions exposed by the proxy itself.
 * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
 * implementation. If the admin tries to call a function on the implementation it will fail with an error that says
 * "admin cannot fallback to proxy target".
 *
 * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
 * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
 * to sudden errors when trying to call a function from the proxy implementation.
 *
 * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
 * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
 */
contract TransparentUpgradeableProxy is ERC1967Proxy {
    /**
     * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
     * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
     */
    constructor(
        address _logic,
        address admin_,
        bytes memory _data
    ) payable ERC1967Proxy(_logic, _data) {
        assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
        _changeAdmin(admin_);
    }

    /**
     * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
     */
    modifier ifAdmin() {
        if (msg.sender == _getAdmin()) {
            _;
        } else {
            _fallback();
        }
    }

    /**
     * @dev Returns the current admin.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
     *
     * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
     * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
     * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
     */
    function admin() external ifAdmin returns (address admin_) {
        admin_ = _getAdmin();
    }

    /**
     * @dev Returns the current implementation.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
     *
     * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
     * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
     * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
     */
    function implementation() external ifAdmin returns (address implementation_) {
        implementation_ = _implementation();
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
     */
    function changeAdmin(address newAdmin) external virtual ifAdmin {
        _changeAdmin(newAdmin);
    }

    /**
     * @dev Upgrade the implementation of the proxy.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
     */
    function upgradeTo(address newImplementation) external ifAdmin {
        _upgradeToAndCall(newImplementation, bytes(""), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
     * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
     * proxied contract.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
     */
    function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
        _upgradeToAndCall(newImplementation, data, true);
    }

    /**
     * @dev Returns the current admin.
     */
    function _admin() internal view virtual returns (address) {
        return _getAdmin();
    }

    /**
     * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
     */
    function _beforeFallback() internal virtual override {
        require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
        super._beforeFallback();
    }
}
          

/_openzeppelin/contracts/token/ERC20/IERC20.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

/_openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol

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

pragma solidity ^0.8.0;

import "../IERC20.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));
        }
    }

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

/_openzeppelin/contracts/utils/Address.sol

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

pragma solidity ^0.8.0;

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

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev 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) {
        require(isContract(target), "Address: delegate call to non-contract");

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

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

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

/_openzeppelin/contracts/utils/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;
    }
}
          

/_openzeppelin/contracts/utils/StorageSlot.sol

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

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        assembly {
            r.slot := slot
        }
    }
}
          

/_openzeppelin/contracts/utils/math/Math.sol

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

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @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 / b + (a % b == 0 ? 0 : 1);
    }
}
          

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

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

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

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

    bool private _paused;

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

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

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

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

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

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

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

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

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

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

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

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

    uint256 private _status;

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

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

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

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

        _;

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

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

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

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}
          

/contracts/ambassadors/interfaces/IAmbassadors.sol

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

interface IAmbassadors {
    function getVersion() external returns(uint256);
    function isAmbassador(address _ambassador) external view returns (bool);
    function isAmbassadorOf(address _ambassador, address _community) external view returns (bool);
    function isEntityOf(address _ambassador, address _entityAddress) external view returns (bool);
    function isAmbassadorAt(address _ambassador, address _entityAddress) external view returns (bool);

    function addEntity(address _entity) external;
    function removeEntity(address _entity) external;
    function replaceEntityAccount(address _entity, address _newEntity) external;
    function addAmbassador(address _ambassador) external;
    function removeAmbassador(address _ambassador) external;
    function replaceAmbassadorAccount(address _ambassador, address _newAmbassador) external;
    function replaceAmbassador(address _oldAmbassador, address _newAmbassador) external;
    function transferAmbassador(address _ambassador, address _toEntity, bool _keepCommunities) external;
    function transferCommunityToAmbassador(address _to, address _community) external;
    function setCommunityToAmbassador(address _ambassador, address _community) external;
    function removeCommunity(address _community) external;
}
          

/contracts/community/interfaces/ICommunity.sol

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

import "@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./ICommunityAdmin.sol";

interface ICommunity {
    enum BeneficiaryState {
        NONE, //the beneficiary hasn't been added yet
        Valid,
        Locked,
        Removed
    }

    struct Beneficiary {
        BeneficiaryState state;  //beneficiary state
        uint256 claims;          //total number of claims
        uint256 claimedAmount;   //total amount of cUSD received
        uint256 lastClaim;       //block number of the last claim
    }

    function initialize(
        address[] memory _managers,
        uint256 _claimAmount,
        uint256 _maxClaim,
        uint256 _decreaseStep,
        uint256 _baseInterval,
        uint256 _incrementInterval,
        uint256 _minTranche,
        uint256 _maxTranche,
        uint256 _maxBeneficiaries,
        ICommunity _previousCommunity
    ) external;
    function getVersion() external returns(uint256);
    function previousCommunity() external view returns(ICommunity);
    function claimAmount() external view returns(uint256);
    function baseInterval() external view returns(uint256);
    function incrementInterval() external view returns(uint256);
    function maxClaim() external view returns(uint256);
    function validBeneficiaryCount() external view returns(uint);
    function maxBeneficiaries() external view returns(uint);
    function treasuryFunds() external view returns(uint);
    function privateFunds() external view returns(uint);
    function communityAdmin() external view returns(ICommunityAdmin);
    function cUSD() external view  returns(IERC20);
    function token() external view  returns(IERC20);
    function locked() external view returns(bool);
    function beneficiaries(address _beneficiaryAddress) external view returns(
        BeneficiaryState state,
        uint256 claims,
        uint256 claimedAmount,
        uint256 lastClaim
    );
    function decreaseStep() external view returns(uint);
    function beneficiaryListAt(uint256 _index) external view returns (address);
    function beneficiaryListLength() external view returns (uint256);
    function impactMarketAddress() external pure returns (address);
    function minTranche() external view returns(uint256);
    function maxTranche() external view returns(uint256);
    function lastFundRequest() external view returns(uint256);

    function updateCommunityAdmin(ICommunityAdmin _communityAdmin) external;
    function updatePreviousCommunity(ICommunity _newPreviousCommunity) external;
    function updateBeneficiaryParams(
        uint256 _claimAmount,
        uint256 _maxClaim,
        uint256 _decreaseStep,
        uint256 _baseInterval,
        uint256 _incrementInterval
    ) external;
    function updateCommunityParams(
        uint256 _minTranche,
        uint256 _maxTranche
    ) external;
    function updateMaxBeneficiaries(uint256 _newMaxBeneficiaries) external;
    function updateToken(IERC20 _newToken, address[] memory _exchangePath) external;
    function donate(address _sender, uint256 _amount) external;
    function addTreasuryFunds(uint256 _amount) external;
    function transfer(IERC20 _token, address _to, uint256 _amount) external;
    function addManager(address _managerAddress) external;
    function removeManager(address _managerAddress) external;
    function addBeneficiaries(address[] memory _beneficiaryAddresses) external;
    function addBeneficiary(address _beneficiaryAddress) external;
    function lockBeneficiary(address _beneficiaryAddress) external;
    function unlockBeneficiary(address _beneficiaryAddress) external;
    function removeBeneficiary(address _beneficiaryAddress) external;
    function claim() external;
    function lastInterval(address _beneficiaryAddress) external view returns (uint256);
    function claimCooldown(address _beneficiaryAddress) external view returns (uint256);
    function lock() external;
    function unlock() external;
    function requestFunds() external;
    function beneficiaryJoinFromMigrated(address _beneficiaryAddress) external;
    function getInitialMaxClaim() external view returns (uint256);
}
          

/contracts/community/interfaces/ICommunityAdmin.sol

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

import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./ICommunity.sol";
import "../../treasury/interfaces/ITreasury.sol";
import "../../governor/impactMarketCouncil/interfaces/IImpactMarketCouncil.sol";
import "../../ambassadors/interfaces/IAmbassadors.sol";

interface ICommunityAdmin {
    enum CommunityState {
        NONE,
        Valid,
        Removed,
        Migrated
    }

    function getVersion() external returns(uint256);
    function cUSD() external view returns(IERC20);
    function treasury() external view returns(ITreasury);
    function impactMarketCouncil() external view returns(IImpactMarketCouncil);
    function ambassadors() external view returns(IAmbassadors);
    function communityMiddleProxy() external view returns(address);
    function communities(address _community) external view returns(CommunityState);
    function communityImplementation() external view returns(ICommunity);
    function communityProxyAdmin() external view returns(ProxyAdmin);
    function communityListAt(uint256 _index) external view returns (address);
    function communityListLength() external view returns (uint256);
    function isAmbassadorOrEntityOfCommunity(address _community, address _ambassadorOrEntity) external view returns (bool);
    function updateTreasury(ITreasury _newTreasury) external;
    function updateImpactMarketCouncil(IImpactMarketCouncil _newImpactMarketCouncil) external;
    function updateAmbassadors(IAmbassadors _newAmbassadors) external;
    function updateCommunityMiddleProxy(address _communityMiddleProxy) external;
    function updateCommunityImplementation(ICommunity _communityImplementation_) external;
    function setCommunityToAmbassador(address _ambassador, ICommunity _communityAddress) external;
    function updateBeneficiaryParams(
        ICommunity _community,
        uint256 _claimAmount,
        uint256 _maxClaim,
        uint256 _decreaseStep,
        uint256 _baseInterval,
        uint256 _incrementInterval,
        uint256 _maxBeneficiaries
    ) external;
    function updateCommunityParams(
        ICommunity _community,
        uint256 _minTranche,
        uint256 _maxTranche
    ) external;
    function updateProxyImplementation(address _CommunityMiddleProxy, address _newLogic) external;
    function updateCommunityToken(
        ICommunity _community,
        IERC20 _newToken,
        address[] memory _exchangePath
    ) external;
    function addCommunity(
        address[] memory _managers,
        address _ambassador,
        uint256 _claimAmount,
        uint256 _maxClaim,
        uint256 _decreaseStep,
        uint256 _baseInterval,
        uint256 _incrementInterval,
        uint256 _minTranche,
        uint256 _maxTranche,
        uint256 _maxBeneficiaries
    ) external;
    function migrateCommunity(
        address[] memory _managers,
        ICommunity _previousCommunity
    ) external;
    function removeCommunity(ICommunity _community) external;
    function fundCommunity() external;
    function transfer(IERC20 _token, address _to, uint256 _amount) external;
    function transferFromCommunity(
        ICommunity _community,
        IERC20 _token,
        address _to,
        uint256 _amount
    ) external;
}
          

/contracts/donationMiner/interfaces/DonationMinerStorageV1.sol

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

import "./IDonationMiner.sol";

/**
 * @title Storage for DonationMiner
 * @notice For future upgrades, do not change DonationMinerStorageV1. Create a new
 * contract which implements DonationMinerStorageV1 and following the naming convention
 * DonationMinerStorageVX.
 */
abstract contract DonationMinerStorageV1 is IDonationMiner {
    IERC20 public override cUSD;
    IERC20 public override PACT;
    ITreasury public override treasury;
    uint256 public override rewardPeriodSize;
    uint256 public override donationCount;
    uint256 public override rewardPeriodCount;
    uint256 public override decayNumerator;
    uint256 public override decayDenominator;

    mapping(uint256 => Donation) public override donations;
    mapping(uint256 => RewardPeriod) public override rewardPeriods;
    mapping(address => Donor) public override donors;
}
          

/contracts/donationMiner/interfaces/DonationMinerStorageV2.sol

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

import "./DonationMinerStorageV1.sol";

/**
 * @title Storage for DonationMiner
 * @notice For future upgrades, do not change DonationMinerStorageV2. Create a new
 * contract which implements DonationMinerStorageV2 and following the naming convention
 * DonationMinerStorageVX.
 */
abstract contract DonationMinerStorageV2 is DonationMinerStorageV1 {
    uint256 public override claimDelay;
}
          

/contracts/donationMiner/interfaces/DonationMinerStorageV3.sol

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

import "./DonationMinerStorageV2.sol";

/**
 * @title Storage for DonationMiner
 * @notice For future upgrades, do not change DonationMinerStorageV3. Create a new
 * contract which implements DonationMinerStorageV3 and following the naming convention
 * DonationMinerStorageVX.
 */
abstract contract DonationMinerStorageV3 is DonationMinerStorageV2 {
    uint256 public override againstPeriods;
}
          

/contracts/donationMiner/interfaces/DonationMinerStorageV4.sol

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

import "./DonationMinerStorageV3.sol";

/**
 * @title Storage for DonationMiner
 * @notice For future upgrades, do not change DonationMinerStorageV4. Create a new
 * contract which implements DonationMinerStorageV4 and following the naming convention
 * DonationMinerStorageVX.
 */
abstract contract DonationMinerStorageV4 is DonationMinerStorageV3 {
    IStaking public override staking;
    //ratio between 1 cUSD donated and 1 PACT staked
    uint256 public override stakingDonationRatio;
    uint256 public override communityDonationRatio;
}
          

/contracts/donationMiner/interfaces/IDonationMiner.sol

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

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../../community/interfaces/ICommunityAdmin.sol";
import "../../treasury/interfaces/ITreasury.sol";
import "../../staking/interfaces/IStaking.sol";

interface IDonationMiner {
    struct RewardPeriod {
        //reward tokens created per block
        uint256 rewardPerBlock;
        //reward tokens from previous periods + reward tokens from this reward period
        uint256 rewardAmount;
        //block number at which reward period starts
        uint256 startBlock;
        //block number at which reward period ends
        uint256 endBlock;
        //total of donations for this rewardPeriod
        uint256 donationsAmount;
        //amounts donated by every donor in this rewardPeriod
        mapping(address => uint256) donorAmounts;
        uint256 againstPeriods;
        //total stake amount at the end of this rewardPeriod
        uint256 stakesAmount;
        //ratio between 1 cUSD donated and 1 PACT staked
        uint256 stakingDonationRatio;
        //true if user has staked/unstaked in this reward period
        mapping(address => bool) hasSetStakeAmount;
        //stake amount of a user at the end of this reward period;
        //if a user doesn't stake/unstake in a reward period,
        //              this value will remain 0 (and hasSetStakeAmount will be false)
        //if hasNewStakeAmount is false it means the donorStakeAmount
        //              is the same as the last reward period where hasSetStakeAmount is true
        mapping(address => uint256) donorStakeAmounts;
    }

    struct Donor {
        uint256 lastClaim;  //last reward period index for which the donor has claimed the reward; used until v2
        uint256 rewardPeriodsCount; //total number of reward periods in which the donor donated
        mapping(uint256 => uint256) rewardPeriods; //list of all reward period ids in which the donor donated
        uint256 lastClaimPeriod; //last reward period id for which the donor has claimed the reward
    }

    struct Donation {
        address donor;  //address of the donner
        address target;  //address of the receiver (community or treasury)
        uint256 rewardPeriod;  //number of the reward period in which the donation was made
        uint256 blockNumber;  //number of the block in which the donation was executed
        uint256 amount;  //the convertedAmount value
        IERC20 token;  //address of the token
        uint256 initialAmount;  //number of tokens donated
    }

    function getVersion() external returns(uint256);
    function cUSD() external view returns (IERC20);
    function PACT() external view returns (IERC20);
    function treasury() external view returns (ITreasury);
    function staking() external view returns (IStaking);
    function rewardPeriodSize() external view returns (uint256);
    function decayNumerator() external view returns (uint256);
    function decayDenominator() external view returns (uint256);
    function stakingDonationRatio() external view returns (uint256);
    function communityDonationRatio() external view returns (uint256);
    function rewardPeriodCount() external view returns (uint256);
    function donationCount() external view returns (uint256);
    function rewardPeriods(uint256 _period) external view returns (
        uint256 rewardPerBlock,
        uint256 rewardAmount,
        uint256 startBlock,
        uint256 endBlock,
        uint256 donationsAmount,
        uint256 againstPeriods,
        uint256 stakesAmount,
        uint256 stakingDonationRatio

);
    function rewardPeriodDonorAmount(uint256 _period, address _donor) external view returns (uint256);
    function rewardPeriodDonorStakeAmounts(uint256 _period, address _donor) external view returns (uint256);
    function donors(address _donor) external view returns (
        uint256 rewardPeriodsCount,
        uint256 lastClaim,
        uint256 lastClaimPeriod
    );
    function donorRewardPeriod(address _donor, uint256 _rewardPeriodIndex) external view returns (uint256);
    function donations(uint256 _index) external view returns (
        address donor,
        address target,
        uint256 rewardPeriod,
        uint256 blockNumber,
        uint256 amount,
        IERC20 token,
        uint256 tokenPrice
    );
    function claimDelay() external view returns (uint256);
    function againstPeriods() external view returns (uint256);
    function updateRewardPeriodParams(
        uint256 _newRewardPeriodSize,
        uint256 _newDecayNumerator,
        uint256 _newDecayDenominator
    ) external;
    function updateClaimDelay(uint256 _newClaimDelay) external;
    function updateStakingDonationRatio(uint256 _newStakingDonationRatio) external;
    function updateCommunityDonationRatio(uint256 _newCommunityDonationRatio) external;
    function updateAgainstPeriods(uint256 _newAgainstPeriods) external;
    function updateTreasury(ITreasury _newTreasury) external;
    function updateStaking(IStaking _newStaking) external;
    function donate(IERC20 _token, uint256 _amount, address _delegateAddress) external;
    function donateToCommunity(ICommunity _community, IERC20 _token, uint256 _amount, address _delegateAddress) external;
    function claimRewards() external;
    function claimRewardsPartial(uint256 _lastPeriodNumber) external;
    function stakeRewards() external;
    function stakeRewardsPartial(uint256 _lastPeriodNumber) external;
    function calculateClaimableRewards(address _donor) external returns (uint256);
    function calculateClaimableRewardsByPeriodNumber(address _donor, uint256 _lastPeriodNumber) external returns (uint256);
    function estimateClaimableReward(address _donor) external view returns (uint256);
    function estimateClaimableRewardAdvance(address _donor) external view returns (uint256);
    function estimateClaimableRewardByStaking(address _donor) external view returns (uint256);
    function apr(address _stakeholderAddress) external view returns (uint256);
    function generalApr() external view returns (uint256);
    function lastPeriodsDonations(address _donor) external view returns (uint256 donorAmount, uint256 totalAmount);
    function transfer(IERC20 _token, address _to, uint256 _amount) external;
    function setStakingAmounts(address _holderAddress, uint256 _holderStakeAmount, uint256 _totalStakesAmount) external;
    function currentRewardPeriodNumber() external view returns (uint256);

}
          

/contracts/governor/impactMarketCouncil/interfaces/IImpactMarketCouncil.sol

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

import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IImpactMarketCouncil {
    //
}
          

/contracts/interfaces/IMintableERC20.sol

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

interface IMintableERC20 {
    function mint(address _account, uint96 _amount) external;

    function burn(address _account, uint96 _amount) external;

    function totalSupply() external view returns (uint256);

    function balanceOf(address _account) external view returns (uint256);

    function transfer(address _recipient, uint256 _amount) external returns (bool);

    function allowance(address _owner, address _spender) external view returns (uint256);

    function approve(address _spender, uint256 _amount) external returns (bool);

    function transferFrom(
        address _sender,
        address _recipient,
        uint256 _amount
    ) external returns (bool);
}
          

/contracts/staking/interfaces/IStaking.sol

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

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../../donationMiner/interfaces/IDonationMiner.sol";
import "../../interfaces/IMintableERC20.sol";

interface IStaking {
    struct Unstake {
        uint256 amount;         //amount unstaked
        uint256 cooldownBlock;  //first block number that will allow holder to claim this unstake
    }

    struct Holder {
        uint256 amount;          // amount of PACT that are staked by holder
        uint256 nextUnstakeId;   //
        Unstake[] unstakes;      //list of all unstakes amount
    }

    function getVersion() external view returns(uint256);
    function updateCooldown(uint256 _newCooldown) external;
    function PACT() external view returns (IERC20);
    function SPACT() external view returns (IMintableERC20);
    function donationMiner() external view returns (IDonationMiner);
    function cooldown() external view returns(uint256);
    function currentTotalAmount() external view returns(uint256);
    function stakeholderAmount(address _holderAddress) external view returns(uint256);
    function stakeholder(address _holderAddress) external view returns (uint256 amount, uint256 nextUnstakeId, uint256 unstakeListLength, uint256 unstakedAmount);
    function stakeholderUnstakeAt(address _holderAddress, uint256 _unstakeIndex) external view returns (Unstake memory);
    function stakeholdersListAt(uint256 _index) external view returns (address);
    function stakeholdersListLength() external view returns (uint256);

    function stake(address _holder, uint256 _amount) external;
    function unstake(uint256 _amount) external;
    function claim() external;
    function claimPartial(uint256 _lastUnstakeId) external;
    function claimAmount(address _holderAddress) external view returns (uint256);
}
          

/contracts/treasury/interfaces/ITreasury.sol

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

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../../community/interfaces/ICommunityAdmin.sol";
import "./IUniswapV2Router.sol";

interface ITreasury {
    struct Token {
        uint256 rate;
        address[] exchangePath;
    }

    function getVersion() external returns(uint256);
    function communityAdmin() external view returns(ICommunityAdmin);
    function uniswapRouter() external view returns(IUniswapV2Router);
    function updateCommunityAdmin(ICommunityAdmin _communityAdmin) external;
    function updateUniswapRouter(IUniswapV2Router _uniswapRouter) external;
    function transfer(IERC20 _token, address _to, uint256 _amount) external;
    function isToken(address _tokenAddress) external view returns (bool);
    function tokenListLength() external view returns (uint256);
    function tokenListAt(uint256 _index) external view returns (address);
    function tokens(address _tokenAddress) external view returns (uint256 rate, address[] memory exchangePath);
    function setToken(address _tokenAddress, uint256 _rate, address[] calldata _exchangePath) external;
    function removeToken(address _tokenAddress) external;
    function getConvertedAmount(address _tokenAddress, uint256 _amount) external view returns (uint256);
    function convertAmount(
        address _tokenAddress,
        uint256 _amountIn,
        uint256 _amountOutMin,
        address[] memory _exchangePath,
        uint256 _deadline
    ) external;
}
          

/contracts/treasury/interfaces/IUniswapV2Router.sol

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

interface IUniswapV2Router {
    function factory() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;

    function pairFor(address tokenA, address tokenB) external view returns (address);
}
          

Contract ABI

[{"type":"event","name":"AgainstPeriodsUpdated","inputs":[{"type":"uint256","name":"oldAgainstPeriods","internalType":"uint256","indexed":false},{"type":"uint256","name":"newAgainstPeriods","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ClaimDelayUpdated","inputs":[{"type":"uint256","name":"oldClaimDelay","internalType":"uint256","indexed":false},{"type":"uint256","name":"newClaimDelay","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"CommunityDonationRatioUpdated","inputs":[{"type":"uint256","name":"oldCommunityDonationRatio","internalType":"uint256","indexed":false},{"type":"uint256","name":"newCommunityDonationRatio","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"DonationAdded","inputs":[{"type":"uint256","name":"donationId","internalType":"uint256","indexed":true},{"type":"address","name":"delegateAddress","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"address","name":"token","internalType":"address","indexed":false},{"type":"uint256","name":"initialAmount","internalType":"uint256","indexed":false},{"type":"address","name":"target","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"RewardClaimed","inputs":[{"type":"address","name":"donor","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardClaimedPartial","inputs":[{"type":"address","name":"donor","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"lastRewardPeriod","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardPeriodParamsUpdated","inputs":[{"type":"uint256","name":"oldRewardPeriodSize","internalType":"uint256","indexed":false},{"type":"uint256","name":"oldDecayNumerator","internalType":"uint256","indexed":false},{"type":"uint256","name":"oldDecayDenominator","internalType":"uint256","indexed":false},{"type":"uint256","name":"newRewardPeriodSize","internalType":"uint256","indexed":false},{"type":"uint256","name":"newDecayNumerator","internalType":"uint256","indexed":false},{"type":"uint256","name":"newDecayDenominator","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardStaked","inputs":[{"type":"address","name":"donor","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardStakedPartial","inputs":[{"type":"address","name":"donor","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"lastRewardPeriod","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"StakingDonationRatioUpdated","inputs":[{"type":"uint256","name":"oldStakingDonationRatio","internalType":"uint256","indexed":false},{"type":"uint256","name":"newStakingDonationRatio","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"StakingUpdated","inputs":[{"type":"address","name":"oldStaking","internalType":"address","indexed":true},{"type":"address","name":"newStaking","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"TransferERC20","inputs":[{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"TreasuryUpdated","inputs":[{"type":"address","name":"oldTreasury","internalType":"address","indexed":true},{"type":"address","name":"newTreasury","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"PACT","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"againstPeriods","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"apr","inputs":[{"type":"address","name":"_stakeholderAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"cUSD","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"calculateClaimableRewards","inputs":[{"type":"address","name":"_donorAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"calculateClaimableRewardsByPeriodNumber","inputs":[{"type":"address","name":"_donorAddress","internalType":"address"},{"type":"uint256","name":"_lastPeriodNumber","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"claimDelay","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimRewards","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimRewardsPartial","inputs":[{"type":"uint256","name":"_lastPeriodNumber","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"communityDonationRatio","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"currentRewardPeriodNumber","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"decayDenominator","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"decayNumerator","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"donate","inputs":[{"type":"address","name":"_token","internalType":"contract IERC20"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"address","name":"_delegateAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"donateToCommunity","inputs":[{"type":"address","name":"_community","internalType":"contract ICommunity"},{"type":"address","name":"_token","internalType":"contract IERC20"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"address","name":"_delegateAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"donationCount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"donor","internalType":"address"},{"type":"address","name":"target","internalType":"address"},{"type":"uint256","name":"rewardPeriod","internalType":"uint256"},{"type":"uint256","name":"blockNumber","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"address","name":"token","internalType":"contract IERC20"},{"type":"uint256","name":"initialAmount","internalType":"uint256"}],"name":"donations","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"donorRewardPeriod","inputs":[{"type":"address","name":"_donor","internalType":"address"},{"type":"uint256","name":"_rewardPeriodIndex","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"donorScore","inputs":[{"type":"address","name":"_donorAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"lastClaim","internalType":"uint256"},{"type":"uint256","name":"rewardPeriodsCount","internalType":"uint256"},{"type":"uint256","name":"lastClaimPeriod","internalType":"uint256"}],"name":"donors","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"estimateClaimableReward","inputs":[{"type":"address","name":"_donorAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"estimateClaimableRewardAdvance","inputs":[{"type":"address","name":"_donorAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"estimateClaimableRewardByStaking","inputs":[{"type":"address","name":"_donorAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"generalApr","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getVersion","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_cUSD","internalType":"contract IERC20"},{"type":"address","name":"_PACT","internalType":"contract IERC20"},{"type":"address","name":"_treasury","internalType":"contract ITreasury"},{"type":"uint256","name":"_firstRewardPerBlock","internalType":"uint256"},{"type":"uint256","name":"_rewardPeriodSize","internalType":"uint256"},{"type":"uint256","name":"_startingBlock","internalType":"uint256"},{"type":"uint256","name":"_decayNumerator","internalType":"uint256"},{"type":"uint256","name":"_decayDenominator","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"donorAmount","internalType":"uint256"},{"type":"uint256","name":"totalAmount","internalType":"uint256"}],"name":"lastPeriodsDonations","inputs":[{"type":"address","name":"_donorAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardPeriodCount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardPeriodDonorAmount","inputs":[{"type":"uint256","name":"_period","internalType":"uint256"},{"type":"address","name":"_donor","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardPeriodDonorStakeAmounts","inputs":[{"type":"uint256","name":"_period","internalType":"uint256"},{"type":"address","name":"_donor","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardPeriodSize","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"rewardPerBlock","internalType":"uint256"},{"type":"uint256","name":"rewardAmount","internalType":"uint256"},{"type":"uint256","name":"startBlock","internalType":"uint256"},{"type":"uint256","name":"endBlock","internalType":"uint256"},{"type":"uint256","name":"donationsAmount","internalType":"uint256"},{"type":"uint256","name":"againstPeriods","internalType":"uint256"},{"type":"uint256","name":"stakesAmount","internalType":"uint256"},{"type":"uint256","name":"stakingDonationRatio","internalType":"uint256"}],"name":"rewardPeriods","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setStakingAmounts","inputs":[{"type":"address","name":"_holderAddress","internalType":"address"},{"type":"uint256","name":"_holderAmount","internalType":"uint256"},{"type":"uint256","name":"_totalAmount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"stakeRewards","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"stakeRewardsPartial","inputs":[{"type":"uint256","name":"_lastPeriodNumber","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IStaking"}],"name":"staking","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"stakingDonationRatio","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transfer","inputs":[{"type":"address","name":"_token","internalType":"contract IERC20"},{"type":"address","name":"_to","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ITreasury"}],"name":"treasury","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateAgainstPeriods","inputs":[{"type":"uint256","name":"_newAgainstPeriods","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateClaimDelay","inputs":[{"type":"uint256","name":"_newClaimDelay","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateCommunityDonationRatio","inputs":[{"type":"uint256","name":"_newCommunityDonationRatio","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateRewardPeriodParams","inputs":[{"type":"uint256","name":"_newRewardPeriodSize","internalType":"uint256"},{"type":"uint256","name":"_newDecayNumerator","internalType":"uint256"},{"type":"uint256","name":"_newDecayDenominator","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateStaking","inputs":[{"type":"address","name":"_newStaking","internalType":"contract IStaking"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateStakingDonationRatio","inputs":[{"type":"uint256","name":"_newStakingDonationRatio","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateTreasury","inputs":[{"type":"address","name":"_newTreasury","internalType":"contract ITreasury"}]}]
              

Contract Creation Code

0x608060405234801561001057600080fd5b50613e52806100206000396000f3fe608060405234801561001057600080fd5b50600436106102d65760003560e01c806396990e6e11610182578063cf428795116100e9578063e57919d6116100a2578063f2fde38b1161007c578063f2fde38b146106d4578063f8626af8146106e7578063fa86590914610785578063fef4af861461079857600080fd5b8063e57919d6146106b0578063ed409ff3146106b8578063f223c973146106c157600080fd5b8063cf42879514610622578063cf9d0b5f1461065c578063de8f41ba14610664578063df8fa43014610677578063e247b8d81461068a578063e48508df1461069d57600080fd5b8063ad3e48c51161013b578063ad3e48c514610583578063beabacc814610596578063c38474c0146105a9578063c89d1a8e146105b2578063ca0cdea8146105c5578063cd75000c1461060f57600080fd5b806396990e6e1461052f578063a345f38d14610542578063a4b01bf514610555578063a70e940b14610568578063a915da5614610571578063ac9e03881461057a57600080fd5b806353d541c111610241578063715018a6116101fa5780638252097d116101d45780638252097d146104765780638901e985146105025780638da5cb5b1461051557806392ade2991461052657600080fd5b8063715018a6146104485780637f51bb1f14610450578063821787ec1461046357600080fd5b806353d541c1146103d357806359d0bfff146103e65780635c975abb146103f957806361d027b31461040f5780636cc40c2c146104225780636d0acb431461043557600080fd5b80632abfab4d116102935780632abfab4d1461034f5780632bef5eef14610358578063372500ab1461036b5780633b9a0176146103735780633ddec531146103865780634cf088d9146103c057600080fd5b806307ea4e57146102db5780630d1e9b4a146102f75780630d8e6e2c1461030c5780631569cc95146103135780631c8ec2991461031b5780631fccf67214610324575b600080fd5b6102e460cf5481565b6040519081526020015b60405180910390f35b61030a61030536600461396c565b6107c0565b005b60046102e4565b6102e461097a565b6102e460d45481565b60c954610337906001600160a01b031681565b6040516001600160a01b0390911681526020016102ee565b6102e460cd5481565b6102e46103663660046139fc565b6109d4565b61030a610a01565b60ca54610337906001600160a01b031681565b6102e46103943660046137c9565b6001600160a01b0391909116600090815260d36020908152604080832093835260029093019052205490565b60d654610337906001600160a01b031681565b6102e46103e13660046137ad565b610af0565b61030a6103f4366004613864565b610ca2565b60655460ff1660405190151581526020016102ee565b60cb54610337906001600160a01b031681565b61030a6104303660046139cc565b611023565b61030a6104433660046139cc565b611273565b61030a6112de565b61030a61045e3660046137ad565b611314565b6102e46104713660046137c9565b61139a565b6104c76104843660046139cc565b60d2602052600090815260409020805460018201546002830154600384015460048501546006860154600787015460089097015495969495939492939192909188565b604080519889526020890197909752958701949094526060860192909252608085015260a084015260c083015260e0820152610100016102ee565b61030a6105103660046139cc565b6114bf565b6033546001600160a01b0316610337565b6102e460d05481565b6102e461053d3660046137ad565b611532565b61030a6105503660046137ad565b61164f565b61030a6105633660046139cc565b6116d5565b6102e460d55481565b6102e460d85481565b6102e460d75481565b61030a6105913660046137f4565b611748565b61030a6105a43660046138b6565b61188a565b6102e460ce5481565b6102e46105c03660046137ad565b611947565b6105f46105d33660046137ad565b60d36020526000908152604090208054600182015460039092015490919083565b604080519384526020840192909252908201526060016102ee565b6102e461061d3660046137ad565b6119b0565b6102e46106303660046139fc565b600082815260d2602090815260408083206001600160a01b0385168452600a0190915290205492915050565b61030a6119d8565b61030a6106723660046139cc565b611b9a565b61030a6106853660046138f6565b611d0c565b61030a6106983660046139cc565b61208a565b61030a6106ab366004613a2b565b6120f5565b6102e46121ae565b6102e460cc5481565b6102e46106cf3660046137ad565b612335565b61030a6106e23660046137ad565b612349565b6107416106f53660046139cc565b60d16020526000908152604090208054600182015460028301546003840154600485015460058601546006909601546001600160a01b0395861696948616959394929391929091169087565b604080516001600160a01b03988916815296881660208801528601949094526060850192909252608084015290921660a082015260c081019190915260e0016102ee565b6102e46107933660046137ad565b6123e4565b6107ab6107a63660046137ad565b61244e565b604080519283526020830191909152016102ee565b60655460ff16156107ec5760405162461bcd60e51b81526004016107e390613adc565b60405180910390fd5b600160005260d2602052600080516020613dfd833981519152544310156108255760405162461bcd60e51b81526004016107e390613aa5565b600260975414156108485760405162461bcd60e51b81526004016107e390613be3565b600260975560c9546001600160a01b03848116911614806108e1575060cb546040516319f3736160e01b81526001600160a01b038581166004830152909116906319f373619060240160206040518083038186803b1580156108a957600080fd5b505afa1580156108bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e19190613828565b6109395760405162461bcd60e51b8152602060048201526024808201527f446f6e6174696f6e4d696e65723a3a646f6e6174653a20496e76616c6964207460448201526337b5b2b760e11b60648201526084016107e3565b60cb54610955906001600160a01b0385811691339116856124a1565b60cb54610970908290859085906001600160a01b0316612512565b5050600160975550565b60ce54600090815260d260205260408120600301544381116109ca5760cc546109a38243613d5c565b6109ad9190613c32565b60ce546109ba9190613c1a565b6109c5906001613c1a565b6109ce565b60ce545b91505090565b600082815260d2602090815260408083206001600160a01b03851684526005019091529020545b92915050565b60655460ff1615610a245760405162461bcd60e51b81526004016107e390613adc565b600160005260d2602052600080516020613dfd83398151915254431015610a5d5760405162461bcd60e51b81526004016107e390613aa5565b60026097541415610a805760405162461bcd60e51b81526004016107e390613be3565b60026097556000610a9833610a936126d6565b61271d565b60ca54909150610ab2906001600160a01b0316338361289a565b60405181815233907f106f923f993c2149d49b4255ff723acafa1f2d94393f561d3eda32ae348f7241906020015b60405180910390a2506001609755565b6001600090815260d2602052600080516020613dfd83398151915254431015610b2b5760405162461bcd60e51b81526004016107e390613aa5565b60655460ff1615610b4e5760405162461bcd60e51b81526004016107e390613adc565b600080610b5b600061244e565b915060009050610b696128cf565b905060d660009054906101000a90046001600160a01b03166001600160a01b0316638c58d0a96040518163ffffffff1660e01b815260040160206040518083038186803b158015610bb957600080fd5b505afa158015610bcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf191906139e4565b60d754610bfe9084613d3d565b610c089190613c1a565b60d654604051631aefa86d60e21b81526001600160a01b03888116600483015290911690636bbea1b49060240160206040518083038186803b158015610c4d57600080fd5b505afa158015610c61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c8591906139e4565b610c8f9083613d3d565b610c999190613c32565b95945050505050565b60655460ff1615610cc55760405162461bcd60e51b81526004016107e390613adc565b600160005260d2602052600080516020613dfd83398151915254431015610cfe5760405162461bcd60e51b81526004016107e390613aa5565b60026097541415610d215760405162461bcd60e51b81526004016107e390613be3565b600260975560cb5460408051632fd648bd60e11b815290516000926001600160a01b031691635fac917a916004808301926020929190829003018186803b158015610d6b57600080fd5b505afa158015610d7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da39190613848565b90506001604051633f9409e960e11b81526001600160a01b038781166004830152831690637f2813d29060240160206040518083038186803b158015610de857600080fd5b505afa158015610dfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e2091906139ad565b6003811115610e3f57634e487b7160e01b600052602160045260246000fd5b14610ec25760405162461bcd60e51b815260206004820152604760248201527f446f6e6174696f6e4d696e65723a3a646f6e617465546f436f6d6d756e69747960448201527f3a2054686973206973206e6f7420612076616c696420636f6d6d756e697479206064820152666164647265737360c81b608482015260a4016107e3565b846001600160a01b0316631fccf6726040518163ffffffff1660e01b815260040160206040518083038186803b158015610efb57600080fd5b505afa158015610f0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f339190613848565b6001600160a01b0316846001600160a01b031614610fab5760405162461bcd60e51b815260206004820152602f60248201527f446f6e6174696f6e4d696e65723a3a646f6e617465546f436f6d6d756e69747960448201526e1d1024b73b30b634b2103a37b5b2b760891b60648201526084016107e3565b60405163e69d849d60e01b8152336004820152602481018490526001600160a01b0386169063e69d849d90604401600060405180830381600087803b158015610ff357600080fd5b505af1158015611007573d6000803e3d6000fd5b5050505061101782858588612512565b50506001609755505050565b60655460ff16156110465760405162461bcd60e51b81526004016107e390613adc565b600160005260d2602052600080516020613dfd8339815191525443101561107f5760405162461bcd60e51b81526004016107e390613aa5565b600260975414156110a25760405162461bcd60e51b81526004016107e390613be3565b60026097556110af612950565b60ce5481106111395760405162461bcd60e51b815260206004820152604a60248201527f446f6e6174696f6e4d696e65723a3a7374616b6552657761726473506172746960448201527f616c3a20546869732072657761726420706572696f642069736e277420636c616064820152691a5b58589b19481e595d60b21b608482015260a4016107e3565b6000611145338361271d565b60ca5460d65460405163095ea7b360e01b81526001600160a01b03918216600482015260248101849052929350169063095ea7b390604401602060405180830381600087803b15801561119757600080fd5b505af11580156111ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111cf9190613828565b5060d6546040516356e4bb9760e11b8152336004820152602481018390526001600160a01b039091169063adc9772e90604401600060405180830381600087803b15801561121c57600080fd5b505af1158015611230573d6000803e3d6000fd5b50506040518381523392507f7d3a0ab251dfd8c04c691239edd99d2c124cce6971cebc4c2ed96a378d13d50091506020015b60405180910390a250506001609755565b6033546001600160a01b0316331461129d5760405162461bcd60e51b81526004016107e390613b06565b60d85460408051918252602082018390527f300b3540c99261403e527f171e281f3dfb0705395e1902af7e9badcddce56e5e910160405180910390a160d855565b6033546001600160a01b031633146113085760405162461bcd60e51b81526004016107e390613b06565b6113126000612a91565b565b6033546001600160a01b0316331461133e5760405162461bcd60e51b81526004016107e390613b06565b60cb546040516001600160a01b038084169216907f4ab5be82436d353e61ca18726e984e561f5c1cc7c6d38b29d2553c790434705a90600090a360cb80546001600160a01b0319166001600160a01b0392909216919091179055565b60ce54600090815260d2602052604081206003015481904311156113fb5760cc5460ce54600090815260d260205260409020600301546113da9043613d5c565b6113e49190613c32565b905060ce54816113f49190613c1a565b905061140d565b600160ce5461140a9190613d5c565b90505b808311156114a95760405162461bcd60e51b815260206004820152605e60248201527f446f6e6174696f6e4d696e65723a3a63616c63756c617465436c61696d61626c60448201527f65526577617264734279506572696f644e756d6265723a20546869732072657760648201527f61726420706572696f642069736e277420617661696c61626c65207965740000608482015260a4016107e3565b60006114b58585612ae3565b5095945050505050565b6033546001600160a01b031633146114e95760405162461bcd60e51b81526004016107e390613b06565b6114f1612950565b60d75460408051918252602082018390527fb7ce19da4d8265c844e0fa744e3429c62104c793f8ecb52d1b418b47eb9f8555910160405180910390a160d755565b6001600090815260d2602052600080516020613dfd8339815191525443101561156d5760405162461bcd60e51b81526004016107e390613aa5565b60655460ff16156115905760405162461bcd60e51b81526004016107e390613adc565b60d654604051631aefa86d60e21b81526001600160a01b0384811660048301526000921690636bbea1b49060240160206040518083038186803b1580156115d657600080fd5b505afa1580156115ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061160e91906139e4565b90508061161e5750600092915050565b8061162a846000612f09565b61163e90694d501c54214bcd300000613d3d565b6116489190613c32565b9392505050565b6033546001600160a01b031633146116795760405162461bcd60e51b81526004016107e390613b06565b60d6546040516001600160a01b038084169216907fcfa056eb826b2a28817aa38ccb94f12ba8a1309598f7ea19bef6fd67fe04b61e90600090a360d680546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b031633146116ff5760405162461bcd60e51b81526004016107e390613b06565b611707612950565b60d55460408051918252602082018390527fd6a28c11ae992e0014e83eaaa6f0023a04c0787848134e8b4e43f44b7d7d8e30910160405180910390a160d555565b60655460ff161561176b5760405162461bcd60e51b81526004016107e390613adc565b600160005260d2602052600080516020613dfd833981519152544310156117a45760405162461bcd60e51b81526004016107e390613aa5565b60d6546001600160a01b031633146117fe5760405162461bcd60e51b815260206004820152601a60248201527f446f6e6174696f6e4d696e65723a204e4f545f5354414b494e4700000000000060448201526064016107e3565b611806612950565b60ce54600090815260d2602090815260408083206001600160a01b0387168452600981018352818420805460ff19166001179055600a810183528184208690556007810185905560d3909252909120600381015415801561186957506001810154155b1561188357600160ce5461187d9190613d5c565b60038201555b5050505050565b6033546001600160a01b031633146118b45760405162461bcd60e51b81526004016107e390613b06565b600260975414156118d75760405162461bcd60e51b81526004016107e390613be3565b60026097556118f06001600160a01b038416838361289a565b816001600160a01b0316836001600160a01b03167f9b035625e569d1d2bf54830a290aefba7ab11610ba8490871dc62b86b63a89568360405161193591815260200190565b60405180910390a35050600160975550565b6001600090815260d2602052600080516020613dfd833981519152544310156119825760405162461bcd60e51b81526004016107e390613aa5565b60655460ff16156119a55760405162461bcd60e51b81526004016107e390613adc565b6109fb826000612f09565b6000806119d08360016119c161097a565b6119cb9190613d5c565b612ae3565b509392505050565b60655460ff16156119fb5760405162461bcd60e51b81526004016107e390613adc565b600160005260d2602052600080516020613dfd83398151915254431015611a345760405162461bcd60e51b81526004016107e390613aa5565b60026097541415611a575760405162461bcd60e51b81526004016107e390613be3565b6002609755611a64612950565b6000611a7933600160ce54610a939190613d5c565b60ca5460d65460405163095ea7b360e01b81526001600160a01b03918216600482015260248101849052929350169063095ea7b390604401602060405180830381600087803b158015611acb57600080fd5b505af1158015611adf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b039190613828565b5060d6546040516356e4bb9760e11b8152336004820152602481018390526001600160a01b039091169063adc9772e90604401600060405180830381600087803b158015611b5057600080fd5b505af1158015611b64573d6000803e3d6000fd5b50506040518381523392507f7d3a0ab251dfd8c04c691239edd99d2c124cce6971cebc4c2ed96a378d13d5009150602001610ae0565b60655460ff1615611bbd5760405162461bcd60e51b81526004016107e390613adc565b600160005260d2602052600080516020613dfd83398151915254431015611bf65760405162461bcd60e51b81526004016107e390613aa5565b60026097541415611c195760405162461bcd60e51b81526004016107e390613be3565b6002609755611c266126d6565b811115611cae5760405162461bcd60e51b815260206004820152604a60248201527f446f6e6174696f6e4d696e65723a3a636c61696d52657761726473506172746960448201527f616c3a20546869732072657761726420706572696f642069736e277420636c616064820152691a5b58589b19481e595d60b21b608482015260a4016107e3565b6000611cba338361271d565b60ca54909150611cd4906001600160a01b0316338361289a565b604080518281526020810184905233917f2233b4bbf378b3d984acd0e36cea96f66bc81012a683e81929ed96df5287ba3d9101611262565b600054610100900460ff16611d275760005460ff1615611d2b565b303b155b611d8e5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016107e3565b600054610100900460ff16158015611db0576000805461ffff19166101011790555b6001600160a01b038916611e1e5760405162461bcd60e51b815260206004820152602f60248201527f446f6e6174696f6e4d696e65723a3a696e697469616c697a653a20635553442060448201526e1859191c995cdcc81b9bdd081cd95d608a1b60648201526084016107e3565b6001600160a01b038816611e8c5760405162461bcd60e51b815260206004820152602f60248201527f446f6e6174696f6e4d696e65723a3a696e697469616c697a653a20504143542060448201526e1859191c995cdcc81b9bdd081cd95d608a1b60648201526084016107e3565b6001600160a01b038716611ef75760405162461bcd60e51b815260206004820152602c60248201527f446f6e6174696f6e4d696e65723a3a696e697469616c697a653a20747265617360448201526b1d5c9e57c81b9bdd081cd95d60a21b60648201526084016107e3565b85611f6a5760405162461bcd60e51b815260206004820152603760248201527f446f6e6174696f6e4d696e65723a3a696e697469616c697a653a20666972737460448201527f526577617264506572426c6f636b206e6f74207365742100000000000000000060648201526084016107e3565b83611fdd5760405162461bcd60e51b815260206004820152603860248201527f446f6e6174696f6e4d696e65723a3a696e697469616c697a653a20737461727460448201527f696e67526577617264506572696f64206e6f742073657421000000000000000060648201526084016107e3565b84611ffa5760405162461bcd60e51b81526004016107e390613b3b565b612002612f62565b61200a612f99565b612012612fd0565b60c980546001600160a01b03808c166001600160a01b03199283161790925560ca80548b841690831617905560cb8054928a169290911691909117905560cc85905560cf83905560d0829055600160ce5561206d8487612fff565b801561207f576000805461ff00191690555b505050505050505050565b6033546001600160a01b031633146120b45760405162461bcd60e51b81526004016107e390613b06565b60d45460408051918252602082018390527f7625e5482008771a414881eb4c957803f2ab46e99e6da60df6e1310f0f009fec910160405180910390a160d455565b6033546001600160a01b0316331461211f5760405162461bcd60e51b81526004016107e390613b06565b8261213c5760405162461bcd60e51b81526004016107e390613b3b565b612144612950565b60cc5460cf5460d05460408051938452602084019290925282820152606082018590526080820184905260a08201839052517f8fb29c6ced5ce51696c08668df816fab7e60c674a6c36e167d5df9b8a5f499849181900360c00190a160cc9290925560cf5560d055565b6001600090815260d2602052600080516020613dfd833981519152544310156121e95760405162461bcd60e51b81526004016107e390613aa5565b60655460ff161561220c5760405162461bcd60e51b81526004016107e390613adc565b600080612219600061244e565b9150600090506122276128cf565b90508060005b61016c8110156122715760d05460cf546122479085613d3d565b6122519190613c32565b925061225d8383613c1a565b91508061226981613db6565b91505061222d565b60d660009054906101000a90046001600160a01b03166001600160a01b0316638c58d0a96040518163ffffffff1660e01b815260040160206040518083038186803b1580156122bf57600080fd5b505afa1580156122d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122f791906139e4565b60d7546123049086613d3d565b61230e9190613c1a565b6123218368056bc75e2d63100000613d3d565b61232b9190613c32565b9550505050505090565b60006109fb82670de0b6b3a7640000613076565b6033546001600160a01b031633146123735760405162461bcd60e51b81526004016107e390613b06565b6001600160a01b0381166123d85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107e3565b6123e181612a91565b50565b6001600090815260d2602052600080516020613dfd8339815191525443101561241f5760405162461bcd60e51b81526004016107e390613aa5565b60655460ff16156124425760405162461bcd60e51b81526004016107e390613adc565b6109fb8260d554612f09565b600080600061245b61097a565b9050600060d554821161246f57600161247c565b60d55461247c9083613d5c565b90508060ce541061249a57612494858260ce546132fa565b90945092505b5050915091565b6040516001600160a01b038085166024830152831660448201526064810182905261250c9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261336f565b50505050565b61251a612950565b60cd805490600061252a83613db6565b909155505060cd54600090815260d16020526040902080546001600160a01b038087166001600160a01b0319928316178355600183018054858316908416811790915543600385015560ce5460028501556005840180548884169416939093179092556006830185905560cb541614156126485760c9546001600160a01b0385811691161461263c5760cb5460405163f2b8995160e01b81526001600160a01b038681166004830152602482018690529091169063f2b899519060440160206040518083038186803b1580156125ff57600080fd5b505afa158015612613573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263791906139e4565b61263e565b825b600482015561265b565b60d8546126559084613c32565b60048201555b61266c60ce54868360040154613441565b6126758561349e565b60cd546004820154604080519182526001600160a01b03878116602084015290820186905280851692908816917f3d2fa2b84d5f2000d605401d563ba60e2e44f62701fdbe9f9101c59b3c215f299060600160405180910390a45050505050565b60006126e0612950565b60d4546126ee906001613c1a565b60ce54116126fc5750600090565b60d454600160ce5461270e9190613d5c565b6127189190613d5c565b905090565b6001600160a01b038216600090815260d36020526040812081806127418686612ae3565b6003850154919350915085111561275a57600383018590555b600085815260d2602090815260408083206001600160a01b038a168452600a01909152902081905581612791575091506109fb9050565b60ca546040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b1580156127d457600080fd5b505afa1580156127e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061280c91906139e4565b8211156128915760ca546040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b15801561285657600080fd5b505afa15801561286a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061288e91906139e4565b91505b50949350505050565b6040516001600160a01b0383166024820152604481018290526128ca90849063a9059cbb60e01b906064016124d5565b505050565b6000806128da61097a565b9050600060ce54826128ec9190613d5c565b60d0546128f99190613c95565b60ce546129069084613d5c565b60cf546129139190613c95565b60ce54600090815260d2602052604090205461292f9190613d3d565b6129399190613c32565b905060cc54816129499190613d3d565b9250505090565b60ce54600090815260d2602052604090205b43816003015410156123e15760ce805490600061297e83613db6565b909155505060ce54600090815260d26020526040902060d554600682015560038201546129ac906001613c1a565b6002820181905560cc546001916129c39190613c1a565b6129cd9190613d5c565b600382015560d05460cf5483546129e49190613d3d565b6129ee9190613c32565b8082556007808401549083015560d754600883015560cc54600091612a1291613d3d565b905060008360060154600160ce54612a2a9190613d5c565b11612a36576001612a54565b8360060154600160ce54612a4a9190613d5c565b612a549190613d5c565b9050612a6e81600160ce54612a699190613d5c565b613537565b612a84576001840154612a819083613c1a565b91505b5060018201559050612962565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216600090815260d36020526040812060038101548291908290612b10906001613c1a565b90508060011415612b3c5781546000908152600283016020526040902054612b39906001613c1a565b90505b60d26020819052600082815260408120818052909182918291829182917f20791b593a776a2631a28f4a3f62a14ad18db22add38130c4f4a8fdfa46398859190829084612b8a60018c613d5c565b8152602001908152602001600020600a0160008f6001600160a01b03166001600160a01b03168152602001908152602001600020549a505b8c8911612ef857600282015415612d53576006820154612c06576001600160a01b038e16600090815260058301602052604090205460048301549098509650612d25565b816006015483600601541415612ce3576006820154612c26906001613c1a565b891115612ca55760d26000836006015460018c612c439190613d5c565b612c4d9190613d5c565b815260200190815260200160002090508060050160008f6001600160a01b03166001600160a01b031681526020019081526020016000205488612c909190613d5c565b9750806004015487612ca29190613d5c565b96505b6001600160a01b038e166000908152600583016020526040902054612cca9089613c1a565b9750816004015487612cdc9190613c1a565b9650612d25565b8160060154891115612d1357612d098e83600601548b612d039190613d5c565b8b6132fa565b9098509650612d25565b612d1f8e60008b6132fa565b90985096505b81600101549550816007015494506000826008015411612d46576001612d4c565b81600801545b9350612e35565b60d554612d61906001613c1a565b891115612dde5760d2600060d55460018c612d7c9190613d5c565b612d869190613d5c565b815260200190815260200160002090508060050160008f6001600160a01b03166001600160a01b031681526020019081526020016000205488612dc99190613d5c565b9750806004015487612ddb9190613d5c565b96505b6001600160a01b038e166000908152600583016020526040902054612e039089613c1a565b9750816004015487612e159190613c1a565b965060d05460cf5487612e289190613d3d565b612e329190613c32565b95505b6001600160a01b038e16600090815260098301602052604090205460ff1615612e76576001600160a01b038e166000908152600a830160205260409020549a505b6000612e828c8a613c1a565b1115612ed35784612e938589613d3d565b612e9d9190613c1a565b8b612ea8868b613d3d565b612eb29190613c1a565b612ebc9088613d3d565b612ec69190613c32565b612ed0908d613c1a565b9b505b88612edd81613db6565b600081815260d260205260409020909a50929350612bc29050565b505050505050505050509250929050565b600080612f146128cf565b9050805b8315612f585760d05460cf54612f2e9084613d3d565b612f389190613c32565b9150612f448282613c1a565b905083612f5081613d9f565b945050612f18565b610c998582613076565b600054610100900460ff16612f895760405162461bcd60e51b81526004016107e390613b98565b612f9161358d565b6113126135b4565b600054610100900460ff16612fc05760405162461bcd60e51b81526004016107e390613b98565b612fc861358d565b6113126135e4565b600054610100900460ff16612ff75760405162461bcd60e51b81526004016107e390613b98565b611312613617565b6001600081905260d2602052600080516020613dfd83398151915283905560cc547fb7404ce2b5a52e61a6b5c9b4585ed65d8cb4b8848d3ee262a356d0c2c46c5f35919061304d9085613c1a565b6130579190613d5c565b600382015581815560cc5461306c9083613d3d565b6001909101555050565b60008060006130848561244e565b60d654604080516319e815f960e01b815290519395509193506000926001600160a01b03909116916319e815f9916004808301926020929190829003018186803b1580156130d157600080fd5b505afa1580156130e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131099190613848565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561314157600080fd5b505afa158015613155573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061317991906139e4565b905080158015613187575081155b1561319857600093505050506109fb565b60008060d754116131aa5760016131ae565b60d7545b905060d660009054906101000a90046001600160a01b03166001600160a01b0316638c58d0a96040518163ffffffff1660e01b815260040160206040518083038186803b1580156131fe57600080fd5b505afa158015613212573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061323691906139e4565b6132408285613d3d565b61324a9190613c1a565b60d654604051631aefa86d60e21b81526001600160a01b038a8116600483015290911690636bbea1b49060240160206040518083038186803b15801561328f57600080fd5b505afa1580156132a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132c791906139e4565b6132d18387613d3d565b6132db9190613c1a565b6132e59088613d3d565b6132ef9190613c32565b979650505050505050565b6000808080855b85811161336257600081815260d2602090815260408083206001600160a01b038c168452600581019092529091205461333a9085613c1a565b935080600401548361334c9190613c1a565b925050808061335a90613db6565b915050613301565b5090969095509350505050565b60006133c4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166136459092919063ffffffff16565b8051909150156128ca57808060200190518101906133e29190613828565b6128ca5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016107e3565b600083815260d26020526040812060048101805491928492613464908490613c1a565b90915550506001600160a01b038316600090815260058201602052604081208054849290613493908490613c1a565b909155505050505050565b6001600160a01b038116600090815260d36020908152604080832060018101548452600281019092529091205460ce548114613505576001820180549060006134e683613db6565b909155505060ce54600183015460009081526002840160205260409020555b600382015415801561351957506001820154155b156128ca57600160ce5461352d9190613d5c565b6003830155505050565b60005b81831161358457600083815260d26020526040812060078101546004909101546135649190613c1a565b1115613572575060016109fb565b8261357c81613db6565b93505061353a565b50600092915050565b600054610100900460ff166113125760405162461bcd60e51b81526004016107e390613b98565b600054610100900460ff166135db5760405162461bcd60e51b81526004016107e390613b98565b61131233612a91565b600054610100900460ff1661360b5760405162461bcd60e51b81526004016107e390613b98565b6065805460ff19169055565b600054610100900460ff1661363e5760405162461bcd60e51b81526004016107e390613b98565b6001609755565b6060613654848460008561365c565b949350505050565b6060824710156136bd5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016107e3565b843b61370b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107e3565b600080866001600160a01b031685876040516137279190613a56565b60006040518083038185875af1925050503d8060008114613764576040519150601f19603f3d011682016040523d82523d6000602084013e613769565b606091505b50915091506132ef82828660608315613783575081611648565b8251156137935782518084602001fd5b8160405162461bcd60e51b81526004016107e39190613a72565b6000602082840312156137be578081fd5b813561164881613de7565b600080604083850312156137db578081fd5b82356137e681613de7565b946020939093013593505050565b600080600060608486031215613808578081fd5b833561381381613de7565b95602085013595506040909401359392505050565b600060208284031215613839578081fd5b81518015158114611648578182fd5b600060208284031215613859578081fd5b815161164881613de7565b60008060008060808587031215613879578081fd5b843561388481613de7565b9350602085013561389481613de7565b92506040850135915060608501356138ab81613de7565b939692955090935050565b6000806000606084860312156138ca578283fd5b83356138d581613de7565b925060208401356138e581613de7565b929592945050506040919091013590565b600080600080600080600080610100898b031215613912578384fd5b883561391d81613de7565b9750602089013561392d81613de7565b9650604089013561393d81613de7565b979a96995096976060810135975060808101359660a0820135965060c0820135955060e0909101359350915050565b600080600060608486031215613980578283fd5b833561398b81613de7565b92506020840135915060408401356139a281613de7565b809150509250925092565b6000602082840312156139be578081fd5b815160048110611648578182fd5b6000602082840312156139dd578081fd5b5035919050565b6000602082840312156139f5578081fd5b5051919050565b60008060408385031215613a0e578182fd5b823591506020830135613a2081613de7565b809150509250929050565b600080600060608486031215613a3f578081fd5b505081359360208301359350604090920135919050565b60008251613a68818460208701613d73565b9190910192915050565b6020815260008251806020840152613a91816040850160208701613d73565b601f01601f19169190910160400192915050565b6020808252601e908201527f446f6e6174696f6e4d696e65723a204552525f4e4f545f535441525445440000604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526037908201527f446f6e6174696f6e4d696e65723a3a696e697469616c697a653a20726577617260408201527f64506572696f6453697a6520697320696e76616c696421000000000000000000606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115613c2d57613c2d613dd1565b500190565b600082613c4d57634e487b7160e01b81526012600452602481fd5b500490565b600181815b80851115613c8d578160001904821115613c7357613c73613dd1565b80851615613c8057918102915b93841c9390800290613c57565b509250929050565b60006116488383600082613cab575060016109fb565b81613cb8575060006109fb565b8160018114613cce5760028114613cd857613cf4565b60019150506109fb565b60ff841115613ce957613ce9613dd1565b50506001821b6109fb565b5060208310610133831016604e8410600b8410161715613d17575081810a6109fb565b613d218383613c52565b8060001904821115613d3557613d35613dd1565b029392505050565b6000816000190483118215151615613d5757613d57613dd1565b500290565b600082821015613d6e57613d6e613dd1565b500390565b60005b83811015613d8e578181015183820152602001613d76565b8381111561250c5750506000910152565b600081613dae57613dae613dd1565b506000190190565b6000600019821415613dca57613dca613dd1565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b03811681146123e157600080fdfeb7404ce2b5a52e61a6b5c9b4585ed65d8cb4b8848d3ee262a356d0c2c46c5f37a2646970667358221220b3c6bc9de5d3dbdc8e396416dc80a33a577de2bf5c209de702a65de9f3b9070b64736f6c63430008040033

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106102d65760003560e01c806396990e6e11610182578063cf428795116100e9578063e57919d6116100a2578063f2fde38b1161007c578063f2fde38b146106d4578063f8626af8146106e7578063fa86590914610785578063fef4af861461079857600080fd5b8063e57919d6146106b0578063ed409ff3146106b8578063f223c973146106c157600080fd5b8063cf42879514610622578063cf9d0b5f1461065c578063de8f41ba14610664578063df8fa43014610677578063e247b8d81461068a578063e48508df1461069d57600080fd5b8063ad3e48c51161013b578063ad3e48c514610583578063beabacc814610596578063c38474c0146105a9578063c89d1a8e146105b2578063ca0cdea8146105c5578063cd75000c1461060f57600080fd5b806396990e6e1461052f578063a345f38d14610542578063a4b01bf514610555578063a70e940b14610568578063a915da5614610571578063ac9e03881461057a57600080fd5b806353d541c111610241578063715018a6116101fa5780638252097d116101d45780638252097d146104765780638901e985146105025780638da5cb5b1461051557806392ade2991461052657600080fd5b8063715018a6146104485780637f51bb1f14610450578063821787ec1461046357600080fd5b806353d541c1146103d357806359d0bfff146103e65780635c975abb146103f957806361d027b31461040f5780636cc40c2c146104225780636d0acb431461043557600080fd5b80632abfab4d116102935780632abfab4d1461034f5780632bef5eef14610358578063372500ab1461036b5780633b9a0176146103735780633ddec531146103865780634cf088d9146103c057600080fd5b806307ea4e57146102db5780630d1e9b4a146102f75780630d8e6e2c1461030c5780631569cc95146103135780631c8ec2991461031b5780631fccf67214610324575b600080fd5b6102e460cf5481565b6040519081526020015b60405180910390f35b61030a61030536600461396c565b6107c0565b005b60046102e4565b6102e461097a565b6102e460d45481565b60c954610337906001600160a01b031681565b6040516001600160a01b0390911681526020016102ee565b6102e460cd5481565b6102e46103663660046139fc565b6109d4565b61030a610a01565b60ca54610337906001600160a01b031681565b6102e46103943660046137c9565b6001600160a01b0391909116600090815260d36020908152604080832093835260029093019052205490565b60d654610337906001600160a01b031681565b6102e46103e13660046137ad565b610af0565b61030a6103f4366004613864565b610ca2565b60655460ff1660405190151581526020016102ee565b60cb54610337906001600160a01b031681565b61030a6104303660046139cc565b611023565b61030a6104433660046139cc565b611273565b61030a6112de565b61030a61045e3660046137ad565b611314565b6102e46104713660046137c9565b61139a565b6104c76104843660046139cc565b60d2602052600090815260409020805460018201546002830154600384015460048501546006860154600787015460089097015495969495939492939192909188565b604080519889526020890197909752958701949094526060860192909252608085015260a084015260c083015260e0820152610100016102ee565b61030a6105103660046139cc565b6114bf565b6033546001600160a01b0316610337565b6102e460d05481565b6102e461053d3660046137ad565b611532565b61030a6105503660046137ad565b61164f565b61030a6105633660046139cc565b6116d5565b6102e460d55481565b6102e460d85481565b6102e460d75481565b61030a6105913660046137f4565b611748565b61030a6105a43660046138b6565b61188a565b6102e460ce5481565b6102e46105c03660046137ad565b611947565b6105f46105d33660046137ad565b60d36020526000908152604090208054600182015460039092015490919083565b604080519384526020840192909252908201526060016102ee565b6102e461061d3660046137ad565b6119b0565b6102e46106303660046139fc565b600082815260d2602090815260408083206001600160a01b0385168452600a0190915290205492915050565b61030a6119d8565b61030a6106723660046139cc565b611b9a565b61030a6106853660046138f6565b611d0c565b61030a6106983660046139cc565b61208a565b61030a6106ab366004613a2b565b6120f5565b6102e46121ae565b6102e460cc5481565b6102e46106cf3660046137ad565b612335565b61030a6106e23660046137ad565b612349565b6107416106f53660046139cc565b60d16020526000908152604090208054600182015460028301546003840154600485015460058601546006909601546001600160a01b0395861696948616959394929391929091169087565b604080516001600160a01b03988916815296881660208801528601949094526060850192909252608084015290921660a082015260c081019190915260e0016102ee565b6102e46107933660046137ad565b6123e4565b6107ab6107a63660046137ad565b61244e565b604080519283526020830191909152016102ee565b60655460ff16156107ec5760405162461bcd60e51b81526004016107e390613adc565b60405180910390fd5b600160005260d2602052600080516020613dfd833981519152544310156108255760405162461bcd60e51b81526004016107e390613aa5565b600260975414156108485760405162461bcd60e51b81526004016107e390613be3565b600260975560c9546001600160a01b03848116911614806108e1575060cb546040516319f3736160e01b81526001600160a01b038581166004830152909116906319f373619060240160206040518083038186803b1580156108a957600080fd5b505afa1580156108bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e19190613828565b6109395760405162461bcd60e51b8152602060048201526024808201527f446f6e6174696f6e4d696e65723a3a646f6e6174653a20496e76616c6964207460448201526337b5b2b760e11b60648201526084016107e3565b60cb54610955906001600160a01b0385811691339116856124a1565b60cb54610970908290859085906001600160a01b0316612512565b5050600160975550565b60ce54600090815260d260205260408120600301544381116109ca5760cc546109a38243613d5c565b6109ad9190613c32565b60ce546109ba9190613c1a565b6109c5906001613c1a565b6109ce565b60ce545b91505090565b600082815260d2602090815260408083206001600160a01b03851684526005019091529020545b92915050565b60655460ff1615610a245760405162461bcd60e51b81526004016107e390613adc565b600160005260d2602052600080516020613dfd83398151915254431015610a5d5760405162461bcd60e51b81526004016107e390613aa5565b60026097541415610a805760405162461bcd60e51b81526004016107e390613be3565b60026097556000610a9833610a936126d6565b61271d565b60ca54909150610ab2906001600160a01b0316338361289a565b60405181815233907f106f923f993c2149d49b4255ff723acafa1f2d94393f561d3eda32ae348f7241906020015b60405180910390a2506001609755565b6001600090815260d2602052600080516020613dfd83398151915254431015610b2b5760405162461bcd60e51b81526004016107e390613aa5565b60655460ff1615610b4e5760405162461bcd60e51b81526004016107e390613adc565b600080610b5b600061244e565b915060009050610b696128cf565b905060d660009054906101000a90046001600160a01b03166001600160a01b0316638c58d0a96040518163ffffffff1660e01b815260040160206040518083038186803b158015610bb957600080fd5b505afa158015610bcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf191906139e4565b60d754610bfe9084613d3d565b610c089190613c1a565b60d654604051631aefa86d60e21b81526001600160a01b03888116600483015290911690636bbea1b49060240160206040518083038186803b158015610c4d57600080fd5b505afa158015610c61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c8591906139e4565b610c8f9083613d3d565b610c999190613c32565b95945050505050565b60655460ff1615610cc55760405162461bcd60e51b81526004016107e390613adc565b600160005260d2602052600080516020613dfd83398151915254431015610cfe5760405162461bcd60e51b81526004016107e390613aa5565b60026097541415610d215760405162461bcd60e51b81526004016107e390613be3565b600260975560cb5460408051632fd648bd60e11b815290516000926001600160a01b031691635fac917a916004808301926020929190829003018186803b158015610d6b57600080fd5b505afa158015610d7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da39190613848565b90506001604051633f9409e960e11b81526001600160a01b038781166004830152831690637f2813d29060240160206040518083038186803b158015610de857600080fd5b505afa158015610dfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e2091906139ad565b6003811115610e3f57634e487b7160e01b600052602160045260246000fd5b14610ec25760405162461bcd60e51b815260206004820152604760248201527f446f6e6174696f6e4d696e65723a3a646f6e617465546f436f6d6d756e69747960448201527f3a2054686973206973206e6f7420612076616c696420636f6d6d756e697479206064820152666164647265737360c81b608482015260a4016107e3565b846001600160a01b0316631fccf6726040518163ffffffff1660e01b815260040160206040518083038186803b158015610efb57600080fd5b505afa158015610f0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f339190613848565b6001600160a01b0316846001600160a01b031614610fab5760405162461bcd60e51b815260206004820152602f60248201527f446f6e6174696f6e4d696e65723a3a646f6e617465546f436f6d6d756e69747960448201526e1d1024b73b30b634b2103a37b5b2b760891b60648201526084016107e3565b60405163e69d849d60e01b8152336004820152602481018490526001600160a01b0386169063e69d849d90604401600060405180830381600087803b158015610ff357600080fd5b505af1158015611007573d6000803e3d6000fd5b5050505061101782858588612512565b50506001609755505050565b60655460ff16156110465760405162461bcd60e51b81526004016107e390613adc565b600160005260d2602052600080516020613dfd8339815191525443101561107f5760405162461bcd60e51b81526004016107e390613aa5565b600260975414156110a25760405162461bcd60e51b81526004016107e390613be3565b60026097556110af612950565b60ce5481106111395760405162461bcd60e51b815260206004820152604a60248201527f446f6e6174696f6e4d696e65723a3a7374616b6552657761726473506172746960448201527f616c3a20546869732072657761726420706572696f642069736e277420636c616064820152691a5b58589b19481e595d60b21b608482015260a4016107e3565b6000611145338361271d565b60ca5460d65460405163095ea7b360e01b81526001600160a01b03918216600482015260248101849052929350169063095ea7b390604401602060405180830381600087803b15801561119757600080fd5b505af11580156111ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111cf9190613828565b5060d6546040516356e4bb9760e11b8152336004820152602481018390526001600160a01b039091169063adc9772e90604401600060405180830381600087803b15801561121c57600080fd5b505af1158015611230573d6000803e3d6000fd5b50506040518381523392507f7d3a0ab251dfd8c04c691239edd99d2c124cce6971cebc4c2ed96a378d13d50091506020015b60405180910390a250506001609755565b6033546001600160a01b0316331461129d5760405162461bcd60e51b81526004016107e390613b06565b60d85460408051918252602082018390527f300b3540c99261403e527f171e281f3dfb0705395e1902af7e9badcddce56e5e910160405180910390a160d855565b6033546001600160a01b031633146113085760405162461bcd60e51b81526004016107e390613b06565b6113126000612a91565b565b6033546001600160a01b0316331461133e5760405162461bcd60e51b81526004016107e390613b06565b60cb546040516001600160a01b038084169216907f4ab5be82436d353e61ca18726e984e561f5c1cc7c6d38b29d2553c790434705a90600090a360cb80546001600160a01b0319166001600160a01b0392909216919091179055565b60ce54600090815260d2602052604081206003015481904311156113fb5760cc5460ce54600090815260d260205260409020600301546113da9043613d5c565b6113e49190613c32565b905060ce54816113f49190613c1a565b905061140d565b600160ce5461140a9190613d5c565b90505b808311156114a95760405162461bcd60e51b815260206004820152605e60248201527f446f6e6174696f6e4d696e65723a3a63616c63756c617465436c61696d61626c60448201527f65526577617264734279506572696f644e756d6265723a20546869732072657760648201527f61726420706572696f642069736e277420617661696c61626c65207965740000608482015260a4016107e3565b60006114b58585612ae3565b5095945050505050565b6033546001600160a01b031633146114e95760405162461bcd60e51b81526004016107e390613b06565b6114f1612950565b60d75460408051918252602082018390527fb7ce19da4d8265c844e0fa744e3429c62104c793f8ecb52d1b418b47eb9f8555910160405180910390a160d755565b6001600090815260d2602052600080516020613dfd8339815191525443101561156d5760405162461bcd60e51b81526004016107e390613aa5565b60655460ff16156115905760405162461bcd60e51b81526004016107e390613adc565b60d654604051631aefa86d60e21b81526001600160a01b0384811660048301526000921690636bbea1b49060240160206040518083038186803b1580156115d657600080fd5b505afa1580156115ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061160e91906139e4565b90508061161e5750600092915050565b8061162a846000612f09565b61163e90694d501c54214bcd300000613d3d565b6116489190613c32565b9392505050565b6033546001600160a01b031633146116795760405162461bcd60e51b81526004016107e390613b06565b60d6546040516001600160a01b038084169216907fcfa056eb826b2a28817aa38ccb94f12ba8a1309598f7ea19bef6fd67fe04b61e90600090a360d680546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b031633146116ff5760405162461bcd60e51b81526004016107e390613b06565b611707612950565b60d55460408051918252602082018390527fd6a28c11ae992e0014e83eaaa6f0023a04c0787848134e8b4e43f44b7d7d8e30910160405180910390a160d555565b60655460ff161561176b5760405162461bcd60e51b81526004016107e390613adc565b600160005260d2602052600080516020613dfd833981519152544310156117a45760405162461bcd60e51b81526004016107e390613aa5565b60d6546001600160a01b031633146117fe5760405162461bcd60e51b815260206004820152601a60248201527f446f6e6174696f6e4d696e65723a204e4f545f5354414b494e4700000000000060448201526064016107e3565b611806612950565b60ce54600090815260d2602090815260408083206001600160a01b0387168452600981018352818420805460ff19166001179055600a810183528184208690556007810185905560d3909252909120600381015415801561186957506001810154155b1561188357600160ce5461187d9190613d5c565b60038201555b5050505050565b6033546001600160a01b031633146118b45760405162461bcd60e51b81526004016107e390613b06565b600260975414156118d75760405162461bcd60e51b81526004016107e390613be3565b60026097556118f06001600160a01b038416838361289a565b816001600160a01b0316836001600160a01b03167f9b035625e569d1d2bf54830a290aefba7ab11610ba8490871dc62b86b63a89568360405161193591815260200190565b60405180910390a35050600160975550565b6001600090815260d2602052600080516020613dfd833981519152544310156119825760405162461bcd60e51b81526004016107e390613aa5565b60655460ff16156119a55760405162461bcd60e51b81526004016107e390613adc565b6109fb826000612f09565b6000806119d08360016119c161097a565b6119cb9190613d5c565b612ae3565b509392505050565b60655460ff16156119fb5760405162461bcd60e51b81526004016107e390613adc565b600160005260d2602052600080516020613dfd83398151915254431015611a345760405162461bcd60e51b81526004016107e390613aa5565b60026097541415611a575760405162461bcd60e51b81526004016107e390613be3565b6002609755611a64612950565b6000611a7933600160ce54610a939190613d5c565b60ca5460d65460405163095ea7b360e01b81526001600160a01b03918216600482015260248101849052929350169063095ea7b390604401602060405180830381600087803b158015611acb57600080fd5b505af1158015611adf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b039190613828565b5060d6546040516356e4bb9760e11b8152336004820152602481018390526001600160a01b039091169063adc9772e90604401600060405180830381600087803b158015611b5057600080fd5b505af1158015611b64573d6000803e3d6000fd5b50506040518381523392507f7d3a0ab251dfd8c04c691239edd99d2c124cce6971cebc4c2ed96a378d13d5009150602001610ae0565b60655460ff1615611bbd5760405162461bcd60e51b81526004016107e390613adc565b600160005260d2602052600080516020613dfd83398151915254431015611bf65760405162461bcd60e51b81526004016107e390613aa5565b60026097541415611c195760405162461bcd60e51b81526004016107e390613be3565b6002609755611c266126d6565b811115611cae5760405162461bcd60e51b815260206004820152604a60248201527f446f6e6174696f6e4d696e65723a3a636c61696d52657761726473506172746960448201527f616c3a20546869732072657761726420706572696f642069736e277420636c616064820152691a5b58589b19481e595d60b21b608482015260a4016107e3565b6000611cba338361271d565b60ca54909150611cd4906001600160a01b0316338361289a565b604080518281526020810184905233917f2233b4bbf378b3d984acd0e36cea96f66bc81012a683e81929ed96df5287ba3d9101611262565b600054610100900460ff16611d275760005460ff1615611d2b565b303b155b611d8e5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016107e3565b600054610100900460ff16158015611db0576000805461ffff19166101011790555b6001600160a01b038916611e1e5760405162461bcd60e51b815260206004820152602f60248201527f446f6e6174696f6e4d696e65723a3a696e697469616c697a653a20635553442060448201526e1859191c995cdcc81b9bdd081cd95d608a1b60648201526084016107e3565b6001600160a01b038816611e8c5760405162461bcd60e51b815260206004820152602f60248201527f446f6e6174696f6e4d696e65723a3a696e697469616c697a653a20504143542060448201526e1859191c995cdcc81b9bdd081cd95d608a1b60648201526084016107e3565b6001600160a01b038716611ef75760405162461bcd60e51b815260206004820152602c60248201527f446f6e6174696f6e4d696e65723a3a696e697469616c697a653a20747265617360448201526b1d5c9e57c81b9bdd081cd95d60a21b60648201526084016107e3565b85611f6a5760405162461bcd60e51b815260206004820152603760248201527f446f6e6174696f6e4d696e65723a3a696e697469616c697a653a20666972737460448201527f526577617264506572426c6f636b206e6f74207365742100000000000000000060648201526084016107e3565b83611fdd5760405162461bcd60e51b815260206004820152603860248201527f446f6e6174696f6e4d696e65723a3a696e697469616c697a653a20737461727460448201527f696e67526577617264506572696f64206e6f742073657421000000000000000060648201526084016107e3565b84611ffa5760405162461bcd60e51b81526004016107e390613b3b565b612002612f62565b61200a612f99565b612012612fd0565b60c980546001600160a01b03808c166001600160a01b03199283161790925560ca80548b841690831617905560cb8054928a169290911691909117905560cc85905560cf83905560d0829055600160ce5561206d8487612fff565b801561207f576000805461ff00191690555b505050505050505050565b6033546001600160a01b031633146120b45760405162461bcd60e51b81526004016107e390613b06565b60d45460408051918252602082018390527f7625e5482008771a414881eb4c957803f2ab46e99e6da60df6e1310f0f009fec910160405180910390a160d455565b6033546001600160a01b0316331461211f5760405162461bcd60e51b81526004016107e390613b06565b8261213c5760405162461bcd60e51b81526004016107e390613b3b565b612144612950565b60cc5460cf5460d05460408051938452602084019290925282820152606082018590526080820184905260a08201839052517f8fb29c6ced5ce51696c08668df816fab7e60c674a6c36e167d5df9b8a5f499849181900360c00190a160cc9290925560cf5560d055565b6001600090815260d2602052600080516020613dfd833981519152544310156121e95760405162461bcd60e51b81526004016107e390613aa5565b60655460ff161561220c5760405162461bcd60e51b81526004016107e390613adc565b600080612219600061244e565b9150600090506122276128cf565b90508060005b61016c8110156122715760d05460cf546122479085613d3d565b6122519190613c32565b925061225d8383613c1a565b91508061226981613db6565b91505061222d565b60d660009054906101000a90046001600160a01b03166001600160a01b0316638c58d0a96040518163ffffffff1660e01b815260040160206040518083038186803b1580156122bf57600080fd5b505afa1580156122d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122f791906139e4565b60d7546123049086613d3d565b61230e9190613c1a565b6123218368056bc75e2d63100000613d3d565b61232b9190613c32565b9550505050505090565b60006109fb82670de0b6b3a7640000613076565b6033546001600160a01b031633146123735760405162461bcd60e51b81526004016107e390613b06565b6001600160a01b0381166123d85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107e3565b6123e181612a91565b50565b6001600090815260d2602052600080516020613dfd8339815191525443101561241f5760405162461bcd60e51b81526004016107e390613aa5565b60655460ff16156124425760405162461bcd60e51b81526004016107e390613adc565b6109fb8260d554612f09565b600080600061245b61097a565b9050600060d554821161246f57600161247c565b60d55461247c9083613d5c565b90508060ce541061249a57612494858260ce546132fa565b90945092505b5050915091565b6040516001600160a01b038085166024830152831660448201526064810182905261250c9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261336f565b50505050565b61251a612950565b60cd805490600061252a83613db6565b909155505060cd54600090815260d16020526040902080546001600160a01b038087166001600160a01b0319928316178355600183018054858316908416811790915543600385015560ce5460028501556005840180548884169416939093179092556006830185905560cb541614156126485760c9546001600160a01b0385811691161461263c5760cb5460405163f2b8995160e01b81526001600160a01b038681166004830152602482018690529091169063f2b899519060440160206040518083038186803b1580156125ff57600080fd5b505afa158015612613573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263791906139e4565b61263e565b825b600482015561265b565b60d8546126559084613c32565b60048201555b61266c60ce54868360040154613441565b6126758561349e565b60cd546004820154604080519182526001600160a01b03878116602084015290820186905280851692908816917f3d2fa2b84d5f2000d605401d563ba60e2e44f62701fdbe9f9101c59b3c215f299060600160405180910390a45050505050565b60006126e0612950565b60d4546126ee906001613c1a565b60ce54116126fc5750600090565b60d454600160ce5461270e9190613d5c565b6127189190613d5c565b905090565b6001600160a01b038216600090815260d36020526040812081806127418686612ae3565b6003850154919350915085111561275a57600383018590555b600085815260d2602090815260408083206001600160a01b038a168452600a01909152902081905581612791575091506109fb9050565b60ca546040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b1580156127d457600080fd5b505afa1580156127e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061280c91906139e4565b8211156128915760ca546040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b15801561285657600080fd5b505afa15801561286a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061288e91906139e4565b91505b50949350505050565b6040516001600160a01b0383166024820152604481018290526128ca90849063a9059cbb60e01b906064016124d5565b505050565b6000806128da61097a565b9050600060ce54826128ec9190613d5c565b60d0546128f99190613c95565b60ce546129069084613d5c565b60cf546129139190613c95565b60ce54600090815260d2602052604090205461292f9190613d3d565b6129399190613c32565b905060cc54816129499190613d3d565b9250505090565b60ce54600090815260d2602052604090205b43816003015410156123e15760ce805490600061297e83613db6565b909155505060ce54600090815260d26020526040902060d554600682015560038201546129ac906001613c1a565b6002820181905560cc546001916129c39190613c1a565b6129cd9190613d5c565b600382015560d05460cf5483546129e49190613d3d565b6129ee9190613c32565b8082556007808401549083015560d754600883015560cc54600091612a1291613d3d565b905060008360060154600160ce54612a2a9190613d5c565b11612a36576001612a54565b8360060154600160ce54612a4a9190613d5c565b612a549190613d5c565b9050612a6e81600160ce54612a699190613d5c565b613537565b612a84576001840154612a819083613c1a565b91505b5060018201559050612962565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216600090815260d36020526040812060038101548291908290612b10906001613c1a565b90508060011415612b3c5781546000908152600283016020526040902054612b39906001613c1a565b90505b60d26020819052600082815260408120818052909182918291829182917f20791b593a776a2631a28f4a3f62a14ad18db22add38130c4f4a8fdfa46398859190829084612b8a60018c613d5c565b8152602001908152602001600020600a0160008f6001600160a01b03166001600160a01b03168152602001908152602001600020549a505b8c8911612ef857600282015415612d53576006820154612c06576001600160a01b038e16600090815260058301602052604090205460048301549098509650612d25565b816006015483600601541415612ce3576006820154612c26906001613c1a565b891115612ca55760d26000836006015460018c612c439190613d5c565b612c4d9190613d5c565b815260200190815260200160002090508060050160008f6001600160a01b03166001600160a01b031681526020019081526020016000205488612c909190613d5c565b9750806004015487612ca29190613d5c565b96505b6001600160a01b038e166000908152600583016020526040902054612cca9089613c1a565b9750816004015487612cdc9190613c1a565b9650612d25565b8160060154891115612d1357612d098e83600601548b612d039190613d5c565b8b6132fa565b9098509650612d25565b612d1f8e60008b6132fa565b90985096505b81600101549550816007015494506000826008015411612d46576001612d4c565b81600801545b9350612e35565b60d554612d61906001613c1a565b891115612dde5760d2600060d55460018c612d7c9190613d5c565b612d869190613d5c565b815260200190815260200160002090508060050160008f6001600160a01b03166001600160a01b031681526020019081526020016000205488612dc99190613d5c565b9750806004015487612ddb9190613d5c565b96505b6001600160a01b038e166000908152600583016020526040902054612e039089613c1a565b9750816004015487612e159190613c1a565b965060d05460cf5487612e289190613d3d565b612e329190613c32565b95505b6001600160a01b038e16600090815260098301602052604090205460ff1615612e76576001600160a01b038e166000908152600a830160205260409020549a505b6000612e828c8a613c1a565b1115612ed35784612e938589613d3d565b612e9d9190613c1a565b8b612ea8868b613d3d565b612eb29190613c1a565b612ebc9088613d3d565b612ec69190613c32565b612ed0908d613c1a565b9b505b88612edd81613db6565b600081815260d260205260409020909a50929350612bc29050565b505050505050505050509250929050565b600080612f146128cf565b9050805b8315612f585760d05460cf54612f2e9084613d3d565b612f389190613c32565b9150612f448282613c1a565b905083612f5081613d9f565b945050612f18565b610c998582613076565b600054610100900460ff16612f895760405162461bcd60e51b81526004016107e390613b98565b612f9161358d565b6113126135b4565b600054610100900460ff16612fc05760405162461bcd60e51b81526004016107e390613b98565b612fc861358d565b6113126135e4565b600054610100900460ff16612ff75760405162461bcd60e51b81526004016107e390613b98565b611312613617565b6001600081905260d2602052600080516020613dfd83398151915283905560cc547fb7404ce2b5a52e61a6b5c9b4585ed65d8cb4b8848d3ee262a356d0c2c46c5f35919061304d9085613c1a565b6130579190613d5c565b600382015581815560cc5461306c9083613d3d565b6001909101555050565b60008060006130848561244e565b60d654604080516319e815f960e01b815290519395509193506000926001600160a01b03909116916319e815f9916004808301926020929190829003018186803b1580156130d157600080fd5b505afa1580156130e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131099190613848565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561314157600080fd5b505afa158015613155573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061317991906139e4565b905080158015613187575081155b1561319857600093505050506109fb565b60008060d754116131aa5760016131ae565b60d7545b905060d660009054906101000a90046001600160a01b03166001600160a01b0316638c58d0a96040518163ffffffff1660e01b815260040160206040518083038186803b1580156131fe57600080fd5b505afa158015613212573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061323691906139e4565b6132408285613d3d565b61324a9190613c1a565b60d654604051631aefa86d60e21b81526001600160a01b038a8116600483015290911690636bbea1b49060240160206040518083038186803b15801561328f57600080fd5b505afa1580156132a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132c791906139e4565b6132d18387613d3d565b6132db9190613c1a565b6132e59088613d3d565b6132ef9190613c32565b979650505050505050565b6000808080855b85811161336257600081815260d2602090815260408083206001600160a01b038c168452600581019092529091205461333a9085613c1a565b935080600401548361334c9190613c1a565b925050808061335a90613db6565b915050613301565b5090969095509350505050565b60006133c4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166136459092919063ffffffff16565b8051909150156128ca57808060200190518101906133e29190613828565b6128ca5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016107e3565b600083815260d26020526040812060048101805491928492613464908490613c1a565b90915550506001600160a01b038316600090815260058201602052604081208054849290613493908490613c1a565b909155505050505050565b6001600160a01b038116600090815260d36020908152604080832060018101548452600281019092529091205460ce548114613505576001820180549060006134e683613db6565b909155505060ce54600183015460009081526002840160205260409020555b600382015415801561351957506001820154155b156128ca57600160ce5461352d9190613d5c565b6003830155505050565b60005b81831161358457600083815260d26020526040812060078101546004909101546135649190613c1a565b1115613572575060016109fb565b8261357c81613db6565b93505061353a565b50600092915050565b600054610100900460ff166113125760405162461bcd60e51b81526004016107e390613b98565b600054610100900460ff166135db5760405162461bcd60e51b81526004016107e390613b98565b61131233612a91565b600054610100900460ff1661360b5760405162461bcd60e51b81526004016107e390613b98565b6065805460ff19169055565b600054610100900460ff1661363e5760405162461bcd60e51b81526004016107e390613b98565b6001609755565b6060613654848460008561365c565b949350505050565b6060824710156136bd5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016107e3565b843b61370b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107e3565b600080866001600160a01b031685876040516137279190613a56565b60006040518083038185875af1925050503d8060008114613764576040519150601f19603f3d011682016040523d82523d6000602084013e613769565b606091505b50915091506132ef82828660608315613783575081611648565b8251156137935782518084602001fd5b8160405162461bcd60e51b81526004016107e39190613a72565b6000602082840312156137be578081fd5b813561164881613de7565b600080604083850312156137db578081fd5b82356137e681613de7565b946020939093013593505050565b600080600060608486031215613808578081fd5b833561381381613de7565b95602085013595506040909401359392505050565b600060208284031215613839578081fd5b81518015158114611648578182fd5b600060208284031215613859578081fd5b815161164881613de7565b60008060008060808587031215613879578081fd5b843561388481613de7565b9350602085013561389481613de7565b92506040850135915060608501356138ab81613de7565b939692955090935050565b6000806000606084860312156138ca578283fd5b83356138d581613de7565b925060208401356138e581613de7565b929592945050506040919091013590565b600080600080600080600080610100898b031215613912578384fd5b883561391d81613de7565b9750602089013561392d81613de7565b9650604089013561393d81613de7565b979a96995096976060810135975060808101359660a0820135965060c0820135955060e0909101359350915050565b600080600060608486031215613980578283fd5b833561398b81613de7565b92506020840135915060408401356139a281613de7565b809150509250925092565b6000602082840312156139be578081fd5b815160048110611648578182fd5b6000602082840312156139dd578081fd5b5035919050565b6000602082840312156139f5578081fd5b5051919050565b60008060408385031215613a0e578182fd5b823591506020830135613a2081613de7565b809150509250929050565b600080600060608486031215613a3f578081fd5b505081359360208301359350604090920135919050565b60008251613a68818460208701613d73565b9190910192915050565b6020815260008251806020840152613a91816040850160208701613d73565b601f01601f19169190910160400192915050565b6020808252601e908201527f446f6e6174696f6e4d696e65723a204552525f4e4f545f535441525445440000604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526037908201527f446f6e6174696f6e4d696e65723a3a696e697469616c697a653a20726577617260408201527f64506572696f6453697a6520697320696e76616c696421000000000000000000606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115613c2d57613c2d613dd1565b500190565b600082613c4d57634e487b7160e01b81526012600452602481fd5b500490565b600181815b80851115613c8d578160001904821115613c7357613c73613dd1565b80851615613c8057918102915b93841c9390800290613c57565b509250929050565b60006116488383600082613cab575060016109fb565b81613cb8575060006109fb565b8160018114613cce5760028114613cd857613cf4565b60019150506109fb565b60ff841115613ce957613ce9613dd1565b50506001821b6109fb565b5060208310610133831016604e8410600b8410161715613d17575081810a6109fb565b613d218383613c52565b8060001904821115613d3557613d35613dd1565b029392505050565b6000816000190483118215151615613d5757613d57613dd1565b500290565b600082821015613d6e57613d6e613dd1565b500390565b60005b83811015613d8e578181015183820152602001613d76565b8381111561250c5750506000910152565b600081613dae57613dae613dd1565b506000190190565b6000600019821415613dca57613dca613dd1565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b03811681146123e157600080fdfeb7404ce2b5a52e61a6b5c9b4585ed65d8cb4b8848d3ee262a356d0c2c46c5f37a2646970667358221220b3c6bc9de5d3dbdc8e396416dc80a33a577de2bf5c209de702a65de9f3b9070b64736f6c63430008040033