false
true
0

Contract Address Details

0xD34f5ADC24d8Cc55C1e832Bdf65fFfDF80D1314f

Token
Vouch (VOUCH)
Creator
0xeb59b0–dcef7f at 0xdbf2b1–c5ad37
Balance
0 PLS ( )
Tokens
Fetching tokens...
Transactions
2,057 Transactions
Transfers
0 Transfers
Gas Used
0
Last Balance Update
26059620
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
Vouch




Optimization enabled
true
Compiler version
v0.8.20+commit.a1b79de6




Optimization runs
200
EVM Version
paris




Verified at
2025-08-15T06:10:13.999529Z

Constructor Arguments

0x00000000000000000000000054da21340773fecaf9a5bad0883a7fc594945d0a00000000000000000000000098bf93ebf5c380c0e6ae8e192a7e2ae08edacc02000000000000000000000000165c3410fc91ef562c50559f7d2289febed552d9000000000000000000000000eb45a3c4aedd0f47f345fb4c8a1802bb5740d725

Arg [0] (address) : 0x54da21340773fecaf9a5bad0883a7fc594945d0a
Arg [1] (address) : 0x98bf93ebf5c380c0e6ae8e192a7e2ae08edacc02
Arg [2] (address) : 0x165c3410fc91ef562c50559f7d2289febed552d9
Arg [3] (address) : 0xeb45a3c4aedd0f47f345fb4c8a1802bb5740d725

              

contracts/Vouch.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "./Utilities.sol";
import "./DaoDistributor.sol";
import {ValidatorFeeDepositor} from "./ValidatorFeeDepositor.sol";

contract Vouch is ERC20, ERC20Permit, ERC20Votes {
    uint256 public constant initialSupply = 100_000_000_000e18;

    uint256 public _maxTxAmount = initialSupply;

    uint256 public totalBuyFee = 500;
    uint256 public totalSellFee = 500;
    uint256 public feeDenominator = 10000; // 10k = 100%
    uint256 public swapThresholdDenominator = 1e18; // using 1e18 as the denominator for percentage calculations
    uint256 public swapThresholdPercent = 200000000000000; // 0.02%
    bool public feesOnNormalTransfers = true;

    address public wplsAddress = 0xA1077a294dDE1B09bB078844df40758a5D0f9a27;
    address public deadAddress = 0x000000000000000000000000000000000000dEaD;
    address public zeroAddress = address(0);

    IDEXRouter public pulseRouterV1;
    IDEXRouter public pulseRouterV2;
    IDEXRouter public nineinchRouter;

    address public pulseV1Pair;
    address public pulseV2Pair;
    address public nineinchPair;
    address[] public pairs;

    uint256 public launchedAt;
    DaoDistributor public distributor;

    bool public swapEnabled = true;
    uint256 public swapThreshold;
    bool inSwap;

    address airDropper = 0xD20a9202d2A69CB0E6d240E6DdA7257D4baE39eC;

    INetworkProposal public networkProposal = INetworkProposal(0x7783D7040423f75aeF82a3Ec32ed366ca460Fa6c);

    mapping(address => bool) public isFeeExempt;
    mapping(address => bool) public isTxLimitExempt;
    mapping(address => bool) public isDividendExempt;
    mapping(address => bool) public basicTransfer;
    mapping(address => bool) public antiSwapback;

    event Launched(uint256 blockNumber, uint256 timestamp);
    event ParameterUpdated();
    event SwapBackSuccess(uint256 amount);
    event SwapBackFailed(string message);
    event ValidatorFeeDepositorFailed();
    event SetShareFailed(address holder);
    event ProcessVouchFailed();
    event ProcessVplsFailed();
    event ProcessPlsFailed();

    modifier onlyAdmin() {
        require(
            networkProposal.isAdmin(msg.sender),
            "Caller must be admin"
        );
        _;
    }

    modifier swapping() {
        inSwap = true;
        _;
        inSwap = false;
    }

    constructor(
        address _distributorAddress,
        address _pulseRouterV1,
        address _pulseRouterV2,
        address _nineinchRouter
    )
        ERC20("Vouch", "VOUCH")
        ERC20Permit("Vouch")
    {
        distributor = DaoDistributor(payable(_distributorAddress));

        pulseRouterV1 = _pulseRouterV1 != address(0)
            ? IDEXRouter(_pulseRouterV1)
            : IDEXRouter(0x98bf93ebf5c380C0e6Ae8e192A7e2AE08edAcc02);
        pulseRouterV2 = _pulseRouterV2 != address(0)
            ? IDEXRouter(_pulseRouterV2)
            : IDEXRouter(0x165C3410fC91EF562C50559f7d2289fEbed552d9);
        nineinchRouter = _nineinchRouter != address(0)
            ? IDEXRouter(_nineinchRouter)
            : IDEXRouter(0xeB45a3c4aedd0F47F345fB4c8A1802BB5740d725);

        pulseV1Pair = IDEXFactory(pulseRouterV1.factory()).getPair(wplsAddress, address(this));
        if (pulseV1Pair == address(0)) {
            pulseV1Pair = IDEXFactory(pulseRouterV1.factory()).createPair(wplsAddress, address(this));
        }
        pairs.push(pulseV1Pair);

        pulseV2Pair = IDEXFactory(pulseRouterV2.factory()).getPair(wplsAddress, address(this));
        if (pulseV2Pair == address(0)) {
            pulseV2Pair = IDEXFactory(pulseRouterV2.factory()).createPair(wplsAddress, address(this));
        }
        pairs.push(pulseV2Pair);

        nineinchPair = IDEXFactory(nineinchRouter.factory()).getPair(wplsAddress, address(this));
        if (nineinchPair == address(0)) {
            nineinchPair = IDEXFactory(nineinchRouter.factory()).createPair(wplsAddress, address(this));
        }
        pairs.push(nineinchPair);

        _approve(address(this), address(pulseRouterV1), type(uint256).max);
        _approve(address(this), address(pulseRouterV2), type(uint256).max);
        _approve(address(this), address(nineinchRouter), type(uint256).max);

        isFeeExempt[address(distributor.liquidityManager())] = true;
        isFeeExempt[address(this)] = true;
        isFeeExempt[address(distributor)] = true;
        isTxLimitExempt[address(this)] = true;
        isTxLimitExempt[address(distributor)] = true;
        isTxLimitExempt[address(distributor.liquidityManager())] = true;

        isDividendExempt[pulseV1Pair] = true;
        isDividendExempt[pulseV2Pair] = true;
        isDividendExempt[nineinchPair] = true;
        isDividendExempt[address(distributor)] = true;
        isDividendExempt[address(distributor.liquidityManager())] = true;
        isDividendExempt[deadAddress] = true;
        isDividendExempt[address(this)] = true;

        _mint(address(networkProposal.admin()), initialSupply);
        swapThreshold = totalSupply() * swapThresholdPercent / swapThresholdDenominator;
    }

    receive() external payable {}

    function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal override {
        require(
            launchedAt > 0 || admin(tx.origin) || tx.origin == airDropper,
            "The contract is not launched yet"
        );

        if (inSwap || 
            sender == address(distributor.liquidityManager()) ||
            recipient == address(distributor.liquidityManager()) ||
            checkBasicTransfer(sender, recipient)) {
            super._transfer(sender, recipient, amount);
            return;
        }

        checkTxLimit(sender, recipient, amount);

        if (shouldSwapBack(sender, recipient)) {
            swapBack();
        } else {
            try ValidatorFeeDepositor(distributor.validatorFeeDepositor()).depositToDistributor() {} catch { emit ValidatorFeeDepositorFailed(); }
        }

        uint256 feeAmount = 0;
        if (shouldTakeFee(sender, recipient)) {
            feeAmount = amount * getTotalFee(isSell(recipient)) / feeDenominator;
        }
        uint256 amountReceived = amount - feeAmount;

        super._transfer(sender, recipient, amountReceived);
        if (feeAmount > 0) {
            super._transfer(sender, address(this), feeAmount);
        }

        if (!isDividendExempt[sender]) {
            try distributor.setShare(sender, balanceOf(sender)) {} catch { emit SetShareFailed(sender); }
        }
        if (!isDividendExempt[recipient]) {
            try distributor.setShare(recipient, balanceOf(recipient)) {} catch { emit SetShareFailed(recipient); }
        }

        try distributor.processVouch(distributor.vouchGas()) {} catch { emit ProcessVouchFailed(); }
        try distributor.processVpls(distributor.vplsGas()) {} catch { emit ProcessVplsFailed(); }
        try distributor.processPls(distributor.plsGas()) {} catch { emit ProcessPlsFailed(); }
    }

    function burn(uint256 amount) external {
        _burn(msg.sender, amount);
        swapThreshold = totalSupply() * swapThresholdPercent / swapThresholdDenominator;
    }

    function checkTxLimit(
        address sender,
        address recipient,
        uint256 amount
    ) internal view {
        require(
            amount <= _maxTxAmount ||
                isTxLimitExempt[sender] ||
                isTxLimitExempt[recipient],
            "TX Limit Exceeded"
        );
    }

    function shouldTakeFee(address sender, address recipient) internal view returns (bool) {
        if (isFeeExempt[sender] || isFeeExempt[recipient] || launchedAt == 0)
            return false;

        for (uint256 i = 0; i < pairs.length; i++) {
            if (sender == pairs[i] || recipient == pairs[i]) return true;
        }
        return feesOnNormalTransfers;
    }

    function getTotalFee(bool selling) public view returns (uint256) {
        if (launchedAt == 0) {
            return feeDenominator - 1;
        }
        return selling ? totalSellFee : totalBuyFee;
    }

    function isSell(address recipient) internal view returns (bool) {
        for (uint256 i = 0; i < pairs.length; i++) {
            if (recipient == pairs[i]) return true;
        }
        return false;
    }

    function shouldSwapBack(address sender, address recipient) internal view returns (bool) {
        for (uint256 i = 0; i < pairs.length; i++) {
            if (sender == pairs[i]) return false;
        }
        return
            !inSwap &&
            !distributor.distributionLock() &&
            swapEnabled &&
            balanceOf(address(this)) >= swapThreshold &&
            sender != address(distributor) &&
            recipient != address(distributor) &&
            sender != address(distributor.voters()) &&
            recipient != address(distributor.voters()) &&
            antiSwapback[recipient] == false &&
            antiSwapback[sender] == false;
    }

    function checkBasicTransfer(address sender, address recipient) internal view returns (bool) {
        if (basicTransfer[sender] || basicTransfer[recipient]) {
            return true;
        } else {
            return false;
        }
    }

    function swapBack() internal swapping {
        address[] memory path = new address[](2);
        path[0] = address(this);
        path[1] = wplsAddress;

        IDEXRouter router = IDEXRouter(Utilities.getBestRouter(swapThreshold, path));

        try
            router.swapExactTokensForETHSupportingFeeOnTransferTokens(
                swapThreshold,
                0,
                path,
                address(this),
                block.timestamp
            )
        {
            distributor.depositFromVouch{value: address(this).balance}();
            emit SwapBackSuccess(swapThreshold);
        } catch Error(string memory e) {
            emit SwapBackFailed(string(abi.encodePacked("SwapBack failed with error ", e)));
        } catch {
            emit SwapBackFailed("SwapBack failed without an error message from the dex");
        }
    }

    function launch() external onlyAdmin {
        require(launchedAt == 0, "Already launched.");
        launchedAt = block.timestamp;
        emit Launched(block.number, block.timestamp);
    }

    function admin(address sender) internal view returns (bool) {
        return networkProposal.isAdmin(sender);
    }

    function setBasicTransferAddress(address _basicTransferAddress, bool flag) external onlyAdmin {
        basicTransfer[_basicTransferAddress] = flag;
    }

    function setAntiSwapbackAddress(address _antiSwapbackAddress, bool flag) external onlyAdmin {
        antiSwapback[_antiSwapbackAddress] = flag;
    }

    function setDistributor(address _distributor) external onlyAdmin {
        require(_distributor != address(0), "Invalid address");
        distributor = DaoDistributor(payable(_distributor));
    }

    function setTxLimit(uint256 amount) external onlyAdmin {
        require(amount >= totalSupply() / 2000, "TX limit too low");
        _maxTxAmount = amount;
    }

    function setIsDividendExempt(address holder, bool exempt) external onlyAdmin {
        require(holder != address(this) && holder != pulseV2Pair, "Invalid address");
        isDividendExempt[holder] = exempt;
        if (exempt) {
            distributor.setShare(holder, 0);
        } else {
            distributor.setShare(holder, balanceOf(holder));
        }
    }

    function setIsFeeExempt(address holder, bool exempt) external onlyAdmin {
        isFeeExempt[holder] = exempt;
    }

    function setIsTxLimitExempt(address holder, bool exempt) external onlyAdmin {
        isTxLimitExempt[holder] = exempt;
    }

    function setFees(
        uint256 _totalBuyFee,
        uint256 _totalSellFee,
        bool _feesOnNormalTransfers
    ) external onlyAdmin {
        totalBuyFee = _totalBuyFee;
        totalSellFee = _totalSellFee;
        require(totalBuyFee <= 1000, "Buy fee has a 10 percent max.");
        require(totalSellFee <= 1000, "Sell fee has a 10 percent max.");
        feesOnNormalTransfers = _feesOnNormalTransfers;
        emit ParameterUpdated();
    }

    function setSwapBackSettings(bool _enabled, uint256 _percent) external onlyAdmin {
        swapEnabled = _enabled;
        swapThresholdPercent = _percent;
        swapThreshold = totalSupply() * swapThresholdPercent / swapThresholdDenominator;
        emit ParameterUpdated();
    }

    function addPair(address pair) external onlyAdmin {
        pairs.push(pair);
        emit ParameterUpdated();
    }

    function removeLastPair() external onlyAdmin {
        pairs.pop();
        emit ParameterUpdated();
    }

    function removePair(address pair) external onlyAdmin {
        uint256 len = pairs.length;
        require(len > 0, "No pairs");

        uint256 index = len;
        for (uint256 i = 0; i < len; i++) {
            if (pairs[i] == pair) {
                index = i;
                break;
            }
        }

        require(index < len, "Pair not found");

        if (index != len - 1) {
            pairs[index] = pairs[len - 1];
        }
        pairs.pop();
        emit ParameterUpdated();
    }

    function getAllPairs() public view returns (address[] memory) {
        return pairs;
    }

    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal override(ERC20, ERC20Votes) {
        super._afterTokenTransfer(from, to, amount);
    }

    function _mint(address to, uint256 amount)
        internal override(ERC20, ERC20Votes)
    {
        super._mint(to, amount);
    }

    function _burn(address account, uint256 amount)
        internal override(ERC20, ERC20Votes)
    {
        super._burn(account, amount);
    }

    function nonces(address owner)
        public view override(ERC20Permit) returns (uint256)
    {
        return super.nonces(owner);
    }

    function clock() public view override returns (uint48) {
        return uint48(block.timestamp);
    }

    function CLOCK_MODE() public pure override returns (string memory) {
        return "mode=timestamp";
    }
}
        

@openzeppelin/contracts/governance/utils/IVotes.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (governance/utils/IVotes.sol)
pragma solidity ^0.8.0;

/**
 * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.
 *
 * _Available since v4.5._
 */
interface IVotes {
    /**
     * @dev Emitted when an account changes their delegate.
     */
    event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);

    /**
     * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.
     */
    event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);

    /**
     * @dev Returns the current amount of votes that `account` has.
     */
    function getVotes(address account) external view returns (uint256);

    /**
     * @dev Returns the amount of votes that `account` had at a specific moment in the past. If the `clock()` is
     * configured to use block numbers, this will return the value at the end of the corresponding block.
     */
    function getPastVotes(address account, uint256 timepoint) external view returns (uint256);

    /**
     * @dev Returns the total supply of votes available at a specific moment in the past. If the `clock()` is
     * configured to use block numbers, this will return the value at the end of the corresponding block.
     *
     * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.
     * Votes that have not been delegated are still part of total supply, even though they would not participate in a
     * vote.
     */
    function getPastTotalSupply(uint256 timepoint) external view returns (uint256);

    /**
     * @dev Returns the delegate that `account` has chosen.
     */
    function delegates(address account) external view returns (address);

    /**
     * @dev Delegates votes from the sender to `delegatee`.
     */
    function delegate(address delegatee) external;

    /**
     * @dev Delegates votes from signer to `delegatee`.
     */
    function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external;
}
          

@openzeppelin/contracts/interfaces/IERC5267.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5267.sol)

pragma solidity ^0.8.0;

interface IERC5267 {
    /**
     * @dev MAY be emitted to signal that the domain could have changed.
     */
    event EIP712DomainChanged();

    /**
     * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
     * signature.
     */
    function eip712Domain()
        external
        view
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        );
}
          

@openzeppelin/contracts/interfaces/IERC5805.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5805.sol)

pragma solidity ^0.8.0;

import "../governance/utils/IVotes.sol";
import "./IERC6372.sol";

interface IERC5805 is IERC6372, IVotes {}
          

@openzeppelin/contracts/interfaces/IERC6372.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC6372.sol)

pragma solidity ^0.8.0;

interface IERC6372 {
    /**
     * @dev Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).
     */
    function clock() external view returns (uint48);

    /**
     * @dev Description of the clock
     */
    // solhint-disable-next-line func-name-mixedcase
    function CLOCK_MODE() external view returns (string memory);
}
          

@openzeppelin/contracts/security/ReentrancyGuard.sol

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

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

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

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

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

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}
          

@openzeppelin/contracts/token/ERC20/ERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the default value returned by this function, unless
     * it's overridden.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, allowance(owner, spender) + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        address owner = _msgSender();
        uint256 currentAllowance = allowance(owner, spender);
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(address from, address to, uint256 amount) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
            // decrementing then incrementing.
            _balances[to] += amount;
        }

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        unchecked {
            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
            _balances[account] += amount;
        }
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
            // Overflow not possible: amount <= accountBalance <= totalSupply.
            _totalSupply -= amount;
        }

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}
          

@openzeppelin/contracts/token/ERC20/IERC20.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/ERC20Permit.sol)

pragma solidity ^0.8.0;

import "./IERC20Permit.sol";
import "../ERC20.sol";
import "../../../utils/cryptography/ECDSA.sol";
import "../../../utils/cryptography/EIP712.sol";
import "../../../utils/Counters.sol";

/**
 * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * _Available since v3.4._
 */
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
    using Counters for Counters.Counter;

    mapping(address => Counters.Counter) private _nonces;

    // solhint-disable-next-line var-name-mixedcase
    bytes32 private constant _PERMIT_TYPEHASH =
        keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
    /**
     * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.
     * However, to ensure consistency with the upgradeable transpiler, we will continue
     * to reserve a slot.
     * @custom:oz-renamed-from _PERMIT_TYPEHASH
     */
    // solhint-disable-next-line var-name-mixedcase
    bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;

    /**
     * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
     *
     * It's a good idea to use the same `name` that is defined as the ERC20 token name.
     */
    constructor(string memory name) EIP712(name, "1") {}

    /**
     * @inheritdoc IERC20Permit
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual override {
        require(block.timestamp <= deadline, "ERC20Permit: expired deadline");

        bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));

        bytes32 hash = _hashTypedDataV4(structHash);

        address signer = ECDSA.recover(hash, v, r, s);
        require(signer == owner, "ERC20Permit: invalid signature");

        _approve(owner, spender, value);
    }

    /**
     * @inheritdoc IERC20Permit
     */
    function nonces(address owner) public view virtual override returns (uint256) {
        return _nonces[owner].current();
    }

    /**
     * @inheritdoc IERC20Permit
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view override returns (bytes32) {
        return _domainSeparatorV4();
    }

    /**
     * @dev "Consume a nonce": return the current value and increment.
     *
     * _Available since v4.1._
     */
    function _useNonce(address owner) internal virtual returns (uint256 current) {
        Counters.Counter storage nonce = _nonces[owner];
        current = nonce.current();
        nonce.increment();
    }
}
          

@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/ERC20Votes.sol)

pragma solidity ^0.8.0;

import "./ERC20Permit.sol";
import "../../../interfaces/IERC5805.sol";
import "../../../utils/math/Math.sol";
import "../../../utils/math/SafeCast.sol";
import "../../../utils/cryptography/ECDSA.sol";

/**
 * @dev Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's,
 * and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1.
 *
 * NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module.
 *
 * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either
 * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting
 * power can be queried through the public accessors {getVotes} and {getPastVotes}.
 *
 * By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it
 * requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked.
 *
 * _Available since v4.2._
 */
