contract Athlon is ERC20Detailed, ERC20Mintable, ERC20Burnable, Ownable
{
    using SafeMath for uint256;

    uint256 public transferFee = 1000;
    // uint256 public tokensPerEther = 40000000;

    mapping( address => bool ) public freezed;

    event Freeze(address indexed acc );
    event Unfreeze(address indexed acc );
    event MintResumed();
    event TokenPurchase( address indexed purchaser, uint256 value, uint256 amount );

    modifier notFreezed() {
        require(!freezed[msg.sender], "This account is freezed!");
        _;
    }

    constructor( uint256 _totalSupply, string memory _name, string memory _symbol, uint8 _decimals ) 
        ERC20Detailed( _name, _symbol, _decimals )
        public
    {
        _mint(msg.sender, _totalSupply);
    }

    function freeze(address _acc) public onlyOwner
    {
        freezed[_acc] = true;
        emit Freeze(_acc);
    }

    function unfreeze(address _acc) public onlyOwner
    {
        require(freezed[_acc], "Account must be freezed!");
        delete freezed[_acc];
        emit Unfreeze(_acc);
    }

    function setTransferFee(uint256 _value) public onlyOwner
    {
        require(_value != 0, "Value must greater than zero");
        transferFee = _value;
    }

    // function setTokensPerEther(uint256 _value) public onlyOwner
    // {
    //     require(_value != 0, "Value must greater than zero");
    //     tokensPerEther = _value;
    // }

    function remainingTokens() public view returns (uint256)
    {
        return this.allowance(owner(), address(this));
    }

    function transfer(address _to, uint256 _value) public notFreezed returns (bool)
    {
        return super.transfer(_to, _value);
    }

    /**
   * @dev Owner pay gas and get tranfer fee by XRM.
   * @param _from Address of sender
   * @param _to Address of receiver
   * @param _value Amount of LCH to transfer
   */
    function feedTransfer( address _from, address _to, uint256 _value ) public onlyOwner returns(bool)
    {   // Owner가 가스비를 지불하고, LCH을 전송해주면서 수수료를 LCH로 받는다.
        require(_value <= balanceOf(msg.sender), "Not enough balance");
        require(_to != address(0), "Receiver address cannot be zero");

        require(!freezed[_from], "Sender account is freezed!");
        require(!freezed[_to], "Receiver account is freezed!");
        require(_value > transferFee, "Value must greater than transaction fee");

        uint256 transferValue = _value.sub(transferFee);
        _transfer(_from, _to, transferValue);
        _transfer(_from, msg.sender, transferFee);
        return true;
    }

    function transferFrom(address _from, address _to, uint256 _value) public returns (bool)
    {
        require(!freezed[_from], "Spender account is freezed!");
        return super.transferFrom(_from, _to, _value);
    }

    function approve(address _spender, uint256 _value) public returns (bool)
    {
        require(!freezed[_spender], "Spender account is freezed!");
        return super.approve(_spender, _value);
    }

    // function purchase() public payable
    // {
    //     require(msg.value != 0, "Value must greater than zero");
    //     uint256 weiAmount = msg.value;
    //     uint256 tokenAmount = tokensPerEther.mul(weiAmount).div(1 ether);

    //     require(this.transferFrom(owner(), msg.sender, tokenAmount), "No more purchsable tokens");
    //     emit TokenPurchase(msg.sender, msg.value, tokenAmount);
    // }

    // transfer balance to owner
    // function withdrawEther() public onlyOwner
    // {
    //     msg.sender.transfer(address(this).balance);
    // }
}
/**
 * @title Loche Token
 * @dev Capped, Mitable, Burnable, ERC20 Token
 */
function feedTransfer( address _from, address _to, uint256 _value ) public onlyOwner returns(bool)
    {   // Owner가 가스비를 지불하고, LCH을 전송해주면서 수수료를 LCH로 받는다.
        require(_value <= balanceOf(msg.sender), "Not enough balance");
        require(_to != address(0), "Receiver address cannot be zero");

        require(!freezed[_from], "Sender account is freezed!");
        require(!freezed[_to], "Receiver account is freezed!");
        require(_value > transferFee, "Value must greater than transaction fee");

        uint256 transferValue = _value.sub(transferFee);
        _transfer(_from, _to, transferValue);
        _transfer(_from, msg.sender, transferFee);
        return true;
    }
/**
 * @dev Owner pay gas and get tranfer fee by XRM.
 * @param _from Address of sender
 * @param _to Address of receiver
 * @param _value Amount of LCH to transfer
 */