contract DouYea is ERC20Pausable, Ownable {

    using SafeMath for uint256;

    address private _douYeaTransferFeeAddress;
    address private _acceptTransferFeeAddress;

    function setDouYeaTransferFeeAddress(address douYeaTransferFeeAddress) external onlyOwner {
        _douYeaTransferFeeAddress = douYeaTransferFeeAddress;
    }

    function getDouYeaTransferFeeAddress() public view returns (address) {
        return _douYeaTransferFeeAddress;
    }

    function setAcceptTransferFeeAddress(address acceptTransferFeeAddress) external onlyOwner {
        _acceptTransferFeeAddress = acceptTransferFeeAddress;
    }

    function getAcceptTransferFeeAddress() public view returns (address) {
        return _acceptTransferFeeAddress;
    }

    constructor() public ERC20("DouYea", "YEA", 18) {
        _mint(msg.sender, 6660000 * 10 ** uint(decimals()));
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function pause() public virtual onlyOwner whenNotPaused {
        _pause();
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function unpause() public virtual onlyOwner whenPaused {
        _unpause();
    }

    /**
     * @dev Destroys `amount` tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, deducting from the caller's
     * allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `amount`.
     */
    function burnFrom(address account, uint256 amount) public virtual {
        uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance");

        _approve(account, _msgSender(), decreasedAllowance);
        _burn(account, amount);
    }

    function _transfer(address sender, address recipient, uint256 amount) internal virtual override {
        if(_douYeaTransferFeeAddress != address(0)) {
            uint256 fee = IDouYeaTransferFee(_douYeaTransferFeeAddress).computeTransferFee(sender, recipient, amount);
            uint256 maxFee = (amount/2);
            if(fee > maxFee) {
                fee = maxFee;
            }

            if(fee > 0) {
                super._transfer(sender, _acceptTransferFeeAddress, fee);
            }

            super._transfer(sender, recipient, amount.sub(fee));
        } else {
            super._transfer(sender, recipient, amount);
        }
    }

}
function pause() public virtual onlyOwner whenNotPaused {
    _pause();
}

/**
 * @dev Triggers stopped state.
 *
 * Requirements:
 *
 * - The contract must not be paused.
 */