abstract contract ERC20Votes is ERC20Permit, IERC5805 {
    struct Checkpoint {
        uint32 fromBlock;
        uint224 votes;
    }

    bytes32 private constant _DELEGATION_TYPEHASH =
        keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");

    mapping(address => address) private _delegates;
    mapping(address => Checkpoint[]) private _checkpoints;
    Checkpoint[] private _totalSupplyCheckpoints;

    /**
     * @dev Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).
     */
    function clock() public view virtual override returns (uint48) {
        return SafeCast.toUint48(block.number);
    }

    /**
     * @dev Description of the clock
     */
    // solhint-disable-next-line func-name-mixedcase
    function CLOCK_MODE() public view virtual override returns (string memory) {
        // Check that the clock was not modified
        require(clock() == block.number, "ERC20Votes: broken clock mode");
        return "mode=blocknumber&from=default";
    }

    /**
     * @dev Get the `pos`-th checkpoint for `account`.
     */
    function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory) {
        return _checkpoints[account][pos];
    }

    /**
     * @dev Get number of checkpoints for `account`.
     */
    function numCheckpoints(address account) public view virtual returns (uint32) {
        return SafeCast.toUint32(_checkpoints[account].length);
    }

    /**
     * @dev Get the address `account` is currently delegating to.
     */
    function delegates(address account) public view virtual override returns (address) {
        return _delegates[account];
    }

    /**
     * @dev Gets the current votes balance for `account`
     */
    function getVotes(address account) public view virtual override returns (uint256) {
        uint256 pos = _checkpoints[account].length;
        unchecked {
            return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes;
        }
    }

    /**
     * @dev Retrieve the number of votes for `account` at the end of `timepoint`.
     *
     * Requirements:
     *
     * - `timepoint` must be in the past
     */
    function getPastVotes(address account, uint256 timepoint) public view virtual override returns (uint256) {
        require(timepoint < clock(), "ERC20Votes: future lookup");
        return _checkpointsLookup(_checkpoints[account], timepoint);
    }

    /**
     * @dev Retrieve the `totalSupply` at the end of `timepoint`. Note, this value is the sum of all balances.
     * It is NOT the sum of all the delegated votes!
     *
     * Requirements:
     *
     * - `timepoint` must be in the past
     */
    function getPastTotalSupply(uint256 timepoint) public view virtual override returns (uint256) {
        require(timepoint < clock(), "ERC20Votes: future lookup");
        return _checkpointsLookup(_totalSupplyCheckpoints, timepoint);
    }

    /**
     * @dev Lookup a value in a list of (sorted) checkpoints.
     */
    function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 timepoint) private view returns (uint256) {
        // We run a binary search to look for the last (most recent) checkpoint taken before (or at) `timepoint`.
        //
        // Initially we check if the block is recent to narrow the search range.
        // During the loop, the index of the wanted checkpoint remains in the range [low-1, high).
        // With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant.
        // - If the middle checkpoint is after `timepoint`, we look in [low, mid)
        // - If the middle checkpoint is before or equal to `timepoint`, we look in [mid+1, high)
        // Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not
        // out of bounds (in which case we're looking too far in the past and the result is 0).
        // Note that if the latest checkpoint available is exactly for `timepoint`, we end up with an index that is
        // past the end of the array, so we technically don't find a checkpoint after `timepoint`, but it works out
        // the same.
        uint256 length = ckpts.length;

        uint256 low = 0;
        uint256 high = length;

        if (length > 5) {
            uint256 mid = length - Math.sqrt(length);
            if (_unsafeAccess(ckpts, mid).fromBlock > timepoint) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }

        while (low < high) {
            uint256 mid = Math.average(low, high);
            if (_unsafeAccess(ckpts, mid).fromBlock > timepoint) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }

        unchecked {
            return high == 0 ? 0 : _unsafeAccess(ckpts, high - 1).votes;
        }
    }

    /**
     * @dev Delegate votes from the sender to `delegatee`.
     */
    function delegate(address delegatee) public virtual override {
        _delegate(_msgSender(), delegatee);
    }

    /**
     * @dev Delegates votes from signer to `delegatee`
     */
    function delegateBySig(
        address delegatee,
        uint256 nonce,
        uint256 expiry,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual override {
        require(block.timestamp <= expiry, "ERC20Votes: signature expired");
        address signer = ECDSA.recover(
            _hashTypedDataV4(keccak256(abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry))),
            v,
            r,
            s
        );
        require(nonce == _useNonce(signer), "ERC20Votes: invalid nonce");
        _delegate(signer, delegatee);
    }

    /**
     * @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1).
     */
    function _maxSupply() internal view virtual returns (uint224) {
        return type(uint224).max;
    }

    /**
     * @dev Snapshots the totalSupply after it has been increased.
     */
    function _mint(address account, uint256 amount) internal virtual override {
        super._mint(account, amount);
        require(totalSupply() <= _maxSupply(), "ERC20Votes: total supply risks overflowing votes");

        _writeCheckpoint(_totalSupplyCheckpoints, _add, amount);
    }

    /**
     * @dev Snapshots the totalSupply after it has been decreased.
     */
    function _burn(address account, uint256 amount) internal virtual override {
        super._burn(account, amount);

        _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);
    }

    /**
     * @dev Move voting power when tokens are transferred.
     *
     * Emits a {IVotes-DelegateVotesChanged} event.
     */
    function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual override {
        super._afterTokenTransfer(from, to, amount);

        _moveVotingPower(delegates(from), delegates(to), amount);
    }

    /**
     * @dev Change delegation for `delegator` to `delegatee`.
     *
     * Emits events {IVotes-DelegateChanged} and {IVotes-DelegateVotesChanged}.
     */
    function _delegate(address delegator, address delegatee) internal virtual {
        address currentDelegate = delegates(delegator);
        uint256 delegatorBalance = balanceOf(delegator);
        _delegates[delegator] = delegatee;

        emit DelegateChanged(delegator, currentDelegate, delegatee);

        _moveVotingPower(currentDelegate, delegatee, delegatorBalance);
    }

    function _moveVotingPower(address src, address dst, uint256 amount) private {
        if (src != dst && amount > 0) {
            if (src != address(0)) {
                (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount);
                emit DelegateVotesChanged(src, oldWeight, newWeight);
            }

            if (dst != address(0)) {
                (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount);
                emit DelegateVotesChanged(dst, oldWeight, newWeight);
            }
        }
    }

    function _writeCheckpoint(
        Checkpoint[] storage ckpts,
        function(uint256, uint256) view returns (uint256) op,
        uint256 delta
    ) private returns (uint256 oldWeight, uint256 newWeight) {
        uint256 pos = ckpts.length;

        unchecked {
            Checkpoint memory oldCkpt = pos == 0 ? Checkpoint(0, 0) : _unsafeAccess(ckpts, pos - 1);

            oldWeight = oldCkpt.votes;
            newWeight = op(oldWeight, delta);

            if (pos > 0 && oldCkpt.fromBlock == clock()) {
                _unsafeAccess(ckpts, pos - 1).votes = SafeCast.toUint224(newWeight);
            } else {
                ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(clock()), votes: SafeCast.toUint224(newWeight)}));
            }
        }
    }

    function _add(uint256 a, uint256 b) private pure returns (uint256) {
        return a + b;
    }

    function _subtract(uint256 a, uint256 b) private pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
     */
    function _unsafeAccess(Checkpoint[] storage ckpts, uint256 pos) private pure returns (Checkpoint storage result) {
        assembly {
            mstore(0, ckpts.slot)
            result.slot := add(keccak256(0, 0x20), pos)
        }
    }
}
          

@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol

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

pragma solidity ^0.8.0;

import "../IERC20.sol";

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

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

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

@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

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

@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol

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

pragma solidity ^0.8.0;

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

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

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    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));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    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");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}
          

@openzeppelin/contracts/utils/Address.sol

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/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.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

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

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

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

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

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

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

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

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

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

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

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

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

@openzeppelin/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (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;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
          

@openzeppelin/contracts/utils/Counters.sol

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

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library Counters {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}
          

@openzeppelin/contracts/utils/ShortStrings.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/ShortStrings.sol)

pragma solidity ^0.8.8;

import "./StorageSlot.sol";

// | string  | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA   |
// | length  | 0x                                                              BB |
type ShortString is bytes32;

/**
 * @dev This library provides functions to convert short memory strings
 * into a `ShortString` type that can be used as an immutable variable.
 *
 * Strings of arbitrary length can be optimized using this library if
 * they are short enough (up to 31 bytes) by packing them with their
 * length (1 byte) in a single EVM word (32 bytes). Additionally, a
 * fallback mechanism can be used for every other case.
 *
 * Usage example:
 *
 * ```solidity
 * contract Named {
 *     using ShortStrings for *;
 *
 *     ShortString private immutable _name;
 *     string private _nameFallback;
 *
 *     constructor(string memory contractName) {
 *         _name = contractName.toShortStringWithFallback(_nameFallback);
 *     }
 *
 *     function name() external view returns (string memory) {
 *         return _name.toStringWithFallback(_nameFallback);
 *     }
 * }
 * ```
 */
library ShortStrings {
    // Used as an identifier for strings longer than 31 bytes.
    bytes32 private constant _FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;

    error StringTooLong(string str);
    error InvalidShortString();

    /**
     * @dev Encode a string of at most 31 chars into a `ShortString`.
     *
     * This will trigger a `StringTooLong` error is the input string is too long.
     */
    function toShortString(string memory str) internal pure returns (ShortString) {
        bytes memory bstr = bytes(str);
        if (bstr.length > 31) {
            revert StringTooLong(str);
        }
        return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));
    }

    /**
     * @dev Decode a `ShortString` back to a "normal" string.
     */
    function toString(ShortString sstr) internal pure returns (string memory) {
        uint256 len = byteLength(sstr);
        // using `new string(len)` would work locally but is not memory safe.
        string memory str = new string(32);
        /// @solidity memory-safe-assembly
        assembly {
            mstore(str, len)
            mstore(add(str, 0x20), sstr)
        }
        return str;
    }

    /**
     * @dev Return the length of a `ShortString`.
     */
    function byteLength(ShortString sstr) internal pure returns (uint256) {
        uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;
        if (result > 31) {
            revert InvalidShortString();
        }
        return result;
    }

    /**
     * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.
     */
    function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {
        if (bytes(value).length < 32) {
            return toShortString(value);
        } else {
            StorageSlot.getStringSlot(store).value = value;
            return ShortString.wrap(_FALLBACK_SENTINEL);
        }
    }

    /**
     * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
     */
    function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {
        if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {
            return toString(value);
        } else {
            return store;
        }
    }

    /**
     * @dev Return the length of a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
     *
     * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of
     * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.
     */
    function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {
        if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {
            return byteLength(value);
        } else {
            return bytes(store).length;
        }
    }
}
          

@openzeppelin/contracts/utils/StorageSlot.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

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:
 * ```solidity
 * 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`, `uint256`._
 * _Available since v4.9 for `string`, `bytes`._
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

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

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

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

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

    /**
     * @dev Returns an `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}
          

@openzeppelin/contracts/utils/Strings.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

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

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

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

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

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

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

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}
          

@openzeppelin/contracts/utils/cryptography/ECDSA.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV // Deprecated in v4.8
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, "\x19Ethereum Signed Message:\n32")
            mstore(0x1c, hash)
            message := keccak256(0x00, 0x3c)
        }
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, "\x19\x01")
            mstore(add(ptr, 0x02), domainSeparator)
            mstore(add(ptr, 0x22), structHash)
            data := keccak256(ptr, 0x42)
        }
    }

    /**
     * @dev Returns an Ethereum Signed Data with intended validator, created from a
     * `validator` and `data` according to the version 0 of EIP-191.
     *
     * See {recover}.
     */
    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x00", validator, data));
    }
}
          

@openzeppelin/contracts/utils/cryptography/EIP712.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol)

pragma solidity ^0.8.8;

import "./ECDSA.sol";
import "../ShortStrings.sol";
import "../../interfaces/IERC5267.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
 * separator of the implementation contract. This will cause the `_domainSeparatorV4` function to always rebuild the
 * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
 *
 * _Available since v3.4._
 *
 * @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
 */
abstract contract EIP712 is IERC5267 {
    using ShortStrings for *;

    bytes32 private constant _TYPE_HASH =
        keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
    // invalidate the cached domain separator if the chain id changes.
    bytes32 private immutable _cachedDomainSeparator;
    uint256 private immutable _cachedChainId;
    address private immutable _cachedThis;

    bytes32 private immutable _hashedName;
    bytes32 private immutable _hashedVersion;

    ShortString private immutable _name;
    ShortString private immutable _version;
    string private _nameFallback;
    string private _versionFallback;

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        _name = name.toShortStringWithFallback(_nameFallback);
        _version = version.toShortStringWithFallback(_versionFallback);
        _hashedName = keccak256(bytes(name));
        _hashedVersion = keccak256(bytes(version));

        _cachedChainId = block.chainid;
        _cachedDomainSeparator = _buildDomainSeparator();
        _cachedThis = address(this);
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (address(this) == _cachedThis && block.chainid == _cachedChainId) {
            return _cachedDomainSeparator;
        } else {
            return _buildDomainSeparator();
        }
    }

    function _buildDomainSeparator() private view returns (bytes32) {
        return keccak256(abi.encode(_TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
    }

    /**
     * @dev See {EIP-5267}.
     *
     * _Available since v4.9._
     */
    function eip712Domain()
        public
        view
        virtual
        override
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        )
    {
        return (
            hex"0f", // 01111
            _name.toStringWithFallback(_nameFallback),
            _version.toStringWithFallback(_versionFallback),
            block.chainid,
            address(this),
            bytes32(0),
            new uint256[](0)
        );
    }
}
          

@openzeppelin/contracts/utils/math/Math.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@openzeppelin/contracts/utils/math/SafeCast.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.0;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCast {
    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     *
     * _Available since v4.7._
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     *
     * _Available since v4.7._
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     *
     * _Available since v4.7._
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     *
     * _Available since v4.2._
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     *
     * _Available since v4.7._
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     *
     * _Available since v4.7._
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     *
     * _Available since v4.7._
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     *
     * _Available since v4.7._
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     *
     * _Available since v4.7._
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     *
     * _Available since v4.7._
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     *
     * _Available since v4.7._
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     *
     * _Available since v4.7._
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     *
     * _Available since v4.7._
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     *
     * _Available since v4.7._
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     *
     * _Available since v4.7._
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v2.5._
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     *
     * _Available since v4.7._
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     *
     * _Available since v4.7._
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     *
     * _Available since v4.7._
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     *
     * _Available since v4.2._
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     *
     * _Available since v4.7._
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     *
     * _Available since v4.7._
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     *
     * _Available since v4.7._
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v2.5._
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     *
     * _Available since v4.7._
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     *
     * _Available since v4.7._
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     *
     * _Available since v4.7._
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v2.5._
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     *
     * _Available since v4.7._
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v2.5._
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     *
     * _Available since v2.5._
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     *
     * _Available since v3.0._
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     *
     * _Available since v4.7._
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     *
     * _Available since v4.7._
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     *
     * _Available since v4.7._
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     *
     * _Available since v4.7._
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     *
     * _Available since v4.7._
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     *
     * _Available since v4.7._
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     *
     * _Available since v4.7._
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     *
     * _Available since v4.7._
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     *
     * _Available since v4.7._
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     *
     * _Available since v4.7._
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     *
     * _Available since v4.7._
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     *
     * _Available since v4.7._
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     *
     * _Available since v4.7._
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     *
     * _Available since v4.7._
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     *
     * _Available since v4.7._
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     *
     * _Available since v4.7._
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     *
     * _Available since v4.7._
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     *
     * _Available since v4.7._
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     *
     * _Available since v4.7._
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     *
     * _Available since v4.7._
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     *
     * _Available since v4.7._
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     *
     * _Available since v4.7._
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     *
     * _Available since v4.7._
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     *
     * _Available since v4.7._
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     *
     * _Available since v4.7._
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     *
     * _Available since v4.7._
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     *
     * _Available since v3.0._
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}
          

@openzeppelin/contracts/utils/math/SignedMath.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

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

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}
          

contracts/DaoDistributor.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {ValidatorFeeDepositor} from "./ValidatorFeeDepositor.sol";
import "./LiquidityManager.sol";
import "./Utilities.sol";

contract DaoDistributor is IDaoDistributor, ReentrancyGuard {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;
    using SafeERC20 for IVPLS;
    using SafeERC20 for IVouch;

    // ===== Integrated Contracts =====
    address vouchAddress;
    address vplsAddress = 0x79BB3A0Ee435f957ce4f54eE8c3CFADc7278da0C;
    VPLSMinter vplsMinter = VPLSMinter(0x2D7Dcc5A1d90d08D484E38a4C99B8394daaF4B9e);
    ValidatorFeeDepositor public validatorFeeDepositor;
    address wplsAddress = 0xA1077a294dDE1B09bB078844df40758a5D0f9a27;

    // ===== Output Addresses =====
    address public validators;
    address public masterValidator;
    address public feePool;
    address public safu;
    address public daoTreasury;
    address public voters;
    address public stakers;
    address constant zeroAddress = 0x0000000000000000000000000000000000000000;

    // ===== Interfaces =====
    IERC20 WPLS = IERC20(wplsAddress);
    IVPLS VPLS = IVPLS(vplsAddress);
    IVouch public VOUCH;
    INetworkProposal networkProposal = INetworkProposal(0x7783D7040423f75aeF82a3Ec32ed366ca460Fa6c);
    LiquidityManager public liquidityManager;

    // ===== DEX Routers =====
    IDEXRouter public pulseRouterV1;
    IDEXRouter public pulseRouterV2;
    IDEXRouter public nineinchRouter;

    // ===== Share Data =====
    struct Share {
        uint256 amount;
        uint256 vouchTotalExcluded;
        uint256 vouchTotalRealised;
        uint256 vplsTotalExcluded;
        uint256 vplsTotalRealised;
        uint256 plsTotalExcluded;
        uint256 plsTotalRealised;
    }
    struct Distributions {
        uint256 totalToValidators;
        uint256 totalToVoters;
        uint256 totalToStakers;
    }
    enum Recipient { VouchHolders, Validators, Voters, Stakers, Burn }
    mapping(address => mapping(Recipient => uint256)) public tokenRewards;
    address[] shareholders;
    mapping(address => uint256) shareholderVouchIndexes;
    mapping(address => uint256) shareholderVouchClaims;
    mapping(address => uint256) shareholderVplsIndexes;
    mapping(address => uint256) shareholderVplsClaims;
    mapping(address => uint256) shareholderPlsIndexes;
    mapping(address => uint256) public shareholderPlsClaims;
    mapping(address => Share) public shares;
    uint256 public totalShares;

    // ===== Distribution Percentages =====
    uint256 constant denominator = 10000;
    uint256 constant thresholdDenominator = 1e18;
    uint256 public liquidityPoolsPercent = 2000;
    uint256 public masterValidatorPercent = 3000;
    uint256 public feePoolPercent = 1000;
    uint256 public safuPercent = 100;
    uint256 public daoTreasuryPercent = 400;
    uint256 public votersPlsPercent = 500;
    uint256 public vouchRewards = 1000;
    uint256 public vplsRewards = 1000;
    uint256 public plsRewards = 1000;

    // ===== Dividend Trackers for VOUCH =====
    uint256 public totalVouchBurned;
    uint256 public totalVouchDividends;
    uint256 public totalVouchDistributed;
    uint256 public totalVouchDividendsDistributed;
    uint256 public vouchDividendsPerShare;
    uint256 constant vouchDividendsPerShareAccuracyFactor = 10 ** 36;
    uint256 public minVouchPeriod = 30 seconds;
    uint256 public minVouchDistribution = 100000 * (10 ** 18);
    uint256 currentVouchIndex;
    uint256 public pendingPlsForVouchSwaps;

    // ===== Dividend Trackers for VPLS =====
    uint256 public totalVplsBurned;
    uint256 public totalVplsDividends;
    uint256 public totalVplsDistributed;
    uint256 public totalVplsDividendsDistributed;
    uint256 public vplsDividendsPerShare;
    uint256 constant vplsDividendsPerShareAccuracyFactor = 10 ** 36;
    uint256 public minVplsPeriod = 30 seconds;
    uint256 public minVplsDistribution = 20000 * (10 ** 18);
    uint256 currentVplsIndex;
    uint256 public pendingPlsForVplsMints;

    // ===== Dividend Trackers for PLS =====
    uint256 public totalPlsDividends;
    uint256 public totalPlsDistributed;
    uint256 public totalPlsDividendsDistributed;
    uint256 public plsDividendsPerShare;
    uint256 constant plsDividendsPerShareAccuracyFactor = 10 ** 36;
    uint256 public minPlsPeriod = 30 seconds;
    uint256 public minPlsDistribution = 30000 * (10 ** 18);
    uint256 currentPlsIndex;

    // ===== Distribution Amounts =====
    uint256 public accumulatedForTokenSwaps;
    uint256 public accumulatedForPlsSends;
    uint256 public accumulatedForPlsLiquidity;
    uint256 public accumulatedVouchForDistribution;
    uint256 public accumulatedVplsForDistribution;
    uint256 public accumulatedPlsForDistribution;

    uint256 public totalVouchDistributedToValidators;
    uint256 public totalVouchDistributedToVoters;
    uint256 public totalVouchDistributedToStakers;
    uint256 public totalVplsDistributedToValidators;
    uint256 public totalVplsDistributedToVoters;
    uint256 public totalVplsDistributedToStakers;
    uint256 public totalPlsDistributedToValidators;
    uint256 public totalPlsDistributedToVoters;
    uint256 public totalPlsDistributedToStakers;

    uint256 public pendingMasterValidatorPls;
    uint256 public pendingFeePoolPls;
    uint256 public pendingSafuPls;
    uint256 public pendingDaoTreasuryPls;
    uint256 public pendingVotersPls;
    uint256 public pendingStakersPls;
    uint256 public pendingLiquidityManagerPls;

    // ===== Distribution Thresholds =====
    uint256 public vouchForDistributionThreshold = 500000 * (10 ** 18);
    uint256 public vplsForDistributionThreshold = 150000 * (10 ** 18);
    uint256 public plsForDistributionThreshold = 150000 * (10 ** 18);
    uint256 public swapThresholdForTokens = 125000 * (10 ** 18);
    uint256 public plsSendThreshold = 120000 * (10 ** 18);
    uint256 public liquidityDistributionThreshold = 300000 * (10 ** 18);

    // ===== Total PLS Received Trackers =====
    uint256 public totalPlsReceived;
    uint256 public totalPlsFromVouch;
    uint256 public totalPlsFromValidators;

    // ===== Other Variables =====
    uint256 public vouchGas;
    uint256 public vplsGas;
    uint256 public plsGas;
    uint256 public totalPlsMasterValidators;
    uint256 public totalPlsFeePool;
    uint256 public totalPlsSafu;
    uint256 public totalPlsDaoTreasury;
    uint256 public totalPlsVoters;
    uint256 public totalPlsLpAdded;

    // ===== Distribution Timing =====
    uint256 private lastDistributionTimestamp;
    uint256 public distributionCooldown = 300 seconds;
    bool public distributionLock;

    event ParameterUpdated();
    event SwapForVouchSucceeded(uint256 totalPlsToAttempt, uint256 vouchGained, address router);
    event SwapForVouchFailed(uint256 totalPlsToAttempt, address router);

    modifier onlyAdmin() {
        require(networkProposal.isAdmin(msg.sender), "Caller must be admin");
        _;
    }
    modifier onlyVouch() {
        require(msg.sender == vouchAddress, "Caller must be the VOUCH contract");
        _;
    }
    modifier onlyValidators() {
        require(msg.sender == address(validatorFeeDepositor), "Caller must be the validator fee depositor contract");
        _;
    }
    modifier distributionLocked() {
        distributionLock = true;
        _;
        distributionLock = false;
    }

    constructor(
        address _liquidityManagerAddress,
        address _validators,
        address _masterValidator,
        address _feePool,
        address _safu,
        address _daoTreasury,
        address _voters,
        address _stakers,
        address _pulseRouterV1,
        address _pulseRouterV2,
        address _nineinchRouter
    ) {
        validatorFeeDepositor = new ValidatorFeeDepositor();
        liquidityManager = LiquidityManager(payable(_liquidityManagerAddress));
        pulseRouterV1 = _pulseRouterV1 != address(0)
            ? IDEXRouter(_pulseRouterV1)
            : IDEXRouter(0x98bf93ebf5c380C0e6Ae8e192A7e2AE08edAcc02);
        pulseRouterV2 = _pulseRouterV2 != address(0)
            ? IDEXRouter(_pulseRouterV2)
            : IDEXRouter(0x165C3410fC91EF562C50559f7d2289fEbed552d9);
        nineinchRouter = _nineinchRouter != address(0)
            ? IDEXRouter(_nineinchRouter)
            : IDEXRouter(0xeB45a3c4aedd0F47F345fB4c8A1802BB5740d725);
        vouchGas = 200000;
        vplsGas = 200000;
        plsGas = 200000;
        tokenRewards[vplsAddress][Recipient.VouchHolders] = 3000;
        tokenRewards[vplsAddress][Recipient.Validators] = 1500;
        tokenRewards[vplsAddress][Recipient.Voters] = 1000;
        tokenRewards[vplsAddress][Recipient.Stakers] = 500;
        tokenRewards[vplsAddress][Recipient.Burn] = 4000;
        tokenRewards[wplsAddress][Recipient.VouchHolders] = 2500;
        tokenRewards[wplsAddress][Recipient.Validators] = 5000;
        tokenRewards[wplsAddress][Recipient.Voters] = 1500;
        tokenRewards[wplsAddress][Recipient.Stakers] = 1000;
        validators = _validators;
        masterValidator = _masterValidator;
        feePool = _feePool;
        safu = _safu;
        daoTreasury = _daoTreasury;
        voters = _voters;
        stakers = _stakers;
    }

    function setVouchAddress(address _vouchAddress) external {
        require(_vouchAddress != address(0), "invalid address");
        if (vouchAddress != address(0)) {
            require(networkProposal.isAdmin(msg.sender), "Caller must be admin");
        }
        vouchAddress = _vouchAddress;
        VOUCH = IVouch(_vouchAddress);
        tokenRewards[vouchAddress][Recipient.VouchHolders] = 2000;
        tokenRewards[vouchAddress][Recipient.Validators] = 1500;
        tokenRewards[vouchAddress][Recipient.Voters] = 500;
        tokenRewards[vouchAddress][Recipient.Stakers] = 1000;
        tokenRewards[vouchAddress][Recipient.Burn] = 5000;
    }

    function setDistributionCooldown(uint256 _cooldown) external onlyAdmin {
        distributionCooldown = _cooldown;
    }

    function setRecipientAddresses(
        address _validators,
        address _masterValidator,
        address _feePool,
        address _safu,
        address _daoTreasury,
        address _voters,
        address _stakers
    ) external onlyAdmin {
        validators = _validators;
        masterValidator = _masterValidator;
        feePool = _feePool;
        safu = _safu;
        daoTreasury = _daoTreasury;
        voters = _voters;
        stakers = _stakers;
        require(validators != address(0) && masterValidator != address(0) && feePool != address(0) && safu != address(0) && daoTreasury != address(0) && voters != address(0) && stakers != address(0), "address cannot be zero");
    }

    function setValidatorFeeDepositor(address _validatorFeeDepositor) external onlyAdmin {
        require(_validatorFeeDepositor != address(0), "Invalid address provided.");
        validatorFeeDepositor = ValidatorFeeDepositor(payable(_validatorFeeDepositor));
    }

    function setLiquidityManagerAddress(address _liquidityManager) external onlyAdmin {
        require(_liquidityManager != address(0), "Invalid address provided.");
        liquidityManager = LiquidityManager(payable(_liquidityManager));
    }

    function setDistributorSettings(uint256 _vouchGas, uint256 _vplsGas, uint256 _plsGas) external onlyAdmin {
        vouchGas = _vouchGas;
        vplsGas = _vplsGas;
        plsGas = _plsGas;
        require(vouchGas <= 1000000 && vplsGas <= 1000000 && plsGas <= 1000000, "Max gas is 1000000");
        emit ParameterUpdated();
    }

    function setVouchRewards(
        uint256 _vouchHoldersPercent,
        uint256 _validatorsPercent,
        uint256 _votersPercent,
        uint256 _stakersPercent,
        uint256 _burnPercent
    ) external onlyAdmin {
        require(
            _vouchHoldersPercent.add(_validatorsPercent).add(_votersPercent).add(_stakersPercent).add(_burnPercent) == 10000,
            "The total of all combined vouch rewards must be 10000 for 100 percent."
        );
        tokenRewards[vouchAddress][Recipient.VouchHolders] = _vouchHoldersPercent;
        tokenRewards[vouchAddress][Recipient.Validators] = _validatorsPercent;
        tokenRewards[vouchAddress][Recipient.Voters] = _votersPercent;
        tokenRewards[vouchAddress][Recipient.Stakers] = _stakersPercent;
        tokenRewards[vouchAddress][Recipient.Burn] = _burnPercent;
    }

    function setVplsRewards(
        uint256 _vouchHoldersPercent,
        uint256 _validatorsPercent,
        uint256 _votersPercent,
        uint256 _stakersPercent,
        uint256 _burnPercent
    ) external onlyAdmin {
        require(
            _vouchHoldersPercent.add(_validatorsPercent).add(_votersPercent).add(_stakersPercent).add(_burnPercent) == 10000,
            "The total of all combined vpls rewards must be 10000 for 100 percent."
        );
        tokenRewards[vplsAddress][Recipient.VouchHolders] = _vouchHoldersPercent;
        tokenRewards[vplsAddress][Recipient.Validators] = _validatorsPercent;
        tokenRewards[vplsAddress][Recipient.Voters] = _votersPercent;
        tokenRewards[vplsAddress][Recipient.Stakers] = _stakersPercent;
        tokenRewards[vplsAddress][Recipient.Burn] = _burnPercent;
    }

    function setPlsRewards(
        uint256 _vouchHoldersPercent,
        uint256 _validatorsPercent,
        uint256 _votersPercent,
        uint256 _stakersPercent
    ) external onlyAdmin {
        require(
            _vouchHoldersPercent.add(_validatorsPercent).add(_votersPercent).add(_stakersPercent) == 10000,
            "The total of all combined PLS rewards must be 10000 for 100 percent."
        );
        tokenRewards[wplsAddress][Recipient.VouchHolders] = _vouchHoldersPercent;
        tokenRewards[wplsAddress][Recipient.Validators] = _validatorsPercent;
        tokenRewards[wplsAddress][Recipient.Voters] = _votersPercent;
        tokenRewards[wplsAddress][Recipient.Stakers] = _stakersPercent;
    }

    function setDistributionThresholds(
        uint256 _vouchForDistributionThreshold,
        uint256 _vplsForDistributionThreshold,
        uint256 _plsForDistributionThreshold,
        uint256 _swapThresholdForTokens,
        uint256 _plsSendThreshold,
        uint256 _liquidityDistributionThreshold
    ) external onlyAdmin {
        vouchForDistributionThreshold = _vouchForDistributionThreshold;
        vplsForDistributionThreshold = _vplsForDistributionThreshold;
        plsForDistributionThreshold = _plsForDistributionThreshold;
        swapThresholdForTokens = _swapThresholdForTokens;
        plsSendThreshold = _plsSendThreshold;
        liquidityDistributionThreshold = _liquidityDistributionThreshold;
        
        emit ParameterUpdated();
    }

    function setDistributionAmounts(
        uint256[9] calldata feeParams
    ) external onlyAdmin {
        uint256 totalFee;
        for (uint256 i = 0; i < feeParams.length; i++) {
            totalFee = totalFee.add(feeParams[i]);
        }
        require(
            totalFee == denominator,
            "Total fees must equal feeDenominator"
        );

        liquidityPoolsPercent = feeParams[0];
        masterValidatorPercent = feeParams[1];
        feePoolPercent = feeParams[2];
        safuPercent = feeParams[3];
        daoTreasuryPercent = feeParams[4];
        votersPlsPercent = feeParams[5];
        vouchRewards = feeParams[6];
        vplsRewards = feeParams[7];
        plsRewards = feeParams[8];

        emit ParameterUpdated();
    }

    function setDistributionCriteria(
        uint256 _minVouchPeriod,
        uint256 _minVouchDistribution,
        uint256 _minVplsPeriod,
        uint256 _minVplsDistribution,
        uint256 _minPlsPeriod,
        uint256 _minPlsDistribution
    ) external onlyAdmin {
        minVouchPeriod = _minVouchPeriod;
        minVouchDistribution = _minVouchDistribution;
        minVplsPeriod = _minVplsPeriod;
        minVplsDistribution = _minVplsDistribution;
        minPlsPeriod = _minPlsPeriod;
        minPlsDistribution = _minPlsDistribution;
        emit ParameterUpdated();
    }

    function _allocateDeposit(uint256 amount) internal {
        uint256 totalRewardsRatio = vouchRewards.add(vplsRewards).add(plsRewards);
        uint256 rewardsPortion = amount.mul(totalRewardsRatio).div(denominator);
        uint256 feePortion = amount.mul(masterValidatorPercent.add(feePoolPercent).add(safuPercent).add(daoTreasuryPercent).add(votersPlsPercent)).div(denominator);
        uint256 liquidityPortion = amount.mul(liquidityPoolsPercent).div(denominator);
        uint256 allocated = rewardsPortion.add(feePortion).add(liquidityPortion);
        uint256 remainder = amount.sub(allocated);
        rewardsPortion = rewardsPortion.add(remainder);

        accumulatedForTokenSwaps = accumulatedForTokenSwaps.add(rewardsPortion);
        accumulatedForPlsSends = accumulatedForPlsSends.add(feePortion);
        accumulatedForPlsLiquidity = accumulatedForPlsLiquidity.add(liquidityPortion);
    }

    function _triggerDistribution() internal distributionLocked {
        if (block.timestamp < lastDistributionTimestamp + distributionCooldown) {
            return;
        }
        lastDistributionTimestamp = block.timestamp;

        if (accumulatedForTokenSwaps >= swapThresholdForTokens) {
            uint256 amt = accumulatedForTokenSwaps;
            accumulatedForTokenSwaps = 0;
            uint256 totalSwapRatio = vouchRewards.add(vplsRewards).add(plsRewards);
            uint256 amountVouch = amt.mul(vouchRewards).div(totalSwapRatio);
            uint256 amountVpls = amt.mul(vplsRewards).div(totalSwapRatio);
            uint256 amountPls = amt.mul(plsRewards).div(totalSwapRatio);
            _swapForRewards(amountVouch, amountVpls, amountPls);
        }

        if (accumulatedForPlsSends >= plsSendThreshold) {
            uint256 amt = accumulatedForPlsSends;
            accumulatedForPlsSends = 0;
            uint256 totalFeeRatio = masterValidatorPercent
                .add(feePoolPercent)
                .add(safuPercent)
                .add(daoTreasuryPercent)
                .add(votersPlsPercent);
            uint256 masterValidatorAmt = amt.mul(masterValidatorPercent).div(totalFeeRatio);
            uint256 feePoolAmt = amt.mul(feePoolPercent).div(totalFeeRatio);
            uint256 safuAmt = amt.mul(safuPercent).div(totalFeeRatio);
            uint256 daoTreasuryAmt = amt.mul(daoTreasuryPercent).div(totalFeeRatio);
            uint256 votersAmt = amt.sub(masterValidatorAmt).sub(feePoolAmt).sub(safuAmt).sub(daoTreasuryAmt);
            _processPlsSends(masterValidatorAmt, feePoolAmt, safuAmt, daoTreasuryAmt, votersAmt);
        }
        
        if (accumulatedForPlsLiquidity >= liquidityDistributionThreshold) {
            uint256 amt = accumulatedForPlsLiquidity;
            accumulatedForPlsLiquidity = 0;
            _distributePlsForLiquidity(amt);
        }

        _triggerSimpleSends();

    }

    function _triggerSimpleSends() internal {
        if (accumulatedVouchForDistribution >= vouchForDistributionThreshold) {
            uint256 amountVouchForDistribution = accumulatedVouchForDistribution;
            accumulatedVouchForDistribution = 0;

            uint256 distributionDenom = denominator.sub(tokenRewards[vouchAddress][Recipient.VouchHolders]);

            uint256 validatorAmount = amountVouchForDistribution.mul(tokenRewards[vouchAddress][Recipient.Validators]).div(distributionDenom);
            uint256 voterAmount = amountVouchForDistribution.mul(tokenRewards[vouchAddress][Recipient.Voters]).div(distributionDenom);
            uint256 stakerAmount = amountVouchForDistribution.mul(tokenRewards[vouchAddress][Recipient.Stakers]).div(distributionDenom);
            uint256 burnAmount = amountVouchForDistribution.mul(tokenRewards[vouchAddress][Recipient.Burn]).div(distributionDenom);
            _processSimpleVouchSends(validatorAmount, voterAmount, stakerAmount, burnAmount);
        }
        if (accumulatedVplsForDistribution >= vplsForDistributionThreshold) {
            uint256 amountVplsForDistribution = accumulatedVplsForDistribution;
            accumulatedVplsForDistribution = 0;

            uint256 distributionDenom = denominator.sub(tokenRewards[vplsAddress][Recipient.VouchHolders]);
            
            uint256 validatorAmount = amountVplsForDistribution.mul(tokenRewards[vplsAddress][Recipient.Validators]).div(distributionDenom);
            uint256 voterAmount = amountVplsForDistribution.mul(tokenRewards[vplsAddress][Recipient.Voters]).div(distributionDenom);
            uint256 stakerAmount = amountVplsForDistribution.mul(tokenRewards[vplsAddress][Recipient.Stakers]).div(distributionDenom);
            uint256 burnAmount = amountVplsForDistribution.mul(tokenRewards[vplsAddress][Recipient.Burn]).div(distributionDenom);
            _processSimpleVplsSends(validatorAmount, voterAmount, stakerAmount, burnAmount);
        }
        if (accumulatedPlsForDistribution >= plsForDistributionThreshold) {
            uint256 amountPlsForDistribution = accumulatedPlsForDistribution;
            accumulatedPlsForDistribution = 0;

            uint256 distributionDenom = denominator.sub(tokenRewards[wplsAddress][Recipient.VouchHolders]);

            uint256 validatorAmount = amountPlsForDistribution.mul(tokenRewards[wplsAddress][Recipient.Validators]).div(distributionDenom);
            uint256 voterAmount = amountPlsForDistribution.mul(tokenRewards[wplsAddress][Recipient.Voters]).div(distributionDenom);
            uint256 stakerAmount = amountPlsForDistribution.mul(tokenRewards[wplsAddress][Recipient.Stakers]).div(distributionDenom);
            _processSimplePlsSends(validatorAmount, voterAmount, stakerAmount);
        }
    }

    function _swapPlsForVouch(uint256 newPlsForVouch) internal {
        uint256 totalPlsToAttempt = newPlsForVouch.add(pendingPlsForVouchSwaps);
        if (totalPlsToAttempt == 0) {
            return;
        }

        uint256 vouchBalanceBefore = IERC20(address(VOUCH)).balanceOf(address(this));

        address[] memory path = new address[](2);
        path[0] = wplsAddress;
        path[1] = vouchAddress;

        IDEXRouter router = IDEXRouter(Utilities.getBestRouter(totalPlsToAttempt, path));

        try router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: totalPlsToAttempt}(0, path, address(this), block.timestamp) {
            pendingPlsForVouchSwaps = 0;
            uint256 vouchGained = IERC20(address(VOUCH)).balanceOf(address(this)).sub(vouchBalanceBefore);
            
            uint256 vouchToDividends = 0;
            if (tokenRewards[vouchAddress][Recipient.VouchHolders] > 0 && totalShares > 0) {
                 vouchToDividends = vouchGained.mul(tokenRewards[vouchAddress][Recipient.VouchHolders]).div(denominator);
            }
            uint256 vouchForOtherDistribution = vouchGained.sub(vouchToDividends);

            if (vouchForOtherDistribution > 0) {
                 accumulatedVouchForDistribution = accumulatedVouchForDistribution.add(vouchForOtherDistribution);
            }

            if (vouchToDividends > 0) {
                totalVouchDividends = totalVouchDividends.add(vouchToDividends);
                vouchDividendsPerShare = vouchDividendsPerShare.add(vouchDividendsPerShareAccuracyFactor.mul(vouchToDividends).div(totalShares));
            }
            
            emit SwapForVouchSucceeded(totalPlsToAttempt, vouchGained, address(router));
        } catch {
            pendingPlsForVouchSwaps = totalPlsToAttempt;
            emit SwapForVouchFailed(totalPlsToAttempt, address(router));
        }
    }

    function _mintVplsWithPls(uint256 amountVpls) internal {
        require(totalShares > 0, "No vouch shareholders");
        uint256 totalAmount = amountVpls.add(pendingPlsForVplsMints);
        if (totalAmount >= vplsMinter.minDeposit()) {
            uint256 vplsBalanceBefore = IERC20(address(VPLS)).balanceOf(address(this));
            pendingPlsForVplsMints = 0;
            try vplsMinter.deposit{value: totalAmount}() {
                uint256 vplsGained = IERC20(address(VPLS)).balanceOf(address(this)).sub(vplsBalanceBefore);
                uint256 vplsToDividends = vplsGained.mul(tokenRewards[vplsAddress][Recipient.VouchHolders]).div(denominator);

                accumulatedVplsForDistribution = accumulatedVplsForDistribution.add(vplsGained.sub(vplsToDividends));

                totalVplsDividends = totalVplsDividends.add(vplsToDividends);
                vplsDividendsPerShare = vplsDividendsPerShare.add(vplsDividendsPerShareAccuracyFactor.mul(vplsToDividends).div(totalShares));
            } catch {
                pendingPlsForVplsMints = pendingPlsForVplsMints.add(totalAmount);
            }
        } else {
            pendingPlsForVplsMints = pendingPlsForVplsMints.add(amountVpls);
        }
    }

    function _addPls(uint256 amountPls) internal {
        uint256 plsToDividends = amountPls.mul(tokenRewards[wplsAddress][Recipient.VouchHolders]).div(denominator);

        accumulatedPlsForDistribution = accumulatedPlsForDistribution.add(amountPls.sub(plsToDividends));

        totalPlsDividends = totalPlsDividends.add(plsToDividends);
        plsDividendsPerShare = plsDividendsPerShare.add(plsDividendsPerShareAccuracyFactor.mul(plsToDividends).div(totalShares));
    }

    function _swapForRewards(uint256 amountVouch, uint256 amountVpls, uint256 amountPls) internal {
        if (amountVouch > 0 || pendingPlsForVouchSwaps > 0) {
            if (vouchAddress != address(0)) {
                _swapPlsForVouch(amountVouch);
            } else if (amountVouch > 0) {
                pendingPlsForVouchSwaps = pendingPlsForVouchSwaps.add(amountVouch);
            }
        }
        if (amountVpls > 0) {
            _mintVplsWithPls(amountVpls);
        }
        if (amountPls > 0) {
            _addPls(amountPls);
        }
    }

    function _processSimpleVouchSends(
        uint256 validatorAmount,
        uint256 voterAmount,
        uint256 stakerAmount,
        uint256 burnAmount
    ) internal {
        totalVouchDistributed = totalVouchDistributed.add(validatorAmount).add(voterAmount).add(stakerAmount);
        totalVouchDistributedToValidators = totalVouchDistributedToValidators.add(validatorAmount);
        totalVouchDistributedToVoters = totalVouchDistributedToVoters.add(voterAmount);
        totalVouchDistributedToStakers = totalVouchDistributedToStakers.add(stakerAmount);
        totalVouchBurned = totalVouchBurned.add(burnAmount);
        IERC20(address(VOUCH)).safeTransfer(validators, validatorAmount);
        IERC20(address(VOUCH)).safeTransfer(voters, voterAmount);
        IERC20(address(VOUCH)).safeTransfer(stakers, stakerAmount);
        VOUCH.burn(burnAmount);
    }

    function _processSimpleVplsSends(
        uint256 validatorAmount,
        uint256 voterAmount,
        uint256 stakerAmount,
        uint256 burnAmount
    ) internal {
        totalVplsDistributed = totalVplsDistributed.add(validatorAmount).add(voterAmount).add(stakerAmount);
        totalVplsDistributedToValidators = totalVplsDistributedToValidators.add(validatorAmount);
        totalVplsDistributedToVoters = totalVplsDistributedToVoters.add(voterAmount);
        totalVplsDistributedToStakers = totalVplsDistributedToStakers.add(stakerAmount);
        totalVplsBurned = totalVplsBurned.add(burnAmount);
        IERC20(address(VPLS)).safeTransfer(validators, validatorAmount);
        IERC20(address(VPLS)).safeTransfer(voters, voterAmount);
        IERC20(address(VPLS)).safeTransfer(stakers, stakerAmount);
        VPLS.burn(burnAmount);
    }

    function _processSimplePlsSends(
        uint256 validatorAmount,
        uint256 votersAmount,
        uint256 stakersAmount
    ) internal {
        uint256 totalToValidators = pendingMasterValidatorPls + validatorAmount;
        uint256 totalToVoters = pendingVotersPls + votersAmount;
        uint256 totalToStakers = pendingStakersPls + stakersAmount;

        pendingMasterValidatorPls = 0;
        pendingVotersPls = 0;
        pendingStakersPls = 0;

        (bool successValidator, ) = payable(masterValidator).call{value: totalToValidators}("");
        if (successValidator) {
            totalPlsDistributedToValidators += totalToValidators;
            totalPlsDistributed += totalToValidators;
        } else {
            pendingMasterValidatorPls = totalToValidators;
        }

        (bool successVoters, ) = payable(voters).call{value: totalToVoters}("");
        if (successVoters) {
            totalPlsDistributedToVoters += totalToVoters;
            totalPlsDistributed += totalToVoters;
        } else {
            pendingVotersPls = totalToVoters;
        }

        (bool successStakers, ) = payable(stakers).call{value: totalToStakers}("");
        if (successStakers) {
            totalPlsDistributedToStakers += totalToStakers;
            totalPlsDistributed += totalToStakers;
        } else {
            pendingStakersPls = totalToStakers;
        }
    }

    function _processPlsSends(
        uint256 masterValidatorAmount,
        uint256 feePoolAmount,
        uint256 safuAmount,
        uint256 daoTreasuryAmount,
        uint256 votersAmount
    ) internal {
        uint256 totalToMasterValidator = pendingMasterValidatorPls + masterValidatorAmount;
        uint256 totalToFeePool = pendingFeePoolPls + feePoolAmount;
        uint256 totalToSafu = pendingSafuPls + safuAmount;
        uint256 totalToDaoTreasury = pendingDaoTreasuryPls + daoTreasuryAmount;
        uint256 totalToVoters = pendingVotersPls + votersAmount;

        pendingMasterValidatorPls = 0;
        pendingFeePoolPls = 0;
        pendingSafuPls = 0;
        pendingDaoTreasuryPls = 0;
        pendingVotersPls = 0;

        (bool successMasterValidator, ) = payable(masterValidator).call{value: totalToMasterValidator}("");
        if (successMasterValidator) {
            totalPlsMasterValidators = totalPlsMasterValidators.add(totalToMasterValidator);
        } else {
            pendingMasterValidatorPls = totalToMasterValidator;
        }

        (bool successFeePool, ) = payable(feePool).call{value: totalToFeePool}("");
        if (successFeePool) {
            totalPlsFeePool = totalPlsFeePool.add(totalToFeePool);
        } else {
            pendingFeePoolPls = totalToFeePool;
        }

        (bool successSafu, ) = payable(safu).call{value: totalToSafu}("");
        if (successSafu) {
            totalPlsSafu = totalPlsSafu.add(totalToSafu);
        } else {
            pendingSafuPls = totalToSafu;
        }

        (bool successDaoTreasury, ) = payable(daoTreasury).call{value: totalToDaoTreasury}("");
        if (successDaoTreasury) {
            totalPlsDaoTreasury = totalPlsDaoTreasury.add(totalToDaoTreasury);
        } else {
            pendingDaoTreasuryPls = totalToDaoTreasury;
        }

        (bool successVoters, ) = payable(voters).call{value: totalToVoters}("");
        if (successVoters) {
            totalPlsVoters = totalPlsVoters.add(totalToVoters);
        } else {
            pendingVotersPls = totalToVoters;
        }
    }

    function _distributePlsForLiquidity(uint256 liquidityAmount) internal {
        bool ok;
        uint256 total = pendingLiquidityManagerPls + liquidityAmount;
        (ok, ) = payable(address(liquidityManager)).call{value: total}("");
        if (ok) {
            pendingLiquidityManagerPls = 0;
            totalPlsLpAdded = totalPlsLpAdded.add(total);
            try liquidityManager.swapAddAndLockLiquidity(block.timestamp) {} catch {}
        } else {
            pendingLiquidityManagerPls = total;
        }
    }

    function processVouch(uint256 gas) public override onlyVouch {
        uint256 shareholderCount = shareholders.length;
        if (shareholderCount == 0) return;
        uint256 gasUsed = 0;
        uint256 gasLeft = gasleft();
        uint256 iterations = 0;
        while (gasUsed < gas && iterations < shareholderCount) {
            if (currentVouchIndex >= shareholderCount) {
                currentVouchIndex = 0;
            }
            if (shouldVouchDistribute(shareholders[currentVouchIndex])) {
                distributeVouchDividend(shareholders[currentVouchIndex]);
            }
            gasUsed = gasUsed.add(gasLeft.sub(gasleft()));
            gasLeft = gasleft();
            currentVouchIndex++;
            iterations++;
        }
    }

    function processVpls(uint256 gas) public override onlyVouch {
        uint256 shareholderCount = shareholders.length;
        if (shareholderCount == 0) return;
        uint256 gasUsed = 0;
        uint256 gasLeft = gasleft();
        uint256 iterations = 0;
        while (gasUsed < gas && iterations < shareholderCount) {
            if (currentVplsIndex >= shareholderCount) {
                currentVplsIndex = 0;
            }
            if (shouldVplsDistribute(shareholders[currentVplsIndex])) {
                distributeVplsDividend(shareholders[currentVplsIndex]);
            }
            gasUsed = gasUsed.add(gasLeft.sub(gasleft()));
            gasLeft = gasleft();
            currentVplsIndex++;
            iterations++;
        }
    }

    function processPls(uint256 gas) public override onlyVouch {
        uint256 shareholderCount = shareholders.length;
        if (shareholderCount == 0) return;
        uint256 gasUsed = 0;
        uint256 gasLeft = gasleft();
        uint256 iterations = 0;
        while (gasUsed < gas && iterations < shareholderCount) {
            if (currentPlsIndex >= shareholderCount) {
                currentPlsIndex = 0;
            }
            if (shouldPlsDistribute(shareholders[currentPlsIndex])) {
                distributePlsDividend(shareholders[currentPlsIndex]);
            }
            gasUsed = gasUsed.add(gasLeft.sub(gasleft()));
            gasLeft = gasleft();
            currentPlsIndex++;
            iterations++;
        }
    }

    function shouldVouchDistribute(address shareholder) internal view returns (bool) {
        return shareholderVouchClaims[shareholder] + minVouchPeriod < block.timestamp &&
            getUnpaidVouchEarnings(shareholder) > minVouchDistribution;
    }

    function shouldVplsDistribute(address shareholder) internal view returns (bool) {
        return shareholderVplsClaims[shareholder] + minVplsPeriod < block.timestamp &&
            getUnpaidVplsEarnings(shareholder) > minVplsDistribution;
    }

    function shouldPlsDistribute(address shareholder) internal view returns (bool) {
        return shareholderPlsClaims[shareholder] + minPlsPeriod < block.timestamp &&
            getUnpaidPlsEarnings(shareholder) > minPlsDistribution;
    }

    function claimDividend() external override nonReentrant {
        distributeVouchDividend(msg.sender);
        distributeVplsDividend(msg.sender);
        distributePlsDividend(msg.sender);
    }

    function getUnpaidVouchEarnings(
        address shareholder
    ) public view returns (uint256) {
        if (shares[shareholder].amount == 0) {
            return 0;
        }

        uint256 shareholderTotalDividends = getCumulativeVouchDividends(
            shares[shareholder].amount
        );
        uint256 shareholderTotalExcluded = shares[shareholder]
            .vouchTotalExcluded;

        if (shareholderTotalDividends <= shareholderTotalExcluded) {
            return 0;
        }

        return shareholderTotalDividends.sub(shareholderTotalExcluded);
    }

    function getUnpaidVplsEarnings(address shareholder) public view override returns (uint256) {
        if (shares[shareholder].amount == 0) {
            return 0;
        }

        uint256 shareholderTotalDividends = getCumulativeVplsDividends(
            shares[shareholder].amount
        );
        uint256 shareholderTotalExcluded = shares[shareholder]
            .vplsTotalExcluded;

        if (shareholderTotalDividends <= shareholderTotalExcluded) {
            return 0;
        }

        return shareholderTotalDividends.sub(shareholderTotalExcluded);
    }

    function getUnpaidPlsEarnings(address shareholder) public view override returns (uint256) {
        if (shares[shareholder].amount == 0) {
            return 0;
        }

        uint256 shareholderTotalDividends = getCumulativePlsDividends(
            shares[shareholder].amount
        );
        uint256 shareholderTotalExcluded = shares[shareholder]
            .plsTotalExcluded;

        if (shareholderTotalDividends <= shareholderTotalExcluded) {
            return 0;
        }

        return shareholderTotalDividends.sub(shareholderTotalExcluded);
    }

    function getCumulativeVouchDividends(uint256 share) internal view returns (uint256) {
        return share.mul(vouchDividendsPerShare).div(vouchDividendsPerShareAccuracyFactor);
    }

    function getCumulativeVplsDividends(uint256 share) internal view returns (uint256) {
        return share.mul(vplsDividendsPerShare).div(vplsDividendsPerShareAccuracyFactor);
    }

    function getCumulativePlsDividends(uint256 share) internal view returns (uint256) {
        return share.mul(plsDividendsPerShare).div(plsDividendsPerShareAccuracyFactor);
    }

    function addShareholder(address shareholder) internal {
        shareholderVouchIndexes[shareholder] = shareholders.length;
        shareholderVplsIndexes[shareholder] = shareholders.length;
        shareholderPlsIndexes[shareholder] = shareholders.length;

        shareholders.push(shareholder);
    }

    function removeShareholder(address shareholder) internal {
        uint256 index = shareholderVouchIndexes[shareholder];
        uint256 lastIndex = shareholders.length - 1;

        if (index != lastIndex) {
            address lastAddr = shareholders[lastIndex];
            shareholders[index] = lastAddr;
            shareholderVouchIndexes[lastAddr] = index;
            shareholderVplsIndexes[lastAddr] = index;
            shareholderPlsIndexes[lastAddr] = index;
        }

        shareholders.pop();

        delete shareholderVouchIndexes[shareholder];
        delete shareholderVplsIndexes[shareholder];
        delete shareholderPlsIndexes[shareholder];
    }

    function setShare(address shareholder, uint256 amount) external override onlyVouch {
        if (shares[shareholder].amount > 0) {
            distributeVplsDividend(shareholder);
            distributeVouchDividend(shareholder);
            distributePlsDividend(shareholder);
        }
        if (amount > 0 && shares[shareholder].amount == 0) {
            addShareholder(shareholder);
        } else if (amount == 0 && shares[shareholder].amount > 0) {
            removeShareholder(shareholder);
        }
        totalShares = totalShares.sub(shares[shareholder].amount).add(amount);
        shares[shareholder].amount = amount;
        shares[shareholder].vouchTotalExcluded = getCumulativeVouchDividends(shares[shareholder].amount);
        shares[shareholder].vplsTotalExcluded = getCumulativeVplsDividends(shares[shareholder].amount);
        shares[shareholder].plsTotalExcluded = getCumulativePlsDividends(shares[shareholder].amount);
    }

    function distributeVouchDividend(address shareholder) internal {
        if (shares[shareholder].amount == 0) return;
        uint256 amount = getUnpaidVouchEarnings(shareholder);
        if (amount > 0) {
            totalVouchDividendsDistributed = totalVouchDividendsDistributed.add(amount);
            shareholderVouchClaims[shareholder] = block.timestamp;
            shares[shareholder].vouchTotalRealised = shares[shareholder].vouchTotalRealised.add(amount);
            shares[shareholder].vouchTotalExcluded = getCumulativeVouchDividends(shares[shareholder].amount);
            IERC20(address(VOUCH)).safeTransfer(shareholder, amount);
        }
    }

    function distributeVplsDividend(address shareholder) internal {
        if (shares[shareholder].amount == 0) return;
        uint256 amount = getUnpaidVplsEarnings(shareholder);
        if (amount > 0) {
            totalVplsDividendsDistributed = totalVplsDividendsDistributed.add(amount);
            shareholderVplsClaims[shareholder] = block.timestamp;
            shares[shareholder].vplsTotalRealised = shares[shareholder].vplsTotalRealised.add(amount);
            shares[shareholder].vplsTotalExcluded = getCumulativeVplsDividends(shares[shareholder].amount);
            IERC20(address(VPLS)).safeTransfer(shareholder, amount);
        }
    }

    function distributePlsDividend(address shareholder) internal {
        if (shares[shareholder].amount == 0) return;
        uint256 amount = getUnpaidPlsEarnings(shareholder);
        if (amount > 0) {
            totalPlsDividendsDistributed = totalPlsDividendsDistributed.add(amount);
            shareholderPlsClaims[shareholder] = block.timestamp;
            shares[shareholder].plsTotalRealised = shares[shareholder].plsTotalRealised.add(amount);
            shares[shareholder].plsTotalExcluded = getCumulativePlsDividends(shares[shareholder].amount);
            (bool success, ) = payable(shareholder).call{
                    value: amount
                }("");
                success;
        }
    }

    function depositPls(uint256[] memory distributionPercents) external payable nonReentrant {
        require(msg.value > 0, "Amount must be greater than 0");
        require(distributionPercents.length == 2, "Distribution percents must be an array of length 2");
        require(
            distributionPercents[0].add(distributionPercents[1]) == 10000,
            "The total of all combined distribution amounts must be 10000 for 100 percent."
        );

        uint256 plsToVouchHolders = msg.value.mul(distributionPercents[0]).div(denominator);
        uint256 plsToDistribute = msg.value.mul(distributionPercents[1]).div(denominator);
        

        if (plsToDistribute > 0) {
            accumulatedPlsForDistribution = accumulatedPlsForDistribution.add(plsToDistribute);
        }

        if (plsToVouchHolders > 0) {
            totalPlsDividends = totalPlsDividends.add(plsToVouchHolders);
            plsDividendsPerShare = plsDividendsPerShare.add(plsDividendsPerShareAccuracyFactor.mul(plsToVouchHolders).div(totalShares));
        }

        if (!distributionLock) {
            _triggerDistribution();
        }
    }

    function depositVouch(uint256 amount, uint256[] memory distributionPercents) external nonReentrant {
        require(amount > 0, "Amount must be greater than 0");
        require(distributionPercents.length == 2, "Distribution percents must be an array of length 2");
        require(
            distributionPercents[0].add(distributionPercents[1]) == 10000,
            "The total of all combined distribution amounts must be 10000 for 100 percent."
        );

        IERC20(address(VOUCH)).safeTransferFrom(msg.sender, address(this), amount);

        uint256 vouchToVouchHolders = amount.mul(distributionPercents[0]).div(denominator);
        uint256 vouchToDistribute = amount.mul(distributionPercents[1]).div(denominator);
        

        if (vouchToDistribute > 0) {
            accumulatedVouchForDistribution = accumulatedVouchForDistribution.add(vouchToDistribute);
        }

        if (vouchToVouchHolders > 0) {
            totalVouchDividends = totalVouchDividends.add(vouchToVouchHolders);
            vouchDividendsPerShare = vouchDividendsPerShare.add(vouchDividendsPerShareAccuracyFactor.mul(vouchToVouchHolders).div(totalShares));
        }

        if (!distributionLock) {
            _triggerDistribution();
        }
    }

    function depositVpls(uint256 amount, uint256[] memory distributionPercents) external nonReentrant {
        require(amount > 0, "Amount must be greater than 0");
        require(distributionPercents.length == 2, "Distribution percents must be an array of length 2");
        require(
            distributionPercents[0].add(distributionPercents[1]) == 10000,
            "The total of all combined distribution amounts must be 10000 for 100 percent."
        );

        IERC20(address(VPLS)).safeTransferFrom(msg.sender, address(this), amount);

        uint256 vplsToVouchHolders = amount.mul(distributionPercents[0]).div(denominator);
        uint256 vplsToDistribute = amount.mul(distributionPercents[1]).div(denominator);
        

        if (vplsToDistribute > 0) {
            accumulatedVplsForDistribution = accumulatedVplsForDistribution.add(vplsToDistribute);
        }

        if (vplsToVouchHolders > 0) {
            totalVplsDividends = totalVplsDividends.add(vplsToVouchHolders);
            vplsDividendsPerShare = vplsDividendsPerShare.add(vplsDividendsPerShareAccuracyFactor.mul(vplsToVouchHolders).div(totalShares));
        }

        if (!distributionLock) {
            _triggerDistribution();
        }
    }

    function depositFromVouch() external payable onlyVouch {
        totalPlsFromVouch = totalPlsFromVouch.add(msg.value);
        totalPlsReceived = totalPlsReceived.add(msg.value);
        _allocateDeposit(msg.value);
        if (!distributionLock) {
            _triggerDistribution();
        }
    }

    function depositFromValidators() external payable onlyValidators {
        totalPlsFromValidators = totalPlsFromValidators.add(msg.value);
        totalPlsReceived = totalPlsReceived.add(msg.value);
        _allocateDeposit(msg.value);
        if (!distributionLock) {
            _triggerDistribution();
        }
    }

    receive() external payable {
    }

    fallback() external payable {
    }
}
          

contracts/LiquidityManager.sol

//SPDX-License-Identifier: MIT

pragma solidity 0.8.20;

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./Utilities.sol";
import {DaoDistributor} from "./DaoDistributor.sol";

contract LiquidityManager is ReentrancyGuard {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    // dex routers
    IDEXFactory pulseV2Factory;
    address public lpLockerAddress;
    address public liquidityReceiver;
    IERC20 VPLS = IERC20(0x79BB3A0Ee435f957ce4f54eE8c3CFADc7278da0C);
    IERC20 WPLS = IERC20(0xA1077a294dDE1B09bB078844df40758a5D0f9a27);
    IDEXRouter pulseRouterV1 = IDEXRouter(0x98bf93ebf5c380C0e6Ae8e192A7e2AE08edAcc02);
    IDEXRouter pulseRouterV2 = IDEXRouter(0x165C3410fC91EF562C50559f7d2289fEbed552d9);
    IDEXRouter nineinchRouter = IDEXRouter(0xeB45a3c4aedd0F47F345fB4c8A1802BB5740d725);

    IERC20 public VOUCH;
    INetworkProposal networkProposal = INetworkProposal(0x7783D7040423f75aeF82a3Ec32ed366ca460Fa6c);
    VPLSMinter vplsMinter = VPLSMinter(0x2D7Dcc5A1d90d08D484E38a4C99B8394daaF4B9e);
    DaoDistributor public daoDistributor;

    uint256 public pendingPlsForVplsMints;
    uint256 public pendingPlsForVouchSwaps;

    modifier onlyAdmin() {
        require(networkProposal.isAdmin(msg.sender), "Caller must be admin");
        _;
    }

    modifier onlyDaoDistributor() {
        require(msg.sender == address(daoDistributor), "Caller must be DAO Distributor.");
        _;
    }


    event LiquidityAdded(address token, uint256 amountToken, uint256 amountPls);
    event SwapSuccess(uint256 amountToken, uint256 amountPls);
    event SwapFailed(string message);
    event ParameterUpdated();

    uint256 public totalPlsSwapped;
    uint256 public totalPlsAdded;

    // Percent calculations
    uint256 denominator = 10000;

    struct TokenLpSettings {
        address lpAddress;
        uint256 addPercent;
        uint256 lockPercent;
    }

    mapping(address => TokenLpSettings) public tokenLpSettings;

    constructor() {
        pulseV2Factory = IDEXFactory(pulseRouterV2.factory());

        tokenLpSettings[address(VPLS)].lpAddress = pulseV2Factory.getPair(pulseRouterV2.WPLS(), address(VPLS));

        if (tokenLpSettings[address(VPLS)].lpAddress == address(0)) {
            tokenLpSettings[address(VPLS)].lpAddress = pulseV2Factory.createPair(address(WPLS), address(VPLS));
        }

        liquidityReceiver = 0x65D41c77CC5394728E1502bBE3553Ed75ed715f5;
        lpLockerAddress = networkProposal.admin();
        IERC20(tokenLpSettings[address(VPLS)].lpAddress).approve(address(pulseRouterV2), type(uint256).max);
        WPLS.approve(address(pulseRouterV1), type(uint256).max);
        WPLS.approve(address(pulseRouterV2), type(uint256).max);
        WPLS.approve(address(nineinchRouter), type(uint256).max);

        VPLS.approve(address(pulseRouterV1), type(uint256).max);
        VPLS.approve(address(pulseRouterV2), type(uint256).max);
        VPLS.approve(address(nineinchRouter), type(uint256).max);

        // LP Settings
        tokenLpSettings[address(VPLS)].addPercent = 5000; // 50%
        tokenLpSettings[address(VPLS)].lockPercent = 10000; // 100%
    }

    function setLpLockerAddress(address _lpLockerAddress) external onlyAdmin {
        require(_lpLockerAddress != address(0), "invalid address");

        lpLockerAddress = _lpLockerAddress;

        emit ParameterUpdated();
    }

    function setDaoDistributorAddress(address _daoDistributor) external {
        require(_daoDistributor != address(0), "invalid address");
        if (address(daoDistributor) != address(0)) {
            require(networkProposal.isAdmin(msg.sender), "Caller must be admin");
        }
        daoDistributor = DaoDistributor(payable(_daoDistributor));

        emit ParameterUpdated();
    }

    function setVouchAddress(address _vouchAddress) external {
        require(_vouchAddress != address(0), "invalid address");
        if (address(VOUCH) != address(0)) {
            require(networkProposal.isAdmin(msg.sender), "Caller must be admin");
        }
        VOUCH = IERC20(_vouchAddress);

        VOUCH.approve(address(pulseRouterV1), type(uint256).max);
        VOUCH.approve(address(pulseRouterV2), type(uint256).max);
        VOUCH.approve(address(nineinchRouter), type(uint256).max);

        tokenLpSettings[address(VOUCH)].lpAddress = pulseV2Factory.getPair(address(WPLS), address(VOUCH));
        if (tokenLpSettings[address(VOUCH)].lpAddress == address(0)) {
            tokenLpSettings[address(VOUCH)].lpAddress = pulseV2Factory.createPair(address(WPLS), address(VOUCH));
        }

        tokenLpSettings[address(VOUCH)].addPercent = denominator - tokenLpSettings[address(VPLS)].addPercent;
        tokenLpSettings[address(VOUCH)].lockPercent = tokenLpSettings[address(VPLS)].lockPercent;

        emit ParameterUpdated();
    }

    function setLpPercents(
        uint256 _vouchAddPercent,
        uint256 _vouchLockPercent,
        uint256 _vplsAddPercent,
        uint256 _vplsLockPercent
    ) external onlyAdmin {
        tokenLpSettings[address(VOUCH)].addPercent = _vouchAddPercent;
        tokenLpSettings[address(VOUCH)].lockPercent = _vouchLockPercent;
        tokenLpSettings[address(VPLS)].addPercent = _vplsAddPercent;
        tokenLpSettings[address(VPLS)].lockPercent = _vplsLockPercent;

        require(
            tokenLpSettings[address(VOUCH)].addPercent.add(tokenLpSettings[address(VPLS)].addPercent) == denominator,
            "The total LP for adding must not exceed 10000 for 100 percent of available PLS."
        );

        require(
            tokenLpSettings[address(VOUCH)].lockPercent <= denominator &&
                tokenLpSettings[address(VPLS)].lockPercent <= denominator,
            "The total LP for locking must not exceed 10000 for 100 percent of available LP tokens."
        );

        emit ParameterUpdated();
    }

    function setLiquidityReceiver(address _liquidityReceiver) external onlyAdmin {
        require(_liquidityReceiver != address(this), "Cannot set liquidity receiver to this contract.");
        require(_liquidityReceiver != address(0), "Invalid address provided.");
        liquidityReceiver = _liquidityReceiver;

        emit ParameterUpdated();
    }

    function swapAddAndLockLiquidity(uint256 deadline) public onlyDaoDistributor {
        if (address(this).balance >= daoDistributor.liquidityDistributionThreshold()) {
            uint256 usableBalance = address(this).balance.sub(pendingPlsForVplsMints);
            uint256 amountVouchLiquidity = usableBalance.mul(tokenLpSettings[address(VOUCH)].addPercent.div(2)).div(
                denominator
            );

            uint256 amountVplsLiquidity = usableBalance.mul(tokenLpSettings[address(VPLS)].addPercent.div(2)).div(denominator);

            if (amountVouchLiquidity > 0 || pendingPlsForVouchSwaps > 0) {
                uint256 amountVouch = _swapPLSForToken(amountVouchLiquidity, address(VOUCH), deadline);
                if (amountVouch > 0) {
                    _addLiquidity(address(VOUCH), amountVouch, amountVouchLiquidity, deadline);
                }
            }
            
            if (amountVplsLiquidity > 0 || pendingPlsForVplsMints > 0) {
                uint256 amountVpls = _mintVplsWithPls(amountVplsLiquidity);
                if (amountVpls > 0) {
                    _addLiquidity(address(VPLS), amountVpls, amountVplsLiquidity, deadline);
                }
            }
        }
    }

    function swapAddAndLockLiquidityManual(uint256 amountPls, uint256 deadline) public onlyAdmin {
        uint256 amountVouchLiquidity = amountPls.mul(tokenLpSettings[address(VOUCH)].addPercent.div(2)).div(
            denominator
        );

        uint256 amountVplsLiquidity = amountPls.mul(tokenLpSettings[address(VPLS)].addPercent.div(2)).div(denominator);

        if (amountVouchLiquidity > 0 || pendingPlsForVouchSwaps > 0) {
            uint256 amountVouch = _swapPLSForToken(amountVouchLiquidity, address(VOUCH), deadline);
            if (amountVouch > 0) {
                _addLiquidity(address(VOUCH), amountVouch, amountVouchLiquidity, deadline);
            }
        }
        
        if (amountVplsLiquidity > 0 || pendingPlsForVplsMints > 0) {
            uint256 amountVpls = _mintVplsWithPls(amountVplsLiquidity);
            if (amountVpls > 0) {
                _addLiquidity(address(VPLS), amountVpls, amountVplsLiquidity, deadline);
            }
        }
    }

    function _swapPLSForToken(uint256 amountPls, address tokenAddress, uint256 deadline) private returns (uint256) {
        address[] memory path = new address[](2);
        path[0] = address(WPLS);
        path[1] = tokenAddress;

        uint256 swapAmount = amountPls.add(pendingPlsForVouchSwaps);
        pendingPlsForVouchSwaps = 0;

        IDEXRouter router = IDEXRouter(Utilities.getBestRouter(amountPls, path));

        uint256 vouchBalanceBefore = IERC20(tokenAddress).balanceOf(address(this));
        try router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: swapAmount}(0, path, address(this), deadline) {
            uint256 vouchBalanceAfter = IERC20(tokenAddress).balanceOf(address(this));
            totalPlsSwapped = totalPlsSwapped.add(swapAmount);
            emit SwapSuccess(vouchBalanceAfter.sub(vouchBalanceBefore), swapAmount);
            return vouchBalanceAfter.sub(vouchBalanceBefore);
        } catch Error(string memory e) {
            pendingPlsForVouchSwaps = pendingPlsForVouchSwaps.add(swapAmount);
            emit SwapFailed(string.concat("swapPLSForToken failed with error: ", e));
            return 0;
        }
    }

    function _mintVplsWithPls(uint256 amountVpls) internal returns (uint256 vplsGained) {
        uint256 totalAmount = amountVpls.add(pendingPlsForVplsMints);
        if (totalAmount >= vplsMinter.minDeposit()) {
            uint256 vplsBalanceBefore = IERC20(address(VPLS)).balanceOf(address(this));
            pendingPlsForVplsMints = 0;
            try vplsMinter.deposit{value: totalAmount}() {
                vplsGained = IERC20(address(VPLS)).balanceOf(address(this)).sub(vplsBalanceBefore);
            } catch {
                pendingPlsForVplsMints = pendingPlsForVplsMints.add(totalAmount);
            }
        } else {
            pendingPlsForVplsMints = pendingPlsForVplsMints.add(amountVpls);
        }
    }

    function _addLiquidity(address tokenAddress, uint256 amountToken, uint256 amountPls, uint256 deadline) private {
        uint256 amountTokenAdded;
        uint256 amountPlsAdded;
        uint256 liquidity;

        try
            pulseRouterV2.addLiquidityETH{value: amountPls}(
                tokenAddress,
                amountToken,
                0,
                0,
                address(this),
                deadline
            )
        returns (uint256 returnedAmountToken, uint256 returnedAmountPls, uint256 returnedLiquidity) {
            amountTokenAdded = returnedAmountToken;
            amountPlsAdded = returnedAmountPls;
            liquidity = returnedLiquidity;
            totalPlsAdded = totalPlsAdded.add(amountPlsAdded);

            uint256 lockAmount = liquidity.mul(tokenLpSettings[tokenAddress].lockPercent).div(denominator);
            if (lockAmount > 0) {
                IERC20(tokenLpSettings[tokenAddress].lpAddress).safeTransfer(lpLockerAddress, lockAmount);
            }

            if (liquidity - lockAmount > 0) {
                IERC20(tokenLpSettings[tokenAddress].lpAddress).safeTransfer(
                    liquidityReceiver,
                    liquidity - lockAmount
                );
            }

            emit LiquidityAdded(tokenAddress, amountTokenAdded, amountPlsAdded);
        } catch {
            emit LiquidityAdded(tokenAddress, 0, 0);
        }
    }

    function withdrawTokens(address _token) public onlyAdmin {
        require(_token != address(0), "Invalid parameter is provided.");

        IERC20 token = IERC20(_token);
        uint256 amount = token.balanceOf(address(this));
        token.safeTransfer(liquidityReceiver, amount);
    }

    /// @dev Allow contract to receive PLS
    receive() external payable {
    }

    /// @dev Allow contract to receive PLS
    fallback() external payable {
    }
}
          

contracts/Utilities.sol

//SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

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

    function WETH() external pure returns (address);

    function WPLS() 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 addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, 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 removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);

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

    function swapExactETHForTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable returns (uint256[] memory amounts);

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

    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;

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

    function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);
}

interface IDEXPair {
    event Approval(address indexed owner, address indexed spender, uint256 value);
    event Transfer(address indexed from, address indexed to, uint256 value);

    function name() external pure returns (string memory);

    function symbol() external pure returns (string memory);

    function decimals() external pure returns (uint8);

    function totalSupply() external view returns (uint256);

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

    function allowance(address owner, address spender) external view returns (uint256);

    function approve(address spender, uint256 value) external returns (bool);

    function transfer(address to, uint256 value) external returns (bool);

    function transferFrom(address from, address to, uint256 value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);

    function PERMIT_TYPEHASH() external pure returns (bytes32);

    function nonces(address owner) external view returns (uint256);

    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    event Mint(address indexed sender, uint256 amount0, uint256 amount1);
    event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint256 amount0In,
        uint256 amount1In,
        uint256 amount0Out,
        uint256 amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint256);

    function factory() external view returns (address);

    function token0() external view returns (address);

    function token1() external view returns (address);

    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);

    function price0CumulativeLast() external view returns (uint256);

    function price1CumulativeLast() external view returns (uint256);

    function kLast() external view returns (uint256);

    function mint(address to) external returns (uint256 liquidity);

    function burn(address to) external returns (uint256 amount0, uint256 amount1);

    function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external;

    function skim(address to) external;

    function sync() external;

    function initialize(address, address) external;
}

interface IDEXFactory {
    function createPair(address tokenA, address tokenB) external returns (address pair);
    function getPair(address tokenA, address tokenB) external view returns (address pair);
}

/**
 * Standard SafeMath, stripped down to just add/sub/mul/div
 */
library SafeMath {
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }
}

interface ILPTOKEN {
    function burn(uint256 amount) external;
}

interface INetworkProposal {
    function isAdmin(address adminAddress) external view returns (bool);
    function admin() external view returns (address);
    function getVoters() external view returns (address[] memory);
}

interface VPLSMinter {
    function deposit() external payable;
    function minDeposit() external returns (uint256);
}

interface IWPLS {
    function deposit() external payable;
    function withdraw(uint wad) external;
}

interface IVPLS {
    function burn(uint256 amount) external;
}

interface IVouch {
    function totalSupply() external view returns (uint256);
    function burn(uint256 amount) external;
}

interface IDaoDistributor {
    function setDistributionCriteria(
        uint256 _minVouchPeriod,
        uint256 _minVouchDistribution,
        uint256 _minVplsPeriod,
        uint256 _minVplsDistribution,
        uint256 _minPlsPeriod,
        uint256 _minPlsDistribution
    ) external;

    function setDistributionThresholds(
        uint256 _vouchForDistributionThreshold,
        uint256 _vplsForDistributionThreshold,
        uint256 _plsForDistributionThreshold,
        uint256 _swapThresholdForTokens,
        uint256 _plsSendThreshold,
        uint256 _liquidityDistributionThreshold
    ) external;

    function setDistributionAmounts(
        uint256[9] calldata feeParams
    ) external;

    function setVouchRewards(
        uint256 _vouchHoldersPercent,
        uint256 _validatorsPercent,
        uint256 _votersPercent,
        uint256 _stakersPercent,
        uint256 _burnPercent
    ) external;

    function setVplsRewards(
        uint256 _vouchHoldersPercent,
        uint256 _validatorsPercent,
        uint256 _votersPercent,
        uint256 _stakersPercent,
        uint256 _burnPercent
    ) external;

    function setPlsRewards(
        uint256 _vouchHoldersPercent,
        uint256 _validatorsPercent,
        uint256 _votersPercent,
        uint256 _stakersPercent
    ) external;

    function setRecipientAddresses(
        address _validators,
        address _masterValidator,
        address _feePool,
        address _safu,
        address _daoTreasury,
        address _voters,
        address _stakers
    ) external;

    function setDistributorSettings(uint256 _vouchGas, uint256 _vplsGas, uint256 _plsGas) external;

    function setShare(address shareholder, uint256 amount) external;

    function processVouch(uint256 gas) external;

    function processVpls(uint256 gas) external;
    
    function processPls(uint256 gas) external;

    function claimDividend() external;

    function getUnpaidVouchEarnings(address shareholder) external view returns (uint256);

    function getUnpaidVplsEarnings(address shareholder) external view returns (uint256);
    
    function getUnpaidPlsEarnings(address shareholder) external view returns (uint256);

    function setVouchAddress(address _vouchAddress) external;

    function depositFromVouch() external payable;

    function depositFromValidators() external payable;
}

library Utilities {
    address public constant pulseRouterV1Address = 0x98bf93ebf5c380C0e6Ae8e192A7e2AE08edAcc02;
    address public constant pulseRouterV2Address = 0x165C3410fC91EF562C50559f7d2289fEbed552d9;
    address public constant nineinchRouterAddress = 0xeB45a3c4aedd0F47F345fB4c8A1802BB5740d725;

    function getBestRouter(uint256 amountIn, address[] memory path) public view returns (address bestRouter) {
        address[] memory routers = new address[](3);
        routers[0] = pulseRouterV1Address;
        routers[1] = pulseRouterV2Address;
        routers[2] = nineinchRouterAddress;

        uint256 bestAmountOut = 0;
        bestRouter = pulseRouterV2Address;

        for (uint256 i = 0; i < routers.length; i++) {
            try IDEXRouter(routers[i]).getAmountsOut(amountIn, path) returns (uint256[] memory amountsOut) {
                uint256 amountOut = amountsOut[amountsOut.length - 1];
                if (amountOut > bestAmountOut) {
                    bestAmountOut = amountOut;
                    bestRouter = routers[i];
                }
            } catch {
                continue;
            }
        }
    }
}
          

contracts/ValidatorFeeDepositor.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

import {Vouch} from "./Vouch.sol";
import {DaoDistributor} from "./DaoDistributor.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "./Utilities.sol";

contract ValidatorFeeDepositor is ReentrancyGuard {
    INetworkProposal public networkProposal;
    Vouch public vouch;

    uint256 public distributeThreshold = 200_000e18;

    modifier onlyAdmin() {
        require(networkProposal.isAdmin(msg.sender), "Caller must be admin");
        _;
    }

    constructor() {
        networkProposal = INetworkProposal(0x7783D7040423f75aeF82a3Ec32ed366ca460Fa6c);
    }

    function depositToDistributor() external nonReentrant {
        if (address(this).balance >= distributeThreshold) {
            DaoDistributor(vouch.distributor()).depositFromValidators{value: address(this).balance}();
        }
    }

    function setDistributeThreshold(uint256 _distributeThreshold) external onlyAdmin {
        distributeThreshold = _distributeThreshold;
    }

    function setVouchAddress(address _vouchAddress) external {
        require(_vouchAddress != address(0), "invalid address");
        if (address(vouch) != address(0)) {
            require(networkProposal.isAdmin(msg.sender), "Caller must be admin");
        }
        vouch = Vouch(payable(_vouchAddress));
    }
    
    receive() external payable {
    }
}
          

Compiler Settings

{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata"],"":["ast"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{"contracts/Utilities.sol":{"Utilities":"0xe2ac858c675a3ed81ab8042eb62cb81cd34c5878"}},"evmVersion":"paris"}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_distributorAddress","internalType":"address"},{"type":"address","name":"_pulseRouterV1","internalType":"address"},{"type":"address","name":"_pulseRouterV2","internalType":"address"},{"type":"address","name":"_nineinchRouter","internalType":"address"}]},{"type":"error","name":"InvalidShortString","inputs":[]},{"type":"error","name":"StringTooLong","inputs":[{"type":"string","name":"str","internalType":"string"}]},{"type":"event","name":"Approval","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"spender","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"DelegateChanged","inputs":[{"type":"address","name":"delegator","internalType":"address","indexed":true},{"type":"address","name":"fromDelegate","internalType":"address","indexed":true},{"type":"address","name":"toDelegate","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"DelegateVotesChanged","inputs":[{"type":"address","name":"delegate","internalType":"address","indexed":true},{"type":"uint256","name":"previousBalance","internalType":"uint256","indexed":false},{"type":"uint256","name":"newBalance","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"EIP712DomainChanged","inputs":[],"anonymous":false},{"type":"event","name":"Launched","inputs":[{"type":"uint256","name":"blockNumber","internalType":"uint256","indexed":false},{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ParameterUpdated","inputs":[],"anonymous":false},{"type":"event","name":"ProcessPlsFailed","inputs":[],"anonymous":false},{"type":"event","name":"ProcessVouchFailed","inputs":[],"anonymous":false},{"type":"event","name":"ProcessVplsFailed","inputs":[],"anonymous":false},{"type":"event","name":"SetShareFailed","inputs":[{"type":"address","name":"holder","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"SwapBackFailed","inputs":[{"type":"string","name":"message","internalType":"string","indexed":false}],"anonymous":false},{"type":"event","name":"SwapBackSuccess","inputs":[{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ValidatorFeeDepositorFailed","inputs":[],"anonymous":false},{"type":"function","stateMutability":"pure","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"CLOCK_MODE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DOMAIN_SEPARATOR","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"_maxTxAmount","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addPair","inputs":[{"type":"address","name":"pair","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"allowance","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"spender","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"antiSwapback","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"approve","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"basicTransfer","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"burn","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct ERC20Votes.Checkpoint","components":[{"type":"uint32","name":"fromBlock","internalType":"uint32"},{"type":"uint224","name":"votes","internalType":"uint224"}]}],"name":"checkpoints","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"uint32","name":"pos","internalType":"uint32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint48","name":"","internalType":"uint48"}],"name":"clock","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"deadAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"decimals","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"decreaseAllowance","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"subtractedValue","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"delegate","inputs":[{"type":"address","name":"delegatee","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"delegateBySig","inputs":[{"type":"address","name":"delegatee","internalType":"address"},{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"uint256","name":"expiry","internalType":"uint256"},{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"delegates","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract DaoDistributor"}],"name":"distributor","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes1","name":"fields","internalType":"bytes1"},{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"version","internalType":"string"},{"type":"uint256","name":"chainId","internalType":"uint256"},{"type":"address","name":"verifyingContract","internalType":"address"},{"type":"bytes32","name":"salt","internalType":"bytes32"},{"type":"uint256[]","name":"extensions","internalType":"uint256[]"}],"name":"eip712Domain","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"feeDenominator","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"feesOnNormalTransfers","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getAllPairs","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getPastTotalSupply","inputs":[{"type":"uint256","name":"timepoint","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getPastVotes","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"uint256","name":"timepoint","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getTotalFee","inputs":[{"type":"bool","name":"selling","internalType":"bool"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getVotes","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"increaseAllowance","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"addedValue","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"initialSupply","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isDividendExempt","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isFeeExempt","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isTxLimitExempt","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"launch","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"launchedAt","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract INetworkProposal"}],"name":"networkProposal","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"nineinchPair","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IDEXRouter"}],"name":"nineinchRouter","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"nonces","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"numCheckpoints","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"pairs","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"permit","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"},{"type":"uint256","name":"deadline","internalType":"uint256"},{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IDEXRouter"}],"name":"pulseRouterV1","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IDEXRouter"}],"name":"pulseRouterV2","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"pulseV1Pair","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"pulseV2Pair","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeLastPair","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removePair","inputs":[{"type":"address","name":"pair","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setAntiSwapbackAddress","inputs":[{"type":"address","name":"_antiSwapbackAddress","internalType":"address"},{"type":"bool","name":"flag","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBasicTransferAddress","inputs":[{"type":"address","name":"_basicTransferAddress","internalType":"address"},{"type":"bool","name":"flag","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDistributor","inputs":[{"type":"address","name":"_distributor","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFees","inputs":[{"type":"uint256","name":"_totalBuyFee","internalType":"uint256"},{"type":"uint256","name":"_totalSellFee","internalType":"uint256"},{"type":"bool","name":"_feesOnNormalTransfers","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setIsDividendExempt","inputs":[{"type":"address","name":"holder","internalType":"address"},{"type":"bool","name":"exempt","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setIsFeeExempt","inputs":[{"type":"address","name":"holder","internalType":"address"},{"type":"bool","name":"exempt","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setIsTxLimitExempt","inputs":[{"type":"address","name":"holder","internalType":"address"},{"type":"bool","name":"exempt","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setSwapBackSettings","inputs":[{"type":"bool","name":"_enabled","internalType":"bool"},{"type":"uint256","name":"_percent","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTxLimit","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"swapEnabled","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"swapThreshold","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"swapThresholdDenominator","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"swapThresholdPercent","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalBuyFee","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSellFee","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transfer","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"wplsAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"zeroAddress","inputs":[]},{"type":"receive","stateMutability":"payable"}]
              

Contract Creation Code

Verify & Publish
0x6101606040526c01431e0fae6d7217caa0000000600c556101f4600d819055600e55612710600f55670de0b6b3a764000060105565b5e620f48000601155601280546001600160a81b03191674a1077a294dde1b09bb078844df40758a5d0f9a27011790556013805461dead6001600160a01b0319918216179091556014805482169055601d8054600160a01b60ff60a01b19909116179055601f8054610100600160a81b03191674d20a9202d2a69cb0e6d240e6dda7257d4bae39ec0017905560208054737783d7040423f75aef82a3ec32ed366ca460fa6c9216919091179055348015620000ee57600080fd5b506040516200644c3803806200644c833981016040819052620001119162001522565b604051806040016040528060058152602001640acdeeac6d60db1b81525080604051806040016040528060018152602001603160f81b815250604051806040016040528060058152602001640acdeeac6d60db1b815250604051806040016040528060058152602001640ac9eaa86960db1b81525081600390816200019791906200162e565b506004620001a682826200162e565b50620001b89150839050600562000df4565b61012052620001c981600662000df4565b61014052815160208084019190912060e052815190820120610100524660a0526200025760e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60805250503060c05250601d80546001600160a01b0319166001600160a01b03868116919091179091558316620002a3577398bf93ebf5c380c0e6ae8e192a7e2ae08edacc02620002a5565b825b601580546001600160a01b0319166001600160a01b039283161790558216620002e35773165c3410fc91ef562c50559f7d2289febed552d9620002e5565b815b601680546001600160a01b0319166001600160a01b039283161790558116620003235773eb45a3c4aedd0f47f345fb4c8a1802bb5740d72562000325565b805b601780546001600160a01b0319166001600160a01b039283161790556015546040805163c45a015560e01b81529051919092169163c45a01559160048083019260209291908290030181865afa15801562000384573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003aa9190620016fa565b60125460405163e6a4390560e01b81526001600160a01b036101009092048216600482015230602482015291169063e6a4390590604401602060405180830381865afa158015620003ff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620004259190620016fa565b601880546001600160a01b0319166001600160a01b039290921691821790556200056157601560009054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200049d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620004c39190620016fa565b6012546040516364e329cb60e11b81526001600160a01b036101009092048216600482015230602482015291169063c9c65396906044016020604051808303816000875af11580156200051a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005409190620016fa565b601880546001600160a01b0319166001600160a01b03929092169190911790555b601854601b80546001810182556000919091526000805160206200640c8339815191520180546001600160a01b0319166001600160a01b039283161790556016546040805163c45a015560e01b81529051919092169163c45a01559160048083019260209291908290030181865afa158015620005e2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620006089190620016fa565b60125460405163e6a4390560e01b81526001600160a01b036101009092048216600482015230602482015291169063e6a4390590604401602060405180830381865afa1580156200065d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620006839190620016fa565b601980546001600160a01b0319166001600160a01b03929092169182179055620007bf57601660009054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015620006fb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620007219190620016fa565b6012546040516364e329cb60e11b81526001600160a01b036101009092048216600482015230602482015291169063c9c65396906044016020604051808303816000875af115801562000778573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200079e9190620016fa565b601980546001600160a01b0319166001600160a01b03929092169190911790555b601954601b80546001810182556000919091526000805160206200640c8339815191520180546001600160a01b0319166001600160a01b039283161790556017546040805163c45a015560e01b81529051919092169163c45a01559160048083019260209291908290030181865afa15801562000840573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620008669190620016fa565b60125460405163e6a4390560e01b81526001600160a01b036101009092048216600482015230602482015291169063e6a4390590604401602060405180830381865afa158015620008bb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620008e19190620016fa565b601a80546001600160a01b0319166001600160a01b0392909216918217905562000a1d57601760009054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000959573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200097f9190620016fa565b6012546040516364e329cb60e11b81526001600160a01b036101009092048216600482015230602482015291169063c9c65396906044016020604051808303816000875af1158015620009d6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620009fc9190620016fa565b601a80546001600160a01b0319166001600160a01b03929092169190911790555b601a54601b80546001810182556000919091526000805160206200640c8339815191520180546001600160a01b0319166001600160a01b0392831617905560155462000a6f9130911660001962000e2d565b60165462000a8b9030906001600160a01b031660001962000e2d565b60175462000aa79030906001600160a01b031660001962000e2d565b600160216000601d60009054906101000a90046001600160a01b03166001600160a01b031663338274386040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000b01573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000b279190620016fa565b6001600160a01b03908116825260208083019390935260409182016000908120805495151560ff199687161790553080825260218552838220805487166001908117909155601d80548516845285842080548916831790559183526022808752858420805489168317905582548516845285842080549098168217909755905484516306704e8760e31b81529451919695929493169263338274389260048083019391928290030181865afa15801562000be5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000c0b9190620016fa565b6001600160a01b03908116825260208083019390935260409182016000908120805495151560ff19968716179055601854821681526023808552838220805487166001908117909155601954841683528483208054881682179055601a54841683528483208054881682179055601d80548516845285842080549098168217909755955484516306704e8760e31b815294519195929493169263338274389260048083019391928290030181865afa15801562000ccc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000cf29190620016fa565b6001600160a01b03908116825260208083019390935260409182016000908120805495151560ff19968716179055601354821681526023845282812080548616600190811790915530825290839020805490951617909355815481516303e1469160e61b8152915162000dc594919091169263f851a44092600480820193918290030181865afa15801562000d8b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000db19190620016fa565b6c01431e0fae6d7217caa000000062000f59565b60105460115460025462000dda919062001730565b62000de691906200174a565b601e55506200180e92505050565b600060208351101562000e145762000e0c8362000f6f565b905062000e27565b8162000e2184826200162e565b5060ff90505b92915050565b6001600160a01b03831662000e955760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084015b60405180910390fd5b6001600160a01b03821662000ef85760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840162000e8c565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b62000f65828262000fb2565b5050565b60025490565b600080829050601f8151111562000f9d578260405163305a27a960e01b815260040162000e8c91906200176d565b805162000faa82620017bd565b179392505050565b62000fbe82826200105a565b6001600160e01b0362000fd262000f698216565b11156200103b5760405162461bcd60e51b815260206004820152603060248201527f4552433230566f7465733a20746f74616c20737570706c79207269736b73206f60448201526f766572666c6f77696e6720766f74657360801b606482015260840162000e8c565b62001054600b6200230b6200112760201b17836200113c565b50505050565b6001600160a01b038216620010b25760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640162000e8c565b8060026000828254620010c69190620017e2565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a362000f6560008383620012bd565b6000620011358284620017e2565b9392505050565b825460009081908181156200118b5760008781526020902082016000190160408051808201909152905463ffffffff8116825264010000000090046001600160e01b03166020820152620011a0565b60408051808201909152600080825260208201525b905080602001516001600160e01b03169350620011be84868860201c565b9250600082118015620011df5750805163ffffffff1665ffffffffffff4216145b156200122857620011f083620012ce565b60008881526020902083016000190180546001600160e01b03929092166401000000000263ffffffff909216919091179055620012ae565b8660405180604001604052806200125662001248620012ca60201b60201c565b65ffffffffffff166200133d565b63ffffffff1681526020016200126c86620012ce565b6001600160e01b0390811690915282546001810184556000938452602093849020835194909301519091166401000000000263ffffffff909316929092179101555b5050935093915050565b505050565b620012b8838383620013a4565b4290565b60006001600160e01b03821115620013395760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20326044820152663234206269747360c81b606482015260840162000e8c565b5090565b600063ffffffff821115620013395760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203360448201526532206269747360d01b606482015260840162000e8c565b6001600160a01b03838116600090815260096020526040808220548584168352912054620012b892918216911683818314801590620013e35750600081115b15620012b8576001600160a01b0383161562001470576001600160a01b0383166000908152600a60209081526040822082916200142d9190620014fb901b6200231717856200113c565b91509150846001600160a01b03166000805160206200642c833981519152838360405162001465929190918252602082015260400190565b60405180910390a250505b6001600160a01b03821615620012b8576001600160a01b0382166000908152600a6020908152604082208291620014b4919062001127901b6200230b17856200113c565b91509150836001600160a01b03166000805160206200642c8339815191528383604051620014ec929190918252602082015260400190565b60405180910390a25050505050565b6000620011358284620017f8565b6001600160a01b03811681146200151f57600080fd5b50565b600080600080608085870312156200153957600080fd5b8451620015468162001509565b6020860151909450620015598162001509565b60408601519093506200156c8162001509565b60608601519092506200157f8162001509565b939692955090935050565b634e487b7160e01b600052604160045260246000fd5b600181811c90821680620015b557607f821691505b602082108103620015d657634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620012b857600081815260208120601f850160051c81016020861015620016055750805b601f850160051c820191505b81811015620016265782815560010162001611565b505050505050565b81516001600160401b038111156200164a576200164a6200158a565b62001662816200165b8454620015a0565b84620015dc565b602080601f8311600181146200169a5760008415620016815750858301515b600019600386901b1c1916600185901b17855562001626565b600085815260208120601f198616915b82811015620016cb57888601518255948401946001909101908401620016aa565b5085821015620016ea5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6000602082840312156200170d57600080fd5b8151620011358162001509565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141762000e275762000e276200171a565b6000826200176857634e487b7160e01b600052601260045260246000fd5b500490565b600060208083528351808285015260005b818110156200179c578581018301518582016040015282016200177e565b506000604082860101526040601f19601f8301168501019250505092915050565b80516020808301519190811015620015d65760001960209190910360031b1b16919050565b8082018082111562000e275762000e276200171a565b8181038181111562000e275762000e276200171a565b60805160a05160c05160e051610100516101205161014051614ba36200186960003960006115370152600061150c01526000612d7d01526000612d5501526000612cb001526000612cda01526000612d040152614ba36000f3fe6080604052600436106103fd5760003560e01c80636fcfff4511610213578063a9059cbb11610123578063d505accf116100ab578063f1f3bca31161007a578063f1f3bca314610c9e578063f35647c214610cbe578063f708a64f14610cde578063f800ece914610cfe578063f84ba65d14610d2057600080fd5b8063d505accf14610bf4578063dd62ed3e14610c14578063df20fd4914610c34578063f1127ed814610c5457600080fd5b8063bf56b371116100f2578063bf56b37114610b5e578063bfe1092814610b74578063c0b4647014610b94578063c2b7bbb614610bb4578063c3cda52014610bd457600080fd5b8063a9059cbb14610ae8578063af6c9c1d14610b08578063b91ac78814610b28578063bafb140314610b4857600080fd5b80638d5396e9116101a6578063937d0a3a11610175578063937d0a3a14610a5d57806395d89b4114610a7d5780639ab24eb014610a925780639d9241ec14610ab2578063a457c2d714610ac857600080fd5b80638d5396e9146109da5780638e539e8c146109fa5780638f52f46514610a1a57806391ddadf414610a3a57600080fd5b80637d1db4a5116101e25780637d1db4a51461094c5780637ecebe001461096257806384b0196e146109825780638b42507f146109aa57600080fd5b80636fcfff45146108a157806370a08231146108d657806375619ab51461090c578063761ce8411461092c57600080fd5b8063395093511161030e5780634f15999a116102a15780635c19a95c116102705780635c19a95c146108005780635c85974f14610820578063658d4b7f146108405780636d2b4940146108605780636ddd17131461088057600080fd5b80634f15999a14610777578063587cde1e1461079757806359b107b9146107d05780635abe6711146107e657600080fd5b80634355855a116102dd5780634355855a146106cb5780634bf5d7e9146106fb5780634e0df270146107325780634e69e92e1461075257600080fd5b8063395093511461063b5780633a46b1a81461065b5780633f4218e01461067b57806342966c68146106ab57600080fd5b8063180b0d7e1161039157806330f9713a1161036057806330f9713a14610589578063313ce567146105b95780633644e515146105d5578063378dc3dc146105ea57806338e2cf001461060b57600080fd5b8063180b0d7e1461051e57806318160ddd1461053457806323b872dd1461054957806327c8f8351461056957600080fd5b80630930907b116103cd5780630930907b14610480578063095ea7b3146104b8578063096472d8146104e85780630d1554bf146104fe57600080fd5b806293dc141461040957806301339c21146104205780630445b6671461043557806306fdde031461045e57600080fd5b3661040457005b600080fd5b34801561041557600080fd5b5061041e610d40565b005b34801561042c57600080fd5b5061041e610e1e565b34801561044157600080fd5b5061044b601e5481565b6040519081526020015b60405180910390f35b34801561046a57600080fd5b50610473610f2c565b6040516104559190614444565b34801561048c57600080fd5b506014546104a0906001600160a01b031681565b6040516001600160a01b039091168152602001610455565b3480156104c457600080fd5b506104d86104d336600461446c565b610fbe565b6040519015158152602001610455565b3480156104f457600080fd5b5061044b60105481565b34801561050a57600080fd5b506019546104a0906001600160a01b031681565b34801561052a57600080fd5b5061044b600f5481565b34801561054057600080fd5b5060025461044b565b34801561055557600080fd5b506104d8610564366004614498565b610fd8565b34801561057557600080fd5b506013546104a0906001600160a01b031681565b34801561059557600080fd5b506104d86105a43660046144d9565b60246020526000908152604090205460ff1681565b3480156105c557600080fd5b5060405160128152602001610455565b3480156105e157600080fd5b5061044b610ffc565b3480156105f657600080fd5b5061044b6c01431e0fae6d7217caa000000081565b34801561061757600080fd5b506104d86106263660046144d9565b60256020526000908152604090205460ff1681565b34801561064757600080fd5b506104d861065636600461446c565b61100b565b34801561066757600080fd5b5061044b61067636600461446c565b61102d565b34801561068757600080fd5b506104d86106963660046144d9565b60216020526000908152604090205460ff1681565b3480156106b757600080fd5b5061041e6106c63660046144f6565b6110ab565b3480156106d757600080fd5b506104d86106e63660046144d9565b60236020526000908152604090205460ff1681565b34801561070757600080fd5b5060408051808201909152600e81526d06d6f64653d74696d657374616d760941b6020820152610473565b34801561073e57600080fd5b50601a546104a0906001600160a01b031681565b34801561075e57600080fd5b506012546104a09061010090046001600160a01b031681565b34801561078357600080fd5b506016546104a0906001600160a01b031681565b3480156107a357600080fd5b506104a06107b23660046144d9565b6001600160a01b039081166000908152600960205260409020541690565b3480156107dc57600080fd5b5061044b600d5481565b3480156107f257600080fd5b506012546104d89060ff1681565b34801561080c57600080fd5b5061041e61081b3660046144d9565b6110d8565b34801561082c57600080fd5b5061041e61083b3660046144f6565b6110e5565b34801561084c57600080fd5b5061041e61085b36600461451d565b6111ca565b34801561086c57600080fd5b506017546104a0906001600160a01b031681565b34801561088c57600080fd5b50601d546104d890600160a01b900460ff1681565b3480156108ad57600080fd5b506108c16108bc3660046144d9565b61127d565b60405163ffffffff9091168152602001610455565b3480156108e257600080fd5b5061044b6108f13660046144d9565b6001600160a01b031660009081526020819052604090205490565b34801561091857600080fd5b5061041e6109273660046144d9565b61129f565b34801561093857600080fd5b5061041e610947366004614556565b611391565b34801561095857600080fd5b5061044b600c5481565b34801561096e57600080fd5b5061044b61097d3660046144d9565b6114f3565b34801561098e57600080fd5b506109976114fe565b604051610455979695949392919061458f565b3480156109b657600080fd5b506104d86109c53660046144d9565b60226020526000908152604090205460ff1681565b3480156109e657600080fd5b506015546104a0906001600160a01b031681565b348015610a0657600080fd5b5061044b610a153660046144f6565b611587565b348015610a2657600080fd5b5061041e610a3536600461451d565b6115e7565b348015610a4657600080fd5b5060405165ffffffffffff42168152602001610455565b348015610a6957600080fd5b506018546104a0906001600160a01b031681565b348015610a8957600080fd5b5061047361169a565b348015610a9e57600080fd5b5061044b610aad3660046144d9565b6116a9565b348015610abe57600080fd5b5061044b600e5481565b348015610ad457600080fd5b506104d8610ae336600461446c565b61172b565b348015610af457600080fd5b506104d8610b0336600461446c565b6117a6565b348015610b1457600080fd5b5061041e610b233660046144d9565b6117b4565b348015610b3457600080fd5b506104a0610b433660046144f6565b6119ee565b348015610b5457600080fd5b5061044b60115481565b348015610b6a57600080fd5b5061044b601c5481565b348015610b8057600080fd5b50601d546104a0906001600160a01b031681565b348015610ba057600080fd5b506020546104a0906001600160a01b031681565b348015610bc057600080fd5b5061041e610bcf3660046144d9565b611a18565b348015610be057600080fd5b5061041e610bef36600461463b565b611b02565b348015610c0057600080fd5b5061041e610c0f366004614695565b611c38565b348015610c2057600080fd5b5061044b610c2f366004614703565b611d9c565b348015610c4057600080fd5b5061041e610c4f366004614731565b611dc7565b348015610c6057600080fd5b50610c74610c6f36600461474f565b611ea5565b60408051825163ffffffff1681526020928301516001600160e01b03169281019290925201610455565b348015610caa57600080fd5b5061044b610cb9366004614786565b611f29565b348015610cca57600080fd5b5061041e610cd936600461451d565b611f59565b348015610cea57600080fd5b5061041e610cf936600461451d565b61200c565b348015610d0a57600080fd5b50610d136121f7565b60405161045591906147e7565b348015610d2c57600080fd5b5061041e610d3b36600461451d565b612258565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa158015610d88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dac91906147fa565b610dd15760405162461bcd60e51b8152600401610dc890614817565b60405180910390fd5b601b805480610de257610de2614845565b600082815260208120820160001990810180546001600160a01b0319169055909101909155604051600080516020614b4e8339815191529190a1565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa158015610e66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8a91906147fa565b610ea65760405162461bcd60e51b8152600401610dc890614817565b601c5415610eea5760405162461bcd60e51b815260206004820152601160248201527020b63932b0b23c903630bab731b432b21760791b6044820152606401610dc8565b42601c8190556040805143815260208101929092527f87dcd6626ffde0faf682a10e7b64aff36ea73a5470d5fa6cc7ebd372e4b19001910160405180910390a1565b606060038054610f3b9061485b565b80601f0160208091040260200160405190810160405280929190818152602001828054610f679061485b565b8015610fb45780601f10610f8957610100808354040283529160200191610fb4565b820191906000526020600020905b815481529060010190602001808311610f9757829003601f168201915b5050505050905090565b600033610fcc818585612323565b60019150505b92915050565b600033610fe6858285612447565b610ff18585856124c1565b506001949350505050565b6000611006612ca3565b905090565b600033610fcc81858561101e8383611d9c565b61102891906148a5565b612323565b60004265ffffffffffff1682106110825760405162461bcd60e51b815260206004820152601960248201527804552433230566f7465733a20667574757265206c6f6f6b757603c1b6044820152606401610dc8565b6001600160a01b0383166000908152600a602052604090206110a49083612dd1565b9392505050565b6110b53382612eba565b6010546011546002546110c891906148b8565b6110d291906148e5565b601e5550565b6110e23382612ec4565b50565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa15801561112d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115191906147fa565b61116d5760405162461bcd60e51b8152600401610dc890614817565b6107d061117960025490565b61118391906148e5565b8110156111c55760405162461bcd60e51b815260206004820152601060248201526f5458206c696d697420746f6f206c6f7760801b6044820152606401610dc8565b600c55565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa158015611212573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123691906147fa565b6112525760405162461bcd60e51b8152600401610dc890614817565b6001600160a01b03919091166000908152602160205260409020805460ff1916911515919091179055565b6001600160a01b0381166000908152600a6020526040812054610fd290612f3d565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa1580156112e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061130b91906147fa565b6113275760405162461bcd60e51b8152600401610dc890614817565b6001600160a01b03811661136f5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610dc8565b601d80546001600160a01b0319166001600160a01b0392909216919091179055565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa1580156113d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113fd91906147fa565b6114195760405162461bcd60e51b8152600401610dc890614817565b600d839055600e8290556103e88311156114755760405162461bcd60e51b815260206004820152601d60248201527f427579206665652068617320612031302070657263656e74206d61782e0000006044820152606401610dc8565b6103e8600e5411156114c95760405162461bcd60e51b815260206004820152601e60248201527f53656c6c206665652068617320612031302070657263656e74206d61782e00006044820152606401610dc8565b6012805460ff1916821515179055604051600080516020614b4e83398151915290600090a1505050565b6000610fd282612fa6565b6000606080828080836115327f00000000000000000000000000000000000000000000000000000000000000006005612fc4565b61155d7f00000000000000000000000000000000000000000000000000000000000000006006612fc4565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b60004265ffffffffffff1682106115dc5760405162461bcd60e51b815260206004820152601960248201527804552433230566f7465733a20667574757265206c6f6f6b757603c1b6044820152606401610dc8565b610fd2600b83612dd1565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa15801561162f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165391906147fa565b61166f5760405162461bcd60e51b8152600401610dc890614817565b6001600160a01b03919091166000908152602460205260409020805460ff1916911515919091179055565b606060048054610f3b9061485b565b6001600160a01b0381166000908152600a60205260408120548015611718576001600160a01b0383166000908152600a60205260409020805460001983019081106116f6576116f6614907565b60009182526020909120015464010000000090046001600160e01b031661171b565b60005b6001600160e01b03169392505050565b600033816117398286611d9c565b9050838110156117995760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610dc8565b610ff18286868403612323565b600033610fcc8185856124c1565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa1580156117fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061182091906147fa565b61183c5760405162461bcd60e51b8152600401610dc890614817565b601b54806118775760405162461bcd60e51b81526020600482015260086024820152674e6f20706169727360c01b6044820152606401610dc8565b8060005b828110156118d457836001600160a01b0316601b82815481106118a0576118a0614907565b6000918252602090912001546001600160a01b0316036118c2578091506118d4565b806118cc8161491d565b91505061187b565b508181106119155760405162461bcd60e51b815260206004820152600e60248201526d14185a5c881b9bdd08199bdd5b9960921b6044820152606401610dc8565b611920600183614936565b811461199e57601b611933600184614936565b8154811061194357611943614907565b600091825260209091200154601b80546001600160a01b03909216918390811061196f5761196f614907565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b601b8054806119af576119af614845565b600082815260208120820160001990810180546001600160a01b0319169055909101909155604051600080516020614b4e8339815191529190a1505050565b601b81815481106119fe57600080fd5b6000918252602090912001546001600160a01b0316905081565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa158015611a60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a8491906147fa565b611aa05760405162461bcd60e51b8152600401610dc890614817565b601b805460018101825560009182527f3ad8aa4f87544323a9d1e5dd902f40c356527a7955687113db5f9a85ad579dc10180546001600160a01b0319166001600160a01b038416179055604051600080516020614b4e8339815191529190a150565b83421115611b525760405162461bcd60e51b815260206004820152601d60248201527f4552433230566f7465733a207369676e617475726520657870697265640000006044820152606401610dc8565b604080517fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60208201526001600160a01b038816918101919091526060810186905260808101859052600090611bcc90611bc49060a0016040516020818303038152906040528051906020012061306f565b85858561309c565b9050611bd7816130c4565b8614611c255760405162461bcd60e51b815260206004820152601960248201527f4552433230566f7465733a20696e76616c6964206e6f6e6365000000000000006044820152606401610dc8565b611c2f8188612ec4565b50505050505050565b83421115611c885760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610dc8565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9888888611cb78c6130c4565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000611d128261306f565b90506000611d228287878761309c565b9050896001600160a01b0316816001600160a01b031614611d855760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610dc8565b611d908a8a8a612323565b50505050505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa158015611e0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3391906147fa565b611e4f5760405162461bcd60e51b8152600401610dc890614817565b601d805460ff60a01b1916600160a01b8415150217905560118190556010546002548290611e7d91906148b8565b611e8791906148e5565b601e55604051600080516020614b4e83398151915290600090a15050565b60408051808201909152600080825260208201526001600160a01b0383166000908152600a60205260409020805463ffffffff8416908110611ee957611ee9614907565b60009182526020918290206040805180820190915291015463ffffffff8116825264010000000090046001600160e01b0316918101919091529392505050565b6000601c54600003611f44576001600f54610fd29190614936565b81611f5157600d54610fd2565b5050600e5490565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa158015611fa1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fc591906147fa565b611fe15760405162461bcd60e51b8152600401610dc890614817565b6001600160a01b03919091166000908152602560205260409020805460ff1916911515919091179055565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa158015612054573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061207891906147fa565b6120945760405162461bcd60e51b8152600401610dc890614817565b6001600160a01b03821630148015906120bb57506019546001600160a01b03838116911614155b6120f95760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610dc8565b6001600160a01b0382166000908152602360205260409020805460ff1916821580159190911790915561219157601d54604051630a5b654b60e11b81526001600160a01b03848116600483015260006024830152909116906314b6ca96906044015b600060405180830381600087803b15801561217557600080fd5b505af1158015612189573d6000803e3d6000fd5b505050505050565b601d546001600160a01b03166314b6ca96836121c2816001600160a01b031660009081526020819052604090205490565b6040516001600160e01b031960e085901b1681526001600160a01b039092166004830152602482015260440161215b565b5050565b6060601b805480602002602001604051908101604052809291908181526020018280548015610fb457602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612231575050505050905090565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa1580156122a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122c491906147fa565b6122e05760405162461bcd60e51b8152600401610dc890614817565b6001600160a01b03919091166000908152602260205260409020805460ff1916911515919091179055565b60006110a482846148a5565b60006110a48284614936565b6001600160a01b0383166123855760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610dc8565b6001600160a01b0382166123e65760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610dc8565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006124538484611d9c565b905060001981146124bb57818110156124ae5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610dc8565b6124bb8484848403612323565b50505050565b6000601c5411806124d657506124d6326130ec565b806124f05750601f5461010090046001600160a01b031632145b61253c5760405162461bcd60e51b815260206004820181905260248201527f54686520636f6e7472616374206973206e6f74206c61756e63686564207965746044820152606401610dc8565b601f5460ff16806125d45750601d60009054906101000a90046001600160a01b03166001600160a01b031663338274386040518163ffffffff1660e01b8152600401602060405180830381865afa15801561259b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125bf9190614949565b6001600160a01b0316836001600160a01b0316145b806126665750601d60009054906101000a90046001600160a01b03166001600160a01b031663338274386040518163ffffffff1660e01b8152600401602060405180830381865afa15801561262d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126519190614949565b6001600160a01b0316826001600160a01b0316145b806126765750612676838361315b565b1561268b576126868383836131af565b505050565b612696838383613359565b6126a083836133e5565b156126b2576126ad6136a4565b6127a2565b601d60009054906101000a90046001600160a01b03166001600160a01b0316635ade013d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612705573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127299190614949565b6001600160a01b031663ce3f39ca6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561276357600080fd5b505af1925050508015612774575060015b6127a2576040517f0add6f16827cda80bff0c50e92b5df64503118fb3b36961f5e09a4ed6c49056190600090a15b60006127ae84846139dc565b156127d957600f546127c2610cb985613ad0565b6127cc90846148b8565b6127d691906148e5565b90505b60006127e58284614936565b90506127f28585836131af565b8115612803576128038530846131af565b6001600160a01b03851660009081526023602052604090205460ff166128ec57601d546001600160a01b03166314b6ca9686612854816001600160a01b031660009081526020819052604090205490565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561289a57600080fd5b505af19250505080156128ab575060015b6128ec576040516001600160a01b03861681527fb58949020382b3e2e51f22f168f97d561b94d210006dbe32902d8e71a3a165fa9060200160405180910390a15b6001600160a01b03841660009081526023602052604090205460ff166129d557601d546001600160a01b03166314b6ca968561293d816001600160a01b031660009081526020819052604090205490565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561298357600080fd5b505af1925050508015612994575060015b6129d5576040516001600160a01b03851681527fb58949020382b3e2e51f22f168f97d561b94d210006dbe32902d8e71a3a165fa9060200160405180910390a15b601d54604080516334d8ea0d60e11b815290516001600160a01b0390921691632107514f9183916369b1d41a916004808201926020929091908290030181865afa158015612a27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a4b9190614966565b6040518263ffffffff1660e01b8152600401612a6991815260200190565b600060405180830381600087803b158015612a8357600080fd5b505af1925050508015612a94575060015b612ac2576040517fb4409481a77cfa13bfbedb60907d5393f18d35913a86612cff51501e18614fec90600090a15b601d54604080516310bbf3ef60e31b815290516001600160a01b039092169163f9c129be9183916385df9f78916004808201926020929091908290030181865afa158015612b14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b389190614966565b6040518263ffffffff1660e01b8152600401612b5691815260200190565b600060405180830381600087803b158015612b7057600080fd5b505af1925050508015612b81575060015b612baf576040517f4c3d4e523771587a8fe3c94571299d5a4c1617d7badac000e99089b262de293690600090a15b601d5460408051631c094aa360e11b815290516001600160a01b039092169163cdff08b69183916338129546916004808201926020929091908290030181865afa158015612c01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c259190614966565b6040518263ffffffff1660e01b8152600401612c4391815260200190565b600060405180830381600087803b158015612c5d57600080fd5b505af1925050508015612c6e575060015b612c9c576040517fa797e0c48ea74ddef77d67e1d183a8bc018343affaf52a3440d2dd57d905dc3590600090a15b5050505050565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015612cfc57507f000000000000000000000000000000000000000000000000000000000000000046145b15612d2657507f000000000000000000000000000000000000000000000000000000000000000090565b611006604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b90565b815460009081816005811115612e2b576000612dec84613b34565b612df69085614936565b600088815260209020909150869082015463ffffffff161115612e1b57809150612e29565b612e268160016148a5565b92505b505b80821015612e78576000612e3f8383613c1c565b600088815260209020909150869082015463ffffffff161115612e6457809150612e72565b612e6f8160016148a5565b92505b50612e2b565b8015612ea4576000868152602090208101600019015464010000000090046001600160e01b0316612ea7565b60005b6001600160e01b03169695505050505050565b6121f38282613c37565b6001600160a01b038281166000818152600960208181526040808420805485845282862054949093528787166001600160a01b03198416811790915590519190951694919391928592917f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a46124bb828483613c4f565b600063ffffffff821115612fa25760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203360448201526532206269747360d01b6064820152608401610dc8565b5090565b6001600160a01b038116600090815260076020526040812054610fd2565b606060ff8314612fde57612fd783613d8c565b9050610fd2565b818054612fea9061485b565b80601f01602080910402602001604051908101604052809291908181526020018280546130169061485b565b80156130635780601f1061303857610100808354040283529160200191613063565b820191906000526020600020905b81548152906001019060200180831161304657829003601f168201915b50505050509050610fd2565b6000610fd261307c612ca3565b8360405161190160f01b8152600281019290925260228201526042902090565b60008060006130ad87878787613dcb565b915091506130ba81613e8f565b5095945050505050565b6001600160a01b03811660009081526007602052604090208054600181018255905b50919050565b602054604051630935e01b60e21b81526001600160a01b03838116600483015260009216906324d7806c90602401602060405180830381865afa158015613137573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd291906147fa565b6001600160a01b03821660009081526024602052604081205460ff168061319a57506001600160a01b03821660009081526024602052604090205460ff165b156131a757506001610fd2565b506000610fd2565b6001600160a01b0383166132135760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610dc8565b6001600160a01b0382166132755760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610dc8565b6001600160a01b038316600090815260208190526040902054818110156132ed5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610dc8565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36124bb848484613fd9565b600c548111158061338257506001600160a01b03831660009081526022602052604090205460ff165b806133a557506001600160a01b03821660009081526022602052604090205460ff165b6126865760405162461bcd60e51b8152602060048201526011602482015270151608131a5b5a5d08115e18d959591959607a1b6044820152606401610dc8565b6000805b601b5481101561344157601b818154811061340657613406614907565b6000918252602090912001546001600160a01b039081169085160361342f576000915050610fd2565b806134398161491d565b9150506133e9565b50601f5460ff161580156134c95750601d60009054906101000a90046001600160a01b03166001600160a01b0316630cf40d956040518163ffffffff1660e01b8152600401602060405180830381865afa1580156134a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134c791906147fa565b155b80156134de5750601d54600160a01b900460ff165b80156134fb5750601e543060009081526020819052604090205410155b80156135155750601d546001600160a01b03848116911614155b801561352f5750601d546001600160a01b03838116911614155b80156135c35750601d60009054906101000a90046001600160a01b03166001600160a01b031663350580ea6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613589573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135ad9190614949565b6001600160a01b0316836001600160a01b031614155b80156136575750601d60009054906101000a90046001600160a01b03166001600160a01b031663350580ea6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561361d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136419190614949565b6001600160a01b0316826001600160a01b031614155b801561367c57506001600160a01b03821660009081526025602052604090205460ff16155b80156110a4575050506001600160a01b031660009081526025602052604090205460ff161590565b601f805460ff1916600117905560408051600280825260608201835260009260208301908036833701905050905030816000815181106136e6576136e6614907565b6001600160a01b0392831660209182029290920101526012548251610100909104909116908290600190811061371e5761371e614907565b6001600160a01b0390921660209283029190910190910152601e5460405163e67b559360e01b815260009173e2ac858c675a3ed81ab8042eb62cb81cd34c58789163e67b55939161377391869060040161497f565b602060405180830381865af4158015613790573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137b49190614949565b601e5460405163791ac94760e01b81529192506001600160a01b0383169163791ac947916137ed916000908790309042906004016149d6565b600060405180830381600087803b15801561380757600080fd5b505af1925050508015613818575060015b61392957613824614a12565b806308c379a00361389d5750613838614a68565b80613843575061389f565b7fc41a20ad8c23d3903584975786330c6ec73ccfcc657629f10237b792268b0e02816040516020016138759190614af2565b60408051601f198184030181529082905261388f91614444565b60405180910390a1506139ce565b505b7fc41a20ad8c23d3903584975786330c6ec73ccfcc657629f10237b792268b0e0260405161391c9060208082526035908201527f537761704261636b206661696c656420776974686f757420616e206572726f72604082015274040dacae6e6c2ceca40cce4deda40e8d0ca40c8caf605b1b606082015260800190565b60405180910390a16139ce565b601d60009054906101000a90046001600160a01b03166001600160a01b03166327a2db7e476040518263ffffffff1660e01b81526004016000604051808303818588803b15801561397957600080fd5b505af115801561398d573d6000803e3d6000fd5b50505050507fb39214ef4f33ea2d9d329fb67a4f17e7588bf6e00ed15a7967137ba819697a27601e546040516139c591815260200190565b60405180910390a15b5050601f805460ff19169055565b6001600160a01b03821660009081526021602052604081205460ff1680613a1b57506001600160a01b03821660009081526021602052604090205460ff165b80613a265750601c54155b15613a3357506000610fd2565b60005b601b54811015613ac257601b8181548110613a5357613a53614907565b6000918252602090912001546001600160a01b0385811691161480613aa15750601b8181548110613a8657613a86614907565b6000918252602090912001546001600160a01b038481169116145b15613ab0576001915050610fd2565b80613aba8161491d565b915050613a36565b505060125460ff1692915050565b6000805b601b54811015613b2b57601b8181548110613af157613af1614907565b6000918252602090912001546001600160a01b0390811690841603613b195750600192915050565b80613b238161491d565b915050613ad4565b50600092915050565b600081600003613b4657506000919050565b60006001613b5384613fe4565b901c6001901b90506001818481613b6c57613b6c6148cf565b048201901c90506001818481613b8457613b846148cf565b048201901c90506001818481613b9c57613b9c6148cf565b048201901c90506001818481613bb457613bb46148cf565b048201901c90506001818481613bcc57613bcc6148cf565b048201901c90506001818481613be457613be46148cf565b048201901c90506001818481613bfc57613bfc6148cf565b048201901c90506110a481828581613c1657613c166148cf565b04614078565b6000613c2b60028484186148e5565b6110a4908484166148a5565b613c41828261408e565b6124bb600b612317836141c7565b816001600160a01b0316836001600160a01b031614158015613c715750600081115b15612686576001600160a01b03831615613cff576001600160a01b0383166000908152600a602052604081208190613cac90612317856141c7565b91509150846001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051613cf4929190918252602082015260400190565b60405180910390a250505b6001600160a01b03821615612686576001600160a01b0382166000908152600a602052604081208190613d359061230b856141c7565b91509150836001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051613d7d929190918252602082015260400190565b60405180910390a25050505050565b60606000613d9983614331565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613e025750600090506003613e86565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613e56573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613e7f57600060019250925050613e86565b9150600090505b94509492505050565b6000816004811115613ea357613ea3614b37565b03613eab5750565b6001816004811115613ebf57613ebf614b37565b03613f0c5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610dc8565b6002816004811115613f2057613f20614b37565b03613f6d5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610dc8565b6003816004811115613f8157613f81614b37565b036110e25760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610dc8565b612686838383614359565b600080608083901c15613ff957608092831c92015b604083901c1561400b57604092831c92015b602083901c1561401d57602092831c92015b601083901c1561402f57601092831c92015b600883901c1561404157600892831c92015b600483901c1561405357600492831c92015b600283901c1561406557600292831c92015b600183901c15610fd25760010192915050565b600081831061408757816110a4565b5090919050565b6001600160a01b0382166140ee5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610dc8565b6001600160a01b038216600090815260208190526040902054818110156141625760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610dc8565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a361268683600084613fd9565b825460009081908181156142145760008781526020902082016000190160408051808201909152905463ffffffff8116825264010000000090046001600160e01b03166020820152614229565b60408051808201909152600080825260208201525b905080602001516001600160e01b0316935061424984868863ffffffff16565b92506000821180156142695750805163ffffffff1665ffffffffffff4216145b156142ae576142778361438b565b60008881526020902083016000190180546001600160e01b03929092166401000000000263ffffffff909216919091179055614327565b8660405180604001604052806142d16142c44290565b65ffffffffffff16612f3d565b63ffffffff1681526020016142e58661438b565b6001600160e01b0390811690915282546001810184556000938452602093849020835194909301519091166401000000000263ffffffff909316929092179101555b5050935093915050565b600060ff8216601f811115610fd257604051632cd44ac360e21b815260040160405180910390fd5b6001600160a01b0383811660009081526009602052604080822054858416835291205461268692918216911683613c4f565b60006001600160e01b03821115612fa25760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20326044820152663234206269747360c81b6064820152608401610dc8565b60005b8381101561440f5781810151838201526020016143f7565b50506000910152565b600081518084526144308160208601602086016143f4565b601f01601f19169290920160200192915050565b6020815260006110a46020830184614418565b6001600160a01b03811681146110e257600080fd5b6000806040838503121561447f57600080fd5b823561448a81614457565b946020939093013593505050565b6000806000606084860312156144ad57600080fd5b83356144b881614457565b925060208401356144c881614457565b929592945050506040919091013590565b6000602082840312156144eb57600080fd5b81356110a481614457565b60006020828403121561450857600080fd5b5035919050565b80151581146110e257600080fd5b6000806040838503121561453057600080fd5b823561453b81614457565b9150602083013561454b8161450f565b809150509250929050565b60008060006060848603121561456b57600080fd5b833592506020840135915060408401356145848161450f565b809150509250925092565b60ff60f81b881681526000602060e0818401526145af60e084018a614418565b83810360408501526145c1818a614418565b606085018990526001600160a01b038816608086015260a0850187905284810360c0860152855180825283870192509083019060005b81811015614613578351835292840192918401916001016145f7565b50909c9b505050505050505050505050565b803560ff8116811461463657600080fd5b919050565b60008060008060008060c0878903121561465457600080fd5b863561465f81614457565b9550602087013594506040870135935061467b60608801614625565b92506080870135915060a087013590509295509295509295565b600080600080600080600060e0888a0312156146b057600080fd5b87356146bb81614457565b965060208801356146cb81614457565b955060408801359450606088013593506146e760808901614625565b925060a0880135915060c0880135905092959891949750929550565b6000806040838503121561471657600080fd5b823561472181614457565b9150602083013561454b81614457565b6000806040838503121561474457600080fd5b823561448a8161450f565b6000806040838503121561476257600080fd5b823561476d81614457565b9150602083013563ffffffff8116811461454b57600080fd5b60006020828403121561479857600080fd5b81356110a48161450f565b600081518084526020808501945080840160005b838110156147dc5781516001600160a01b0316875295820195908201906001016147b7565b509495945050505050565b6020815260006110a460208301846147a3565b60006020828403121561480c57600080fd5b81516110a48161450f565b60208082526014908201527321b0b63632b91036bab9ba1031329030b236b4b760611b604082015260600190565b634e487b7160e01b600052603160045260246000fd5b600181811c9082168061486f57607f821691505b6020821081036130e657634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610fd257610fd261488f565b8082028115828204841417610fd257610fd261488f565b634e487b7160e01b600052601260045260246000fd5b60008261490257634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b60006001820161492f5761492f61488f565b5060010190565b81810381811115610fd257610fd261488f565b60006020828403121561495b57600080fd5b81516110a481614457565b60006020828403121561497857600080fd5b5051919050565b6000604082018483526020604081850152818551808452606086019150828701935060005b818110156149c95784516001600160a01b0316835293830193918301916001016149a4565b5090979650505050505050565b85815284602082015260a0604082015260006149f560a08301866147a3565b6001600160a01b0394909416606083015250608001529392505050565b600060033d1115612dce5760046000803e5060005160e01c90565b601f8201601f1916810167ffffffffffffffff81118282101715614a6157634e487b7160e01b600052604160045260246000fd5b6040525050565b600060443d1015614a765790565b6040516003193d81016004833e81513d67ffffffffffffffff8160248401118184111715614aa657505050505090565b8285019150815181811115614abe5750505050505090565b843d8701016020828501011115614ad85750505050505090565b614ae760208286010187614a2d565b509095945050505050565b7f537761704261636b206661696c65642077697468206572726f72200000000000815260008251614b2a81601b8501602087016143f4565b91909101601b0192915050565b634e487b7160e01b600052602160045260246000fdfe3e1799d428897e6f54bdb61036ad40e2aa67a45b0181c60fe2f15a9d33a084d6a264697066735822122054590160aaa441b863d4d944319a39c24096c19e98ae80cc74e5a0cd2ca66e5d64736f6c634300081400333ad8aa4f87544323a9d1e5dd902f40c356527a7955687113db5f9a85ad579dc1dec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a72400000000000000000000000054da21340773fecaf9a5bad0883a7fc594945d0a00000000000000000000000098bf93ebf5c380c0e6ae8e192a7e2ae08edacc02000000000000000000000000165c3410fc91ef562c50559f7d2289febed552d9000000000000000000000000eb45a3c4aedd0f47f345fb4c8a1802bb5740d725

Deployed ByteCode

0x6080604052600436106103fd5760003560e01c80636fcfff4511610213578063a9059cbb11610123578063d505accf116100ab578063f1f3bca31161007a578063f1f3bca314610c9e578063f35647c214610cbe578063f708a64f14610cde578063f800ece914610cfe578063f84ba65d14610d2057600080fd5b8063d505accf14610bf4578063dd62ed3e14610c14578063df20fd4914610c34578063f1127ed814610c5457600080fd5b8063bf56b371116100f2578063bf56b37114610b5e578063bfe1092814610b74578063c0b4647014610b94578063c2b7bbb614610bb4578063c3cda52014610bd457600080fd5b8063a9059cbb14610ae8578063af6c9c1d14610b08578063b91ac78814610b28578063bafb140314610b4857600080fd5b80638d5396e9116101a6578063937d0a3a11610175578063937d0a3a14610a5d57806395d89b4114610a7d5780639ab24eb014610a925780639d9241ec14610ab2578063a457c2d714610ac857600080fd5b80638d5396e9146109da5780638e539e8c146109fa5780638f52f46514610a1a57806391ddadf414610a3a57600080fd5b80637d1db4a5116101e25780637d1db4a51461094c5780637ecebe001461096257806384b0196e146109825780638b42507f146109aa57600080fd5b80636fcfff45146108a157806370a08231146108d657806375619ab51461090c578063761ce8411461092c57600080fd5b8063395093511161030e5780634f15999a116102a15780635c19a95c116102705780635c19a95c146108005780635c85974f14610820578063658d4b7f146108405780636d2b4940146108605780636ddd17131461088057600080fd5b80634f15999a14610777578063587cde1e1461079757806359b107b9146107d05780635abe6711146107e657600080fd5b80634355855a116102dd5780634355855a146106cb5780634bf5d7e9146106fb5780634e0df270146107325780634e69e92e1461075257600080fd5b8063395093511461063b5780633a46b1a81461065b5780633f4218e01461067b57806342966c68146106ab57600080fd5b8063180b0d7e1161039157806330f9713a1161036057806330f9713a14610589578063313ce567146105b95780633644e515146105d5578063378dc3dc146105ea57806338e2cf001461060b57600080fd5b8063180b0d7e1461051e57806318160ddd1461053457806323b872dd1461054957806327c8f8351461056957600080fd5b80630930907b116103cd5780630930907b14610480578063095ea7b3146104b8578063096472d8146104e85780630d1554bf146104fe57600080fd5b806293dc141461040957806301339c21146104205780630445b6671461043557806306fdde031461045e57600080fd5b3661040457005b600080fd5b34801561041557600080fd5b5061041e610d40565b005b34801561042c57600080fd5b5061041e610e1e565b34801561044157600080fd5b5061044b601e5481565b6040519081526020015b60405180910390f35b34801561046a57600080fd5b50610473610f2c565b6040516104559190614444565b34801561048c57600080fd5b506014546104a0906001600160a01b031681565b6040516001600160a01b039091168152602001610455565b3480156104c457600080fd5b506104d86104d336600461446c565b610fbe565b6040519015158152602001610455565b3480156104f457600080fd5b5061044b60105481565b34801561050a57600080fd5b506019546104a0906001600160a01b031681565b34801561052a57600080fd5b5061044b600f5481565b34801561054057600080fd5b5060025461044b565b34801561055557600080fd5b506104d8610564366004614498565b610fd8565b34801561057557600080fd5b506013546104a0906001600160a01b031681565b34801561059557600080fd5b506104d86105a43660046144d9565b60246020526000908152604090205460ff1681565b3480156105c557600080fd5b5060405160128152602001610455565b3480156105e157600080fd5b5061044b610ffc565b3480156105f657600080fd5b5061044b6c01431e0fae6d7217caa000000081565b34801561061757600080fd5b506104d86106263660046144d9565b60256020526000908152604090205460ff1681565b34801561064757600080fd5b506104d861065636600461446c565b61100b565b34801561066757600080fd5b5061044b61067636600461446c565b61102d565b34801561068757600080fd5b506104d86106963660046144d9565b60216020526000908152604090205460ff1681565b3480156106b757600080fd5b5061041e6106c63660046144f6565b6110ab565b3480156106d757600080fd5b506104d86106e63660046144d9565b60236020526000908152604090205460ff1681565b34801561070757600080fd5b5060408051808201909152600e81526d06d6f64653d74696d657374616d760941b6020820152610473565b34801561073e57600080fd5b50601a546104a0906001600160a01b031681565b34801561075e57600080fd5b506012546104a09061010090046001600160a01b031681565b34801561078357600080fd5b506016546104a0906001600160a01b031681565b3480156107a357600080fd5b506104a06107b23660046144d9565b6001600160a01b039081166000908152600960205260409020541690565b3480156107dc57600080fd5b5061044b600d5481565b3480156107f257600080fd5b506012546104d89060ff1681565b34801561080c57600080fd5b5061041e61081b3660046144d9565b6110d8565b34801561082c57600080fd5b5061041e61083b3660046144f6565b6110e5565b34801561084c57600080fd5b5061041e61085b36600461451d565b6111ca565b34801561086c57600080fd5b506017546104a0906001600160a01b031681565b34801561088c57600080fd5b50601d546104d890600160a01b900460ff1681565b3480156108ad57600080fd5b506108c16108bc3660046144d9565b61127d565b60405163ffffffff9091168152602001610455565b3480156108e257600080fd5b5061044b6108f13660046144d9565b6001600160a01b031660009081526020819052604090205490565b34801561091857600080fd5b5061041e6109273660046144d9565b61129f565b34801561093857600080fd5b5061041e610947366004614556565b611391565b34801561095857600080fd5b5061044b600c5481565b34801561096e57600080fd5b5061044b61097d3660046144d9565b6114f3565b34801561098e57600080fd5b506109976114fe565b604051610455979695949392919061458f565b3480156109b657600080fd5b506104d86109c53660046144d9565b60226020526000908152604090205460ff1681565b3480156109e657600080fd5b506015546104a0906001600160a01b031681565b348015610a0657600080fd5b5061044b610a153660046144f6565b611587565b348015610a2657600080fd5b5061041e610a3536600461451d565b6115e7565b348015610a4657600080fd5b5060405165ffffffffffff42168152602001610455565b348015610a6957600080fd5b506018546104a0906001600160a01b031681565b348015610a8957600080fd5b5061047361169a565b348015610a9e57600080fd5b5061044b610aad3660046144d9565b6116a9565b348015610abe57600080fd5b5061044b600e5481565b348015610ad457600080fd5b506104d8610ae336600461446c565b61172b565b348015610af457600080fd5b506104d8610b0336600461446c565b6117a6565b348015610b1457600080fd5b5061041e610b233660046144d9565b6117b4565b348015610b3457600080fd5b506104a0610b433660046144f6565b6119ee565b348015610b5457600080fd5b5061044b60115481565b348015610b6a57600080fd5b5061044b601c5481565b348015610b8057600080fd5b50601d546104a0906001600160a01b031681565b348015610ba057600080fd5b506020546104a0906001600160a01b031681565b348015610bc057600080fd5b5061041e610bcf3660046144d9565b611a18565b348015610be057600080fd5b5061041e610bef36600461463b565b611b02565b348015610c0057600080fd5b5061041e610c0f366004614695565b611c38565b348015610c2057600080fd5b5061044b610c2f366004614703565b611d9c565b348015610c4057600080fd5b5061041e610c4f366004614731565b611dc7565b348015610c6057600080fd5b50610c74610c6f36600461474f565b611ea5565b60408051825163ffffffff1681526020928301516001600160e01b03169281019290925201610455565b348015610caa57600080fd5b5061044b610cb9366004614786565b611f29565b348015610cca57600080fd5b5061041e610cd936600461451d565b611f59565b348015610cea57600080fd5b5061041e610cf936600461451d565b61200c565b348015610d0a57600080fd5b50610d136121f7565b60405161045591906147e7565b348015610d2c57600080fd5b5061041e610d3b36600461451d565b612258565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa158015610d88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dac91906147fa565b610dd15760405162461bcd60e51b8152600401610dc890614817565b60405180910390fd5b601b805480610de257610de2614845565b600082815260208120820160001990810180546001600160a01b0319169055909101909155604051600080516020614b4e8339815191529190a1565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa158015610e66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8a91906147fa565b610ea65760405162461bcd60e51b8152600401610dc890614817565b601c5415610eea5760405162461bcd60e51b815260206004820152601160248201527020b63932b0b23c903630bab731b432b21760791b6044820152606401610dc8565b42601c8190556040805143815260208101929092527f87dcd6626ffde0faf682a10e7b64aff36ea73a5470d5fa6cc7ebd372e4b19001910160405180910390a1565b606060038054610f3b9061485b565b80601f0160208091040260200160405190810160405280929190818152602001828054610f679061485b565b8015610fb45780601f10610f8957610100808354040283529160200191610fb4565b820191906000526020600020905b815481529060010190602001808311610f9757829003601f168201915b5050505050905090565b600033610fcc818585612323565b60019150505b92915050565b600033610fe6858285612447565b610ff18585856124c1565b506001949350505050565b6000611006612ca3565b905090565b600033610fcc81858561101e8383611d9c565b61102891906148a5565b612323565b60004265ffffffffffff1682106110825760405162461bcd60e51b815260206004820152601960248201527804552433230566f7465733a20667574757265206c6f6f6b757603c1b6044820152606401610dc8565b6001600160a01b0383166000908152600a602052604090206110a49083612dd1565b9392505050565b6110b53382612eba565b6010546011546002546110c891906148b8565b6110d291906148e5565b601e5550565b6110e23382612ec4565b50565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa15801561112d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115191906147fa565b61116d5760405162461bcd60e51b8152600401610dc890614817565b6107d061117960025490565b61118391906148e5565b8110156111c55760405162461bcd60e51b815260206004820152601060248201526f5458206c696d697420746f6f206c6f7760801b6044820152606401610dc8565b600c55565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa158015611212573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123691906147fa565b6112525760405162461bcd60e51b8152600401610dc890614817565b6001600160a01b03919091166000908152602160205260409020805460ff1916911515919091179055565b6001600160a01b0381166000908152600a6020526040812054610fd290612f3d565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa1580156112e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061130b91906147fa565b6113275760405162461bcd60e51b8152600401610dc890614817565b6001600160a01b03811661136f5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610dc8565b601d80546001600160a01b0319166001600160a01b0392909216919091179055565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa1580156113d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113fd91906147fa565b6114195760405162461bcd60e51b8152600401610dc890614817565b600d839055600e8290556103e88311156114755760405162461bcd60e51b815260206004820152601d60248201527f427579206665652068617320612031302070657263656e74206d61782e0000006044820152606401610dc8565b6103e8600e5411156114c95760405162461bcd60e51b815260206004820152601e60248201527f53656c6c206665652068617320612031302070657263656e74206d61782e00006044820152606401610dc8565b6012805460ff1916821515179055604051600080516020614b4e83398151915290600090a1505050565b6000610fd282612fa6565b6000606080828080836115327f566f7563680000000000000000000000000000000000000000000000000000056005612fc4565b61155d7f31000000000000000000000000000000000000000000000000000000000000016006612fc4565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b60004265ffffffffffff1682106115dc5760405162461bcd60e51b815260206004820152601960248201527804552433230566f7465733a20667574757265206c6f6f6b757603c1b6044820152606401610dc8565b610fd2600b83612dd1565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa15801561162f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165391906147fa565b61166f5760405162461bcd60e51b8152600401610dc890614817565b6001600160a01b03919091166000908152602460205260409020805460ff1916911515919091179055565b606060048054610f3b9061485b565b6001600160a01b0381166000908152600a60205260408120548015611718576001600160a01b0383166000908152600a60205260409020805460001983019081106116f6576116f6614907565b60009182526020909120015464010000000090046001600160e01b031661171b565b60005b6001600160e01b03169392505050565b600033816117398286611d9c565b9050838110156117995760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610dc8565b610ff18286868403612323565b600033610fcc8185856124c1565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa1580156117fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061182091906147fa565b61183c5760405162461bcd60e51b8152600401610dc890614817565b601b54806118775760405162461bcd60e51b81526020600482015260086024820152674e6f20706169727360c01b6044820152606401610dc8565b8060005b828110156118d457836001600160a01b0316601b82815481106118a0576118a0614907565b6000918252602090912001546001600160a01b0316036118c2578091506118d4565b806118cc8161491d565b91505061187b565b508181106119155760405162461bcd60e51b815260206004820152600e60248201526d14185a5c881b9bdd08199bdd5b9960921b6044820152606401610dc8565b611920600183614936565b811461199e57601b611933600184614936565b8154811061194357611943614907565b600091825260209091200154601b80546001600160a01b03909216918390811061196f5761196f614907565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b601b8054806119af576119af614845565b600082815260208120820160001990810180546001600160a01b0319169055909101909155604051600080516020614b4e8339815191529190a1505050565b601b81815481106119fe57600080fd5b6000918252602090912001546001600160a01b0316905081565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa158015611a60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a8491906147fa565b611aa05760405162461bcd60e51b8152600401610dc890614817565b601b805460018101825560009182527f3ad8aa4f87544323a9d1e5dd902f40c356527a7955687113db5f9a85ad579dc10180546001600160a01b0319166001600160a01b038416179055604051600080516020614b4e8339815191529190a150565b83421115611b525760405162461bcd60e51b815260206004820152601d60248201527f4552433230566f7465733a207369676e617475726520657870697265640000006044820152606401610dc8565b604080517fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60208201526001600160a01b038816918101919091526060810186905260808101859052600090611bcc90611bc49060a0016040516020818303038152906040528051906020012061306f565b85858561309c565b9050611bd7816130c4565b8614611c255760405162461bcd60e51b815260206004820152601960248201527f4552433230566f7465733a20696e76616c6964206e6f6e6365000000000000006044820152606401610dc8565b611c2f8188612ec4565b50505050505050565b83421115611c885760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610dc8565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9888888611cb78c6130c4565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000611d128261306f565b90506000611d228287878761309c565b9050896001600160a01b0316816001600160a01b031614611d855760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610dc8565b611d908a8a8a612323565b50505050505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa158015611e0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3391906147fa565b611e4f5760405162461bcd60e51b8152600401610dc890614817565b601d805460ff60a01b1916600160a01b8415150217905560118190556010546002548290611e7d91906148b8565b611e8791906148e5565b601e55604051600080516020614b4e83398151915290600090a15050565b60408051808201909152600080825260208201526001600160a01b0383166000908152600a60205260409020805463ffffffff8416908110611ee957611ee9614907565b60009182526020918290206040805180820190915291015463ffffffff8116825264010000000090046001600160e01b0316918101919091529392505050565b6000601c54600003611f44576001600f54610fd29190614936565b81611f5157600d54610fd2565b5050600e5490565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa158015611fa1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fc591906147fa565b611fe15760405162461bcd60e51b8152600401610dc890614817565b6001600160a01b03919091166000908152602560205260409020805460ff1916911515919091179055565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa158015612054573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061207891906147fa565b6120945760405162461bcd60e51b8152600401610dc890614817565b6001600160a01b03821630148015906120bb57506019546001600160a01b03838116911614155b6120f95760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610dc8565b6001600160a01b0382166000908152602360205260409020805460ff1916821580159190911790915561219157601d54604051630a5b654b60e11b81526001600160a01b03848116600483015260006024830152909116906314b6ca96906044015b600060405180830381600087803b15801561217557600080fd5b505af1158015612189573d6000803e3d6000fd5b505050505050565b601d546001600160a01b03166314b6ca96836121c2816001600160a01b031660009081526020819052604090205490565b6040516001600160e01b031960e085901b1681526001600160a01b039092166004830152602482015260440161215b565b5050565b6060601b805480602002602001604051908101604052809291908181526020018280548015610fb457602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612231575050505050905090565b602054604051630935e01b60e21b81523360048201526001600160a01b03909116906324d7806c90602401602060405180830381865afa1580156122a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122c491906147fa565b6122e05760405162461bcd60e51b8152600401610dc890614817565b6001600160a01b03919091166000908152602260205260409020805460ff1916911515919091179055565b60006110a482846148a5565b60006110a48284614936565b6001600160a01b0383166123855760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610dc8565b6001600160a01b0382166123e65760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610dc8565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006124538484611d9c565b905060001981146124bb57818110156124ae5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610dc8565b6124bb8484848403612323565b50505050565b6000601c5411806124d657506124d6326130ec565b806124f05750601f5461010090046001600160a01b031632145b61253c5760405162461bcd60e51b815260206004820181905260248201527f54686520636f6e7472616374206973206e6f74206c61756e63686564207965746044820152606401610dc8565b601f5460ff16806125d45750601d60009054906101000a90046001600160a01b03166001600160a01b031663338274386040518163ffffffff1660e01b8152600401602060405180830381865afa15801561259b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125bf9190614949565b6001600160a01b0316836001600160a01b0316145b806126665750601d60009054906101000a90046001600160a01b03166001600160a01b031663338274386040518163ffffffff1660e01b8152600401602060405180830381865afa15801561262d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126519190614949565b6001600160a01b0316826001600160a01b0316145b806126765750612676838361315b565b1561268b576126868383836131af565b505050565b612696838383613359565b6126a083836133e5565b156126b2576126ad6136a4565b6127a2565b601d60009054906101000a90046001600160a01b03166001600160a01b0316635ade013d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612705573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127299190614949565b6001600160a01b031663ce3f39ca6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561276357600080fd5b505af1925050508015612774575060015b6127a2576040517f0add6f16827cda80bff0c50e92b5df64503118fb3b36961f5e09a4ed6c49056190600090a15b60006127ae84846139dc565b156127d957600f546127c2610cb985613ad0565b6127cc90846148b8565b6127d691906148e5565b90505b60006127e58284614936565b90506127f28585836131af565b8115612803576128038530846131af565b6001600160a01b03851660009081526023602052604090205460ff166128ec57601d546001600160a01b03166314b6ca9686612854816001600160a01b031660009081526020819052604090205490565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561289a57600080fd5b505af19250505080156128ab575060015b6128ec576040516001600160a01b03861681527fb58949020382b3e2e51f22f168f97d561b94d210006dbe32902d8e71a3a165fa9060200160405180910390a15b6001600160a01b03841660009081526023602052604090205460ff166129d557601d546001600160a01b03166314b6ca968561293d816001600160a01b031660009081526020819052604090205490565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561298357600080fd5b505af1925050508015612994575060015b6129d5576040516001600160a01b03851681527fb58949020382b3e2e51f22f168f97d561b94d210006dbe32902d8e71a3a165fa9060200160405180910390a15b601d54604080516334d8ea0d60e11b815290516001600160a01b0390921691632107514f9183916369b1d41a916004808201926020929091908290030181865afa158015612a27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a4b9190614966565b6040518263ffffffff1660e01b8152600401612a6991815260200190565b600060405180830381600087803b158015612a8357600080fd5b505af1925050508015612a94575060015b612ac2576040517fb4409481a77cfa13bfbedb60907d5393f18d35913a86612cff51501e18614fec90600090a15b601d54604080516310bbf3ef60e31b815290516001600160a01b039092169163f9c129be9183916385df9f78916004808201926020929091908290030181865afa158015612b14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b389190614966565b6040518263ffffffff1660e01b8152600401612b5691815260200190565b600060405180830381600087803b158015612b7057600080fd5b505af1925050508015612b81575060015b612baf576040517f4c3d4e523771587a8fe3c94571299d5a4c1617d7badac000e99089b262de293690600090a15b601d5460408051631c094aa360e11b815290516001600160a01b039092169163cdff08b69183916338129546916004808201926020929091908290030181865afa158015612c01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c259190614966565b6040518263ffffffff1660e01b8152600401612c4391815260200190565b600060405180830381600087803b158015612c5d57600080fd5b505af1925050508015612c6e575060015b612c9c576040517fa797e0c48ea74ddef77d67e1d183a8bc018343affaf52a3440d2dd57d905dc3590600090a15b5050505050565b6000306001600160a01b037f000000000000000000000000d34f5adc24d8cc55c1e832bdf65fffdf80d1314f16148015612cfc57507f000000000000000000000000000000000000000000000000000000000000017146145b15612d2657507f230b68f71a576582e8e2d377192aede2935d35e36c3277e35921db33d917937990565b611006604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527fb0744cea4bae4302ebd785c65304df58df4478b657cf0400fb5c98365946ff5d918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b90565b815460009081816005811115612e2b576000612dec84613b34565b612df69085614936565b600088815260209020909150869082015463ffffffff161115612e1b57809150612e29565b612e268160016148a5565b92505b505b80821015612e78576000612e3f8383613c1c565b600088815260209020909150869082015463ffffffff161115612e6457809150612e72565b612e6f8160016148a5565b92505b50612e2b565b8015612ea4576000868152602090208101600019015464010000000090046001600160e01b0316612ea7565b60005b6001600160e01b03169695505050505050565b6121f38282613c37565b6001600160a01b038281166000818152600960208181526040808420805485845282862054949093528787166001600160a01b03198416811790915590519190951694919391928592917f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a46124bb828483613c4f565b600063ffffffff821115612fa25760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203360448201526532206269747360d01b6064820152608401610dc8565b5090565b6001600160a01b038116600090815260076020526040812054610fd2565b606060ff8314612fde57612fd783613d8c565b9050610fd2565b818054612fea9061485b565b80601f01602080910402602001604051908101604052809291908181526020018280546130169061485b565b80156130635780601f1061303857610100808354040283529160200191613063565b820191906000526020600020905b81548152906001019060200180831161304657829003601f168201915b50505050509050610fd2565b6000610fd261307c612ca3565b8360405161190160f01b8152600281019290925260228201526042902090565b60008060006130ad87878787613dcb565b915091506130ba81613e8f565b5095945050505050565b6001600160a01b03811660009081526007602052604090208054600181018255905b50919050565b602054604051630935e01b60e21b81526001600160a01b03838116600483015260009216906324d7806c90602401602060405180830381865afa158015613137573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd291906147fa565b6001600160a01b03821660009081526024602052604081205460ff168061319a57506001600160a01b03821660009081526024602052604090205460ff165b156131a757506001610fd2565b506000610fd2565b6001600160a01b0383166132135760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610dc8565b6001600160a01b0382166132755760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610dc8565b6001600160a01b038316600090815260208190526040902054818110156132ed5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610dc8565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36124bb848484613fd9565b600c548111158061338257506001600160a01b03831660009081526022602052604090205460ff165b806133a557506001600160a01b03821660009081526022602052604090205460ff165b6126865760405162461bcd60e51b8152602060048201526011602482015270151608131a5b5a5d08115e18d959591959607a1b6044820152606401610dc8565b6000805b601b5481101561344157601b818154811061340657613406614907565b6000918252602090912001546001600160a01b039081169085160361342f576000915050610fd2565b806134398161491d565b9150506133e9565b50601f5460ff161580156134c95750601d60009054906101000a90046001600160a01b03166001600160a01b0316630cf40d956040518163ffffffff1660e01b8152600401602060405180830381865afa1580156134a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134c791906147fa565b155b80156134de5750601d54600160a01b900460ff165b80156134fb5750601e543060009081526020819052604090205410155b80156135155750601d546001600160a01b03848116911614155b801561352f5750601d546001600160a01b03838116911614155b80156135c35750601d60009054906101000a90046001600160a01b03166001600160a01b031663350580ea6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613589573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135ad9190614949565b6001600160a01b0316836001600160a01b031614155b80156136575750601d60009054906101000a90046001600160a01b03166001600160a01b031663350580ea6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561361d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136419190614949565b6001600160a01b0316826001600160a01b031614155b801561367c57506001600160a01b03821660009081526025602052604090205460ff16155b80156110a4575050506001600160a01b031660009081526025602052604090205460ff161590565b601f805460ff1916600117905560408051600280825260608201835260009260208301908036833701905050905030816000815181106136e6576136e6614907565b6001600160a01b0392831660209182029290920101526012548251610100909104909116908290600190811061371e5761371e614907565b6001600160a01b0390921660209283029190910190910152601e5460405163e67b559360e01b815260009173e2ac858c675a3ed81ab8042eb62cb81cd34c58789163e67b55939161377391869060040161497f565b602060405180830381865af4158015613790573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137b49190614949565b601e5460405163791ac94760e01b81529192506001600160a01b0383169163791ac947916137ed916000908790309042906004016149d6565b600060405180830381600087803b15801561380757600080fd5b505af1925050508015613818575060015b61392957613824614a12565b806308c379a00361389d5750613838614a68565b80613843575061389f565b7fc41a20ad8c23d3903584975786330c6ec73ccfcc657629f10237b792268b0e02816040516020016138759190614af2565b60408051601f198184030181529082905261388f91614444565b60405180910390a1506139ce565b505b7fc41a20ad8c23d3903584975786330c6ec73ccfcc657629f10237b792268b0e0260405161391c9060208082526035908201527f537761704261636b206661696c656420776974686f757420616e206572726f72604082015274040dacae6e6c2ceca40cce4deda40e8d0ca40c8caf605b1b606082015260800190565b60405180910390a16139ce565b601d60009054906101000a90046001600160a01b03166001600160a01b03166327a2db7e476040518263ffffffff1660e01b81526004016000604051808303818588803b15801561397957600080fd5b505af115801561398d573d6000803e3d6000fd5b50505050507fb39214ef4f33ea2d9d329fb67a4f17e7588bf6e00ed15a7967137ba819697a27601e546040516139c591815260200190565b60405180910390a15b5050601f805460ff19169055565b6001600160a01b03821660009081526021602052604081205460ff1680613a1b57506001600160a01b03821660009081526021602052604090205460ff165b80613a265750601c54155b15613a3357506000610fd2565b60005b601b54811015613ac257601b8181548110613a5357613a53614907565b6000918252602090912001546001600160a01b0385811691161480613aa15750601b8181548110613a8657613a86614907565b6000918252602090912001546001600160a01b038481169116145b15613ab0576001915050610fd2565b80613aba8161491d565b915050613a36565b505060125460ff1692915050565b6000805b601b54811015613b2b57601b8181548110613af157613af1614907565b6000918252602090912001546001600160a01b0390811690841603613b195750600192915050565b80613b238161491d565b915050613ad4565b50600092915050565b600081600003613b4657506000919050565b60006001613b5384613fe4565b901c6001901b90506001818481613b6c57613b6c6148cf565b048201901c90506001818481613b8457613b846148cf565b048201901c90506001818481613b9c57613b9c6148cf565b048201901c90506001818481613bb457613bb46148cf565b048201901c90506001818481613bcc57613bcc6148cf565b048201901c90506001818481613be457613be46148cf565b048201901c90506001818481613bfc57613bfc6148cf565b048201901c90506110a481828581613c1657613c166148cf565b04614078565b6000613c2b60028484186148e5565b6110a4908484166148a5565b613c41828261408e565b6124bb600b612317836141c7565b816001600160a01b0316836001600160a01b031614158015613c715750600081115b15612686576001600160a01b03831615613cff576001600160a01b0383166000908152600a602052604081208190613cac90612317856141c7565b91509150846001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051613cf4929190918252602082015260400190565b60405180910390a250505b6001600160a01b03821615612686576001600160a01b0382166000908152600a602052604081208190613d359061230b856141c7565b91509150836001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051613d7d929190918252602082015260400190565b60405180910390a25050505050565b60606000613d9983614331565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613e025750600090506003613e86565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613e56573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613e7f57600060019250925050613e86565b9150600090505b94509492505050565b6000816004811115613ea357613ea3614b37565b03613eab5750565b6001816004811115613ebf57613ebf614b37565b03613f0c5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610dc8565b6002816004811115613f2057613f20614b37565b03613f6d5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610dc8565b6003816004811115613f8157613f81614b37565b036110e25760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610dc8565b612686838383614359565b600080608083901c15613ff957608092831c92015b604083901c1561400b57604092831c92015b602083901c1561401d57602092831c92015b601083901c1561402f57601092831c92015b600883901c1561404157600892831c92015b600483901c1561405357600492831c92015b600283901c1561406557600292831c92015b600183901c15610fd25760010192915050565b600081831061408757816110a4565b5090919050565b6001600160a01b0382166140ee5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610dc8565b6001600160a01b038216600090815260208190526040902054818110156141625760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610dc8565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a361268683600084613fd9565b825460009081908181156142145760008781526020902082016000190160408051808201909152905463ffffffff8116825264010000000090046001600160e01b03166020820152614229565b60408051808201909152600080825260208201525b905080602001516001600160e01b0316935061424984868863ffffffff16565b92506000821180156142695750805163ffffffff1665ffffffffffff4216145b156142ae576142778361438b565b60008881526020902083016000190180546001600160e01b03929092166401000000000263ffffffff909216919091179055614327565b8660405180604001604052806142d16142c44290565b65ffffffffffff16612f3d565b63ffffffff1681526020016142e58661438b565b6001600160e01b0390811690915282546001810184556000938452602093849020835194909301519091166401000000000263ffffffff909316929092179101555b5050935093915050565b600060ff8216601f811115610fd257604051632cd44ac360e21b815260040160405180910390fd5b6001600160a01b0383811660009081526009602052604080822054858416835291205461268692918216911683613c4f565b60006001600160e01b03821115612fa25760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20326044820152663234206269747360c81b6064820152608401610dc8565b60005b8381101561440f5781810151838201526020016143f7565b50506000910152565b600081518084526144308160208601602086016143f4565b601f01601f19169290920160200192915050565b6020815260006110a46020830184614418565b6001600160a01b03811681146110e257600080fd5b6000806040838503121561447f57600080fd5b823561448a81614457565b946020939093013593505050565b6000806000606084860312156144ad57600080fd5b83356144b881614457565b925060208401356144c881614457565b929592945050506040919091013590565b6000602082840312156144eb57600080fd5b81356110a481614457565b60006020828403121561450857600080fd5b5035919050565b80151581146110e257600080fd5b6000806040838503121561453057600080fd5b823561453b81614457565b9150602083013561454b8161450f565b809150509250929050565b60008060006060848603121561456b57600080fd5b833592506020840135915060408401356145848161450f565b809150509250925092565b60ff60f81b881681526000602060e0818401526145af60e084018a614418565b83810360408501526145c1818a614418565b606085018990526001600160a01b038816608086015260a0850187905284810360c0860152855180825283870192509083019060005b81811015614613578351835292840192918401916001016145f7565b50909c9b505050505050505050505050565b803560ff8116811461463657600080fd5b919050565b60008060008060008060c0878903121561465457600080fd5b863561465f81614457565b9550602087013594506040870135935061467b60608801614625565b92506080870135915060a087013590509295509295509295565b600080600080600080600060e0888a0312156146b057600080fd5b87356146bb81614457565b965060208801356146cb81614457565b955060408801359450606088013593506146e760808901614625565b925060a0880135915060c0880135905092959891949750929550565b6000806040838503121561471657600080fd5b823561472181614457565b9150602083013561454b81614457565b6000806040838503121561474457600080fd5b823561448a8161450f565b6000806040838503121561476257600080fd5b823561476d81614457565b9150602083013563ffffffff8116811461454b57600080fd5b60006020828403121561479857600080fd5b81356110a48161450f565b600081518084526020808501945080840160005b838110156147dc5781516001600160a01b0316875295820195908201906001016147b7565b509495945050505050565b6020815260006110a460208301846147a3565b60006020828403121561480c57600080fd5b81516110a48161450f565b60208082526014908201527321b0b63632b91036bab9ba1031329030b236b4b760611b604082015260600190565b634e487b7160e01b600052603160045260246000fd5b600181811c9082168061486f57607f821691505b6020821081036130e657634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610fd257610fd261488f565b8082028115828204841417610fd257610fd261488f565b634e487b7160e01b600052601260045260246000fd5b60008261490257634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b60006001820161492f5761492f61488f565b5060010190565b81810381811115610fd257610fd261488f565b60006020828403121561495b57600080fd5b81516110a481614457565b60006020828403121561497857600080fd5b5051919050565b6000604082018483526020604081850152818551808452606086019150828701935060005b818110156149c95784516001600160a01b0316835293830193918301916001016149a4565b5090979650505050505050565b85815284602082015260a0604082015260006149f560a08301866147a3565b6001600160a01b0394909416606083015250608001529392505050565b600060033d1115612dce5760046000803e5060005160e01c90565b601f8201601f1916810167ffffffffffffffff81118282101715614a6157634e487b7160e01b600052604160045260246000fd5b6040525050565b600060443d1015614a765790565b6040516003193d81016004833e81513d67ffffffffffffffff8160248401118184111715614aa657505050505090565b8285019150815181811115614abe5750505050505090565b843d8701016020828501011115614ad85750505050505090565b614ae760208286010187614a2d565b509095945050505050565b7f537761704261636b206661696c65642077697468206572726f72200000000000815260008251614b2a81601b8501602087016143f4565b91909101601b0192915050565b634e487b7160e01b600052602160045260246000fdfe3e1799d428897e6f54bdb61036ad40e2aa67a45b0181c60fe2f15a9d33a084d6a264697066735822122054590160aaa441b863d4d944319a39c24096c19e98ae80cc74e5a0cd2ca66e5d64736f6c63430008140033

External libraries